Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem by modeling of a heat pump #213

Closed
yuson95 opened this issue Jul 26, 2020 · 9 comments
Closed

problem by modeling of a heat pump #213

yuson95 opened this issue Jul 26, 2020 · 9 comments

Comments

@yuson95
Copy link

yuson95 commented Jul 26, 2020

Hi, I got a problem by using tespy to model a heat pump. In the examples of heat pump, NH3 ist used as the Refrigerant, if I thought about it right. If I need to change to other Refrigerant such as R134a or R410a. There will be an error by calculating. I think I may use it wrong. Could you please tell me how to fix that problem? Thank you!

@fwitte
Copy link
Member

fwitte commented Jul 27, 2020

Hi @yuson95,
I'll need the code you are trying to run to see, what is happening. Can you post it here? Also please provide the version of tespy you are using.
Cheers

@yuson95
Copy link
Author

yuson95 commented Jul 27, 2020

Hi,
thank you for responding! here is the code I just change the Refrigerant in the example to R134a:

# -*- coding: utf-8 -*-
from tespy.networks import network
from tespy.components import (
    sink, source, splitter, compressor, condenser, pump, heat_exchanger_simple,
    valve, drum, heat_exchanger, cycle_closer
)
from tespy.connections import connection, ref
from tespy.tools.characteristics import char_line
from tespy.tools.characteristics import load_default_char as ldc

import numpy as np
import pandas as pd

# %% network

nw = network(
    fluids=['water', 'R134a', 'air'], T_unit='C', p_unit='bar', h_unit='kJ / kg',
    m_unit='kg / s'
)

# %% components

# sources & sinks
cc = cycle_closer('coolant cycle closer')
cb = source('consumer back flow')
cf = sink('consumer feed flow')
amb = source('ambient air')
amb_out1 = sink('sink ambient 1')
amb_out2 = sink('sink ambient 2')

# ambient air system
sp = splitter('splitter')
fan = compressor('fan')

# consumer system

cd = condenser('condenser')
dhp = pump('district heating pump')
cons = heat_exchanger_simple('consumer')

# evaporator system

ves = valve('valve')
dr = drum('drum')
ev = heat_exchanger('evaporator')
su = heat_exchanger('superheater')
erp = pump('evaporator reciculation pump')

# compressor-system

cp1 = compressor('compressor 1')
cp2 = compressor('compressor 2')
ic = heat_exchanger('intercooler')

# %% connections

# consumer system

c_in_cd = connection(cc, 'out1', cd, 'in1')

cb_dhp = connection(cb, 'out1', dhp, 'in1')
dhp_cd = connection(dhp, 'out1', cd, 'in2')
cd_cons = connection(cd, 'out2', cons, 'in1')
cons_cf = connection(cons, 'out1', cf, 'in1')

nw.add_conns(c_in_cd, cb_dhp, dhp_cd, cd_cons, cons_cf)

# connection condenser - evaporator system

cd_ves = connection(cd, 'out1', ves, 'in1')

nw.add_conns(cd_ves)

# evaporator system

ves_dr = connection(ves, 'out1', dr, 'in1')
dr_erp = connection(dr, 'out1', erp, 'in1')
erp_ev = connection(erp, 'out1', ev, 'in2')
ev_dr = connection(ev, 'out2', dr, 'in2')
dr_su = connection(dr, 'out2', su, 'in2')

nw.add_conns(ves_dr, dr_erp, erp_ev, ev_dr, dr_su)

amb_fan = connection(amb, 'out1', fan, 'in1')
fan_sp = connection(fan, 'out1', sp, 'in1')
sp_su = connection(sp, 'out1', su, 'in1')
su_ev = connection(su, 'out1', ev, 'in1')
ev_amb_out = connection(ev, 'out1', amb_out1, 'in1')

nw.add_conns(amb_fan, fan_sp, sp_su, su_ev, ev_amb_out)

# connection evaporator system - compressor system

su_cp1 = connection(su, 'out2', cp1, 'in1')

nw.add_conns(su_cp1)

# compressor-system

cp1_he = connection(cp1, 'out1', ic, 'in1')
he_cp2 = connection(ic, 'out1', cp2, 'in1')
cp2_c_out = connection(cp2, 'out1', cc, 'in1')

sp_ic = connection(sp, 'out2', ic, 'in2')
ic_out = connection(ic, 'out2', amb_out2, 'in1')

nw.add_conns(cp1_he, he_cp2, sp_ic, ic_out, cp2_c_out)

# %% component parametrization

# condenser system

cd.set_attr(pr1=0.99, pr2=0.99, ttd_u=5, design=['pr2', 'ttd_u'],
            offdesign=['zeta2', 'kA_char'])
dhp.set_attr(eta_s=0.8, design=['eta_s'], offdesign=['eta_s_char'])
cons.set_attr(pr=0.99, design=['pr'], offdesign=['zeta'])

# air fan

fan.set_attr(eta_s=0.65, design=['eta_s'], offdesign=['eta_s_char'])

# evaporator system

kA_char1 = ldc('heat exchanger', 'kA_char1', 'DEFAULT', char_line)
kA_char2 = ldc('heat exchanger', 'kA_char2', 'EVAPORATING FLUID', char_line)

ev.set_attr(pr1=0.999, pr2=0.99, ttd_l=5,
            kA_char1=kA_char1, kA_char2=kA_char2,
            design=['pr1', 'ttd_l'], offdesign=['zeta1', 'kA_char'])
su.set_attr(pr1=0.999, pr2=0.99, ttd_u=2, design=['pr1', 'pr2', 'ttd_u'],
            offdesign=['zeta1', 'zeta2', 'kA_char'])
erp.set_attr(eta_s=0.8, design=['eta_s'], offdesign=['eta_s_char'])

# compressor system

cp1.set_attr(eta_s=0.85, design=['eta_s'], offdesign=['eta_s_char'])
cp2.set_attr(eta_s=0.9, pr=3, design=['eta_s'], offdesign=['eta_s_char'])
ic.set_attr(pr1=0.99, pr2=0.999, design=['pr1', 'pr2'],
            offdesign=['zeta1', 'zeta2', 'kA_char'])

# %% connection parametrization

# condenser system

c_in_cd.set_attr(fluid={'air': 0, 'R134a': 1, 'water': 0})
cb_dhp.set_attr(T=60, p=10, fluid={'air': 0, 'R134a': 0, 'water': 1})
cd_cons.set_attr(T=90)
cons_cf.set_attr(h=ref(cb_dhp, 1, 0), p=ref(cb_dhp, 1, 0))

# evaporator system cold side

erp_ev.set_attr(m=ref(ves_dr, 1.25, 0), p0=5)
su_cp1.set_attr(p0=5, h0=1700)

# evaporator system hot side

# fan blows at constant rate
amb_fan.set_attr(T=12, p=1, fluid={'air': 1, 'R134a': 0, 'water': 0},
                 offdesign=['v'])
sp_su.set_attr(offdesign=['v'])
ev_amb_out.set_attr(p=1, T=9, design=['T'])

# compressor-system

he_cp2.set_attr(Td_bp=5, p0=20, design=['Td_bp'])
ic_out.set_attr(T=30, design=['T'])

# %% key paramter

cons.set_attr(Q=-200e3)

# %% Calculation

nw.solve('design')
nw.print_results()
nw.save('heat_pump_air')

T_range = [6, 12, 18, 24, 30]
Q_range = np.array([100e3, 120e3, 140e3, 160e3, 180e3, 200e3, 220e3])
df = pd.DataFrame(columns=Q_range / -cons.Q.val)

for T in T_range:
    amb_fan.set_attr(T=T)
    eps = []

    for Q in Q_range:
        cons.set_attr(Q=-Q)
        nw.solve('offdesign', design_path='heat_pump_air')

        if nw.lin_dep:
            eps += [np.nan]
        else:
            eps += [
                abs(cd.Q.val) / (cp1.P.val + cp2.P.val + erp.P.val + fan.P.val)
            ]

    df.loc[T] = eps

df.to_csv('COP_air.csv')
`
And here is the arised ERROR:
`ValueError: unable to solve 1phase PY flash with Tmin=288.895, Tmax=682.5 due to error: HSU_P_flash_singlephase_Brent could not find a solution because Hmolar [173454 J/mol] is above the maximum value of 87946.3997716 J/mol`
The Version is 0.3.2
Thank you!

@fwitte
Copy link
Member

fwitte commented Jul 27, 2020

Changing the refrigerant without changing the parameters of the model appropriately is the issue here:

  • The manually specified starting values for pressure and enthalpy are suited to NH3, not to R134a. I recommend having a look at the corresponding log_ph diagram (I generate these with fluprodia)
  • On the condenser side, R134a will be near to the critical point pressure. This might also cause instability in the solution process, as the condenser does not work with supercritical fluids due to its constraint of saturated liquid at the hot side outlet. If pressure is above critical pressure, this value cannot be computed.

Specifically, the following modifications will make the model solvable:

# use a starting value for pressure at the condenser inlet
c_in_cd.set_attr(fluid={'air': 0, 'R134a': 1, 'water': 0}, p0=30)

# modify the pressure starting values and remove the enthalpy starting value.
# Instead add a condition for the fluid to be at gaseous state at the superheater outlet.
# This condition does not add an equation but stabilizes the solution process.
# At the date of the creation of the example, this tool had not been implemented but it
# is surperior to the enthalpy starting value. I will add a reminder, that I need to change
# the example here.
erp_ev.set_attr(m=ref(ves_dr, 1.25, 0), p0=2)
su_cp1.set_attr(p0=2, state='g')

logph_diagram

Code to generate this diagram:

from fluprodia import FluidPropertyDiagram
import numpy as np


diagram = FluidPropertyDiagram('R134a')
diagram.set_unit_system(T='°C', p='bar', h='kJ/kg')
iso_T = np.arange(-50, 201, 25)
diagram.set_isolines(T=iso_T)
diagram.calc_isolines()
diagram.set_limits(x_min=750, x_max=2000, y_min=-50, y_max=200)
diagram.draw_isolines('Ts')
diagram.save('Ts_diagram.svg')

diagram.set_limits(x_min=0, x_max=750, y_min=1e-1, y_max=1e2)
diagram.draw_isolines('logph')
diagram.save('logph_diagram.svg')

@yuson95
Copy link
Author

yuson95 commented Jul 27, 2020

Thank you! I tried to change the pressure there before, but it raised the same error. And I tried the pressure you gave, it still doesn't work. But Now I know where the problem is. thank you!
I adjusted the temperature too? Now it works!!

@fwitte
Copy link
Member

fwitte commented Jul 27, 2020

Forgot the modification of this line:

he_cp2.set_attr(Td_bp=5, p0=10, design=['Td_bp'])

Also, I did only look at the design case. You might need to change the refrigerant in case you want to go for higher temperature levels at the heating side.

Best regards

@yuson95
Copy link
Author

yuson95 commented Jul 27, 2020

Yeah I see. And the tool fluprodia is really cool. Thank you so much!

@fwitte
Copy link
Member

fwitte commented Jul 27, 2020

You're welcome :), happy to see people using tespy (and fluprodia of course :D). Have a nice week!

@fwitte
Copy link
Member

fwitte commented Oct 9, 2020

Hi @yuson95,
can we close this issue? It may be useful for other users, to append the information on changing the working fluid change in the online documentation, too.
Best regards

@yuson95
Copy link
Author

yuson95 commented Oct 9, 2020 via email

@fwitte fwitte closed this as completed Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants