Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonRubenDrauz authored Nov 17, 2023
2 parents b2652d8 + d5d25ae commit e2e4118
Show file tree
Hide file tree
Showing 46 changed files with 632 additions and 478 deletions.
9 changes: 9 additions & 0 deletions doc/source/fluid_properties/composition.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;**Biomethane pure**;**Biomethane treated**
methane; 96.15% ; 90.94%
nitrogen; 0.75 % ;0.69 %
carbon dioxide; 2.9 % ;2.68 %
oxygen; 0.2 % ; 0.19 %
propane; 0 % ; 5 %
butane; 0 %; 0.5 %
Wobbe-Index (normal conditions) :math:`[\frac{KWh}{m^3}]` ; 13.9 ; 14.9
HHV (normal conditions) :math:`[\frac{KWh}{m^3}]`; 10.6 ; 11.6
12 changes: 10 additions & 2 deletions doc/source/fluid_properties/create_fluids.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ Fluid from Library
==================

In the fluid library some default fluids are already implemented. Currently it is
possible to work with the default fluids high and low calorific natural
gas (hgas and lgas), hydrogen, methane, water and air. The values are loaded from txt-files in
possible to work with the default fluids:

- ``hgas`` and ``lgas`` (high and low calorific natural gas),
- ``hydrogen``,
- ``methane``,
- ``water``,
- ``biomethane_pure`` and ``biomathane_treated`` (see `here <https://pandapipes.readthedocs.io/en/latest/fluid_properties/fluids.html>`_ for the compositions),
- ``air``.

The values are loaded from txt-files in
the 'pandapipes/properties/[fluid name]' folder.
One of these default fluids can be created and added to an
existing network by calling the following function.
Expand Down
24 changes: 22 additions & 2 deletions doc/source/fluid_properties/fluids.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,29 @@ Fluid Properties in pandapipes

The pipelines in the pandapipes network are run with a certain fluid. This can be
chosen individually for the net from the fluid library or by own creation. The fluids
are defined by certain properties. In the fluid library currently high and low calorific natural
gas (hgas and lgas), hydrogen, methane, water and air are implemented with default properties.
are defined by certain properties.

The following fluids currently exist in the library:

- ``hgas`` and ``lgas`` (high and low calorific natural gas),
- ``hydrogen``,
- ``methane``,
- ``water``,
- ``biomethane_pure`` and ``biomathane_treated`` (compositions below)
- ``air``.


.. Note::
**Biomethane(s)**:
A particularity of injecting biomethane in the gas grid in Germany is the addition of LPG to enhance
the Wobbe-Index and the heating value of the gas and thus make it equivalent to the (high-calorific) natural gas transported
in the grid. This addition is done in a gas treatment unit (Biogaseinspeiseanlage) upstream of the biomethane
feed-in junction. The properties of the biomethane(s) were computed based on the package `CoolProp <http://www.coolprop.org/)>`_.

.. csv-table::
:file: composition.csv
:delim: ;
:widths: 10, 10, 10

The Fluid Class
===============
Expand Down
46 changes: 9 additions & 37 deletions pandapipes/component_models/abstract_models/base_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ def adaption_before_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lo
def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lookups, options):
pass

@classmethod
def adaption_before_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options):
pass

@classmethod
def adaption_after_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options):
pass


@classmethod
def create_node_lookups(cls, net, ft_lookups, table_lookup, idx_lookups, current_start,
current_table, internal_nodes_lookup):
Expand Down Expand Up @@ -166,40 +175,3 @@ def create_pit_branch_entries(cls, net, branch_pit):
"""
pass

@classmethod
def calculate_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lookups, options):
"""
Function which creates derivatives.
:param net: The pandapipes network
:type net: pandapipesNet
:param branch_pit:
:type branch_pit:
:param node_pit:
:type node_pit:
:param idx_lookups:
:type idx_lookups:
:param options:
:type options:
:return: No Output.
"""
pass

@classmethod
def calculate_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options):
"""
Function which creates derivatives.
:param net: The pandapipes network
:type net: pandapipesNet
:param branch_pit:
:type branch_pit:
:param node_pit:
:type node_pit:
:param idx_lookups:
:type idx_lookups:
:param options:
:type options:
:return: No Output.
"""
pass
69 changes: 1 addition & 68 deletions pandapipes/component_models/abstract_models/branch_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import numpy as np

from pandapipes.component_models.abstract_models.base_component import Component
from pandapipes.idx_branch import LENGTH, D, AREA, RHO, VINIT, ALPHA, QEXT, TEXT, branch_cols, \
T_OUT, CP, VINIT_T, FROM_NODE_T, TL, \
JAC_DERIV_DT, JAC_DERIV_DT1, JAC_DERIV_DT_NODE, LOAD_VEC_BRANCHES_T, LOAD_VEC_NODES_T
from pandapipes.idx_node import TINIT as TINIT_NODE
from pandapipes.idx_branch import VINIT, branch_cols
from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup

try:
Expand Down Expand Up @@ -94,70 +91,6 @@ def create_pit_branch_entries(cls, net, branch_pit):
branch_component_pit[:, VINIT] = 0.1
return branch_component_pit, node_pit, from_nodes, to_nodes

@classmethod
def calculate_derivatives_thermal(cls, net, branch_pit, node_pit, idx_lookups, options):
"""
Function which creates derivatives of the temperature.
:param net:
:type net:
:param branch_pit:
:type branch_pit:
:param node_pit:
:type node_pit:
:param idx_lookups:
:type idx_lookups:
:param options:
:type options:
:return: No Output.
"""
f, t = idx_lookups[cls.table_name()]
branch_component_pit = branch_pit[f:t, :]
cp = branch_component_pit[:, CP]
rho = branch_component_pit[:, RHO]
v_init = branch_component_pit[:, VINIT_T]
from_nodes = branch_component_pit[:, FROM_NODE_T].astype(np.int32)
t_init_i = node_pit[from_nodes, TINIT_NODE]
t_init_i1 = branch_component_pit[:, T_OUT]
t_amb = branch_component_pit[:, TEXT]
area = branch_component_pit[:, AREA]
length = branch_component_pit[:, LENGTH]
alpha = branch_component_pit[:, ALPHA] * np.pi * branch_component_pit[:, D]
cls.calculate_temperature_lift(net, branch_component_pit, node_pit)
tl = branch_component_pit[:, TL]
qext = branch_component_pit[:, QEXT]
t_m = (t_init_i1 + t_init_i) / 2

branch_component_pit[:, LOAD_VEC_BRANCHES_T] = \
-(rho * area * cp * v_init * (-t_init_i + t_init_i1 - tl)
- alpha * (t_amb - t_m) * length + qext)

branch_component_pit[:, JAC_DERIV_DT] = - rho * area * cp * v_init + alpha / 2 * length
branch_component_pit[:, JAC_DERIV_DT1] = rho * area * cp * v_init + alpha / 2 * length

branch_component_pit[:, JAC_DERIV_DT_NODE] = rho * v_init * branch_component_pit[:, AREA]
branch_component_pit[:, LOAD_VEC_NODES_T] = rho * v_init * branch_component_pit[:, AREA] \
* t_init_i1

@classmethod
def adaption_before_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lookups, options):
pass

@classmethod
def calculate_temperature_lift(cls, net, branch_component_pit, node_pit):
"""
:param net:
:type net:
:param branch_component_pit:
:type branch_component_pit:
:param node_pit:
:type node_pit:
:return:
:rtype:
"""
raise NotImplementedError

@classmethod
def extract_results(cls, net, options, branch_results, mode):
raise NotImplementedError
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from pandapipes.component_models.abstract_models.branch_models import BranchComponent
from pandapipes.component_models.component_toolbox import set_entry_check_repeat
from pandapipes.idx_branch import ACTIVE, FROM_NODE, TO_NODE, TINIT, RHO, ETA, CP, ELEMENT_IDX
from pandapipes.idx_branch import ACTIVE, FROM_NODE, TO_NODE, RHO, ETA, CP, ELEMENT_IDX, TOUTINIT
from pandapipes.idx_node import L, node_cols, TINIT as TINIT_NODE
from pandapipes.pf.pipeflow_setup import add_table_lookup, get_lookup, get_table_number
from pandapipes.properties.fluids import get_fluid
Expand Down Expand Up @@ -196,13 +196,12 @@ def create_pit_branch_entries(cls, net, branch_pit):
internal_pipe_number, has_internals)
branch_w_internals_pit[:, FROM_NODE] = from_nodes
branch_w_internals_pit[:, TO_NODE] = to_nodes
branch_w_internals_pit[:, TINIT] = (node_pit[from_nodes, TINIT_NODE] + node_pit[
to_nodes, TINIT_NODE]) / 2
branch_w_internals_pit[:, TOUTINIT] = node_pit[to_nodes, TINIT_NODE]
tm = (node_pit[from_nodes, TINIT_NODE] + branch_w_internals_pit[:, TOUTINIT]) / 2
fluid = get_fluid(net)
branch_w_internals_pit[:, RHO] = fluid.get_density(branch_w_internals_pit[:, TINIT])
branch_w_internals_pit[:, ETA] = fluid.get_viscosity(branch_w_internals_pit[:, TINIT])
branch_w_internals_pit[:, CP] = fluid.get_heat_capacity(branch_w_internals_pit[:, TINIT])

branch_w_internals_pit[:, RHO] = fluid.get_density(tm)
branch_w_internals_pit[:, ETA] = fluid.get_viscosity(tm)
branch_w_internals_pit[:, CP] = fluid.get_heat_capacity(tm)
return branch_w_internals_pit, internal_pipe_number

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pandapipes.component_models.abstract_models.branch_models import BranchComponent

from pandapipes.idx_branch import FROM_NODE, TO_NODE, TINIT, ELEMENT_IDX, RHO, ETA, CP, ACTIVE
from pandapipes.idx_branch import FROM_NODE, TO_NODE, TOUTINIT, ELEMENT_IDX, RHO, ETA, CP, ACTIVE
from pandapipes.idx_node import TINIT as TINIT_NODE

from pandapipes.pf.pipeflow_setup import add_table_lookup
Expand Down Expand Up @@ -82,12 +82,12 @@ def create_pit_branch_entries(cls, net, branch_pit):
branch_wo_internals_pit[:, ELEMENT_IDX] = net[cls.table_name()].index.values
branch_wo_internals_pit[:, FROM_NODE] = from_nodes
branch_wo_internals_pit[:, TO_NODE] = to_nodes
branch_wo_internals_pit[:, TINIT] = (node_pit[from_nodes, TINIT_NODE]
+ node_pit[to_nodes, TINIT_NODE]) / 2
branch_wo_internals_pit[:, TOUTINIT] = node_pit[to_nodes, TINIT_NODE]
tm = (node_pit[from_nodes, TINIT_NODE] + branch_wo_internals_pit[:, TOUTINIT]) / 2
fluid = get_fluid(net)
branch_wo_internals_pit[:, RHO] = fluid.get_density(branch_wo_internals_pit[:, TINIT])
branch_wo_internals_pit[:, ETA] = fluid.get_viscosity(branch_wo_internals_pit[:, TINIT])
branch_wo_internals_pit[:, CP] = fluid.get_heat_capacity(branch_wo_internals_pit[:, TINIT])
branch_wo_internals_pit[:, RHO] = fluid.get_density(tm)
branch_wo_internals_pit[:, ETA] = fluid.get_viscosity(tm)
branch_wo_internals_pit[:, CP] = fluid.get_heat_capacity(tm)
branch_wo_internals_pit[:, ACTIVE] = net[cls.table_name()][cls.active_identifier()].values
return branch_wo_internals_pit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ def create_pit_branch_entries(cls, net, branch_pit):
circ_pump_pit[:, AREA] = circ_pump_pit[:, D] ** 2 * np.pi / 4
circ_pump_pit[:, ACTIVE] = False

@classmethod
def calculate_temperature_lift(cls, net, pipe_pit, node_pit):
raise NotImplementedError

@classmethod
def extract_results(cls, net, options, branch_results, mode):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,3 @@ def create_pit_node_entries(cls, net, node_pit):
index = junction_idx_lookups[juncts]
node_pit[index, LOAD] += loads_sum

@classmethod
def calculate_temperature_lift(cls, net, pipe_pit, node_pit):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,3 @@ def create_pit_node_entries(cls, net, node_pit):
p_in = press - circ_pump.plift_bar.values
set_fixed_node_entries(net, node_pit, junction, circ_pump.type.values, p_in, None,
cls.get_connected_node_type(), "p")

@classmethod
def calculate_temperature_lift(cls, net, pipe_pit, node_pit):
pass
20 changes: 1 addition & 19 deletions pandapipes/component_models/flow_control_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pandapipes.component_models.component_toolbox import \
standard_branch_wo_internals_result_lookup, get_component_array
from pandapipes.component_models.junction_component import Junction
from pandapipes.idx_branch import D, AREA, TL, JAC_DERIV_DP, JAC_DERIV_DP1, JAC_DERIV_DV, VINIT, \
from pandapipes.idx_branch import D, AREA, JAC_DERIV_DP, JAC_DERIV_DP1, JAC_DERIV_DV, VINIT, \
RHO, LOAD_VEC_BRANCHES
from pandapipes.pf.result_extraction import extract_branch_results_without_internals

Expand Down Expand Up @@ -72,9 +72,6 @@ def create_component_array(cls, net, component_pits):
fc_pit[:, cls.CONTROL_ACTIVE] = tbl.control_active.values
component_pits[cls.table_name()] = fc_pit

@classmethod
def adaption_before_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lookups, options):
pass

@classmethod
def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lookups, options):
Expand All @@ -89,21 +86,6 @@ def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_loo
fc_branch_pit[active, JAC_DERIV_DV] = 1
fc_branch_pit[active, LOAD_VEC_BRANCHES] = 0

@classmethod
def calculate_temperature_lift(cls, net, branch_component_pit, node_pit):
"""
:param net:
:type net:
:param branch_component_pit:
:type branch_component_pit:
:param node_pit:
:type node_pit:
:return:
:rtype:
"""
branch_component_pit[:, TL] = 0

@classmethod
def extract_results(cls, net, options, branch_results, mode):
required_results_hyd, required_results_ht = standard_branch_wo_internals_result_lookup(net)
Expand Down
18 changes: 2 additions & 16 deletions pandapipes/component_models/heat_exchanger_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pandapipes.component_models.abstract_models.branch_wzerolength_models import \
BranchWZeroLengthComponent
from pandapipes.component_models.junction_component import Junction
from pandapipes.idx_branch import TL, ALPHA, TEXT, QEXT, T_OUT, D, AREA, LOSS_COEFFICIENT as LC
from pandapipes.idx_branch import ALPHA, TEXT, QEXT, D, AREA, LOSS_COEFFICIENT as LC, TOUTINIT
from pandapipes.pf.pipeflow_setup import get_fluid
from pandapipes.pf.result_extraction import extract_branch_results_without_internals

Expand Down Expand Up @@ -58,7 +58,7 @@ def create_pit_branch_entries(cls, net, branch_pit):
heat_exchanger_pit[:, ALPHA] = 0
heat_exchanger_pit[:, QEXT] = net[cls.table_name()].qext_w.values
heat_exchanger_pit[:, TEXT] = 293.15
heat_exchanger_pit[:, T_OUT] = 307
heat_exchanger_pit[:, TOUTINIT] = 307

@classmethod
def extract_results(cls, net, options, branch_results, mode):
Expand All @@ -81,20 +81,6 @@ def extract_results(cls, net, options, branch_results, mode):
extract_branch_results_without_internals(net, branch_results, required_results_hyd,
required_results_ht, cls.table_name(), mode)

@classmethod
def calculate_temperature_lift(cls, net, branch_component_pit, node_pit):
"""
:param net:
:type net:
:param branch_component_pit:
:type branch_component_pit:
:param node_pit:
:type node_pit:
:return:
:rtype:
"""
branch_component_pit[:, TL] = 0

@classmethod
def get_component_input(cls):
Expand Down
20 changes: 1 addition & 19 deletions pandapipes/component_models/pipe_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pandapipes.component_models.junction_component import Junction
from pandapipes.constants import NORMAL_TEMPERATURE, NORMAL_PRESSURE
from pandapipes.idx_branch import FROM_NODE, TO_NODE, LENGTH, D, AREA, K, \
VINIT, ALPHA, QEXT, TEXT, LOSS_COEFFICIENT as LC, T_OUT, TL
VINIT, ALPHA, QEXT, TEXT, LOSS_COEFFICIENT as LC
from pandapipes.idx_node import PINIT, HEIGHT, TINIT as TINIT_NODE, \
RHO as RHO_NODES, PAMB, ACTIVE as ACTIVE_ND
from pandapipes.pf.pipeflow_setup import get_fluid, get_lookup
Expand Down Expand Up @@ -151,26 +151,8 @@ def create_pit_branch_entries(cls, net, branch_pit):
set_entry_check_repeat(
pipe_pit, LC, net[tbl].loss_coefficient.values, internal_pipe_number, has_internals)

node_pit = net["_pit"]["node"]
to_nodes = pipe_pit[:, TO_NODE].astype(np.int32)
pipe_pit[:, T_OUT] = node_pit[to_nodes, TINIT_NODE]
pipe_pit[:, AREA] = pipe_pit[:, D] ** 2 * np.pi / 4

@classmethod
def calculate_temperature_lift(cls, net, branch_component_pit, node_pit):
"""
:param net:
:type net:
:param branch_component_pit:
:type branch_component_pit:
:param node_pit:
:type node_pit:
:return:
:rtype:
"""
branch_component_pit[:, TL] = 0

@classmethod
def extract_results(cls, net, options, branch_results, mode):
res_nodes_from_hyd = [("p_from_bar", "p_from"), ("mdot_from_kg_per_s", "mf_from")]
Expand Down
Loading

0 comments on commit e2e4118

Please sign in to comment.