Structures¶
The Structure
object is a collection of atoms in a periodic box.
The mandatory inputs are the cell vectors of the box and the chemical species
and Cartesian coordinates of the atoms.
The atoms are automatically folded back into the primary cell, so the
input coordinates don’t need to lie inside the box.
-
class
Structure
(cell: np.array, species: List[str] or List[int], positions: np.array, mass_dict: dict = {}, prev_positions: ndarray = [], species_labels: List[str] = [])¶ Contains information about a periodic structure of atoms, including the periodic cell boundaries, atomic species, and coordinates. Note that input positions are assumed to be Cartesian.
Parameters: - cell (np.ndarray) – 3x3 array whose rows are the Bravais lattice vectors of the cell.
- species (List[int] or List[str]) – List of atomic species, which can be given as either atomic numbers (integers) or chemical symbols (string of one or two characters, e.g. ‘He’ for Helium).
- positions (np.array) – Nx3 array of atomic coordinates in Angstrom.
- mass_dict (dict, optional) – Dictionary of atomic masses used in MD simulations, with species as keywords (either as integers or strings) and masses in amu as values. The format of the species keyword should match the format of the species input. For example, if the species are given as strings, mass_dict might take the form {‘H’: 1.0, ‘He’: 2.0}.
- prev_positions (np.ndarray, optional) – Nx3 array of previous atomic coordinates used in MD simulations. If not specified, prev_positions is set equal to positions.
- species_labels (List[str], optional) – List of chemical symbols used in the output file of on-the-fly runs. If not specified, species_labels is set equal to species.
-
coded_species
¶
Python methods¶
The following are methods implemented in pure Python, i.e. independently of the underlying C++ backend, and are intended to improve the quality of life of the user.
-
flare.struc.
as_dict
(self) → dict¶ Returns structure as a dictionary; useful for serialization purposes.
Returns: Dictionary version of current structure Return type: dict
-
flare.struc.
as_str
(self) → str¶ Returns string dictionary serialization cast as string.
Returns: output of as_dict method cast as string Return type: str
-
flare.struc.
get_unique_species
(species: List[Any]) -> (typing.List, typing.List[int])¶ Returns a list of the unique species passed in, and a list of integers indexing them.
Parameters: species – Species to index uniquely Returns: List of the unique species, and integer indexes
-
flare.struc.
indices_of_specie
(self, specie: Union[int, str]) → List[int]¶ Return the indices of a given species within atoms of the structure.
Parameters: specie – Element to target, can be string or integer Returns: The indices in the structure at which this element occurs Return type: List[str]
-
flare.struc.
to_pmg_structure
(self)¶ Returns FLARE structure as a pymatgen structure.
Returns: Pymatgen structure corresponding to current FLARE structure
-
flare.struc.
to_xyz
(self, extended_xyz: bool = True, print_stds: bool = False, print_forces: bool = False, print_max_stds: bool = False, write_file: str = '') → str¶ Convenience function which turns a structure into an extended .xyz file; useful for further input into visualization programs like VESTA or Ovito. Can be saved to an output file via write_file.
Parameters: - print_stds – Print the stds associated with the structure.
- print_forces –
- extended_xyz –
- print_max_stds –
- write_file –
Returns: