Skip to content

Commit

Permalink
Merge pull request #684 from retoflow/bugfix/q_zero_problem
Browse files Browse the repository at this point in the history
bugfix qzero problem
  • Loading branch information
SimonRubenDrauz authored Jan 8, 2025
2 parents 81cbe7b + 1b17076 commit dc86acc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/pandapipes/component_models/heat_consumer_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def create_pit_branch_entries(cls, net, branch_pit):
hc_pit[:, FLOW_RETURN_CONNECT] = True
mask_q0 = qext == 0 & np.isnan(mdot)
if np.any(mask_q0):
hc_pit[mask_q0, ACTIVE] = False
logger.warning(r'qext_w is equals to zero for heat consumers with index %s. '
r'Therefore, the defined temperature control cannot be maintained.' \
%net[cls.table_name()].index[mask_q0])
Expand Down Expand Up @@ -170,10 +169,12 @@ def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_loo
t_out = hc_pit[:, TOUTINIT]

df_dm = - cp * (t_out - t_in)
hc_pit[mask, LOAD_VEC_BRANCHES] = - hc_pit[mask, QEXT] + df_dm[mask] * hc_pit[mask, MDOTINIT]
mask_equal = t_out == t_in
hc_pit[mask & mask_equal, MDOTINIT] = 0
hc_pit[mask & ~mask_equal, JAC_DERIV_DM] = df_dm[mask & ~mask_equal]
mask_zero = hc_pit[:, QEXT] == 0
mask_ign = mask_equal | mask_zero
hc_pit[mask & mask_ign, MDOTINIT] = 0
hc_pit[mask & ~mask_ign, JAC_DERIV_DM] = df_dm[mask & ~mask_ign]
hc_pit[mask, LOAD_VEC_BRANCHES] = - hc_pit[mask, QEXT] + df_dm[mask] * hc_pit[mask, MDOTINIT]

@classmethod
def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options):
Expand Down Expand Up @@ -201,9 +202,10 @@ def adaption_after_derivatives_thermal(cls, net, branch_pit, node_pit, idx_looku
hc_pit = branch_pit[f:t, :]
consumer_array = get_component_array(net, cls.table_name(), mode='heat_transfer')

# Any MODE where TRETURN is given
mask = consumer_array[:, cls.MODE] == cls.QE_TR
mask= consumer_array[:, cls.MODE] == cls.QE_TR
if np.any(mask):
mask_ign = hc_pit[:, QEXT] == 0
mask = mask & ~mask_ign
hc_pit[mask, LOAD_VEC_BRANCHES_T] = 0
hc_pit[mask, JAC_DERIV_DTOUT] = 1
hc_pit[mask, JAC_DERIV_DT] = 0
Expand Down

0 comments on commit dc86acc

Please sign in to comment.