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
272 stars 85 forks source link

Use of eta_s_char #240

Closed jase64 closed 2 years ago

jase64 commented 3 years ago

Hi everybody,

I'm trying to configure a turbine based on vendor documents. So usually vendor provides several curves from which a characteristic curve eta_s=f(m) can be derived. However, even after reading the documentation thoroughly, I still cannot figure out the way to pass properly my custom eta_s_char.

Documentation says that for turbine component :

eta_s_char: isentropic efficiency vs. isentropic enthalpy difference/pressure ratio/volumetric flow/mass flow.

but doesn't tell how (at least I didn't find it).

So I think documentation could benefit from a clear reference on how do I tell TESPY:

  1. which curve I intend to select (eta_s vs mass flow for instance)
  2. how to calibrate the curve. I supposed that the design calculation is setting eta_s_design=f(m_design) and that offdesign figure would then be eta_s_offdesign=eta_s_design*interpolation(m_offdesign/m_design,x,y) where x are the reduced mass flow coordinates and y the associated efficiency degradation.

However, by running the following code taken from the documentation examples, it doesn't appear clearly to me.

from tespy.components import sink, source, turbine
from tespy.connections import connection
from tespy.networks import network
from tespy.tools.characteristics import char_line

fluid_list = ['water']
nw = network(fluids=fluid_list, p_unit='bar', T_unit='C', h_unit='kJ / kg', iterinfo=False)
si = sink('sink')
so = source('source')
t = turbine('turbine')
inc = connection(so, 'out1', t, 'in1')
outg = connection(t, 'out1', si, 'in1')
nw.add_conns(inc, outg)
t.set_attr(eta_s=0.9, design=['eta_s'], offdesign=['eta_s_char','cone'])
# Characteristics x as m/m_design and y as eta_s(m)/eta_s_design
t.set_attr(eta_s_char=char_line(x=[0.1, 0.3, 0.5, 0.7, 0.9, 1.1], y=[0.6, 0.65, 0.75, 0.82, 0.85, 0.79],extrapolate=False))
inc.set_attr(fluid={'water': 1}, m=10, T=550, p=110, design=['p'])
outg.set_attr(p=0.5)
nw.solve('design')
nw.print_results()
nw.save('tmp')
inc.set_attr(m=3)
nw.solve('offdesign', design_path='tmp')
nw.print_results()

Has anyone a clue ? Thanks in advance.

fwitte commented 3 years ago

Hi @jase64, sorry for my late reply.

Thank you for pointing that out, the documentation should be improved regarding customization of characteristic functions. I will make an update with the next release, which is planned for early January. I have a different feature I am working on at the moment, which I want to deploy with that release, too.

Regarding the example, the characteristic function is eta_design * f(m/m_design), meaning that you y values of the char_line need to be relative to the design point efficiency value. In order to match the curve to your design point efficiency, you'll need to divide all values by the respective value (which is somewhere between 0.85 and 0.79, or?). Or maybe the 0.9 as specified in the turbine specification values?

The code could look like so. I added one more x value (1.0) to the line and the corresponding value of the efficiency in the y values and divided those by that design value. This is to make sure, the design value efficiency is observed at design mass flow. At m/m_design = 0.3 as specified for the offdesign calculation, the efficiency value will therefore be at 0.65.

from tespy.components import sink, source, turbine
from tespy.connections import connection
from tespy.networks import network
from tespy.tools.characteristics import char_line

fluid_list = ['water']
nw = network(fluids=fluid_list, p_unit='bar', T_unit='C', h_unit='kJ / kg', iterinfo=False)
si = sink('sink')
so = source('source')
t = turbine('turbine')
inc = connection(so, 'out1', t, 'in1')
outg = connection(t, 'out1', si, 'in1')
nw.add_conns(inc, outg)
eta_s_design = 0.84
t.set_attr(eta_s=eta_s_design, design=['eta_s'], offdesign=['eta_s_char','cone'])
# Characteristics x as m/m_design and y as eta_s(m)/eta_s_design
t.set_attr(eta_s_char=char_line(x=[0.1, 0.3, 0.5, 0.7, 0.9, 1.0, 1.1], y=np.array([0.6, 0.65, 0.75, 0.82, 0.85, eta_s_design, 0.79]) / eta_s_design, extrapolate=False))
inc.set_attr(fluid={'water': 1}, m=10, T=550, p=110, design=['p'])
outg.set_attr(p=0.5)
nw.solve('design')
nw.print_results()
nw.save('tmp')
inc.set_attr(m=3)
nw.solve('offdesign', design_path='tmp')
nw.print_results()

Best regards, have a good Christmas holiday! Francesco

jase64 commented 3 years ago

Hi Francesco,

Thanks for your reply.

I understand that the default characteristic line for the turbine, ie eta_s=eta_s_design*f(m/m_design). However the documentation was quoting the existence of 3 other char lines. This might be an error, but when I looked at the source code of eta_s_char_func I see the following condition:

        if self.eta_s_char.param == 'm':
            if not np.isnan(i_d[0]):
                expr = i[0] / i_d[0]
        elif self.eta_s_char.param == 'pr':
            if not np.isnan([i_d[1], o_d[1]]).any():
                expr = (o[1] * i_d[1]) / (i[1] * o_d[1])

The question is how do I pass the "param" parameter to eta_s_char to change the curve ?

The replay can wait for January. In the meantime, enjoy your Christmas holiday !

Best regards, Serge

fwitte commented 3 years ago

Hi Serge, hope you have a good start into 2021. This is, how it should work at the moment:

mychar=dc_cc(
    func=char_line(x=[0.1, 0.3, 0.5, 0.7, 0.9, 1.1], y=[0.6, 0.65, 0.75, 0.82, 0.85, 0.79], extrapolate=False),
    param='pr',
    is_set=False # will be switched to True automatically in offdesign mode as eta_s_char is specified as offdesign parameter
)
t.set_attr(eta_s_char=mychar)

The upcoming API changes will make this easier, I will add this example to the documentation, which will be available once the new version is live. I will let you know once this is the case. Also, the new API will offer easier implementation of different referencing methods. Do you have some spare time this or the next week? Maybe we can have short talk about what features could be implemented here. Best regards Francesco