API Reference - Nouman090/ThermoSim GitHub Wiki

ThermodynamicModel

class ThermodynamicModel:
    set_dead_state(T0=298.15, P0=101325)
    add_point(fluid, StatePointName, Mass_flowrate=None, **properties)
    Prop(fluid, StatePointName='_tmp', Mass_flowrate=None, **properties) โ†’ Prop
    Solve(max_iter=10, verbose=False) โ†’ bool
    ModelSummary()
    Point_print(header=None) โ†’ DataFrame
    Component_print()
    save_model(filename)
    load_model(filename)

Prop (State Point)

class Prop:
    __init__(fluid, StatePointName, Mass_flowrate=None, **properties)
    calculate_missing_properties()
    
    # Attributes
    .fluid, .StatePointName, .Mass_flowrate
    .P, .T, .H, .S, .Q, .D, .Cp
    .ex, .Ex
    .Solution_Status

Components

Turbine

Turbine(Model, ID, In_state, Out_state,
        n_isen=1.0, n_mech=1.0, Calculate=False)
# Attributes: .work, .Ex_D, .Solution_Status, .In, .Out

Pump

Pump(Model, ID, In_state, Out_state,
     Compressibility='Compressible', n_isen=1.0, n_mech=1.0,
     Calculate=False)
# Attributes: .work, .Ex_D, .Solution_Status, .In, .Out

Compressor

Compressor(Model, ID, In_state, Out_state,
           n_isen=1.0, n_mech=1.0, Calculate=False)
# Attributes: .work, .pressure_ratio, .Ex_D, .Solution_Status

HeatExchanger

HeatExchanger(Model, ID, PPT, HEX_type, HeatAdded,
              Hot_In_state, Hot_Out_state,
              Cold_In_state, Cold_Out_state,
              UA=None, effectiveness=None, Q=None,
              div_N=200, PPT_graph=False, Calculate=False)
# Attributes: .Q, .UA, .Hot_Mass_flowrate, .Cold_Mass_flowrate,
#             .Hot_to_Cold, .Ex_D, .effectiveness

Expansion_valve

Expansion_valve(Model, ID, In_state, Out_state, Calculate=False)
# Attributes: .Ex_D

Mixer

Mixer(Model, ID, In_states, Out_state, Calculate=False)
# Attributes: .Ex_D, .Out

Splitter

Splitter(Model, ID, In_state, Out_states, split_fractions,
         Calculate=False)
# Attributes: .Ex_D, .split_fractions

Separator

Separator(Model, ID, In_state, Out_vap_state, Out_liq_state,
          Calculate=False)
# Attributes: .Ex_D, .Out_vap, .Out_liq

Pipe

Pipe(Model, ID, In_state, Out_state,
     Pressure_drop=0, Temperature_drop=0, Calculate=False)
# Attributes: .Pressure_drop, .Temperature_drop, .Ex_D

Source / Sink

Source(Model, ID, Out_state, Calculate=False)
Sink(Model, ID, In_state, Calculate=False)
# Attributes: .energy_supply

TES

TES(Model, ID, PPT, Charge, T_melt,
    Hot_In_state, Hot_Out_state,
    Cold_In_state, Cold_Out_state,
    Charging_time, Discharging_time,
    per_loss, Capacity=None, Calculate=False)
# Attributes: .Capacity, .Charging_Power, .Discharging_Power

Plotting

class CyclePlotter:
    __init__(model)
    plot_Ts_diagram(loop_points=None, fluid=None, show_dome=True,
                    show_labels=True, title='T-s Diagram', figsize=(10,7))
    plot_Ph_diagram(loop_points=None, ...)
    plot_hs_diagram(loop_points=None, ...)
    plot_hex_profile(hex_id, div_N=200, figsize=(12,5)) โ†’ min_dT
    plot_exergy_bar(figsize=(12,6), as_percentage=False)
    plot_exergy_pie(figsize=(8,8))
    plot_energy_summary(figsize=(10,6))

Sensitivity Analysis

class SensitivityAnalyzer:
    __init__(build_func, base_params)
    single_sweep(param_name, values, outputs, x_label=None,
                 figsize=(10,6), plot=True) โ†’ DataFrame
    double_sweep(param1_name, param1_values, param2_name, param2_values,
                 output_name, output_func, figsize=(10,8)) โ†’ DataFrame
    multi_output_sweep(param_name, values, outputs,
                       x_label=None, figsize=(12,8)) โ†’ DataFrame

Units Convention

Quantity Unit Example
Pressure Pa P=8e6 (80 bar)
Temperature K T=753.15 (480ยฐC)
Enthalpy J/kg H=3400000
Entropy J/(kgยทK) S=7000
Mass flow kg/s Mass_flowrate=1
Work/Heat W Computed outputs
Exergy W Computed outputs
Time (TES) hours Charging_time=8