Reservoirs#
- class Reservoirs(res_dict, phase_diagram=None, mu_refs=None, are_chempots_delta=False)[source]#
Bases:
MSONableClass to handle dictionaries of chemical potentials. Works almost completely like a python dictionary.
- Parameters:
res_dict (dict) – Dictionary with reservoir names as key and dictionaries of chemical potentials as values.
phase_diagram (PhaseDiagram) – PhaseDiagram object, useful to convert absolute chempots in referenced chempots.
mu_refs (dict) – Dictionary with chemical potentials of reference elements ({Element:chempot}). If the PhaseDiagram is provided mu_refs is taken from the mu_refs attribute.
are_chempots_delta (bool) – Set this variable to True if chempots in dictionary are referenced values.
Methods
Json-serializable dict representation of a Reservoirs object.
Get new Reservoir object filtering the chempots dictionary.
Constructor of Reservoirs object from dictionary representation.
Build Reservoirs object from json file or string.
Return values of chempots from referenced to absolute
Get DataFrame object of the dictionary of reservoirs.
Get string with formatted latex table of chemical potentials.
Plot the stability diagram with the reservoir points.
Return values of chempots from absolute to referenced
loadLoad an instance from a JSON file written by
save().saveSerialize the instance to JSON on disk, pickling fields if needed.
Set reservoir dictionary to absolute values of chempots.
Set reservoir dictionary to referenced values of chempots.
Save Reservoirs object as json string or file
unsafe_hashReturn a hash of the current object.
validate_monty_v1Pydantic validator with correct signature for pydantic v1.x.
validate_monty_v2Pydantic validator with correct signature for pydantic v2.x.
Attributes
REDIRECT- property are_chempots_delta#
- as_dict()[source]#
Json-serializable dict representation of a Reservoirs object.
- Returns:
d – Json-serializable dict of a Reservoirs object.
- Return type:
dict
- filter_reservoirs(inplace=False, elements=None)[source]#
Get new Reservoir object filtering the chempots dictionary.
- Parameters:
inplace (bool) – Apply changes to current Reservoirs object.
elements (list) – List of element symbols.
- Returns:
res – Reservoirs object.
- Return type:
- classmethod from_dict(d)[source]#
Constructor of Reservoirs object from dictionary representation.
- Parameters:
d (dict) – Json-serializable dict of a Reservoirs object.
- Returns:
reservoirs – Reservoirs object.
- Return type:
- static from_json(path_or_string)[source]#
Build Reservoirs object from json file or string.
- Parameters:
path_or_string (str) – If an existing path to a file is given the object is constructed reading the json file. Otherwise it will be read as a string.
- Return type:
Reservoir object.
- get_dataframe(format_symbols=False, format_compositions=False, all_math=False, ndecimals=None)[source]#
Get DataFrame object of the dictionary of reservoirs.
- Parameters:
format_symbols (bool) – Format labels of element chempots in latex math format.
format_compositions (bool) – Get Latex format of compositions.
all_math (bool) – Get all characters in composition written in latex’s math format.
ndecimals (int) – Number of decimals to round the chemical potentials, if None the numbers are not changed.
- Returns:
df – DataFrame object.
- Return type:
DataFrame
- get_plot(elements, size=1, **kwargs)[source]#
Plot the stability diagram with the reservoir points.
- Parameters:
elements (list) – List of strings with element symbols on the diagram axis.
size (float) – Size of the points. The default is 1.
**kwargs (dict) – Kwargs for the add_reservoirs function.
- Return type:
Matplotlib object.
- to_json(path, cls=<class 'monty.json.MontyEncoder'>)[source]#
Save Reservoirs object as json string or file
- Parameters:
path (str) – Path to the destination file. If None a string is exported.
cls (cls) – Encoder class for json.dump. The default is MontyEncoder.
- Returns:
d – If path is not set a string is returned.
- Return type:
str