Create Function

pandapower.create_gen(net, bus, p_kw, vm_pu=1., sn_kva=nan, name=None, index=None, max_q_kvar=nan, min_q_kvar=nan, min_p_kw=nan, max_p_kw=nan, scaling=1., type=None, controllable=nan, vn_kv=nan, xdss=nan, rdss=nan, cos_phi=nan, in_service=True)

Adds a generator to the network.

Generators are always modelled as voltage controlled PV nodes, which is why the input parameter is active power and a voltage set point. If you want to model a generator as PQ load with fixed reactive power and variable voltage, please use a static generator instead.


net - The net within this generator should be created

bus (int) - The bus id to which the generator is connected


p_kw (float, default 0) - The real power of the generator (negative for generation!)

vm_pu (float, default 0) - The voltage set point of the generator.

sn_kva (float, None) - Nominal power of the generator

name (string, None) - The name for this generator

index (int, None) - Force a specified ID if it is available. If None, the index one higher than the highest already existing index is selected.

scaling (float, 1.0) - scaling factor which for the active power of the generator

type (string, None) - type variable to classify generators

controllable (bool, NaN) - Whether this generator is controllable by the optimal powerflow

vn_kv (float, NaN) - Rated voltage of the generator for short-circuit calculation

xdss (float, NaN) - Subtransient generator reactance for short-circuit calculation

rdss (float, NaN) - Subtransient generator resistance for short-circuit calculation

cos_phi (float, NaN) - Rated cosine phi of the generator for short-circuit calculation

in_service (bool, True) - True for in_service or False for out of service

max_p_kw (float, default NaN) - Maximum active power injection - necessary for OPF

min_p_kw (float, default NaN) - Minimum active power injection - necessary for OPF

max_q_kvar (float, default NaN) - Maximum reactive power injection - necessary for OPF

min_q_kvar (float, default NaN) - Minimum reactive power injection - necessary for OPF

index (int) - The unique ID of the created generator
create_gen(net, 1, p_kw = -120, vm_pu = 1.02)

Input Parameters


Parameter Datatype Value Range Explanation
name string   name of the generator
type string
naming conventions:
“sync” - synchronous generator
“async” - asynchronous generator
type variable to classify generators
bus* integer   index of connected bus
p_kw* float \(\leq\) 0 the real power of the generator [kW]
vm_pu* float   voltage set point of the generator [p.u]
sn_kva float \(>\) 0 nominal power of the generator [kVA]
min_q_kvar float   minimal reactive power of the generator [kVar]
max_q_kvar float   maximal reactive power of the generator [kVar]
scaling* float \(\leq\) 0 scaling factor for the active power
max_p_kw** float   Maximum active power
min_p_kw** float   Minimum active power
max_q_kvar** float   Maximum reactive power
min_q_kvar** float   Minimum reactive power
controllable** bool True/False States if a gen is controllable or not. Currently gens must be controllable, because there is no method to respect uncontrollable gens yet.
vn_kv*** float    
xdss*** float \(>\) 0  
rdss*** float \(>\) 0 Rated voltage of the generator
cos_phi*** float \(0 \leq\) 1 Subtransient generator reactance
in_service* boolean True / False Subtransient generator resistence
      Rated generator cosine phi
      specifies if the generator is in service.

*necessary for executing a power flow calculation
**optimal power flow parameter
***short-circuit calculation parameter


Active power should normally be negative to model a voltage controlled generator, since all power values are given in the load reference system. A generator with positive active power represents a voltage controlled machine. If you want to model constant generation without voltage control, use the Static Generator element.

Electric Model

Generators are modelled as PV-nodes in the power flow:

alternate Text

Voltage magnitude and active power are defined by the input parameters in the generator table:

\begin{align*} P_{gen} &= p\_kw * scaling \\ v_{bus} &= vm\_pu \end{align*}

Result Parameters


Parameter Datatype Explanation
p_kw float resulting active power demand after scaling [kW]
q_kvar float resulting reactive power demand after scaling [kVar]
va_degree float generator voltage angle [degree]
vm_pu float voltage at the generator [p.u]

The power flow returns reactive generator power and generator voltage angle:

\begin{align*} p\_kw &= P_{gen} \\ q\_kvar &= Q_{gen} \\ va\_degree &= \angle \underline{v}_{bus} \\ vm\_degree &= |\underline{v}_{bus}| \end{align*}


If the power flow is run with the enforce_qlims option and the generator reactive power exceeds / underruns the maximum / minimum reactive power limit, the generator is converted to a static generator with the maximum / minimum reactive power as constant reactive power generation. The voltage at the generator bus is then no longer equal to the voltage set point defined in the parameter table.