pymatgen.analysis namespace
Subpackages
- pymatgen.analysis.chemenv package
- Subpackages
- pymatgen.analysis.chemenv.connectivity package
- Submodules
- pymatgen.analysis.chemenv.connectivity.connected_components module
ConnectedComponent
ConnectedComponent.as_dict()
ConnectedComponent.compute_periodicity()
ConnectedComponent.compute_periodicity_all_simple_paths_algorithm()
ConnectedComponent.compute_periodicity_cycle_basis()
ConnectedComponent.coordination_sequence()
ConnectedComponent.description()
ConnectedComponent.elastic_centered_graph()
ConnectedComponent.from_dict()
ConnectedComponent.from_graph()
ConnectedComponent.graph
ConnectedComponent.is_0d
ConnectedComponent.is_1d
ConnectedComponent.is_2d
ConnectedComponent.is_3d
ConnectedComponent.is_periodic
ConnectedComponent.make_supergraph()
ConnectedComponent.periodicity
ConnectedComponent.periodicity_vectors
ConnectedComponent.show_graph()
draw_network()
make_supergraph()
- pymatgen.analysis.chemenv.connectivity.connectivity_finder module
- pymatgen.analysis.chemenv.connectivity.environment_nodes module
AbstractEnvironmentNode
AbstractEnvironmentNode.ATOM
AbstractEnvironmentNode.CE_NNBCES_NBCES_LIGANDS
AbstractEnvironmentNode.COORDINATION_ENVIRONMENT
AbstractEnvironmentNode.DEFAULT_EXTENSIONS
AbstractEnvironmentNode.LIGANDS_ARRANGEMENT
AbstractEnvironmentNode.NEIGHBORING_CES
AbstractEnvironmentNode.NEIGHBORING_COORDINATION_ENVIRONMENTS
AbstractEnvironmentNode.NEIGHBORS_LIGANDS_ARRANGEMENT
AbstractEnvironmentNode.NUMBER_OF_LIGANDS_FOR_EACH_NEIGHBORING_CE
AbstractEnvironmentNode.NUMBER_OF_LIGANDS_FOR_EACH_NEIGHBORING_COORDINATION_ENVIRONMENT
AbstractEnvironmentNode.NUMBER_OF_NEIGHBORING_CES
AbstractEnvironmentNode.NUMBER_OF_NEIGHBORING_COORDINATION_ENVIRONMENTS
AbstractEnvironmentNode.atom_symbol
AbstractEnvironmentNode.ce
AbstractEnvironmentNode.ce_symbol
AbstractEnvironmentNode.coordination_environment
AbstractEnvironmentNode.everything_equal()
AbstractEnvironmentNode.isite
AbstractEnvironmentNode.mp_symbol
EnvironmentNode
get_environment_node()
- pymatgen.analysis.chemenv.connectivity.structure_connectivity module
StructureConnectivity
StructureConnectivity.add_bonds()
StructureConnectivity.add_sites()
StructureConnectivity.as_dict()
StructureConnectivity.environment_subgraph()
StructureConnectivity.from_dict()
StructureConnectivity.get_connected_components()
StructureConnectivity.print_links()
StructureConnectivity.setup_atom_environment_subgraph()
StructureConnectivity.setup_atom_environments_subgraph()
StructureConnectivity.setup_connectivity_description()
StructureConnectivity.setup_environment_subgraph()
StructureConnectivity.setup_environments_subgraph()
get_delta_image()
- pymatgen.analysis.chemenv.coordination_environments package
- Subpackages
- Submodules
- pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies module
AbstractChemenvStrategy
AbstractChemenvStrategy.AC
AbstractChemenvStrategy.DEFAULT_SYMMETRY_MEASURE_TYPE
AbstractChemenvStrategy.STRATEGY_DESCRIPTION
AbstractChemenvStrategy.STRATEGY_INFO_FIELDS
AbstractChemenvStrategy.STRATEGY_OPTIONS
AbstractChemenvStrategy.as_dict()
AbstractChemenvStrategy.equivalent_site_index_and_transform()
AbstractChemenvStrategy.from_dict()
AbstractChemenvStrategy.get_site_ce_fractions_and_neighbors()
AbstractChemenvStrategy.get_site_coordination_environment()
AbstractChemenvStrategy.get_site_coordination_environments()
AbstractChemenvStrategy.get_site_coordination_environments_fractions()
AbstractChemenvStrategy.get_site_neighbors()
AbstractChemenvStrategy.prepare_symmetries()
AbstractChemenvStrategy.set_option()
AbstractChemenvStrategy.set_structure_environments()
AbstractChemenvStrategy.setup_options()
AbstractChemenvStrategy.symmetry_measure_type
AbstractChemenvStrategy.uniquely_determines_coordination_environments
AdditionalConditionInt
AngleCutoffFloat
AngleNbSetWeight
AnglePlateauNbSetWeight
CNBiasNbSetWeight
CSMFloat
DeltaCSMNbSetWeight
DeltaCSMNbSetWeight.DEFAULT_EFFECTIVE_CSM_ESTIMATOR
DeltaCSMNbSetWeight.DEFAULT_SYMMETRY_MEASURE_TYPE
DeltaCSMNbSetWeight.DEFAULT_WEIGHT_ESTIMATOR
DeltaCSMNbSetWeight.SHORT_NAME
DeltaCSMNbSetWeight.as_dict()
DeltaCSMNbSetWeight.delta_cn_specifics()
DeltaCSMNbSetWeight.from_dict()
DeltaCSMNbSetWeight.weight()
DeltaDistanceNbSetWeight
DistanceAngleAreaNbSetWeight
DistanceAngleAreaNbSetWeight.AC
DistanceAngleAreaNbSetWeight.DEFAULT_SURFACE_DEFINITION
DistanceAngleAreaNbSetWeight.SHORT_NAME
DistanceAngleAreaNbSetWeight.as_dict()
DistanceAngleAreaNbSetWeight.from_dict()
DistanceAngleAreaNbSetWeight.rectangle_crosses_area()
DistanceAngleAreaNbSetWeight.w_area_has_intersection()
DistanceAngleAreaNbSetWeight.w_area_intersection_nbsfh_fbs_onb0()
DistanceAngleAreaNbSetWeight.weight()
DistanceCutoffFloat
DistanceNbSetWeight
DistancePlateauNbSetWeight
MultiWeightsChemenvStrategy
MultiWeightsChemenvStrategy.DEFAULT_CE_ESTIMATOR
MultiWeightsChemenvStrategy.STRATEGY_DESCRIPTION
MultiWeightsChemenvStrategy.as_dict()
MultiWeightsChemenvStrategy.from_dict()
MultiWeightsChemenvStrategy.stats_article_weights_parameters()
MultiWeightsChemenvStrategy.uniquely_determines_coordination_environments
NbSetWeight
NormalizedAngleDistanceNbSetWeight
NormalizedAngleDistanceNbSetWeight.SHORT_NAME
NormalizedAngleDistanceNbSetWeight.ang()
NormalizedAngleDistanceNbSetWeight.anginvdist()
NormalizedAngleDistanceNbSetWeight.anginvndist()
NormalizedAngleDistanceNbSetWeight.angn()
NormalizedAngleDistanceNbSetWeight.angninvdist()
NormalizedAngleDistanceNbSetWeight.angninvndist()
NormalizedAngleDistanceNbSetWeight.as_dict()
NormalizedAngleDistanceNbSetWeight.aweight()
NormalizedAngleDistanceNbSetWeight.from_dict()
NormalizedAngleDistanceNbSetWeight.gweight()
NormalizedAngleDistanceNbSetWeight.invdist()
NormalizedAngleDistanceNbSetWeight.invndist()
NormalizedAngleDistanceNbSetWeight.weight()
SelfCSMNbSetWeight
SimpleAbundanceChemenvStrategy
SimpleAbundanceChemenvStrategy.DEFAULT_ADDITIONAL_CONDITION
SimpleAbundanceChemenvStrategy.DEFAULT_MAX_DIST
SimpleAbundanceChemenvStrategy.STRATEGY_DESCRIPTION
SimpleAbundanceChemenvStrategy.STRATEGY_OPTIONS
SimpleAbundanceChemenvStrategy.as_dict()
SimpleAbundanceChemenvStrategy.from_dict()
SimpleAbundanceChemenvStrategy.get_site_coordination_environment()
SimpleAbundanceChemenvStrategy.get_site_coordination_environments()
SimpleAbundanceChemenvStrategy.get_site_neighbors()
SimpleAbundanceChemenvStrategy.uniquely_determines_coordination_environments
SimplestChemenvStrategy
SimplestChemenvStrategy.DEFAULT_ADDITIONAL_CONDITION
SimplestChemenvStrategy.DEFAULT_ANGLE_CUTOFF
SimplestChemenvStrategy.DEFAULT_CONTINUOUS_SYMMETRY_MEASURE_CUTOFF
SimplestChemenvStrategy.DEFAULT_DISTANCE_CUTOFF
SimplestChemenvStrategy.STRATEGY_DESCRIPTION
SimplestChemenvStrategy.STRATEGY_OPTIONS
SimplestChemenvStrategy.add_strategy_visualization_to_subplot()
SimplestChemenvStrategy.additional_condition
SimplestChemenvStrategy.angle_cutoff
SimplestChemenvStrategy.as_dict()
SimplestChemenvStrategy.continuous_symmetry_measure_cutoff
SimplestChemenvStrategy.distance_cutoff
SimplestChemenvStrategy.from_dict()
SimplestChemenvStrategy.get_site_coordination_environment()
SimplestChemenvStrategy.get_site_coordination_environments()
SimplestChemenvStrategy.get_site_coordination_environments_fractions()
SimplestChemenvStrategy.get_site_neighbors()
SimplestChemenvStrategy.uniquely_determines_coordination_environments
StrategyOption
TargetedPenaltiedAbundanceChemenvStrategy
TargetedPenaltiedAbundanceChemenvStrategy.DEFAULT_TARGET_ENVIRONMENTS
TargetedPenaltiedAbundanceChemenvStrategy.as_dict()
TargetedPenaltiedAbundanceChemenvStrategy.from_dict()
TargetedPenaltiedAbundanceChemenvStrategy.get_site_coordination_environment()
TargetedPenaltiedAbundanceChemenvStrategy.uniquely_determines_coordination_environments
WeightedNbSetChemenvStrategy
WeightedNbSetChemenvStrategy.DEFAULT_CE_ESTIMATOR
WeightedNbSetChemenvStrategy.STRATEGY_DESCRIPTION
WeightedNbSetChemenvStrategy.as_dict()
WeightedNbSetChemenvStrategy.from_dict()
WeightedNbSetChemenvStrategy.get_site_coordination_environment()
WeightedNbSetChemenvStrategy.get_site_coordination_environments()
WeightedNbSetChemenvStrategy.get_site_coordination_environments_fractions()
WeightedNbSetChemenvStrategy.get_site_neighbors()
WeightedNbSetChemenvStrategy.uniquely_determines_coordination_environments
get_effective_csm()
set_info()
- pymatgen.analysis.chemenv.coordination_environments.coordination_geometries module
AbstractChemenvAlgorithm
AllCoordinationGeometries
AllCoordinationGeometries.get_geometries()
AllCoordinationGeometries.get_geometry_from_IUCr_symbol()
AllCoordinationGeometries.get_geometry_from_IUPAC_symbol()
AllCoordinationGeometries.get_geometry_from_mp_symbol()
AllCoordinationGeometries.get_geometry_from_name()
AllCoordinationGeometries.get_implemented_geometries()
AllCoordinationGeometries.get_not_implemented_geometries()
AllCoordinationGeometries.get_symbol_cn_mapping()
AllCoordinationGeometries.get_symbol_name_mapping()
AllCoordinationGeometries.is_a_valid_coordination_geometry()
AllCoordinationGeometries.pretty_print()
CoordinationGeometry
CoordinationGeometry.CSM_SKIP_SEPARATION_PLANE_ALGO
CoordinationGeometry.IUCr_symbol
CoordinationGeometry.IUCr_symbol_str
CoordinationGeometry.IUPAC_symbol
CoordinationGeometry.IUPAC_symbol_str
CoordinationGeometry.NeighborsSetsHints
CoordinationGeometry.NeighborsSetsHints.ALLOWED_HINTS_TYPES
CoordinationGeometry.NeighborsSetsHints.as_dict()
CoordinationGeometry.NeighborsSetsHints.double_cap_hints()
CoordinationGeometry.NeighborsSetsHints.from_dict()
CoordinationGeometry.NeighborsSetsHints.hints()
CoordinationGeometry.NeighborsSetsHints.single_cap_hints()
CoordinationGeometry.NeighborsSetsHints.triple_cap_hints()
CoordinationGeometry.algorithms
CoordinationGeometry.as_dict()
CoordinationGeometry.ce_symbol
CoordinationGeometry.coordination_number
CoordinationGeometry.distfactor_max
CoordinationGeometry.edges()
CoordinationGeometry.faces()
CoordinationGeometry.from_dict()
CoordinationGeometry.get_central_site()
CoordinationGeometry.get_coordination_number()
CoordinationGeometry.get_name()
CoordinationGeometry.get_pmeshes()
CoordinationGeometry.is_implemented()
CoordinationGeometry.mp_symbol
CoordinationGeometry.number_of_permutations
CoordinationGeometry.pauling_stability_ratio
CoordinationGeometry.ref_permutation()
CoordinationGeometry.solid_angles()
ExplicitPermutationsAlgorithm
SeparationPlane
- pymatgen.analysis.chemenv.coordination_environments.coordination_geometry_finder module
AbstractGeometry
AbstractGeometry.cn
AbstractGeometry.coordination_number
AbstractGeometry.from_cg()
AbstractGeometry.points_wcs_csc()
AbstractGeometry.points_wcs_ctwcc()
AbstractGeometry.points_wcs_ctwocc()
AbstractGeometry.points_wocs_csc()
AbstractGeometry.points_wocs_ctwcc()
AbstractGeometry.points_wocs_ctwocc()
LocalGeometryFinder
LocalGeometryFinder.BVA_DISTANCE_SCALE_FACTORS
LocalGeometryFinder.DEFAULT_BVA_DISTANCE_SCALE_FACTOR
LocalGeometryFinder.DEFAULT_SPG_ANALYZER_OPTIONS
LocalGeometryFinder.DEFAULT_STRATEGY
LocalGeometryFinder.PRESETS
LocalGeometryFinder.STRUCTURE_REFINEMENT_NONE
LocalGeometryFinder.STRUCTURE_REFINEMENT_REFINED
LocalGeometryFinder.STRUCTURE_REFINEMENT_SYMMETRIZED
LocalGeometryFinder.compute_coordination_environments()
LocalGeometryFinder.compute_structure_environments()
LocalGeometryFinder.coordination_geometry_symmetry_measures()
LocalGeometryFinder.coordination_geometry_symmetry_measures_fallback_random()
LocalGeometryFinder.coordination_geometry_symmetry_measures_separation_plane()
LocalGeometryFinder.coordination_geometry_symmetry_measures_separation_plane_optim()
LocalGeometryFinder.coordination_geometry_symmetry_measures_sepplane_optim()
LocalGeometryFinder.coordination_geometry_symmetry_measures_standard()
LocalGeometryFinder.get_coordination_symmetry_measures()
LocalGeometryFinder.get_coordination_symmetry_measures_optim()
LocalGeometryFinder.get_structure()
LocalGeometryFinder.set_structure()
LocalGeometryFinder.setup_explicit_indices_local_geometry()
LocalGeometryFinder.setup_local_geometry()
LocalGeometryFinder.setup_ordered_indices_local_geometry()
LocalGeometryFinder.setup_parameter()
LocalGeometryFinder.setup_parameters()
LocalGeometryFinder.setup_random_indices_local_geometry()
LocalGeometryFinder.setup_random_structure()
LocalGeometryFinder.setup_structure()
LocalGeometryFinder.setup_test_perfect_environment()
LocalGeometryFinder.update_nb_set_environments()
find_rotation()
find_scaling_factor()
symmetry_measure()
- pymatgen.analysis.chemenv.coordination_environments.structure_environments module
ChemicalEnvironments
LightStructureEnvironments
LightStructureEnvironments.DEFAULT_STATISTICS_FIELDS
LightStructureEnvironments.DELTA_MAX_OXIDATION_STATE
LightStructureEnvironments.NeighborsSet
LightStructureEnvironments.NeighborsSet.as_dict()
LightStructureEnvironments.NeighborsSet.from_dict()
LightStructureEnvironments.NeighborsSet.neighb_coords
LightStructureEnvironments.NeighborsSet.neighb_indices_and_images
LightStructureEnvironments.NeighborsSet.neighb_sites
LightStructureEnvironments.NeighborsSet.neighb_sites_and_indices
LightStructureEnvironments.as_dict()
LightStructureEnvironments.clear_environments()
LightStructureEnvironments.contains_only_one_anion()
LightStructureEnvironments.contains_only_one_anion_atom()
LightStructureEnvironments.environments_identified()
LightStructureEnvironments.from_dict()
LightStructureEnvironments.from_structure_environments()
LightStructureEnvironments.get_site_info_for_specie_allces()
LightStructureEnvironments.get_site_info_for_specie_ce()
LightStructureEnvironments.get_statistics()
LightStructureEnvironments.setup_statistic_lists()
LightStructureEnvironments.site_contains_environment()
LightStructureEnvironments.site_has_clear_environment()
LightStructureEnvironments.structure_contains_atom_environment()
LightStructureEnvironments.structure_has_clear_environments()
LightStructureEnvironments.uniquely_determines_coordination_environments
StructureEnvironments
StructureEnvironments.AC
StructureEnvironments.NeighborsSet
StructureEnvironments.NeighborsSet.add_source()
StructureEnvironments.NeighborsSet.angle_plateau()
StructureEnvironments.NeighborsSet.angles
StructureEnvironments.NeighborsSet.as_dict()
StructureEnvironments.NeighborsSet.coords
StructureEnvironments.NeighborsSet.distance_plateau()
StructureEnvironments.NeighborsSet.distances
StructureEnvironments.NeighborsSet.from_dict()
StructureEnvironments.NeighborsSet.get_neighb_voronoi_indices()
StructureEnvironments.NeighborsSet.info
StructureEnvironments.NeighborsSet.neighb_coords
StructureEnvironments.NeighborsSet.neighb_coordsOpt
StructureEnvironments.NeighborsSet.neighb_sites
StructureEnvironments.NeighborsSet.neighb_sites_and_indices
StructureEnvironments.NeighborsSet.normalized_angles
StructureEnvironments.NeighborsSet.normalized_distances
StructureEnvironments.NeighborsSet.source
StructureEnvironments.NeighborsSet.voronoi_grid_surface_points()
StructureEnvironments.add_neighbors_set()
StructureEnvironments.as_dict()
StructureEnvironments.differences_wrt()
StructureEnvironments.from_dict()
StructureEnvironments.get_coordination_environments()
StructureEnvironments.get_csm()
StructureEnvironments.get_csm_and_maps()
StructureEnvironments.get_csms()
StructureEnvironments.get_environments_figure()
StructureEnvironments.init_neighbors_sets()
StructureEnvironments.plot_csm_and_maps()
StructureEnvironments.plot_environments()
StructureEnvironments.save_environments_figure()
StructureEnvironments.update_coordination_environments()
StructureEnvironments.update_site_info()
- pymatgen.analysis.chemenv.coordination_environments.voronoi module
DetailedVoronoiContainer
DetailedVoronoiContainer.AC
DetailedVoronoiContainer.as_dict()
DetailedVoronoiContainer.default_normalized_angle_tolerance
DetailedVoronoiContainer.default_normalized_distance_tolerance
DetailedVoronoiContainer.default_voronoi_cutoff
DetailedVoronoiContainer.from_dict()
DetailedVoronoiContainer.get_rdf_figure()
DetailedVoronoiContainer.get_sadf_figure()
DetailedVoronoiContainer.is_close_to()
DetailedVoronoiContainer.maps_and_surfaces()
DetailedVoronoiContainer.maps_and_surfaces_bounded()
DetailedVoronoiContainer.neighbors()
DetailedVoronoiContainer.neighbors_surfaces()
DetailedVoronoiContainer.neighbors_surfaces_bounded()
DetailedVoronoiContainer.setup_neighbors_distances_and_angles()
DetailedVoronoiContainer.setup_voronoi_list()
DetailedVoronoiContainer.to_bson_voronoi_list2()
DetailedVoronoiContainer.voronoi_parameters_bounds_and_limits()
from_bson_voronoi_list2()
- pymatgen.analysis.chemenv.utils package
- Submodules
- pymatgen.analysis.chemenv.utils.chemenv_config module
- pymatgen.analysis.chemenv.utils.chemenv_errors module
- pymatgen.analysis.chemenv.utils.coordination_geometry_utils module
Plane
Plane.TEST_2D_POINTS
Plane.a
Plane.abcd
Plane.b
Plane.c
Plane.coefficients
Plane.crosses_origin
Plane.d
Plane.distance_to_origin
Plane.distance_to_point()
Plane.distances()
Plane.distances_indices_groups()
Plane.distances_indices_sorted()
Plane.fit_error()
Plane.fit_least_square_distance_error()
Plane.fit_maximum_distance_error()
Plane.from_2points_and_origin()
Plane.from_3points()
Plane.from_coefficients()
Plane.from_npoints()
Plane.from_npoints_least_square_distance()
Plane.from_npoints_maximum_distance()
Plane.indices_separate()
Plane.init_3points()
Plane.is_in_list()
Plane.is_in_plane()
Plane.is_same_plane_as()
Plane.orthonormal_vectors()
Plane.perpendicular_bisector()
Plane.project_and_to2dim()
Plane.project_and_to2dim_ordered_indices()
Plane.projectionpoints()
anticlockwise_sort()
anticlockwise_sort_indices()
changebasis()
collinear()
diamond_functions()
function_comparison()
get_lower_and_upper_f()
is_anion_cation_bond()
matrixTimesVector()
quarter_ellipsis_functions()
rectangle_surface_intersection()
rotateCoords()
rotateCoordsOpt()
separation_in_list()
solid_angle()
sort_separation()
sort_separation_tuple()
spline_functions()
vectorsToMatrix()
- pymatgen.analysis.chemenv.utils.defs_utils module
AdditionalConditions
AdditionalConditions.ALL
AdditionalConditions.CONDITION_DESCRIPTION
AdditionalConditions.NONE
AdditionalConditions.NO_AC
AdditionalConditions.NO_ADDITIONAL_CONDITION
AdditionalConditions.NO_E2SEB
AdditionalConditions.NO_ELEMENT_TO_SAME_ELEMENT_BONDS
AdditionalConditions.ONLY_ACB
AdditionalConditions.ONLY_ACB_AND_NO_E2SEB
AdditionalConditions.ONLY_ANION_CATION_BONDS
AdditionalConditions.ONLY_ANION_CATION_BONDS_AND_NO_ELEMENT_TO_SAME_ELEMENT_BONDS
AdditionalConditions.ONLY_E2OB
AdditionalConditions.ONLY_ELEMENT_TO_OXYGEN_BONDS
AdditionalConditions.check_condition()
- pymatgen.analysis.chemenv.utils.func_utils module
- pymatgen.analysis.chemenv.utils.graph_utils module
- pymatgen.analysis.chemenv.utils.math_utils module
cosinus_step()
divisors()
get_center_of_arc()
get_linearly_independent_vectors()
normal_cdf_step()
power2_decreasing_exp()
power2_inverse_decreasing()
power2_inverse_power2_decreasing()
power2_inverse_powern_decreasing()
power2_tangent_decreasing()
power3_step()
powern_decreasing()
powern_parts_step()
prime_factors()
scale_and_clamp()
smootherstep()
smoothstep()
- pymatgen.analysis.chemenv.utils.scripts_utils module
- pymatgen.analysis.chemenv.connectivity package
- Subpackages
- pymatgen.analysis.diffraction package
- Submodules
- pymatgen.analysis.diffraction.core module
AbstractDiffractionPatternCalculator
AbstractDiffractionPatternCalculator.SCALED_INTENSITY_TOL
AbstractDiffractionPatternCalculator.TWO_THETA_TOL
AbstractDiffractionPatternCalculator.get_pattern()
AbstractDiffractionPatternCalculator.get_plot()
AbstractDiffractionPatternCalculator.plot_structures()
AbstractDiffractionPatternCalculator.show_plot()
DiffractionPattern
get_unique_families()
- pymatgen.analysis.diffraction.neutron module
- pymatgen.analysis.diffraction.tem module
TEMCalculator
TEMCalculator.bragg_angles()
TEMCalculator.cell_intensity()
TEMCalculator.cell_scattering_factors()
TEMCalculator.electron_scattering_factors()
TEMCalculator.generate_points()
TEMCalculator.get_first_point()
TEMCalculator.get_interplanar_angle()
TEMCalculator.get_interplanar_spacings()
TEMCalculator.get_pattern()
TEMCalculator.get_plot_2d()
TEMCalculator.get_plot_2d_concise()
TEMCalculator.get_plot_coeffs()
TEMCalculator.get_positions()
TEMCalculator.get_s2()
TEMCalculator.is_parallel()
TEMCalculator.normalized_cell_intensity()
TEMCalculator.tem_dots()
TEMCalculator.wavelength_rel()
TEMCalculator.x_ray_factors()
TEMCalculator.zone_axis_filter()
- pymatgen.analysis.diffraction.xrd module
- pymatgen.analysis.elasticity package
- Submodules
- pymatgen.analysis.elasticity.elastic module
ComplianceTensor
ElasticTensor
ElasticTensor.agne_diffusive_thermalcond()
ElasticTensor.cahill_thermalcond()
ElasticTensor.clarke_thermalcond()
ElasticTensor.compliance_tensor
ElasticTensor.debye_temperature()
ElasticTensor.directional_elastic_mod()
ElasticTensor.directional_poisson_ratio()
ElasticTensor.from_independent_strains()
ElasticTensor.from_pseudoinverse()
ElasticTensor.g_reuss
ElasticTensor.g_voigt
ElasticTensor.g_vrh
ElasticTensor.get_structure_property_dict()
ElasticTensor.green_kristoffel()
ElasticTensor.homogeneous_poisson
ElasticTensor.k_reuss
ElasticTensor.k_voigt
ElasticTensor.k_vrh
ElasticTensor.long_v()
ElasticTensor.property_dict
ElasticTensor.snyder_ac()
ElasticTensor.snyder_opt()
ElasticTensor.snyder_total()
ElasticTensor.trans_v()
ElasticTensor.universal_anisotropy
ElasticTensor.y_mod
ElasticTensorExpansion
ElasticTensorExpansion.calculate_stress()
ElasticTensorExpansion.energy_density()
ElasticTensorExpansion.from_diff_fit()
ElasticTensorExpansion.get_compliance_expansion()
ElasticTensorExpansion.get_effective_ecs()
ElasticTensorExpansion.get_ggt()
ElasticTensorExpansion.get_gruneisen_parameter()
ElasticTensorExpansion.get_heat_capacity()
ElasticTensorExpansion.get_stability_criteria()
ElasticTensorExpansion.get_strain_from_stress()
ElasticTensorExpansion.get_symmetric_wallace_tensor()
ElasticTensorExpansion.get_tgt()
ElasticTensorExpansion.get_wallace_tensor()
ElasticTensorExpansion.get_yield_stress()
ElasticTensorExpansion.omega()
ElasticTensorExpansion.order
ElasticTensorExpansion.thermal_expansion_coeff()
NthOrderElasticTensor
diff_fit()
find_eq_stress()
generate_pseudo()
get_diff_coeff()
get_strain_state_dict()
get_symbol_list()
raise_if_unphysical()
subs()
- pymatgen.analysis.elasticity.strain module
- pymatgen.analysis.elasticity.stress module
- pymatgen.analysis.ferroelectricity package
- Submodules
- pymatgen.analysis.ferroelectricity.polarization module
EnergyTrend
Polarization
Polarization.from_outcars_and_structures()
Polarization.get_lattice_quanta()
Polarization.get_pelecs_and_pions()
Polarization.get_polarization_change()
Polarization.get_polarization_change_norm()
Polarization.get_same_branch_polarization_data()
Polarization.max_spline_jumps()
Polarization.same_branch_splines()
Polarization.smoothness()
calc_ionic()
get_nearest_site()
get_total_ionic_dipole()
zval_dict_from_potcar()
- pymatgen.analysis.gb package
- pymatgen.analysis.interfaces package
- Submodules
- pymatgen.analysis.interfaces.coherent_interfaces module
- pymatgen.analysis.interfaces.substrate_analyzer module
- pymatgen.analysis.interfaces.zsl module
- pymatgen.analysis.magnetism package
- Submodules
- pymatgen.analysis.magnetism.analyzer module
CollinearMagneticStructureAnalyzer
CollinearMagneticStructureAnalyzer.get_exchange_group_info()
CollinearMagneticStructureAnalyzer.get_ferromagnetic_structure()
CollinearMagneticStructureAnalyzer.get_nonmagnetic_structure()
CollinearMagneticStructureAnalyzer.get_structure_with_only_magnetic_atoms()
CollinearMagneticStructureAnalyzer.get_structure_with_spin()
CollinearMagneticStructureAnalyzer.is_magnetic
CollinearMagneticStructureAnalyzer.magmoms
CollinearMagneticStructureAnalyzer.magnetic_species_and_magmoms
CollinearMagneticStructureAnalyzer.matches_ordering()
CollinearMagneticStructureAnalyzer.number_of_magnetic_sites
CollinearMagneticStructureAnalyzer.number_of_unique_magnetic_sites()
CollinearMagneticStructureAnalyzer.ordering
CollinearMagneticStructureAnalyzer.types_of_magnetic_specie
CollinearMagneticStructureAnalyzer.types_of_magnetic_species
MagneticDeformation
MagneticStructureEnumerator
Ordering
OverwriteMagmomMode
magnetic_deformation()
- pymatgen.analysis.magnetism.heisenberg module
HeisenbergMapper
HeisenbergMapper.strategy
HeisenbergMapper.sgraphs
HeisenbergMapper.unique_site_ids
HeisenbergMapper.wyckoff_ids
HeisenbergMapper.nn_interactions
HeisenbergMapper.dists
HeisenbergMapper.ex_mat
HeisenbergMapper.ex_params
HeisenbergMapper.estimate_exchange()
HeisenbergMapper.get_exchange()
HeisenbergMapper.get_heisenberg_model()
HeisenbergMapper.get_interaction_graph()
HeisenbergMapper.get_low_energy_orderings()
HeisenbergMapper.get_mft_temperature()
HeisenbergModel
HeisenbergScreener
- pymatgen.analysis.magnetism.jahnteller module
JahnTellerAnalyzer
JahnTellerAnalyzer.get_analysis()
JahnTellerAnalyzer.get_analysis_and_structure()
JahnTellerAnalyzer.get_magnitude_of_effect_from_species()
JahnTellerAnalyzer.get_magnitude_of_effect_from_spin_config()
JahnTellerAnalyzer.is_jahn_teller_active()
JahnTellerAnalyzer.mu_so()
JahnTellerAnalyzer.tag_structure()
- pymatgen.analysis.solar package
- pymatgen.analysis.structure_prediction package
- Submodules
- pymatgen.analysis.structure_prediction.dopant_predictor module
- pymatgen.analysis.structure_prediction.substitution_probability module
- pymatgen.analysis.structure_prediction.substitutor module
- pymatgen.analysis.structure_prediction.volume_predictor module
- pymatgen.analysis.topological package
- pymatgen.analysis.xas package
Submodules
pymatgen.analysis.adsorption module
This module provides classes used to enumerate surface sites and to find adsorption sites on slabs.
- class AdsorbateSiteFinder(slab: Slab, selective_dynamics: bool = False, height: float = 0.9, mi_vec: ArrayLike | None = None)[source]
Bases:
object
This class finds adsorbate sites on slabs and generates adsorbate structures according to user-defined criteria.
- The algorithm for finding sites is essentially as follows:
- Determine “surface sites” by finding those within
a height threshold along the miller index of the highest site
- Create a network of surface sites using the Delaunay
triangulation of the surface sites
- Assign on-top, bridge, and hollow adsorption sites
at the nodes, edges, and face centers of the Del. Triangulation
- Generate structures from a molecule positioned at
these sites
Create an AdsorbateSiteFinder object.
- Parameters:
slab (Slab) – slab object for which to find adsorbate sites
selective_dynamics (bool) – flag for whether to assign non-surface sites as fixed for selective dynamics
height (float) – height criteria for selection of surface sites
mi_vec (3-D array-like) – vector corresponding to the vector concurrent with the miller index, this enables use with slabs that have been reoriented, but the miller vector must be supplied manually
- add_adsorbate(molecule: Molecule, ads_coord, repeat=None, translate=True, reorient=True)[source]
Add an adsorbate at a particular coordinate. Adsorbate represented by a Molecule object and is translated to (0, 0, 0) if translate is True, or positioned relative to the input adsorbate coordinate if translate is False.
- Parameters:
molecule (Molecule) – molecule object representing the adsorbate
ads_coord (array) – coordinate of adsorbate position
repeat (3-tuple or list) – input for making a supercell of slab prior to placing the adsorbate
translate (bool) – flag on whether to translate the molecule so that its CoM is at the origin prior to adding it to the surface
reorient (bool) – flag on whether to reorient the molecule to have its z-axis concurrent with miller index
- adsorb_both_surfaces(molecule, repeat=None, min_lw=5.0, translate=True, reorient=True, find_args=None)[source]
Generate all adsorption structures for a given molecular adsorbate on both surfaces of a slab. This is useful for calculating surface energy where both surfaces need to be equivalent or if we want to calculate nonpolar systems.
- Parameters:
molecule (Molecule) – molecule corresponding to adsorbate
repeat (3-tuple or list) – repeat argument for supercell generation
min_lw (float) – minimum length and width of the slab, only used if repeat is None
reorient (bool) – flag on whether or not to reorient adsorbate along the miller index
find_args (dict) – dictionary of arguments to be passed to the call to self.find_adsorption_sites, e.g. {“distance”:2.0}
- classmethod assign_selective_dynamics(slab)[source]
Helper function to assign selective dynamics site_properties based on surface, subsurface site properties.
- Parameters:
slab (Slab) – slab for which to assign selective dynamics
- classmethod ensemble_center(site_list, indices, cartesian=True)[source]
Find the center of an ensemble of sites selected from a list of sites. Helper method for the find_adsorption_sites algorithm.
- Parameters:
site_list (list[Site]) – sites from which to select
indices (list[int]) – indices of sites from which to select sites from site list
cartesian (bool) – whether to get average fractional or Cartesian coordinate
- find_adsorption_sites(distance=2.0, put_inside=True, symm_reduce=0.01, near_reduce=0.01, positions=('ontop', 'bridge', 'hollow'), no_obtuse_hollow=True)[source]
Find surface sites according to the above algorithm. Returns a list of corresponding Cartesian coordinates.
- Parameters:
distance (float) – distance from the coordinating ensemble of atoms along the miller index for the site (i.e. the distance from the slab itself)
put_inside (bool) – whether to put the site inside the cell
symm_reduce (float) – symm reduction threshold
near_reduce (float) – near reduction threshold
positions (list) –
which positions to include in the site finding “ontop”: sites on top of surface sites “bridge”: sites at edges between surface sites in Delaunay
triangulation of surface sites in the miller plane
”hollow”: sites at centers of Delaunay triangulation faces “subsurface”: subsurface positions projected into miller plane
no_obtuse_hollow (bool) – flag to indicate whether to include obtuse triangular ensembles in hollow sites
- find_surface_sites_by_height(slab: Slab, height=0.9, xy_tol=0.05)[source]
Find surface sites by determining which sites are within a threshold value in height from the topmost site in a list of sites.
- Parameters:
slab (Slab) – slab for which to find surface sites
height (float) – threshold in angstroms of distance from topmost site in slab along the slab c-vector to include in surface site determination
xy_tol (float) – if supplied, will remove any sites which are within a certain distance in the miller plane.
- Returns:
list of sites selected to be within a threshold of the highest
- classmethod from_bulk_and_miller(structure, miller_index, min_slab_size=8.0, min_vacuum_size=10.0, max_normal_search=None, center_slab=True, selective_dynamics=False, undercoord_threshold=0.09) Self [source]
Construct the adsorbate site finder from a bulk structure and a miller index, which allows the surface sites to be determined from the difference in bulk and slab coordination, as opposed to the height threshold.
- Parameters:
structure (Structure) – structure from which slab input to the ASF is constructed
miller_index (3-tuple or list) – miller index to be used
min_slab_size (float) – min slab size for slab generation
min_vacuum_size (float) – min vacuum size for slab generation
max_normal_search (int) – max normal search for slab generation
center_slab (bool) – whether to center slab in slab generation
dynamics (selective) – whether to assign surface sites to selective dynamics
undercoord_threshold (float) – threshold of “undercoordation” to use for the assignment of surface sites. Default is 0.1, for which surface sites will be designated if they are 10% less coordinated than their bulk counterpart
- generate_adsorption_structures(molecule, repeat=None, min_lw=5.0, translate=True, reorient=True, find_args=None)[source]
Generate all adsorption structures for a given molecular adsorbate. Can take repeat argument or minimum length/width of precursor slab as an input.
- Parameters:
molecule (Molecule) – molecule corresponding to adsorbate
repeat (3-tuple or list) – repeat argument for supercell generation
min_lw (float) – minimum length and width of the slab, only used if repeat is None
translate (bool) – flag on whether to translate the molecule so that its CoM is at the origin prior to adding it to the surface
reorient (bool) – flag on whether or not to reorient adsorbate along the miller index
find_args (dict) – dictionary of arguments to be passed to the call to self.find_adsorption_sites, e.g. {“distance”:2.0}
- generate_substitution_structures(atom, target_species=None, sub_both_sides=False, range_tol=0.01, dist_from_surf=0)[source]
Perform substitution-type doping on the surface and returns all possible configurations where one dopant is substituted per surface. Can substitute one surface or both.
- Parameters:
atom (str) – atom corresponding to substitutional dopant
sub_both_sides (bool) – If true, substitute an equivalent site on the other surface
target_species (list) – Specific species to substitute
range_tol (float) – Find viable substitution sites at a specific distance from the surface +- this tolerance
dist_from_surf (float) – Distance from the surface to find viable substitution sites, defaults to 0 to substitute at the surface
- get_extended_surface_mesh(repeat=(5, 5, 1))[source]
Get an extended surface mesh for to use for adsorption site finding by constructing supercell of surface sites.
- Parameters:
repeat (3-tuple) – repeat for getting extended surface mesh
- near_reduce(coords_set, threshold=0.0001)[source]
Prune coordinate set for coordinates that are within threshold.
- Parameters:
coords_set (Nx3 array-like) – list or array of coordinates
threshold (float) – threshold value for distance
- symm_reduce(coords_set, threshold=1e-06)[source]
Reduce the set of adsorbate sites by finding removing symmetrically equivalent duplicates.
- Parameters:
coords_set – coordinate set in Cartesian coordinates
threshold – tolerance for distance equivalence, used as input to in_coord_list_pbc for dupl. checking
- get_mi_vec(slab)[source]
Convenience function which returns the unit vector aligned with the miller index.
- get_rot(slab: Slab) SymmOp [source]
Get the transformation to rotate the z axis into the miller index.
- plot_slab(slab: Slab, ax: plt.Axes, scale=0.8, repeat=5, window=1.5, draw_unit_cell=True, decay=0.2, adsorption_sites=True, inverse=False)[source]
Help visualize the slab in a 2-D plot, for convenient viewing of output of AdsorbateSiteFinder.
- Parameters:
slab (slab) – Slab object to be visualized
ax (axes) – matplotlib axes with which to visualize
scale (float) – radius scaling for sites
repeat (int) – number of repeating unit cells to visualize
window (float) – window for setting the axes limits, is essentially a fraction of the unit cell limits
draw_unit_cell (bool) – flag indicating whether or not to draw cell
decay (float) – how the alpha-value decays along the z-axis
inverse (bool) – invert z axis to plot opposite surface
pymatgen.analysis.bond_dissociation module
Module for BondDissociationEnergies.
- class BondDissociationEnergies(molecule_entry: dict[str, str | dict[str, str | int]], fragment_entries: list[dict[str, str | dict[str, str | int]]], allow_additional_charge_separation: bool = False, multibreak: bool = False)[source]
Bases:
MSONable
Standard constructor for bond dissociation energies. All bonds in the principle molecule are looped through and their dissociation energies are calculated given the energies of the resulting fragments, or, in the case of a ring bond, from the energy of the molecule obtained from breaking the bond and opening the ring. This class should only be called after the energies of the optimized principle molecule and all relevant optimized fragments have been determined, either from quantum chemistry or elsewhere. It was written to provide the analysis after running an atomate fragmentation workflow.
The provided entries must have the following keys: formula_pretty, initial_molecule, final_molecule. If a PCM is present, all entries should also have a pcm_dielectric key.
- Parameters:
molecule_entry (dict) – Entry for the principle molecule. Should have the keys mentioned above.
fragment_entries (list[dict]) – Fragment entries. Each should have the keys mentioned above.
allow_additional_charge_separation (bool) – If True, consider larger than normal charge separation among fragments. Defaults to False. See the definition of self.expected_charges below for more specific information.
multibreak (bool) – If True, additionally attempt to break pairs of bonds. Defaults to False.
- build_new_entry(frags: list, bonds: list) list [source]
Build a new entry for bond dissociation that will be returned to the user.
- Parameters:
frags (list) – Fragments involved in the bond dissociation.
bonds (list) – Bonds broken in the dissociation process.
- Returns:
Formatted bond dissociation entries.
- Return type:
list
- filter_fragment_entries(fragment_entries: list) None [source]
Filter the fragment entries.
- Parameters:
fragment_entries (List) – Fragment entries to be filtered.
- fragment_and_process(bonds)[source]
Fragment and process bonds.
- Parameters:
bonds (list) – bonds to process.
- search_fragment_entries(frag) list [source]
Search all fragment entries for those isomorphic to the given fragment. We distinguish between entries where both initial and final MoleculeGraphs are isomorphic to the given fragment (entries) vs those where only the initial MoleculeGraph is isomorphic to the given fragment (initial_entries) vs those where only the final MoleculeGraph is isomorphic (final_entries).
- Parameters:
frag – Fragment
pymatgen.analysis.bond_valence module
This module implements classes to perform bond valence analyses.
- class BVAnalyzer(symm_tol=0.1, max_radius=4, max_permutations=100000, distance_scale_factor=1.015, charge_neutrality_tolerance=1e-05, forbidden_species=None)[source]
Bases:
object
This class implements a maximum a posteriori (MAP) estimation method to determine oxidation states in a structure. The algorithm is as follows: 1) The bond valence sum of all symmetrically distinct sites in a structure is calculated using the element-based parameters in M. O’Keefe, & N. Brese, JACS, 1991, 113(9), 3226-3229. doi:10.1021/ja00009a002. 2) The posterior probabilities of all oxidation states is then calculated using: P(oxi_state/BV) = K * P(BV/oxi_state) * P(oxi_state), where K is a constant factor for each element. P(BV/oxi_state) is calculated as a Gaussian with mean and std deviation determined from an analysis of the ICSD. The posterior P(oxi_state) is determined from a frequency analysis of the ICSD. 3) The oxidation states are then ranked in order of decreasing probability and the oxidation state combination that result in a charge neutral cell is selected.
Initialize the BV analyzer, with useful defaults.
- Parameters:
symm_tol – Symmetry tolerance used to determine which sites are symmetrically equivalent. Set to 0 to turn off symmetry.
max_radius – Maximum radius in Angstrom used to find nearest neighbors.
max_permutations – The maximum number of permutations of oxidation states to test.
distance_scale_factor – A scale factor to be applied. This is useful for scaling distances, esp in the case of calculation-relaxed structures which may tend to under (GGA) or over bind (LDA). The default of 1.015 works for GGA. For experimental structure, set this to 1.
charge_neutrality_tolerance – Tolerance on the charge neutrality when unordered structures are at stake.
forbidden_species – List of species that are forbidden (example : [“O-”] cannot be used) It is used when e.g. someone knows that some oxidation state cannot occur for some atom in a structure or list of structures.
- get_oxi_state_decorated_structure(structure: Structure) Structure [source]
Get an oxidation state decorated structure. This currently works only for ordered structures only.
- Parameters:
structure – Structure to analyze
- Returns:
modified with oxidation state decorations.
- Return type:
- Raises:
ValueError if the valences cannot be determined. –
- get_valences(structure: Structure)[source]
Get a list of valences for each site in the structure.
- Parameters:
structure – Structure to analyze
- Returns:
A list of valences for each site in the structure (for an ordered structure), e.g. [1, 1, -2] or a list of lists with the valences for each fractional element of each site in the structure (for an unordered structure), e.g. [[2, 4], [3], [-2], [-2], [-2]]
- Raises:
A ValueError if the valences cannot be determined. –
- add_oxidation_state_by_site_fraction(structure: Structure, oxidation_states: list[list[int]]) Structure [source]
Add oxidation states to a structure by fractional site.
- Parameters:
oxidation_states (list[list[int]]) – List of list of oxidation states for each site fraction for each site. e.g. [[2, 4], [3], [-2], [-2], [-2]]
- calculate_bv_sum(site, nn_list, scale_factor=1.0)[source]
Calculate the BV sum of a site.
- Parameters:
site (PeriodicSite) – The central site to calculate the bond valence
nn_list ([Neighbor]) – A list of namedtuple Neighbors having “distance” and “site” attributes
scale_factor (float) – A scale factor to be applied. This is useful for scaling distance, esp in the case of calculation-relaxed structures which may tend to under (GGA) or over bind (LDA).
- calculate_bv_sum_unordered(site, nn_list, scale_factor=1)[source]
Calculate the BV sum of a site for unordered structures.
- Parameters:
site (PeriodicSite) – The central site to calculate the bond valence
nn_list ([Neighbor]) – A list of namedtuple Neighbors having “distance” and “site” attributes
scale_factor (float) – A scale factor to be applied. This is useful for scaling distance, esp in the case of calculation-relaxed structures which may tend to under (GGA) or over bind (LDA).
- get_z_ordered_elmap(comp)[source]
Arbitrary ordered element map on the elements/species of a composition of a given site in an unordered structure. Returns a list of tuples ( element_or_specie: occupation) in the arbitrary order.
The arbitrary order is based on the Z of the element and the smallest fractional occupations first. Example : {“Ni3+”: 0.2, “Ni4+”: 0.2, “Cr3+”: 0.15, “Zn2+”: 0.34, “Cr4+”: 0.11} will yield the species in the following order : Cr4+, Cr3+, Ni3+, Ni4+, Zn2+ … or Cr4+, Cr3+, Ni4+, Ni3+, Zn2+
pymatgen.analysis.chempot_diagram module
This module implements the construction and plotting of chemical potential diagrams from a list of entries within a chemical system containing 2 or more elements. The chemical potential diagram is the mathematical dual to the traditional compositional phase diagram.
For more information, please cite/reference the paper below:
Todd, P. K., McDermott, M. J., Rom, C. L., Corrao, A. A., Denney, J. J., Dwaraknath, S. S., Khalifah, P. G., Persson, K. A., & Neilson, J. R. (2021). Selectivity in Yttrium Manganese Oxide Synthesis via Local Chemical Potentials in Hyperdimensional Phase Space. Journal of the American Chemical Society, 143(37), 15185-15194. https://doi.org/10.1021/jacs.1c06229
Please also consider referencing the original 1999 paper by H. Yokokawa, who outlined many of its possible uses:
Yokokawa, H. “Generalized chemical potential diagram and its applications to chemical reactions at interfaces between dissimilar materials.” JPE 20, 258 (1999). https://doi.org/10.1361/105497199770335794
- class ChemicalPotentialDiagram(entries: list[PDEntry], limits: dict[Element, tuple[float, float]] | None = None, default_min_limit: float = -50.0, formal_chempots: bool = True)[source]
Bases:
MSONable
The chemical potential diagram is the mathematical dual to the compositional phase diagram. To create the diagram, convex minimization is performed in energy (E) vs. chemical potential (μ) space by taking the lower convex envelope of hyperplanes. Accordingly, “points” on the compositional phase diagram become N-dimensional convex polytopes (domains) in chemical potential space.
For more information on this specific implementation of the algorithm, please cite/reference the paper below:
Todd, P. K., McDermott, M. J., Rom, C. L., Corrao, A. A., Denney, J. J., Dwaraknath, S. S., Khalifah, P. G., Persson, K. A., & Neilson, J. R. (2021). Selectivity in Yttrium Manganese Oxide Synthesis via Local Chemical Potentials in Hyperdimensional Phase Space. Journal of the American Chemical Society, 143(37), 15185-15194. https://doi.org/10.1021/jacs.1c06229
- Parameters:
entries (list[PDEntry]) – PDEntry-like objects containing a composition and energy. Must contain elemental references and be suitable for typical phase diagram construction. Entries must be within a chemical system of with 2+ elements.
limits (dict[Element, float] | None) – Bounds of elemental chemical potentials (min, max), which are used to construct the border hyperplanes used in the HalfSpaceIntersection algorithm; these constrain the space over which the domains are calculated and also determine the size of the plotted diagram. Any elemental limits not specified are covered in the default_min_limit argument. e.g. {Element(“Li”): [-12.0, 0.0], …}
default_min_limit (float) – Default minimum chemical potential limit (i.e., lower bound) for unspecified elements within the “limits” argument.
formal_chempots (bool) – Whether to plot the formal (‘reference’) chemical potentials (i.e. μ_X - μ_X^0) or the absolute DFT reference energies (i.e. μ_X(DFT)). Default is True (i.e. plot formal chemical potentials).
- property domains: dict[str, ndarray][source]
Mapping of formulas to array of domain boundary points.
- property entry_dict: dict[str, ComputedEntry][source]
Mapping between reduced formula and ComputedEntry.
- get_plot(elements: list[Element | str] | None = None, label_stable: bool | None = True, formulas_to_draw: list[str] | None = None, draw_formula_meshes: bool | None = True, draw_formula_lines: bool | None = True, formula_colors: list[str] = ['rgb(27,158,119)', 'rgb(217,95,2)', 'rgb(117,112,179)', 'rgb(231,41,138)', 'rgb(102,166,30)', 'rgb(230,171,2)', 'rgb(166,118,29)', 'rgb(102,102,102)'], element_padding: float | None = 1.0) Figure [source]
Plot the 2-dimensional or 3-dimensional chemical potential diagram using an interactive Plotly interface.
Elemental axes can be specified; if none provided, will automatically default to first 2-3 elements within the “elements” attribute.
In 3D, this method also allows for plotting of lower-dimensional “slices” of hyperdimensional polytopes (e.g., the LiMnO2 domain within a Y-Mn-O diagram). This allows for visualization of some of the phase boundaries that can only be seen fully in high dimensional space; see the “formulas_to_draw” argument.
- Parameters:
elements – list of elements to use as axes in the diagram. If None, automatically defaults to the first 2 or elements within the object’s “elements” attribute.
label_stable – whether to label stable phases by their reduced formulas. Defaults to True.
formulas_to_draw – for 3-dimensional diagrams, an optional list of formulas to plot on the diagram; if these are from a different chemical system a 3-d polyhedron “slice” will be plotted. Defaults to None.
draw_formula_meshes – whether to draw a colored mesh for the optionally specified formulas_to_draw. Defaults to True.
draw_formula_lines – whether to draw bounding lines for the optionally specified formulas_to_draw. Defaults to True.
formula_colors – a list of colors to use in the plotting of the optionally specified formulas_to-draw. Defaults to the Plotly Dark2 color scheme.
element_padding – if provided, automatically adjusts chemical potential axis limits of the plot such that elemental domains have the specified padding (in eV/atom), helping provide visual clarity. Defaults to 1.0.
- Returns:
plotly.graph_objects.Figure
- get_2d_orthonormal_vector(line_pts: ndarray) ndarray [source]
Calculates a vector that is orthonormal to a line given by a set of points. Used for determining the location of an annotation on a 2-d chemical potential diagram.
- Parameters:
line_pts – a 2x2 array in the form of [[x0, y0], [x1, y1]] giving the coordinates of a line
- Returns:
A length-2 vector that is orthonormal to the line.
- Return type:
np.ndarray
- get_centroid_2d(vertices: ndarray) ndarray [source]
A bare-bones implementation of the formula for calculating the centroid of a 2D polygon. Useful for calculating the location of an annotation on a chemical potential domain within a 3D chemical potential diagram.
NOTE vertices must be ordered circumferentially!
- Parameters:
vertices – array of 2-d coordinates corresponding to a polygon, ordered circumferentially
- Returns:
Giving 2-d centroid coordinates.
- Return type:
np.ndarray
- simple_pca(data: ndarray, k: int = 2) tuple[ndarray, ndarray, ndarray] [source]
A bare-bones implementation of principal component analysis (PCA) used in the ChemicalPotentialDiagram class for plotting.
- Parameters:
data – array of observations
k – Number of principal components returned
- Returns:
projected data, eigenvalues, eigenvectors
- Return type:
tuple
pymatgen.analysis.cost module
This module is used to estimate the cost of various compounds. Costs are taken from the a CostDB instance, for example a CSV file via CostDBCSV. For compounds with no cost listed, a Phase Diagram style convex hull optimization is performed to determine a set of compositions that can be mixed to give the desired compound with lowest total cost.
- class CostAnalyzer(costdb: CostDB)[source]
Bases:
object
Given a CostDB, figures out the minimum cost solutions via convex hull.
- Parameters:
costdb (CostDB) – Cost database to use.
- get_cost_per_kg(comp)[source]
Get best estimate of minimum cost/kg based on known data.
- Parameters:
comp (CompositionLike) – chemical formula
- Returns:
energy cost/kg
- Return type:
float
- class CostDB[source]
Bases:
ABC
Abstract class for representing a Cost database. Can be extended, e.g. for file-based or REST-based databases.
- class CostDBCSV(filename)[source]
Bases:
CostDB
Read a CSV file to get costs. Format is formula,cost_per_kg,name,BibTeX.
- Parameters:
filename (str) – Filename of cost database.
- class CostEntry(composition, cost, name, reference)[source]
Bases:
PDEntry
Extends PDEntry to include a BibTeX reference and include language about cost.
- Parameters:
composition (Composition) – chemical composition of the entry
cost (float) – per mol, NOT per kg of the full Composition
name (str) – Optional parameter to name the entry. Defaults to the reduced chemical formula as in PDEntry.
reference (str) – Reference data as BiBTeX string.
pymatgen.analysis.dimensionality module
This module provides functions to get the dimensionality of a structure.
A number of different algorithms are implemented. These are based on the following publications:
- get_dimensionality_larsen:
P. M. Larsen, M. Pandey, M. Strange, K. W. Jacobsen. Definition of a scoring parameter to identify low-dimensional materials components. Phys. Rev. Materials 3, 034003 (2019).
- get_dimensionality_cheon:
Cheon, G.; Duerloo, K.-A. N.; Sendek, A. D.; Porter, C.; Chen, Y.; Reed, E. J. Data Mining for New Two- and One-Dimensional Weakly Bonded Solids and Lattice-Commensurate Heterostructures. Nano Lett. 2017.
- get_dimensionality_gorai:
Gorai, P., Toberer, E. & Stevanovic, V. Computational Identification of Promising Thermoelectric Materials Among Known Quasi-2D Binary Compounds. J. Mater. Chem. A 2, 4136 (2016).
- calculate_dimensionality_of_site(bonded_structure, site_index, inc_vertices=False)[source]
Calculate the dimensionality of the component containing the given site.
Implements directly the modified breadth-first-search algorithm described in Algorithm 1 of:
P. M. Larsen, M. Pandey, M. Strange, K. W. Jacobsen. Definition of a scoring parameter to identify low-dimensional materials components. Phys. Rev. Materials 3, 034003 (2019).
- Parameters:
bonded_structure (StructureGraph) – A structure with bonds, represented as a pymatgen structure graph. For example, generated using the CrystalNN.get_bonded_structure() method.
site_index (int) – The index of a site in the component of interest.
inc_vertices (bool, optional) – Whether to return the vertices (site images) of the component.
- Returns:
- If inc_vertices is False, the dimensionality of the
component will be returned as an int. If inc_vertices is true, the function will return a tuple of (dimensionality, vertices), where vertices is a list of tuples. E.g. [(0, 0, 0), (1, 1, 1)].
- Return type:
int | tuple
- find_clusters(struct, connected_matrix)[source]
Find bonded clusters of atoms in the structure with periodic boundary conditions.
If there are atoms that are not bonded to anything, returns [0,1,0]. (For faster computation time)
Author: Gowoon Cheon Email: gcheon@stanford.edu
- Parameters:
struct (Structure) – Input structure
connected_matrix – Must be made from the same structure with find_connected_atoms() function.
- Returns:
the size of the largest cluster in the crystal structure min_cluster: the size of the smallest cluster in the crystal structure clusters: list of bonded clusters found here, clusters are formatted as sets of indices of atoms
- Return type:
max_cluster
- find_connected_atoms(struct, tolerance=0.45, ldict=None)[source]
Find bonded atoms and returns a adjacency matrix of bonded atoms.
Author: “Gowoon Cheon” Email: “gcheon@stanford.edu”
- Parameters:
struct (Structure) – Input structure
tolerance – length in angstroms used in finding bonded atoms. Two atoms are considered bonded if (radius of atom 1) + (radius of atom 2) + (tolerance) < (distance between atoms 1 and 2). Default value = 0.45, the value used by JMol and Cheon et al.
ldict – dictionary of bond lengths used in finding bonded atoms. Values from JMol are used as default
- Returns:
- A numpy array of shape (number of atoms, number of atoms);
If any image of atom j is bonded to atom i with periodic boundary conditions, the matrix element [atom i, atom j] is 1.
- Return type:
np.ndarray
- get_dimensionality_cheon(structure_raw, tolerance=0.45, ldict=None, standardize=True, larger_cell=False)[source]
Algorithm for finding the dimensions of connected subunits in a structure. This method finds the dimensionality of the material even when the material is not layered along low-index planes, or does not have flat layers/molecular wires.
Author: “Gowoon Cheon” Email: “gcheon@stanford.edu”
See details at :
Cheon, G.; Duerloo, K.-A. N.; Sendek, A. D.; Porter, C.; Chen, Y.; Reed, E. J. Data Mining for New Two- and One-Dimensional Weakly Bonded Solids and Lattice-Commensurate Heterostructures. Nano Lett. 2017.
- Parameters:
structure_raw (Structure) – A pymatgen Structure object.
tolerance (float) – length in angstroms used in finding bonded atoms. Two atoms are considered bonded if (radius of atom 1) + (radius of atom 2) + (tolerance) < (distance between atoms 1 and 2). Default value = 0.45, the value used by JMol and Cheon et al.
ldict (dict) – dictionary of bond lengths used in finding bonded atoms. Values from JMol are used as default
standardize – works with conventional standard structures if True. It is recommended to keep this as True.
larger_cell –
tests with 3x3x3 supercell instead of 2x2x2. Testing with 2x2x2 supercell is faster but misclassifies rare interpenetrated 3D
structures. Testing with a larger cell circumvents this problem
- Returns:
- dimension of the largest cluster as a string. If there are ions
or molecules it returns ‘intercalated ion/molecule’
- Return type:
str
- get_dimensionality_gorai(structure, max_hkl=2, el_radius_updates=None, min_slab_size=5, min_vacuum_size=5, standardize=True, bonds=None)[source]
This method returns whether a structure is 3D, 2D (layered), or 1D (linear chains or molecules) according to the algorithm published in Gorai, P., Toberer, E. & Stevanovic, V. Computational Identification of Promising Thermoelectric Materials Among Known Quasi-2D Binary Compounds. J. Mater. Chem. A 2, 4136 (2016).
Note that a 1D structure detection might indicate problems in the bonding algorithm, particularly for ionic crystals (e.g., NaCl)
Users can change the behavior of bonds detection by passing either el_radius_updates to update atomic radii for auto-detection of max bond distances, or bonds to explicitly specify max bond distances for atom pairs. Note that if you pass both, el_radius_updates are ignored.
- Parameters:
structure (Structure) – structure to analyze dimensionality for
max_hkl (int) – max index of planes to look for layers
el_radius_updates (dict) – symbol->float to update atomic radii
min_slab_size (float) – internal surface construction parameter
min_vacuum_size (float) – internal surface construction parameter
standardize (bool) – whether to standardize the structure before analysis. Set to False only if you already have the structure in a convention where layers / chains will be along low <hkl> indexes.
bonds (dict[tuple, float]) – bonds are specified as a dict of 2-tuples of Species mapped to floats, the max bonding distance. For example, PO4 groups may be defined as {(“P”, “O”): 3}.
- Returns:
- the dimensionality of the structure - 1 (molecules/chains),
2 (layered), or 3 (3D)
- Return type:
int
- get_dimensionality_larsen(bonded_structure)[source]
Gets the dimensionality of a bonded structure.
The dimensionality of the structure is the highest dimensionality of all structure components. This method is very robust and can handle many tricky structures, regardless of structure type or improper connections due to periodic boundary conditions.
Requires a StructureGraph object as input. This can be generated using one of the NearNeighbor classes. For example, using the CrystalNN class:
bonded_structure = CrystalNN().get_bonded_structure(structure)
Based on the modified breadth-first-search algorithm described in:
P. M. Larsen, M. Pandey, M. Strange, K. W. Jacobsen. Definition of a scoring parameter to identify low-dimensional materials components. Phys. Rev. Materials 3, 034003 (2019).
- Parameters:
bonded_structure (StructureGraph) – A structure with bonds, represented as a pymatgen structure graph. For example, generated using the CrystalNN.get_bonded_structure() method.
- Returns:
The dimensionality of the structure.
- Return type:
int
- get_structure_components(bonded_structure, inc_orientation=False, inc_site_ids=False, inc_molecule_graph=False)[source]
Gets information on the components in a bonded structure.
Correctly determines the dimensionality of all structures, regardless of structure type or improper connections due to periodic boundary conditions.
Requires a StructureGraph object as input. This can be generated using one of the NearNeighbor classes. For example, using the CrystalNN class:
bonded_structure = CrystalNN().get_bonded_structure(structure)
Based on the modified breadth-first-search algorithm described in:
P. M. Larsen, M. Pandey, M. Strange, K. W. Jacobsen. Definition of a scoring parameter to identify low-dimensional materials components. Phys. Rev. Materials 3, 034003 (2019).
- Parameters:
bonded_structure (StructureGraph) – A structure with bonds, represented as a pymatgen structure graph. For example, generated using the CrystalNN.get_bonded_structure() method.
inc_orientation (bool, optional) – Whether to include the orientation of the structure component. For surfaces, the miller index is given, for one-dimensional structures, the direction of the chain is given.
inc_site_ids (bool, optional) – Whether to include the site indices of the sites in the structure component.
inc_molecule_graph (bool, optional) – Whether to include MoleculeGraph objects for zero-dimensional components.
- Returns:
- Information on the components in a structure as a list
of dictionaries with the keys:
- ”structure_graph”: A pymatgen StructureGraph object for the
component.
- ”dimensionality”: The dimensionality of the structure component as an
int.
- ”orientation”: If inc_orientation is True, the orientation of the
component as a tuple. E.g. (1, 1, 1)
- ”site_ids”: If inc_site_ids is True, the site indices of the
sites in the component as a tuple.
- ”molecule_graph”: If inc_molecule_graph is True, the site a
MoleculeGraph object for zero-dimensional components.
- Return type:
list[dict]
- zero_d_graph_to_molecule_graph(bonded_structure, graph)[source]
Converts a zero-dimensional networkx Graph object into a MoleculeGraph.
Implements a similar breadth-first search to that in calculate_dimensionality_of_site().
- Parameters:
bonded_structure (StructureGraph) – A structure with bonds, represented as a pymatgen structure graph. For example, generated using the CrystalNN.get_bonded_structure() method.
graph (nx.Graph) – A networkx Graph object for the component of interest.
- Returns:
A MoleculeGraph object of the component.
- Return type:
pymatgen.analysis.disorder module
This module provides various methods to analyze order/disorder in materials.
- get_warren_cowley_parameters(structure: Structure, r: float, dr: float) dict[tuple, float] [source]
Warren-Crowley parameters.
- Parameters:
structure – Pymatgen Structure.
r – Radius
dr – Shell width
- Returns:
-1.0, …}
- Return type:
Warren-Crowley parameters in the form of a dict, e.g. {(Element Mo, Element W)
pymatgen.analysis.energy_models module
This module implements a EnergyModel abstract class and some basic implementations. Basically, an EnergyModel is any model that returns an “energy” for any given structure.
- class EnergyModel[source]
Bases:
MSONable
,ABC
Abstract structure filter class.
- class EwaldElectrostaticModel(real_space_cut=None, recip_space_cut=None, eta=None, acc_factor=8.0)[source]
Bases:
EnergyModel
Wrapper around EwaldSum to calculate the electrostatic energy.
Initialize the model. Args have the same definitions as in pymatgen.analysis.ewald.EwaldSummation.
- Parameters:
real_space_cut (float) – Real space cutoff radius dictating how many terms are used in the real space sum. Defaults to None, which means determine automatically using the formula given in gulp 3.1 documentation.
recip_space_cut (float) – Reciprocal space cutoff radius. Defaults to None, which means determine automatically using the formula given in gulp 3.1 documentation.
eta (float) – Screening parameter. Defaults to None, which means determine automatically.
acc_factor (float) – No. of significant figures each sum is converged to.
- class IsingModel(j, max_radius)[source]
Bases:
EnergyModel
A very simple Ising model, with r^2 decay.
- Parameters:
j (float) – The interaction parameter. E = J * spin1 * spin2.
radius (float) – max_radius for the interaction.
- class NsitesModel[source]
Bases:
EnergyModel
Sets the energy to the number of sites. More sites => higher “energy”. Used to rank structures from smallest number of sites to largest number of sites after enumeration.
- class SymmetryModel(symprec: float = 0.1, angle_tolerance=5)[source]
Bases:
EnergyModel
Sets the energy to the negative of the spacegroup number. Higher symmetry => lower “energy”.
Args have same meaning as in pymatgen.symmetry.SpacegroupAnalyzer.
- Parameters:
symprec (float) – Symmetry tolerance. Defaults to 0.1.
angle_tolerance (float) – Tolerance for angles. Defaults to 5 degrees.
pymatgen.analysis.eos module
This module implements various equation of states.
Note: Most of the code were initially adapted from ASE and deltafactor by @gmatteo but has since undergone major refactoring.
- class Birch(volumes, energies)[source]
Bases:
EOSBase
Birch EOS.
- Parameters:
volumes (Sequence[float]) – in Ang^3.
energies (Sequence[float]) – in eV.
- class BirchMurnaghan(volumes, energies)[source]
Bases:
EOSBase
BirchMurnaghan EOS.
- Parameters:
volumes (Sequence[float]) – in Ang^3.
energies (Sequence[float]) – in eV.
- class DeltaFactor(volumes, energies)[source]
Bases:
PolynomialEOS
Fitting a polynomial EOS using delta factor.
- Parameters:
volumes (Sequence[float]) – in Ang^3.
energies (Sequence[float]) – in eV.
- class EOS(eos_name='murnaghan')[source]
Bases:
object
Convenient wrapper. Retained in its original state to ensure backward compatibility.
Fit equation of state for bulk systems.
The following equations are supported:
murnaghan: PRB 28, 5480 (1983)
- birch: Intermetallic compounds: Principles and Practice, Vol I:
Principles. pages 195-210
birch_murnaghan: PRB 70, 224107
pourier_tarantola: PRB 70, 224107
vinet: PRB 70, 224107
deltafactor
numerical_eos: 10.1103/PhysRevB.90.174107.
Usage:
eos = EOS(eos_name=’murnaghan’) eos_fit = eos.fit(volumes, energies) eos_fit.plot()
- Parameters:
eos_name (str) – Type of EOS to fit.
- MODELS: ClassVar = {'birch': <class 'pymatgen.analysis.eos.Birch'>, 'birch_murnaghan': <class 'pymatgen.analysis.eos.BirchMurnaghan'>, 'deltafactor': <class 'pymatgen.analysis.eos.DeltaFactor'>, 'murnaghan': <class 'pymatgen.analysis.eos.Murnaghan'>, 'numerical_eos': <class 'pymatgen.analysis.eos.NumericalEOS'>, 'pourier_tarantola': <class 'pymatgen.analysis.eos.PourierTarantola'>, 'vinet': <class 'pymatgen.analysis.eos.Vinet'>}[source]
- class EOSBase(volumes, energies)[source]
Bases:
ABC
Abstract class that must be subclassed by all equation of state implementations.
- Parameters:
volumes (Sequence[float]) – in Ang^3.
energies (Sequence[float]) – in eV.
- property b0_GPa: FloatWithUnit[source]
The bulk modulus in GPa. This assumes the energy and volumes are in eV and Ang^3.
- fit()[source]
Do the fitting. Does least square fitting. If you want to use custom fitting, must override this.
- func(volume)[source]
The equation of state function with the parameters other than volume set to the ones obtained from fitting.
- Parameters:
volume (float | list[float]) – volumes in Ang^3
- Returns:
numpy.array
- plot(width=8, height=None, ax: plt.Axes = None, dpi=None, **kwargs)[source]
Plot the equation of state.
- Parameters:
width (float) – Width of plot in inches. Defaults to 8in.
height (float) – Height of plot in inches. Defaults to width * golden ratio.
ax (plt.Axes) – If supplied, changes will be made to the existing Axes. Otherwise, new Axes will be created.
dpi
kwargs (dict) – additional args fed to pyplot.plot. supported keys: style, color, text, label
- Returns:
The matplotlib axes.
- Return type:
plt.Axes
- plot_ax(ax: plt.Axes = None, fontsize=12, **kwargs)[source]
Plot the equation of state on axis ax.
- Parameters:
ax – matplotlib Axes or None if a new figure should be created.
fontsize – Legend fontsize.
color (str) – plot color.
label (str) – Plot label
text (str) – Legend text (options)
- Returns:
matplotlib figure.
- Return type:
plt.Figure
Keyword arguments controlling the display of the figure:
kwargs
Meaning
title
Title of the plot (Default: None).
show
True to show the figure (default: True).
savefig
“abc.png” or “abc.eps” to save the figure to a file.
size_kwargs
Dictionary with options passed to fig.set_size_inches e.g. size_kwargs=dict(w=3, h=4)
tight_layout
True to call fig.tight_layout (default: False)
ax_grid
True (False) to add (remove) grid from all axes in fig. Default: None i.e. fig is left unchanged.
ax_annotate
Add labels to subplots e.g. (a), (b). Default: False
fig_close
Close figure. Default: False.
- class Murnaghan(volumes, energies)[source]
Bases:
EOSBase
Murnaghan EOS.
- Parameters:
volumes (Sequence[float]) – in Ang^3.
energies (Sequence[float]) – in eV.
- class NumericalEOS(volumes, energies)[source]
Bases:
PolynomialEOS
A numerical EOS.
- Parameters:
volumes (Sequence[float]) – in Ang^3.
energies (Sequence[float]) – in eV.
- fit(min_ndata_factor=3, max_poly_order_factor=5, min_poly_order=2)[source]
Fit the input data to the ‘numerical eos’, the equation of state employed in the quasiharmonic Debye model described in the paper: 10.1103/PhysRevB.90.174107.
credits: Cormac Toher
- Parameters:
min_ndata_factor (int) – parameter that controls the minimum number of data points that will be used for fitting. minimum number of data points = total data points-2*min_ndata_factor
max_poly_order_factor (int) – parameter that limits the max order of the polynomial used for fitting. max_poly_order = number of data points used for fitting - max_poly_order_factor
min_poly_order (int) – minimum order of the polynomial to be considered for fitting.
- class PolynomialEOS(volumes, energies)[source]
Bases:
EOSBase
Derives from EOSBase. Polynomial based equations of states must subclass this.
- Parameters:
volumes (Sequence[float]) – in Ang^3.
energies (Sequence[float]) – in eV.
pymatgen.analysis.ewald module
This module provides classes for calculating the Ewald sum of a structure.
- class EwaldMinimizer(matrix, m_list, num_to_return=1, algo=0)[source]
Bases:
object
This class determines the manipulations that will minimize an Ewald matrix, given a list of possible manipulations. This class does not perform the manipulations on a structure, but will return the list of manipulations that should be done on one to produce the minimal structure. It returns the manipulations for the n lowest energy orderings. This class should be used to perform fractional species substitution or fractional species removal to produce a new structure. These manipulations create large numbers of candidate structures, and this class can be used to pick out those with the lowest Ewald sum.
An alternative (possibly more intuitive) interface to this class is the order disordered structure transformation.
Author - Will Richards
- Parameters:
matrix – A matrix of the Ewald sum interaction energies. This is stored in the class as a diagonally symmetric array and so self._matrix will not be the same as the input matrix.
m_list – list of manipulations. each item is of the form (multiplication fraction, number_of_indices, indices, species) These are sorted such that the first manipulation contains the most permutations. this is actually evaluated last in the recursion since I’m using pop.
num_to_return – The minimizer will find the number_returned lowest energy structures. This is likely to return a number of duplicate structures so it may be necessary to overestimate and then remove the duplicates later. (duplicate checking in this process is extremely expensive).
- add_m_list(matrix_sum, m_list)[source]
Add an m_list to the output_lists and updates the current minimum if the list is full.
- best_case(matrix, m_list, indices_left)[source]
Compute a best case given a matrix and manipulation list.
- Parameters:
matrix – the current matrix (with some permutations already performed)
m_list – [(multiplication fraction, number_of_indices, indices, species)] describing the manipulation
indices – Set of indices which haven’t had a permutation performed on them.
- classmethod get_next_index(matrix, manipulation, indices_left)[source]
Get an index that should have the most negative effect on the matrix sum.
- class EwaldSummation(structure, real_space_cut=None, recip_space_cut=None, eta=None, acc_factor=12.0, w=0.7071067811865475, compute_forces=False)[source]
Bases:
MSONable
Calculates the electrostatic energy of a periodic array of charges using the Ewald technique.
- Ref:
Ewald summation techniques in perspective: a survey Abdulnour Y. Toukmaji and John A. Board Jr. DOI: 10.1016/0010-4655(96)00016-1 URL: http://www.ee.duke.edu/~ayt/ewaldpaper/ewaldpaper.html
This matrix can be used to do fast calculations of Ewald sums after species removal.
E = E_recip + E_real + E_point
Atomic units used in the code, then converted to eV.
Initialize and calculate the Ewald sum. Default convergence parameters have been specified, but you can override them if you wish.
- Parameters:
structure (Structure) – Input structure that must have proper Species on all sites, i.e. Element with oxidation state. Use Structure.add_oxidation_state… for example.
real_space_cut (float) – Real space cutoff radius dictating how many terms are used in the real space sum. Defaults to None, which means determine automatically using the formula given in gulp 3.1 documentation.
recip_space_cut (float) – Reciprocal space cutoff radius. Defaults to None, which means determine automatically using the formula given in gulp 3.1 documentation.
eta (float) – The screening parameter. Defaults to None, which means determine automatically.
acc_factor (float) – No. of significant figures each sum is converged to.
w (float) – Weight parameter, w, has been included that represents the relative computational expense of calculating a term in real and reciprocal space. Default of 0.7 reproduces result similar to GULP 4.2. This has little effect on the total energy, but may influence speed of computation in large systems. Note that this parameter is used only when the cutoffs are set to None.
compute_forces (bool) – Whether to compute forces. False by default since it is usually not needed.
- as_dict(verbosity: int = 0) dict [source]
JSON-serialization dict representation of EwaldSummation.
- Parameters:
verbosity (int) – Verbosity level. Default of 0 only includes the matrix representation. Set to 1 for more details.
- compute_partial_energy(removed_indices)[source]
Get total Ewald energy for certain sites being removed, i.e. zeroed out.
- compute_sub_structure(sub_structure, tol: float = 0.001)[source]
Get total Ewald energy for an sub structure in the same lattice. The sub_structure must be a subset of the original structure, with possible different charges.
- Parameters:
substructure (Structure) – Substructure to compute Ewald sum for.
tol (float) – Tolerance for site matching in fractional coordinates.
- Returns:
Ewald sum of substructure.
- classmethod from_dict(dct: dict[str, Any], fmt: str | None = None, **kwargs) Self [source]
Create an EwaldSummation instance from JSON-serialized dictionary.
- Parameters:
dct (dict) – Dictionary representation
fmt (str, optional) – Unused. Defaults to None.
- Returns:
class instance
- Return type:
- get_site_energy(site_index)[source]
Compute the energy for a single site in the structure.
- Parameters:
site_index (int) – Index of site
- Returns:
Energy of that site
- Return type:
float
- property point_energy_matrix[source]
The point space matrix. A diagonal matrix with the point terms for each site in the diagonal elements.
- property real_space_energy_matrix[source]
The real space energy matrix. Each matrix element (i, j) corresponds to the interaction energy between site i and site j in real space.
pymatgen.analysis.excitation module
This module defines an excitation spectrum class.
pymatgen.analysis.fragmenter module
Perform fragmentation of molecules.
- class Fragmenter(molecule: Molecule, edges: list | None = None, depth: int = 1, open_rings: bool = False, use_metal_edge_extender: bool = False, opt_steps: int = 10000, prev_unique_frag_dict: dict | None = None, assume_previous_thoroughness: bool = True)[source]
Bases:
MSONable
Molecule fragmenter class.
Standard constructor for molecule fragmentation.
- Parameters:
molecule (Molecule) – The molecule to fragment.
edges (list) – List of index pairs that define graph edges, aka molecule bonds. If not set, edges will be determined with OpenBabel. Defaults to None.
depth (int) – The number of levels of iterative fragmentation to perform, where each level will include fragments obtained by breaking one bond of a fragment one level up. Defaults to 1. However, if set to 0, instead all possible fragments are generated using an alternative, non-iterative scheme.
open_rings (bool) – Whether or not to open any rings encountered during fragmentation. Defaults to False. If true, any bond that fails to yield disconnected graphs when broken is instead removed and the entire structure is optimized with OpenBabel in order to obtain a good initial guess for an opened geometry that can then be put back into QChem to be optimized without the ring just reforming.
use_metal_edge_extender (bool) – Whether or not to attempt to add additional edges from O, N, F, or Cl to any Li or Mg atoms present that OpenBabel may have missed. Defaults to False. Most important for ionic bonding. Note that additional metal edges may yield new “rings” (e.g. -C-O-Li-O- in LiEC) that will not play nicely with ring opening.
opt_steps (int) – Number of optimization steps when opening rings. Defaults to 10000.
prev_unique_frag_dict (dict) – A dictionary of previously identified unique fragments. Defaults to None. Typically only used when trying to find the set of unique fragments that come from multiple molecules.
assume_previous_thoroughness (bool) – Whether or not to assume that a molecule / fragment provided in prev_unique_frag_dict has all of its unique subfragments also provided in prev_unique_frag_dict. Defaults to True. This is an essential optimization when trying to find the set of unique fragments that come from multiple molecules if all of those molecules are being fully iteratively fragmented. However, if you’re passing a prev_unique_frag_dict which includes a molecule and its fragments that were generated at insufficient depth to find all possible subfragments to a fragmentation calculation of a different molecule that you aim to find all possible subfragments of and which has common subfragments with the previous molecule, this optimization will cause you to miss some unique subfragments.
- open_ring(mol_graph: MoleculeGraph, bond: list, opt_steps: int) MoleculeGraph [source]
Open a ring using OpenBabel’s local opt. Given a molecule graph and a bond, convert the molecule graph into an OpenBabel molecule, remove the given bond, perform the local opt with the number of steps determined by self.steps, and then convert the resulting structure back into a molecule graph to be returned.
pymatgen.analysis.functional_groups module
Determine functional groups present in a Molecule.
- class FunctionalGroupExtractor(molecule, optimize=False)[source]
Bases:
object
This class is used to algorithmically parse a molecule (represented by an instance of pymatgen.analysis.graphs.MoleculeGraph) and determine arbitrary functional groups.
Instantiation method for FunctionalGroupExtractor.
- Parameters:
molecule – Either a filename, a pymatgen.core.structure.Molecule object, or a pymatgen.analysis.graphs.MoleculeGraph object.
optimize – Default False. If True, then the input molecule will be modified, adding Hydrogens, performing a simple conformer search, etc.
- categorize_functional_groups(groups)[source]
Determine classes of functional groups present in a set.
- Parameters:
groups – Set of functional groups.
- Returns:
dict containing representations of the groups, the indices of where the group occurs in the MoleculeGraph, and how many of each type of group there is.
- get_all_functional_groups(elements=None, func_groups=None, catch_basic=True)[source]
Identify all functional groups (or all within a certain subset) in the molecule, combining the methods described above.
- Parameters:
elements – List of elements that will qualify a carbon as special (if only certain functional groups are of interest). Default None.
func_groups – List of strs representing the functional groups of interest. Default to None, meaning that all of the functional groups defined in this function will be sought.
catch_basic – bool. If True, use get_basic_functional_groups and other methods
- Returns:
list of sets of ints, representing groups of connected atoms
- get_basic_functional_groups(func_groups=None)[source]
Identify functional groups that cannot be identified by the Ertl method of get_special_carbon and get_heteroatoms, such as benzene rings, methyl groups, and ethyl groups.
TODO: Think of other functional groups that are important enough to be added (ex: do we need ethyl, butyl, propyl?)
- Parameters:
func_groups – List of strs representing the functional groups of interest. Default to None, meaning that all of the functional groups defined in this function will be sought.
- Returns:
list of sets of ints, representing groups of connected atoms
- get_heteroatoms(elements=None)[source]
Identify non-H, non-C atoms in the MoleculeGraph, returning a list of their node indices.
- Parameters:
elements – List of elements to identify (if only certain
interest). (functional groups are of)
- Returns:
set of ints representing node indices
- get_special_carbon(elements=None)[source]
Identify Carbon atoms in the MoleculeGraph that fit the characteristics defined Ertl (2017), returning a list of their node indices.
- The conditions for marking carbon atoms are (quoted from Ertl):
“- atoms connected by non-aromatic double or triple bond to any heteroatom - atoms in nonaromatic carbon-carbon double or triple bonds - acetal carbons, i.e. sp3 carbons connected to two or more oxygens, nitrogens or sulfurs; these O, N or S atoms must have only single bonds - all atoms in oxirane, aziridine and thiirane rings”
- Parameters:
elements – List of elements that will qualify a carbon as special (if only certain functional groups are of interest). Default None.
- Returns:
set of ints representing node indices
- link_marked_atoms(atoms)[source]
Take a list of marked “interesting” atoms (heteroatoms, special carbons) and attempt to connect them, returning a list of disjoint groups of special atoms (and their connected hydrogens).
- Parameters:
atoms – set of marked “interesting” atoms, presumably identified using other functions in this class.
- Returns:
list of sets of ints, representing groups of connected atoms
pymatgen.analysis.graphs module
Module for graph representations of crystals and molecules.
- class ConnectedSite(site, jimage, index, weight, dist)[source]
Bases:
NamedTuple
Create new instance of ConnectedSite(site, jimage, index, weight, dist)
- site: PeriodicSite[source]
Alias for field number 0
- exception MolGraphSplitError[source]
Bases:
Exception
Raised when a molecule graph is failed to split into two disconnected subgraphs.
- class MoleculeGraph(molecule, graph_data=None)[source]
Bases:
MSONable
This is a class for annotating a Molecule with bond information, stored in the form of a graph. A “bond” does not necessarily have to be a chemical bond, but can store any kind of information that connects two Sites.
If constructing this class manually, use the from_empty_graph method or from_local_env_strategy method (using an algorithm provided by the local_env module, such as O’Keeffe).
This class that contains connection information: relationships between sites represented by a Graph structure, and an associated structure object.
This class uses the NetworkX package to store and operate on the graph itself, but contains a lot of helper methods to make associating a graph with a given molecule easier.
Use cases for this include storing bonding information, NMR J-couplings, Heisenberg exchange parameters, etc.
- Parameters:
molecule – Molecule object
graph_data – dict containing graph information in dict format (not intended to be constructed manually, see as_dict method for format)
- add_edge(from_index, to_index, weight=None, warn_duplicates=True, edge_properties=None)[source]
Add edge to graph.
Since physically a ‘bond’ (or other connection between sites) doesn’t have a direction, from_index, from_jimage can be swapped with to_index, to_jimage.
However, images will always be shifted so that from_index < to_index and from_jimage becomes (0, 0, 0).
- Parameters:
from_index – index of site connecting from
to_index – index of site connecting to
weight (float) – e.g. bond length
warn_duplicates (bool) – if True, will warn if trying to add duplicate edges (duplicate edges will not be added in either case)
edge_properties (dict) – any other information to store on graph edges, similar to Structure’s site_properties
- alter_edge(from_index, to_index, new_weight=None, new_edge_properties=None)[source]
Alters either the weight or the edge_properties of an edge in the MoleculeGraph.
- Parameters:
from_index – int
to_index – int
new_weight – alter_edge does not require that weight be altered. As such, by default, this is None. If weight is to be changed, it should be a float.
new_edge_properties – alter_edge does not require that edge_properties be altered. As such, by default, this is None. If any edge properties are to be changed, it should be a dictionary of edge properties to be changed.
- as_dict()[source]
As in pymatgen.core.Molecule except with using to_dict_of_dicts from NetworkX to store graph information.
- break_edge(from_index, to_index, allow_reverse=False)[source]
Remove an edge from the MoleculeGraph.
- Parameters:
from_index – int
to_index – int
allow_reverse – If allow_reverse is True, then break_edge will attempt to break both (from_index, to_index) and, failing that, will attempt to break (to_index, from_index).
- build_unique_fragments()[source]
Find all possible fragment combinations of the MoleculeGraphs (in other words, all connected induced subgraphs).
- diff(other, strict=True)[source]
Compares two MoleculeGraphs. Returns dict with keys ‘self’, ‘other’, ‘both’ with edges that are present in only one MoleculeGraph (‘self’ and ‘other’), and edges that are present in both.
The Jaccard distance is a simple measure of the dissimilarity between two MoleculeGraphs (ignoring edge weights), and is defined by 1 - (size of the intersection / size of the union) of the sets of edges. This is returned with key ‘dist’.
Important note: all node indices are in terms of the MoleculeGraph this method is called from, not the ‘other’ MoleculeGraph: there is no guarantee the node indices will be the same if the underlying Molecules are ordered differently.
- Parameters:
other – MoleculeGraph
strict – if False, will compare bonds from different Molecules, with node indices replaced by Species strings, will not count number of occurrences of bonds
- draw_graph_to_file(filename='graph', diff=None, hide_unconnected_nodes=False, hide_image_edges=True, edge_colors=False, node_labels=False, weight_labels=False, image_labels=False, color_scheme='VESTA', keep_dot=False, algo='fdp')[source]
Draws graph using GraphViz.
The networkx graph object itself can also be drawn with networkx’s in-built graph drawing methods, but note that this might give misleading results for multigraphs (edges are super-imposed on each other).
If visualization is difficult to interpret, hide_image_edges can help, especially in larger graphs.
- Parameters:
filename – filename to output, will detect filetype from extension (any graphviz filetype supported, such as pdf or png)
diff (StructureGraph) – an additional graph to compare with, will color edges red that do not exist in diff and edges green that are in diff graph but not in the reference graph
hide_unconnected_nodes – if True, hide unconnected nodes
hide_image_edges – if True, do not draw edges that go through periodic boundaries
edge_colors (bool) – if True, use node colors to color edges
node_labels (bool) – if True, label nodes with species and site index
weight_labels (bool) – if True, label edges with weights
image_labels (bool) – if True, label edges with their periodic images (usually only used for debugging, edges to periodic images always appear as dashed lines)
color_scheme (str) – “VESTA” or “JMOL”
keep_dot (bool) – keep GraphViz .dot file for later visualization
algo – any graphviz algo, “neato” (for simple graphs) or “fdp” (for more crowded graphs) usually give good outputs
- find_rings(including=None) list[list[tuple[int, int]]] [source]
Find ring structures in the MoleculeGraph.
- Parameters:
including (list[int]) – list of site indices. If including is not None, then find_rings
default (will only return those rings including the specified sites. By)
parameter (this)
None (is)
returned. (and all rings will be)
- Returns:
- Each entry will be a ring (cycle, in graph theory terms)
including the index found in the Molecule. If there is no cycle including an index, the value will be an empty list.
- Return type:
list[list[tuple[int, int]]]
- classmethod from_dict(dct: dict) Self [source]
As in pymatgen.core.Molecule except restoring graphs using from_dict_of_dicts from NetworkX to restore graph information.
- classmethod from_edges(molecule: Molecule, edges: dict[tuple[int, int], None | dict]) Self [source]
Constructor for MoleculeGraph, using pre-existing or pre-defined edges with optional edge parameters.
- Parameters:
molecule – Molecule object
edges – dict representing the bonds of the functional group (format: {(u, v): props}, where props is a dictionary of properties, including weight. Props should be None if no additional properties are to be specified.
- Returns:
A MoleculeGraph
- classmethod from_empty_graph(molecule, name='bonds', edge_weight_name=None, edge_weight_units=None) Self [source]
Constructor for MoleculeGraph, returns a MoleculeGraph object with an empty graph (no edges, only nodes defined that correspond to Sites in Molecule).
- Parameters:
molecule (Molecule)
name (str) – name of graph, e.g. “bonds”
edge_weight_name (str) – name of edge weights, e.g. “bond_length” or “exchange_constant”
edge_weight_units (str) – name of edge weight units
"eV" (e.g. "Å" or)
- Returns:
MoleculeGraph
- classmethod from_local_env_strategy(molecule, strategy) Self [source]
Constructor for MoleculeGraph, using a strategy from pymatgen.analysis.local_env.
molecule: Molecule object strategy: an instance of a
pymatgen.analysis.local_env.NearNeighbors object
- Returns:
mg, a MoleculeGraph
- get_connected_sites(n)[source]
Get a named tuple of neighbors of site n: periodic_site, jimage, index, weight. Index is the index of the corresponding site in the original structure, weight can be None if not defined.
- Parameters:
n – index of Site in Molecule
jimage – lattice vector of site.
- Returns:
list of ConnectedSite tuples, sorted by closest first.
- get_coordination_of_site(n) int [source]
Get the number of neighbors of site n. In graph terms, simply returns degree of node corresponding to site n.
- Parameters:
n – index of site
- Returns:
the number of neighbors of site n.
- Return type:
int
- get_disconnected_fragments(return_index_map: bool = False)[source]
Determine if the MoleculeGraph is connected. If it is not, separate the MoleculeGraph into different MoleculeGraphs, where each resulting MoleculeGraph is a disconnected subgraph of the original. Currently, this function naively assigns the charge of the total molecule to a single submolecule. A later effort will be to actually accurately assign charge.
- Parameters:
return_index_map (bool) – If True, return a dictionary that maps the new indices to the original indices. Defaults to False.
NOTE: This function does not modify the original MoleculeGraph. It creates a copy, modifies that, and returns two or more new MoleculeGraph objects.
- Returns:
Each MoleculeGraph is a disconnected subgraph of the original MoleculeGraph.
- Return type:
list[MoleculeGraph]
- insert_node(idx, species, coords, validate_proximity=False, site_properties=None, edges=None)[source]
A wrapper around Molecule.insert(), which also incorporates the new site into the MoleculeGraph.
- Parameters:
idx – Index at which to insert the new site
species – Species for the new site
coords – 3x1 array representing coordinates of the new site
validate_proximity – For Molecule.insert(); if True (default False), distance will be checked to ensure that site can be safely added.
site_properties – Site properties for Molecule
edges – List of dicts representing edges to be added to the MoleculeGraph. These edges must include the index of the new site i, and all indices used for these edges should reflect the MoleculeGraph AFTER the insertion, NOT before. Each dict should at least have a “to_index” and “from_index” key, and can also have a “weight” and a “properties” key.
- isomorphic_to(other: MoleculeGraph) bool [source]
Checks if the graphs of two MoleculeGraphs are isomorphic to one another. In order to prevent problems with misdirected edges, both graphs are converted into undirected nx.Graph objects.
- Parameters:
other – MoleculeGraph object to be compared.
- Returns:
bool
- remove_nodes(indices: list[int]) None [source]
A wrapper for Molecule.remove_sites().
- Parameters:
indices – indices in the current Molecule (and graph) to be removed.
- replace_group(index, func_grp, strategy, bond_order=1, graph_dict=None, strategy_params=None)[source]
Builds off of Molecule.substitute and MoleculeGraph.substitute_group to replace a functional group in self.molecule with a functional group. This method also amends self.graph to incorporate the new functional group.
TODO: Figure out how to replace into a ring structure.
- Parameters:
index – Index of atom to substitute.
func_grp – Substituent molecule. There are three options: 1. Providing an actual molecule as the input. The first atom must be a DummySpecies X, indicating the position of nearest neighbor. The second atom must be the next nearest atom. For example, for a methyl group substitution, func_grp should be X-CH3, where X is the first site and C is the second site. What the code will do is to remove the index site, and connect the nearest neighbor to the C atom in CH3. The X-C bond indicates the directionality to connect the atoms. 2. A string name. The molecule will be obtained from the relevant template in func_groups.json. 3. A MoleculeGraph object.
strategy – Class from pymatgen.analysis.local_env.
bond_order – A specified bond order to calculate the bond length between the attached functional group and the nearest neighbor site. Defaults to 1.
graph_dict – Dictionary representing the bonds of the functional group (format: {(u, v): props}, where props is a dictionary of properties, including weight. If None, then the algorithm will attempt to automatically determine bonds using one of a list of strategies defined in pymatgen.analysis.local_env.
strategy_params – dictionary of keyword arguments for strategy. If None, default parameters will be used.
- set_node_attributes()[source]
Replicates molecule site properties (specie, coords, etc.) in the MoleculeGraph.
- sort(key: Callable[[Molecule], float] | None = None, reverse: bool = False) None [source]
Same as Molecule.sort(). Also remaps nodes in graph.
- Parameters:
key (callable, optional) – Sort key. Defaults to None.
reverse (bool, optional) – Reverse sort order. Defaults to False.
- split_molecule_subgraphs(bonds, allow_reverse=False, alterations=None)[source]
Split MoleculeGraph into two or more MoleculeGraphs by breaking a set of bonds. This function uses MoleculeGraph.break_edge repeatedly to create disjoint graphs (two or more separate molecules). This function does not only alter the graph information, but also changes the underlying Molecules. If the bonds parameter does not include sufficient bonds to separate two molecule fragments, then this function will fail. Currently, this function naively assigns the charge of the total molecule to a single submolecule. A later effort will be to actually accurately assign charge. NOTE: This function does not modify the original MoleculeGraph. It creates a copy, modifies that, and returns two or more new MoleculeGraph objects.
- Parameters:
bonds – list of tuples (from_index, to_index) representing bonds to be broken to split the MoleculeGraph.
alterations – a dict {(from_index, to_index): alt}, where alt is a dictionary including weight and/or edge properties to be changed following the split.
allow_reverse – If allow_reverse is True, then break_edge will attempt to break both (from_index, to_index) and, failing that, will attempt to break (to_index, from_index).
- Returns:
list of MoleculeGraphs.
- substitute_group(index, func_grp, strategy, bond_order=1, graph_dict=None, strategy_params=None)[source]
Builds off of Molecule.substitute to replace an atom in self.molecule with a functional group. This method also amends self.graph to incorporate the new functional group.
NOTE: using a MoleculeGraph will generally produce a different graph compared with using a Molecule or str (when not using graph_dict).
- Parameters:
index – Index of atom to substitute.
func_grp –
Substituent molecule. There are three options: 1. Providing an actual molecule as the input. The first atom
must be a DummySpecies X, indicating the position of nearest neighbor. The second atom must be the next nearest atom. For example, for a methyl group substitution, func_grp should be X-CH3, where X is the first site and C is the second site. What the code will do is to remove the index site, and connect the nearest neighbor to the C atom in CH3. The X-C bond indicates the directionality to connect the atoms.
- A string name. The molecule will be obtained from the
relevant template in func_groups.json.
A MoleculeGraph object.
strategy – Class from pymatgen.analysis.local_env.
bond_order – A specified bond order to calculate the bond length between the attached functional group and the nearest neighbor site. Defaults to 1.
graph_dict – Dictionary representing the bonds of the functional group (format: {(u, v): props}, where props is a dictionary of properties, including weight. If None, then the algorithm will attempt to automatically determine bonds using one of a list of strategies defined in pymatgen.analysis.local_env.
strategy_params – dictionary of keyword arguments for strategy. If None, default parameters will be used.
- class StructureGraph(structure: Structure, graph_data: dict | None = None)[source]
Bases:
MSONable
This is a class for annotating a Structure with bond information, stored in the form of a graph. A “bond” does not necessarily have to be a chemical bond, but can store any kind of information that connects two Sites.
If constructing this class manually, use the from_empty_graph method or from_local_env_strategy method (using an algorithm provided by the local_env module, such as O’Keeffe). This class that contains connection information: relationships between sites represented by a Graph structure, and an associated structure object.
StructureGraph uses the NetworkX package to store and operate on the graph itself, but contains a lot of helper methods to make associating a graph with a given crystallographic structure easier. Use cases for this include storing bonding information, NMR J-couplings, Heisenberg exchange parameters, etc. For periodic graphs, class stores information on the graph edges of what lattice image the edge belongs to.
- Parameters:
structure (Structure) – Structure object to be analyzed.
graph_data (dict) – Dictionary containing graph information. Not intended to be constructed manually see as_dict method for format.
- add_edge(from_index: int, to_index: int, from_jimage: Tuple3Ints = (0, 0, 0), to_jimage: Tuple3Ints | None = None, weight: float | None = None, warn_duplicates: bool = True, edge_properties: dict | None = None) None [source]
Add edge to graph.
Since physically a ‘bond’ (or other connection between sites) doesn’t have a direction, from_index, from_jimage can be swapped with to_index, to_jimage.
However, images will always be shifted so that from_index < to_index and from_jimage becomes (0, 0, 0).
- Parameters:
from_index – index of site connecting from
to_index – index of site connecting to
from_jimage (tuple of ints) – lattice vector of periodic image, e.g. (1, 0, 0) for periodic image in +x direction
to_jimage (tuple of ints) – lattice vector of image
weight (float) – e.g. bond length
warn_duplicates (bool) – if True, will warn if trying to add duplicate edges (duplicate edges will not be added in either case)
edge_properties (dict) – any other information to store on graph edges, similar to Structure’s site_properties
- alter_edge(from_index: int, to_index: int, to_jimage: tuple | None = None, new_weight: float | None = None, new_edge_properties: dict | None = None)[source]
Alters either the weight or the edge_properties of an edge in the StructureGraph.
- Parameters:
from_index – int
to_index – int
to_jimage – tuple
new_weight – alter_edge does not require that weight be altered. As such, by default, this is None. If weight is to be changed, it should be a float.
new_edge_properties – alter_edge does not require that edge_properties be altered. As such, by default, this is None. If any edge properties are to be changed, it should be a dictionary of edge properties to be changed.
- as_dict() dict [source]
As in pymatgen.core.Structure except with using to_dict_of_dicts from NetworkX to store graph information.
- break_edge(from_index: int, to_index: int, to_jimage: tuple | None = None, allow_reverse: bool = False) None [source]
Remove an edge from the StructureGraph. If no image is given, this method will fail.
- Parameters:
from_index – int
to_index – int
to_jimage – tuple
allow_reverse – If allow_reverse is True, then break_edge will attempt to break both (from_index, to_index) and, failing that, will attempt to break (to_index, from_index).
- diff(other: StructureGraph, strict: bool = True) dict [source]
Compares two StructureGraphs. Returns dict with keys ‘self’, ‘other’, ‘both’ with edges that are present in only one StructureGraph (‘self’ and ‘other’), and edges that are present in both.
The Jaccard distance is a simple measure of the dissimilarity between two StructureGraphs (ignoring edge weights), and is defined by 1 - (size of the intersection / size of the union) of the sets of edges. This is returned with key ‘dist’.
Important note: all node indices are in terms of the StructureGraph this method is called from, not the ‘other’ StructureGraph: there is no guarantee the node indices will be the same if the underlying Structures are ordered differently.
- Parameters:
other – StructureGraph
strict – if False, will compare bonds from different Structures, with node indices replaced by Species strings, will not count number of occurrences of bonds
- draw_graph_to_file(filename: str = 'graph', diff: StructureGraph = None, hide_unconnected_nodes: bool = False, hide_image_edges: bool = True, edge_colors: bool = False, node_labels: bool = False, weight_labels: bool = False, image_labels: bool = False, color_scheme: str = 'VESTA', keep_dot: bool = False, algo: str = 'fdp')[source]
Draws graph using GraphViz.
The networkx graph object itself can also be drawn with networkx’s in-built graph drawing methods, but note that this might give misleading results for multigraphs (edges are super-imposed on each other).
If visualization is difficult to interpret, hide_image_edges can help, especially in larger graphs.
- Parameters:
filename – filename to output, will detect filetype from extension (any graphviz filetype supported, such as pdf or png)
diff (StructureGraph) – an additional graph to compare with, will color edges red that do not exist in diff and edges green that are in diff graph but not in the reference graph
hide_unconnected_nodes – if True, hide unconnected nodes
hide_image_edges – if True, do not draw edges that go through periodic boundaries
edge_colors (bool) – if True, use node colors to color edges
node_labels (bool) – if True, label nodes with species and site index
weight_labels (bool) – if True, label edges with weights
image_labels (bool) – if True, label edges with their periodic images (usually only used for debugging, edges to periodic images always appear as dashed lines)
color_scheme (str) – “VESTA” or “JMOL”
keep_dot (bool) – keep GraphViz .dot file for later visualization
algo – any graphviz algo, “neato” (for simple graphs) or “fdp” (for more crowded graphs) usually give good outputs
- classmethod from_dict(dct: dict) Self [source]
As in pymatgen.core.Structure except restoring graphs using from_dict_of_dicts from NetworkX to restore graph information.
- classmethod from_edges(structure: Structure, edges: dict) Self [source]
Constructor for MoleculeGraph, using pre-existing or pre-defined edges with optional edge parameters.
- Parameters:
structure – Structure object
edges – dict representing the bonds of the functional group (format: {(from_index, to_index, from_image, to_image): props}, where props is a dictionary of properties, including weight. Props should be None if no additional properties are to be specified.
- Returns:
sg, a StructureGraph
- classmethod from_empty_graph(structure: Structure, name: str = 'bonds', edge_weight_name: str | None = None, edge_weight_units: str | None = None) Self [source]
Constructor for an empty StructureGraph, i.e. no edges, containing only nodes corresponding to sites in Structure.
- Parameters:
structure – A pymatgen Structure object.
name – Name of the graph, e.g. “bonds”.
edge_weight_name – Name of the edge weights, e.g. “bond_length” or “exchange_constant”.
edge_weight_units – Name of the edge weight units, e.g. “Å” or “eV”.
- Returns:
- an empty graph with no edges, only nodes defined
that correspond to sites in Structure.
- Return type:
- classmethod from_local_env_strategy(structure: Structure, strategy: NearNeighbors, weights: bool = False, edge_properties: bool = False) Self [source]
Constructor for StructureGraph, using a strategy from pymatgen.analysis.local_env.
- Parameters:
structure – Structure object
strategy – an instance of a pymatgen.analysis.local_env.NearNeighbors object
weights (bool) – if True, use weights from local_env class (consult relevant class for their meaning)
edge_properties (bool) – if True, edge_properties from neighbors will be used
- get_connected_sites(n: int, jimage: Tuple3Ints = (0, 0, 0)) list[ConnectedSite] [source]
Get a named tuple of neighbors of site n: periodic_site, jimage, index, weight. Index is the index of the corresponding site in the original structure, weight can be None if not defined.
- Parameters:
n – index of Site in Structure
jimage – lattice vector of site
- Returns:
list of ConnectedSite tuples, sorted by closest first.
- get_coordination_of_site(n: int) int [source]
Get the number of neighbors of site n. In graph terms, simply returns degree of node corresponding to site n.
- Parameters:
n – index of site
- Returns:
number of neighbors of site n.
- Return type:
int
- get_subgraphs_as_molecules(use_weights: bool = False) list[Molecule] [source]
Retrieve subgraphs as molecules, useful for extracting molecules from periodic crystals.
Will only return unique molecules, not any duplicates present in the crystal (a duplicate defined as an isomorphic subgraph).
- Parameters:
use_weights (bool) – If True, only treat subgraphs as isomorphic if edges have the same weights. Typically, this means molecules will need to have the same bond lengths to be defined as duplicates, otherwise bond lengths can differ. This is a fairly robust approach, but will treat e.g. enantiomers as being duplicates.
- Returns:
list of unique Molecules in Structure
- insert_node(idx: int, species: Species, coords: ArrayLike, coords_are_cartesian: bool = False, validate_proximity: bool = False, site_properties: dict | None = None, edges: list | dict | None = None) None [source]
A wrapper around Molecule.insert(), which also incorporates the new site into the MoleculeGraph.
- Parameters:
idx – Index at which to insert the new site
species – Species for the new site
coords – 3x1 array representing coordinates of the new site
coords_are_cartesian – Whether coordinates are cartesian. Defaults to False.
validate_proximity – For Molecule.insert(); if True (default False), distance will be checked to ensure that site can be safely added.
site_properties – Site properties for Molecule
edges – List of dicts representing edges to be added to the
i (MoleculeGraph. These edges must include the index of the new site)
:param : :param and all indices used for these edges should reflect the: :param MoleculeGraph AFTER the insertion: :param NOT before. Each dict should at: :param least have a “to_index” and “from_index” key: :param and can also have a: :param “weight” and a “properties” key.:
- remove_nodes(indices: Sequence[int | None]) None [source]
A wrapper for Molecule.remove_sites().
- Parameters:
indices – list of indices in the current Molecule (and graph) to be removed.
- set_node_attributes() None [source]
Get each node a “specie” and a “coords” attribute, updated with the current species and coordinates.
- sort(key=None, reverse: bool = False) None [source]
Same as Structure.sort(). Also remaps nodes in graph.
- Parameters:
key – key to sort by
reverse – reverse sort order
- substitute_group(index: int, func_grp: Molecule | str, strategy: Any, bond_order: int = 1, graph_dict: dict | None = None, strategy_params: dict | None = None)[source]
Builds off of Structure.substitute to replace an atom in self.structure with a functional group. This method also amends self.graph to incorporate the new functional group.
NOTE: Care must be taken to ensure that the functional group that is substituted will not place atoms to close to each other, or violate the dimensions of the Lattice.
- Parameters:
index – Index of atom to substitute.
func_grp –
Substituent molecule. There are two options: 1. Providing an actual Molecule as the input. The first atom
must be a DummySpecies X, indicating the position of nearest neighbor. The second atom must be the next nearest atom. For example, for a methyl group substitution, func_grp should be X-CH3, where X is the first site and C is the second site. What the code will do is to remove the index site, and connect the nearest neighbor to the C atom in CH3. The X-C bond indicates the directionality to connect the atoms.
- A string name. The molecule will be obtained from the
relevant template in func_groups.json.
strategy – Class from pymatgen.analysis.local_env.
bond_order – A specified bond order to calculate the bond length between the attached functional group and the nearest neighbor site. Defaults to 1.
graph_dict – Dictionary representing the bonds of the functional group (format: {(u, v): props}, where props is a dictionary of properties, including weight. If None, then the algorithm will attempt to automatically determine bonds using one of a list of strategies defined in pymatgen.analysis.local_env.
strategy_params – dictionary of keyword arguments for strategy. If None, default parameters will be used.
- property types_and_weights_of_connections: dict[source]
Extract a dictionary summarizing the types and weights of edges in the graph.
- Returns:
A dictionary with keys specifying the species involved in a connection in alphabetical order (e.g. string ‘Fe-O’) and values which are a list of weights for those connections (e.g. bond lengths).
- types_of_coordination_environments(anonymous: bool = False) list[str] [source]
Extract information on the different co-ordination environments present in the graph.
- Parameters:
anonymous – if anonymous, will replace specie names with A, B, C, etc.
- Returns:
List of coordination environments, e.g. {‘Mo-S(6)’, ‘S-Mo(3)’}
pymatgen.analysis.hhi module
This module is used to estimate the Herfindahl-Hirschman Index, or HHI, of chemical compounds. The HHI is a measure of how geographically confined or dispersed the elements comprising a compound are. A low HHI is desirable because it means the component elements are geographically dispersed.
Data/strategy from “Data-Driven Review of Thermoelectric Materials: Performance and Resource Considerations” by Gaultois et al., published in Chemistry of Materials (2013).
pymatgen.analysis.interface_reactions module
This module provides a class to predict and analyze interfacial reactions between two solids, with or without an open element (e.g., flowing O2).
- class GrandPotentialInterfacialReactivity(c1: Composition, c2: Composition, grand_pd: GrandPotentialPhaseDiagram, pd_non_grand: PhaseDiagram, include_no_mixing_energy: bool = False, norm: bool = True, use_hull_energy: bool = True)[source]
Bases:
InterfacialReactivity
Extends upon InterfacialReactivity to allow for modelling possible reactions at the interface between two solids in the presence of an open element. The thermodynamics of the open system are provided by the user via the GrandPotentialPhaseDiagram class.
- Parameters:
c1 – Reactant 1 composition
c2 – Reactant 2 composition
grand_pd – Grand potential phase diagram object built from all elements in composition c1 and c2.
include_no_mixing_energy – No_mixing_energy for a reactant is the opposite number of its energy above grand potential convex hull. In cases where reactions involve elements reservoir, this param determines whether no_mixing_energy of reactants will be included in the final reaction energy calculation. By definition, if pd is not a GrandPotentialPhaseDiagram object, this param is False.
pd_non_grand – PhaseDiagram object but not GrandPotentialPhaseDiagram object built from elements in c1 and c2.
norm – Whether or not the total number of atoms in composition of reactant will be normalized to 1.
use_hull_energy – Whether or not use the convex hull energy for a given composition for reaction energy calculation. If false, the energy of ground state structure will be used instead. Note that in case when ground state can not be found for a composition, convex hull energy will be used associated with a warning message.
- class InterfacialReactivity(c1: Composition, c2: Composition, pd: PhaseDiagram, norm: bool = True, use_hull_energy: bool = False, **kwargs)[source]
Bases:
MSONable
Model an interface between two solids and its possible reactions. The two reactants are provided as Composition objects (c1 and c2), along with the relevant compositional PhaseDiagram object. Possible reactions are calculated by finding all points along a tie-line between c1 and c2 where there is a “kink” in the phase diagram; i.e. a point or facet of the phase diagram.
Please consider citing one or both of the following papers if you use this code in your own work.
References
Richards, W. D., Miara, L. J., Wang, Y., Kim, J. C., & Ceder, G. (2015). Interface stability in solid-state batteries. Chemistry of Materials, 28(1), 266-273. https://doi.org/10.1021/acs.chemmater.5b04082
Xiao, Y., Wang, Y., Bo, S.-H., Kim, J. C., Miara, L. J., & Ceder, G. (2019). Understanding interface stability in solid-state batteries. Nature Reviews Materials, 5(2), 105-126. https://doi.org/10.1038/s41578-019-0157-5
- Parameters:
c1 – Reactant 1 composition
c2 – Reactant 2 composition
pd – Phase diagram object built from all elements in composition c1 and c2.
norm – Whether or not the total number of atoms in composition of reactant will be normalized to 1.
use_hull_energy – Whether or not use the convex hull energy for a given composition for reaction energy calculation. If false, the energy of ground state structure will be used instead. Note that in case when ground state can not be found for a composition, convex hull energy will be used associated with a warning message.
- classmethod get_chempot_correction(element: str, temp: float, pres: float)[source]
Get the normalized correction term Δμ for chemical potential of a gas phase consisting of element at given temperature and pressure, referenced to that in the standard state (T_std = 298.15 K, T_std = 1 bar). The gas phase is limited to be one of O2, N2, Cl2, F2, H2. Calculation formula can be found in the documentation of Materials Project website.
- Parameters:
element – The string representing the element.
temp – The temperature of the gas phase in Kelvin.
pres – The pressure of the gas phase in Pa. # codespell:ignore pres
- Returns:
The correction of chemical potential in eV/atom of the gas phase at given temperature and pressure.
- get_critical_original_kink_ratio()[source]
Get a list of molar mixing ratio for each kink between ORIGINAL (instead of processed) reactant compositions. This is the same list as mixing ratio obtained from get_kinks method if self.norm = False.
- Returns:
A list of floats representing molar mixing ratios between the original reactant compositions for each kink.
- get_dataframe() DataFrame [source]
Get a pandas DataFrame representation of the data produced by the get_kinks() method.
- get_kinks() list[tuple[int, float, float, Reaction, float]] [source]
Find all the kinks in mixing ratio where reaction products changes along the tie-line of composition self.c1 and composition self.c2.
- Returns:
(index, mixing ratio, reaction energy in eV/atom, Reaction object, reaction energy per mol of formula in kJ/mol).
- Return type:
List object of tuples, each of which contains 5 elements
- property labels[source]
A dictionary containing kink information: {index: ‘x= mixing_ratio energy= reaction_energy reaction_equation’}. e.g. {1: ‘x= 0 energy = 0 Mn -> Mn’,
2: ‘x= 0.5 energy = -15 O2 + Mn -> MnO2’, 3: ‘x= 1 energy = 0 O2 -> O2’}.
- property minimum[source]
The minimum reaction energy E_min and corresponding mixing ratio x_min as tuple[float, float]: (x_min, E_min).
- plot(backend: Literal['plotly', 'matplotlib'] = 'plotly') Figure | plt.Figure [source]
Plots reaction energy as a function of mixing ratio x in self.c1 - self.c2 tie line.
- Parameters:
backend ("plotly" | "matplotlib") – Plotting library used to create the plot. Defaults to “plotly” but can also be “matplotlib”.
- Returns:
Plot of reaction energies as a function of mixing ratio
pymatgen.analysis.local_env module
This module provides classes to perform analyses of the local environments (e.g., finding near neighbors) of single sites in molecules and structures.
- class BrunnerNNReal(tol: float = 0.0001, cutoff=8.0)[source]
Bases:
NearNeighbors
Determine coordination number using Brunner’s algorithm which counts the atoms that are within the largest gap in differences in real space interatomic distances. This algorithm uses Brunner’s method of largest gap in interatomic distances.
- Parameters:
tol (float) – tolerance parameter for bond determination (default: 1E-4).
cutoff (float) – cutoff radius in Angstrom to look for near-neighbor atoms. Defaults to 8.0.
- get_nn_info(structure: Structure, n: int)[source]
Get all near-neighbor sites as well as the associated image locations and weights of the site with index n in structure.
- class BrunnerNNReciprocal(tol: float = 0.0001, cutoff=8.0)[source]
Bases:
NearNeighbors
Determine coordination number using Brunner’s algorithm which counts the atoms that are within the largest gap in differences in real space interatomic distances. This algorithm uses Brunner’s method of largest reciprocal gap in interatomic distances.
- Parameters:
tol (float) – tolerance parameter for bond determination (default: 1E-4).
cutoff (float) – cutoff radius in Angstrom to look for near-neighbor atoms. Defaults to 8.0.
- get_nn_info(structure: Structure, n: int)[source]
Get all near-neighbor sites as well as the associated image locations and weights of the site with index n in structure.
- class BrunnerNNRelative(tol: float = 0.0001, cutoff=8.0)[source]
Bases:
NearNeighbors
Determine coordination number using Brunner’s algorithm which counts the atoms that are within the largest gap in differences in real space interatomic distances. This algorithm uses Brunner’s method of of largest relative gap in interatomic distances.
- Parameters:
tol (float) – tolerance parameter for bond determination (default: 1E-4).
cutoff (float) – cutoff radius in Angstrom to look for near-neighbor atoms. Defaults to 8.0.
- get_nn_info(structure: Structure, n: int)[source]
Get all near-neighbor sites as well as the associated image locations and weights of the site with index n in structure.
- class BrunnerNN_real(tol: float = 0.0001, cutoff=8.0)[source]
Bases:
BrunnerNNReal
- Parameters:
tol (float) – tolerance parameter for bond determination (default: 1E-4).
cutoff (float) – cutoff radius in Angstrom to look for near-neighbor atoms. Defaults to 8.0.
- class BrunnerNN_reciprocal(tol: float = 0.0001, cutoff=8.0)[source]
Bases:
BrunnerNNReciprocal
- Parameters:
tol (float) – tolerance parameter for bond determination (default: 1E-4).
cutoff (float) – cutoff radius in Angstrom to look for near-neighbor atoms. Defaults to 8.0.
- class BrunnerNN_relative(tol: float = 0.0001, cutoff=8.0)[source]
Bases:
BrunnerNNRelative
- Parameters:
tol (float) – tolerance parameter for bond determination (default: 1E-4).
cutoff (float) – cutoff radius in Angstrom to look for near-neighbor atoms. Defaults to 8.0.
- class CovalentBondNN(tol: float = 0.2, order=True)[source]
Bases:
NearNeighbors
Determine near-neighbor sites and bond orders using built-in pymatgen.Molecule CovalentBond functionality.
NOTE: This strategy is only appropriate for molecules, and not for structures.
- Parameters:
tol (float) – Tolerance for covalent bond checking.
order (bool) – If True (default), this class will compute bond orders. If False, bond lengths will be computed.
- property extend_structure_molecules: bool[source]
Do Molecules need to be converted to Structures to use this NearNeighbors class? Note: this property is not defined for classes for which molecules_allowed is False.
- Type:
Boolean property
- get_bonded_structure(structure: Structure, decorate: bool = False) MoleculeGraph [source]
Obtain a MoleculeGraph object using this NearNeighbor class.
- Parameters:
structure – Molecule object.
decorate (bool) – whether to annotate site properties
by (with order parameters using neighbors determined)
class (this NearNeighbor)
- Returns:
object from pymatgen.analysis.graphs
- Return type:
- get_nn_info(structure: Structure, n: int)[source]
Get all near-neighbor sites and weights (orders) of bonds for a given atom.
- Parameters:
structure – input Molecule.
n – index of site for which to determine near neighbors.
- Returns:
[dict] representing a neighboring site and the type of bond present between site n and the neighboring site.
- get_nn_shell_info(structure: Structure, site_idx, shell)[source]
Get a certain nearest neighbor shell for a certain site.
Determines all non-backtracking paths through the neighbor network computed by get_nn_info. The weight is determined by multiplying the weight of the neighbor at each hop through the network. For example, a 2nd-nearest-neighbor that has a weight of 1 from its 1st-nearest-neighbor and weight 0.5 from the original site will be assigned a weight of 0.5.
As this calculation may involve computing the nearest neighbors of atoms multiple times, the calculation starts by computing all of the neighbor info and then calling _get_nn_shell_info. If you are likely to call this method for more than one site, consider calling get_all_nn first and then calling this protected method yourself.
- Parameters:
structure (Molecule) – Input structure
site_idx (int) – index of site for which to determine neighbor information.
shell (int) – Which neighbor shell to retrieve (1 == 1st NN shell)
- Returns:
- list of dictionaries. Each entry in the list is information about
a certain neighbor in the structure, in the same format as get_nn_info.
- class Critic2NN[source]
Bases:
NearNeighbors
Performs a topological analysis using critic2 to obtain neighbor information, using a sum of atomic charge densities. If an actual charge density is available (e.g. from a VASP CHGCAR), see Critic2Caller directly instead.
Init for Critic2NN.
- property extend_structure_molecules: bool[source]
Do Molecules need to be converted to Structures to use this NearNeighbors class? Note: this property is not defined for classes for which molecules_allowed is False.
- Type:
Boolean property
- get_bonded_structure(structure: Structure, decorate: bool = False) StructureGraph [source]
- Parameters:
structure (Structure) – Input structure
decorate (bool, optional) – Whether to decorate the structure. Defaults to False.
- Returns:
Bonded structure
- Return type:
- get_nn_info(structure: Structure, n: int) list[dict] [source]
Get all near-neighbor sites as well as the associated image locations and weights of the site with index n in structure.
- class CrystalNN(weighted_cn=False, cation_anion=False, distance_cutoffs=(0.5, 1), x_diff_weight=3.0, porous_adjustment=True, search_cutoff=7, fingerprint_length=None)[source]
Bases:
NearNeighbors
This is a custom near-neighbor method intended for use in all kinds of periodic structures (metals, minerals, porous structures, etc). It is based on a Voronoi algorithm and uses the solid angle weights to determine the probability of various coordination environments. The algorithm can also modify probability using smooth distance cutoffs as well as Pauling electronegativity differences. The output can either be the most probable coordination environment or a weighted list of coordination environments. Please note that the default weights have been benchmarked for inorganic crystal structures. For MOFs or molecular crystals, weights and cutoffs likely will need to be adapted. A starting point could be: CrystalNN(x_diff_weight = 1.5, search_cutoff = 4.5).
Initialize CrystalNN with desired parameters. Default parameters assume “chemical bond” type behavior is desired. For geometric neighbor finding (e.g., structural framework), set (i) distance_cutoffs=None, (ii) x_diff_weight=0 and (optionally) (iii) porous_adjustment=False which will disregard the atomic identities and perform best for a purely geometric match.
- Parameters:
weighted_cn (bool) – if set to True, will return fractional weights for each potential near neighbor.
cation_anion (bool) – if set True, will restrict bonding targets to sites with opposite or zero charge. Requires an oxidation states on all sites in the structure.
distance_cutoffs ([float, float]) –
if not None, penalizes neighbor
distances greater than sum of covalent radii plus distance_cutoffs[0]. Distances greater than covalent radii sum plus distance_cutoffs[1] are enforced to have zero weight.
x_diff_weight (float) –
if multiple types of neighbor elements are
possible, this sets preferences for targets with higher electronegativity difference.
porous_adjustment (bool) –
if True, readjusts Voronoi weights to
better describe layered / porous structures
search_cutoff (float) – cutoff in Angstroms for initial neighbor search; this will be adjusted if needed internally
fingerprint_length (int) – if a fixed_length CN “fingerprint” is desired from get_nn_data(), set this parameter
- class NNData(all_nninfo, cn_weights, cn_nninfo)[source]
Bases:
NamedTuple
Create new instance of NNData(all_nninfo, cn_weights, cn_nninfo)
- get_cn(structure: Structure, n: int, **kwargs) float [source]
Get coordination number, CN, of site with index n in structure.
- Parameters:
structure (Structure) – input structure.
n (int) – index of site for which to determine CN.
use_weights (bool) – flag indicating whether (True) to use weights for computing the coordination number or not (False, default: each coordinated site has equal weight).
on_disorder ('take_majority_strict' | 'take_majority_drop' | 'take_max_species' | 'error') – What to do when encountering a disordered structure. ‘error’ will raise ValueError. ‘take_majority_strict’ will use the majority specie on each site and raise ValueError if no majority exists. ‘take_max_species’ will use the first max specie on each site. For {{Fe: 0.4, O: 0.4, C: 0.2}}, ‘error’ and ‘take_majority_strict’ will raise ValueError, while ‘take_majority_drop’ ignores this site altogether and ‘take_max_species’ will use Fe as the site specie.
- Returns:
coordination number.
- Return type:
float
- get_cn_dict(structure: Structure, n: int, use_weights: bool = False, **kwargs)[source]
Get coordination number, CN, of each element bonded to site with index n in structure.
- Parameters:
structure (Structure) – input structure
n (int) – index of site for which to determine CN.
use_weights (bool) – flag indicating whether (True) to use weights for computing the coordination number or not (False, default: each coordinated site has equal weight).
- Returns:
coordination number and list of coordinated sites
- Return type:
dict[int, list[dict]]
- get_nn_data(structure: Structure, n: int, length=None)[source]
The main logic of the method to compute near neighbor.
- Parameters:
structure – (Structure) enclosing structure object
n – (int) index of target site to get NN info for
length – (int) if set, will return a fixed range of CN numbers
- Returns:
all near neighbor sites with weights
a dict of CN -> weight
a dict of CN -> associated near neighbor sites
- Return type:
a namedtuple (NNData) object that contains
- get_nn_info(structure: Structure, n: int) list[dict] [source]
Get all near-neighbor information.
- Parameters:
structure – (Structure) pymatgen Structure
n – (int) index of target site
- Returns:
- each dictionary provides information
about a single near neighbor, where key ‘site’ gives access to the corresponding Site object, ‘image’ gives the image location, and ‘weight’ provides the weight that a given near-neighbor site contributes to the coordination number (1 or smaller), ‘site_index’ gives index of the corresponding site in the original structure.
- Return type:
siw (list[dict])
- property molecules_allowed: bool[source]
can this NearNeighbors class be used with Molecule objects?
- Type:
Boolean property
- class CutOffDictNN(cut_off_dict: dict | None = None)[source]
Bases:
NearNeighbors
A basic NN class using a dictionary of fixed cut-off distances. Only pairs of elements listed in the cut-off dictionary are considered during construction of the neighbor lists.
Omit passing a dictionary for a Null/Empty NN class.
- Parameters:
cut_off_dict (dict[str, float]) – a dictionary
distances (of cut-off) – 2.0} for
{ (e.g.) – 2.0} for
Angstroms. (a maximum Fe-O bond length of 2)
listed (Bonds will only be created between pairs)
dictionary. (in the cut-off)
decorated (If your structure is oxidation state)
:param : :param the cut-off distances will have to explicitly include: :param the oxidation state: 2.0}. :type the oxidation state: ‘Fe2+’, ‘O2-’ :param e.g. {: 2.0}. :type e.g. {: ‘Fe2+’, ‘O2-’
- property extend_structure_molecules: bool[source]
Do Molecules need to be converted to Structures to use this NearNeighbors class? Note: this property is not defined for classes for which molecules_allowed is False.
- Type:
Boolean property
- classmethod from_preset(preset) Self [source]
Initialize a CutOffDictNN according to a preset set of cutoffs.
- Parameters:
preset (str) – A preset name. The list of supported presets are: - “vesta_2019”: The distance cutoffs used by the VESTA visualisation program.
- Returns:
A CutOffDictNN using the preset cut-off dictionary.
- get_nn_info(structure: Structure, n: int) list[dict] [source]
Get all near-neighbor sites as well as the associated image locations and weights of the site with index n in structure.
- class EconNN(tol: float = 0.2, cutoff: float = 10.0, cation_anion: bool = False, use_fictive_radius: bool = False)[source]
Bases:
NearNeighbors
Determines the average effective coordination number for each cation in a given structure using Hoppe’s algorithm.
This method follows the procedure outlined in:
Hoppe, Rudolf. “Effective coordination numbers (ECoN) and mean fictive ionic radii (MEFIR).” Zeitschrift für Kristallographie-Crystalline Materials 150.1-4 (1979): 23-52.
- Parameters:
tol – Tolerance parameter for bond determination.
cutoff – Cutoff radius in Angstrom to look for near-neighbor atoms.
cation_anion – If set to True, will restrict bonding targets to sites with opposite or zero charge. Requires an oxidation states on all sites in the structure.
use_fictive_radius – Whether to use the fictive radius in the EcoN calculation. If False, the bond distance will be used.
- property extend_structure_molecules: bool[source]
Do Molecules need to be converted to Structures to use this NearNeighbors class? Note: this property is not defined for classes for which molecules_allowed is False.
- Type:
Boolean property
- get_nn_info(structure: Structure, n: int)[source]
Get all near-neighbor sites as well as the associated image locations and weights of the site with index n in structure.
- class IsayevNN(tol: float = 0.25, targets: Element | list[Element] | None = None, cutoff: float = 13.0, allow_pathological: bool = False, extra_nn_info: bool = True, compute_adj_neighbors: bool = True)[source]
Bases:
VoronoiNN
Uses the algorithm defined in 10.1038/ncomms15679.
Sites are considered neighbors if (i) they share a Voronoi facet and (ii) the bond distance is less than the sum of the Cordero covalent radii + 0.25 Å.
- Parameters:
tol – Tolerance in Å for bond distances that are considered coordinated.
targets – Target element(s).
cutoff – Cutoff radius in Angstrom to look for near-neighbor atoms.
allow_pathological – Whether to allow infinite vertices in Voronoi coordination.
extra_nn_info – Add all polyhedron info to get_nn_info.
compute_adj_neighbors – Whether to compute which neighbors are adjacent. Turn off for faster performance.
- get_all_nn_info(structure: Structure) list[list[dict[str, Any]]] [source]
- Parameters:
structure (Structure) – input structure.
- Returns:
List of near neighbor information for each site. See get_nn_info for the format of the data for each site.
- get_nn_info(structure: Structure, n: int) list[dict[str, Any]] [source]
Get all near-neighbor site information.
Gets the associated image locations and weights of the site with index n in structure using Voronoi decomposition and distance cutoff.
- Parameters:
structure – Input structure.
n – Index of site for which to determine near-neighbor sites.
- Returns:
List of dicts containing the near-neighbor information. Each dict has the keys:
”site”: The near-neighbor site.
”image”: The periodic image of the near-neighbor site.
”weight”: The face weight of the Voronoi decomposition.
”site_index”: The index of the near-neighbor site in the original structure.
- class JmolNN(tol: float = 0.45, min_bond_distance: float = 0.4, el_radius_updates: dict[SpeciesLike, float] | None = None)[source]
Bases:
NearNeighbors
Determine near-neighbor sites and coordination number using an emulation of Jmol’s default autoBond() algorithm. This version of the algorithm does not take into account any information regarding known charge states.
- Parameters:
tol (float) – tolerance parameter for bond determination Defaults to 0.56.
min_bond_distance (float) – minimum bond distance for consideration Defaults to 0.4.
el_radius_updates (dict) – symbol->float to override default atomic radii table values.
- property extend_structure_molecules: bool[source]
Do Molecules need to be converted to Structures to use this NearNeighbors class? Note: this property is not defined for classes for which molecules_allowed is False.
- Type:
Boolean property
- get_max_bond_distance(el1_sym, el2_sym)[source]
Use Jmol algorithm to determine bond length from atomic parameters.
- Parameters:
el1_sym (str) – symbol of atom 1
el2_sym (str) – symbol of atom 2.
- Returns:
max bond length
- Return type:
float
- get_nn_info(structure: Structure, n: int)[source]
Get all near-neighbor sites as well as the associated image locations and weights of the site with index n using the bond identification algorithm underlying Jmol.
- class LocalStructOrderParams(types: list[str], parameters: list[dict[str, float] | None] | None = None, cutoff: float = -10.0)[source]
Bases:
object
This class permits the calculation of various types of local structure order parameters.
- Parameters:
types (list[str]) –
the types of order parameters to be calculated. Note that multiple mentions of the same type may occur. Currently available types recognize following environments:
- ”cn”: simple coordination number—normalized
if desired;
”sgl_bd”: single bonds; “bent”: bent (angular) coordinations
(Zimmermann & Jain, in progress, 2017);
”T”: T-shape coordinations; “see_saw_rect”: see saw-like coordinations; “tet”: tetrahedra
(Zimmermann et al., submitted, 2017);
- ”oct”: octahedra
(Zimmermann et al., submitted, 2017);
- ”bcc”: body-centered cubic environments (Peters,
Chem. Phys., 131, 244103, 2009);
”tri_plan”: trigonal planar environments; “sq_plan”: square planar environments; “pent_plan”: pentagonal planar environments; “tri_pyr”: trigonal pyramids (coordinated atom is in
the center of the basal plane);
”sq_pyr”: square pyramids; “pent_pyr”: pentagonal pyramids; “hex_pyr”: hexagonal pyramids; “tri_bipyr”: trigonal bipyramids; “sq_bipyr”: square bipyramids; “pent_bipyr”: pentagonal bipyramids; “hex_bipyr”: hexagonal bipyramids; “cuboct”: cuboctahedra; “q2”: motif-unspecific bond orientational order
parameter (BOOP) of weight l=2 (Steinhardt et al., Phys. Rev. B, 28, 784-805, 1983);
”q4”: BOOP of weight l=4; “q6”: BOOP of weight l=6. “reg_tri”: regular triangle with varying height
to basal plane;
”sq”: square coordination (cf., “reg_tri”); “oct_legacy”: original Peters-style OP recognizing
octahedral coordination environments (Zimmermann et al., J. Am. Chem. Soc., 137, 13352-13361, 2015) that can, however, produce small negative values sometimes.
”sq_pyr_legacy”: square pyramids (legacy);
parameters (list[dict]) –
float-type parameters associated with the definitions of the different order parameters (length of list = number of OPs). If an entry is None, default values are used that are read from the op_params.yaml file. With few exceptions, 9 different parameters are used across all OPs:
- ”norm”: normalizing constant (used in “cn”
(default value: 1)).
- ”TA”: target angle (TA) in fraction of 180 degrees
(“bent” (1), “tet” (0.6081734479693927), “tri_plan” (0.66666666667), “pent_plan” (0.6), “sq_pyr_legacy” (0.5)).
- ”IGW_TA”: inverse Gaussian width (IGW) for penalizing
angles away from the target angle in inverse fractions of 180 degrees to (“bent” and “tet” (15), “tri_plan” (13.5), “pent_plan” (18), “sq_pyr_legacy” (30)).
- ”IGW_EP”: IGW for penalizing angles away from the
equatorial plane (EP) at 90 degrees (“T”, “see_saw_rect”, “oct”, “sq_plan”, “tri_pyr”, “sq_pyr”, “pent_pyr”, “hex_pyr”, “tri_bipyr”, “sq_bipyr”, “pent_bipyr”, “hex_bipyr”, and “oct_legacy” (18)).
- ”fac_AA”: factor applied to azimuth angle (AA) in cosine
term (“T”, “tri_plan”, and “sq_plan” (1), “tet”, “tri_pyr”, and “tri_bipyr” (1.5), “oct”, “sq_pyr”, “sq_bipyr”, and “oct_legacy” (2), “pent_pyr” and “pent_bipyr” (2.5), “hex_pyr” and “hex_bipyr” (3)).
- ”exp_cos_AA”: exponent applied to cosine term of AA
(“T”, “tet”, “oct”, “tri_plan”, “sq_plan”, “tri_pyr”, “sq_pyr”, “pent_pyr”, “hex_pyr”, “tri_bipyr”, “sq_bipyr”, “pent_bipyr”, “hex_bipyr”, and “oct_legacy” (2)).
- ”min_SPP”: smallest angle (in radians) to consider
a neighbor to be at South pole position (“see_saw_rect”, “oct”, “bcc”, “sq_plan”, “tri_bipyr”, “sq_bipyr”, “pent_bipyr”, “hex_bipyr”, “cuboct”, and “oct_legacy” (2.792526803190927)).
- ”IGW_SPP”: IGW for penalizing angles away from South
pole position (“see_saw_rect”, “oct”, “bcc”, “sq_plan”, “tri_bipyr”, “sq_bipyr”, “pent_bipyr”, “hex_bipyr”, “cuboct”, and “oct_legacy” (15)).
- ”w_SPP”: weight for South pole position relative to
equatorial positions (“see_saw_rect” and “sq_plan” (1), “cuboct” (1.8), “tri_bipyr” (2), “oct”, “sq_bipyr”, and “oct_legacy” (3), “pent_bipyr” (4), “hex_bipyr” (5), “bcc” (6)).
cutoff (float) – Cutoff radius to determine which nearest neighbors are supposed to contribute to the order parameters. If the value is negative the neighboring sites found by distance and cutoff radius are further pruned using the get_nn method from the VoronoiNN class.
- compute_trigonometric_terms(thetas, phis)[source]
Compute trigonometric terms that are required to calculate bond orientational order parameters using internal variables.
- Parameters:
thetas ([float]) – polar angles of all neighbors in radians.
phis ([float]) – azimuth angles of all neighbors in radians. The list of azimuth angles of all neighbors in radians. The list of azimuth angles is expected to have the same size as the list of polar angles; otherwise, a ValueError is raised. Also, the two lists of angles have to be coherent in order. That is, it is expected that the order in the list of azimuth angles corresponds to a distinct sequence of neighbors. And, this sequence has to equal the sequence of neighbors in the list of polar angles.
- get_order_parameters(structure: Structure, n: int, indices_neighs: list[int] | None = None, tol: float = 0.0, target_spec: Species | None = None)[source]
Compute all order parameters of site n.
- Parameters:
structure (Structure) – input structure.
n (int) – index of site in input structure, for which OPs are to be calculated. Note that we do not use the sites iterator here, but directly access sites via struct[index].
indices_neighs (list[int]) – list of indices of those neighbors in Structure object structure that are to be considered for OP computation. This optional argument overwrites the way neighbors are to be determined as defined in the constructor (i.e., Voronoi coordination finder via negative cutoff radius vs constant cutoff radius if cutoff was positive). We do not use information about the underlying structure lattice if the neighbor indices are explicitly provided. This has two important consequences. First, the input Structure object can, in fact, be a simple list of Site objects. Second, no nearest images of neighbors are determined when providing an index list. Note furthermore that this neighbor determination type ignores the optional target_spec argument.
tol (float) – threshold of weight (= solid angle / maximal solid angle) to determine if a particular pair is considered neighbors; this is relevant only in the case when Voronoi polyhedra are used to determine coordination
target_spec (Species) – target species to be considered when calculating the order parameters of site n; None includes all species of input structure.
- Returns:
representing order parameters. Should it not be possible to compute a given OP for a conceptual reason, the corresponding entry is None instead of a float. For Steinhardt et al.’s bond orientational OPs and the other geometric OPs (“tet”, “oct”, “bcc”, etc.), this can happen if there is a single neighbor around site n in the structure because that does not permit calculation of angles between multiple neighbors.
- Return type:
[floats]
- get_parameters(index: int) dict[str | int, float] | None [source]
Get parameters associated with calculation of the order parameter that was defined at the index provided.
Attention: the parameters do not need to equal those originally inputted because of processing out of efficiency reasons.
- Parameters:
index (int) – index of order parameter for which to return associated params.
- Returns:
parameters of a given OP.
- Return type:
dict[str, float]
- get_q2(thetas=None, phis=None)[source]
Calculates the value of the bond orientational order parameter of weight l=2. If the function is called with non-empty lists of polar and azimuthal angles the corresponding trigonometric terms are computed afresh. Otherwise, it is expected that the compute_trigonometric_terms function has been just called.
- Parameters:
thetas ([float]) – polar angles of all neighbors in radians.
phis ([float]) – azimuth angles of all neighbors in radians.
- Returns:
- bond orientational order parameter of weight l=2
corresponding to the input angles thetas and phis.
- Return type:
float
- get_q4(thetas=None, phis=None)[source]
Calculates the value of the bond orientational order parameter of weight l=4. If the function is called with non-empty lists of polar and azimuthal angles the corresponding trigonometric terms are computed afresh. Otherwise, it is expected that the compute_trigonometric_terms function has been just called.
- Parameters:
thetas ([float]) – polar angles of all neighbors in radians.
phis ([float]) – azimuth angles of all neighbors in radians.
- Returns:
- bond orientational order parameter of weight l=4
corresponding to the input angles thetas and phis.
- Return type:
float
- get_q6(thetas=None, phis=None)[source]
Calculates the value of the bond orientational order parameter of weight l=6. If the function is called with non-empty lists of polar and azimuthal angles the corresponding trigonometric terms are computed afresh. Otherwise, it is expected that the compute_trigonometric_terms function has been just called.
- Parameters:
thetas ([float]) – polar angles of all neighbors in radians.
phis ([float]) – azimuth angles of all neighbors in radians.
- Returns:
- bond orientational order parameter of weight l=6
corresponding to the input angles thetas and phis.
- Return type:
float
- get_type(index)[source]
Get type of order parameter at the index provided and represented by a short string.
- Parameters:
index (int) – index of order parameter for which type is to be returned.
- Returns:
OP type.
- Return type:
str
- class MinimumDistanceNN(tol: float = 0.1, cutoff=10, get_all_sites=False)[source]
Bases:
NearNeighbors
Determine near-neighbor sites and coordination number using the nearest neighbor(s) at distance, d_min, plus all neighbors within a distance (1 + tol) * d_min, where tol is a (relative) distance tolerance parameter.
- Parameters:
tol (float) – tolerance parameter for neighbor identification (default: 0.1).
cutoff (float) – cutoff radius in Angstrom to look for trial near-neighbor sites (default: 10).
get_all_sites (bool) – If this is set to True then the neighbor sites are only determined by the cutoff radius, tol is ignored.
- property extend_structure_molecules: bool[source]
Do Molecules need to be converted to Structures to use this NearNeighbors class? Note: this property is not defined for classes for which molecules_allowed is False.
- Type:
Boolean property
- get_nn_info(structure: Structure, n: int) list[dict[str, Any]] [source]
Get all near-neighbor sites as well as the associated image locations and weights of the site with index n using the closest neighbor distance-based method.
- Parameters:
structure (Structure) – input structure.
n (int) – index of site for which to determine near neighbors.
- Returns:
- dicts with (Site, array, float) each one of which represents a
neighbor site, its image location, and its weight.
- Return type:
siw (list[dict])
- class MinimumOKeeffeNN(tol: float = 0.1, cutoff=10)[source]
Bases:
NearNeighbors
Determine near-neighbor sites and coordination number using the neighbor(s) at closest relative distance, d_min_OKeffee, plus some relative tolerance, where bond valence parameters from O’Keeffe’s bond valence method (J. Am. Chem. Soc. 1991, 3226-3229) are used to calculate relative distances.
- Parameters:
tol (float) – tolerance parameter for neighbor identification (default: 0.1).
cutoff (float) – cutoff radius in Angstrom to look for trial near-neighbor sites (default: 10).
- property extend_structure_molecules: bool[source]
Do Molecules need to be converted to Structures to use this NearNeighbors class? Note: this property is not defined for classes for which molecules_allowed is False.
- Type:
Boolean property
- get_nn_info(structure: Structure, n: int)[source]
Get all near-neighbor sites as well as the associated image locations and weights of the site with index n using the closest relative neighbor distance-based method with O’Keeffe parameters.
- class MinimumVIRENN(tol: float = 0.1, cutoff=10)[source]
Bases:
NearNeighbors
Determine near-neighbor sites and coordination number using the neighbor(s) at closest relative distance, d_min_VIRE, plus some relative tolerance, where atom radii from the ValenceIonicRadiusEvaluator (VIRE) are used to calculate relative distances.
- Parameters:
tol (float) – tolerance parameter for neighbor identification (default: 0.1).
cutoff (float) – cutoff radius in Angstrom to look for trial near-neighbor sites (default: 10).
- get_nn_info(structure: Structure, n: int)[source]
Get all near-neighbor sites as well as the associated image locations and weights of the site with index n using the closest relative neighbor distance-based method with VIRE atomic/ionic radii.
- class NearNeighbors[source]
Bases:
object
Base class to determine near neighbors that typically include nearest neighbors and others that are within some tolerable distance.
- property extend_structure_molecules: bool[source]
Do Molecules need to be converted to Structures to use this NearNeighbors class? Note: this property is not defined for classes for which molecules_allowed is False.
- Type:
Boolean property
- get_all_nn_info(structure: Structure)[source]
Get a listing of all neighbors for all sites in a structure.
- Parameters:
structure (Structure) – Input structure
- Returns:
- List of NN site information for each site in the structure. Each
entry has the same format as get_nn_info
- get_bonded_structure(structure: Structure, decorate: bool = False, weights: bool = True, edge_properties: bool = False, on_disorder: on_disorder_options = 'take_majority_strict') StructureGraph | MoleculeGraph [source]
Obtain a StructureGraph object using this NearNeighbor class. Requires pip install networkx.
NOTE: The StructureGraph will not contain sites or bonds that are equivalent under lattice vector translations. For more details please see the following discussion: https://github.com/materialsproject/pymatgen/issues/3888
- Parameters:
structure – Structure object.
decorate (bool) – whether to annotate site properties with order parameters using neighbors determined by this NearNeighbor class
weights (bool) – whether to include edge weights from NearNeighbor class in StructureGraph
edge_properties (bool)
on_disorder ('take_majority_strict' | 'take_majority_drop' | 'take_max_species' | 'error') – What to do when encountering a disordered structure. ‘error’ will raise ValueError. ‘take_majority_strict’ will use the majority specie on each site and raise ValueError if no majority exists. ‘take_max_species’ will use the first max specie on each site. For {{Fe: 0.4, O: 0.4, C: 0.2}}, ‘error’ and ‘take_majority_strict’ will raise ValueError, while ‘take_majority_drop’ ignores this site altogether and ‘take_max_species’ will use Fe as the site specie.
- Returns:
object from pymatgen.analysis.graphs
- Return type:
- get_cn(structure: Structure, n: int, use_weights: Literal[False] = False, on_disorder: Literal['take_majority_strict', 'take_majority_drop', 'take_max_species', 'error'] = 'take_majority_strict') int