# Minimal Example pandapipes¶

## Creating a low pressure gas network¶

We consider the following simple 3-junction example network with an ideal valve as a minimal example:

The above network can be created in pandapipes as follows:

In [ ]:
import pandapipes as pp

#create empty net
net = pp.create_empty_network(fluid="lgas")

# create junction
j1 = pp.create_junction(net, pn_bar=1.05, tfluid_k=293.15, name="Junction 1")
j2 = pp.create_junction(net, pn_bar=1.05, tfluid_k=293.15, name="Junction 2")
j3 = pp.create_junction(net, pn_bar=1.05, tfluid_k=293.15, name="Junction 3")

# create junction elements
ext_grid = pp.create_ext_grid(net, junction=j1, p_bar=1.1, t_k=293.15, name="Grid Connection")
sink = pp.create_sink(net, junction=j3, mdot_kg_per_s=0.045, name="Sink")

# create branch element
pipe = pp.create_pipe_from_parameters(net, from_junction=j1, to_junction=j2, length_km=0.1, diameter_m=0.05, name="Pipe 1")
valve = pp.create_valve(net, from_junction=j2, to_junction=j3, diameter_m=0.05, opened=True, name="Valve 1")


Note that the fluid used here is lgas. You can find 5 predefined fluids in pandapipes:

- lgas
- hgas
- hydrogen
- water
- air



And that the predefined valve element is an ideal valve.

## Data Structure¶

Each dataframe in a pandapipes net object contains the information about one pandapipes element, such as pipe, sink, valve etc.

In [ ]:
net.junction

In [ ]:
net.pipe

In [ ]:
net.ext_grid


## Pipe Flow¶

We now run a pipe flow:

In [ ]:
pp.pipeflow(net)


And check out at the results for junctions and pipes:

In [ ]:
net.res_junction


They're is no pressure loss between junction 2 and junction 3 because of the ideal valve.

In [ ]:
net.res_pipe


### Closed valve¶

We now close the valve between junction 2 and junction 3:

In [ ]:
# Problem can not run pipeflow if valve closed
net.valve.opened = False


The closed valve cuts the sink from the external grid:

This can be verified by running a power flow and inspecting the results. The pressure and temperature at junction 2 is given as NaN:

In [ ]:
pp.pipeflow(net)
net.res_junction


Also the results from the pipe show that the mass flow is almost zero and the speed of the mass flow is zero.

In [ ]:
net.res_pipe