# Pipeflow Options¶

When running a pipeflow, you can choose between different calculation modes, turn on or off a lot of different functionalities, or change input parameters and boundary conditions that shall be considered. In this section you can find information on how the options can be set and how they influence the pipeflow calculation.

## The Option Order¶

The options in pandapipes are considered in a very specific order as there are different ways of how to define your own options and how settings override one another depending on how they are defined. There are four layers that define the final option setup. Those layers are:

1. The default options (found in the pipeflow_setup). There all necessary options are defined with default values. This means that a pipeflow will not usually lead to an error of not having defined a specific option.

2. Some default parameters in the pipeflow call are already implemented as explicit keyword arguments. The default options are overriden with those values.

3. It is possible to add user options (c.f. Setting User Options). These user options will override all default options defined before.

4. When calling the pipeflow function and explicitly overriding any arguments, this is identified and even the user options are overriden again.

The available options and how they can be set are described in the following.

## Initialize Option Function¶

The final option setup is generated and saved under net[“_options”] by the following internal function:

init_options(net, local_parameters)

Initializes physical and mathematical constants included in pandapipes. In addition, options for the nonlinear and time-dependent solver are also set.

Those are the options that can be set and their default values:

• iter (int): 10 - If the simulation is terminated after a certain amount of iterations, this is the number of iterations.

• tol_p (float): 1e-4 - The relative tolerance for the pressure. A result is accepted if the relative error is smaller than this factor.

• tol_v (float): 1e-4 - The relative tolerance for the velocity. A result is accepted if the relative error is smaller than this factor.

• tol_T (float): 1e-4 - The relative tolerance for the temperature. A result is accepted if the relative error is smaller than this factor.

• tol_res (float): 1e-3 - The relative tolerance for the residual. A result is accepted if the relative error is smaller than this factor.

• ambient_temperature (float): 293.0 - The assumed ambient temperature for the calculation of the barometric formula

• friction_model (str): “nikuradse” - The friction model that shall be used to identify the value for lambda (can be “nikuradse” or “colebrook”)

• alpha (float): 1 - The step width for the Newton iterations. If the Newton steps shall be damped, alpha can be reduced. See also the nonlinear_method parameter.

• nonlinear_method (str): “constant” - The option of how the damping factor alpha is determined in each iteration. It can be “constant” (i.e. alpha is always the same in each iteration) or “automatic”, in which case alpha is adapted automatically with respect to the convergence behaviour.

• gas_impl (str): “pandapipes” - Implementation of the gas model. It can be set to “pandapipes” with calculations according to “Handbuch der Gasversorgungstechnik” or to “STANET” with calculations according to the STANET reference.

• heat_transfer (bool): False - Flag to determine if the heat transfer shall be calculated.

• only_update_hydraulic_matrix (bool): False - If True, the system matrix is not created in every iteration, but only the data is updated according to a lookup that is identified in the first iteration. This speeds up calculation, but has not yet been tested extensively.

• check_connectivity (bool): True - If True, a connectivity check is performed at the beginning of the pipeflow and parts of the net that are not connected to external grids are set inactive.

• quit_on_inconsistency_connectivity (bool): False - If True, inconsistencies in the connectivity check raise an error, otherwise they are handled. Inconsistencies mean that out of service nodes are connected to in service branches. If that is the case and the flag is set to False, the connected nodes are activated.

Parameters
• net (pandapipesNet) – The pandapipesNet for which the options are initialized

• local_parameters (dict) – Dictionary with local parameters that were passed to the pipeflow call.

Returns

No output

Example
>>> init_options(net)


## Setting User Options¶

User options will be stored in a pandapipes network and will always override the default options, unless specified otherwise during the pipeflow call.

set_user_pf_options(net, reset=False, **kwargs)

This function sets the “user_pf_options” dictionary for net. These options overrule net._internal_options once they are added to net. These options are used in configuration of load flow calculation. At the same time, user-defined arguments for pandapipes.pipeflow() always have a higher priority. To remove user_pf_options, set “reset = True” and provide no additional arguments.

Parameters
• net (pandapipesNet) – pandapipes network for which to create user options

• reset (bool, default False) – Specifies whether the user_pf_options is removed before setting new options

• kwargs – pipeflow options that shall be set, e. g. tol_v = 1e-7

Returns

No output

## Auxiliary Option Functions¶

With the help of the following functions options can be set or retrieved. These functions are usually only used internally in the pipeflow.

get_net_option(net, option_name)

Returns the requested option of the given net. Raises a UserWarning if the option was not found.

Parameters
• net (pandapipesNet) – pandapipesNet for which option is requested

• option_name (str) – Name of requested option

Returns

option - The value of the option

get_net_options(net, *option_names)

Returns several requested options of the given net. Raises a UserWarning if any of the options was not found.

Parameters
• net (pandapipesNet) – pandapipesNet for which option is requested

• option_names (str) – Names of requested options (as args)

Returns

option - Tuple with values of the options

Note

If you set options with the following function, they will still be overridden once you run another pipeflow.

set_net_option(net, option_name, option_value)

Auxiliary function to set the value of a specific option (options are saved in a dict).

Parameters
• net (pandapipesNet) – pandapipesNet for which option shall be set

• option_name (str) – Name under which the option shall be saved

• option_value – Value that shall be set for the given option

Returns

No output