e2nIEE / pandapipes

A pipeflow calculation tool that complements pandapower in the simulation of multi energy grids
https://www.pandapipes.org
Other
139 stars 60 forks source link

Out of service create_circ_pump_const_pressure results in IndexError #594

Closed samvanderzwan closed 5 months ago

samvanderzwan commented 6 months ago

When setting a circ pump const pressure to in service to False then I get the following error in pandapipes:

File "\pandapipes\component_models\component_toolbox.py", line 154, in set_fixed_node_entries juncts, press_sum, number = _sum_by_group(use_numba, junctions[mask], values[mask], IndexError: boolean index did not match indexed array along dimension 0; dimension is 2 but corresponding boolean dimension is 1

This is the code I am running:

import pandapipes as pp
import pandas as pd

def main2():
    net = pp.create_empty_network(fluid="water")
    # create junctions
    junctions = pp.create_junctions(
        net,
        8,
        pn_bar=5.0,
        tfluid_k=300.0,
        height_m=0.0,
      #  geodata=[[4, 2], [4, 1], [4, 0], [0, 0]],
        name=[
            "1",
            "2",
            "3",
            "4",
            "5",
            "6",
            "7",
            "8",
        ],
    )

    pipe_list = pp.create_pipes_from_parameters(
        net,
        from_junctions=[1, 5, 4, 2, 7, 5],
        to_junctions=[2, 3, 2, 6, 5, 0],
        length_km=[1, 1, 1, 1, 1, 1],
        diameter_m=0.2,
        name=[
            "A",
            "B",
            "C",
            "D",
            "E",
            "F",
        ],
    )

    #heating demand
    pp.create_flow_control(
        net=net,
        from_junction=junctions[3],
        to_junction=junctions[4],
        diameter_m=0.2,
        controlled_mdot_kg_per_s=100.0,
        control_active=True,
        in_service=True,
        name="valve_demand_cluster01",
    )

    pp.create_circ_pump_const_pressure(
        net=net,
        return_junction=junctions[0],
        flow_junction=junctions[1],
        p_flow_bar=15,
        plift_bar=5,
        t_flow_k=300.0 + 30.0,
        name="pump_production_cluster01",
        type="pt"
    )
    pp.create_flow_control(
        net=net,
        from_junction=junctions[0],
        to_junction=junctions[1],
        diameter_m=0.2,
        controlled_mdot_kg_per_s=50.0,
        control_active=True,
        in_service=False,
        name="valve_demand_cluster01",
    )

    pp.create_flow_control(
        net=net,
        from_junction=junctions[6],
        to_junction=junctions[7],
        diameter_m=0.2,
        controlled_mdot_kg_per_s=50.0,
        control_active=True,
        in_service=True,
        name="valve_demand_cluster01",
    )
    pp.create_circ_pump_const_pressure(
        net=net,
        return_junction=junctions[6],
        flow_junction=junctions[7],
        p_flow_bar=15,
        plift_bar=5,
        t_flow_k=300.0 + 30.0,
        name="pump_production_cluster01",
        type="pt",
        in_service=False
    )
    pp.pipeflow(net, "all")

    print(net.res_pipe)

if __name__ == "__main__":
    main2()

I have 8 nodes and 6 pipes 1 consumer cluster which is modeled with a control valve with a fixed mass flow rate. 2 production cluster modeled by a parallel control valve and a const pressure pump. One of the const pressure pump is set to in service false, this results in the given error. When you remove this pump the example runs.

We are running on Windows with Python 3.9 and we are using pandapipes 0.9.0

dlohmeier commented 6 months ago

Hi @samvanderzwan , I looked at the error and quickly found the source for it. I created a hotfix PR, but I cannot promise that this will be released very quickly. There is always the possibility to checkout the respective branch or to change the small part in your own code (see here).

dlohmeier commented 5 months ago

We made the release finally.