Power Flow Calculation

Delivery Element

Default data-classes for delivery elements.

Any delivery element has two terminals and moves electricity from one bus to another. Cables and transformers fit into this category. Any edge in supra graph corresponds to one and only one delivery element, and vice versa.

Note

Whether the element is paralleled should be specified as an edge attribute.

Warning

Inherited attributes are not shown again.

class mgrid.power_flow.delivery.Cable(length_km, name, parallel, r_ohm, x_ohm, c_nf, max_i_ka)[source]

Bases: mgrid.power_flow.delivery.CableEssential

Define cable from parameters.

c_nf: float

capacitance in nano Farad per kilo-meter

max_i_ka: float

maximum thermal current in kilo-ampere

r_ohm: float

resistance in ohm per kilo-meter

update_pandapower(net, source, target)[source]

Update a pandapower model by adding the cable itself.

Parameters
  • net (pandapowerNet) – a pandapower network model.

  • source (str) – a bus of the cable, corresponding to source in networkx edge.

  • target (str) – another bus of the cable, corresponding to source in networkx edge.

x_ohm: float

reactance in ohm per kilo-meter

class mgrid.power_flow.delivery.CableEssential(length_km, name, parallel)[source]

Bases: object

Essential cable parameters.

length_km: float

cable length in kilometer

name: str

name

parallel: int

number of same cables in parallel

class mgrid.power_flow.delivery.CablePhase(length_km, name, parallel, phases, r_ohm_mat, x_ohm_mat)[source]

Bases: mgrid.power_flow.delivery.CableEssential

Define cable phase-by-phase from parameters.

phases: List[str]

phase(s) of the cable

r_ohm_mat: numpy.ndarray

resistance matrix in ohm per kilo-meter

x_ohm_mat: numpy.ndarray

reactance matrix in ohm per kilo-meter

property z_ohm_mat

Calculate impedance matrix based on resistance and reactance.

Return type

ndarray

Returns

Impedance matrix of the cable.

class mgrid.power_flow.delivery.CableStd(length_km, name, parallel, std_type)[source]

Bases: mgrid.power_flow.delivery.CableEssential

Define cable from standard type.

std_type: str

a standard cable type

class mgrid.power_flow.delivery.Transformer[source]

Bases: object

Define transformer from parameters.

class mgrid.power_flow.delivery.TransformerStd(std_type, name, parallel)[source]

Bases: object

Essential transformer parameters.

name: str

name of the inter-node

parallel: int

number of same transformers in parallel.

std_type: str

a standard transformer type

update_pandapower(net, source, target)[source]

Update a pandapower model by adding the transformer itself.

Parameters
  • net (pandapowerNet) – a pandapower network model.

  • source (str) – a bus of the transformer, corresponding to source in networkx edge.

  • target (str) – another bus of the transformer, corresponding to source in networkx edge.

Conversion Element

Prototypical classes for conversion elements in power flow analysis.

A conversion element is an electrical device converting electricity to or from other form. For example, a microware oven relies on electricity to emit wave. Such devices have only one terminal and must be attached to a bus. Generally, based on if the neutral wire is involved, there are two kinds of connection: wye or delta. Wye connection is the focus for now. A bus can have multiple or zero conversion element attached.

For any conversion element, a unique name and a node to which it attaches must be specified in supra graph. Furthermore, in planar graph, the layer of the element must be specified, because it might be attached to an inter-node, which spans two layers. See mgrid.grid.planar for more details.

class mgrid.power_flow.conversion.Capacitor(q_mvar, loss_factor)[source]

Bases: object

Define a shunt element representing a capacitor bank.

Note

Capacitor can be seen as a source of reactive power. The value may change with respect to voltage.

loss_factor: float

loss factor tan(delta) of the capacitor bank

q_mvar: float

reactive power of the capacitor bank at nominal voltage

update_pandapower(net, name, bus)[source]

Update a pandapower model by adding the capacitor itself.

Parameters
  • net (pandapowerNet) – a pandapower network model.

  • name (str) – name of the external grid.

  • bus (str) – the bus to which the external grid is attached.

class mgrid.power_flow.conversion.Ejection(p_mw, power_factor)[source]

Bases: object

Essential parameters for load or static generators.

Note

  • The power factor of such ejection model is usually time-invariant.

p_mw: float

ejected real power in mega-watt

power_factor: float

power factory

property q_mvar

Calculate ejected reactive power in mega-watt.

Return type

float

Returns

Ejected reactive power in mega-watt.

update_pandapower(net, name, bus)[source]

Update a pandapower model by adding the ejection itself.

Note

When the value of p_mw is negative, a generator without voltage control ability is added.

Parameters
  • net (pandapowerNet) – a pandapower network model.

  • name (str) – name of the external grid.

  • bus (str) – the bus to which the external grid is attached.

class mgrid.power_flow.conversion.Slack(vm_pu=1.0)[source]

Bases: object

Specify one slack bus and its voltage magnitude.

Note

  • The external grid or a voltage-controlled conversion element is usually attached to this bus. It is not necessary to model it.

  • Distributed slack buses should be specified using SlackMulti, and is supported by PyPSA.

update_pandapower(net, name, bus)[source]

Update a pandapower model by adding the transformer itself.

Parameters
  • net (pandapowerNet) – a pandapower network model.

  • name (str) – name of the external grid.

  • bus (str) – the bus to which the external grid is attached.

vm_pu: float = 1.0

voltage magnitude in per unit. Default to be 1.

class mgrid.power_flow.conversion.SlackMulti[source]

Bases: object

Specify some bus(es) and/or voltage-controlled element as slack.

Note

See Power Flow, PyPSA for details.

Conversion Element Type

Define data-classes for element types.

class mgrid.power_flow.type.TransformerType(s_mva, v_high_kv, v_low_kv, vk_percent, vkr_percent, pfe_kw, i0_percent)[source]

Bases: object

One-phase equivalent transformer type.

i0_percent: float

open loop losses in percent

pfe_kw: float

iron losses in kilo-watt

s_mva: float

nominal apparent power in mega-voltampere

update_pandapower(net, name)[source]

Update a pandapower model by adding this transformer type.

Parameters
  • net (pandapowerNet) – a pandapower network model.

  • name (str) – name of this transformer type.

v_high_kv: float

nominal high voltage in kilo-volt

v_low_kv: float

nominal low voltage in kilo-volt

vk_percent: float

real part of relative short-circuit voltage in percent

vkr_percent: float

relative short-circuit voltage in percent

“pandapower” Package

Build pandapower model.

Three functions to add buses, delivery elements, and conversion elements.

mgrid.power_flow.pandapower.supra2pandapower(supra)[source]

Build pandapower model based on supra format.

Parameters

supra (SupraGrid) – a supra-grid.

Return type

pandapowerNet

Returns

A pandapower model.