INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Extracts a cluster of atoms based on bond lengths
def extract_cluster(self, target_sites, **kwargs): """ Extracts a cluster of atoms based on bond lengths Args: target_sites ([Site]): List of initial sites to nucleate cluster. \\*\\*kwargs: kwargs passed through to CovalentBond.is_bonded. Returns: [...
Convenience constructor to make a Structure from a list of sites.
def from_sites(cls, sites, charge=None, validate_proximity=False, to_unit_cell=False): """ Convenience constructor to make a Structure from a list of sites. Args: sites: Sequence of PeriodicSites. Sites must have the same lattice. valid...
Generate a structure using a spacegroup. Note that only symmetrically distinct species and coords should be provided. All equivalent sites are generated from the spacegroup operations.
def from_spacegroup(cls, sg, lattice, species, coords, site_properties=None, coords_are_cartesian=False, tol=1e-5): """ Generate a structure using a spacegroup. Note that only symmetrically distinct species and coords should be provided. All equivalent sites are g...
Generate a structure using a magnetic spacegroup. Note that only symmetrically distinct species coords and magmoms should be provided. ] All equivalent sites are generated from the spacegroup operations.
def from_magnetic_spacegroup( cls, msg, lattice, species, coords, site_properties, transform_setting=None, coords_are_cartesian=False, tol=1e-5): """ Generate a structure using a magnetic spacegroup. Note that only symmetrically distinct species, coords and magmoms should...
Returns the density in units of g/ cc
def density(self): """ Returns the density in units of g/cc """ m = Mass(self.composition.weight, "amu") return m.to("g") / (self.volume * Length(1, "ang").to("cm") ** 3)
Convenience method to quickly get the spacegroup of a structure.
def get_space_group_info(self, symprec=1e-2, angle_tolerance=5.0): """ Convenience method to quickly get the spacegroup of a structure. Args: symprec (float): Same definition as in SpacegroupAnalyzer. Defaults to 1e-2. angle_tolerance (float): Same defini...
Check whether this structure is similar to another structure. Basically a convenience method to call structure matching fitting.
def matches(self, other, **kwargs): """ Check whether this structure is similar to another structure. Basically a convenience method to call structure matching fitting. Args: other (IStructure/Structure): Another structure. **kwargs: Same **kwargs as in ...
Get distance between site i and j assuming periodic boundary conditions. If the index jimage of two sites atom j is not specified it selects the jimage nearest to the i atom and returns the distance and jimage indices in terms of lattice vector translations if the index jimage of atom j is specified it returns the dist...
def get_distance(self, i, j, jimage=None): """ Get distance between site i and j assuming periodic boundary conditions. If the index jimage of two sites atom j is not specified it selects the jimage nearest to the i atom and returns the distance and jimage indices in terms of lat...
Find all sites within a sphere from the point. This includes sites in other periodic images.
def get_sites_in_sphere(self, pt, r, include_index=False, include_image=False): """ Find all sites within a sphere from the point. This includes sites in other periodic images. Algorithm: 1. place sphere of radius r in crystal and determine minimum supercell (paralle...
Get all neighbors to a site within a sphere of radius r. Excludes the site itself.
def get_neighbors(self, site, r, include_index=False, include_image=False): """ Get all neighbors to a site within a sphere of radius r. Excludes the site itself. Args: site (Site): Which is the center of the sphere. r (float): Radius of sphere. incl...
Get neighbors for each atom in the unit cell out to a distance r Returns a list of list of neighbors for each site in structure. Use this method if you are planning on looping over all sites in the crystal. If you only want neighbors for a particular site use the method get_neighbors as it may not have to build such a ...
def get_all_neighbors(self, r, include_index=False, include_image=False): """ Get neighbors for each atom in the unit cell, out to a distance r Returns a list of list of neighbors for each site in structure. Use this method if you are planning on looping over all sites in the cry...
Returns all sites in a shell centered on origin ( coords ) between radii r - dr and r + dr.
def get_neighbors_in_shell(self, origin, r, dr, include_index=False, include_image=False): """ Returns all sites in a shell centered on origin (coords) between radii r-dr and r+dr. Args: origin (3x1 array): Cartesian coordinates of center of sphere. r (float): In...
Get a sorted copy of the structure. The parameters have the same meaning as in list. sort. By default sites are sorted by the electronegativity of the species.
def get_sorted_structure(self, key=None, reverse=False): """ Get a sorted copy of the structure. The parameters have the same meaning as in list.sort. By default, sites are sorted by the electronegativity of the species. Args: key: Specifies a function of one argumen...
Get a reduced structure.
def get_reduced_structure(self, reduction_algo="niggli"): """ Get a reduced structure. Args: reduction_algo (str): The lattice reduction algorithm to use. Currently supported options are "niggli" or "LLL". """ if reduction_algo == "niggli": ...
Convenience method to get a copy of the structure with options to add site properties.
def copy(self, site_properties=None, sanitize=False): """ Convenience method to get a copy of the structure, with options to add site properties. Args: site_properties (dict): Properties to add or override. The properties are specified in the same way as the ...
Interpolate between this structure and end_structure. Useful for construction of NEB inputs.
def interpolate(self, end_structure, nimages=10, interpolate_lattices=False, pbc=True, autosort_tol=0): """ Interpolate between this structure and end_structure. Useful for construction of NEB inputs. Args: end_structure (Structure): structure to interpol...
Get the Miller index of a plane from a set of sites indexes.
def get_miller_index_from_site_indexes(self, site_ids, round_dp=4, verbose=True): """ Get the Miller index of a plane from a set of sites indexes. A minimum of 3 sites are required. If more than 3 sites are given the best plane that minimises t...
This finds a smaller unit cell than the input. Sometimes it doesn t find the smallest possible one so this method is recursively called until it is unable to find a smaller cell.
def get_primitive_structure(self, tolerance=0.25, use_site_props=False, constrain_latt=None): """ This finds a smaller unit cell than the input. Sometimes it doesn"t find the smallest possible one, so this method is recursively called until it is unable to...
Dict representation of Structure.
def as_dict(self, verbosity=1, fmt=None, **kwargs): """ Dict representation of Structure. Args: verbosity (int): Verbosity level. Default of 1 includes both direct and cartesian coordinates for all sites, lattice parameters, etc. Useful for reading an...
Reconstitute a Structure object from a dict representation of Structure created using as_dict ().
def from_dict(cls, d, fmt=None): """ Reconstitute a Structure object from a dict representation of Structure created using as_dict(). Args: d (dict): Dict representation of structure. Returns: Structure object """ if fmt == "abivars": ...
Outputs the structure to a file or string.
def to(self, fmt=None, filename=None, **kwargs): """ Outputs the structure to a file or string. Args: fmt (str): Format to output to. Defaults to JSON unless filename is provided. If fmt is specifies, it overrides whatever the filename is. Options inc...
Reads a structure from a string.
def from_str(cls, input_string, fmt, primitive=False, sort=False, merge_tol=0.0): """ Reads a structure from a string. Args: input_string (str): String to parse. fmt (str): A format specification. primitive (bool): Whether to find a primitive...
Reads a structure from a file. For example anything ending in a cif is assumed to be a Crystallographic Information Format file. Supported formats include CIF POSCAR/ CONTCAR CHGCAR LOCPOT vasprun. xml CSSR Netcdf and pymatgen s JSON serialized structures.
def from_file(cls, filename, primitive=False, sort=False, merge_tol=0.0): """ Reads a structure from a file. For example, anything ending in a "cif" is assumed to be a Crystallographic Information Format file. Supported formats include CIF, POSCAR/CONTCAR, CHGCAR, LOCPOT, vasprun...
Center of mass of molecule.
def center_of_mass(self): """ Center of mass of molecule. """ center = np.zeros(3) total_weight = 0 for site in self: wt = site.species.weight center += site.coords * wt total_weight += wt return center / total_weight
Convenience constructor to make a Molecule from a list of sites.
def from_sites(cls, sites, charge=0, spin_multiplicity=None, validate_proximity=False): """ Convenience constructor to make a Molecule from a list of sites. Args: sites ([Site]): Sequence of Sites. charge (int): Charge of molecule. Defaults to 0. ...
Returns two molecules based on breaking the bond between atoms at index ind1 and ind2.
def break_bond(self, ind1, ind2, tol=0.2): """ Returns two molecules based on breaking the bond between atoms at index ind1 and ind2. Args: ind1 (int): Index of first site. ind2 (int): Index of second site. tol (float): Relative tolerance to test. Bas...
Determines the covalent bonds in a molecule.
def get_covalent_bonds(self, tol=0.2): """ Determines the covalent bonds in a molecule. Args: tol (float): The tol to determine bonds in a structure. See CovalentBond.is_bonded. Returns: List of bonds """ bonds = [] for si...
Json - serializable dict representation of Molecule
def as_dict(self): """ Json-serializable dict representation of Molecule """ d = {"@module": self.__class__.__module__, "@class": self.__class__.__name__, "charge": self._charge, "spin_multiplicity": self._spin_multiplicity, "sites": []...
Reconstitute a Molecule object from a dict representation created using as_dict ().
def from_dict(cls, d): """ Reconstitute a Molecule object from a dict representation created using as_dict(). Args: d (dict): dict representation of Molecule. Returns: Molecule object """ sites = [Site.from_dict(sd) for sd in d["sites"]] ...
Find all sites within a sphere from a point.
def get_sites_in_sphere(self, pt, r): """ Find all sites within a sphere from a point. Args: pt (3x1 array): Cartesian coordinates of center of sphere. r (float): Radius of sphere. Returns: [(site, dist) ...] since most of the time, subsequent proces...
Get all neighbors to a site within a sphere of radius r. Excludes the site itself.
def get_neighbors(self, site, r): """ Get all neighbors to a site within a sphere of radius r. Excludes the site itself. Args: site (Site): Site at the center of the sphere. r (float): Radius of sphere. Returns: [(site, dist) ...] since most...
Returns all sites in a shell centered on origin ( coords ) between radii r - dr and r + dr.
def get_neighbors_in_shell(self, origin, r, dr): """ Returns all sites in a shell centered on origin (coords) between radii r-dr and r+dr. Args: origin (3x1 array): Cartesian coordinates of center of sphere. r (float): Inner radius of shell. dr (float...
Creates a Structure from a Molecule by putting the Molecule in the center of a orthorhombic box. Useful for creating Structure for calculating molecules using periodic codes.
def get_boxed_structure(self, a, b, c, images=(1, 1, 1), random_rotation=False, min_dist=1, cls=None, offset=None, no_cross=False): """ Creates a Structure from a Molecule by putting the Molecule in the center of a orthorhombic box. Useful ...
Returns a Molecule centered at the center of mass.
def get_centered_molecule(self): """ Returns a Molecule centered at the center of mass. Returns: Molecule centered with center of mass at origin. """ center = self.center_of_mass new_coords = np.array(self.cart_coords) - center return self.__class__(s...
Outputs the molecule to a file or string.
def to(self, fmt=None, filename=None): """ Outputs the molecule to a file or string. Args: fmt (str): Format to output to. Defaults to JSON unless filename is provided. If fmt is specifies, it overrides whatever the filename is. Options include "xyz",...
Reads the molecule from a string.
def from_str(cls, input_string, fmt): """ Reads the molecule from a string. Args: input_string (str): String to parse. fmt (str): Format to output to. Defaults to JSON unless filename is provided. If fmt is specifies, it overrides whatever the ...
Reads a molecule from a file. Supported formats include xyz gaussian input ( gjf|g03|g09|com|inp ) Gaussian output (. out|and pymatgen s JSON serialized molecules. Using openbabel many more extensions are supported but requires openbabel to be installed.
def from_file(cls, filename): """ Reads a molecule from a file. Supported formats include xyz, gaussian input (gjf|g03|g09|com|inp), Gaussian output (.out|and pymatgen's JSON serialized molecules. Using openbabel, many more extensions are supported but requires openbabel to be ...
Append a site to the structure.
def append(self, species, coords, coords_are_cartesian=False, validate_proximity=False, properties=None): """ Append a site to the structure. Args: species: Species of inserted site coords (3x1 array): Coordinates of inserted site coords_are_ca...
Insert a site to the structure.
def insert(self, i, species, coords, coords_are_cartesian=False, validate_proximity=False, properties=None): """ Insert a site to the structure. Args: i (int): Index to insert site species (species-like): Species of inserted site coords (3x1 ar...
Replace a single site. Takes either a species or a dict of species and occupations.
def replace(self, i, species, coords=None, coords_are_cartesian=False, properties=None): """ Replace a single site. Takes either a species or a dict of species and occupations. Args: i (int): Index of the site in the _sites list. species (species-...
Substitute atom at index with a functional group.
def substitute(self, index, func_grp, bond_order=1): """ Substitute atom at index with a functional group. Args: index (int): Index of atom to substitute. func_grp: Substituent molecule. There are two options: 1. Providing an actual Molecule as the input...
Remove all occurrences of several species from a structure.
def remove_species(self, species): """ Remove all occurrences of several species from a structure. Args: species: Sequence of species to remove, e.g., ["Li", "Na"]. """ new_sites = [] species = [get_el_sp(s) for s in species] for site in self._sites:...
Delete sites with at indices.
def remove_sites(self, indices): """ Delete sites with at indices. Args: indices: Sequence of indices of sites to delete. """ self._sites = [s for i, s in enumerate(self._sites) if i not in indices]
Apply a symmetry operation to the structure and return the new structure. The lattice is operated by the rotation matrix only. Coords are operated in full and then transformed to the new lattice.
def apply_operation(self, symmop, fractional=False): """ Apply a symmetry operation to the structure and return the new structure. The lattice is operated by the rotation matrix only. Coords are operated in full and then transformed to the new lattice. Args: symmop (...
Modify the lattice of the structure. Mainly used for changing the basis.
def modify_lattice(self, new_lattice): """ Modify the lattice of the structure. Mainly used for changing the basis. Args: new_lattice (Lattice): New lattice """ self._lattice = new_lattice for site in self._sites: site.lattice = new_latti...
Apply a strain to the lattice.
def apply_strain(self, strain): """ Apply a strain to the lattice. Args: strain (float or list): Amount of strain to apply. Can be a float, or a sequence of 3 numbers. E.g., 0.01 means all lattice vectors are increased by 1%. This is equivalent to cal...
Sort a structure in place. The parameters have the same meaning as in list. sort. By default sites are sorted by the electronegativity of the species. The difference between this method and get_sorted_structure ( which also works in IStructure ) is that the latter returns a new Structure while this just sorts the Struc...
def sort(self, key=None, reverse=False): """ Sort a structure in place. The parameters have the same meaning as in list.sort. By default, sites are sorted by the electronegativity of the species. The difference between this method and get_sorted_structure (which also works in ISt...
Translate specific sites by some vector keeping the sites within the unit cell.
def translate_sites(self, indices, vector, frac_coords=True, to_unit_cell=True): """ Translate specific sites by some vector, keeping the sites within the unit cell. Args: indices: Integer or List of site indices on which to perform the ...
Rotate specific sites by some angle around vector at anchor.
def rotate_sites(self, indices=None, theta=0, axis=None, anchor=None, to_unit_cell=True): """ Rotate specific sites by some angle around vector at anchor. Args: indices (list): List of site indices on which to perform the translation. ...
Performs a random perturbation of the sites in a structure to break symmetries.
def perturb(self, distance): """ Performs a random perturbation of the sites in a structure to break symmetries. Args: distance (float): Distance in angstroms by which to perturb each site. """ def get_rand_vec(): # deals with zer...
Create a supercell.
def make_supercell(self, scaling_matrix, to_unit_cell=True): """ Create a supercell. Args: scaling_matrix: A scaling matrix for transforming the lattice vectors. Has to be all integers. Several options are possible: a. A full 3x3 scaling matrix defin...
Merges sites ( adding occupancies ) within tol of each other. Removes site properties.
def merge_sites(self, tol=0.01, mode="sum"): """ Merges sites (adding occupancies) within tol of each other. Removes site properties. Args: tol (float): Tolerance for distance to merge sites. mode (str): Three modes supported. "delete" means duplicate sites are ...
Appends a site to the molecule.
def append(self, species, coords, validate_proximity=True, properties=None): """ Appends a site to the molecule. Args: species: Species of inserted site coords: Coordinates of inserted site validate_proximity (bool): Whether to check if inserted site is ...
Set the charge and spin multiplicity.
def set_charge_and_spin(self, charge, spin_multiplicity=None): """ Set the charge and spin multiplicity. Args: charge (int): Charge for the molecule. Defaults to 0. spin_multiplicity (int): Spin multiplicity for molecule. Defaults to None, which means tha...
Insert a site to the molecule.
def insert(self, i, species, coords, validate_proximity=False, properties=None): """ Insert a site to the molecule. Args: i (int): Index to insert site species: species of inserted site coords (3x1 array): coordinates of inserted site ...
Remove all occurrences of a species from a molecule.
def remove_species(self, species): """ Remove all occurrences of a species from a molecule. Args: species: Species to remove. """ new_sites = [] species = [get_el_sp(sp) for sp in species] for site in self._sites: new_sp_occu = {sp: amt fo...
Delete sites with at indices.
def remove_sites(self, indices): """ Delete sites with at indices. Args: indices: Sequence of indices of sites to delete. """ self._sites = [self._sites[i] for i in range(len(self._sites)) if i not in indices]
Translate specific sites by some vector keeping the sites within the unit cell.
def translate_sites(self, indices=None, vector=None): """ Translate specific sites by some vector, keeping the sites within the unit cell. Args: indices (list): List of site indices on which to perform the translation. vector (3x1 array): Translat...
Apply a symmetry operation to the molecule.
def apply_operation(self, symmop): """ Apply a symmetry operation to the molecule. Args: symmop (SymmOp): Symmetry operation to apply. """ def operate_site(site): new_cart = symmop.operate(site.coords) return Site(site.species, new_cart, ...
: param structure ( bulk structure to be scaled up - typically conventional unit cell ): return: defect_structure with charge applied
def apply_transformation(self, structure): """ :param structure (bulk structure to be scaled up - typically conventional unit cell) :return: defect_structure, with charge applied """ if structure != self.defect.bulk_structure: raise ValueError("Defect bulk...
create the polymer from the monomer
def _create(self, monomer, mon_vector): """ create the polymer from the monomer Args: monomer (Molecule) mon_vector (numpy.array): molecule vector that starts from the start atom index to the end atom index """ while self.length != (self.n...
pick a move at random from the list of moves
def _next_move_direction(self): """ pick a move at random from the list of moves """ nmoves = len(self.moves) move = np.random.randint(1, nmoves+1) while self.prev_move == (move + 3) % nmoves: move = np.random.randint(1, nmoves+1) self.prev_move = move...
rotate the monomer so that it is aligned along the move direction
def _align_monomer(self, monomer, mon_vector, move_direction): """ rotate the monomer so that it is aligned along the move direction Args: monomer (Molecule) mon_vector (numpy.array): molecule vector that starts from the start atom index to the end atom i...
extend the polymer molecule by adding a monomer along mon_vector direction
def _add_monomer(self, monomer, mon_vector, move_direction): """ extend the polymer molecule by adding a monomer along mon_vector direction Args: monomer (Molecule): monomer molecule mon_vector (numpy.array): monomer vector that points from head to tail. move...
Internal method to format values in the packmol parameter dictionaries
def _format_param_val(self, param_val): """ Internal method to format values in the packmol parameter dictionaries Args: param_val: Some object to turn into String Returns: string representation of the object """ if isinst...
Set the box size for the molecular assembly
def _set_box(self): """ Set the box size for the molecular assembly """ net_volume = 0.0 for idx, mol in enumerate(self.mols): length = max([np.max(mol.cart_coords[:, i])-np.min(mol.cart_coords[:, i]) for i in range(3)]) + 2.0 ne...
Write the packmol input file to the input directory.
def _write_input(self, input_dir="."): """ Write the packmol input file to the input directory. Args: input_dir (string): path to the input directory """ with open(os.path.join(input_dir, self.input_file), 'wt', encoding="utf-8") as inp: for k, v in self....
Write the input file to the scratch directory run packmol and return the packed molecule.
def run(self, copy_to_current_on_exit=False, site_property=None): """ Write the input file to the scratch directory, run packmol and return the packed molecule. Args: copy_to_current_on_exit (bool): Whether or not to copy the packmol input/output files from t...
dump the molecule into pdb file with custom residue name and number.
def write_pdb(self, mol, filename, name=None, num=None): """ dump the molecule into pdb file with custom residue name and number. """ # ugly hack to get around the openbabel issues with inconsistent # residue labelling. scratch = tempfile.gettempdir() with Scratc...
map each residue to the corresponding molecule.
def _set_residue_map(self): """ map each residue to the corresponding molecule. """ self.map_residue_to_mol = {} lookup = {} for idx, mol in enumerate(self.mols): if not mol.formula in lookup: mol.translate_sites(indices=range(len(mol)), ...
Convert list of openbabel atoms to MOlecule.
def convert_obatoms_to_molecule(self, atoms, residue_name=None, site_property="ff_map"): """ Convert list of openbabel atoms to MOlecule. Args: atoms ([OBAtom]): list of OBAtom objects residue_name (str): the key in self.map_residue_to_mol. Usec to restor...
Restore the site properties for the final packed molecule.
def restore_site_properties(self, site_property="ff_map", filename=None): """ Restore the site properties for the final packed molecule. Args: site_property (str): filename (str): path to the final packed molecule. Returns: Molecule """ ...
Write the input/ data files and run LAMMPS.
def run(self): """ Write the input/data files and run LAMMPS. """ lammps_cmd = self.lammps_bin + ['-in', self.input_filename] print("Running: {}".format(" ".join(lammps_cmd))) p = Popen(lammps_cmd, stdout=PIPE, stderr=PIPE) (stdout, stderr) = p.communicate() ...
Utility method to get an Element or Specie from an input obj. If obj is in itself an element or a specie it is returned automatically. If obj is an int or a string representing an integer the Element with the atomic number obj is returned. If obj is a string Specie parsing will be attempted ( e. g. Mn2 + ) failing whic...
def get_el_sp(obj): """ Utility method to get an Element or Specie from an input obj. If obj is in itself an element or a specie, it is returned automatically. If obj is an int or a string representing an integer, the Element with the atomic number obj is returned. If obj is a string, Specie par...
Average ionic radius for element ( with units ). The average is taken over all oxidation states of the element for which data is present.
def average_ionic_radius(self): """ Average ionic radius for element (with units). The average is taken over all oxidation states of the element for which data is present. """ if "Ionic radii" in self._data: radii = self._data["Ionic radii"] return sum(rad...
Average cationic radius for element ( with units ). The average is taken over all positive oxidation states of the element for which data is present.
def average_cationic_radius(self): """ Average cationic radius for element (with units). The average is taken over all positive oxidation states of the element for which data is present. """ if "Ionic radii" in self._data: radii = [v for k, v in self._data["Io...
All ionic radii of the element as a dict of { oxidation state: ionic radii }. Radii are given in ang.
def ionic_radii(self): """ All ionic radii of the element as a dict of {oxidation state: ionic radii}. Radii are given in ang. """ if "Ionic radii" in self._data: return {int(k): v for k, v in self._data["Ionic radii"].items()} else: return {}
Full electronic structure as tuple. E. g. The electronic structure for Fe is represented as: [ ( 1 s 2 ) ( 2 s 2 ) ( 2 p 6 ) ( 3 s 2 ) ( 3 p 6 ) ( 3 d 6 ) ( 4 s 2 ) ]
def full_electronic_structure(self): """ Full electronic structure as tuple. E.g., The electronic structure for Fe is represented as: [(1, "s", 2), (2, "s", 2), (2, "p", 6), (3, "s", 2), (3, "p", 6), (3, "d", 6), (4, "s", 2)] """ estr = self._data["Electronic stru...
# From full electron config obtain valence subshell # angular moment ( L ) and number of valence e - ( v_e )
def valence(self): """ # From full electron config obtain valence subshell # angular moment (L) and number of valence e- (v_e) """ # the number of valence of noble gas is 0 if self.group == 18: return (np.nan, 0) L_symbols = 'SPDFGHIKLMNOQRTUVWXYZ' ...
All possible Russell - Saunders term symbol of the Element eg. L = 1 n_e = 2 ( s2 ) returns [[ 1D2 ] [ 3P0 3P1 3P2 ] [ 1S0 ]]
def term_symbols(self): """ All possible Russell-Saunders term symbol of the Element eg. L = 1, n_e = 2 (s2) returns [['1D2'], ['3P0', '3P1', '3P2'], ['1S0']] """ L_symbols = 'SPDFGHIKLMNOQRTUVWXYZ' L, v_e = self.valence # for one electron i...
Ground state term symbol Selected based on Hund s Rule
def ground_state_term_symbol(self): """ Ground state term symbol Selected based on Hund's Rule """ L_symbols = 'SPDFGHIKLMNOQRTUVWXYZ' term_symbols = self.term_symbols term_symbol_flat = {term: {"multiplicity": int(term[0]), "L...
Get an element from an atomic number.
def from_Z(z: int): """ Get an element from an atomic number. Args: z (int): Atomic number Returns: Element with atomic number z. """ for sym, data in _pt_data.items(): if data["Atomic no"] == z: return Element(sym) ...
Returns an element from a row and group number.
def from_row_and_group(row: int, group: int): """ Returns an element from a row and group number. Args: row (int): Row number group (int): Group number .. note:: The 18 group number system is used, i.e., Noble gases are group 18. """ ...
Returns the periodic table row of the element.
def row(self): """ Returns the periodic table row of the element. """ z = self.Z total = 0 if 57 <= z <= 71: return 8 elif 89 <= z <= 103: return 9 for i in range(len(_pt_row_sizes)): total += _pt_row_sizes[i] ...
Returns the periodic table group of the element.
def group(self): """ Returns the periodic table group of the element. """ z = self.Z if z == 1: return 1 if z == 2: return 18 if 3 <= z <= 18: if (z - 2) % 8 == 0: return 18 elif (z - 2) % 8 <= 2: ...
Return the block character s p d f
def block(self): """ Return the block character "s,p,d,f" """ if (self.is_actinoid or self.is_lanthanoid) and self.Z not in [71, 103]: return "f" elif self.is_actinoid or self.is_lanthanoid: return "d" elif self.group in [1, 2]: return ...
True if element is a transition metal.
def is_transition_metal(self): """ True if element is a transition metal. """ ns = list(range(21, 31)) ns.extend(list(range(39, 49))) ns.append(57) ns.extend(list(range(72, 81))) ns.append(89) ns.extend(list(range(104, 113))) return self.Z ...
Get a dictionary the nuclear electric quadrupole moment in units of e * millibarns for various isotopes
def nmr_quadrupole_moment(self): """ Get a dictionary the nuclear electric quadrupole moment in units of e*millibarns for various isotopes """ return {k: FloatWithUnit(v, "mbarn") for k, v in self.data.get("NMR Quadrupole Moment", {}).items()}
Makes Element obey the general json interface used in pymatgen for easier serialization.
def as_dict(self): """ Makes Element obey the general json interface used in pymatgen for easier serialization. """ return {"@module": self.__class__.__module__, "@class": self.__class__.__name__, "element": self.symbol}
A pretty ASCII printer for the periodic table based on some filter_function.
def print_periodic_table(filter_function: callable = None): """ A pretty ASCII printer for the periodic table, based on some filter_function. Args: filter_function: A filtering function taking an Element as input and returning a boolean. For example, setting ...
Ionic radius of specie. Returns None if data is not present.
def ionic_radius(self): """ Ionic radius of specie. Returns None if data is not present. """ if self._oxi_state in self.ionic_radii: return self.ionic_radii[self._oxi_state] d = self._el.data oxstr = str(int(self._oxi_state)) if oxstr in d.get("Ionic ...
Returns a Specie from a string representation.
def from_string(species_string: str): """ Returns a Specie from a string representation. Args: species_string (str): A typical string representation of a species, e.g., "Mn2+", "Fe3+", "O2-". Returns: A Specie object. Raises: ...
Gets the nuclear electric quadrupole moment in units of e * millibarns
def get_nmr_quadrupole_moment(self, isotope=None): """ Gets the nuclear electric quadrupole moment in units of e*millibarns Args: isotope (str): the isotope to get the quadrupole moment for default is None, which gets the lowest mass isotope """ ...
Get the local environment specific ionic radius for species.
def get_shannon_radius(self, cn: str, spin: str = "", radius_type: str = "ionic"): """ Get the local environment specific ionic radius for species. Args: cn (str): Coordination using roman letters. Supported values are I-IX, as well as IIIP...
Calculate the crystal field spin based on coordination and spin configuration. Only works for transition metal species.
def get_crystal_field_spin(self, coordination: str = "oct", spin_config: str = "high"): """ Calculate the crystal field spin based on coordination and spin configuration. Only works for transition metal species. Args: coordination (str): Only o...
Returns a Dummy from a string representation.
def from_string(species_string: str): """ Returns a Dummy from a string representation. Args: species_string (str): A string representation of a dummy species, e.g., "X2+", "X3+". Returns: A DummySpecie object. Raises: ValueE...
Returns a DummySpecie object that can be safely used with ( i. e. not present in ) a given composition
def safe_from_composition(cls, comp: "Composition", oxidation_state: float = 0): """ Returns a DummySpecie object that can be safely used with (i.e. not present in) a given composition """ # We don't want to add a DummySpecie with the same # ...
Process a given Defect entry with qualifiers given from initialization of class. Order of processing is: 1 ) perform all possible defect corrections with information given 2 ) consider delocalization analyses based on qualifier metrics given initialization of class. If delocalized flag entry as delocalized 3 ) update c...
def process_entry(self, defect_entry): """ Process a given Defect entry with qualifiers given from initialization of class. Order of processing is: 1) perform all possible defect corrections with information given 2) consider delocalization analyses based on qualifier met...
Do delocalization analysis. To do this one considers: i ) sampling region of planar averaged electrostatic potential ( freysoldt approach ) ii ) sampling region of atomic site averaged potentials ( kumagai approach ) iii ) structural relaxation amount outside of radius considered in kumagai approach ( default is wigner...
def delocalization_analysis(self, defect_entry): """ Do delocalization analysis. To do this, one considers: i) sampling region of planar averaged electrostatic potential (freysoldt approach) ii) sampling region of atomic site averaged potentials (kumagai approach) iii...
Determine the distance of space between each layer of atoms along c
def get_d(slab): """ Determine the distance of space between each layer of atoms along c """ sorted_sites = sorted(slab, key=lambda site: site.frac_coords[2]) for i, site in enumerate(sorted_sites): if "%.6f" % (site.frac_coords[2]) == \ "%.6f" % (sorted_sites[i +...