Troubleshooting - Nouman090/ThermoSim GitHub Wiki

Import Errors

ModuleNotFoundError: No module named 'ThermoSim'

Cause: Package not installed or running from wrong directory.
Fix:   pip install ThermoSim
  OR:  cd to project root directory, then run your script.

ModuleNotFoundError: No module named 'CoolProp'

Fix:   pip install CoolProp

State Point Errors

"provide exactly 2 properties"

# ❌ Wrong: 3 properties
Model.add_point('water', '1', P=1e6, T=500, H=3000000)

# ✅ Right: exactly 2
Model.add_point('water', '1', P=1e6, T=500)

"Invalid property 'X'"

# ❌ Wrong key
Model.add_point('water', '1', P=1e6, Temperature=500)

# ✅ Valid keys: P, T, H, S, Q, D
Model.add_point('water', '1', P=1e6, T=500)

CoolProp error: input pair is not valid

Cause: Properties are in the two-phase region.
Fix:   Use Q (quality) instead of T.
# ❌ Can fail if T is exactly at saturation
Model.add_point('water', '3', P=0.008e6, T=314.67)

# ✅ Use quality for saturation
Model.add_point('water', '3', P=0.008e6, Q=0)

Wrong units

# ❌ Temperature in °C (CoolProp uses Kelvin!)
Model.add_point('water', '1', P=8e6, T=480)  # 480 K ≠ 480°C!

# ✅ Convert to Kelvin
Model.add_point('water', '1', P=8e6, T=480 + 273.15)

# ❌ Pressure in bar
Model.add_point('water', '1', P=80, T=753.15)  # 80 Pa!

# ✅ Pressure in Pascal
Model.add_point('water', '1', P=80e5, T=753.15)  # 80 bar

Component Errors

"Mass flowrate mismatch"

Cause: Inlet and outlet mass flows are different (for same-fluid components).
Fix:   Set mass flow on only one side. Let it propagate.
# ❌ Different mass flows
Model.add_point('water', '1', P=8e6, T=753.15, Mass_flowrate=1)
Model.add_point('water', '2', P=0.008e6, Mass_flowrate=2)  # mismatch!

# ✅ Set on one side only
Model.add_point('water', '1', P=8e6, T=753.15, Mass_flowrate=1)
Model.add_point('water', '2', P=0.008e6)  # inherits from inlet

"Pinch already occurred"

Cause: The temperatures cross in the heat exchanger.
Fix:   - Increase hot side inlet temperature
       - Decrease cold side inlet temperature
       - Increase PPT value
       - Adjust mass flow rates

Component not solving

# Make sure Calculate=True
Turbine(Model, 'T1', '1', '2', n_isen=0.85, Calculate=True)
#                                              ^^^^^^^^^^^^^^

# Or call Cal() manually
turb = Turbine(Model, 'T1', '1', '2', n_isen=0.85)
turb.Cal()

Model Summary Issues

Efficiency shows 0 or negative

Cause: HeatAdded parameter is wrong.
Fix:   Boiler must have HeatAdded=True
       Condenser must have HeatAdded=False

Exergy destruction is "Not Calculated"

Cause: Mass flow rate is missing on some points.
Fix:   Make sure every point that needs exergy has a Mass_flowrate.

Plotting Errors

"has not been solved yet"

Fix: Make sure the component's Calculate=True or call .Cal() first.

"SimpleHEX has only two points"

Fix: plot_hex_profile only works for double_pipe/Condenser/Evaporator.
     SimpleHEX doesn't have an internal temperature profile.

File Errors

FileNotFoundError: T66.json

Fix: Copy T66.json into the ThermoSim/ package directory.
     Only needed if you use Therminol66 fluid.

General Tips

  1. Units: Always use Pa for pressure, K for temperature, J/kg for enthalpy
  2. Two properties: Each state point needs exactly 2 independent properties
  3. Mass flow: Set mass flow on one state point per loop — it propagates
  4. Calculate: Set Calculate=True or call .Cal() to solve a component
  5. Order matters: Define points before components. Solve components in flow order.
  6. Dead state: Always call Model.set_dead_state() before creating state points