oemof / tespy

Thermal Engineering Systems in Python (TESPy). This package provides a powerful simulation toolkit for thermal engineering plants such as power plants, district heating systems or heat pumps.
https://tespy.readthedocs.io
MIT License
256 stars 80 forks source link

key for specific volume in fluid property plotting data of components is `v` instead of `vol` #432

Open davidpasquale opened 10 months ago

davidpasquale commented 10 months ago

Hi, first of all, I thank you for the great work you are doing. I just started with the library and it seems very well thought out and structured. Could you please check the properties present in the connections of a HeatExchanger in the cold branch? In my opinion p, T, h are correct, v is wrong (other properties I have not checked). Thank you

I mean: HEX.inl[1].v.val and HEX.outl[1].v.val

fwitte commented 10 months ago

@davidpasquale, thank you for reaching out.

I do not really understand what example you are referring to. Could you provide a fully working script to reproduce the erroneous behavior?

Thanks

davidpasquale commented 10 months ago

Hi, here a working example. Kind regards

from tespy.components import Sink, Source, HeatExchanger, Condenser
from tespy.connections import Connection
from tespy.networks import Network
from tespy.tools import document_model
import shutil
import numpy as np
from CoolProp.CoolProp import PropsSI as PSI
from CoolProp.CoolProp import AbstractState as AS
from CoolProp import iP_critical, PT_INPUTS, PQ_INPUTS, HmassP_INPUTS

fluids=['Cyclopentane', 'isobutane']
NET = Network(fluids=fluids, T_unit='C', p_unit='bar', h_unit='kJ / kg', iterinfo=True)

SRChot = Source('HOTin')
SNKhot = Sink('HOTout')

SRCcold = Source('CLDin')
SNKcold = Sink('CLDout')

HEX = HeatExchanger('HEX')

ch1 = Connection(SRChot, 'out1', HEX, 'in1')
cc1 = Connection(SRCcold, 'out1', HEX, 'in2')
ch2 = Connection(HEX, 'out1', SNKhot, 'in1')
cc2 = Connection(HEX, 'out2', SNKcold, 'in1')

NET.add_conns(ch1, ch2, cc1, cc2)

p_h1 = 20.0
T_h1 = 200
dp1=6

p_c1 = 30
T_c1 = 80
dp2=15

HEX.set_attr(pr1=(p_h1-dp1)/p_h1, pr2=(p_c1-dp2)/p_c1, ttd_l=20, ttd_u=40,
             design=['pr1', 'pr2', 'ttd_l'],
             offdesign=['zeta1', 'pr2', 'kA_char'])

ch1.set_attr(fluid={fluids[0]:1, fluids[1]: 0}, T=T_h1, p=p_h1, m=1)
ch2.set_attr()
cc1.set_attr(fluid={fluids[0]:0, fluids[1]: 1}, T=T_c1, p=p_c1)
cc2.set_attr()

NET.solve('design')#, use_cuda=True)
NET.save('tmp')
NET.print_results()

if (NET.iter <=1 or not NET.converged): 
   print('SOLUTION NOT CONVERGED', NET.iter, NET.converged)
   exit()

HOTside_data = HEX.get_plotting_data()[1]
CLDside_data = HEX.get_plotting_data()[2]

print('HOTside plotting   data', HOTside_data['starting_point_property'], HOTside_data['starting_point_value'], HOTside_data['ending_point_value'])
print('HOTside connection data', 'v', HEX.inl[0].v.val, HEX.outl[0].v.val)
print('HOTside connection data', 'v', ch1.v.val, ch2.v.val)

print('CLDside plotting   data', CLDside_data['starting_point_property'], CLDside_data['starting_point_value'], CLDside_data['ending_point_value'])
print('CLDside connection data', 'v', HEX.inl[1].v.val, HEX.outl[1].v.val)
print('CLDside connection data', 'v', cc1.v.val, cc2.v.val)
fwitte commented 10 months ago

Ah I see... The data are correct. The v key from the plotting data is actually the specific volume, while the v attributes is the volumetric flow, i.e. mass flow times specific volume. You'd have to look for the connection attribute vol to get the same value as the v key of the plotting data.

I guess there was a renaming a long time ago or something and I did not check the compability with fluprodia...

davidpasquale commented 10 months ago

Thank you!!! you are right!