PyMatGen Sites & Species¶
Important
This page provides a concise list of available properties and methods, grouped by topic.
Refer to Pymatgen's API docs for detailed descriptions.
Introduction¶
Make sure you understand the difference between object classifications:
Element: The fundamental chemical component (e.g., Na or Cl).Species: A singular chemical entity, encompassing anElement,Ion,Molecule, orCluster. Essentially, a species can be an individual element or a set of associated elements. Additionally, it may contain extra information about the element(s), such as charge and bonding.Site: ASpecieswith xyz coordinates in free space (without a lattice). It includes orientation information if multiple atoms are present in theSpecies.PeriodicSite: ASpecieswith xyz coordinates relative to an associated lattice. This also includes orientation details if multiple atoms are part of theSpecies.
Example
(basic single crystals)
If your Structure object represents the unit cell for NaCl, it contains two PeriodicSites: one for Na and one for Cl, both of type Element.
Optionally, you can replace the Element types with Ion types: Na+ and Cl-.
Since these are single-atom Species, there's no need to worry about orientation (i.e., rotating the atom has no effect).
Example
(advanced molecular crystals and beyond)
If you have a crystal structure with ethanol intercalated between graphite, your Structure object has several ways to define its PeriodicSites.
- each atom is its own
PeriodicSite, represented by anElementtype - there are two
PeriodicSitetypes: (i) aMoleculetype for all ethanol molecules and (ii) anElementtype for all carbons part of the graphite. - ... and more! Choose what makes sense for your application. NOTE: Options 1 and 2 should cover the majority of cases.
Periodic Sites¶
Access¶
To access the PeriodicSite objects from a Structure:
# OPTION 1
sites = structure.sites
# OPTION 2
for site in structure:
#... do something
Loading/Exporting¶
as_dictfrom_dictto_jsonto_unit_cell
Position¶
xyzabccoordsfrac_coordsposition_atollattice(matches between all sites inStructure)
Basic Properties¶
is_orderedis_periodic_imagepropertiesspeciespeciesspecies_string
Measurements¶
distance
distance_and_image
distance_and_image_from_frac_coords
distance_from_point
JSON utils¶
unsafe_hash
validate_monty_v1
validate_monty_v2
(under dev sections)¶
ElementSpecies