Commit 83773159 authored by Malthe Kjær Bisbo's avatar Malthe Kjær Bisbo
Browse files

fixed dublicate initial structures in output trajectory

parent b5c348c0
from candidate_operations.candidate_generation import CandidateGenerator, StartGenerator
from candidate_operations.basic_mutations import RattleMutation, PermutationMutation
__all__ = ['CandidateGenerator', 'StartGenerator', 'RattleMutation', 'PermutationMutation']
......@@ -33,27 +33,36 @@ def pos_add_sphere_shell(rmin, rmax):
class RattleMutation(OffspringOperation):
"""Class to perform rattle mutations on structures.
Rattles a number of randomly selected atoms within a sphere
of radius 'rattle_range' of their original positions.
Parameters:
n_top: The number of atoms to optimize. Specifically the
atoms with indices [-n_top:] are optimized.
n_top: int
The number of atoms to optimize. Specifically the
atoms with indices [-n_top:] are optimized.
Nrattle: The average number of atoms to rattle.
Nrattle: float
The average number of atoms to rattle.
rattle_range: The maximum distance within witch to rattle the
atoms. Atoms are rattled uniformly within a sphere of this
radius.
rattle_range: float
The maximum distance within witch to rattle the
atoms. Atoms are rattled uniformly within a sphere of this
radius.
blmin: The minimum allowed distance between atoms in units of
the covalent distance between atoms, where d_cov=r_cov_i+r_cov_j.
blmin: float
The minimum allowed distance between atoms in units of
the covalent distance between atoms, where d_cov=r_cov_i+r_cov_j.
blmax: The maximum allowed distance, in units of the covalent
distance, from a single isolated atom to the closest atom. If
blmax=None, no constraint is enforced on isolated atoms.
description: Name of the operation, which will be saved in
info-dict of structures, on which the operation is applied.
blmax: float
The maximum allowed distance, in units of the covalent
distance, from a single isolated atom to the closest atom. If
blmax=None, no constraint is enforced on isolated atoms.
description: str
Name of the operation, which will be saved in
info-dict of structures, on which the operation is applied.
"""
def __init__(self, n_top, Nrattle=3, rattle_range=3,
description='RattleMutation', *args, **kwargs):
......@@ -110,23 +119,31 @@ class RattleMutation(OffspringOperation):
class RattleMutation2(OffspringOperation):
"""Class to perform rattle mutations on structures.
Rattles a number of randomly selected atom to the visinity
of other candomly selected atoms random atom.
Parameters:
n_top: The number of atoms to optimize. Specifically the
atoms with indices [-n_top:] are optimized.
n_top: int
The number of atoms to optimize. Specifically the
atoms with indices [-n_top:] are optimized.
Nrattle: The average number of atoms to rattle.
Nrattle: float
The average number of atoms to rattle.
blmin: The minimum allowed distance between atoms in units of
the covalent distance between atoms, where d_cov=r_cov_i+r_cov_j.
blmin: float
The minimum allowed distance between atoms in units of
the covalent distance between atoms, where d_cov=r_cov_i+r_cov_j.
blmax: The maximum allowed distance, in units of the covalent
distance, from a single isolated atom to the closest atom. If
blmax=None, no constraint is enforced on isolated atoms.
description: Name of the operation, which will be saved in
info-dict of structures, on which the operation is applied.
blmax: float
The maximum allowed distance, in units of the covalent
distance, from a single isolated atom to the closest atom. If
blmax=None, no constraint is enforced on isolated atoms.
description: str
Name of the operation, which will be saved in
info-dict of structures, on which the operation is applied.
"""
def __init__(self, n_top, Nrattle=3, description='RattleMutation',
*args, **kwargs):
......@@ -189,23 +206,30 @@ class RattleMutation2(OffspringOperation):
class PermutationMutation(OffspringOperation):
"""Class to perform permutation mutations on structures.
Swaps the positions of a number of pairs of unlike atoms.
Parameters:
n_top: The number of atoms to optimize. Specifically the
atoms with indices [-n_top:] are optimized.
n_top: int
The number of atoms to optimize. Specifically the
atoms with indices [-n_top:] are optimized.
Npermute: The average number of permutations to perform.
Npermute: float
The average number of permutations to perform.
blmin: The minimum allowed distance between atoms in units of
the covalent distance between atoms, where d_cov=r_cov_i+r_cov_j.
blmin: float
The minimum allowed distance between atoms in units of
the covalent distance between atoms, where d_cov=r_cov_i+r_cov_j.
blmax: The maximum allowed distance, in units of the covalent
distance, from a single isolated atom to the closest atom. If
blmax=None, no constraint is enforced on isolated atoms.
blmax: float
The maximum allowed distance, in units of the covalent
distance, from a single isolated atom to the closest atom. If
blmax=None, no constraint is enforced on isolated atoms.
description: Name of the operation, which will be saved in
info-dict of structures, on which the operation is applied.
description: str
Name of the operation, which will be saved in
info-dict of structures, on which the operation is applied.
"""
def __init__(self, n_top, Npermute=3,
......
......@@ -131,10 +131,16 @@ class CandidateGenerator():
'operations'-list. The operations are drawn randomly according
to the 'probabilities'-list.
operations : "list" or "list of lists" of mutations/crossovers.
probabilities : probability for each of the mutations/crossovers
in operations. Must have the same dimensions as operations.
operations : list or list of lists
Defines the operations to generate new candidates in GOFEE.
of mutations/crossovers. Either a list of mutations, e.g. the
RattleMutation, or alternatively a list of lists of such mutations,
in which case consecutive operations, one drawn from each list,
are performed.
probabilities : list or list of lists
probability for each of the mutations/crossovers
in operations. Must have the same dimensions as operations.
"""
def __init__(self, probabilities, operations):
cond1 = isinstance(operations[0], list)
......@@ -246,33 +252,40 @@ class OperationConstraint():
class StartGenerator(OffspringOperation):
""" Class used to generate random initial candidates.
The candidates are generated by iteratively adding in
one atom at a time within the box described.
Generates new candidates by iteratively adding
one atom at a time within a user-defined box.
Parameters:
slab: The atoms object describing the super cell to
optimize within. Can be an empty cell or a cell
containing the atoms of a slab.
slab: Atoms object
The atoms object describing the super cell to
optimize within. Can be an empty cell or a cell
containing the atoms of a slab.
stoichiometry: A list of atomic numbers for the atoms
that are placed on top of the slab (if one is present).
stoichiometry: list
A list of atomic numbers for the atoms
that are placed on top of the slab (if one is present).
box_to_place_in: The box within which atoms are placed. The box
should be on the form [p0, vspan] where 'p0' is the position of
the box corner and 'vspan' is a matrix containing the three
spanning vectors.
box_to_place_in: list
The box within which atoms are placed. The box
should be on the form [p0, vspan] where 'p0' is the position of
the box corner and 'vspan' is a matrix containing the three
spanning vectors.
blmin: The minimum allowed distance between atoms in units of
the covalent distance between atoms, where d_cov=r_cov_i+r_cov_j.
blmin: float
The minimum allowed distance between atoms in units of
the covalent distance between atoms, where d_cov=r_cov_i+r_cov_j.
blmax: The maximum allowed distance, in units of the covalent
distance, from a single isolated atom to the closest atom. If
blmax=None, no constraint is enforced on isolated atoms.
cluster: If True atoms are required to be placed within
blmin*d_cov of one of the other atoms to be placed. If
False the atoms in the slab are also included.
blmax: float
The maximum allowed distance, in units of the covalent
distance, from a single isolated atom to the closest atom. If
blmax=None, no constraint is enforced on isolated atoms.
cluster: bool
If True atoms are required to be placed within
blmin*d_cov of one of the other atoms to be placed. If
False the atoms in the slab are also included.
"""
def __init__(self, slab, stoichiometry, box_to_place_in,
cluster=False, description='StartGenerator',
......
......@@ -2,30 +2,57 @@
=====
GOFEE
=====
Below an overview of the inputs to GOFEE is shown. Many of the inputs
can be safely kept at default settings. However ``calc``, defining the
calculator, as well as either ``startgenerator`` or ``structures``,
defining the system, must always be set.
In addition it is recomended to also set the ``candidate_generatior``.
.. autoclass:: gofee.GOFEE
:members:
Surrogate
=========
.. .. autoclass:: surrogate.gpr.GPR
:members:
Kernel
======
:members: run
StartGenerator
==============
The :class:`StartGenerator` is used to generate initial structures for
the search. In addition it can be used to generate new candidates during
the search, if it is included as an operation in the
:class:`CandidateGenerator`.
.. autoclass:: candidate_operations.candidate_generation.StartGenerator
:exclude-members:
CandidateGenerator
==================
The :class:`CandidateGenerator` is used in each iteration in the GOFEE search
to generate new candidates based on a list on operations to use. Possible
operation can be found below under the "Mutations" section.
.. autoclass:: candidate_operations.candidate_generation.CandidateGenerator
:members: get_new_candidate
.. .. autoclass:: candidate_operations.CandidateGenerator
:members: get_new_candidate
Mutations
=========
The mutations to chose from are listed below.
RattleMutation
==============
--------------
.. autoclass:: candidate_operations.basic_mutations.RattleMutation
:exclude-members:
RattleMutation2
---------------
.. autoclass:: candidate_operations.basic_mutations.RattleMutation2
:exclude-members:
PermutationMutation
===================
\ No newline at end of file
-------------------
.. autoclass:: candidate_operations.basic_mutations.PermutationMutation
:exclude-members:
\ No newline at end of file
.. _slurm:
==================
SLURM job examples
==================
If you are running your calculations on a cluster using
SLURM for job management, you can use a jobscript like
this (propperly modified for your setup)::
#!/bin/bash
#SBATCH --job-name=GOFEE_test
#SBATCH --partition=<desired partitions>
#SBATCH --mem=30G
#SBATCH --nodes=1
#SBATCH --time=2:00:00
##SBATCH --exclusive
#SBATCH --ntasks-per-node=10
#SBATCH --cpus-per-task=1
echo "========= Job started at `date` =========="
# Go to the directory where this job was submitted
cd $SLURM_SUBMIT_DIR
export PYTHONPATH=<path to GOFEE code>:$PYTHONPATH
source <python stuff>
source <GPAW stuff>
source <DFTB stuff> # if running DFTB
mpiexec --mca mpi_warn_on_fork 0 gpaw-python run_search.py > search.log
echo "========= Job finished at `date` =========="
This job will be run locally in the submission folder on 10 cpu cores.
NOTE: for this jobscript, the submission folder must contain a file
"run_search.py", which runs GOFEE as described in the
:ref:`tutorial <tutorial>`.
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment