pandapipes

repository·develop·Indexed 42 days ago

https://github.com/e2niee/pandapipes

A pipeflow calculation tool for simulating multi-energy grids, specifically heat and gas networks. Built upon pandapower, it utilizes pandas tables for data representation and implements a Newton-Raphson solver for steady-state analysis. Version 0.14.0.post1.

Tokens
51.7K
Snippets
187
Records
271
Agent score
53%

What's inside pandapipes

  1. Overview of pandapipes

    develop
    pandapipes is a piping grid simulation tool built upon pandapower. It is designed for the analysis and optimization of piping grids, utilizing pandas tables for all input and output data representations. The tool implements a Newton-Raphson solver for steady-state analysis, aiming for a high level of automation similar to the pandapower framework.
  2. Overview of the pandapipes toolbox

    develop
    The pandapipes toolbox is a collection of helper functions designed for common application tasks within the pandapipes framework. These functions are intended for utilities that do not fit into specialized packages. While many functions are similar to those found in the pandapower toolbox, not all pandapower functions are directly transferred to pandapipes.
  3. Plotting networks with pandapipes

    develop

    pandapipes provides functions to visualize network grids using matplotlib. The standard workflow for plotting a network involves two main steps:

    1. Generate collections: Create a collection of geometric representations for each component type within the network.
    2. Draw collections: Use matplotlib.pyplot to render these collections.

    For specific implementation details, refer to the simple_plot and collections guides.

  4. Perform Time Series Simulation in pandapipes

    develop

    The timeseries module allows you to solve quasi-stationary time-dependent problems. It works by performing a stationary calculation for each discrete time step in a given sequence. This enables the calculation of time-dependent distributions for variables such as pressures or flow velocities.

    Additionally, the module supports the use of pandapower controller implementations, allowing you to apply control strategies to time-dependent problems.

  5. What is the Flow Control component?

    develop

    The Flow Control component is a physical model used to enforce a specific mass flow between two junctions. It is particularly useful for controlling mass flow in district heating networks.

    Important Usage Note: It is highly recommended to use flow control components only in looped networks. Using them in non-looped networks, especially on stubs, may cause the pipeflow simulation to fail to converge.

  6. What is an external grid and how to use it

    develop

    An external grid is used to denote nodes with fixed values of pressure or temperature that should not be solved for during calculations. They often represent connections to higher-level grids (e.g., a medium pressure level connecting to a low pressure grid).

    Naming Convention

    The type of external grid is determined by its name suffix:

    • p: Fixed pressure.
    • t: Fixed temperature.
    • pt: Both pressure and temperature are fixed at the connected junction.

    Calculation Requirements

    • Hydraulic calculations: At least one node with a fixed pressure must be present for each separate part of the grid.
    • Heat transfer calculations: At least one node with a fixed temperature must be present for each separate part of the grid.
    • Mass Flow: For nodes with fixed pressure, the mass flow into or out of the system is not known prior to calculation; it is a result of the pipeflow calculation.

    Note: Connectivity checks will validate if these requirements are met.

  7. Overview of Pipeflow functionality

    develop

    Pipeflow is the core functionality of pandapipes used to calculate hydraulic and thermal properties in a pipe-bound network.

    Key capabilities include:

    • Hydraulic calculations: Determining pressure at junctions and velocity within pipes.
    • Thermal calculations: Determining temperatures at junctions and heat transfer between components and the environment.

    To perform these calculations, users must define or assume boundary conditions. These conditions can be configured directly within the network components or via global options.

  8. Understand the pandapipesNet data structure

    develop

    In pandapipes, a network is represented by a pandapipesNet object. This object acts as a container for all network elements, organized into pandas.DataFrame tables. Each table corresponds to a specific element type (e.g., pipe, sink, source, junction).

    Key characteristics of pandapipesNet:

    • Data Storage: Elements are stored in DataFrames where each row represents one element and each column represents a parameter.
    • Access Patterns: The pandapipesNet object is an ADict (Attribute Dictionary). You can access element tables using either dictionary syntax or attribute syntax:
      • Dictionary syntax: net['pipe']
      • Attribute syntax: net.pipe
    • Inspection: Calling repr(net) provides a human-readable summary of the network, including the fluid type and the count/types of elements included.
    import pandapipes as pp
    
    # Create a network
    net = pp.create_empty_network()
    
    # Accessing a table via dictionary syntax
    pipe_df_dict = net['pipe']
    
    # Accessing a table via attribute syntax
    pipe_df_attr = net.pipe
  9. Understand the pandapipes internal tables (pit) structure

    develop

    Calculations in pandapipes do not run directly on the user-facing pandas tables. Instead, they use an internal structure called pandapipes internal tables (pit), accessible via net["_pit"].

    Key Components:

    • pit: The standard internal structure consisting of two numpy arrays: one for all network nodes and one for all branches.
    • active_pit: An optimized internal structure (net["_active_pit"]) that contains only the 'active' parts of the network. It excludes nodes and branches that were set out of service by the user or by the connectivity check.

    Important Note on Node Indices: In the branch tables, FROM_NODE and TO_NODE refer to the indices of junctions in the pipe table. However, within the pit and active_pit, these indices refer to the positions within the node arrays. When nodes are removed to create an active_pit, these indices are re-mapped to ensure they point to the correct locations in the reduced tables.

  10. Use the Fluid class to manage fluid properties

    develop

    The pandapipes.Fluid class is used to define the fluid running through a network. You can use the built-in library of fluids or create your own. The class provides a general function to retrieve requested property values, as well as specific functions for common properties like density, viscosity, and heat capacity.

    You can extend a fluid by adding new properties using the provided addition function, which handles name collisions by warning the user or overwriting existing properties.

    import pandapipes
    # Example of accessing a fluid (conceptual usage)
    fluid = pandapipes.Fluid()
    # Specific functions for density, viscosity, and heat capacity are available
    # New properties can be added to the fluid instance
  11. How pipe hydraulic calculations work

    develop

    In hydraulic mode, the pipe element calculates pressure and velocity losses. The calculation method depends on the medium type:

    Incompressible Media

    For incompressible fluids, velocity remains constant along the pipe. Pressure loss is calculated based on elevation changes, friction, and local losses (e.g., $\zeta$).

    Compressible Media

    For compressible fluids, density and velocity change along the pipe axis. Pandapipes uses the law of ideal gases and reference state variables (normal temperature and pressure) to calculate pressure drops.

    Increasing Resolution: Because velocity changes along the axis for compressible fluids, you can use the sections parameter to split a pipe into multiple internal sections, increasing the calculation resolution.

  12. How compressor pressure lift and power are calculated

    develop

    The compressor component in pandapipes models pressure lift and compression power based on the following physical principles:

    Pressure Lift

    For a compressor between from_junction i and to_junction j, the pressure lift is calculated using the absolute pressure (relative pressure + ambient pressure) and the pressure_ratio $\Pi$.

    If the mass flow $\dot{m}{ij} > 0$ kg/s: $$p_j = (p_i + p{amb}) \cdot \Pi - p_{amb}$$

    Otherwise, $p_j = p_i$.

    Compression Power

    For $\dot{m}_{ij} > 0$, the required compression power (in Megawatts) is estimated via the ideal adiabatic change in enthalpy:

    $$P_{\text{compr},ij} = \dot{m}_{ij}\frac{\kappa}{\kappa - 1} R_s z(p_i) T_i \cdot \left(\Pi ^{\frac{\kappa -1}{\kappa}}-1\right)\cdot 10^{-6}$$

    Where:

    • $\kappa$ is the isentropic exponent (assumed as 1.4).
    • $R_s$ is the specific gas constant.
    • $z(p)$ is the compressibility.
    • $T_i$ is the temperature.