epowcore.gdf package

Subpackages

Submodules

class epowcore.gdf.bus.LFBusType(value)

Bases: Enum

Defines the type of a bus for load flow calculations.

PQ = 'PQ'
PV = 'PV'
SL = 'SLACK'
ISO = 'ISOLATED'
class epowcore.gdf.bus.BusType(value)

Bases: Enum

Defines the functional type of the bus.

BUSBAR = 'Busbar'
JUNCTION = 'Junction Node'
INTERNAL = 'Internal Node'
class epowcore.gdf.bus.Bus(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None, *, lf_bus_type: ~epowcore.gdf.bus.LFBusType, nominal_voltage: float = <factory>, bus_type: ~epowcore.gdf.bus.BusType = BusType.BUSBAR)

Bases: Component

This class represents a Bus element.

lf_bus_type: LFBusType

This represents the bus type for load flow calculations.

nominal_voltage: float

This is the nominal voltage of the bus in kV.

bus_type: BusType = 'Busbar'

This defines the functional type of the bus. Default is Busbar.

class epowcore.gdf.common_impedance.CommonImpedance(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None, *, sn_mva: float = <factory>, r_pu: float = <factory>, x_pu: float = <factory>, r_pu_ba: float | None = None, x_pu_ba: float | None = None, g_pu_a: float | None = None, b_pu_a: float | None = None, g_pu_b: float | None = None, b_pu_b: float | None = None, phase_shift: float = 0.0)

Bases: Component

The Common Impedance is a per unit impedance model including an ideal transformer. The main usage is for branches used for network reduction.

connector_names: ClassVar[list[str]] = ['A', 'B']

List of connectors of the component.

sn_mva: float

The rated apparent power in MVA.

r_pu: float

Real part of positive sequence impedance from A to B [p.u.]

x_pu: float

Imaginary part of positive sequence impedance from A to B [p.u.]

r_pu_ba: float | None = None

Real part of positive sequence impedance from B to A [p.u.]

x_pu_ba: float | None = None

Imaginary part of positive sequence impedance from B to A [p.u.]

g_pu_a: float | None = None

Real part of admittance at terminal A [p.u.]

b_pu_a: float | None = None

Imaginary part of admittance at terminal A [p.u.]

g_pu_b: float | None = None

Real part of admittance at terminal B [p.u.]

b_pu_b: float | None = None

Imaginary part of admittance at terminal B [p.u.]

phase_shift: float = 0.0

Phase shift from terminal A to B [deg]

class epowcore.gdf.component.Component(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None)

Bases: object

Abstract class for model components.

uid: int

ID of the element, used for the graph in the CoreModel

name: str

Name of the component.

coords: tuple[float, float] | list[tuple[float, float]] | None = None

Coordinates of the component in the model.

connector_names: ClassVar[list[str]] = []

List of connectors of the component.

classmethod from_primitive_dict(data: dict) Component

Create a Component from a dictionary containing primitive data types.

Parameters:

data (dict) – The dictionary containing the Component data as primitive values.

Returns:

The created Component containing the data.

Return type:

Component

get_fb(attr: str, platform: Platform | None = None, log: bool = True) Any

Get the value of the attribute with fallback. If it is None, try getting the default value from the configuration files. Log usages of default variables by default.

Parameters:
  • attr (str) – The name of the requested attribute.

  • platform (Platform | None, optional) – The platform to get the default value for, e.g. JMDL; defaults to None

  • log (bool, optional) – Enable/disable logging; defaults to True

Returns:

The instance value or default value of [attr].

Return type:

Any | None

get_default(attr: str, platform: Platform | None = None, log: bool = True) Any | None

Get the default value of the requested attribute.

Allows getting defaults for different platforms. Creates a log entry for getting the default value by default.

Parameters:
  • attr (str) – The name of the requested attribute.

  • platform (Platform | None, optional) – The platform to get the default value for, e.g. JMDL; defaults to None

  • log (bool, optional) – Enable/disable logging; defaults to True

Returns:

The default value for the attribute.

Return type:

Any | None

to_export_str() str

Return a simple string representation, containing only the class, uid and name of the Component.

Returns:

A simple string representation. Can be parsed as a tuple.

Return type:

str

to_primitive_dict() dict

Return the dataclass as a dict containing only primitive data types.

Returns:

A dictionary describing the instance with primitive data types only.

Return type:

dict

class epowcore.gdf.core_model.CoreModel(*, base_frequency: float, base_mva: float | None = None, graph: ~epowcore.generic.component_graph.ComponentGraph = <factory>, version: int = 1)

Bases: object

This class represents the generic model, including the component graph and additional attributes.

base_frequency: float

Base Frequency of the elements based of the project.

base_mva: float | None = None

Base rating for pu calculations in the project.

graph: ComponentGraph

Graph of connection between elements.

version: int = 1

Version of the generic data format.

base_mva_fb(platform: Platform | None = None) float

Base rating for pu calculations in the project with fallback.

add_component(component: Component) None

Add a component to the graph.

Parameters:

component (Component) – The component to be added.

remove_component(component: Component, keep_connections: bool = False) None

Remove a component from the graph.

Parameters:

component (Component) – The component to be removed.

get_component_by_id(uid: int) tuple[Component | None, ComponentGraph | None]

Get a component by its uid.

Parameters:

uid (int) – The uid of the component.

Returns:

The component.

Return type:

Component

add_connection(component1: Component, component2: Component, connector_name1: str | list[str] | None = '', connector_name2: str | list[str] | None = '') None

Add an edge between two components to the graph.

Parameters:
  • component1 (Component) – The first component.

  • component2 (Component) – The second component.

  • connector_name1 (str | list[str] | None) – The name of the connector on the first component.

  • connector_name2 (str | list[str] | None) – The name of the connector on the second component.

get_attached_to(component: Component, connector_name: str | None = None) list[tuple[Component, list[str]]]

Get the components attached to a component. Optionally filtered by connector name.

Parameters:
  • component (Component) – The source component.

  • connector_name (str) – The name of the connector. If None, all neighbors are returned.

  • include_subsystems (bool) – If True, connections to Subsystems and Ports are resolved to the component connected to this port/subsystem.

Returns:

A list of components attached to the connector and their port name.

Return type:

list[Component, list[str]]

get_corresponding_connector(component: Component, neighbor: Component, connector_name: str) str | None

Get the corresponding connector name of a component to a neighbor component.

Parameters:
  • component – The component.

  • neighbor – The neighbor component.

  • connector_name – The name of the connector.

Returns:

The corresponding connector name. None if no corresponding connector exists.

get_connector_names(component: Component) list[str]

Get the names of all connectors of a component.

Parameters:

component (Component) – The component.

Returns:

A list of connector names.

Return type:

list[str]

get_connection_name(component: Component, neighbor: Component) list[str] | None

Get the connector name of the neighbor.

Parameters:
  • component (Component) – The component with the connector.

  • neighbor (Component) – The component connected to the connector.

Returns:

The name of the connector.

Return type:

list[str] | None

check_connectors(component: Component) bool

Checks if the component only has connectors according to its type.

Parameters:

component (Component) – The component.

Returns:

True if the component only has valid connectors, else False.

Return type:

bool

has_connected_to(component: Component, connector_name: str) bool

Checks if the component has a connection to a specific connector.

Parameters:
  • component (Component) – The component.

  • connector_name (str) – The name of the connector.

Returns:

True if the component has a connection to the connector, else False.

Return type:

bool

get_neighbors(component: Component, follow_links: bool = True, connector: str | None = None) list[Component]

Get the direct neighbors of [component]. Can optionally traverse subsystems and restrict looking for neighbors at a specified [connector].

Parameters:
  • component (Component) – The component whose neighbors are returned.

  • follow_links (bool, optional) – If true, replace Subsystems and Ports with the component they actually connect to; defaults to True

  • connector (str | None, optional) – If not None, limit only return neighbors connected to this connector; defaults to None

Returns:

A list of components connected to to given [component].

Return type:

list[Component]

type_list(comp_type: type[T] | list[type[T]]) list[T]

List of components of type [comp_type].

component_list() list[Component]

List of all components.

get_valid_id() int

Generate a valid new component ID by calculating the maximum taken ID.

Returns:

A valid ID for a new component.

Return type:

int

sanity_check() bool

Checks the validity of the model.

Returns:

True if the model is valid, else False.

export_dict() dict

Export the whole model as a dictionary. The dictionary only contains primitive values and thus can be encoded as JSON.

Returns:

The dictionary containing the model settings, graph, and components.

Return type:

dict

classmethod import_dict(data: dict) CoreModel

Import a valid dictionary and return a CoreModel representation of the model.

Parameters:

data (dict) – The dictionary containing the model data.

Returns:

The CoreModel representation of the model.

Return type:

CoreModel

class epowcore.gdf.extended_ward.ExtendedWard(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None, *, p_load: float = <factory>, q_load: float = <factory>, p_gen: float = <factory>, q_gen: float = <factory>, p_zload: float = <factory>, q_zload: float = <factory>, u_setp: float = <factory>, r_ext: float = <factory>, x_ext: float = <factory>)

Bases: Ward

This class represents a Ward equivalent. It consists of a constant impedance load and constant PQ load and generation.

u_setp: float

The voltage setpoint for the internal voltage source in pu.

r_ext: float

The internal resistance of the internal voltage source in Ohm.

x_ext: float

The internal reactance of the internal voltage source in Ohm.

replace_with_load_shunt_vsource(core_model: CoreModel, base_mva: float = 100.0) None

Replaces the Ward equivalent with a Load, a Shunt component, and a VoltageSource in the graph.

Parameters:

core_model (CoreModel) – The core model to replace the ward in.

class epowcore.gdf.external_grid.ExternalGridType(value)

Bases: Enum

Enum for the different types of power grids

PQ = 'PQ'
PV = 'PV'
SL = 'SL'
class epowcore.gdf.external_grid.ExternalGrid(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None, *, u_setp: float, p: float, q: float, p_min: float | None = None, p_max: float | None = None, q_min: float, q_max: float, bus_type: ExternalGridType)

Bases: Component

An external electrical grid, defined as a bus.

u_setp: float

Voltage setpoint [pu].

p: float

Active power [MW].

q: float

Reactive power [Mvar].

p_min: float | None = None

Minimum active power [MW].

p_max: float | None = None

Maximum active power [MW].

q_min: float

Minimum reactive power [Mvar].

q_max: float

Maximum reactive power [Mvar].

bus_type: ExternalGridType

Bus type.

class epowcore.gdf.impedance.Impedance(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None, *, sn_mva: float = <factory>, r_pu: float = <factory>, x_pu: float = <factory>, r_pu_ba: float | None = None, x_pu_ba: float | None = None)

Bases: Component

A series impedance.

connector_names: ClassVar[list[str]] = ['A', 'B']

List of connectors of the component.

sn_mva: float

The rated apparent power in MVA.

r_pu: float

Real part of positive sequence impedance from A to B in pu.

x_pu: float

Imaginary part of positive sequence impedance from A to B in pu.

r_pu_ba: float | None = None

Real part of positive sequence impedance from B to A in pu.

x_pu_ba: float | None = None

Imaginary part of positive sequence impedance from B to A in pu.

replace_with_line(core_model: CoreModel, platform: Platform | None = None) None

Replaces the Impedance with a TLine component in the graph.

Parameters:

core_model (CoreModel) – The CoreModel to replace this component in.

class epowcore.gdf.load.Load(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None, *, active_power: float = <factory>, reactive_power: float = <factory>)

Bases: Component

This class represents an general Load. Specific kinds of loads are not taken into account currently.

active_power: float

The active power of the Load. The unit is MW.

reactive_power: float

The reactive Power of the Load. The unit is Mvar.

class epowcore.gdf.port.Port(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None, connection_component: int = <factory>)

Bases: Component

A surrogate component to enable connections between components in subsystems and higher level components.

connection_component: int
class epowcore.gdf.pv_system.PVSystem(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None, *, rated_power: float = <factory>, real_power_output: float = <factory>, reactive_power_output: float = <factory>, minimum_real_power_output: float = <factory>, maximum_real_power_output: float = <factory>, minimum_reactive_power_output: float = <factory>, maximum_reactive_power_output: float = <factory>)

Bases: Component

A simple photovoltaic system.

rated_power: float

Rated power in MVA.

real_power_output: float

Real power output in MW.

reactive_power_output: float

Reactive power output in Mvar.

minimum_real_power_output: float

Minimum real power output in MW.

maximum_real_power_output: float

Maximum real power output in MW.

minimum_reactive_power_output: float

Minimum reactive power output in Mvar.

maximum_reactive_power_output: float

Maximum reactive power output in Mvar.

class epowcore.gdf.shunt.Shunt(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None, *, p: float, q: float)

Bases: Component

A shunt defined by conductance and susceptance.

p: float

Active power demand at 1.0 p.u. voltage in MW.

q: float

Reactive power demand at 1.0 p.u. voltage in Mvar.

class epowcore.gdf.subsystem.Subsystem(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None, graph: ~epowcore.generic.component_graph.ComponentGraph = <factory>)

Bases: Component

Generic class for subsystem components. Used as an intermediate class in preparation for export.

graph: ComponentGraph

Subgraph containing the components

get_connected_to_port(component_id: int) list[Component]

Get a list of components that are connected to the Port whose connection_component equals [component_id].

Parameters:

component_id (int) – The id of the Component that is represented by a Port in this Subsystem.

Returns:

The list of components in the Subsystem connected to the Port.

Return type:

list[Component]

classmethod from_components(core_model: CoreModel, components: list[Component], update_ds: bool = True, name: str | None = None) Subsystem

Create a subsystem from a list of components and optionally update the core model.

Parameters:
  • core_model (CoreModel) – The core model that contains the given components.

  • components (list[Component]) – The components that form the new subsystem.

  • update_ds (bool, optional) – If True, the components are removed from the core model and replaced with the subsystem; defaults to True

Raises:

ValueError – Raised when parameters are not allowed.

Returns:

The new Subsystem component containing the given Component list.

Return type:

Subsystem

to_primitive_dict() dict

Return the dataclass as a dict containing only primitive data types.

Returns:

A dictionary describing the instance with primitive data types only.

Return type:

dict

classmethod from_primitive_dict(data: dict) Component

Override the default from_primitive_dict method to handle the graph.

get_max_id() int

Get the highest assigned component id in this Subsystem. Recursively scans included Subsystems.

Returns:

The biggest component id found in this and subsequent Subsystems.

Return type:

int

get_component_by_id(uid: int) tuple[Component | None, ComponentGraph | None]

Get a component by its uid.

Parameters:

uid (int) – The uid of the component.

Returns:

The component.

Return type:

Component

class epowcore.gdf.switch.Switch(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None, *, closed: bool, in_service: bool | None = None, rate_a: float | None = None, rate_b: float | None = None, rate_c: float | None = None)

Bases: Component

A switch.

closed: bool

If set to true, the switch connects.

in_service: bool | None = None

If set to true, switch has no failure.

rate_a: float | None = None

Long term rating [MVA].

rate_b: float | None = None

Short term rating [MVA].

rate_c: float | None = None

Emergency rating [MVA].

class epowcore.gdf.tline.TLine(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None, *, length: float | None = None, r1: float, x1: float, b1: float, r0: float | None = None, x0: float | None = None, b0: float | None = None, rating: float, rating_short_term: float | None = None, rating_emergency: float | None = None, parallel_lines: int = 1, angle_min: float | None = None, angle_max: float | None = None)

Bases: Component

This class represents a transmission line.

connector_names: ClassVar[list[str]] = ['A', 'B']

List of connectors of the component.

length: float | None = None

Length of the line in km.

r1: float

Line resistance in Ohm per km. Absolute value if length is None.

x1: float

Line reactance in Ohm per km. Absolute value if length is None.

b1: float

Line susceptance in uS per km. Absolute value if length is None.

r0: float | None = None

Zero sequence resistance in Ohm per km. Absolute value if length is None.

x0: float | None = None

Zero sequence reactance in Ohm per km. Absolute value if length is None.

b0: float | None = None

Zero sequence susceptance in uS per km. Absolute value if length is None.

rating: float

Rating of the line in MVA.

rating_short_term: float | None = None

Rating of the line in MVA.

rating_emergency: float | None = None

Rating of the line in MVA.

parallel_lines: int = 1

Number of parallel lines.

angle_min: float | None = None

Minimum angle difference in degrees.

angle_max: float | None = None

Maximum angle differnce in degrees.

r0_fb(platform: Platform | None = None, log: bool = True) float

Fallback for r0 (zero sequence resistance) calculated with r1 and a configured factor.

Parameters:

platform (Platform | None, optional) – The platform to get the configured factor for, defaults to None

Returns:

r0 if set, otherwise the calculated value

Return type:

float

x0_fb(platform: Platform | None = None, log: bool = True) float

Fallback for x0 (zero sequence reactance) calculated with x1 and a configured factor.

Parameters:

platform (Platform | None, optional) – The platform to get the configured factor for, defaults to None

Returns:

x0 if set, otherwise the calculated value

Return type:

float

b0_fb(platform: Platform | None = None, log: bool = True) float

Fallback for b0 (zero sequence susceptance) calculated with b1 and a configured factor.

Parameters:

platform (Platform | None, optional) – The platform to get the configured factor for, defaults to None

Returns:

b0 if set, otherwise the calculated value

Return type:

float

rating_short_term_fb(platform: Platform | None = None, log: bool = True) float

Fallback property for [rating_short_term]. Returns attribute if not None. Calculates the value with the [rating] and a given multiplicator.

Parameters:

platform (Platform | None, optional) – The platform to get the default value from, defaults to None

Returns:

The given or calculated value.

Return type:

float

rating_emergency_fb(platform: Platform | None = None, log: bool = True) float

Fallback property for [rating_emergency]. Returns attribute if not None. Calculates the value with the [rating] and a given multiplicator.

Parameters:

platform (Platform | None, optional) – The platform to get the default value from, defaults to None

Returns:

The given or calculated value.

Return type:

float

epowcore.gdf.utils.get_connected_bus(graph: ComponentGraph, node: Component, max_depth: int = 3) Bus | None

Search for the nearest bus connected to the given node with maximum search depth.

Parameters:
  • graph (nx.Graph) – The graph to search in.

  • node (Component) – The node to start the search from.

  • max_depth (int) – The maximum search depth.

epowcore.gdf.utils.get_z_base(component: Component, core_model: CoreModel) float

Calculate the base impedance (z_base) with the voltage of a connected bus and the base rating.

Parameters:
  • component (Component) – The component to get the connected bus for

  • core_model (CoreModel) – The CoreModel containing the component

Returns:

The base rating [MVA]

Return type:

float

class epowcore.gdf.voltage_source.VoltageSource(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None, u_setp: float = <factory>, phi_setp: float = <factory>, r_pu: float = <factory>, x_pu: float = <factory>)

Bases: Component

A voltage source.

u_setp: float

The voltage magnitude setpoint in pu.

phi_setp: float

The voltage angle setpoint in pu.

r_pu: float

The internal resistance in pu.

x_pu: float

The internal reactance in pu.

class epowcore.gdf.ward.Ward(uid: int, name: str, coords: tuple[float, float] | list[tuple[float, float]] | None = None, *, p_load: float = <factory>, q_load: float = <factory>, p_gen: float = <factory>, q_gen: float = <factory>, p_zload: float = <factory>, q_zload: float = <factory>)

Bases: Component

This class represents a Ward equivalent. It consists of a constant impedance load and constant PQ load and generation.

p_load: float

The active power of the load. The unit is MW.

q_load: float

The reactive power of the load. The unit is Mvar.

p_gen: float

The active power of the generator. The unit is MW.

q_gen: float

The reactive power of the generator. The unit is Mvar.

p_zload: float

The active power of the constant impedance load. The unit is MW.

q_zload: float

The reactive power of the constant impedance load. The unit is Mvar.

replace_with_load_and_shunt(core_model: CoreModel) None

Replaces the Ward equivalent with a Load and a Shunt component in the graph.

Parameters:

core_model (CoreModel) – The core model to replace the ward in.

Module contents