aim2dat.utils.chem_formula¶
Module to parse representations of chemical formulas into each other.
Module Contents¶
Functions¶
|
Check if two chemical formulas are identical. |
|
Try to find a reduced formula. Elements with fractional occupation numbers are neglected. |
|
Create a string from a formula dictionary, fractional quantities are rounded. |
|
Create a string from a formula dictionary, fractional quantities are rounded. |
|
Convert a list of elements to a dictionary. |
|
Convert a list of elements to a dictionary. |
|
Create a dictionary from a formula string. |
-
aim2dat.utils.chem_formula.compare_formulas(chem_formula1, chem_formula2, reduce_formulas=
False)[source]¶ Check if two chemical formulas are identical.
- Parameters:¶
chem_formula1 (dict) – Chemical formula as dictionary, e.g.
{'Fe' : 4.0, 'O' : 6.0}or{'H' : 2.0, 'O' : 1.0}.chem_formula2 (dict) – Chemical formula as dictionary, e.g.
{'Fe' : 4.0, 'O' : 6.0}or{'H' : 2.0, 'O' : 1.0}.reduce_formulas (bool) – Whether to reduce the formulas before comparison.
- Returns:¶
match (bool) –
Trueif the two forumals are identical
- aim2dat.utils.chem_formula.reduce_formula(formula_dict)[source]¶
Try to find a reduced formula. Elements with fractional occupation numbers are neglected.
- aim2dat.utils.chem_formula.transform_dict_to_latexstr(formula_dict)[source]¶
Create a string from a formula dictionary, fractional quantities are rounded.
-
aim2dat.utils.chem_formula.transform_dict_to_str(formula_dict, output_type=
None)[source]¶ Create a string from a formula dictionary, fractional quantities are rounded.
- Parameters:¶
formula_dict (dict) – Chemical formula as dictionary, e.g.
{'Fe' : 2.0, 'O' : 3.0}or{'H' : 2.0, 'O' : 1.0}output_type (None or str) – If set to
'alphabetic'the output formula will be alphabetically ordered.
- Returns:¶
formula_str (str) – Chemical formula as string, e.g.
Fe2O3`, ``H2O
- aim2dat.utils.chem_formula.transform_list_to_dict(formula_list)[source]¶
Convert a list of elements to a dictionary.
- aim2dat.utils.chem_formula.transform_list_to_str(formula_list)[source]¶
Convert a list of elements to a dictionary.