VeraGridEngine.Simulations.OPF package

Subpackages

Submodules

VeraGridEngine.Simulations.OPF.ac_opf_worker module

VeraGridEngine.Simulations.OPF.ac_opf_worker.remap_original_bus_indices(n_bus, original_bus_idx: Sequence[int]) Tuple[ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[int64]]][source]

Get arrays of bus mappings :param n_bus: number of buses :param original_bus_idx: array of bus indices in the multi-island scheme :return: original_indices: array of bus indices in the multi-island that apply for this island,

island_indices: array of island indices that apply for this island

VeraGridEngine.Simulations.OPF.ac_opf_worker.run_nonlinear_opf(grid: ~VeraGridEngine.Devices.multi_circuit.MultiCircuit, opf_options: ~VeraGridEngine.Simulations.OPF.opf_options.OptimalPowerFlowOptions, t_idx: None | int = None, plot_error: bool = False, optimize_nodal_capacity: bool = False, nodal_capacity_sign: float = 1.0, capacity_nodes_idx: ~numpy.ndarray[tuple[~typing.Any, ...], ~numpy.dtype[~numpy.int64]] | None = None, logger: ~VeraGridEngine.basic_structures.Logger = <VeraGridEngine.basic_structures.Logger object>) NonlinearOPFResults[source]

Run optimal power flow for a MultiCircuit :param grid: MultiCircuit :param opf_options: OptimalPowerFlowOptions :param t_idx: Time index :param plot_error: Plot the error evolution :param optimize_nodal_capacity: :param nodal_capacity_sign: :param capacity_nodes_idx: :param logger: Logger object :return: NonlinearOPFResults

VeraGridEngine.Simulations.OPF.opf_driver module

class VeraGridEngine.Simulations.OPF.opf_driver.OptimalPowerFlowDriver(grid: MultiCircuit, options: OptimalPowerFlowOptions | None = None, engine: EngineType = VeraGrid)[source]

Bases: TimeSeriesDriverTemplate

add_report() None[source]

Add a report of the results (in-place)

all_solved
name = 'Optimal power flow'
opf(remote=False, batteries_energy_0=None) OptimalPowerFlowResults[source]

Run a power flow for every circuit :param remote: is this function being called from the time series? :param batteries_energy_0: initial state of the batteries, if None the default values are taken :return: OptimalPowerFlowResults object

options
property pf_options: PowerFlowOptions

Get the PowerFlow options provides with the OpfOptions :return: PowerFlowOptions

run()[source]
Returns:

tpe = 'Optimal power flow'

VeraGridEngine.Simulations.OPF.opf_options module

class VeraGridEngine.Simulations.OPF.opf_options.OptimalPowerFlowOptions[source]

Bases: OptionsTemplate

CLASS_NON_EDITABLE_PROPERTIES: Tuple[str, ...] = ('idtag', 'selected_to_merge', 'diff_changes')
CLASS_PROPERTIES_WITH_PROFILE: Dict[str, str] = {}
CLASS_PROPERTY_DECLARATIONS: Tuple[GCProp, ...] = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:selected_to_merge, prop:comment, prop:diff_changes, prop:verbose, prop:solver, prop:time_grouping, prop:zonal_grouping, prop:mip_solver, prop:dispatch_mode, prop:power_flow_options, prop:skip_generation_limits, prop:consider_contingencies, prop:contingency_groups_used, prop:lodf_tolerance, prop:add_losses_approximation, prop:use_glsk_as_cost, prop:inter_aggregation_info, prop:consider_ramps, prop:consider_time_up_down, prop:area_spinning_reserve, prop:report_formulation, prop:generate_report, prop:acopf_mode, prop:ips_method, prop:ips_tolerance, prop:ips_iterations, prop:ips_trust_radius, prop:ips_init_with_pf, prop:ips_control_q_limits, prop:robust, prop:acopf_v0, prop:acopf_S0)
CLASS_PROPERTY_LIST: Tuple[GCProp, ...] = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:selected_to_merge, prop:comment, prop:diff_changes, prop:verbose, prop:solver, prop:time_grouping, prop:zonal_grouping, prop:mip_solver, prop:dispatch_mode, prop:power_flow_options, prop:skip_generation_limits, prop:consider_contingencies, prop:contingency_groups_used, prop:lodf_tolerance, prop:add_losses_approximation, prop:use_glsk_as_cost, prop:inter_aggregation_info, prop:consider_ramps, prop:consider_time_up_down, prop:area_spinning_reserve, prop:report_formulation, prop:generate_report, prop:acopf_mode, prop:ips_method, prop:ips_tolerance, prop:ips_iterations, prop:ips_trust_radius, prop:ips_init_with_pf, prop:ips_control_q_limits, prop:robust, prop:acopf_v0, prop:acopf_S0)
CLASS_REGISTERED_PROPERTIES: Dict[str, GCProp] = {'acopf_S0': prop:acopf_S0, 'acopf_mode': prop:acopf_mode, 'acopf_v0': prop:acopf_v0, 'action': prop:action, 'add_losses_approximation': prop:add_losses_approximation, 'area_spinning_reserve': prop:area_spinning_reserve, 'code': prop:code, 'comment': prop:comment, 'consider_contingencies': prop:consider_contingencies, 'consider_ramps': prop:consider_ramps, 'consider_time_up_down': prop:consider_time_up_down, 'contingency_groups_used': prop:contingency_groups_used, 'diff_changes': prop:diff_changes, 'dispatch_mode': prop:dispatch_mode, 'generate_report': prop:generate_report, 'idtag': prop:idtag, 'inter_aggregation_info': prop:inter_aggregation_info, 'ips_control_q_limits': prop:ips_control_q_limits, 'ips_init_with_pf': prop:ips_init_with_pf, 'ips_iterations': prop:ips_iterations, 'ips_method': prop:ips_method, 'ips_tolerance': prop:ips_tolerance, 'ips_trust_radius': prop:ips_trust_radius, 'lodf_tolerance': prop:lodf_tolerance, 'mip_solver': prop:mip_solver, 'name': prop:name, 'power_flow_options': prop:power_flow_options, 'rdfid': prop:rdfid, 'report_formulation': prop:report_formulation, 'robust': prop:robust, 'selected_to_merge': prop:selected_to_merge, 'skip_generation_limits': prop:skip_generation_limits, 'solver': prop:solver, 'time_grouping': prop:time_grouping, 'use_glsk_as_cost': prop:use_glsk_as_cost, 'verbose': prop:verbose, 'zonal_grouping': prop:zonal_grouping}
LOCAL_PROPERTY_DECLARATIONS: Tuple[GCProp, ...] = (prop:verbose, prop:solver, prop:time_grouping, prop:zonal_grouping, prop:mip_solver, prop:dispatch_mode, prop:power_flow_options, prop:skip_generation_limits, prop:consider_contingencies, prop:contingency_groups_used, prop:lodf_tolerance, prop:add_losses_approximation, prop:use_glsk_as_cost, prop:inter_aggregation_info, prop:consider_ramps, prop:consider_time_up_down, prop:area_spinning_reserve, prop:report_formulation, prop:generate_report, prop:acopf_mode, prop:ips_method, prop:ips_tolerance, prop:ips_iterations, prop:ips_trust_radius, prop:ips_init_with_pf, prop:ips_control_q_limits, prop:robust, prop:acopf_v0, prop:acopf_S0)
action: ActionType
comment: str
device_type: DeviceType
diff_changes
selected_to_merge

VeraGridEngine.Simulations.OPF.opf_results module

class VeraGridEngine.Simulations.OPF.opf_results.OptimalPowerFlowResults(bus_names: ndarray[tuple[Any, ...], dtype[str_]], branch_names: ndarray[tuple[Any, ...], dtype[str_]], load_names: ndarray[tuple[Any, ...], dtype[str_]], generator_names: ndarray[tuple[Any, ...], dtype[str_]], shunt_like_names: ndarray[tuple[Any, ...], dtype[str_]], battery_names: ndarray[tuple[Any, ...], dtype[str_]], hvdc_names: ndarray[tuple[Any, ...], dtype[str_]], vsc_names: ndarray[tuple[Any, ...], dtype[str_]], bus_types: ndarray[tuple[Any, ...], dtype[int64]], area_names: ndarray[tuple[Any, ...], dtype[str_]], fluid_node_names: ndarray[tuple[Any, ...], dtype[str_]], fluid_path_names: ndarray[tuple[Any, ...], dtype[str_]], fluid_inj_names: ndarray[tuple[Any, ...], dtype[str_]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], F_hvdc: ndarray[tuple[Any, ...], dtype[int64]], T_hvdc: ndarray[tuple[Any, ...], dtype[int64]], bus_area_indices: ndarray[tuple[Any, ...], dtype[int64]])[source]

Bases: ResultsTemplate

CLASS_DATA_VARIABLES = {'F': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'Sbus': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'Sf': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'St': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'T': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'area_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'battery_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'battery_power': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'branch_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'bus_area_indices': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'bus_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'bus_shadow_prices': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'bus_types': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'contingency_flows_list': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'contingency_flows_slacks_list': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'contingency_indices_list': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'contingency_rates': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'converged': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'error': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_inj_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_injection_flow': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_node_current_level': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_node_flow_in': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_node_flow_out': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_node_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_node_p2x_flow': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_node_spillage': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_path_flow': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_path_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'generator_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'generator_power': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'generator_reactive_power': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'generator_shedding': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'hvdc_F': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'hvdc_Pf': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'hvdc_T': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'hvdc_loading': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'hvdc_losses': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'hvdc_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'load_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'load_power': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'load_shedding': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'load_shedding_cost': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'loading': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'losses': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'non_linear': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'overloads': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'overloads_cost': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'rates': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'shunt_like_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'shunt_like_reactive_power': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'tap_angle': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'tap_module': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'voltage': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'vsc_Pf': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'vsc_loading': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'vsc_losses': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'vsc_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>}
CLASS_RESULTS_DECLARATIONS = (<VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>)
LOCAL_RESULTS_DECLARATIONS = (<VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>)
Sbus
Sf
St
battery_names
battery_power
branch_names
bus_names
bus_shadow_prices
bus_types
contingency_flows_list
contingency_flows_slacks_list
contingency_indices_list
contingency_rates
converged
error
fluid_inj_names
fluid_injection_flow
fluid_node_current_level
fluid_node_flow_in
fluid_node_flow_out
fluid_node_names
fluid_node_p2x_flow
fluid_node_spillage
fluid_path_flow
fluid_path_names
generator_names
generator_power
generator_reactive_power
generator_shedding
get_batt_df() DataFrame[source]

Get a DataFrame with the battery results :return: DataFrame

get_branch_df() DataFrame[source]

Get a DataFrame with the branches results :return: DataFrame

get_bus_df() DataFrame[source]

Get a DataFrame with the buses results :return: DataFrame

get_gen_df() DataFrame[source]

Get a DataFrame with the generator results :return: DataFrame

get_hvdc_df() DataFrame[source]

Get a DataFrame with the battery results :return: DataFrame

hvdc_Pf
hvdc_loading
hvdc_losses
hvdc_names
load_names
load_power
load_shedding
load_shedding_cost
loading
losses
mdl(result_type) ResultsTable[source]

Plot the results :param result_type: type of results (string) :return: DataFrame of the results (or None if the result was not understood)

non_linear
overloads
overloads_cost
property phase_shift: ndarray[tuple[Any, ...], dtype[float64]]

Cover for old API :return: tap angles in rad

plot_bars_limit
rates
shunt_like_names
shunt_like_reactive_power
tap_angle
tap_module
voltage
vsc_Pf
vsc_loading
vsc_losses
vsc_names

VeraGridEngine.Simulations.OPF.opf_ts_driver module

class VeraGridEngine.Simulations.OPF.opf_ts_driver.OptimalPowerFlowTimeSeriesDriver(grid: MultiCircuit, options: OptimalPowerFlowOptions | None = None, time_indices: ndarray[tuple[Any, ...], dtype[int64]] | None = None, clustering_results: ClusteringResults | None = None, engine: EngineType = VeraGrid)[source]

Bases: TimeSeriesDriverTemplate

add_report(eps: float = 1e-06) None[source]

Add a report of the results (in-place)

all_solved
get_steps()[source]

Get time steps list of strings

name = 'Optimal power flow time series'
opf(remote=False, batteries_energy_0=None)[source]

Run a power flow for every circuit :param remote: is this function being called from the time series? :param batteries_energy_0: initial state of the batteries, if None the default values are taken :return: OptimalPowerFlowResults object

opf_by_groups() None[source]

Run the OPF by groups

options
property pf_options: PowerFlowOptions

Get the PowerFlow options provides with the OpfOptions :return: PowerFlowOptions

run()[source]
Returns:

run_greedy_dispatch()[source]
Returns:

run_greedy_dispatch_indices(time_indices: ndarray[tuple[Any, ...], dtype[int64]])[source]
Parameters:

time_indices

Returns:

run_linear_opf()[source]
Returns:

run_linear_opf_indices(time_indices: ndarray[tuple[Any, ...], dtype[int64]], energy_0: ndarray[tuple[Any, ...], dtype[float64]], fluid_level_0: ndarray[tuple[Any, ...], dtype[float64]])[source]
run_non_linear_opf()[source]
Returns:

run_nonlinear_opf_indices(time_indices: ndarray[tuple[Any, ...], dtype[int64]])[source]
Parameters:

time_indices

Returns:

tpe = 'Optimal power flow time series'

VeraGridEngine.Simulations.OPF.opf_ts_results module

class VeraGridEngine.Simulations.OPF.opf_ts_results.OptimalPowerFlowTimeSeriesResults(bus_names: StrVec, branch_names: StrVec, load_names: StrVec, generator_names: StrVec, battery_names: StrVec, shunt_like_names: StrVec, hvdc_names: StrVec, vsc_names: StrVec, fuel_names: StrVec, emission_names: StrVec, technology_names: StrVec, fluid_node_names: StrVec, fluid_path_names: StrVec, fluid_injection_names: StrVec, nt: int, time_array=None, bus_types=(), clustering_results: None | ClusteringResults = None)[source]

Bases: ResultsTemplate

Optimal power flow time series results

CLASS_DATA_VARIABLES = {'Sbus': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'Sf': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'St': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'battery_energy': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'battery_invested': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'battery_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'battery_power': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'branch_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'bus_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'bus_shadow_prices': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'bus_types': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'contingency_flows_list': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'contingency_flows_slacks_list': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'contingency_indices_list': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'contingency_rates': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'converged': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'emission_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_injection_flow': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_injection_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_node_current_level': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_node_flow_in': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_node_flow_out': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_node_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_node_p2x_flow': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_node_spillage': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_path_flow': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fluid_path_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'fuel_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'generator_cost': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'generator_invested': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'generator_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'generator_power': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'generator_producing': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'generator_reactive_power': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'generator_shedding': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'generator_shutting_down': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'generator_starting_up': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'hvdc_Pf': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'hvdc_loading': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'hvdc_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'load_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'load_power': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'load_shedding': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'load_shedding_cost': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'loading': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'losses': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'overloads': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'overloads_cost': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'power_by_technology': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'rates': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'shunt_like_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'shunt_like_reactive_power': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'system_emissions': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'system_energy_cost': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'system_fuel': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'system_total_energy_cost': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'tap_angle': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'tap_module': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'technology_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'voltage': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'vsc_Pf': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'vsc_loading': <VeraGridEngine.Simulations.results_template.ResultsProperty object>, 'vsc_names': <VeraGridEngine.Simulations.results_template.ResultsProperty object>}
CLASS_RESULTS_DECLARATIONS = (<VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>)
LOCAL_RESULTS_DECLARATIONS = (<VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>, <VeraGridEngine.Simulations.results_template.ResultsProperty object>)
Sbus
Sf
St
apply_new_time_series_rates(nc: NumericalCircuit)[source]
Parameters:

nc

battery_energy
battery_invested
battery_names
battery_power
branch_names
bus_names
bus_shadow_prices
bus_types
contingency_flows_list
contingency_flows_slacks_list
contingency_indices_list
contingency_rates
converged
emission_names
fluid_injection_flow
fluid_injection_names
fluid_node_current_level
fluid_node_flow_in
fluid_node_flow_out
fluid_node_names
fluid_node_p2x_flow
fluid_node_spillage
fluid_path_flow
fluid_path_names
fuel_names
generator_cost
generator_invested
generator_names
generator_power
generator_producing
generator_reactive_power
generator_shedding
generator_shutting_down
generator_starting_up
hvdc_Pf
hvdc_loading
hvdc_names
load_names
load_power
load_shedding
load_shedding_cost
loading
losses
mdl(result_type) ResultsTable[source]

Plot the results :param result_type: :return:

overloads
overloads_cost
property phase_shift: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]]

Cover for old API :return: tap angles in rad

power_by_technology
rates
set_at(t, res: OptimalPowerFlowResults)[source]

Set the results :param t: time index :param res: OptimalPowerFlowResults instance

shunt_like_names
shunt_like_reactive_power
system_emissions
system_energy_cost
system_fuel
system_total_energy_cost
tap_angle
tap_module
technology_names
voltage
vsc_Pf
vsc_loading
vsc_names

VeraGridEngine.Simulations.OPF.simple_dispatch_ts module

This file implements a DC-OPF for time series That means that solves the OPF problem for a complete time series at once

class VeraGridEngine.Simulations.OPF.simple_dispatch_ts.GreedyDispatchInputs(grid: ~VeraGridEngine.Devices.multi_circuit.MultiCircuit, time_indices: ~numpy.ndarray[tuple[~typing.Any, ...], ~numpy.dtype[~numpy.int64]] | None = None, logger: ~VeraGridEngine.basic_structures.Logger = <VeraGridEngine.basic_structures.Logger object>)[source]

Bases: object

class VeraGridEngine.Simulations.OPF.simple_dispatch_ts.GreedyDispatchInputsSnapshot(grid: MultiCircuit, logger: Logger = <VeraGridEngine.basic_structures.Logger object>)[source]

Bases: object

VeraGridEngine.Simulations.OPF.simple_dispatch_ts.greedy_dispatch(load_profile: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_profile: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_p_max: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_p_min: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_dispatchable: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_active: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_cost: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_active: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_p_max_charge: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_p_max_discharge: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_energy_max: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_eff_charge: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_eff_discharge: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_cost: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_soc0: ndarray[tuple[Any, ...], dtype[float64]], batt_soc_min: ndarray[tuple[Any, ...], dtype[float64]], dt: ndarray[tuple[Any, ...], dtype[float64]], force_charge_if_low: bool, tol=1e-06)[source]

Greedy dispatch algorithm with dispatchable and non-dispatchable (e.g., renewable) generators. :param load_profile: ndarray (T, L) - Load time series per timestep and load element. :param gen_profile: ndarray (T, G) - Precomputed generator output (for renewables or constraints). :param gen_p_max: ndarray (T, G) - array of generators maximum power :param gen_p_min: ndarray (T, G) - array of generators minimum power :param gen_dispatchable: ndarray (T, G) - Boolean flag per generator (True if dispatchable). :param gen_active: ndarray (T, G) - Boolean array indicating whether each generator is active. :param gen_cost: ndarray (T, G) - Generator cost profile per timestep. :param batt_active: ndarray (T, B) - Battery active states. :param batt_p_max_charge: ndarray (T, B) - Battery charge limits. :param batt_p_max_discharge: ndarray (T, B) - Battery discharge limits. :param batt_energy_max: ndarray (T, B) - Battery energy capacity. :param batt_eff_charge: ndarray (T, B) - Battery efficiencies. :param batt_eff_discharge: ndarray (T, B) - Battery efficiencies. :param batt_cost (T, B) - Battery costs of discharge :param batt_soc0: ndarray (B,) - Initial SOC. :param batt_soc_min: ndarray (B) - Battery minimum state of charge :param dt: float - Timestep duration [h]. :param force_charge_if_low: Force to charge if low? :param tol: Tolerance (numerical zero) :return:

dispatch_gen : ndarray (T, G) dispatch_batt : ndarray (T, B) soc : ndarray (T, B) total_cost : float

VeraGridEngine.Simulations.OPF.simple_dispatch_ts.greedy_dispatch2(load_profile: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_profile: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_p_max: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_p_min: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_dispatchable: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_active: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], gen_cost: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_active: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_p_max_charge: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_p_max_discharge: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_energy_max: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_eff_charge: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_eff_discharge: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_cost: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], batt_soc0: ndarray[tuple[Any, ...], dtype[float64]], batt_soc_min: ndarray[tuple[Any, ...], dtype[float64]], dt: ndarray[tuple[Any, ...], dtype[float64]], force_charge_if_low: bool, tol=1e-06)[source]

Greedy dispatch algorithm with dispatchable and non-dispatchable (e.g., renewable) generators.

(A) non-dispatchable gens β†’ (B) battery discharge β†’ (C) dispatchable gens β†’ (D) charge batteries from NDG excess

(and, if force_charge_if_low=True, allow charging even with no excess for depleted batteries).

Parameters:
  • load_profile – ndarray (T, L) - Load time series per timestep and load element.

  • gen_profile – ndarray (T, G) - Precomputed generator output (for renewables or constraints).

  • gen_p_max – ndarray (T, G) - array of generators maximum power

  • gen_p_min – ndarray (T, G) - array of generators minimum power

  • gen_dispatchable – ndarray (T, G) - Boolean flag per generator (True if dispatchable).

  • gen_active – ndarray (T, G) - Boolean array indicating whether each generator is active.

  • gen_cost – ndarray (T, G) - Generator cost profile per timestep.

  • batt_active – ndarray (T, B) - Battery active states.

  • batt_p_max_charge – ndarray (T, B) - Battery charge limits.

  • batt_p_max_discharge – ndarray (T, B) - Battery discharge limits.

  • batt_energy_max – ndarray (T, B) - Battery energy capacity.

  • batt_eff_charge – ndarray (T, B) - Battery efficiencies.

  • batt_eff_discharge – ndarray (T, B) - Battery efficiencies.

:param batt_cost (T, B) - Battery costs of discharge :param batt_soc0: ndarray (B,) - Initial SOC. :param batt_soc_min: ndarray (B) - Battery minimum state of charge :param dt: float - Timestep duration [h]. :param force_charge_if_low: Force to charge if low? :param tol: Tolerance (numerical zero) :return:

dispatch_gen : ndarray (T, G) dispatch_batt : ndarray (T, B) soc : ndarray (T, B) total_cost : float load_not_supplied: load_shedding: ndg_surplus_after_batt, ndg_curtailment_per_gen (T, G)

VeraGridEngine.Simulations.OPF.simple_dispatch_ts.run_greedy_dispatch_ts(grid: MultiCircuit, time_indices: ndarray[tuple[Any, ...], dtype[int64]] | None, logger: Logger, text_prog=None, prog_func=None) Tuple[ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], GreedyDispatchInputs][source]

Run a simple (greedy) dispatch :param grid: MultiCircuit :param time_indices: array of time indices (optional) :param logger: Logger :param text_prog: text report function (optional) :param prog_func: progress report function (optional) :return:

VeraGridEngine.Simulations.OPF.simple_dispatch_ts.run_simple_dispatch(grid: MultiCircuit, text_prog=None, prog_func=None) Tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]][source]

Simple generation dispatch for the snapshot :param grid: MultiCircuit instance :param text_prog: text report function :param prog_func: progress report function :return Pl, Pg

Module contents