VeraGridEngine.DataStructures package

Submodules

VeraGridEngine.DataStructures.active_branch_data module

class VeraGridEngine.DataStructures.active_branch_data.ActiveBranchData(nelm: int, nbus: int)[source]

Bases: object

ControllableBranchData

Pset: ndarray[tuple[Any, ...], dtype[float64]]
Qset: ndarray[tuple[Any, ...], dtype[float64]]
property any_pf_control
Returns:

compare(other: ActiveBranchData, tol: float, logger: Logger) → None[source]

Compare active-branch fields used by NumericalCircuit.compare().

copy() → ActiveBranchData[source]
Returns:

is_controlled: ndarray[tuple[Any, ...], dtype[int64]]
m_taps
nbus: int
nelm: int
remap(bus_map_arr: ndarray[tuple[Any, ...], dtype[int64]]) → None[source]

Remapping of the branch-controlled bus indices. :param bus_map_arr: array of old-to-new buses

size() → int[source]

Get size of the structure :return:

slice(elm_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_map: ndarray[tuple[Any, ...], dtype[int64]], logger: Logger | None) → ActiveBranchData[source]

Slice branch data by given indices :param elm_idx: array of branch indices :param bus_idx: array of bus indices :param bus_map: array of bus indices to re index main to island indices :param logger: Logger (optional) :return: new BranchData instance

property tap: ndarray[tuple[Any, ...], dtype[complex128]]
Returns:

tap_angle: ndarray[tuple[Any, ...], dtype[float64]]
tap_angle_max: ndarray[tuple[Any, ...], dtype[float64]]
tap_angle_min: ndarray[tuple[Any, ...], dtype[float64]]
tap_controlled_buses: ndarray[tuple[Any, ...], dtype[int64]]
tap_module: ndarray[tuple[Any, ...], dtype[float64]]
tap_module_control_mode: ndarray[tuple[Any, ...], dtype[int64]]
tap_module_max: ndarray[tuple[Any, ...], dtype[float64]]
tap_module_min: ndarray[tuple[Any, ...], dtype[float64]]
tap_phase_control_mode: ndarray[tuple[Any, ...], dtype[int64]]
tau_taps
vset: ndarray[tuple[Any, ...], dtype[float64]]

VeraGridEngine.DataStructures.battery_data module

class VeraGridEngine.DataStructures.battery_data.BatteryData(nelm: int, nbus: int)[source]

Bases: GeneratorData

Structure to host the battery compiled data

charge_efficiency: ndarray[tuple[Any, ...], dtype[float64]]
copy() → BatteryData[source]

Get a deep copy of this object :return: new BatteryData instance

discharge_efficiency: ndarray[tuple[Any, ...], dtype[float64]]
e_max: ndarray[tuple[Any, ...], dtype[float64]]
e_min: ndarray[tuple[Any, ...], dtype[float64]]
efficiency: ndarray[tuple[Any, ...], dtype[float64]]
enom: ndarray[tuple[Any, ...], dtype[float64]]
max_soc: ndarray[tuple[Any, ...], dtype[float64]]
min_soc: ndarray[tuple[Any, ...], dtype[float64]]
slice(elm_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_map: ndarray[tuple[Any, ...], dtype[int64]]) → BatteryData[source]

Slice battery data by given indices :param elm_idx: array of element indices :param bus_idx: array of bus indices :param bus_map: map from bus to index :return: new BatteryData instance

soc_0: ndarray[tuple[Any, ...], dtype[float64]]

VeraGridEngine.DataStructures.branch_parent_data module

class VeraGridEngine.DataStructures.branch_parent_data.BranchParentData(nelm: int, nbus: int)[source]

Bases: object

Structure to host all branches data for calculation

property C: csc_matrix

Branch-bus connectivity matrix :return:

property Cf: csc_matrix

Bras-bus from connectivity :return:

property Ct: csc_matrix

Bras-bus to connectivity :return:

F: ndarray[tuple[Any, ...], dtype[int64]]
T: ndarray[tuple[Any, ...], dtype[int64]]
active: ndarray[tuple[Any, ...], dtype[bool]]
compare(other: BranchParentData, tol: float, logger: Logger) → None[source]

Compare branch-parent fields shared by branch-like structures.

contingency_enabled: ndarray[tuple[Any, ...], dtype[int64]]
contingency_rates: ndarray[tuple[Any, ...], dtype[float64]]
copy() → BranchParentData[source]

Get a deep copy of this object :return: new BranchData instance

dc: ndarray[tuple[Any, ...], dtype[int64]]
get_3ph_names()[source]
get_ac_indices() → ndarray[tuple[Any, ...], dtype[int64]][source]

Get ac branch indices :return:

get_contingency_enabled_indices() → ndarray[tuple[Any, ...], dtype[int64]][source]

Get contingency branch indices :return:

get_dc_indices() → ndarray[tuple[Any, ...], dtype[int64]][source]

Get dc branch indices :return:

get_inter_areas(bus_idx_from: ndarray[tuple[Any, ...], dtype[int64]] | Set[int], bus_idx_to: ndarray[tuple[Any, ...], dtype[int64]] | Set[int])[source]

Get the Branches that join two areas :param bus_idx_from: Area from :param bus_idx_to: Area to :return: List of (branch index, flow sense w.r.t the area exchange)

get_monitor_enabled_indices() → ndarray[tuple[Any, ...], dtype[int64]][source]

Get monitored branch indices :return:

idtag: ndarray[tuple[Any, ...], dtype[str_]]
monitor_loading: ndarray[tuple[Any, ...], dtype[int64]]
monitored_Cf(idx) → csc_matrix[source]

Bras-bus from connectivity for monitored branches :param idx: Monitored branches ids :return:

monitored_Ct(idx) → csc_matrix[source]

Bras-bus to connectivity for monitored branches :param idx: Monitored branches ids :return:

mttf: ndarray[tuple[Any, ...], dtype[float64]]
mttr: ndarray[tuple[Any, ...], dtype[float64]]
names: ndarray[tuple[Any, ...], dtype[str_]]
nbus: int
nelm: int
original_idx: ndarray[tuple[Any, ...], dtype[int64]]
overload_cost: ndarray[tuple[Any, ...], dtype[float64]]
protection_rates: ndarray[tuple[Any, ...], dtype[float64]]
rates: ndarray[tuple[Any, ...], dtype[float64]]
reducible: ndarray[tuple[Any, ...], dtype[int64]]
remap(bus_map_arr: ndarray[tuple[Any, ...], dtype[int64]])[source]

Remapping of the branch buses :param bus_map_arr: array of old-to-new buses

size() → int[source]

Get size of the structure :return:

slice(elm_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_map: ndarray[tuple[Any, ...], dtype[int64]], logger: Logger | None) → Tuple[BranchParentData, ndarray[tuple[Any, ...], dtype[int64]]][source]

Slice branch data by given indices :param elm_idx: array of branch indices :param bus_idx: array of bus indices :param bus_map: map from bus index to island bus index {int(o): i for i, o in enumerate(bus_idx)} :param logger: Logger :return: new BranchData instance

to_df() → DataFrame[source]

Create DataFrame with the compiled Branches information :return: Pandas DataFrame

VeraGridEngine.DataStructures.bus_data module

class VeraGridEngine.DataStructures.bus_data.BusData[source]

Bases: object

Vbus: ndarray[tuple[Any, ...], dtype[complex128]]
Vmax: ndarray[tuple[Any, ...], dtype[float64]]
Vmin: ndarray[tuple[Any, ...], dtype[float64]]
Vnom: ndarray[tuple[Any, ...], dtype[float64]]
active: ndarray[tuple[Any, ...], dtype[int64]]
angle_max: ndarray[tuple[Any, ...], dtype[float64]]
angle_min: ndarray[tuple[Any, ...], dtype[float64]]
areas: ndarray[tuple[Any, ...], dtype[int64]]
b_fixed
bus_types: ndarray[tuple[Any, ...], dtype[int64]]
compare(other: BusData, tol: float, logger: Logger) → None[source]

Compare bus data arrays used by NumericalCircuit.compare().

copy() → BusData[source]

Deep copy of this structure :return: instance of BusData

cost_v: ndarray[tuple[Any, ...], dtype[float64]]
get_3ph_names()[source]

Get the 3-phase names :return:

get_idtag_dict() → Dict[str, int][source]

Get dictionary of bus idtagd related to the island bus index :return:

get_original_to_island_bus_dict() → Dict[int, int][source]

Dictionary that relates the original bus index to the island bus index :return: dict[original idx] -> island index

idtag: ndarray[tuple[Any, ...], dtype[str_]]
ii_fixed
installed_power: ndarray[tuple[Any, ...], dtype[float64]]
is_dc: ndarray[tuple[Any, ...], dtype[bool]]
is_grounded: ndarray[tuple[Any, ...], dtype[bool]]
is_p_controlled
is_q_controlled
is_va_controlled
is_vm_controlled
names: ndarray[tuple[Any, ...], dtype[str_]]
nbus: int
original_idx: ndarray[tuple[Any, ...], dtype[int64]]
propagate_controls(chosen_idx: int, other_idx: ndarray[tuple[Any, ...], dtype[int64]]) → None[source]

Propagate the strongest control status of the reduced buses into chosen_idx.

q_fixed
q_shared_total
set_bus_mode(idx: int, val: BusMode)[source]

Set bus mode :param idx: int :param val: BusMode

size() → int[source]

Get size of the structure :return:

slice(elm_idx: ndarray[tuple[Any, ...], dtype[int64]]) → BusData[source]

Slice this data structure :param elm_idx: array of bus indices :return: instance of BusData

srap_available_power: ndarray[tuple[Any, ...], dtype[float64]]
substations: ndarray[tuple[Any, ...], dtype[int64]]
VeraGridEngine.DataStructures.bus_data.propagate_controls(chosen_idx: int, other_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_types: ndarray[tuple[Any, ...], dtype[int64]], Vbus: ndarray[tuple[Any, ...], dtype[complex128]], is_p_controlled: ndarray[tuple[Any, ...], dtype[bool]], is_q_controlled: ndarray[tuple[Any, ...], dtype[bool]], is_vm_controlled: ndarray[tuple[Any, ...], dtype[bool]], is_va_controlled: ndarray[tuple[Any, ...], dtype[bool]]) → None[source]

Propagate the strongest control status of a reduced bus cluster to the surviving bus.

The donor bus is chosen from chosen_idx and other_idx using the actual control flags, not only the bus type, so VSC/HVDC-added controls are preserved as well. :param chosen_idx: island of the island chosen by the topological reduction process to represent the reduction set :param other_idx: rest of buses in the set that are going to be reduced but may contain important information :param bus_types: :param Vbus: :param is_p_controlled: :param is_q_controlled: :param is_vm_controlled: :param is_va_controlled: :return:

VeraGridEngine.DataStructures.fluid_node_data module

class VeraGridEngine.DataStructures.fluid_node_data.FluidNodeData[source]

Bases: object

copy() → FluidNodeData[source]

Get deep copy of this structure :return: new FluidNodeData instance

idtag: ndarray[tuple[Any, ...], dtype[str_]]
inflow
initial_level
max_level
max_soc
min_level
min_soc
names: ndarray[tuple[Any, ...], dtype[str_]]
nelm: int
size() → int[source]

Get size of the structure :return:

spillage_cost

VeraGridEngine.DataStructures.fluid_p2x_data module

class VeraGridEngine.DataStructures.fluid_p2x_data.FluidP2XData[source]

Bases: FluidTurbineData

copy() → FluidP2XData[source]

Get deep copy of this structure :return: new FluidP2XData instance

VeraGridEngine.DataStructures.fluid_path_data module

class VeraGridEngine.DataStructures.fluid_path_data.FluidPathData[source]

Bases: object

copy() → FluidPathData[source]

Get deep copy of this structure :return: new FluidPathData instance

idtag: ndarray[tuple[Any, ...], dtype[str_]]
max_flow
min_flow
names: ndarray[tuple[Any, ...], dtype[str_]]
nelm: int
size() → int[source]

Get size of the structure :return:

source_idx
target_idx

VeraGridEngine.DataStructures.fluid_pump_data module

class VeraGridEngine.DataStructures.fluid_pump_data.FluidPumpData[source]

Bases: FluidTurbineData

copy() → FluidPumpData[source]

Get deep copy of this structure :return: new FluidPumpData instance

VeraGridEngine.DataStructures.fluid_turbine_data module

class VeraGridEngine.DataStructures.fluid_turbine_data.FluidTurbineData[source]

Bases: object

copy() → FluidTurbineData[source]

Get deep copy of this structure :return: new FluidTurbineData instance

efficiency
generator_idx
idtag: ndarray[tuple[Any, ...], dtype[str_]]
max_flow_rate
names: ndarray[tuple[Any, ...], dtype[str_]]
nelm: int
plant_idx
size() → int[source]

Get size of the structure :return:

VeraGridEngine.DataStructures.generator_data module

class VeraGridEngine.DataStructures.generator_data.GeneratorData[source]

Bases: object

Rr: ndarray[tuple[Any, ...], dtype[float64]]
Rs: ndarray[tuple[Any, ...], dtype[float64]]
Xm: ndarray[tuple[Any, ...], dtype[float64]]
Xr: ndarray[tuple[Any, ...], dtype[float64]]
Xs: ndarray[tuple[Any, ...], dtype[float64]]
active: ndarray[tuple[Any, ...], dtype[bool]]
bus_idx: ndarray[tuple[Any, ...], dtype[int64]]
capex: ndarray[tuple[Any, ...], dtype[float64]]
compare(other: GeneratorData, tol: float, logger: Logger) → None[source]

Compare generator fields used by NumericalCircuit.compare().

control_mode_int: ndarray[tuple[Any, ...], dtype[int64]]
controllable_bus_idx
copy()[source]

Get a deep copy of this object :return: new GeneratorData instance

cost_0: ndarray[tuple[Any, ...], dtype[float64]]
cost_1: ndarray[tuple[Any, ...], dtype[float64]]
cost_2: ndarray[tuple[Any, ...], dtype[float64]]
dead_band: ndarray[tuple[Any, ...], dtype[float64]]
dev_per_bus() → ndarray[tuple[Any, ...], dtype[int64]][source]

Get number of devices per bus :return: array with the number of elements per bus

discount_rate: ndarray[tuple[Any, ...], dtype[float64]]
dispatchable: ndarray[tuple[Any, ...], dtype[bool]]
get_C_bus_elm() → csc_matrix[source]

Get the connectivity matrix :return: CSC matrix

get_Yshunt(seq: int = 1) → ndarray[tuple[Any, ...], dtype[complex128]][source]

Obtain the vector of shunt admittances of a given sequence per bus :param seq: sequence (0, 1 or 2)

get_array_per_bus(arr: ndarray[tuple[Any, ...], dtype[float64]]) → ndarray[tuple[Any, ...], dtype[float64]][source]

Get generator array per bus :param arr: :return:

get_array_per_bus_obj(arr: ndarray[tuple[Any, ...], dtype[float64]]) → ndarray[tuple[Any, ...], dtype[float64]][source]

Sum per bus in python mode (it can add objects) :param arr: any array of size nelm :return: array of size nbus

get_bus_indices() → ndarray[tuple[Any, ...], dtype[int64]][source]

Get the bus indices :return: array with the bus indices

get_controllable_and_not_controllable_indices() → Tuple[ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[int64]]][source]

Get the indices of controllable generators :return: idx_controllable, idx_non_controllable

get_dispatchable_active_indices() → ndarray[tuple[Any, ...], dtype[int64]][source]

Get the indices of dispatchable generators :return:

get_dispatchable_active_indices_per_area(bus_area_indices: ndarray[tuple[Any, ...], dtype[int64]], area_count: int) → list[ndarray[tuple[Any, ...], dtype[int64]]][source]

Get the active dispatchable generator indices grouped by area.

Parameters:
  • bus_area_indices – Area index of each bus. A value of -1 means that the bus does not belong to any area.

  • area_count – Number of declared areas.

Returns:

List where position a stores the generator-index array for area a.

get_dispatchable_indices() → ndarray[tuple[Any, ...], dtype[int64]][source]

Get the indices of dispatchable generators :return:

get_dispatchable_per_bus() → ndarray[tuple[Any, ...], dtype[bool]][source]

Get generator Injections per bus :return:

get_effective_generation() → ndarray[tuple[Any, ...], dtype[float64]][source]

Get generator effective power :return:

get_gen_indices_at_buses(bus_indices: ndarray[tuple[Any, ...], dtype[int64]]) → ndarray[tuple[Any, ...], dtype[int64]][source]
get_injections() → ndarray[tuple[Any, ...], dtype[complex128]][source]

Compute the active and reactive power of non-controlled generators (assuming all) :return:

get_injections_per_bus() → ndarray[tuple[Any, ...], dtype[complex128]][source]

Get generator Injections per bus :return:

get_installed_power_per_bus() → ndarray[tuple[Any, ...], dtype[float64]][source]

Get generator installed power per bus :return:

get_non_dispatchable_indices() → ndarray[tuple[Any, ...], dtype[int64]][source]

Get the indices of dispatchable generators :return:

get_pf() → ndarray[tuple[Any, ...], dtype[float64]][source]

Get the array of power factors :return:

get_pmax_per_bus() → ndarray[tuple[Any, ...], dtype[float64]][source]

Get generator Pmax per bus :return:

get_pmin_per_bus() → ndarray[tuple[Any, ...], dtype[float64]][source]

Get generator Pmin per bus :return:

get_q_at(i) → float[source]
Parameters:

i

Returns:

get_qmax_per_bus() → ndarray[tuple[Any, ...], dtype[float64]][source]

Get generator Qmax per bus :return:

get_qmin_per_bus() → ndarray[tuple[Any, ...], dtype[float64]][source]

Get generator Qmin per bus :return:

idtag: ndarray[tuple[Any, ...], dtype[str_]]
installed_p: ndarray[tuple[Any, ...], dtype[float64]]
is_at_dc_bus: ndarray[tuple[Any, ...], dtype[bool]]
is_candidate: ndarray[tuple[Any, ...], dtype[bool]]
is_static_generator: ndarray[tuple[Any, ...], dtype[bool]]
k_droop: ndarray[tuple[Any, ...], dtype[float64]]
min_time_down: ndarray[tuple[Any, ...], dtype[float64]]
min_time_up: ndarray[tuple[Any, ...], dtype[float64]]
mttf: ndarray[tuple[Any, ...], dtype[float64]]
mttr: ndarray[tuple[Any, ...], dtype[float64]]
must_run: ndarray[tuple[Any, ...], dtype[bool]]
name_to_idx: dict
names: ndarray[tuple[Any, ...], dtype[str_]]
nbus: int
nelm: int
original_idx
p: ndarray[tuple[Any, ...], dtype[float64]]
p3_star
pmax: ndarray[tuple[Any, ...], dtype[float64]]
pmin: ndarray[tuple[Any, ...], dtype[float64]]
q: ndarray[tuple[Any, ...], dtype[float64]]
q_share: ndarray[tuple[Any, ...], dtype[float64]]
qmax: ndarray[tuple[Any, ...], dtype[float64]]
qmin: ndarray[tuple[Any, ...], dtype[float64]]
r0: ndarray[tuple[Any, ...], dtype[float64]]
r1: ndarray[tuple[Any, ...], dtype[float64]]
r2: ndarray[tuple[Any, ...], dtype[float64]]
ramp_down: ndarray[tuple[Any, ...], dtype[float64]]
ramp_up: ndarray[tuple[Any, ...], dtype[float64]]
remap(bus_map_arr: ndarray[tuple[Any, ...], dtype[int64]])[source]

Remapping of the elm buses :param bus_map_arr: array of old-to-new buses

scalable: ndarray[tuple[Any, ...], dtype[bool]]
shift_key: ndarray[tuple[Any, ...], dtype[float64]]
shut_down_cost: ndarray[tuple[Any, ...], dtype[float64]]
size() → int[source]

Get size of the structure :return:

slice(elm_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_map: ndarray[tuple[Any, ...], dtype[int64]])[source]

Slice generator data by given indices :param elm_idx: array of element indices :param bus_idx: array of bus indices :param bus_map: map from bus index to element index :return: new GeneratorData instance

snom: ndarray[tuple[Any, ...], dtype[float64]]
startup_cost: ndarray[tuple[Any, ...], dtype[float64]]
tpe_int: ndarray[tuple[Any, ...], dtype[int64]]
v: ndarray[tuple[Any, ...], dtype[float64]]
x0: ndarray[tuple[Any, ...], dtype[float64]]
x1: ndarray[tuple[Any, ...], dtype[float64]]
x2: ndarray[tuple[Any, ...], dtype[float64]]

VeraGridEngine.DataStructures.hvdc_data module

class VeraGridEngine.DataStructures.hvdc_data.HvdcData[source]

Bases: BranchParentData

Pset: ndarray[tuple[Any, ...], dtype[float64]]
Pt: ndarray[tuple[Any, ...], dtype[float64]]
Qmax_f: ndarray[tuple[Any, ...], dtype[float64]]
Qmax_t: ndarray[tuple[Any, ...], dtype[float64]]
Qmin_f: ndarray[tuple[Any, ...], dtype[float64]]
Qmin_t: ndarray[tuple[Any, ...], dtype[float64]]
Vnf: ndarray[tuple[Any, ...], dtype[float64]]
Vnt: ndarray[tuple[Any, ...], dtype[float64]]
Vset_f: ndarray[tuple[Any, ...], dtype[float64]]
Vset_t: ndarray[tuple[Any, ...], dtype[float64]]
angle_droop: ndarray[tuple[Any, ...], dtype[float64]]
control_mode_int: ndarray[tuple[Any, ...], dtype[int64]]
copy() → HvdcData[source]

Make a deep copy of this structure :return: new HvdcData instance

dispatchable: ndarray[tuple[Any, ...], dtype[int64]]
get_angle_droop_in_pu_rad(Sbase: float)[source]

Get the angle droop in pu/rad :param Sbase: base power :return:

get_angle_droop_in_pu_rad_at(i: int, Sbase: float)[source]

Get the angle droop in pu/rad :param i: index :param Sbase: base power :return:

get_bus_indices_f() → ndarray[tuple[Any, ...], dtype[int64]][source]

Get bus indices β€œfrom” :return:

get_bus_indices_t() → ndarray[tuple[Any, ...], dtype[int64]][source]

Get bus indices β€œto” :return:

get_inter_areas(bus_idx_from: ndarray[tuple[Any, ...], dtype[int64]] | Set[int], bus_idx_to: ndarray[tuple[Any, ...], dtype[int64]] | Set[int])[source]

Get the hvdcs that join two areas :param bus_idx_from: Area from :param bus_idx_to: Area to :return: List of (branch index, flow sense w.r.t the area exchange)

get_power(Sbase: float, theta: ndarray[tuple[Any, ...], dtype[float64]]) → Tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]], int][source]

Get hvdc power :param Sbase: base power :param theta: bus angles array :return: Pbus, Losses, Pf, Pt, loading, nfree

get_qmax_from_per_bus() → ndarray[tuple[Any, ...], dtype[float64]][source]

Max reactive power in the From Bus :return: (nbus, nt) Qmax From

get_qmax_to_per_bus() → ndarray[tuple[Any, ...], dtype[float64]][source]

Max reactive power in the To Bus :return: (nbus, nt) Qmax To

get_qmin_from_per_bus() → ndarray[tuple[Any, ...], dtype[float64]][source]

Min reactive power in the From Bus :return: (nbus, nt) Qmin From

get_qmin_to_per_bus() → ndarray[tuple[Any, ...], dtype[float64]][source]

Min reactive power in the To Bus :return: (nbus, nt) Qmin To

r: ndarray[tuple[Any, ...], dtype[float64]]
remap(bus_map_arr: ndarray[tuple[Any, ...], dtype[int64]])[source]

Remapping of the branch buses :param bus_map_arr: array of old-to-new buses

size() → int[source]

Get size of the structure :return:

slice(elm_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_map: ndarray[tuple[Any, ...], dtype[int64]], logger: Logger | None) → HvdcData[source]

Make a deep copy of this structure :return: new HvdcData instance

VeraGridEngine.DataStructures.load_data module

class VeraGridEngine.DataStructures.load_data.LoadData(nelm: int, nbus: int)[source]

Bases: object

Structure to host the load calculation information

A_floatingstar
B_floatingstar
C_floatingstar
I: ndarray[tuple[Any, ...], dtype[float64]]
I3_delta
I3_floatingstar
I3_star
S: ndarray[tuple[Any, ...], dtype[float64]]
S3_delta
S3_floatingstar
S3_star
Y: ndarray[tuple[Any, ...], dtype[float64]]
Y3_delta
Y3_star
active: ndarray[tuple[Any, ...], dtype[bool]]
bus_idx
compare(other: LoadData, tol: float, logger: Logger) → None[source]

Compare load fields used by NumericalCircuit.compare().

copy() → LoadData[source]

Get a deep copy of this structure :return: new LoadData instance

cost: ndarray[tuple[Any, ...], dtype[float64]]
get_admittance_injections_per_bus() → ndarray[tuple[Any, ...], dtype[complex128]][source]

Get admittance Injections per bus with sign :return:

get_array_per_bus(arr: ndarray[tuple[Any, ...], dtype[float64]]) → ndarray[tuple[Any, ...], dtype[float64]][source]

Get generator array per bus :param arr: :return:

get_array_per_bus_obj(arr: ndarray[tuple[Any, ...], dtype[float64]]) → ndarray[tuple[Any, ...], dtype[float64]][source]

Sum per bus in python mode (it can add objects) :param arr: any array of size nelm :return: array of size nbus

get_bus_indices() → ndarray[tuple[Any, ...], dtype[int64]][source]

Get the bus indices :return: array with the bus indices

get_current_injections_per_bus() → ndarray[tuple[Any, ...], dtype[complex128]][source]

Get current Injections per bus with sign :return:

get_effective_load() → ndarray[tuple[Any, ...], dtype[complex128]][source]

Get effective load :return:

get_injections_per_bus() → ndarray[tuple[Any, ...], dtype[complex128]][source]

Get Injections per bus with sign :return:

get_linear_effective_load() → ndarray[tuple[Any, ...], dtype[float64]][source]

Get effective load :return:

get_linear_injections_per_bus() → ndarray[tuple[Any, ...], dtype[float64]][source]

Get Injections per bus with sign :return:

get_non_static_generator_injections_per_bus() → ndarray[tuple[Any, ...], dtype[complex128]][source]

Get the non-static-generator injections per bus with sign. :return:

get_static_generator_injections_per_bus() → ndarray[tuple[Any, ...], dtype[complex128]][source]

Get the static generator injections per bus with sign. Static generators are stored in the load data structure with negative load values. :return:

idtag: ndarray[tuple[Any, ...], dtype[str_]]
is_static_generator: ndarray[tuple[Any, ...], dtype[bool]]
mttf: ndarray[tuple[Any, ...], dtype[float64]]
mttr: ndarray[tuple[Any, ...], dtype[float64]]
names: ndarray[tuple[Any, ...], dtype[str_]]
nbus: int
nelm: int
original_idx
remap(bus_map_arr: ndarray[tuple[Any, ...], dtype[int64]])[source]

Remapping of the elm buses :param bus_map_arr: array of old-to-new buses

scalable: ndarray[tuple[Any, ...], dtype[bool]]
shift_key: ndarray[tuple[Any, ...], dtype[float64]]
size() → int[source]

Get size of the structure :return:

slice(elm_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_map: ndarray[tuple[Any, ...], dtype[int64]]) → LoadData[source]

Slice load data by given indices :param elm_idx: array of branch indices :param bus_idx: array of bus indices :param bus_map: map from bus index to island bus index {int(o): i for i, o in enumerate(bus_idx)} :return: new LoadData instance

VeraGridEngine.DataStructures.numerical_circuit module

class VeraGridEngine.DataStructures.numerical_circuit.DataStructType(*values)[source]

Bases: Enum

BATTERYDATA = 5
BRANCHDATA = 2
BUSDATA = 1
GENERATORDATA = 4
HVDCDATA = 3
LOADDATA = 6
NOSTRUCT = 0
SHUNTDATA = 7
VSCDATA = 8
class VeraGridEngine.DataStructures.numerical_circuit.NumericalCircuit(nbus: int, nbr: int, nhvdc: int, nvsc: int, nload: int, ngen: int, nbatt: int, nshunt: int, nfluidnode: int, nfluidturbine: int, nfluidpump: int, nfluidp2x: int, nfluidpath: int, sbase: float, t_idx: int | None = None)[source]

Bases: object

Class storing the calculation information of the devices

Sbase: float
active_branch_data: ActiveBranchData
battery_data: BatteryData
bus_data: BusData
bus_dict: Dict[Any, int] | None
compare(nc_2: NumericalCircuit, tol=1e-06, by_idtag: bool = False) → Tuple[bool, Logger][source]

Compare this numerical circuit with another numerical circuit. :param nc_2: other NumericalCircuit :param tol: tolerance for numerical values :param by_idtag: comparison mode (if true the comparison is made by idtag instead of by raw shape) :return: all ok?, Logger with the errors and warning events

compare_sums(nc_2: NumericalCircuit, tol=1e-06) → Tuple[bool, Logger][source]

Compare raw injection sums.

compute_adjacency_matrix(consider_hvdc_as_island_links: bool = False) → csc_matrix[source]

Compute the adjacency matrix :param consider_hvdc_as_island_links: Does the HVDCLine works for the topology as a normal line? :return: csc_matrix

consolidate_information() → None[source]

Consolidates the information of this object

copy() → NumericalCircuit[source]

Deep copy of ths object :return: NumericalCircuit instance

fluid_node_data: FluidNodeData
fluid_p2x_data: FluidP2XData
fluid_path_data: FluidPathData
fluid_pump_data: FluidPumpData
fluid_turbine_data: FluidTurbineData
generator_data: GeneratorData
get_Yshunt_bus_pu() → ndarray[tuple[Any, ...], dtype[complex128]][source]
Returns:

get_admittance_injections_pu() → ndarray[tuple[Any, ...], dtype[complex128]][source]
Returns:

get_admittance_matrices() → AdmittanceMatrices[source]

Get Admittance structures :return: Admittance object

get_connectivity_matrices() → ConnectivityMatrices[source]

Get connectivity matrices :return:

get_current_injections_pu() → ndarray[tuple[Any, ...], dtype[complex128]][source]
Returns:

get_fast_decoupled_amittances() → FastDecoupledAdmittanceMatrices[source]
Returns:

get_island(bus_idx: ndarray[tuple[Any, ...], dtype[int64]], logger: Logger | None = None) → NumericalCircuit[source]

Get the island corresponding to the given buses :param bus_idx: array of bus indices :param logger: Logger :return: NumericalCircuit

get_linear_admittance_matrices(indices: SimulationIndices | None = None) → LinearAdmittanceMatrices[source]

Get the linear admittances :return:LinearAdmittanceMatrices

get_linear_power_injections() → ndarray[tuple[Any, ...], dtype[complex128]][source]

Compute the bus power injections seen by the linear studies (DC PF, PTDF).

Those models assume a flat voltage of 1 p.u.

Returns:

array of power injections in MW

get_power_injections() → ndarray[tuple[Any, ...], dtype[complex128]][source]

Compute the power :return: return the array of power Injections in MW if normalized is false, in p.u. otherwise

get_power_injections_pu() → ndarray[tuple[Any, ...], dtype[complex128]][source]

Compute the power :return: return the array of power Injections in MW if normalized is false, in p.u. otherwise

get_reactive_power_limits() → Tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]][source]

compute the reactive power limits in place :return: Qmax_bus, Qmin_bus in per unit

get_reduction_bus_mapping() → ndarray[tuple[Any, ...], dtype[int64]][source]

Get array is used to keep track of the bus topological reduction :return: IntVec

get_series_admittance_matrices() → SeriesAdmittanceMatrices[source]
Returns:

get_simulation_indices(Sbus: ndarray[tuple[Any, ...], dtype[complex128]] | None = None, bus_types: ndarray[tuple[Any, ...], dtype[int64]] | None = None, force_only_pq_pv_vd_types=False) → SimulationIndices[source]

Get the simulation indices :param Sbus: Array of bus powers (optional) :param bus_types: different array of bus_types (optional) :param force_only_pq_pv_vd_types: if true, all bus types are forced into PQ PV or VD,

for certain types of simulations that cannot handle other bus types

Returns:

SimulationIndices

get_structural_ntc(bus_a1_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_a2_idx: ndarray[tuple[Any, ...], dtype[int64]]) → float[source]

Get the structural NTC :param bus_a1_idx: array of bus indices of the area from :param bus_a2_idx: array of bus indices of the area to :return: structural NTC in MVA

hvdc_data: HvdcData
init_idtags_dict()[source]

Initialize the internal structure for idtags querying :return:

is_dc() → Tuple[int, str][source]

Check if this island is DC :return: int, str -> 1: all DC, 0: all AC, 2: AC and DC

load_data: LoadData
nbatt: int
nbr: int
nbus: int
nfluidnode: int
nfluidp2x: int
nfluidpath: int
nfluidpump: int
nfluidturbine: int
ngen: int
nhvdc: int
nload: int
nshunt: int
nvsc: int
passive_branch_data: PassiveBranchData
process_reducible_branches() → int[source]

Process the reducible branches (i.e. reduce branches like the switches) in-place :return: Number of reduced branches

propagate_bus_result(bus_magnitude: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[Any, ...], dtype[complex128]])[source]

This function applies the __bus_map_arr to a calculated magnitude to propagate the calculated nodal result :param bus_magnitude: some array of the size of buses (all) :return: propagated results

propagate_bus_result_mat(bus_magnitude: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]] | ndarray[tuple[Any, ...], dtype[complex128]])[source]

This function applies the __bus_map_arr to a calculated magnitude to propagate the calculated nodal result :param bus_magnitude: some array of the size of buses (all) :return: propagated results

query_idtag(idtag: str) → Tuple[DataStructType, int][source]

Query the structure and index where an idtag exists :param idtag: idtag :return: DataStructType, integer position

set_con_or_ra_status(event_list: List[Contingency | RemedialAction], revert: bool = False) → ndarray[tuple[Any, ...], dtype[float64]][source]

Set the status of a list of contingencies or remedial actions :param event_list: list of contingencies and or remedial actions :param revert: if false, the contingencies are applied, else they are reversed :return: vector of power injection increments

set_investments_status(investments_list: List[Investment], status: int) → None[source]

Set the status of a list of investments :param investments_list: list of investments :param status: status to set in the internal structures

shunt_data: ShuntData
split_into_islands(ignore_single_node_islands: bool = False, consider_hvdc_as_island_links: bool = False, logger: Logger | None = None) → List[NumericalCircuit][source]

Split circuit into islands :param ignore_single_node_islands: ignore islands composed of only one bus :param consider_hvdc_as_island_links: Does the HVDCLine works for the topology as a normal line? :param logger: Logger :return: List[NumericCircuit]

structs_idtag_dict: Dict[str, Tuple[DataStructType, int]]
t_idx: int | None
property topology_performed: bool

Flag indicating if topology processing happened here :return:

vsc_data: VscData
VeraGridEngine.DataStructures.numerical_circuit.build_q_limits(nbus: int, Sbase: float, gen_idx, q_min_gen, q_max_gen, active_gen, control_mode_int_gen, batt_idx, q_min_batt, q_max_batt, active_batt, control_mode_int_batt, sh_idx, q_min_sh, q_max_sh, active_sh, control_mode_int_sh, hvdc_f, hvdc_t, q_min_hvdc_f, q_max_hvdc_f, q_min_hvdc_t, q_max_hvdc_t, active_hvdc, v_ctrl_val_gen: int, v_ctrl_val_sh: int)[source]
Parameters:
  • nbus

  • Sbase

  • gen_idx

  • q_min_gen

  • q_max_gen

  • active_gen

  • control_mode_int_gen

  • batt_idx

  • q_min_batt

  • q_max_batt

  • active_batt

  • control_mode_int_batt

  • sh_idx

  • q_min_sh

  • q_max_sh

  • active_sh

  • control_mode_int_sh

  • hvdc_f

  • hvdc_t

  • q_min_hvdc_f

  • q_max_hvdc_f

  • q_min_hvdc_t

  • q_max_hvdc_t

  • active_hvdc

  • v_ctrl_val_gen

:param v_ctrl_val_sh :return:

VeraGridEngine.DataStructures.numerical_circuit.check_arr(arr: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[Any, ...], dtype[int64]] | ndarray[tuple[Any, ...], dtype[bool]] | ndarray[tuple[Any, ...], dtype[complex128]], arr_expected: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[Any, ...], dtype[int64]] | ndarray[tuple[Any, ...], dtype[bool]] | ndarray[tuple[Any, ...], dtype[complex128]], tol: float, name: str, test: str, logger: Logger) → int[source]
Parameters:
  • arr

  • arr_expected

  • tol

  • name

  • test

  • logger

Returns:

VeraGridEngine.DataStructures.numerical_circuit.correct_bus_types(gen_idx: ndarray[tuple[Any, ...], dtype[int64]], control_mode_int: ndarray[tuple[Any, ...], dtype[int64]], gen_controllable_bus_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_types: ndarray[tuple[Any, ...], dtype[int64]], v_ctrl_val: int) → None[source]

Correct remote voltage-controlled bus types after topology processing.

Parameters:
  • gen_idx

  • control_mode_int

  • gen_controllable_bus_idx

  • bus_types

  • v_ctrl_val – value for GeneratorControlMode.V

Returns:

None.

VeraGridEngine.DataStructures.numerical_circuit.select_ac_phase_reference_buses(bus_types: ndarray[tuple[Any, ...], dtype[int64]], active_power: ndarray[tuple[Any, ...], dtype[float64]], bus_active: ndarray[tuple[Any, ...], dtype[bool]], is_dc_bus: ndarray[tuple[Any, ...], dtype[bool]], branch_from: ndarray[tuple[Any, ...], dtype[int64]], branch_to: ndarray[tuple[Any, ...], dtype[int64]], branch_active: ndarray[tuple[Any, ...], dtype[bool]]) → ndarray[tuple[Any, ...], dtype[int64]][source]

Select missing angular references in independent AC phase regions.

Passive AC branches couple voltage angles. VSC and DC connections transfer power without coupling the absolute AC phase, so they must not merge the regions used to select one reference bus.

Parameters:
  • bus_types – Compiled bus modes before automatic promotion.

  • active_power – Active-power injections used to rank PV candidates.

  • bus_active – Active state of every bus.

  • is_dc_bus – DC classification of every bus.

  • branch_from – From-bus indices of passive branches.

  • branch_to – To-bus indices of passive branches.

  • branch_active – Active state of passive branches.

Returns:

PV bus indices that must become angular references.

VeraGridEngine.DataStructures.passive_branch_data module

class VeraGridEngine.DataStructures.passive_branch_data.PassiveBranchData(nelm: int, nbus: int)[source]

Bases: BranchParentData

Structure to host all branches data for calculation

B: ndarray[tuple[Any, ...], dtype[float64]]
B0: ndarray[tuple[Any, ...], dtype[float64]]
B2: ndarray[tuple[Any, ...], dtype[float64]]
G: ndarray[tuple[Any, ...], dtype[float64]]
G0: ndarray[tuple[Any, ...], dtype[float64]]
G2: ndarray[tuple[Any, ...], dtype[float64]]
R: ndarray[tuple[Any, ...], dtype[float64]]
R0: ndarray[tuple[Any, ...], dtype[float64]]
R2: ndarray[tuple[Any, ...], dtype[float64]]
X: ndarray[tuple[Any, ...], dtype[float64]]
X0: ndarray[tuple[Any, ...], dtype[float64]]
X2: ndarray[tuple[Any, ...], dtype[float64]]
Yff3
Yft3
Ytf3
Ytt3
compare(other: PassiveBranchData, tol: float, logger: Logger) → None[source]

Compare passive-branch fields used by NumericalCircuit.compare().

conn: ndarray[tuple[Any, ...], dtype[int64]]
conn_f: ndarray[tuple[Any, ...], dtype[int64]]
conn_t: ndarray[tuple[Any, ...], dtype[int64]]
copy() → PassiveBranchData[source]

Get a deep copy of this object :return: new BranchData instance

detect_superconductor_at(k) → None[source]

There is a beyond terrible practice of setting branches with R=0 and X=0 as β€œsuperconductor”…. Those must be reduced of course :param k: index

get_series_admittance() → ndarray[tuple[Any, ...], dtype[complex128]][source]

Get the series admittance of the branches :return: complex vector

m_taps
phA: ndarray[tuple[Any, ...], dtype[bool]]
phB: ndarray[tuple[Any, ...], dtype[bool]]
phC: ndarray[tuple[Any, ...], dtype[bool]]
phN: ndarray[tuple[Any, ...], dtype[bool]]
size() → int[source]

Get size of the structure :return:

slice(elm_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_map: ndarray[tuple[Any, ...], dtype[int64]], logger: Logger | None) → PassiveBranchData[source]

Slice branch data by given indices :param elm_idx: array of branch indices :param bus_idx: array of bus indices :param bus_map: map from bus index to island bus index {int(o): i for i, o in enumerate(bus_idx)} :param logger: Logger :return: new BranchData instance

tau_taps
virtual_tap_f: ndarray[tuple[Any, ...], dtype[float64]]
virtual_tap_t: ndarray[tuple[Any, ...], dtype[float64]]

VeraGridEngine.DataStructures.shunt_data module

class VeraGridEngine.DataStructures.shunt_data.ShuntData[source]

Bases: object

A_floating_star
B_floating_star
C_floating_star
Y: ndarray[tuple[Any, ...], dtype[complex128]]
Y3_delta
Y3_star
active: ndarray[tuple[Any, ...], dtype[bool]]
b_steps
bus_idx
compare(other: ShuntData, tol: float, logger: Logger) → None[source]

Compare shunt fields used by NumericalCircuit.compare().

control_mode_int: ndarray[tuple[Any, ...], dtype[int64]]
controllable_bus_idx
copy() → ShuntData[source]

Get deep copy of this structure :return: new ShuntData instance

cost: ndarray[tuple[Any, ...], dtype[float64]]
g_steps
get_C_bus_elm() → csc_matrix[source]

Get the connectivity matrix :return: CSC matrix

get_array_per_bus(arr: ndarray[tuple[Any, ...], dtype[float64]]) → ndarray[tuple[Any, ...], dtype[float64]][source]

Get generator array per bus :param arr: :return:

get_bus_indices() → ndarray[tuple[Any, ...], dtype[int64]][source]

Get the bus indices :return: array with the bus indices

get_controllable_and_not_controllable_indices() → Tuple[ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[int64]]][source]

Get the indices of controllable generators :return: idx_controllable, idx_non_controllable

get_fix_injections_per_bus() → ndarray[tuple[Any, ...], dtype[complex128]][source]

Get fixed Injections per bus :return:

get_injections_per_bus() → ndarray[tuple[Any, ...], dtype[complex128]][source]

Get Injections per bus :return:

get_qmax_per_bus() → ndarray[tuple[Any, ...], dtype[float64]][source]

Get generator Qmax per bus :return:

get_qmin_per_bus() → ndarray[tuple[Any, ...], dtype[float64]][source]

Get generator Qmin per bus :return:

grounds_neutral: ndarray[tuple[Any, ...], dtype[bool]]
idtag: ndarray[tuple[Any, ...], dtype[str_]]
mttf: ndarray[tuple[Any, ...], dtype[float64]]
mttr: ndarray[tuple[Any, ...], dtype[float64]]
names: ndarray[tuple[Any, ...], dtype[str_]]
nbus: int
nelm: int
original_idx: ndarray[tuple[Any, ...], dtype[int64]]
q_share: ndarray[tuple[Any, ...], dtype[float64]]
qmax: ndarray[tuple[Any, ...], dtype[float64]]
qmin: ndarray[tuple[Any, ...], dtype[float64]]
remap(bus_map_arr: ndarray[tuple[Any, ...], dtype[int64]])[source]

Remapping of the elm buses :param bus_map_arr: array of old-to-new buses

size() → int[source]

Get size of the structure :return:

slice(elm_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_map: ndarray[tuple[Any, ...], dtype[int64]]) → ShuntData[source]

Slice shunt data by given indices :param elm_idx: array of branch indices :param bus_idx: array of bus indices :param bus_map: map from bus index to branch index :return: new ShuntData instance

step
taps
vmax: ndarray[tuple[Any, ...], dtype[float64]]
vmin: ndarray[tuple[Any, ...], dtype[float64]]
vset: ndarray[tuple[Any, ...], dtype[float64]]

VeraGridEngine.DataStructures.vsc_data module

class VeraGridEngine.DataStructures.vsc_data.VscData(nelm: int, nbus: int)[source]

Bases: BranchParentData

VscData class provides a structured model for managing data related to Voltage Source Converters (VSC) in power grid simulations.

F_dcn
alpha1: ndarray[tuple[Any, ...], dtype[float64]]
alpha2: ndarray[tuple[Any, ...], dtype[float64]]
alpha3: ndarray[tuple[Any, ...], dtype[float64]]
control1_branch_idx: ndarray[tuple[Any, ...], dtype[int64]]
control1_bus_idx: ndarray[tuple[Any, ...], dtype[int64]]
control1_droop_val: ndarray[tuple[Any, ...], dtype[float64]]
control1_droop_val_max: ndarray[tuple[Any, ...], dtype[float64]]
control1_droop_val_min: ndarray[tuple[Any, ...], dtype[float64]]
control1_int: ndarray[tuple[Any, ...], dtype[int64]]
control1_val: ndarray[tuple[Any, ...], dtype[float64]]
control1_val_droop: ndarray[tuple[Any, ...], dtype[float64]]
control1_val_max: ndarray[tuple[Any, ...], dtype[float64]]
control1_val_min: ndarray[tuple[Any, ...], dtype[float64]]
control2_branch_idx: ndarray[tuple[Any, ...], dtype[int64]]
control2_bus_idx: ndarray[tuple[Any, ...], dtype[int64]]
control2_droop_val: ndarray[tuple[Any, ...], dtype[float64]]
control2_droop_val_max: ndarray[tuple[Any, ...], dtype[float64]]
control2_droop_val_min: ndarray[tuple[Any, ...], dtype[float64]]
control2_int: ndarray[tuple[Any, ...], dtype[int64]]
control2_val: ndarray[tuple[Any, ...], dtype[float64]]
control2_val_droop: ndarray[tuple[Any, ...], dtype[float64]]
control2_val_max: ndarray[tuple[Any, ...], dtype[float64]]
control2_val_min: ndarray[tuple[Any, ...], dtype[float64]]
copy() → VscData[source]

Get a deep copy of this object :return: new BranchData instance

fault_control_int: ndarray[tuple[Any, ...], dtype[int64]]
min_ac_voltage: ndarray[tuple[Any, ...], dtype[float64]]
slice(elm_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_idx: ndarray[tuple[Any, ...], dtype[int64]], bus_map: ndarray[tuple[Any, ...], dtype[int64]], logger: Logger | None) → VscData[source]

Slice branch data by given indices :param elm_idx: array of branch indices :param bus_idx: array of bus indices :param bus_map: map from bus index to branch index :param logger: Logger :return: new BranchData instance

ysvs: ndarray[tuple[Any, ...], dtype[float64]]

Module contents