Heat pump issue - Possiblie linear dependencies #503
Replies: 2 comments 7 replies
-
I'd strongly advise you, to set up your system component by component. This way, you will be able to identify, what specifications lead to the linear dependency. In this case, it has nothing to do with the starting values. I can see at first glance, that your streams 21 to 23 are underdetermined in pressure:
Same goes for the condensing side:
I can provide a working version of that model, but I think it would be wise to refactor your model first :). Have a nice day, best Francesco |
Beta Was this translation helpful? Give feedback.
-
Hi there, I've managed to redesign my model but while running and offdesign attempt, I can't figure out what parameters I'm adding that I shouldn't from tespy.networks import Network
from CoolProp.CoolProp import PropsSI as PSI
import matplotlib.pyplot as plt
import numpy as np
heatPump = Network()
heatPump.set_attr(T_unit='C', p_unit='Pa', h_unit='kJ / kg', iterinfo=False)
from tespy.components import (
CycleCloser, Compressor, Valve, Pump, HeatExchanger, Source, Sink
)
closer = CycleCloser('cycle closer')
condenser = HeatExchanger('condenser')
evaporator = HeatExchanger('evaporator')
valve = Valve('expansion valve')
compressor = Compressor('compressor')
pump = Pump('pump')
ambIn1 = Source('ambIn1')
ambIn2 = Source('ambIn2')
ambOut1 = Sink('ambOut1')
ambOut2 = Sink('ambOut2')
from tespy.connections import Connection
# connections of heat pump
c0 = Connection(evaporator, 'out2', compressor, 'in1', label= 'Starting point')
c1 = Connection(compressor, 'out1', condenser, 'in1', label= 'Post compression')
c2 = Connection(condenser, "out1", closer, "in1", label= "Post cooling")
c3 = Connection(closer, "out1", pump, "in1", label= "Cycle Closer")
c4 = Connection(pump, "out1", valve, "in1", label= "Post pumping")
c5 = Connection(valve, "out1", evaporator, "in2", label= "Post expantion")
c10 = Connection(ambIn1, "out1", condenser, "in2", label= "Cold air 1 cold")
c11 = Connection(condenser, "out2", ambOut1, "in1", label= "Cold air 1 hot")
c20 = Connection(ambIn2, "out1", evaporator, "in1", label= "Cold air 2 cold")
c21 = Connection(evaporator, "out1", ambOut2, "in1", label= "Cold air 2 hot")
heatPump.add_conns(c0, c1, c2, c3, c4, c5, c10, c11, c20, c21)
wf = "R1234yf"
massRateWF = 0.04
T_wf_in = -23
pressureIn = 1e5
pressureOut = 8e5
h0 = PSI("H", "P", pressureIn, "T", 273.15 + T_wf_in, wf) / 1000
fluidCheck = PSI("T", "P", pressureIn, "Q", 1, wf) - 273.15
T_exterior = -20
coolingHeated = 20
coolingVolumeRate = 500 / 3600 #m3/s
coolingFluid = "Air"
coolingDensity = PSI("D", "T", 273.15 + T_exterior, "P", 1.01325e5, coolingFluid)
massRateCooling = coolingVolumeRate * coolingDensity
if T_wf_in <= fluidCheck:
print("Existência de líquido / mistura bifásica no compressor. Aumente a temperatura de entrada.")
else:
condenserPressureLossRatioHot = 0.95
evaporatorPressureLossRatioHot = 0.95
efficiencyCompressor = 0.85
efficiencyPump = 0.65
condenser.set_attr(pr1 = condenserPressureLossRatioHot, pr2 = 1, design=["pr1"], offdesign=["zeta1", "kA_char"])
compressor.set_attr(eta_s = efficiencyCompressor, pr = pressureOut / pressureIn, design=["eta_s"], offdesign=["eta_s_char"])
evaporator.set_attr(pr1 = evaporatorPressureLossRatioHot, design=["pr1"], offdesign=["zeta1", "kA_char"])
pump.set_attr(eta_s = efficiencyPump)
valve.set_attr(pr = pressureIn / pressureOut)
c0.set_attr(fluid={wf: 1}, m = massRateWF, h = h0, p = pressureIn)
c4.set_attr(p = pressureOut)
c10.set_attr(fluid={coolingFluid: 1}, m = massRateCooling, p = 1e5, T = T_exterior)
c11.set_attr(T = coolingHeated)
c20.set_attr(fluid={coolingFluid: 1}, m = massRateCooling * 10, p = 1e5, T = T_exterior)
heatPump.solve(mode='design')
heatPump.save('hp_design')
heatPump.print_results()
print(f'COP = {abs(condenser.Q.val) / compressor.P.val}')
for m in np.linspace(0.005, 0.04, 21):
c0.set_attr(m=m)
heatPump.solve(mode='offdesign', design_path='hp_design', max_iter=200)
print(f'COP = {abs(condenser.Q.val) / compressor.P.val}') |
Beta Was this translation helpful? Give feedback.
-
Hi,
Been trying to learn TESPy (also getting introduced to Python itself) and tried building a heat pump model. Sadly, over the span of multiple tries, i havent been able to get rid of the following error
Singularity in jacobian matrix, calculation aborted! Make sure your network does not have any linear dependencies in the parametrisation. Other reasons might be
-> given temperature with given pressure in two phase region, try setting enthalpy instead or provide accurate starting value for pressure.
-> given logarithmic temperature differences or kA-values for heat exchangers,
-> support better starting values.
-> bad starting value for fuel mass flow of combustion chamber, provide small (near to zero, but not zero) starting value.
From what I ve read, it probably is an issue concerning linear dependencies or two phase region due to the expantion valve.
I ll leave my code bellow as well as an image of the cycle i ve been trying to implemet in my latest attempt, in case its useful.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions