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 Celsius. - pamb: Ambient pressure in bar.

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: .. math:

    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 chemical exergy of a stream based on the molar fractions and chemical exergy data. There are three cases: - Case A: Handle pure substance. - Case B: If water condenses, handle the liquid and gas phases separately. - Case C: If water doesn’t condense or if water is not present, handle the mixture using the standard approach (ideal mixture).

Parameters: - stream_data: Dictionary containing ‘mass_composition’ of the stream. - Tamb: Ambient temperature in Celsius. - pamb: Ambient pressure in bar.

Returns: - eCH: Chemical exergy in kJ/kg.

exerpy.functions.convert_to_SI(property, value, unit)[source]

Convert a value to its SI value.

Parameters:
  • property (str) – Fluid property to convert.

  • value (float) – Value to convert.

  • unit (str) – Unit of the value.

Returns:

SI_value (float) – Specified fluid property in SI value.

Raises:

ValueError – If the property or unit is invalid or conversion is not possible.:

exerpy.functions.mass_to_molar_fractions(mass_fractions)[source]

Convert mass fractions to molar fractions.

Parameters: - mass_fractions: Dictionary with component names as keys and mass fractions as values.

Returns: - molar_fractions: Dictionary with component names as keys and molar fractions as values.

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.