Replies: 1 comment
-
@stockh0lm, thank you for reaching out! One issue is actually kind of tespy related:
The issue with the minimum value violations has also been resolved in that release, it printed out the wrong value in the logging (maximum instead of minimum). For the fan and the pump these are actually the power I have two more suggestions for your script:
Best! import pandas as pd
from tespy.components import Sink, Source, Pump, HeatExchanger
from tespy.connections import Connection, Ref
from tespy.networks import Network
from tespy.tools.helpers import TESPyNetworkError
def main():
fluid_list = ['water', 'air']
nw = Network(fluids=fluid_list, p_unit='bar', T_unit='C', h_unit='kJ / kg', m_unit='kg / s')
air_in = Source('Air Inlet')
air_out = Sink('Air Outlet')
water_in = Source('Water Inlet')
water_out = Sink('Water Outlet')
pump_water = Pump('Water Pump')
fan_air = Pump('Air Fan')
hx = HeatExchanger('Heat Exchanger')
# Verbindungen erstellen
air_inlet_fan = Connection(air_in, 'out1', fan_air, 'in1')
fan_air_hx = Connection(fan_air, 'out1', hx, 'in1')
hx_air_outlet = Connection(hx, 'out1', air_out, 'in1')
water_inlet_pump = Connection(water_in, 'out1', pump_water, 'in1')
pump_hx = Connection(pump_water, 'out1', hx, 'in2')
hx_water_outlet = Connection(hx, 'out2', water_out, 'in1')
nw.add_conns(air_inlet_fan, fan_air_hx, hx_air_outlet, water_inlet_pump, pump_hx, hx_water_outlet)
hx_air_outlet.set_attr(p=Ref(air_inlet_fan, 1, 0))
hx_water_outlet.set_attr(p=Ref(water_inlet_pump, 1, 0))
[c.set_attr(p0=1) for c in nw.conns["object"]]
# Initial solve
calc_heatexchange(air_inlet_fan, 25, fan_air, 0.4, hx, nw, pump_water, water_inlet_pump, 10)
# Daten speichern
data = []
# Parameter für die Berechnungen
air_temps = [20, 25, 30, 35]
water_temps = [4, 9, 14]
humidities = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6]
# Schleife für verschiedene Bedingungen
for air_temp in air_temps:
for water_temp in water_temps:
for humidity in humidities:
try:
calc_heatexchange(air_inlet_fan, air_temp, fan_air, humidity, hx, nw, pump_water, water_inlet_pump, water_temp)
water_out_temp = hx_water_outlet.T.val
Q = hx.Q.val
data.append([air_temp, water_temp, humidity, water_out_temp, Q])
except TESPyNetworkError as e:
print(f"Calculation failed for air_temp={air_temp}, water_temp={water_temp}, humidity={humidity}: {e}")
df = pd.DataFrame(data, columns=['Air Temperature (C)', 'Water Temperature (C)', 'Humidity', 'Water Outlet Temperature (C)', 'Heat Transfer (W)'])
df.to_csv('heat_exchanger_results.csv', index=False)
print("Berechnungen abgeschlossen und Daten gespeichert.")
def calc_heatexchange(air_inlet_fan, air_temp, fan_air, humidity, hx, nw, pump_water, water_inlet_pump, water_temp):
# Luftzustand setzen
print("#" * 10)
air_inlet_fan.set_attr(m=1.2, T=air_temp, p=1, fluid={'air': 1 - humidity, 'water': humidity})
fan_air.set_attr(eta_s=0.8)
# Wasserzustand setzen
water_inlet_pump.set_attr(m=0.1, T=water_temp, p=1, fluid={'water': 1})
pump_water.set_attr(eta_s=0.8)
hx.set_attr(pr1=0.99, pr2=0.99, eff_max=.9)
print(f"Calculating for air_temp={air_temp}, water_temp={water_temp}, humidity={humidity}")
nw.solve('design', print_results=False)
if __name__ == '__main__':
main() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am calculating heat flow for a range of parameters and get this output:
I assume I am running into thermodynamic or otherwise impossible scenarios, which TesPy highlights here. However, I need help seeing the pattern. Thermodynamically, different issues could be causing these messages.
But how is there an issue with condensation, e.g., if higher humidities with identical temperatures seem to work fine? The same goes for negative pressure values of the air fan. Some fail, and the surrounding ones work. What is the issue here?
Beta Was this translation helpful? Give feedback.
All reactions