-
First, thank you for the effort of creating TESpy -- it looks like a great tool. I am trying model closed-cycle networks with gaseous CO2 as the working fluid. Per the advice in the documentation to "set up your system step by step", I've started with a simple model: A compressor circulates CO2 through a heat exchanger and the heat exchanger dissipates the compressor's pressure rise and rejects heat from the compressor work. The network also includes a When solving the model, I expect the pressures on either side of the Interestingly, this error only occurs with CO2, and goes away if I change the fluid to another gas. I would like help figuring out what is wrong with this model. Have I not properly initialized the component and connection attributes? Am I using the Here is the script: from tespy.components import CycleCloser, Compressor, HeatExchangerSimple
from tespy.connections import Connection
from tespy.networks import Network
from CoolProp.CoolProp import PropsSI
# Build the network
# -----------------
# Diagram of components and connections:
#
# +------------+
# ↑ |
# ▷ |
# / ↑ ↓
# compressor +-*--+--\/\/\-+
# / \ \ \ \
# c1 \ c0 \ c2
# \ cooler
# cycle closer
#
# The error only occurs if the fluid is CO2. With N2, NH3, He or Ar the solver converges, and
# pressure c0 == pressure c1 == 4.0 bar.
fluid = "CO2"
nw = Network(fluids=[fluid], p_unit="bar", T_unit="K", m_unit="g / s")
# Components
closer = CycleCloser("cycle closer")
compressor = Compressor("compressor")
cooler = HeatExchangerSimple("cooler")
# Connections
c0 = Connection(cooler, "out1", closer, "in1", label="0")
c1 = Connection(closer, "out1", compressor, "in1", label="1")
c2 = Connection(compressor, "out1", cooler, "in1", label="2")
connections = [c0, c1, c2]
nw.add_conns(*connections)
# Set attributes
# --------------
compressor.set_attr(eta_s=0.80)
c1.set_attr(fluid={fluid: 1.0})
# Cooler outlet conditions
p_cooler_bar = 4.0 # [bar] cooler outlet pressure
T_cooler = 273.15 + 35.0 # [K] cooler outlet temperature
h_cooler = PropsSI("H", "P", 1e5 * p_cooler_bar, "T", T_cooler, fluid) # [J/kg] cooler outlet enthalpy
c1.set_attr(p=p_cooler_bar, h=h_cooler)
# Compressor outlet conditions
p_comp_bar = 10.0 # [bar] compressor outlet pressure
c2.set_attr(p=p_comp_bar)
cooler.set_attr(Q=-1e3)
# If I size the system by mass flow, instead of power, the same error still happens.
# c1.set_attr(m=1.0)
# Guess starting values to help the solver
# ----------------------------------------
# Setting initial values for the fluid around the loop does not help.
# for c in connections:
# c.set_attr(fluid0={fluid: 1.0})
# Setting initial values for p,h on the other side of the CycleCloser does not help.
# c0.set_attr(p0=p_cooler_bar, h0=h_cooler)
# Solve
# -----
nw.solve("design")
nw.print_results() And here is the output (using python 3.11.1, tespy 0.6.2):
Note that the pressure at c0 is 5.180 bar, whereas the pressure at c1 is 4.0 bar. I would expect the pressure at both c0 and c1 to be 4.0 bar. I noticed that the warning message says "This frequently happens, if the solver pushes the fluid properties out of their feasible range." However, the returned pressure and temperature range (4-15 bar, 308-431 K) are well within the "feasible range" for gaseous CO2. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Dear @mvernacc, thank you for reaching out and sharing your code snippet, I hope you can make use of the software! To your issue: It looks like CoolProp only supports pressure higher than triple point pressure for CO2 (also see http://www.coolprop.org/fluid_properties/fluids/CarbonDioxide.html#fluid-carbondioxide and http://www.coolprop.org/_downloads/9a4fdd673eb02b49856d14485b27e6e9/CarbonDioxide.pdf): >>> print(PropsSI("P_min", "CO2")) # minimum possible pressure in CoolProp in Pa
517964.34344772575 If you specify a higher pressure than that value at the compressor's inlet, the problem can be solved. To also quickly answer some of your questions:
The outcome of the equations (not necessarily all of them) applied by the different components will be wrong, if the solver fails to converge. That is why you see the pressure differences. TESPy does not allow the pressure to be lower than the CoolProp provided minimum pressure. Since the pressure c0 will be a result of the equation of the
Overall looks very good, one small hints for your models: Starting values for fluid composition are rarely required. With single fluid networks you do not need any actually. In case some connections miss a starting value for the fluid composition, a warning should be printed in the preprocessing. Then you can make use of Have a nice sunny weekend! Best Francesco |
Beta Was this translation helpful? Give feedback.
Hmm, I was a bit too quick here...
It does not really make sense, that CoolProp does not offer pressure below that value, we have often used models, where CO2 is in a mixture with the other ambient air components or combustion products. There the partial pressure would be much lower than that value.
TESPy reads value boundaries for pressure and temperature from CoolProp in order to make sure, no fluid properties are accessed outside of CoolProp's ranges as that would raise errors. You can circumvent that issue for now by adding the following lines: