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

Water Tower Component #107

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
11 changes: 6 additions & 5 deletions pandapipes/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@

import numpy as np
import pandas as pd
from pandapower.auxiliary import get_free_id, _preserve_dtypes

from pandapipes.component_models import Junction, Sink, Source, Pump, Pipe, ExtGrid, \
HeatExchanger, Valve, CirculationPumpPressure, CirculationPumpMass
from pandapipes.component_models.auxiliaries.component_toolbox import add_new_component
from pandapipes.pandapipes_net import pandapipesNet, get_default_pandapipes_structure
from pandapipes.properties import call_lib, add_fluid_to_net
from pandapower.auxiliary import get_free_id, _preserve_dtypes
from pandapipes.properties.fluids import Fluid
from pandapipes.std_types.std_type import PumpStdType, add_basic_std_types, add_pump_std_type, \
load_std_type
from pandapipes.std_types.std_type_toolbox import regression_function
from pandapipes.component_models import Junction, Sink, Source, Pump, Pipe, ExtGrid, \
HeatExchanger, Valve, CirculationPumpPressure, CirculationPumpMass

try:
import pplog as logging
Expand Down Expand Up @@ -823,8 +824,8 @@ def create_circ_pump_const_pressure(net, from_junction, to_junction, p_bar, plif
for b in [from_junction, to_junction]:
if b not in net["junction"].index.values:
raise UserWarning(
"CirculationPumpPressure %s tries to attach to non-existing junction %s"
% (name, b))
"CirculationPumpPressure %s tries to attach to non-existing junction %s"
% (name, b))

if index is None:
index = get_free_id(net["circ_pump_pressure"])
Expand Down
15 changes: 15 additions & 0 deletions pandapipes/create_toolbox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2020 by Fraunhofer Institute for Energy Economics
# and Energy System Technology (IEE), 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 pandapipes as pp
from pandapipes.constants import GRAVITATION_CONSTANT, P_CONVERSION


def transform_water_tower_into_ext_grid(net, junction, height_m, t_k=293.15, name='water_tower', in_service=True,
index=None, type='pt'):
density = net.fluid.get_density([t_k])

p_bar = density * height_m * GRAVITATION_CONSTANT / P_CONVERSION

return pp.create_ext_grid(net, junction, p_bar, t_k, name, in_service, index, type)
45 changes: 45 additions & 0 deletions pandapipes/test/api/test_components/test_water_tower.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright (c) 2020 by Fraunhofer Institute for Energy Economics
# and Energy System Technology (IEE), 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 os
from pandapipes.create_toolbox import transform_water_tower_into_ext_grid

import numpy as np
import pandas as pd

import pandapipes as pp
from pandapipes.test.pipeflow_internals import internals_data_path


def test_water_tower():
"""

:rtype:
"""
net = pp.create_empty_network(fluid="water")

junction1 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, name="Connection to Water Tower")
junction2 = pp.create_junction(net, pn_bar=1.0, tfluid_k=293.15, name="Junction 2")

transform_water_tower_into_ext_grid(net, junction1, height_m=30)

pp.create_pipe_from_parameters(net, from_junction=junction1, to_junction=junction2, length_km=10, diameter_m=0.075,
name="Pipe 1")

pp.create_sink(net, junction=junction2, mdot_kg_per_s=0.545, name="Sink 1")

pp.pipeflow(net, stop_condition="tol", iter=3, friction_model="nikuradse",
mode="hydraulics", transient=False, nonlinear_method="automatic",
tol_p=1e-4, tol_v=1e-4)

data = pd.read_csv(os.path.join(internals_data_path, "test_water_tower.csv"), sep=';')

res_junction = net.res_junction.p_bar.values
res_pipe = net.res_pipe.v_mean_m_per_s.values

p_diff = np.abs(1 - res_junction / data['p'].dropna().values)
v_diff = np.abs(1 - res_pipe / data['v'].dropna().values)

assert np.all(p_diff < 0.01)
assert np.all(v_diff < 0.01)
3 changes: 3 additions & 0 deletions pandapipes/test/pipeflow_internals/data/test_water_tower.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
v;p
0.123588;2.937630
;2.442159