RockyChem Module#
- exception thermoengine.rockychem.InvalidInputError(message)#
Exception raised for custom error scenarios.
- Attributes:
message – explanation of the error
- thermoengine.rockychem.convert_bulk_comp(wt_oxides: dict | Series | None = None, mol_oxides: dict | Series | None = None, wt_elems: dict | Series | None = None, mol_elems: dict | Series | None = None, to: str | None = None, drop_missing: bool = True) Series#
Convert a bulk composition.
The input composition is given in terms of weight (or moles) of oxides (or elements). It is converted from the input type to any desired output type. This conversion is unnormalized (or extensive). Select only one of the input methods to define composition.
- Parameters:
- wt_oxidesdict_like, optional
Input composition given as weight of each oxide.
- mol_oxidesdict_like, optional
Input composition given as moles of each oxide.
- wt_elemsdict_like, optional
Input composition given as weight of each element.
- mol_elemsdict_like, optional
Input composition given as moles of each element.
- tostr, required
Desired output type. This required argument must be one of: - ‘wt_oxides’ - ‘mol_oxides’ - ‘wt_elems’ - ‘mol_elems’
- Returns:
- output_compSeries
Converted composition, where missing components are dropped.
See also
rockychem.convert_bulk_comp_table
Examples
>>> import thermoengine.rockychem as rockychem >>> OXIDE_WTS = rockychem.OXIDE_WTS >>> wt_oxides = { ... 'MgO' : 2*OXIDE_WTS['MgO'], ... 'SiO2': 1*OXIDE_WTS['SiO2']} >>> mol_elems = rockychem.convert_bulk_comp(wt_oxides=wt_oxides, to='mol_elems') >>> mol_elems Si 1.0 Mg 2.0 O 4.0
- thermoengine.rockychem.convert_bulk_comp_table(wt_oxides: DataFrame | None = None, mol_oxides: DataFrame | None = None, wt_elems: DataFrame | None = None, mol_elems: DataFrame | None = None, to: str = 'mol_elems', drop_missing: bool = True) DataFrame#
Convert table of bulk compositions.
A table of compositions is given in terms of weight (or moles) of oxides (or elements). It is converted from the input type to any desired output type. This conversion is unnormalized (or extensive). Select only one of the input methods to define composition.
- Parameters:
- wt_oxidesDataFrame, optional
Input composition table given as weights of each oxide.
- mol_oxidesDataFrame, optional
Input composition table given as moles of each oxide.
- wt_elemsDataFrame, optional
Input composition table given as weights of each element.
- mol_elemsDataFrame, optional
Input composition table given as moles of each element.
- tostr, default=’mol_elems’
Desired output type. This required argument must be one of: - ‘wt_oxides’ - ‘mol_oxides’ - ‘wt_elems’ - ‘mol_elems’
- Returns:
- output_compDataFrame
Converted composition table, where missing components are dropped.
See also
rockychem.convert_bulk_comp
Examples
>>> import thermoengine.rockychem as rockychem >>> import pandas as pd >>> OXIDE_WTS = rockychem.OXIDE_WTS
>>> wt_oxides_tbl = pd.DataFrame({ ... 'SiO2': {'SiO2' : OXIDE_WTS['SiO2']}, ... 'MgSiO3': {'MgO' : OXIDE_WTS['MgO'], 'SiO2':OXIDE_WTS['SiO2']}, ... 'Mg2SiO4': {'MgO' : 2*OXIDE_WTS['MgO'], 'SiO2':OXIDE_WTS['SiO2']}, ... 'MgO': {'MgO' : OXIDE_WTS['MgO']}}, ... index=['MgO','SiO2']).fillna(0).T >>> mol_elems_tbl = rockychem.convert_bulk_comp_table(wt_oxides=wt_oxides_tbl, to='mol_elems') >>> mol_elems_tbl Si Mg O SiO2 1.0 0.0 2.0 MgSiO3 1.0 1.0 3.0 Mg2SiO4 1.0 2.0 4.0 MgO 0.0 1.0 1.0
- thermoengine.rockychem.convert_phase_comp(abbrev: str, database: str | ~thermoengine.model.Database = 'MELTS_v1_2', mol_endmems: ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy._typing._array_like._ScalarType_co]] | None = None, wt_oxides: dict | ~pandas.core.series.Series | None = None, mol_oxides: dict | ~pandas.core.series.Series | None = None, wt_elems: dict | ~pandas.core.series.Series | None = None, mol_elems: dict | ~pandas.core.series.Series | None = None, to=<class 'str'>) Series#
Convert a phase composition.
The composition of a phase is converted from oxides (or elements) to moles of endmembers in either the forward or reverse direction. In the forward direction, the input phase composition is given in terms of weight (or moles) of oxides (or elements) and converted to moles of endmembers. In the reverse direction, moles of endmembers are converted back into weigth (or moles) of oxides (or elements). This conversion is unnormalized (or extensive). Select only one of the input methods to define composition.
- Parameters:
- abbrev: str
Standard abbreviation for a phase of interest that belongs to the current database.
- database: str|Database, default=’MELTS_v1_2’
Database ID or Database object that contains the phase of interest.
- mol_endmemsarray_like, optional
Input composition given as moles of endmembers for the phase.
- wt_oxidesdict_like, optional
Input composition given as weight of each oxide.
- mol_oxidesdict_like, optional
Input composition given as moles of each oxide.
- wt_elemsdict_like, optional
Input composition given as weight of each element.
- mol_elemsdict_like, optional
Input composition given as moles of each element.
- tostr, required
Desired output type. This required argument must be one of: - ‘mol_endmems’ - ‘wt_oxides’ - ‘mol_oxides’ - ‘wt_elems’ - ‘mol_elems’
- Returns:
- output_compSeries
Converted composition.
See also
rockychem.convert_bulk_comp_table
Notes
The order of the endmembers depends on the particular phase model being used. In the forward direction, output is labeled by endmember name. In case of confusion, examine the endmember names or consult the phase model for details.
Examples
>>> import thermoengine.rockychem as rockychem >>> OXIDE_WTS = rockychem.OXIDE_WTS >>> wt_oxides = { ... 'MgO' : 1.5*OXIDE_WTS['MgO'], ... 'FeO' : 0.5*OXIDE_WTS['FeO'], ... 'SiO2': 1*OXIDE_WTS['SiO2']} >>> mol_endmems = rockychem.convert_phase_comp('Ol', wt_oxides=wt_oxides, to='mol_endmems') >>> mol_endmems Tephroite 0.00 Fayalite 0.25 Coolivine 0.00 Niolivine 0.00 Monticellite 0.00 Forsterite 0.75
- thermoengine.rockychem.convert_phase_comp_table(abbrev: str, database: str | ~thermoengine.model.Database = 'MELTS_v1_2', mol_endmems: ~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy._typing._array_like._ScalarType_co]] | None = None, wt_oxides: ~pandas.core.frame.DataFrame | None = None, mol_oxides: ~pandas.core.frame.DataFrame | None = None, wt_elems: ~pandas.core.frame.DataFrame | None = None, mol_elems: ~pandas.core.frame.DataFrame | None = None, to=<class 'str'>) DataFrame#
Convert table of phase compositions.
A table of compositions for a particular phase is converted from oxides (or elements) to moles of endmembers in either the forward or reverse direction. In the forward direction, the input phase compositions are given in terms of weight (or moles) of oxides (or elements) and converted to moles of endmembers. In the reverse direction, moles of endmembers are converted back into weights (or moles) of oxides (or elements). This conversion is unnormalized (or extensive). Select only one of the input methods to define composition.
- Parameters:
- abbrev: str
Standard abbreviation for a phase of interest that belongs to the current database.
- database: str|Database, default=’MELTS_v1_2’
Database ID or Database object that contains the phase of interest.
- mol_endmemsarray_like, optional
Input compositions given as moles of endmembers for the phase.
- wt_oxidesDataFrame, optional
Input compositions given as weight of each oxide.
- mol_oxidesDataFrame, optional
Input compositions given as moles of each oxide.
- wt_elemsDataFrame, optional
Input compositions given as weight of each element.
- mol_elemsDataFrame, optional
Input compositions given as moles of each element.
- tostr, required
Desired output type. This required argument must be one of: - ‘mol_endmems’ : select for forward direction - ‘wt_oxides’ : select for reverse direction, input as mol_endmems required - ‘mol_oxides’ : select for reverse direction, input as mol_endmems required - ‘wt_elems’ : select for reverse direction, input as mol_endmems required - ‘mol_elems’ : select for reverse direction, input as mol_endmems required
- Returns:
- output_comp_tableDataFrame
Converted composition table.
See also
rockychem.convert_bulk_comp_table
Notes
The order of the endmembers depends on the particular phase model being used. In the forward direction, output is labeled by endmember name. In case of confusion, examine the endmember names or consult the phase model for details.
Examples
>>> import thermoengine.rockychem as rockychem >>> OXIDE_WTS = rockychem.OXIDE_WTS >>> wt_oxides_tbl = pd.DataFrame({ ... 'Mg2SiO4': {'MgO' : 2*OXIDE_WTS['MgO'], 'SiO2':OXIDE_WTS['SiO2']}, ... 'Mg1Fe1SiO4': {'MgO' : 1*OXIDE_WTS['MgO'], 'FeO':1*OXIDE_WTS['FeO'], 'SiO2':OXIDE_WTS['SiO2']}, ... 'Fe2SiO4': {'FeO' : 2*OXIDE_WTS['FeO'], 'SiO2':OXIDE_WTS['SiO2']} ... }, index=['MgO','FeO','SiO2']).fillna(0).T >>> mol_endmems_tbl = rockychem.convert_phase_comp_table('Ol', wt_oxides=wt_oxides_tbl, to='mol_endmems') >>> mol_endmems_tbl Tephroite Fayalite Coolivine Niolivine Monticellite Forsterite Mg2SiO4 0.0 0.0 0.0 0.0 0.0 1.0 MgFeSiO4 0.0 0.5 0.0 0.0 0.0 0.5 Fe2SiO4 0.0 1.0 0.0 0.0 0.0 0.0