Exemplo n.º 1
0
def test_create_sinks_raise_except(create_empty_net):
    net = copy.deepcopy(create_empty_net)
    # standard
    j1 = pandapipes.create_junction(net, 3, 273)
    j2 = pandapipes.create_junction(net, 3, 273)
    j3 = pandapipes.create_junction(net, 3, 273)

    with pytest.raises(
            UserWarning,
            match=r"Cannot attach to junctions \{3, 4, 5\}, they do not "
            r"exist"):
        pandapipes.create_sinks(net,
                                junctions=[3, 4, 5],
                                mdot_kg_per_s=[0, 0.1, 0.2],
                                scaling=[1., 1., 0.5],
                                name=["sink%d" % s for s in range(3)],
                                new_col=[1, 3, 5])

    sg = pandapipes.create_sinks(net,
                                 junctions=[j1, j2, j3],
                                 mdot_kg_per_s=[0, 0.1, 0.2],
                                 scaling=[1., 1., 0.5],
                                 name=["sink%d" % s for s in range(3)],
                                 new_col=[1, 3, 5])
    with pytest.raises(UserWarning,
                       match=r"Sinks with indexes \[0 1 2\] already exist."):
        pandapipes.create_sinks(net,
                                junctions=[j1, j2, j3],
                                mdot_kg_per_s=[0, 0.1, 0.2],
                                scaling=[1., 1., 0.5],
                                name=["sink%d" % s for s in range(3)],
                                new_col=[1, 3, 5],
                                index=sg)
Exemplo n.º 2
0
def test_create_sinks(create_empty_net):
    net = copy.deepcopy(create_empty_net)
    # standard
    j1 = pandapipes.create_junction(net, 3, 273)
    j2 = pandapipes.create_junction(net, 3, 273)
    j3 = pandapipes.create_junction(net, 3, 273)
    pandapipes.create_sinks(net,
                            junctions=[j1, j2, j3],
                            mdot_kg_per_s=[0, 0.1, 0.2],
                            scaling=[1., 1., 0.5],
                            name=["sink%d" % s for s in range(3)],
                            new_col=[1, 3, 5])

    assert (net.sink.junction.at[0] == j1)
    assert (net.sink.junction.at[1] == j2)
    assert (net.sink.junction.at[2] == j3)
    assert (net.sink.mdot_kg_per_s.at[0] == 0)
    assert (net.sink.mdot_kg_per_s.at[1] == 0.1)
    assert (net.sink.mdot_kg_per_s.at[2] == 0.2)
    assert (net.sink.scaling.at[0] == 1)
    assert (net.sink.scaling.at[1] == 1)
    assert (net.sink.scaling.at[2] == 0.5)
    assert (all(net.sink.in_service.values == True))
    assert (all(net.sink.type.values == "sink"))
    assert (all(net.sink.new_col.values == [1, 3, 5]))
Exemplo n.º 3
0
def test_g2p_multiple(get_gas_example, get_power_example_simple):
    """ coupling of multiple elements with one MulitEnergyController"""
    # get the nets
    fluid = {"name": "hgas", "cal_value": 14.62197}
    net_gas = copy.deepcopy(get_gas_example)
    net_power = copy.deepcopy(get_power_example_simple)
    assert fluid["name"] == pandapipes.get_fluid(net_gas).name

    # set up multinet
    mn = create_empty_multinet("test_g2p")
    add_nets_to_multinet(mn, power=net_power, gas=net_gas)

    # dummy component for offset in load/source indices:
    _ = pandapower.create_sgen(net_power, 0, p_mw=0.01)
    no_g2p = pandapipes.create_sinks(net_gas, [0, 3], mdot_kg_per_s=0.001)

    # add components to represent G2P unit
    gas_cons_kg_per_s = 0.5
    g2p_ids_gas = pandapipes.create_sinks(net_gas,
                                          range(1, 3),
                                          mdot_kg_per_s=gas_cons_kg_per_s,
                                          name="gas to power consumption")
    g2p_ids_el = pandapower.create_sgens(net_power,
                                         range(4, 6),
                                         0,
                                         name="gas to power feed in")

    # add coupling controller
    eta = 0.4
    G2PControlMultiEnergy(mn,
                          g2p_ids_el,
                          g2p_ids_gas,
                          efficiency=eta,
                          element_type_power="sgen")

    run_control(mn)

    # nets must not be changed
    assert mn.nets["power"] == net_power
    assert mn.nets["gas"] == net_gas

    # check G2P result
    assert np.all(net_power.sgen.loc[g2p_ids_el, "p_mw"] == \
                  net_power.res_sgen.loc[g2p_ids_el, "p_mw"])
    assert np.allclose(net_power.sgen.loc[g2p_ids_el, "p_mw"],
                       (gas_cons_kg_per_s * fluid["cal_value"] * 3600 / 1000) *
                       eta)
    assert np.all(net_gas.sink.loc[g2p_ids_gas,
                                   "mdot_kg_per_s"] == gas_cons_kg_per_s)
    assert np.all(net_gas.sink.loc[no_g2p, "mdot_kg_per_s"] == 0.001)
Exemplo n.º 4
0
def test_g2g_multiple(get_gas_example):
    """ coupling of multiple elements in two gas grids with one MulitEnergyController
        gas-to-gas = e.g. hgas (methane) to Hydrogen conversion (SMR)"""
    # get the nets
    fluid1 = {"name": "hgas", "cal_value": 14.62197}
    net_gas1 = copy.deepcopy(get_gas_example)
    pandapipes.create_fluid_from_lib(net_gas1, fluid1["name"], overwrite=True)

    fluid2 = {"name": "hydrogen", "cal_value": 38.38024}
    net_gas2 = copy.deepcopy(get_gas_example)
    pandapipes.create_fluid_from_lib(net_gas2, fluid2["name"], overwrite=True)

    # set up multinet
    mn = create_empty_multinet("test_g2g")
    add_nets_to_multinet(mn, hgas_net=net_gas1, hydrogen_net=net_gas2)

    # dummy component for offset in sink/source indices:
    _ = pandapipes.create_sink(net_gas1, 0, mdot_kg_per_s=0.001)
    no_g2g = pandapipes.create_sources(net_gas2, [0, 3], mdot_kg_per_s=0.0314)

    # add components to represent G2P unit
    gas1_cons_kg_per_s = 0.05
    g2g_ids_cons = pandapipes.create_sinks(net_gas1,
                                           range(1, 4),
                                           mdot_kg_per_s=gas1_cons_kg_per_s,
                                           name="SMR consumption")
    g2g_ids_prod = pandapipes.create_sources(net_gas2, [0, 2, 5],
                                             0,
                                             name="SMR production")

    # add coupling controller
    eta = 0.65
    GasToGasConversion(mn,
                       g2g_ids_cons,
                       g2g_ids_prod,
                       efficiency=eta,
                       name_gas_net_from='hgas_net',
                       name_gas_net_to='hydrogen_net')

    run_control(mn)

    # nets must not be changed
    assert mn.nets["hgas_net"] == net_gas1
    assert mn.nets["hydrogen_net"] == net_gas2

    # check G2G result
    assert np.all(net_gas1.sink.loc[g2g_ids_cons, "mdot_kg_per_s"] == \
                  net_gas1.res_sink.loc[g2g_ids_cons, "mdot_kg_per_s"])
    assert np.all(net_gas1.sink.loc[g2g_ids_cons,
                                    "mdot_kg_per_s"] == gas1_cons_kg_per_s)
    assert np.all(net_gas2.source.loc[no_g2g, "mdot_kg_per_s"] == 0.0314)
    assert np.allclose(
        net_gas2.source.loc[g2g_ids_prod, "mdot_kg_per_s"],
        (gas1_cons_kg_per_s * fluid1["cal_value"] / fluid2["cal_value"]) * eta)