tespy.components.piping package

tespy.components.piping.pipe module

Module of class Pipe.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/piping/pipe.py

SPDX-License-Identifier: MIT

class tespy.components.piping.pipe.Pipe(label, **kwargs)[source]

Bases: SimpleHeatExchanger

The Pipe is a subclass of a SimpleHeatExchanger.

Besides the heat transfer specifications of the SimpleHeatExchanger to calculate Q from UA and Tamb, the heat loss of the pipe can be calculated from information on its insulation and surroundings. There are two options for that, a pipe at the surface and a buried pipe:

  • Surface pipe, Q_ohc_group_surface: forced convection to the ambient air, based on [50].

  • Buried pipe, Q_ohc_group_subsurface: conduction through the subsurface, based on [51].

Both options also need Tamb, insulation_thickness, insulation_tc, pipe_thickness and environment_media, as well as the length L and the diameter D (fixed or "var"). Passing wind_velocity or pipe_depth selects the option, passing both overdetermines the problem. The surface pipe takes the wall conductivity from the material, steel unless specified, or from wall_tc, which overrides the material. The buried pipe neglects the wall.

flowsheet of the pipe flowsheet of the pipe

Ports

  • Fluid inlets: in1

  • Fluid outlets: out1

  • Heat inlets: heat

  • Heat outlets: heat

Mandatory Equations

When a power or heat connector is attached:

Parameters:
  • char_warnings (bool) – Ignore warnings on default characteristics usage for this component.

  • D (float, dict, "var") – Diameter of channel. Quantity: length. Can be set as a system variable by passing "var" as its value.

  • darcy_group (ParameterGroup) – Darcy-Weißbach equation for pressure loss. Elements: L, ks, D. Equation: darcy_func.

  • design (list) – List containing design parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • dissipative (bool) – Description missing.

  • dp (float, dict) – Inlet to outlet absolute pressure change. Quantity: pressure_difference. Equation: dp_structure_matrix.

  • environment_media (str) – Media around the pipe, air for surface pipes, the ground for buried pipes. Options: 'air', 'gravel', 'stones', 'dry soil', 'moist soil'.

  • flow_speed (float, dict) – Flow speed at inlet of pipe. Quantity: speed.

  • flow_speed_group (ParameterGroup) – Equation connecting volumetric flow, flow speed and diameter of pipe. Elements: D, flow_speed. Equation: flow_speed_func.

  • hw_group (ParameterGroup) – Hazen-Williams equation for pressure loss. Elements: L, ks_HW, D. Equation: hazen_williams_func.

  • insulation_tc (float, dict) – Thermal conductivity of insulation. Quantity: thermal_conductivity.

  • insulation_thickness (float, dict) – Thickness of pipe insulation. Quantity: length.

  • ks (float, dict, "var") – Roughness of wall material. Quantity: length. Can be set as a system variable by passing "var" as its value.

  • ks_HW (float, dict, "var") – Hazen-Williams roughness. Can be set as a system variable by passing "var" as its value.

  • L (float, dict, "var") – Length of channel. Quantity: length. Can be set as a system variable by passing "var" as its value.

  • label (str) – The label of the component.

  • lmtd (float, dict) – Effective logarithmic mean temperature difference Q/UA. Quantity: temperature_difference. Result only - calculated after each solve.

  • local_design (bool) – Treat this component in design mode in an offdesign calculation.

  • local_offdesign (bool) – Treat this component in offdesign mode in a design calculation.

  • material (str) – Pipe wall material, not used for buried pipes. Options: 'Steel', 'Carbon Steel', 'Cast Iron', 'Stainless Steel', 'PVC', 'Copper'.

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • pipe_depth (float, dict) – Depth of buried pipe. Quantity: length.

  • pipe_thickness (float, dict) – Wall thickness of pipe. Quantity: length.

  • pr (float, dict) – Outlet to inlet pressure ratio. Quantity: ratio. Equation: pr_structure_matrix.

  • printout (bool) – Include this component in the network’s results printout.

  • Q (float, dict) – Heat transfer. Quantity: heat. Equation: energy_balance_func.

  • Q_ohc_group_subsurface (ParameterGroup) – Equation for heat loss of buried pipes. Elements: insulation_thickness, insulation_tc, Tamb, pipe_thickness, environment_media, pipe_depth. Equation: ohc_subsurface_group_func.

  • Q_ohc_group_surface (ParameterGroup) – Equation for heat loss of surface pipes. Elements: insulation_thickness, insulation_tc, Tamb, pipe_thickness, environment_media, wind_velocity. Optional elements: material, wall_tc. Equation: ohc_surface_group_func.

  • Tamb (float, dict) – Ambient temperature. Quantity: temperature.

  • UA (float, dict, "var") – Heat transfer coefficient considering ambient temperature. Quantity: heat_transfer_coefficient. Can be set as a system variable by passing "var" as its value.

  • UA_char (tespy.tools.characteristics.CharLine, dict) – Heat transfer coefficient lookup table for offdesign.

  • UA_char_group (ParameterGroup) – Heat transfer from design heat transfer coefficient, modifier lookup table and ambient temperature. Elements: UA_char, Tamb. Equation: UA_char_group_func.

  • UA_group (ParameterGroup) – Equation for heat transfer based on ambient temperature and heat transfer coefficient. Elements: UA, Tamb. Equation: UA_group_func.

  • wall_tc (float, dict) – Thermal conductivity of the pipe wall, overrides the value of the material, not used for buried pipes. Quantity: thermal_conductivity.

  • wind_velocity (float, dict) – Velocity of wind at insulation surface. Quantity: speed.

  • zeta_d4 (float, dict) – Geometry-independent friction coefficient zeta/D^4 for pressure loss calculation. Equation: zeta_d4_func.

Example

A mass flow of 10 kg/s hot ethanol is transported in a pipeline. The pipe is considered adiabatic, in the first approach and has a length of 100 meters. We can calculate the diameter required at a given pressure loss of 2.5 %. After we determined the required diameter, we can predict pressure loss at a different mass flow through the pipeline. Afterwards heat losses can be calculated by defining insulation and environment parameters. The heat losses of a subsurface pipe can be compared to heat losses of a surface pipe.

>>> from tespy.components import Sink, Source, Pipe
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> nw = Network(iterinfo=False)
>>> nw.units.set_defaults(**{
...     "pressure": "bar", "pressure_difference": "bar",
...     "temperature": "degC", "enthalpy": "kJ/kg"
... })
>>> so = Source("source 1")
>>> si = Sink("sink 1")
>>> pi = Pipe("pipeline")
>>> pi.set_attr(pr=0.975, Q=0, L=100, D="var", ks=5e-5)
>>> inc = Connection(so, "out1", pi, "in1")
>>> outg = Connection(pi, "out1", si, "in1")
>>> nw.add_conns(inc, outg)
>>> inc.set_attr(fluid={"ethanol": 1}, m=10, T=30, p=3)
>>> nw.solve("design")
>>> round(pi.D.val, 3)
0.119
>>> round(outg.p.val / inc.p.val, 3) == round(pi.pr.val, 3)
True
>>> inc.set_attr(m=15)
>>> pi.set_attr(pr=None)
>>> pi.set_attr(D=pi.D.val)
>>> nw.solve("design")
>>> round(pi.pr.val, 2)
0.94

In the second section the example shows how to calculate the heat losses of the pipe to the ambient considering insulation. For this, we will look at a pipe transporting hot water. Since we change the fluid, we should also give a reasonable guess value for the outflow connection of the pipe as the initial guess originates from the previous calculation using ethanol as fluid.

>>> inc.set_attr(fluid={"water": 1, "ethanol": 0}, T=100)
>>> outg.set_attr(h0=300)
>>> pi.set_attr(
...     D="var", Q=None, pr=0.975,
...     Tamb=0, environment_media="dry soil", pipe_depth=5,
...     insulation_thickness=0.1, insulation_tc=0.035,
...     pipe_thickness=0.003, material="Steel"
... )
>>> nw.solve("design")
>>> round(pi.Q.val, 2)
-1780.74

We can reuse many of the given parameters of the pipe. By unsetting the pipe’s depth and setting the environment media and wind velocity instead the analogous method for surface pipes is applied. Observe, how the overall heat loss increases.

>>> pi.set_attr(
...     pipe_depth=None, environment_media="air", wind_velocity=2.0
... )
>>> nw.solve("design")
>>> round(pi.Q.val, 2)
-2434.13
flow_speed_dependents()[source]
flow_speed_func()[source]

Heat transfer calculation based on pipe material, insulation and surrounding ambient conditions for subsurface pipes.

Returns:

float – Residual value of equation

\[0 = c \cdot \pi \cdot D ^ 2 - \dot m \cdot v_\text{in} * 4\]

get_parameters()[source]
ohc_subsurface_group_dependents()[source]
ohc_subsurface_group_func()[source]

Heat transfer calculation based on pipe material, insulation and surrounding ambient conditions for subsurface pipes.

Returns:

float – Residual value of equation

\[0 = \dot m \cdot \left(h_\text{out}-h_\text{in}\right)- \Delta T_\text{log} \cdot A \cdot U\]

First order approximation of multipole method for a single pipe in the ground.

Reference: [51]

ohc_surface_group_dependents()[source]
ohc_surface_group_func()[source]

Heat transfer calculation based on pipe material, insulation and surrounding ambient conditions fur surface pipes. Valid for forced convection.

Returns:

  • float – Residual value of equation

    \[ \begin{align}\begin{aligned}0 = \dot m \cdot \left(h_\text{out}-h_\text{in}\right)- \Delta T_\text{log} \cdot A \cdot U\\U = R_\text{conductance} + \frac{1}{\alpha_\text{outer}}\\\alpha_\text{outer} = \frac{Nu_\text{l} \cdot \lambda}{l}\\Nu_\text{l}= 0.3 + \sqrt{Nu_\text{l, lam}^{2} + Nu_\text{l, turb}^{2}}\\Nu_\text{l, turb} = \frac{0.037 Re_l^{0.8} \cdot Pr}{1+2.443 \cdot Re_l^{-0.1}\cdot (Pr^{2/3}-1)}\\Nu_\text{l, lam} = 0.664 \sqrt{Re_l}\cdot \sqrt[3]{Pr}\end{aligned}\end{align} \]
  • Reference ([50])

tespy.components.piping.valve module

Module of class Valve.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/piping.py

SPDX-License-Identifier: MIT

class tespy.components.piping.valve.Valve(label, **kwargs)[source]

Bases: Component

The Valve throttles a fluid without changing enthalpy.

flowsheet of the valve flowsheet of the valve

Ports

  • Fluid inlets: in1

  • Fluid outlets: out1

Mandatory Equations

Parameters:
  • char_warnings (bool) – Ignore warnings on default characteristics usage for this component.

  • design (list) – List containing design parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • dp (float, dict) – Inlet to outlet absolute pressure change. Quantity: pressure_difference. Equation: dp_structure_matrix.

  • dp_char (tespy.tools.characteristics.CharLine, dict) – Inlet to outlet absolute pressure change as function of mass flow lookup table. Equation: dp_char_func.

  • Kv (float, dict) – Flow coefficient in m3/h. Equation: Kv_func.

  • Kv_analytical (dict) – Fitting parameters and method for the analytical Kv evaluation provided in a dictionary with keys ‘method’ (callable) and ‘params’ (list).

  • Kv_char (tespy.tools.characteristics.CharLine, dict) – Lookup-table data for flow coefficient as function of opening.

  • Kv_char_analytical_group (ParameterGroup) – Elements: Kv_analytical, opening. Equation: Kv_char_analytical_func.

  • Kv_char_group (ParameterGroup) – Equation for flow coefficient over opening. Elements: Kv_char, opening. Equation: Kv_char_func.

  • label (str) – The label of the component.

  • local_design (bool) – Treat this component in design mode in an offdesign calculation.

  • local_offdesign (bool) – Treat this component in offdesign mode in a design calculation.

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • opening (float, dict, "var") – Opening ratio of the valve. Quantity: ratio. Can be set as a system variable by passing "var" as its value.

  • pr (float, dict) – Outlet to inlet pressure ratio. Quantity: ratio. Equation: pr_structure_matrix.

  • printout (bool) – Include this component in the network’s results printout.

  • zeta_d4 (float, dict) – Geometry-independent friction coefficient zeta/D^4 for pressure loss calculation. Equation: zeta_d4_func.

Example

A mass flow of 1 kg/s methane is throttled from 80 bar to 15 bar in a valve. The inlet temperature is at 50 °C. It is possible to determine the outlet temperature as the throttling does not change enthalpy.

>>> from tespy.components import Sink, Source, Valve
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> nw = Network(iterinfo=False)
>>> nw.units.set_defaults(**{
...     "pressure": "bar", "pressure_difference": "bar",
...     "temperature": "degC"
... })
>>> so = Source('source')
>>> si = Sink('sink')
>>> v = Valve('valve')
>>> so_v = Connection(so, 'out1', v, 'in1')
>>> v_si = Connection(v, 'out1', si, 'in1')
>>> nw.add_conns(so_v, v_si)
>>> v.set_attr(offdesign=['zeta_d4'])
>>> so_v.set_attr(fluid={'CH4': 1}, m=1, T=50, p=80, design=['m'])
>>> v_si.set_attr(p=15)
>>> nw.solve('design')
>>> design_state = nw.save()
>>> round(v_si.T.val, 1)
26.3
>>> round(v.pr.val, 3)
0.188

The simulation determined the area independent zeta_d4 value \(\frac{\zeta}{D^4}\). This value remains constant if the cross sectional area of the valve opening does not change. Using zeta_d4 we can determine the pressure ratio at a different feed pressure.

>>> so_v.set_attr(p=70)
>>> nw.solve('offdesign', design_path=design_state)
>>> round(so_v.m.val, 1)
0.9
>>> round(v_si.T.val, 1)
30.0

You can also specify the flow coefficient of the valve Kv which is used in context of liquids. For this there are several methods available:

  • direct specification with Kv

  • lookup table specification \(Kv=f\left(opening\right)\) with Kv_char and opening

  • arbitrary function specification \(Kv=f\left(opening, params\right)\) with Kv_analytical and opening

>>> nw = Network(iterinfo=False)
>>> nw.units.set_defaults(**{
...     "pressure": "bar", "pressure_difference": "bar",
...     "temperature": "degC"
... })
>>> so = Source('source')
>>> si = Sink('sink')
>>> v = Valve('valve')
>>> so_v = Connection(so, 'out1', v, 'in1')
>>> v_si = Connection(v, 'out1', si, 'in1')
>>> nw.add_conns(so_v, v_si)
>>> so_v.set_attr(fluid={'water': 1}, T=50, p=5)
>>> v_si.set_attr(p=4)

First we specify Kv:

>>> v.set_attr(Kv=10)
>>> nw.solve('design')
>>> round(so_v.v.val, 4)
0.0028

Then, for example an analytical function:

>>> def analytical(opening, *params):
...     return params[0] * opening
>>> v.set_attr(
...     Kv=None,
...     opening=0.5,
...     Kv_analytical={"method": analytical, "params": [10]}
... )
>>> nw.solve("design")
>>> round(v.Kv.val_SI, 1)
5.0

Or, use the Kv_char, which is a CharLine instance:

>>> from tespy.tools import CharLine
>>> kv_data = np.array([
...     0.09,0.63,1.1,2.1,3.1,4.2,5.2,6.2,7.2,8.2,9.2,10.3,11.3
... ])
>>> opening_data = np.array([0,5,10,20,30,40,50,60,70,80,90,100,110]) / 100
>>> Kv_char = {
...     "char_func": CharLine(x=opening_data, y=kv_data) , "is_set": True
... }
>>> v.set_attr(Kv_char=Kv_char, Kv_analytical=None)
>>> nw.solve("design")
>>> round(v.Kv.val, 1)
5.2
Kv_char_analytical_dependents()[source]
Kv_char_analytical_func()[source]

Equation for Kv characteristic of a Valve opening \(K_v=f\left(opening\right)\)

Kv is determined from the method supplied by the user in the Kv_analytical specification and the additional parameters next to the opening. The method must accept parameters in the following way: method(opening, *params)

\[K_v=\dot V \cdot \sqrt{\frac{\rho}{1000\cdot \Delta p}}\]

The residual is reformulated as below:

Returns:

float – Residual value of equation.

\[0=K_v ^ 2 \cdot \frac{\Delta p}{100} -\frac{\left(3600 \cdot \dot m \right) ^ 2}{\rho}\]

Kv_char_dependents()[source]
Kv_char_func()[source]

Equation for Kv characteristic of a Valve opening \(K_v=f\left(opening\right)\)

Kv is determined from the degree of opening with a lookup table, the Kv equation is then applied:

\[K_v=\dot V \cdot \sqrt{\frac{\rho}{1000\cdot \Delta p}}\]

The residual is reformulated as below:

Returns:

float – Residual value of equation.

\[0=K_v ^ 2 \cdot \frac{\Delta p}{100} -\frac{\left(3600 \cdot \dot m \right) ^ 2}{\rho}\]

Kv_dependents()[source]
Kv_func()[source]

Equation for Kv value of a Valve

The equation is as follows:

\[K_v=\dot V \cdot \sqrt{\frac{\rho}{1000\cdot \Delta p}}\]

The residual is reformulated as below:

Returns:

float – Residual value of equation.

\[0=K_v ^ 2 \cdot \frac{\Delta p}{100} -\frac{\left(3600 \cdot \dot m \right) ^ 2}{\rho}\]

dp_char_dependents()[source]
dp_char_func()[source]

Equation for characteristic line of difference pressure to mass flow.

Returns:

float – Residual value of equation.

\[0=p_\text{in}-p_\text{out}-f\left( expr \right)\]

entropy_balance()[source]

Calculate entropy balance of a valve.

Note

The entropy balance makes the following parameter available:

\[\begin{split}\text{S\_irr}=\dot{m} \cdot \left(s_\text{out}-s_\text{in} \right)\\\end{split}\]
get_bypass_constraints()[source]
get_char_inputs(key)[source]

Inputs of a characteristic at the current state of the component.

The equation of the characteristic evaluates it at these inputs, the range check after convergence tests them against the data. The base implementation covers characteristics with a param, see get_char_expr(). Components override this method for characteristics with other inputs.

Parameters:

key (str) – Name of the characteristic parameter.

Returns:

tuple – SI inputs, one per input axis, None if the inputs of the characteristic are not known to the component.

get_mandatory_constraints()[source]
get_parameters()[source]
get_plotting_data()[source]

Generate a dictionary containing FluProDia plotting information.

Returns:

data (dict) – A nested dictionary containing the keywords required by the calc_individual_isoline method of the FluidPropertyDiagram class. First level keys are the connection index (‘in1’ -> ‘out1’, therefore 1 etc.).

static inlets()[source]
static outlets()[source]