soprano.collection.generate.defect

soprano.collection.generate.defect#

Generator producing structures with a randomly positioned point defect

Functions

additionGen(struct, add[, to_addition, n, ...])

Generator function to create multiple structures with an atom of a given element added in the existing cell.

defectGen(struct, defect[, poisson_r, ...])

Generator function to create multiple structures with a defect of a given element randomly added to the existing cell.

substitutionGen(struct, subst[, to_replace, ...])

Generator function to create multiple structures with a defect of a given element substituted in the existing cell.

soprano.collection.generate.defect.additionGen(struct, add, to_addition=None, n=1, add_r=1.2, accept=None)[source]#

Generator function to create multiple structures with an atom of a given element added in the existing cell. The atoms will be attached to the atoms passed in the to_addition selection. If none is passed, all atoms will be additioned in turn. Multiple defects can be included, in which case all permutations will be generated. The algorithm will try adding the atom in the direction that seems most compatible with all the already existing bonds. If multiple directions satisfy the condition, they will all be tested. It is also possible to reject some configurations based on the output of a filter function.

Args:
struct (ase.Atoms): the starting structure. All atoms will be added
to it.
add (str): element symbol of the atom to add.
to_addition (AtomSelection): if present, only atoms belonging to this
selection will get an addition.
n (int): number of new atoms to include in each structure. Default
is 1.
add_r (float): distance, in Angstroms, at which to add the atoms.
Default is 1.2 Ang
accept (function): a function that determines whether a generated
structure should be accepted or rejected. Takes as
input the generated structure and a tuple of
the indices of the atoms to which the new atoms
were added, and must return a bool. The newly added
atoms will always be the last n of the structure.
If False, the structure will be rejected.
Returns:
defectGenerator (generator): an iterator object that yields
structures with all possible additions.
soprano.collection.generate.defect.defectGen(struct, defect, poisson_r=None, avoid_atoms=True, vdw_set='csd', vdw_scale=1, max_attempts=30)[source]#

Generator function to create multiple structures with a defect of a given element randomly added to the existing cell. The defects can be distributed following a random uniform distribution or a Poisson-sphere distribution which guarantees that no two defects are created closer than a certain distance. These are created using a variation on Bridson’s algorithm. For that reason the defects will be created contiguously and added in succession. A full cover of all the empty space will be provided only by extracting structures until StopIteration is raised.

Args:
struct (ase.Atoms): the starting structure. All defects will be added
to it.
defect (str): element symbol of the defect to add.
poisson_r (float): if this argument is present, the Poisson sphere
distribution rather than random uniform will be
used, and this will be the minimum distance in
Angstroms between the generated defects.
avoid_atoms (bool): if True, defects too close to the existing atoms
in the cell will be rejected. The cutoff distance
will be estimated based on the Van der Waals radii
set of choice. Default is True.
vdw_set({ase, jmolm csd}): set of Van der Waals radii to use. Only
relevant if avoid_atoms is True.
Default is csd [S. Alvarez, 2013].
vdw_scale (float): scaling factor to apply to the base Van der Waals
radii values. Only relevant if avoid_atoms is True.
Values bigger than one make for larger empty
volumes around existing atoms.
max_attempts(int): maximum number of attempts used to generate a
random point. When using a uniform distribution,
this is the maximum number of attempts that will be
done to avoid existing atoms (if avoid_atoms is
False, no attempts are needed). When using a Poisson
sphere distribution, this is a parameter of the
Bridson-like algorithm and will include also
avoiding previously generated defects. Default
is 30.
Returns:
defectGenerator (generator): an iterator object that yields
structures with randomly distributed
defects.
soprano.collection.generate.defect.substitutionGen(struct, subst, to_replace=None, n=1, accept=None, max_attempts=0, random=False)[source]#

Generator function to create multiple structures with a defect of a given element substituted in the existing cell. The defects will be put in place of the atoms passed in the to_replace selection. If none is passed, all atoms will be replaced in turn. Multiple defects can be included, in which case all permutations will be generated. It is also possible to reject some configurations based on the output of a filter function.

Args:
struct (ase.Atoms): the starting structure. All defects will be added
to it.
subst (str): element symbol of the defect to add.
to_replace (AtomSelection): if present, only atoms belonging to this
selection will be substituted.
n (int): number of defects to include in each structure. Default is 1.
accept (function): a function that determines whether a generated
structure should be accepted or rejected. Takes as
input the generated structure and a tuple of the
indices of the substituted atoms, and must return a
bool. If False, the structure will be rejected.
Default is None, in which case all structures are
accepted.
max_attempts (int): maximum number of attempts used to generate a
random point. Default is 0, in which case all
possible configurations are generated.
random (bool): if True, the order of the loop over the possible
configurations will be randomized. Default is False.
This is useful if limiting the number of configurations
with max_attempts, to better sample the space of
possible configurations.
Returns:
defectGenerator (generator): an iterator object that yields
structures with all possible
substitutions.