State Points - Nouman090/ThermoSim GitHub Wiki

A state point represents the thermodynamic condition of a fluid at a specific location in the cycle. It stores properties like pressure, temperature, enthalpy, entropy, quality, density, and exergy.

Creating a State Point

Method 1: Through the Model (Recommended)

from ThermoSim import ThermodynamicModel

Model = ThermodynamicModel()
Model.set_dead_state() #defult value is T0=298.15, P0=101325 

Model.add_point('water', '1', P=1e6, T=500, Mass_flowrate=2.0)

Method 2: Directly

from ThermoSim.state import Prop
from ThermoSim import config

config.set_dead_state(T0=298.15, P0=101325)

pt = Prop('water', 'my_point', P=1e6, T=500, Mass_flowrate=2.0)
print(pt)

Required Inputs

Every state point needs:

  1. Fluid name (string)
  2. State point name (unique string identifier)
  3. Exactly 2 independent thermodynamic properties
Property Symbol Unit Key
Pressure P Pa P
Temperature T K T
Specific Enthalpy h J/kg H
Specific Entropy s J/(kg·K) S
Quality (vapour fraction) x 0–1 Q
Density ρ kg/m³ D

Optional Inputs

Parameter Type Unit Description
Mass_flowrate float kg/s Mass flow rate at this point

Calculated Properties

When you provide 2 properties, all others are automatically calculated:

Property Attribute Unit
Pressure .P Pa
Temperature .T K
Enthalpy .H J/kg
Entropy .S J/(kg·K)
Quality .Q 0–1 or descriptive string
Density .D kg/m³
Specific heat .Cp J/(kg·K)
Specific exergy .ex J/kg
Exergy rate .Ex W (only if mass flow is given)

All Valid Input Combinations

Case 1: Pressure + Temperature (Most Common)

Model.add_point('water', '1', P=8e6, T=753.15)

⚠️ Cannot be used in the two-phase region. Use P+Q or P+H instead.

Case 2: Pressure + Enthalpy

Model.add_point('water', '2', P=0.7e6, H=2800000)

Works in all regions including two-phase.

Case 3: Pressure + Entropy

Model.add_point('water', '3', P=0.7e6, S=7200)

Case 4: Pressure + Quality (Saturation)

# Saturated liquid
Model.add_point('water', '4', P=0.008e6, Q=0)

# Saturated vapour
Model.add_point('water', '5', P=0.008e6, Q=1)

# Two-phase mixture (30% vapour)
Model.add_point('water', '6', P=0.008e6, Q=0.3)

Case 5: Temperature + Quality

# Saturated liquid at 100°C
Model.add_point('water', '7', T=373.15, Q=0)

Case 6: Temperature + Entropy

Model.add_point('water', '8', T=500, S=7000)

Quality Labels

The .Q attribute shows extra information:

Condition .Q value
Saturated liquid 0.0
Two-phase 0.0 – 1.0
Saturated vapour 1.0
Subcooled liquid "Sub-cooled (X.XX K)"
Superheated vapour "Superheated (X.XX K)"

Exergy Calculation

Exergy is calculated automatically using the dead state:

ex = (h - h₀) - T₀ × (s - s₀)
Ex = ṁ × ex

Where h₀ and s₀ are enthalpy and entropy at the dead state (T₀, P₀).

Model.set_dead_state(T0=298.15, P0=101325)  # 25°C, 1 atm

Model.add_point('water', '1', P=8e6, T=753.15, Mass_flowrate=1)

pt = Model.Point['1']
print(f"Specific exergy: {pt.ex:.0f} J/kg")
print(f"Exergy rate:     {pt.Ex:.0f} W")

If Mass_flowrate is None, then .Ex will be None but .ex is still calculated.

Accessing Properties

pt = Model.Point['1']

print(pt.P)               # Pressure in Pa
print(pt.T)               # Temperature in K
print(pt.T - 273.15)      # Temperature in °C
print(pt.H)               # Enthalpy in J/kg
print(pt.S)               # Entropy in J/(kg·K)
print(pt.Q)               # Quality or phase description
print(pt.D)               # Density in kg/m³
print(pt.Cp)              # Specific heat in J/(kg·K)
print(pt.ex)              # Specific exergy in J/kg
print(pt.Ex)              # Exergy rate in W
print(pt.Mass_flowrate)   # Mass flow rate in kg/s
print(pt.fluid)           # Fluid name
print(pt.StatePointName)  # Point name

Updating Properties

pt = Model.Point['1']
print(pt)
pt.P = 7e5
print(pt)

This will update the pressure as well as other properties of the object #pt#. If you want to update the state point in the model, then you have to update the pressure of the state point in the model.

Model.Point['1'].P = 7e5

Print All State Points

# Default columns
Model.Point_print()

# Custom columns
Model.Point_print(header=['StatePointName', 'P', 'T', 'H', 'S', 'Q', 'ex'])

Partially Defined State Points

You can create a state point with only one known property. The component connected to it will calculate the rest.

# Only pressure known — turbine/pump will calculate H, T, etc.
Model.add_point('water', '2', P=0.008e6)

# Only pressure and quality known
Model.add_point('water', '3', P=0.008e6, Q=0)

Therminol66 (Custom Fluid)

For Therminol66, only P+T or P+H inputs are supported:

Model.add_point('Therminol66', 'hot1', P=1e5, T=573.15, Mass_flowrate=5)
Model.add_point('Therminol66', 'hot2', P=1e5, H=500000)

Requires T66.json file in the package directory.

Common Errors

Error Cause Fix
"provide exactly 2 properties" Gave 0, 1, or 3+ properties Give exactly 2
"Invalid property 'X'" Used wrong key name Use: P, T, H, S, Q, D
"CoolProp error" Properties are outside valid range Check units (Pa, K, J/kg)
Near-saturation warning T and P land exactly on saturation curve Use Q instead of T