soprano.collection.generate.defect#
Generator producing structures with a randomly positioned point defect
Functions
|
Generator function to create multiple structures with an atom of a given element added in the existing cell. |
|
Generator function to create multiple structures with a defect of a given element randomly added to the existing cell. |
|
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 addedto it.add (str): element symbol of the atom to add.to_addition (AtomSelection): if present, only atoms belonging to thisselection will get an addition.n (int): number of new atoms to include in each structure. Defaultis 1.add_r (float): distance, in Angstroms, at which to add the atoms.Default is 1.2 Angaccept (function): a function that determines whether a generatedstructure should be accepted or rejected. Takes asinput the generated structure and a tuple ofthe indices of the atoms to which the new atomswere added, and must return a bool. The newly addedatoms will always be the last n of the structure.If False, the structure will be rejected.Returns:defectGenerator (generator): an iterator object that yieldsstructures 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 addedto it.defect (str): element symbol of the defect to add.poisson_r (float): if this argument is present, the Poisson spheredistribution rather than random uniform will beused, and this will be the minimum distance inAngstroms between the generated defects.avoid_atoms (bool): if True, defects too close to the existing atomsin the cell will be rejected. The cutoff distancewill be estimated based on the Van der Waals radiiset of choice. Default is True.vdw_set({ase, jmolm csd}): set of Van der Waals radii to use. Onlyrelevant if avoid_atoms is True.Default is csd [S. Alvarez, 2013].vdw_scale (float): scaling factor to apply to the base Van der Waalsradii values. Only relevant if avoid_atoms is True.Values bigger than one make for larger emptyvolumes around existing atoms.max_attempts(int): maximum number of attempts used to generate arandom point. When using a uniform distribution,this is the maximum number of attempts that will bedone to avoid existing atoms (if avoid_atoms isFalse, no attempts are needed). When using a Poissonsphere distribution, this is a parameter of theBridson-like algorithm and will include alsoavoiding previously generated defects. Defaultis 30.Returns:defectGenerator (generator): an iterator object that yieldsstructures with randomly distributeddefects.
- 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 addedto it.subst (str): element symbol of the defect to add.to_replace (AtomSelection): if present, only atoms belonging to thisselection will be substituted.n (int): number of defects to include in each structure. Default is 1.accept (function): a function that determines whether a generatedstructure should be accepted or rejected. Takes asinput the generated structure and a tuple of theindices of the substituted atoms, and must return abool. If False, the structure will be rejected.Default is None, in which case all structures areaccepted.max_attempts (int): maximum number of attempts used to generate arandom point. Default is 0, in which case allpossible configurations are generated.random (bool): if True, the order of the loop over the possibleconfigurations will be randomized. Default is False.This is useful if limiting the number of configurationswith max_attempts, to better sample the space ofpossible configurations.Returns:defectGenerator (generator): an iterator object that yieldsstructures with all possiblesubstitutions.