Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pipe standard type 'heating pipe' #569

Closed
wants to merge 14 commits into from
Closed
12 changes: 8 additions & 4 deletions pandapipes/component_models/pipe_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,18 @@ def create_pit_branch_entries(cls, net, branch_pit):
internal_pipe_number, has_internals)
set_entry_check_repeat(
pipe_pit, K, net[tbl].k_mm.values / 1000, internal_pipe_number, has_internals)

set_entry_check_repeat(
pipe_pit, ALPHA, net[tbl].alpha_w_per_m2k.values, internal_pipe_number, has_internals)
pipe_pit, ALPHA, net[tbl].u_w_per_m2k.values, internal_pipe_number, has_internals)

set_entry_check_repeat(
pipe_pit, QEXT, net[tbl].qext_w.values, internal_pipe_number, has_internals)
set_entry_check_repeat(
pipe_pit, TEXT, net[tbl].text_k.values, internal_pipe_number, has_internals)

set_entry_check_repeat(
pipe_pit, D, net[tbl].diameter_m.values, internal_pipe_number, has_internals)
pipe_pit, D, net[tbl].diameter_mm.values / 1000, internal_pipe_number, has_internals)

set_entry_check_repeat(
pipe_pit, LC, net[tbl].loss_coefficient.values, internal_pipe_number, has_internals)

Expand Down Expand Up @@ -307,10 +311,10 @@ def get_component_input(cls):
("to_junction", "u4"),
("std_type", dtype(object)),
("length_km", "f8"),
("diameter_m", "f8"),
("diameter_mm", "f8"),
("k_mm", "f8"),
("loss_coefficient", "f8"),
("alpha_w_per_m2k", 'f8'),
("u_w_per_m2k", 'f8'),
("text_k", 'f8'),
("qext_w", 'f8'),
("sections", "u4"),
Expand Down
29 changes: 14 additions & 15 deletions pandapipes/converter/stanet/table_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def create_valve_and_pipe(net, stored_data, index_mapping, net_params, stanet_li
if stanet_like_valves:
create_valve_pipe_from_parameters(
net, node_mapping[from_stanet_nr], node_mapping[to_stanet_nr],
length_km=row.RORL / 1000, diameter_m=float(row.DM / 1000), k_mm=row.RAU,
length_km=row.RORL / 1000, diameter_mm=float(row.DM), k_mm=row.RAU,
opened=row.AUF == 'J', loss_coefficient=row.ZETA,
name="valve_pipe_%s_%s" % (row.ANFNAM, row.ENDNAM), in_service=bool(row.ISACTIVE),
stanet_nr=int(row.RECNO), stanet_id=str(row.STANETID), v_stanet=row.VM, **add_info
Expand All @@ -156,16 +156,15 @@ def create_valve_and_pipe(net, stored_data, index_mapping, net_params, stanet_li
text_k = 293
if hasattr(row, "TU"):
text_k = row.TU + 273.15
pandapipes.create_pipe_from_parameters(
net, node_mapping[from_stanet_nr], j_aux, length_km=row.RORL / 1000,
diameter_m=float(row.DM / 1000), k_mm=row.RAU, loss_coefficient=row.ZETA,
name="pipe_%s_%s" % (str(row.ANFNAM), 'aux_' + str(row.ENDNAM)),
text_k=text_k, in_service=bool(row.ISACTIVE), stanet_nr=-999,
stanet_id='pipe_valve_' + str(row.STANETID), v_stanet=row.VM,
stanet_active=bool(row.ISACTIVE), stanet_valid=False, **add_info
)
pandapipes.create_pipe_from_parameters(net, node_mapping[from_stanet_nr], j_aux, length_km=row.RORL / 1000,
diameter_mm=float(row.DM), k_mm=row.RAU, loss_coefficient=row.ZETA,
text_k=text_k,
name="pipe_%s_%s" % (str(row.ANFNAM), 'aux_' + str(row.ENDNAM)),
in_service=bool(row.ISACTIVE), stanet_nr=-999,
stanet_id='pipe_valve_' + str(row.STANETID), v_stanet=row.VM,
stanet_active=bool(row.ISACTIVE), stanet_valid=False, **add_info)
pandapipes.create_valve(
net, j_aux, node_mapping[to_stanet_nr], diameter_m=float(row.DM / 1000),
net, j_aux, node_mapping[to_stanet_nr], diameter_mm=float(row.DM),
opened=row.AUF == 'J', loss_coefficient=0,
name="valve_%s_%s" % ('aux_' + str(row.ENDNAM), str(row.ENDNAM)),
stanet_nr=int(row.RECNO), stanet_id=str(row.STANETID), v_stanet=np.NaN,
Expand Down Expand Up @@ -222,7 +221,7 @@ def create_slider_valves(net, stored_data, index_mapping, add_layers):
f"The diameter will be set to 1 m.")
slider_valves.DM[slider_valves.DM == 0] = 1e3
pandapipes.create_valves(
net, from_junctions, to_junctions, slider_valves.DM.values / 1000,
net, from_junctions, to_junctions, slider_valves.DM.values,
opened=slider_valves.TYP.astype(np.int32).replace(opened_types).values,
loss_coefficient=slider_valves.ZETA.values, name=slider_valves.STANETID.values,
type="slider_valve_" + valve_system, stanet_nr=slider_valves.RECNO.values.astype(np.int32),
Expand Down Expand Up @@ -568,7 +567,7 @@ def create_geodata_sections(row):
text_k = pipes.TU.values.astype(np.float64) + 273.15
pandapipes.create_pipes_from_parameters(
net, pipe_sections.fj.values, pipe_sections.tj.values, pipe_sections.length.values / 1000,
pipes.DM.values / 1000, pipes.RAU.values, pipes.ZETA.values, type="main_pipe",
pipes.DM.values, pipes.RAU.values, pipes.ZETA.values, type="main_pipe",
stanet_std_type=pipes.ROHRTYP.values, in_service=pipes.ISACTIVE.values, text_k=text_k,
alpha_w_per_m2k=pipes.WDZAHL.values.astype(np.float64),
name=["pipe_%s_%s_%s" % (nf, nt, sec) for nf, nt, sec in zip(
Expand Down Expand Up @@ -631,7 +630,7 @@ def create_heat_exchangers_stanet(net, stored_data, index_mapping, add_layers, a
# TODO: there is no qext given!!!
pandapipes.create_heat_exchanger(
net, node_mapping[from_stanet_nr], node_mapping[to_stanet_nr], qext_w=qext,
diameter_m=float(row.DM / 1000), loss_coefficient=row.ZETA, std_type=row.ROHRTYP,
diameter_mm=float(row.DM), loss_coefficient=row.ZETA, std_type=row.ROHRTYP,
in_service=bool(row.ISACTIVE), name="heat_exchanger_%s_%s" % (row.ANFNAM, row.ENDNAM),
stanet_nr=int(row.RECNO), stanet_id=str(row.STANETID), v_stanet=row.VM,
stanet_active=bool(row.ISACTIVE), **add_info
Expand Down Expand Up @@ -696,7 +695,7 @@ def create_pipes_from_remaining_pipe_table(net, stored_data, connection_table, i
text_k = p_tbl.TU.values.astype(np.float64) + 273.15
pandapipes.create_pipes_from_parameters(
net, from_junctions, to_junctions, length_km=p_tbl.RORL.values.astype(np.float64) / 1000,
type="main_pipe", diameter_m=p_tbl.DM.values.astype(np.float64) / 1000,
type="main_pipe", diameter_mm=p_tbl.DM.values.astype(np.float64),
loss_coefficient=p_tbl.ZETA.values, stanet_std_type=p_tbl.ROHRTYP.values,
k_mm=p_tbl.RAU.values, in_service=p_tbl.ISACTIVE.values.astype(np.bool_),
alpha_w_per_m2k=p_tbl.WDZAHL.values.astype(np.float64), text_k=text_k,
Expand Down Expand Up @@ -1011,7 +1010,7 @@ def create_geodata_sections(row):
text_k = hp_data.TU.values.astype(np.float64) + 273.15
pandapipes.create_pipes_from_parameters(
net, hp_data.fj.values, hp_data.tj.values, hp_data.length.values / 1000,
hp_data.DM.values / 1000, hp_data.RAU.values, hp_data.ZETA.values, type="house_pipe",
hp_data.DM.values, hp_data.RAU.values, hp_data.ZETA.values, type="house_pipe",
stanet_std_type=hp_data.ROHRTYP.values,
in_service=hp_data.ISACTIVE.values if houses_in_calculation else False, text_k=text_k,
alpha_w_per_m2k=hp_data.WDZAHL.values.astype(np.float64),
Expand Down
65 changes: 48 additions & 17 deletions pandapipes/create.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2020-2023 by Fraunhofer Institute for Energy Economics
# and Energy System Technology (IEE), Kassel, and University of Kassel. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
import warnings

import numpy as np
import pandas as pd
Expand All @@ -19,6 +20,7 @@
from pandapipes.std_types.std_type_class import regression_function, PumpStdType
from pandapipes.std_types.std_types import add_basic_std_types, create_pump_std_type, \
load_std_type
#from pandapipes.toolbox import calculate_alpha

try:
import pandaplan.core.pplog as logging
Expand Down Expand Up @@ -377,7 +379,7 @@ def create_heat_exchanger(net, from_junction, to_junction, diameter_m, qext_w, l


def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2, loss_coefficient=0,
sections=1, alpha_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None,
sections=1, text_k=293, qext_w=0., name=None, index=None,
geodata=None, in_service=True, type="pipe", **kwargs):
"""
Creates a pipe element in net["pipe"] from pipe parameters.
Expand All @@ -400,8 +402,6 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2,
:param sections: The number of internal pipe sections. Important for gas and temperature\
calculations, where variables are dependent on pipe length.
:type sections: int, default 1
:param alpha_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)]
:type alpha_w_per_m2k: float, default 0
:param text_k: Ambient temperature of pipe in [K]
:type text_k: float, default 293
:param qext_w: External heat feed-in to the pipe in [W]
Expand Down Expand Up @@ -436,10 +436,20 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2,
_check_std_type(net, std_type, "pipe", "create_pipe")

pipe_parameter = load_std_type(net, std_type, "pipe")

# # Check if alpha parameter was declared (Alpha has been changed to U)
# if 'alpha_w_per_m2k' in kwargs:
# if pipe_parameter['u_w_per_m2k']:
# pipe_parameter['u_w_per_m2k'] = kwargs['alpha_w_per_m2k']
# raise UserWarning('You have defined alpha and u by chosing a standard type, '
# 'which both describe the heat transfer coefficient. '
# 'Alpha will overwrite the u value of the std type.')
# raise DeprecationWarning('alpha_w_per_m2k will be renamed to u_w_per_m2k in the future.')

v = {"name": name, "from_junction": from_junction, "to_junction": to_junction,
"std_type": std_type, "length_km": length_km,
"diameter_m": pipe_parameter["inner_diameter_mm"] / 1000, "k_mm": k_mm,
"loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k,
"diameter_mm": pipe_parameter["inner_diameter_mm"] , "k_mm": k_mm,
"loss_coefficient": loss_coefficient, "u_w_per_m2k": pipe_parameter['u_w_per_m2k'],
"sections": sections, "in_service": bool(in_service), "type": type, "qext_w": qext_w,
"text_k": text_k}
_set_entries(net, "pipe", index, **v, **kwargs)
Expand All @@ -450,10 +460,9 @@ def create_pipe(net, from_junction, to_junction, std_type, length_km, k_mm=0.2,
return index


def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diameter_m, k_mm=0.2,
loss_coefficient=0, sections=1, alpha_w_per_m2k=0., text_k=293,
qext_w=0., name=None, index=None, geodata=None, in_service=True,
type="pipe", **kwargs):
def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diameter_mm=0, k_mm=0.2, loss_coefficient=0,
sections=1, u_w_per_m2k=0., text_k=293, qext_w=0., name=None, index=None, geodata=None,
in_service=True, type="pipe", **kwargs):
"""
Creates a pipe element in net["pipe"] from pipe parameters.

Expand All @@ -465,8 +474,8 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam
:type to_junction: int
:param length_km: Length of the pipe in [km]
:type length_km: float
:param diameter_m: The pipe diameter in [m]
:type diameter_m: float
:param diameter_mm: The pipe diameter in [mm]
:type diameter_mm: float
:param k_mm: Pipe roughness in [mm]. 0.2 mm is quite rough, usually betweeen 0.0015 (new
pipes) and 0.3 (old steel pipelines)
:type k_mm: float, default 0.2
Expand All @@ -475,8 +484,8 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam
:param sections: The number of internal pipe sections. Important for gas and temperature\
calculations, where variables are dependent on pipe length.
:type sections: int, default 1
:param alpha_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)]
:type alpha_w_per_m2k: float, default 0
:param u_w_per_m2k: Heat transfer coefficient in [W/(m^2*K)]
:type u_w_per_m2k: float, default 0
:param qext_w: external heat feed-in to the pipe in [W]
:type qext_w: float, default 0
:param text_k: Ambient temperature of pipe in [K]
Expand All @@ -500,8 +509,7 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam
:rtype: int

:Example:
>>> create_pipe_from_parameters(net, from_junction=0, to_junction=1,
>>> length_km=1, diameter_m=40e-3)
>>> create_pipe_from_parameters(net, from_junction=0, to_junction=1, length_km=1, diameter_mm=40)

"""
add_new_component(net, Pipe)
Expand All @@ -510,10 +518,33 @@ def create_pipe_from_parameters(net, from_junction, to_junction, length_km, diam
_check_branch(net, "Pipe", index, from_junction, to_junction)

v = {"name": name, "from_junction": from_junction, "to_junction": to_junction,
"std_type": None, "length_km": length_km, "diameter_m": diameter_m, "k_mm": k_mm,
"loss_coefficient": loss_coefficient, "alpha_w_per_m2k": alpha_w_per_m2k,
"std_type": None, "length_km": length_km, "diameter_mm": diameter_mm, "k_mm": k_mm,
"loss_coefficient": loss_coefficient, "u_w_per_m2k": u_w_per_m2k,
"sections": sections, "in_service": bool(in_service),
"type": type, "qext_w": qext_w, "text_k": text_k}
#Check if alpha parameter was declared (Alpha has been changed to U)
if 'alpha_w_per_m2k' in kwargs:
if u_w_per_m2k:

raise UserWarning('you have defined u and alpha which represent both the heat transfer coefficient.'
' In the future alpha will be renamed to u.'
' Please define only one variable for the heat transfer coefficient. '
'u will be overwritten by alpha')
else:
raise DeprecationWarning('alpha_w_per_m2k will be renamed to u_w_per_m2k in the future.')

# Check if diameter was declared in right dimension(m has been changed to mm)
if 'diameter_m' in kwargs:
if diameter_mm!=0:
warnings.warn('you have defined the diameter twice(mm and m).'
' In the future diameter_m will be renamed to diameter_mm.'
'diameter_m will be overwritten by diameter_mm')

else:
v['diameter_mm'] = kwargs['diameter_m']*1000
warnings.warn(' In the future diameter_m will be renamed to diameter_mm.'
'diameter_mm will be overwritten by diameter_m')
kwargs.pop('diameter_m')
if 'std_type' in kwargs:
raise UserWarning('you have defined a std_type, however, using this function you can only '
'create a pipe setting specific, individual parameters. If you want to '
Expand Down
5 changes: 5 additions & 0 deletions pandapipes/io/convert_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ def _rename_columns(net):
else:
net['controller'].drop('controller', inplace=True, axis=1)
net["controller"].rename(columns={"controller": "object"}, inplace=True)
if "pipe" in net:
if "u_w_per_m2k" not in net["pipe"]:
net["pipe"].rename(columns={"alpha_w_per_m2k": "u_w_per_m2k"}, inplace=True)
if "diameter_mm" not in net["pipe"]:
net["pipe"].rename(columns={"diameter_m": "diameter_mm"}, inplace=True)
for comp in [CirculationPumpMass, CirculationPumpPressure]:
cp_tbl = comp.table_name()
if cp_tbl in net:
Expand Down
Loading
Loading