exerpy.functions¶
- exerpy.functions.add_chemical_exergy(my_json, Tamb, pamb, chemExLib)[source]¶
Adds the chemical exergy to each connection in the JSON data, prioritizing molar composition if available.
Parameters: - my_json: The JSON object containing the components and connections. - Tamb: Ambient temperature in K. - pamb: Ambient pressure in Pa.
Returns: - The modified JSON object with added chemical exergy for each connection.
- exerpy.functions.add_total_exergy_flow(my_json, split_physical_exergy)[source]¶
Adds the total exergy flow to each connection in the JSON data based on its kind.
For ‘material’ connections, the exergy is calculated as before.
For ‘power’ connections, the energy flow value is used directly.
For ‘heat’ connections, if the associated component is of class SimpleHeatExchanger, the thermal exergy difference is computed as:
\[E = (e^\mathrm{T}_\mathrm{in} \cdot \dot m_\mathrm{in}) - (e^\mathrm{T}_\mathrm{out} \cdot \dot m_\mathrm{out})\]
Otherwise, a warning is logged and E is set to None.
- Parameters:
my_json (dict) – The JSON object containing the components and connections.
split_physical_exergy (bool) – Split physical exergy in mechanical and thermal shares.
- Returns:
dict – The modified JSON object with added total exergy flow for each connection.
- exerpy.functions.calc_chemical_exergy(stream_data, Tamb, pamb, chemExLib)[source]¶
Calculate the specific chemical exergy of a stream.
A pure substance gets the value of its reference phase. A pure substance without a value in the library gets 0, which is only valid if it does not react. A mixture is an ideal gas mixture. If water condenses at the ambient state, the liquid water forms a separate phase (Bejan et al., 1996, p. 138):
\[\bar{e}^\mathrm{CH} = x_\mathrm{g} \left( \sum_k y_k \bar{e}^\mathrm{CH}_k + \bar{R} T_0 \sum_k y_k \ln y_k \right) + x_\mathrm{H_2O,l} \, \bar{e}^\mathrm{CH}_\mathrm{H_2O,l}\]with the molar fraction of the gas phase \(x_\mathrm{g}\) and the molar fractions \(y_k\) within the gas phase.
- Parameters:
stream_data (dict) –
molar_compositionormass_compositionof the stream.Tamb (float) – Ambient temperature in K.
pamb (float) – Ambient pressure in Pa.
chemExLib (str) – Name of the chemical exergy library, e.g.
'Ahrendts'.
- Returns:
float – Specific chemical exergy in J/kg.
- Raises:
ValueError – If the library has no value for a substance of a mixture.
- exerpy.functions.mass_to_molar_fractions(mass_fractions)[source]¶
Convert mass fractions to molar fractions.
Species with a zero mass fraction are left out. A stream of a single species gets the molar fraction 1 without its molar mass.
- Parameters:
mass_fractions (dict) – Mass fractions by species name. The names have to be known to CoolProp.
- Returns:
dict – Molar fractions by species name.
- Raises:
ValueError – If CoolProp has no molar mass for a species with a nonzero mass fraction.
- exerpy.functions.molar_to_mass_fractions(molar_fractions)[source]¶
Convert molar fractions to mass fractions.
Parameters: - molar_fractions: Dictionary with component names as keys and molar fractions as values.
Returns: - mass_fractions: Dictionary with component names as keys and mass fractions as values.