Replies: 1 comment
-
Hi! You are doing quite a lot of steps at the same time here, I would recommend you go step by step, i.e. build the heat pump, then add the other streams bit by bit. The from tespy.networks import Network
from tespy.components import Sink, Source, Separator
from tespy.connections import Connection
from tespy.tools.helpers import UserDefinedEquation
class HumidAirSeparator(Separator):
"""This component ignores the temperature equality constraint"""
def get_mandatory_constraints(self):
constraints = super().get_mandatory_constraints()
return {c: data for c, data in constraints.items() if c != "energy_balance_constraints"}
nw = Network(T_unit="C",p_unit="bar",h_unit="J / kg",m_unit = "kg / s")
air_inlet = Source("air in")
air_outlet = Sink("air out")
condensate_outlet = Sink("condensate")
separator = HumidAirSeparator("condensate separator")
c12 = Connection(air_inlet, "out1", separator, "in1", label="12")
c13 = Connection(separator, "out1", air_outlet, "in1", label="13")
c14 = Connection(separator, "out2", condensate_outlet, "in1", label="14")
nw.add_conns(c12, c13, c14)
c12.set_attr(fluid={"air": 0.9, "water": 0.1}, p=1, T=40, m=20)
c13.set_attr(fluid={"water": 1, "air": 0}, T=40)
c14.set_attr(T=40)
from tespy.tools.fluid_properties.mixtures import cond_check
def condansate_mass_flow(ude):
cin, cout = ude.conns
_, _, mass_fraction_water_liquid, _ = cond_check(cin.p.val_SI, cin.T.val_SI, cin.fluid_data, "water")
return cin.m.val_SI * mass_fraction_water_liquid - cout.m.val_SI * 1.0001 # partial pressure of water inside humid air cannot be exactly at saturation so we are separating a tiny bit less
def condensate_mass_flow_deriv(ude):
cin, cout = ude.conns
if cin.m.is_var:
_, _, mass_fraction_water_liquid, _ = cond_check(cin.p.val_SI, cin.T.val_SI, cin.fluid_data, "water")
ude.jacobian[cin.m.J_col] = mass_fraction_water_liquid
if cin.p.is_var:
ude.jacobian[cin.p.J_col] = ude.numeric_deriv("p", cin)
if cin.h.is_var:
ude.jacobian[cin.h.J_col] = ude.numeric_deriv("h", cin)
if cout.m.is_var:
ude.jacobian[cout.m.J_col] = -1.0001
condensate_ude = UserDefinedEquation(
"condensate mass flow", condansate_mass_flow, condensate_mass_flow_deriv, [c12, c13]
)
nw.add_ude(condensate_ude)
nw.solve("design")
nw.print_results() Maybe creating a dedicated class for the component could be nice :). Does that help you for now? Have a nice weekend! Best Francesco |
Beta Was this translation helpful? Give feedback.
-
Hello!
In our MSc thesis, we are trying to model the integration of an heatpump to use for drying of sewage sludge and are having trouble to get our inital model to work. See the added picture for our system.
The main idea is that we are using an heat pump to provide the necessary mass flow of air to drive the drying of the sludge and thus, we are treating the entire drying process as a black box. Since we can't figure out how to create moisture in an airstream, we had to figure a possible way to add it in another way.
Due to this, we are utilizing an SimpleHeatExchanger to model the heat demand of the dryer and adding a flow (c9) from source 1, which adds the evaporated water into the outlet stream of air from the SimpleHeatExchanger. Meaning that the heat load gets added with the SimpleHeatExchanger and the evaporated water with c9/source 1, to account for the entire drying process.
Then, we have added a sink for the excess humid air to be removed from the system, sink A.
We have also added a sink for the condensed water to be removed after the evaporator, sink B, which we are doing with a droplet separator.
Finally, we are adding a fresh air intake with source 2, to add outside air into the system with a mixer.
We get the error "Singularity in jacobian matrix, calculation aborted!" after running the code for our system below and would appreciate any help or tips we can get! We suspect that we are confusing our self with the attributes, but after troubleshooting for a while we are stuck.
Thank you in advance for any help!
Kind regards,
Erik & Erik
Beta Was this translation helpful? Give feedback.
All reactions