Skip to content

Commit

Permalink
add ideal isentropic compression power in Watt to results if fluid.is…
Browse files Browse the repository at this point in the history
…_gas

* for now, kappa is simply assumed as 1.4 -> TODO: add c_v
  • Loading branch information
jkisse committed Feb 5, 2021
1 parent 2a231e0 commit 00bb150
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions pandapipes/component_models/pressure_control_component.py
Expand Up @@ -4,6 +4,8 @@

import numpy as np
from numpy import dtype
from pandapipes.constants import R_UNIVERSAL

from pandapipes.component_models.abstract_models import BranchWZeroLengthComponent, get_fluid, \
TINIT_NODE
from pandapipes.idx_branch import D, AREA, PL, TL, \
Expand Down Expand Up @@ -122,8 +124,9 @@ def extract_results(cls, net, options, node_name):
to_junction_nodes = node_active_idx_lookup[junction_idx_lookup[
net[cls.table_name()]["to_junction"].values[placement_table]]]

res_table['deltap_bar'].values[placement_table] = node_pit[to_junction_nodes, PINIT] - \
node_pit[from_junction_nodes, PINIT]
p_to = node_pit[to_junction_nodes, PINIT]
p_from = node_pit[from_junction_nodes, PINIT]
res_table['deltap_bar'].values[placement_table] = p_to - p_from

from_nodes = pc_pit[:, FROM_NODE].astype(np.int32)
to_nodes = pc_pit[:, TO_NODE].astype(np.int32)
Expand All @@ -140,6 +143,17 @@ def extract_results(cls, net, options, node_name):
res_table["mdot_from_kg_per_s"].values[placement_table] = mf_sum / internal_pipes
res_table["vdot_norm_m3_per_s"].values[placement_table] = vf_sum / internal_pipes

if net.fluid.is_gas:
compr = net.fluid.get_compressibility(t0)
molar_mass = net.fluid.get_molar_mass() # [g/mol]
R_spec = 1e3 * R_UNIVERSAL / molar_mass # [J/(kg * K)]
# 'kappa' heat capacity ratio:
k = 1.4 # TODO: implement proper calculation of kappa
w_real_isentr = (k / (k - 1)) * compr * R_spec * t0 * \
(np.divide(p_to, p_from) ** ((k - 1) / k) - 1)
res_table['id_isentropic_compr_w'].values[placement_table] = \
w_real_isentr * abs(mf_sum / internal_pipes)

@classmethod
def get_component_input(cls):
"""
Expand Down Expand Up @@ -171,4 +185,9 @@ def get_result_table(cls, net):
if False, returns columns as tuples also specifying the dtypes
:rtype: (list, bool)
"""
return ["deltap_bar", "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_norm_m3_per_s"], True
result_columns = ["deltap_bar", "mdot_from_kg_per_s", "mdot_to_kg_per_s",
"vdot_norm_m3_per_s"]
if net.fluid.is_gas:
result_columns += ['id_isentropic_compr_w']

return result_columns, True

0 comments on commit 00bb150

Please sign in to comment.