enex_analysis.thermodynamics

Thermodynamic property and exergy calculations.

Functions

calc_energy_flow(G, T, T0)

Calculate energy flow rate.

calc_exergy_flow(G, T, T0)

Calculate exergy flow rate.

calc_refrigerant_exergy(df, ref, T0_K[, P0])

Calculate refrigerant state-point exergy using pre-computed properties.

convert_electricity_to_exergy(df)

Copy all electricity columns (E_*) to exergy columns (X_*).

generate_entropy_exergy_term(fluid, T, P, Q, ...)

Calculate entropy, enthalpy, and exergy.

enex_analysis.thermodynamics.generate_entropy_exergy_term(fluid, T, P, Q, T0, P0, phase='gas')[source]

Calculate entropy, enthalpy, and exergy.

Parameters:
  • fluid (str) – Fluid name.

  • T (float) – Temperature [K].

  • P (float) – Pressure [Pa].

  • Q (float) – Quality (0 to 1).

  • T0 (float) – Dead state temperature [K].

  • P0 (float) – Dead state pressure [Pa].

  • phase (Literal['gas', 'liquid', 'twophase'], optional) – Fluid phase. Default is ‘gas’.

Returns:

Entropy [J/kg-K], Enthalpy [J/kg], Exergy [J/kg].

Return type:

tuple[float, float, float]

enex_analysis.thermodynamics.calc_energy_flow(G, T, T0)[source]

Calculate energy flow rate.

Parameters:
  • G (float or pd.Series) – Heat capacity flow rate (mass_flow * Cp) [W/K].

  • T (float or pd.Series) – Current temperature [K].

  • T0 (float or pd.Series) – Reference/dead state temperature [K].

Returns:

Energy flow rate [W].

Return type:

float or pd.Series

enex_analysis.thermodynamics.calc_exergy_flow(G, T, T0)[source]

Calculate exergy flow rate.

Parameters:
  • G (float or pd.Series) – Heat capacity flow rate (mass_flow * Cp) [W/K].

  • T (float or pd.Series) – Current temperature [K].

  • T0 (float or pd.Series) – Reference/dead state temperature [K].

Returns:

Exergy flow rate [W].

Return type:

float or pd.Series

enex_analysis.thermodynamics.calc_refrigerant_exergy(df, ref, T0_K, P0=101325)[source]

Calculate refrigerant state-point exergy using pre-computed properties.

Uses the entropy (s_ref_*) and enthalpy (h_ref_*) columns already present in df (produced by calc_ref_state) to compute specific exergy and exergy flow rate for each refrigerant state point.

Dead-state properties (h0, s0) are evaluated at (T0, P0) for the given refrigerant using CoolProp (vectorized via unique T0 values).

Parameters:
  • df (pd.DataFrame) – DataFrame containing pre-computed enthalpy h_ref_* [J/kg], entropy s_ref_* [J/(kg·K)], and mass-flow m_dot_ref [kg/s] columns.

  • ref (str) – CoolProp refrigerant identifier (e.g. 'R410A').

  • T0_K (pd.Series) – Dead-state (environment) temperature per row [K].

  • P0 (float) – Dead-state pressure [Pa] (default 101325).

Returns:

df with columns added per state point: x_ref_{name} [J/kg], X_ref_{name} [W].

Return type:

pd.DataFrame

Notes

  • Exergy equation: x = (h − h0) − T0·(s − s0) [J/kg]

  • Exergy flow: X = ṁ · x [W]

  • Rows with NaN enthalpy/entropy propagate NaN naturally.

enex_analysis.thermodynamics.convert_electricity_to_exergy(df)[source]

Copy all electricity columns (E_*) to exergy columns (X_*).

Electrical energy is 100 %% pure exergy, so X = E for all electricity-consumption columns.

The function searches for columns matching the pattern E_xxx [W] and creates corresponding X_xxx [W] columns.

Parameters:

df (pd.DataFrame) – DataFrame with E_xxx [W] columns.

Returns:

df with X_xxx [W] columns added.

Return type:

pd.DataFrame