Source and Sink - Nouman090/ThermoSim GitHub Wiki
Source and Sink are boundary condition components that represent mass/energy entering or leaving the system. They do not perform any thermodynamic calculations; they simply track the energy flow rate.
Source
A source supplies fluid to the system. The outlet state must be fully defined (including mass flow rate).
Physics
Energy supply = แน ร H
Ex_D = 0
Syntax
Source(Model, ID, Out_state, Calculate=False)
| Parameter | Type | Default | Description |
|---|---|---|---|
Model |
ThermodynamicModel | โ | The model object |
ID |
str | โ | Unique component name |
Out_state |
str | โ | Outlet state point name (must be fully defined) |
Calculate |
bool | False | Solve immediately if True |
Output Attributes
| Attribute | Type | Unit | Description |
|---|---|---|---|
.energy_supply |
float | W | Energy supply rate |
.Ex_D |
float | โ | Always 0 |
.Solution_Status |
bool | โ | True if solved |
Example
from Thermosim import ThermodynamicModel, Source
Model = ThermodynamicModel()
Model.set_dead_state()
# Define the source outlet
Model.add_point('water', 'FreshSteam', P=10e5, T=500, Mass_flowrate=5.0)
Source(Model, 'SteamSource', Out_state='FreshSteam', Calculate=True)
print(f"Energy supply: {Model.Component['SteamSource'].energy_supply/1e6:.2f} MW")
Sink
A sink receives fluid from the system. The inlet state must be fully defined (including mass flow rate).
Physics
Energy received = แน ร H
Ex_D = 0
Syntax
Sink(Model, ID, In_state, Calculate=False)
| Parameter | Type | Default | Description |
|---|---|---|---|
Model |
ThermodynamicModel | โ | The model object |
ID |
str | โ | Unique component name |
In_state |
str | โ | Inlet state point name (must be fully defined) |
Calculate |
bool | False | Solve immediately if True |
Output Attributes
| Attribute | Type | Unit | Description |
|---|---|---|---|
.energy_supply |
float | W | Energy received rate |
.Ex_D |
float | โ | Always 0 |
.Solution_Status |
bool | โ | True if solved |
Example
from Thermosim import ThermodynamicModel, Sink
Model = ThermodynamicModel()
Model.set_dead_state()
# Define the sink inlet
Model.add_point('water', 'Exhaust', P=1e5, T=350, Mass_flowrate=5.0)
Sink(Model, 'ExhaustSink', In_state='Exhaust', Calculate=True)
print(f"Energy received: {Model.Component['ExhaustSink'].energy_supply/1e6:.2f} MW")
Complete Example (Source + Sink)
from Thermosim import ThermodynamicModel, Source, Sink, Turbine
Model = ThermodynamicModel()
Model.set_dead_state()
# Source: high-pressure steam
Model.add_point('water', 'Inlet', P=80e5, T=773.15, Mass_flowrate=10)
Source(Model, 'BoilerOut', Out_state='Inlet', Calculate=True)
# Turbine
Model.add_point('water', 'Outlet', P=0.1e5)
Turbine(Model, 'Turbine', 'Inlet', 'Outlet', n_isen=0.85, Calculate=True)
# Sink: low-pressure exhaust
Sink(Model, 'CondenserIn', In_state='Outlet', Calculate=True)
# Results
print(f"Source energy: {Model.Component['BoilerOut'].energy_supply/1e6:.2f} MW")
print(f"Turbine work: {Model.Component['Turbine'].work/1e6:.2f} MW")
print(f"Sink energy: {Model.Component['CondenserIn'].energy_supply/1e6:.2f} MW")
Output:
Source energy: XX.XX MW
Turbine work: X.XX MW
Sink energy: XX.XX MW