class ChargeBalanceTransformation(charge_balance_sp)[source]

This is a transformation that disorders a structure to make it charge balanced, given an oxidation state-decorated structure.

Parameters

charge_balance_sp – specie to add or remove. Currently only removal is supported

apply_transformation(structure)[source]

Applies the transformation to a structure. Depending on whether a transformation is one-to-many, there may be an option to return a ranked list of structures.

Parameters
• structure – input structure

• return_ranked_list – Boolean stating whether or not multiple structures are returned. If return_ranked_list is a number, that number of structures is returned.

Returns

depending on returned_ranked list, either a transformed structure or a list of dictionaries, where each dictionary is of the form {‘structure’ = …. , ‘other_arguments’} the key ‘transformation’ is reserved for the transformation that was actually applied to the structure. This transformation is parsed by the alchemy classes for generating a more specific transformation history. Any other information will be stored in the transformation_parameters dictionary in the transmuted structure class.

inverse

Returns the inverse transformation if available. Otherwise, should return None.

is_one_to_many

Determines if a Transformation is a one-to-many transformation. If a Transformation is a one-to-many transformation, the apply_transformation method should have a keyword arg “return_ranked_list” which allows for the transformed structures to be returned as a ranked list.

class DisorderOrderedTransformation(max_sites_to_merge=2)[source]

Not to be confused with OrderDisorderedTransformation, this transformation attempts to obtain a disordered structure from an input ordered structure. This may or may not be physically plausible, further inspection of the returned structures is advised. The main purpose for this transformation is for structure matching to crystal prototypes for structures that have been derived from a parent prototype structure by substitutions or alloying additions.

Parameters

max_sites_to_merge – only merge this number of sites together

apply_transformation(structure, return_ranked_list=False)[source]
Parameters
• structure – ordered structure

• return_ranked_list – as in other pymatgen Transformations

Returns: transformed disordered structure(s)

inverse

Returns the inverse transformation if available. Otherwise, should return None.

is_one_to_many

Determines if a Transformation is a one-to-many transformation. If a Transformation is a one-to-many transformation, the apply_transformation method should have a keyword arg “return_ranked_list” which allows for the transformed structures to be returned as a ranked list.

class DopingTransformation(dopant, ionic_radius_tol=inf, min_length=10, alio_tol=0, codopant=False, max_structures_per_enum=100, allowed_doping_species=None, **kwargs)[source]

A transformation that performs doping of a structure.

Parameters
• dopant (Specie-like) – E.g., Al3+. Must have oxidation state.

• ionic_radius_tol (float) – E.g., Fractional allowable ionic radii mismatch for dopant to fit into a site. Default of inf means that any dopant with the right oxidation state is allowed.

• min_Length (float) – Min. lattice parameter between periodic images of dopant. Defaults to 10A for now.

• alio_tol (int) – If this is not 0, attempt will be made to dope sites with oxidation_states +- alio_tol of the dopant. E.g., 1 means that the ions like Ca2+ and Ti4+ are considered as potential doping sites for Al3+.

• codopant (bool) – If True, doping will be carried out with a codopant to maintain charge neutrality. Otherwise, vacancies will be used.

• max_structures_per_enum (float) – Maximum number of structures to return per enumeration. Note that there can be more than one candidate doping site, and each site enumeration will return at max max_structures_per_enum structures. Defaults to 100.

• allowed_doping_species (list) – Species that are allowed to be doping sites. This is an inclusionary list. If specified, any sites which are not

• **kwargs – Same keyword args as EnumerateStructureTransformation, i.e., min_cell_size, etc.

apply_transformation(structure, return_ranked_list=False)[source]
Parameters

structure (Structure) – Input structure to dope

Returns

Structure, “energy”: float}]

Return type

[{“structure”

inverse

Returns the inverse transformation if available. Otherwise, should return None.

is_one_to_many

Determines if a Transformation is a one-to-many transformation. If a Transformation is a one-to-many transformation, the apply_transformation method should have a keyword arg “return_ranked_list” which allows for the transformed structures to be returned as a ranked list.

class EnumerateStructureTransformation(min_cell_size=1, max_cell_size=1, symm_prec=0.1, refine_structure=False, enum_precision_parameter=0.001, check_ordered_symmetry=True, max_disordered_sites=None, sort_criteria='ewald', timeout=None)[source]

Order a disordered structure using enumlib. For complete orderings, this generally produces fewer structures that the OrderDisorderedStructure transformation, and at a much faster speed.

Parameters
• min_cell_size – The minimum cell size wanted. Must be an int. Defaults to 1.

• max_cell_size – The maximum cell size wanted. Must be an int. Defaults to 1.

• symm_prec – Tolerance to use for symmetry.

• refine_structure – This parameter has the same meaning as in enumlib_caller. If you are starting from a structure that has been relaxed via some electronic structure code, it is usually much better to start with symmetry determination and then obtain a refined structure. The refined structure have cell parameters and atomic positions shifted to the expected symmetry positions, which makes it much less sensitive precision issues in enumlib. If you are already starting from an experimental cif, refinment should have already been done and it is not necessary. Defaults to False.

• enum_precision_parameter (float) – Finite precision parameter for enumlib. Default of 0.001 is usually ok, but you might need to tweak it for certain cells.

• check_ordered_symmetry (bool) – Whether to check the symmetry of the ordered sites. If the symmetry of the ordered sites is lower, the lowest symmetry ordered sites is included in the enumeration. This is important if the ordered sites break symmetry in a way that is important getting possible structures. But sometimes including ordered sites slows down enumeration to the point that it cannot be completed. Switch to False in those cases. Defaults to True.

• max_disordered_sites (int) – An alternate parameter to max_cell size. Will sequentially try larger and larger cell sizes until (i) getting a result or (ii) the number of disordered sites in the cell exceeds max_disordered_sites. Must set max_cell_size to None when using this parameter.

• sort_criteria (str) – Sort by Ewald energy (“ewald”, must have oxidation states and slow) or by number of sites (“nsites”, much faster).

• timeout (float) – timeout in minutes to pass to EnumlibAdaptor

apply_transformation(structure, return_ranked_list=False)[source]

Return either a single ordered structure or a sequence of all ordered structures.

Parameters
• structure – Structure to order.

• return_ranked_list (bool) – Whether or not multiple structures are returned. If return_ranked_list is a number, that number of structures is returned.

Returns

Depending on returned_ranked list, either a transformed structure or a list of dictionaries, where each dictionary is of the form {“structure” = …. , “other_arguments”}

The list of ordered structures is ranked by ewald energy / atom, if the input structure is an oxidation state decorated structure. Otherwise, it is ranked by number of sites, with smallest number of sites first.

inverse

Returns the inverse transformation if available. Otherwise, should return None.

is_one_to_many

Determines if a Transformation is a one-to-many transformation. If a Transformation is a one-to-many transformation, the apply_transformation method should have a keyword arg “return_ranked_list” which allows for the transformed structures to be returned as a ranked list.

class GrainBoundaryTransformation(rotation_axis, rotation_angle, expand_times=4, vacuum_thickness=0.0, ab_shift=[0, 0], normal=False, ratio=None, plane=None, max_search=50, tol_coi=0.001)[source]

A transformation that creates a gb from a bulk structure.

Parameters
• rotation_axis (list) – Rotation axis of GB in the form of a list of integer e.g.: [1, 1, 0]

• rotation_angle (float, in unit of degree) – rotation angle used to generate GB. Make sure the angle is accurate enough. You can use the enum* functions in this class to extract the accurate angle. e.g.: The rotation angle of sigma 3 twist GB with the rotation axis [1, 1, 1] and GB plane (1, 1, 1) can be 60.000000000 degree. If you do not know the rotation angle, but know the sigma value, we have provide the function get_rotation_angle_from_sigma which is able to return all the rotation angles of sigma value you provided.

• expand_times (int) – The multiple times used to expand one unit grain to larger grain. This is used to tune the grain length of GB to warrant that the two GBs in one cell do not interact with each other. Default set to 4.

• vacuum_thickness (float) – The thickness of vacuum that you want to insert between two grains of the GB. Default to 0.

• ab_shift (list of float, in unit of a, b vectors of Gb) – in plane shift of two grains

• normal (logic) – determine if need to require the c axis of top grain (first transformation matrix) perperdicular to the surface or not. default to false.

• ratio (list of integers) – lattice axial ratio. For cubic system, ratio is not needed. For tetragonal system, ratio = [mu, mv], list of two integers, that is, mu/mv = c2/a2. If it is irrational, set it to none. For orthorhombic system, ratio = [mu, lam, mv], list of three integers, that is, mu:lam:mv = c2:b2:a2. If irrational for one axis, set it to None. e.g. mu:lam:mv = c2,None,a2, means b2 is irrational. For rhombohedral system, ratio = [mu, mv], list of two integers, that is, mu/mv is the ratio of (1+2*cos(alpha))/cos(alpha). If irrational, set it to None. For hexagonal system, ratio = [mu, mv], list of two integers, that is, mu/mv = c2/a2. If it is irrational, set it to none.

• plane (list) – Grain boundary plane in the form of a list of integers e.g.: [1, 2, 3]. If none, we set it as twist GB. The plane will be perpendicular to the rotation axis.

• max_search (int) – max search for the GB lattice vectors that give the smallest GB lattice. If normal is true, also max search the GB c vector that perpendicular to the plane. For complex GB, if you want to speed up, you can reduce this value. But too small of this value may lead to error.

• tol_coi (float) – tolerance to find the coincidence sites. When making approximations to the ratio needed to generate the GB, you probably need to increase this tolerance to obtain the correct number of coincidence sites. To check the number of coincidence sites are correct or not, you can compare the generated Gb object’s sigma with enum* sigma values (what user expected by input).

Returns

Grain boundary structure (Gb (Structure) object).

apply_transformation(structure)[source]

Applies the transformation to a structure. Depending on whether a transformation is one-to-many, there may be an option to return a ranked list of structures.

Parameters
• structure – input structure

• return_ranked_list – Boolean stating whether or not multiple structures are returned. If return_ranked_list is a number, that number of structures is returned.

Returns

depending on returned_ranked list, either a transformed structure or a list of dictionaries, where each dictionary is of the form {‘structure’ = …. , ‘other_arguments’} the key ‘transformation’ is reserved for the transformation that was actually applied to the structure. This transformation is parsed by the alchemy classes for generating a more specific transformation history. Any other information will be stored in the transformation_parameters dictionary in the transmuted structure class.

inverse

Returns the inverse transformation if available. Otherwise, should return None.

is_one_to_many

Determines if a Transformation is a one-to-many transformation. If a Transformation is a one-to-many transformation, the apply_transformation method should have a keyword arg “return_ranked_list” which allows for the transformed structures to be returned as a ranked list.

class MagOrderParameterConstraint(order_parameter, species_constraints=None, site_constraint_name=None, site_constraints=None)[source]

Bases: monty.json.MSONable

This class can be used to supply MagOrderingTransformation to just a specific subset of species or sites that satisfy the provided constraints. This can be useful for setting an order parameters for, for example, ferrimagnetic structures which might order on certain motifs, with the global order parameter dependent on how many sites satisfy that motif.

Parameters

(float) (order_parameter) – any number from 0.0 to 1.0,

typically 0.5 (antiferromagnetic) or 1.0 (ferromagnetic) :param species_constraint (list): str or list of strings of Specie symbols that the constraint should apply to :param site_constraint_name (str): name of the site property that the constraint should apply to, e.g. “coordination_no” :param site_constraints (list): list of values of the site property that the constraints should apply to

satisfies_constraint(site)[source]

Checks if a periodic site satisfies the constraint.

class MagOrderingTransformation(mag_species_spin, order_parameter=0.5, energy_model=<pymatgen.analysis.energy_models.SymmetryModel object>, **kwargs)[source]

This transformation takes a structure and returns a list of collinear magnetic orderings. For disordered structures, make an ordered approximation first.

Parameters

mag_species_spin – A mapping of elements/species to their

spin magnitudes, e.g. {“Fe3+”: 5, “Mn3+”: 4} :param order_parameter (float or list): if float, a specifies a global order parameter and can take values from 0.0 to 1.0 (e.g. 0.5 for antiferromagnetic or 1.0 for ferromagnetic), if list has to be a list of :class: pymatgen.transformations.advanced_transformations.MagOrderParameterConstraint to specify more complicated orderings, see documentation for MagOrderParameterConstraint more details on usage :param energy_model: Energy model to rank the returned structures, see :mod: pymatgen.analysis.energy_models for more information (note that this is not necessarily a physical energy). By default, returned structures use SymmetryModel() which ranks structures from most symmetric to least. :param kwargs: Additional kwargs that are passed to EnumerateStructureTransformation such as min_cell_size etc.

apply_transformation(structure, return_ranked_list=False)[source]

Apply MagOrderTransformation to an input structure. :param structure: Any ordered structure. :param return_ranked_list: As in other Transformations. :return:

static determine_min_cell(disordered_structure)[source]

Determine the smallest supercell that is able to enumerate the provided structure with the given order parameter

inverse

Returns the inverse transformation if available. Otherwise, should return None.

is_one_to_many

Determines if a Transformation is a one-to-many transformation. If a Transformation is a one-to-many transformation, the apply_transformation method should have a keyword arg “return_ranked_list” which allows for the transformed structures to be returned as a ranked list.

class MultipleSubstitutionTransformation(sp_to_replace, r_fraction, substitution_dict, charge_balance_species=None, order=True)[source]

Bases: object

Performs multiple substitutions on a structure. For example, can do a fractional replacement of Ge in LiGePS with a list of species, creating one structure for each substitution. Ordering is done using a dummy element so only one ordering must be done per substitution oxidation state. Charge balancing of the structure is optionally performed.

Note

There are no checks to make sure that removal fractions are possible and rounding may occur. Currently charge balancing only works for removal of species.

Performs multiple fractional substitutions on a transmuter.

Parameters
• sp_to_replace – species to be replaced

• r_fraction – fraction of that specie to replace

• substitution_dict – dictionary of the format {2: [“Mg”, “Ti”, “V”, “As”, “Cr”, “Ta”, “N”, “Nb”], 3: [“Ru”, “Fe”, “Co”, “Ce”, “As”, “Cr”, “Ta”, “N”, “Nb”], 4: [“Ru”, “V”, “Cr”, “Ta”, “N”, “Nb”], 5: [“Ru”, “W”, “Mn”] } The number is the charge used for each of the list of elements (an element can be present in multiple lists)

• charge_balance_species – If specified, will balance the charge on the structure using that specie.

apply_transformation(structure, return_ranked_list=False)[source]
inverse
is_one_to_many
class SlabTransformation(miller_index, min_slab_size, min_vacuum_size, lll_reduce=False, center_slab=False, in_unit_planes=False, primitive=True, max_normal_search=None, shift=0, tol=0.1)[source]

A transformation that creates a slab from a structure.

Parameters
• miller_index (3-tuple or list) – miller index of slab

• min_slab_size (float) – minimum slab size in angstroms

• min_vacuum_size (float) – minimum size of vacuum

• lll_reduce (bool) – whether to apply LLL reduction

• center_slab (bool) – whether to center the slab

• primitive (bool) – whether to reduce slabs to most primitive cell

• max_normal_search (int) – maximum index to include in linear combinations of indices to find c lattice vector orthogonal to slab surface

• shift (float) – shift to get termination

• tol (float) – tolerance for primitive cell finding

apply_transformation(structure)[source]

Applies the transformation to a structure. Depending on whether a transformation is one-to-many, there may be an option to return a ranked list of structures.

Parameters
• structure – input structure

• return_ranked_list – Boolean stating whether or not multiple structures are returned. If return_ranked_list is a number, that number of structures is returned.

Returns

depending on returned_ranked list, either a transformed structure or a list of dictionaries, where each dictionary is of the form {‘structure’ = …. , ‘other_arguments’} the key ‘transformation’ is reserved for the transformation that was actually applied to the structure. This transformation is parsed by the alchemy classes for generating a more specific transformation history. Any other information will be stored in the transformation_parameters dictionary in the transmuted structure class.

inverse

Returns the inverse transformation if available. Otherwise, should return None.

is_one_to_many

Determines if a Transformation is a one-to-many transformation. If a Transformation is a one-to-many transformation, the apply_transformation method should have a keyword arg “return_ranked_list” which allows for the transformed structures to be returned as a ranked list.

class SubstitutionPredictorTransformation(threshold=0.01, scale_volumes=True, **kwargs)[source]

This transformation takes a structure and uses the structure prediction module to find likely site substitutions.

Parameters
• threshold – Threshold for substitution.

• **kwargs – Args for SubstitutionProbability class lambda_table, alpha

apply_transformation(structure, return_ranked_list=False)[source]

Applies the transformation to a structure. Depending on whether a transformation is one-to-many, there may be an option to return a ranked list of structures.

Parameters
• structure – input structure

• return_ranked_list – Boolean stating whether or not multiple structures are returned. If return_ranked_list is a number, that number of structures is returned.

Returns

depending on returned_ranked list, either a transformed structure or a list of dictionaries, where each dictionary is of the form {‘structure’ = …. , ‘other_arguments’} the key ‘transformation’ is reserved for the transformation that was actually applied to the structure. This transformation is parsed by the alchemy classes for generating a more specific transformation history. Any other information will be stored in the transformation_parameters dictionary in the transmuted structure class.

inverse

Returns the inverse transformation if available. Otherwise, should return None.

is_one_to_many

Determines if a Transformation is a one-to-many transformation. If a Transformation is a one-to-many transformation, the apply_transformation method should have a keyword arg “return_ranked_list” which allows for the transformed structures to be returned as a ranked list.

class SuperTransformation(transformations, nstructures_per_trans=1)[source]

This is a transformation that is inherently one-to-many. It is constructed from a list of transformations and returns one structure for each transformation. The primary use for this class is extending a transmuter object.

Parameters
• transformations ([transformations]) – List of transformations to apply to a structure. One transformation is applied to each output structure.

• nstructures_per_trans (int) – If the transformations are one-to-many and, nstructures_per_trans structures from each transformation are added to the full list. Defaults to 1, i.e., only best structure.

apply_transformation(structure, return_ranked_list=False)[source]

Applies the transformation to a structure. Depending on whether a transformation is one-to-many, there may be an option to return a ranked list of structures.

Parameters
• structure – input structure

• return_ranked_list – Boolean stating whether or not multiple structures are returned. If return_ranked_list is a number, that number of structures is returned.

Returns

depending on returned_ranked list, either a transformed structure or a list of dictionaries, where each dictionary is of the form {‘structure’ = …. , ‘other_arguments’} the key ‘transformation’ is reserved for the transformation that was actually applied to the structure. This transformation is parsed by the alchemy classes for generating a more specific transformation history. Any other information will be stored in the transformation_parameters dictionary in the transmuted structure class.

inverse

Returns the inverse transformation if available. Otherwise, should return None.

is_one_to_many

Determines if a Transformation is a one-to-many transformation. If a Transformation is a one-to-many transformation, the apply_transformation method should have a keyword arg “return_ranked_list” which allows for the transformed structures to be returned as a ranked list.