VeraGridEngine.Simulations.OPF.Formulations packageο
Submodulesο
VeraGridEngine.Simulations.OPF.Formulations.ac_opf_problem moduleο
- class VeraGridEngine.Simulations.OPF.Formulations.ac_opf_problem.NonLinearOptimalPfProblem(nc: NumericalCircuit, options: OptimalPowerFlowOptions, logger: Logger, pf_init: bool = True, Sbus_pf: ndarray[tuple[Any, ...], dtype[complex128]] | None = None, voltage_pf: ndarray[tuple[Any, ...], dtype[complex128]] | None = None, optimize_nodal_capacity: bool = False, nodal_capacity_sign: float = 1.0, capacity_nodes_idx: ndarray[tuple[Any, ...], dtype[int64]] | None = None)[source]ο
Bases:
object- Cdispgenο
- Cdispgen_shο
- Cdispgen_sh_tο
- Cdispgen_tο
- Cfmonο
- Cfmon_tο
- Ctmonο
- Ctmon_tο
- F_vscο
- Inomο
- It_vscο
- NVο
- P_hvdc_maxο
- Pf_nondispο
- Pf_vscο
- Pfdcο
- Pgο
- Pg_maxο
- Pg_minο
- Pt_vscο
- Qgο
- Qg_maxο
- Qg_minο
- Qsh_maxο
- Qsh_minο
- Qt_vscο
- Rο
- Sbaseο
- Scalcο
- Sdο
- Sfο
- Sf2ο
- Sg_undisο
- Stο
- St2ο
- T_vscο
- Vο
- Vaο
- Va_maxο
- Va_minο
- Vmο
- Vm_maxο
- Vm_minο
- Xο
- Ybus_colsο
- Ybus_diag_posο
- Ybus_indicesο
- Ybus_indptrο
- ac_bus_idxο
- admittancesο
- allSfο
- allStο
- all_tap_mο
- all_tap_tauο
- analyze_branch_controls() None[source]ο
Analyze the control branches and compute the indices :return: None
- br_idxο
- br_mon_idxο
- c0ο
- c0nο
- c1ο
- c1nο
- c2ο
- c2nο
- c_sο
- c_vο
- c_vscο
- capacity_nodes_idxο
- compute_branch_power_derivatives() Tuple[csr_matrix, lil_matrix, lil_matrix, csr_matrix, lil_matrix, lil_matrix][source]ο
TODO: Move outside of the class :return: First power derivatives with respect to the tap variables
[dSbusdm, dSfdm, dStdm, dSbusdt, dSfdtau, dStdtau]
- compute_branch_power_second_derivatives(lam: ndarray[tuple[Any, ...], dtype[float64]], mu: ndarray[tuple[Any, ...], dtype[float64]]) Tuple[lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix, lil_matrix][source]ο
TODO: Move outside of the class :param lam: Lambda multiplier :param mu: Mu multiplier :return: Power second derivatives with respect to tap variables
- dc_bus_idxο
- f_disp_hvdcο
- f_nd_hvdcο
- from_idxο
- gen_bus_idxο
- gen_disp_idxο
- gen_disp_idx_shο
- gen_nondisp_idxο
- get_jacobians_and_hessians(mu: ndarray[tuple[Any, ...], dtype[float64]], lam: ndarray[tuple[Any, ...], dtype[float64]], compute_hessians: bool) Tuple[ndarray[tuple[Any, ...], dtype[float64]], csc_matrix, csc_matrix, csc_matrix, csc_matrix, csc_matrix][source]ο
- TODO: we should split this function into functions outside the class, that should make it more manageable
one for each of these: fx, Gx, Hx, fxx, Gxx, Hxx, and leave this function just to call them
- Parameters:
mu
lam
compute_hessians
- Returns:
fx, Gx, Hx, fxx, Gxx, Hxx
- get_solution(ips_results: IpsSolution, verbose: int = 0, plot_error: bool = False)[source]ο
- Parameters:
ips_results
verbose
plot_error
- Returns:
- hvdc_disp_idxο
- hvdc_nondisp_idxο
- id_Vm_max0ο
- id_Vm_min0ο
- id_shο
- ind_gensο
- indicesο
- k_mο
- k_mtauο
- k_tauο
- loggerο
- n_br_monο
- n_dc_busο
- n_disp_hvdcο
- n_gen_dispο
- n_gen_disp_shο
- n_sl_vscο
- n_slackο
- n_vsc_limο
- n_vsc_varsο
- nbrο
- nbusο
- ncο
- neqο
- ngenο
- nineqο
- nodal_capacity_signο
- npqο
- npvο
- nshο
- nslο
- nslcapο
- ntapmο
- ntaptο
- nvscο
- optimize_nodal_capacityο
- optionsο
- pfο
- pqο
- pvο
- ratesο
- rates2ο
- resultsο
- sh_bus_idxο
- sl_sfο
- sl_stο
- sl_vmaxο
- sl_vminο
- sl_vscο
- slackο
- slackgensο
- slcapο
- slcap0ο
- t_disp_hvdcο
- t_nd_hvdcο
- tanmaxο
- tap_mο
- tap_tauο
- tapm_maxο
- tapm_minο
- tapt_maxο
- tapt_minο
- to_idxο
- update(x: ndarray[tuple[Any, ...], dtype[float64]]) Tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]][source]ο
- vsc_alpha1ο
- vsc_alpha2ο
- vsc_alpha3ο
- vsc_idxο
- vsc_lim_idxο
- vsc_rate_puο
- x0ο
- class VeraGridEngine.Simulations.OPF.Formulations.ac_opf_problem.NonlinearOPFResults(Va: ndarray[tuple[Any, ...], dtype[float64]] = None, Vm: ndarray[tuple[Any, ...], dtype[float64]] = None, S: ndarray[tuple[Any, ...], dtype[complex128]] = None, Sf: ndarray[tuple[Any, ...], dtype[complex128]] = None, St: ndarray[tuple[Any, ...], dtype[complex128]] = None, loading: ndarray[tuple[Any, ...], dtype[float64]] = None, Pg: ndarray[tuple[Any, ...], dtype[float64]] = None, Qg: ndarray[tuple[Any, ...], dtype[float64]] = None, Qsh: ndarray[tuple[Any, ...], dtype[float64]] = None, Pcost: ndarray[tuple[Any, ...], dtype[float64]] = None, tap_module: ndarray[tuple[Any, ...], dtype[float64]] = None, tap_phase: ndarray[tuple[Any, ...], dtype[float64]] = None, hvdc_Pf: ndarray[tuple[Any, ...], dtype[float64]] = None, hvdc_loading: ndarray[tuple[Any, ...], dtype[float64]] = None, vsc_Pt: ndarray[tuple[Any, ...], dtype[float64]] = None, vsc_Qt: ndarray[tuple[Any, ...], dtype[float64]] = None, vsc_Pf: ndarray[tuple[Any, ...], dtype[float64]] = None, vsc_It: ndarray[tuple[Any, ...], dtype[float64]] = None, vsc_loading: ndarray[tuple[Any, ...], dtype[float64]] = None, lam_p: ndarray[tuple[Any, ...], dtype[float64]] = None, lam_q: ndarray[tuple[Any, ...], dtype[float64]] = None, sl_sf: ndarray[tuple[Any, ...], dtype[float64]] = None, sl_st: ndarray[tuple[Any, ...], dtype[float64]] = None, sl_vmax: ndarray[tuple[Any, ...], dtype[float64]] = None, sl_vmin: ndarray[tuple[Any, ...], dtype[float64]] = None, nodal_capacity: ndarray[tuple[Any, ...], dtype[float64]] = None, error: float = None, converged: bool = None, iterations: int = None, voltage: ndarray[tuple[Any, ...], dtype[complex128]] = None)[source]ο
Bases:
objectNumerical non linear OPF results
- Pcost: ndarray[tuple[Any, ...], dtype[float64]]ο
- Pg: ndarray[tuple[Any, ...], dtype[float64]]ο
- Qg: ndarray[tuple[Any, ...], dtype[float64]]ο
- Qsh: ndarray[tuple[Any, ...], dtype[float64]]ο
- S: ndarray[tuple[Any, ...], dtype[complex128]]ο
- Sf: ndarray[tuple[Any, ...], dtype[complex128]]ο
- St: ndarray[tuple[Any, ...], dtype[complex128]]ο
- property V: ndarray[tuple[Any, ...], dtype[complex128]]ο
Complex voltage :return: CxVec
- Va: ndarray[tuple[Any, ...], dtype[float64]]ο
- Vm: ndarray[tuple[Any, ...], dtype[float64]]ο
- converged: boolο
- error: floatο
- hvdc_Pf: ndarray[tuple[Any, ...], dtype[float64]]ο
- hvdc_loading: ndarray[tuple[Any, ...], dtype[float64]]ο
- initialize(nbus: int, nbr: int, nil: int, nsh: int, ng: int, nhvdc: int, ncap: int, nvsc: int = 0)[source]ο
Initialize the arrays :param nbus: number of buses :param nbr: number of branches :param nsh: number of controllable shunt elements :param ng: number of generators :param nhvdc: number of HVDCs :param ncap: number of nodal capacity nodes :param nvsc: number of VSCs
- iterations: intο
- lam_p: ndarray[tuple[Any, ...], dtype[float64]]ο
- lam_q: ndarray[tuple[Any, ...], dtype[float64]]ο
- loading: ndarray[tuple[Any, ...], dtype[float64]]ο
- merge(other: NonlinearOPFResults, bus_idx: ndarray[tuple[Any, ...], dtype[int64]], br_idx: ndarray[tuple[Any, ...], dtype[int64]], il_idx: ndarray[tuple[Any, ...], dtype[int64]], gen_idx: ndarray[tuple[Any, ...], dtype[int64]], hvdc_idx: ndarray[tuple[Any, ...], dtype[int64]], ncap_idx: ndarray[tuple[Any, ...], dtype[int64]], contshunt_idx: ndarray[tuple[Any, ...], dtype[int64]], acopf_mode, vsc_idx: ndarray[tuple[Any, ...], dtype[int64]] = None)[source]ο
- Parameters:
other
bus_idx
br_idx
il_idx
gen_idx
hvdc_idx
ncap_idx
contshunt_idx
acopf_mode
- Returns:
- nodal_capacity: ndarray[tuple[Any, ...], dtype[float64]]ο
- sl_sf: ndarray[tuple[Any, ...], dtype[float64]]ο
- sl_st: ndarray[tuple[Any, ...], dtype[float64]]ο
- sl_vmax: ndarray[tuple[Any, ...], dtype[float64]]ο
- sl_vmin: ndarray[tuple[Any, ...], dtype[float64]]ο
- tap_module: ndarray[tuple[Any, ...], dtype[float64]]ο
- tap_phase: ndarray[tuple[Any, ...], dtype[float64]]ο
- voltage: ndarray[tuple[Any, ...], dtype[complex128]]ο
- vsc_It: ndarray[tuple[Any, ...], dtype[float64]]ο
- vsc_Pf: ndarray[tuple[Any, ...], dtype[float64]]ο
- vsc_Pt: ndarray[tuple[Any, ...], dtype[float64]]ο
- vsc_Qt: ndarray[tuple[Any, ...], dtype[float64]]ο
- vsc_loading: ndarray[tuple[Any, ...], dtype[float64]]ο
VeraGridEngine.Simulations.OPF.Formulations.linear_opf_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.Formulations.linear_opf_ts.BatteryVars(nt: int, n_elm: int)[source]ο
Bases:
GenerationVarsstruct extending the generation vars to handle the battery vars
- get_values(Sbase: float, model: PulpLpModel | None, gen_emissions_rates_matrix: csc_matrix = None, gen_fuel_rates_matrix: csc_matrix = None) BatteryVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :return: GenerationVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.BranchVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the branch related vars
- add_contingency_flow(t: int, m: int, c: int, flow_var: float | LpVariable | None | LpAffineExpression, neg_slack: LpVariable | None, pos_slack: LpVariable | None)[source]ο
Add contingency flow :param t: time index :param m: monitored index :param c: contingency group index :param flow_var: flow var :param neg_slack: negative flow slack variable :param pos_slack: positive flow slack variable
- get_values(Sbase: float, model: PulpLpModel | None) BranchVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :return: BranchVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.BusVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the bus related vars
- get_values(Sbase: float, model: PulpLpModel | None) BusVars[source]ο
Return an instance of this class where the arrayβs content is not LP vars but their value :return: BusVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.FluidInjectionVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the vars of injections of fluid type
- get_values(model: PulpLpModel | None) FluidInjectionVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :param model: LP model from where we extract the values :return: FluidInjectionVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.FluidNodeVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the vars of nodes of fluid type
- get_values(model: PulpLpModel | None) FluidNodeVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :param model: LP model from where we extract the values :return: FluidNodeVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.FluidPathVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the vars of paths of fluid type
- get_values(model: PulpLpModel | None) FluidPathVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :param model: LP model from where we extract the values :return: FluidPathVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.GenerationVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the generation vars
- get_values(Sbase: float, model: PulpLpModel | None, gen_emissions_rates_matrix: csc_matrix, gen_fuel_rates_matrix: csc_matrix) GenerationVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :param Sbase: Base power (100 MVA) :param model: LpModel :param gen_emissions_rates_matrix: emissins rates matrix (n_emissions, n_gen) :param gen_fuel_rates_matrix: fuel rates matrix (n_fuels, n_gen) :return: GenerationVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.HvdcVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the generation vars
- get_values(Sbase: float, model: PulpLpModel | None) HvdcVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :return: HvdcVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.LoadVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the load related vars
- get_values(Sbase: float, model: PulpLpModel | None) LoadVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :return: LoadVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.NodalCapacityVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the nodal capacity related vars
- get_values(Sbase: float, model: PulpLpModel | None) NodalCapacityVars[source]ο
Return an instance of this class where the arrayβs content is not LP vars but their value :return: BusVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.OpfVars(nt: int, nbus: int, ng: int, nb: int, nl: int, nbr: int, n_hvdc: int, n_vsc: int, n_fluid_node: int, n_fluid_path: int, n_fluid_inj: int, n_cap_buses: int)[source]ο
Bases:
objectStructure to host the opf variables
- get_values(Sbase: float, model: PulpLpModel | None, gen_emissions_rates_matrix: csc_matrix, gen_fuel_rates_matrix: csc_matrix, gen_tech_shares_matrix: csc_matrix, batt_tech_shares_matrix: csc_matrix) OpfVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :return: OpfVars instance
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.SystemVars(nt: int)[source]ο
Bases:
objectStruct to store the system vars
- compute(gen_emissions_rates_matrix: csc_matrix, gen_fuel_rates_matrix: csc_matrix, gen_tech_shares_matrix: csc_matrix, batt_tech_shares_matrix: csc_matrix, gen_p: 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_p: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], shedding_cost: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]])[source]ο
Compute the system values :param gen_emissions_rates_matrix: emissions rates matrix (n_emissions, n_gen) :param gen_fuel_rates_matrix: fuel rates matrix (n_fuels, n_gen) :param gen_tech_shares_matrix: technology shares of the generators :param batt_tech_shares_matrix technology shares of the batteries :param gen_p: Generation power values (nt, ngen) :param gen_cost: Generation cost values (nt, ngen) :param batt_p: Battery power values (nt, nbatt) :param shedding_cost: Shedding cost values (nt, ngen)
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.VscVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the generation vars
- get_values(Sbase: float, model: PulpLpModel | None) HvdcVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :return: HvdcVars
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_copper_plate_balance(t_idx: int, bus_vars: BusVars, prob: PulpLpModel | None)[source]ο
Add the copperplate equality :param t_idx: time step :param bus_vars: BusVars :param prob: LpModel
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_hydro_formulation(t: int | None, time_global_tidx: int | None, time_array: DatetimeIndex, Sbase: float, node_vars: FluidNodeVars, path_vars: FluidPathVars, inj_vars: FluidInjectionVars, node_data: FluidNodeData, path_data: FluidPathData, turbine_data: FluidTurbineData, pump_data: FluidPumpData, p2x_data: FluidP2XData, generator_data: GeneratorData, generator_vars: GenerationVars, fluid_level_0: ndarray[tuple[Any, ...], dtype[float64]], prob: PulpLpModel | None, logger: Logger)[source]ο
Formulate the branches :param t: local time index :param time_global_tidx: global time index :param time_array: list of time indices :param Sbase: base power of the system :param node_vars: FluidNodeVars :param path_vars: FluidPathVars :param inj_vars: FluidInjectionVars :param node_data: FluidNodeData :param path_data: FluidPathData :param turbine_data: FluidTurbineData :param pump_data: FluidPumpData :param p2x_data: FluidP2XData :param generator_data: GeneratorData :param generator_vars: GeneratorVars :param fluid_level_0: Initial node level :param prob: OR problem :param logger: log of the LP :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_linear_battery_formulation(t: int | None, Sbase: float, time_array: DatetimeIndex, bus_vars: BusVars, batt_data_t: BatteryData, batt_vars: BatteryVars, prob: PulpLpModel | None, unit_commitment: bool, ramp_constraints: bool, skip_generation_limits: bool, generation_expansion_planning: bool, energy_0: ndarray[tuple[Any, ...], dtype[float64]])[source]ο
Add MIP generation formulation :param t: time step, if None we assume single time step :param Sbase: base power (100 MVA) :param time_array: complete time array :param bus_vars: BusVars :param batt_data_t: BatteryData structure :param batt_vars: BatteryVars structure :param prob: ORTools problem :param unit_commitment: formulate unit commitment? :param ramp_constraints: formulate ramp constraints? :param skip_generation_limits: skip the generation limits? :param generation_expansion_planning: generation expansion planning? :param energy_0: initial value of the energy stored :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_linear_branches_contingencies_formulation(t_idx: int, Sbase: float, branch_data_t: PassiveBranchData, hvdc_vars: HvdcVars, vsc_vars: VscVars, branch_vars: BranchVars, bus_vars: BusVars, prob: PulpLpModel | None, linear_multi_contingencies: LinearMultiContingencies)[source]ο
Formulate the branches :param t_idx: time index :param Sbase: base power (100 MVA) :param branch_data_t: BranchData :param hvdc_vars: HvdcVars :param vsc_vars: VscVars :param branch_vars: BranchVars :param bus_vars: BusVars :param prob: OR problem :param linear_multi_contingencies: LinearMultiContingencies :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_linear_branches_formulation(t: int, Sbase: float, bus_data_t: BusData, branch_data_t: PassiveBranchData, ctrl_branch_data_t: ActiveBranchData, branch_vars: BranchVars, bus_vars: BusVars, prob: PulpLpModel | None, inf=1e+20, add_losses_approximation: bool = False)[source]ο
Formulate the branches :param t: time index :param Sbase: base power (100 MVA) :param bus_data_t: BusData :param branch_data_t: BranchData :param ctrl_branch_data_t: ControllableBranchData :param branch_vars: BranchVars :param bus_vars: BusVars :param prob: OR problem :param inf: number considered infinite :param add_losses_approximation: If true the distribution factors losses approximation is used :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_linear_generation_expansion_planning_formulation(local_t: int | None, Sbase: float, time_array: DatetimeIndex, bus_vars: BusVars, gen_data_t: GeneratorData, gen_vars: GenerationVars, prob: PulpLpModel | None, ramp_constraints: bool, skip_generation_limits: bool, use_glsk_as_cost: bool, logger: Logger) LpAffineExpression | None | float[source]ο
Add MIP generation formulation :param local_t: time step :param Sbase: base power (100 MVA) :param time_array: complete time array :param bus_vars: BusVars :param gen_data_t: GeneratorData structure :param gen_vars: GenerationVars structure :param prob: LpModel :param ramp_constraints: formulate ramp constraints? :param skip_generation_limits: skip the generation limits? :param generation_expansion_planning: generation expansion plan? :param use_glsk_as_cost: if true, the GLSK values are used instead of the traditional costs :param logger: Logger object :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_linear_generation_redispatch_formulation(local_t: int | None, Sbase: float, bus_vars: BusVars, gen_data_t: GeneratorData, gen_vars: GenerationVars, prob: PulpLpModel | None, inter_aggregation_info: InterAggregationInfo, skip_generation_limits: bool, use_glsk_as_cost: bool, logger: Logger) LpAffineExpression | None | float[source]ο
Add MIP generation redispatch formulation the main difference is that Pg = P + dP dP >= 0 for generators in A1 (sending), dP <= 0 for generators in A2 (receiving), :param local_t: time step :param Sbase: base power (100 MVA) :param bus_vars: BusVars :param gen_data_t: GeneratorData structure :param gen_vars: GenerationVars structure :param prob: LpModel :param inter_aggregation_info: :param skip_generation_limits: skip the generation limits? :param use_glsk_as_cost: if true, the GLSK values are used instead of the traditional costs :param logger: Logger object :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_linear_generation_unit_commitment_formulation(local_t: int | None, Sbase: float, time_array: DatetimeIndex, bus_vars: BusVars, gen_data_t: GeneratorData, gen_vars: GenerationVars, prob: PulpLpModel | None, ramp_constraints: bool, consider_time_up_down: bool, area_spinning_reserve: bool, skip_generation_limits: bool, use_glsk_as_cost: bool, logger: Logger) LpAffineExpression | None | float[source]ο
Add MIP generation formulation :param local_t: time step :param Sbase: base power (100 MVA) :param time_array: complete time array :param bus_vars: BusVars :param gen_data_t: GeneratorData structure :param gen_vars: GenerationVars structure :param prob: LpModel :param ramp_constraints: formulate ramp constraints? :param consider_time_up_down: consider time up/down? :param area_spinning_reserve: area spinning reserve? :param skip_generation_limits: skip the generation limits? :param use_glsk_as_cost: if true, the GLSK values are used instead of the traditional costs :param logger: Logger object :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_linear_hvdc_formulation(t: int, Sbase: float, hvdc_data_t: HvdcData, hvdc_vars: HvdcVars, bus_vars: BusVars, prob: PulpLpModel | None, logger: Logger)[source]ο
- Parameters:
t
Sbase
hvdc_data_t
hvdc_vars
bus_vars
prob
logger
- Returns:
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_linear_load_formulation(t: int | None, Sbase: float, bus_vars: BusVars, load_data_t: LoadData, load_vars: LoadVars, prob: PulpLpModel | None)[source]ο
Add MIP generation formulation :param t: time step, if None we assume single time step :param Sbase: base power (100 MVA) :param bus_vars: BusVars :param load_data_t: BatteryData structure :param load_vars: BatteryVars structure :param prob: ORTools problem :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_linear_nodal_capacity_generation_formulation(local_t: int | None, Sbase: float, time_array: DatetimeIndex, bus_vars: BusVars, gen_data_t: GeneratorData, gen_vars: GenerationVars, prob: PulpLpModel | None, skip_generation_limits: bool, vd: ndarray[tuple[Any, ...], dtype[int64]], nodal_capacity_active: bool, use_glsk_as_cost: bool, logger: Logger) LpAffineExpression | None | float[source]ο
Add MIP generation formulation :param local_t: time step :param Sbase: base power (100 MVA) :param time_array: complete time array :param bus_vars: BusVars :param gen_data_t: GeneratorData structure :param gen_vars: GenerationVars structure :param prob: LpModel :param skip_generation_limits: skip the generation limits? :param vd: slack indices :param nodal_capacity_active: nodal capacity active? :param use_glsk_as_cost: if true, the GLSK values are used instead of the traditional costs :param logger: Logger object :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_linear_node_balance(t_idx: int, vd: ndarray[tuple[Any, ...], dtype[int64]], bus_data: BusData, bus_vars: BusVars, nodal_capacity_vars: NodalCapacityVars, capacity_nodes_idx: ndarray[tuple[Any, ...], dtype[int64]], prob: PulpLpModel | None, logger: Logger)[source]ο
Add the Kirchhoff nodal equality :param t_idx: time step :param vd: List of slack node indices :param bus_data: BusData :param bus_vars: BusVars :param nodal_capacity_vars: NodalCapacityVars :param capacity_nodes_idx: IntVec :param prob: LpModel :param logger: Logger
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_linear_simple_generation_formulation(local_t: int | None, Sbase: float, time_array: DatetimeIndex, bus_vars: BusVars, gen_data_t: GeneratorData, gen_vars: GenerationVars, prob: PulpLpModel | None, ramp_constraints: bool, consider_time_up_down: bool, area_spinning_reserve: bool, skip_generation_limits: bool, use_glsk_as_cost: bool, logger: Logger) LpAffineExpression | None | float[source]ο
Add MIP generation formulation :param local_t: time step :param Sbase: base power (100 MVA) :param time_array: complete time array :param bus_vars: BusVars :param gen_data_t: GeneratorData structure :param gen_vars: GenerationVars structure :param prob: LpModel :param ramp_constraints: formulate ramp constraints? :param consider_time_up_down: consider time up/down? :param area_spinning_reserve: area spinning reserve? :param skip_generation_limits: skip the generation limits? :param use_glsk_as_cost: if true, the GLSK values are used instead of the traditional costs :param logger: Logger object :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_linear_vsc_formulation(t: int, Sbase: float, vsc_data_t: VscData, vsc_vars: VscVars, bus_vars: BusVars, prob: PulpLpModel | None, logger: Logger)[source]ο
- Parameters:
t
Sbase
vsc_data_t
vsc_vars
bus_vars
prob
logger
- Returns:
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.add_nodal_capacity_formulation(t: int | None, nodal_capacity_vars: NodalCapacityVars, nodal_capacity_sign: float, capacity_nodes_idx: ndarray[tuple[Any, ...], dtype[int64]], prob: PulpLpModel | None)[source]ο
Add MIP generation formulation :param t: time step, if None we assume single time step :param nodal_capacity_vars: NodalCapacityVars structure :param nodal_capacity_sign: :param capacity_nodes_idx: IntVec :param prob: ORTools problem :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.get_contingency_flow_with_filter(multi_contingency: LinearMultiContingency, base_flow: ndarray[tuple[Any, ...], dtype[float64]], injections: None | ndarray[tuple[Any, ...], dtype[float64]], threshold: float, m: int) LpAffineExpression | None[source]ο
Get contingency flow :param multi_contingency: MultiContingency object :param base_flow: Base branch flows (nbranch) :param injections: Bus injections increments (nbus) :param threshold: threshold to filter contingency elements :param m: branch monitor index (int) :return: New flows (nbranch)
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.pmode3_formulation_impr(prob: PulpLpModel | None, elm_idx: int, t_idx: int, m: float, rate: float, P0: float, droop: float, theta_f: LpVariable | None, theta_t: LpVariable | None, base_name: str, logger: Logger)[source]ο
Formulation for HVDC link with three operating regions using big-M and binary variables. :param prob: :param elm_idx: :param t_idx: :param m: :param rate: :param P0: :param droop: :param theta_f: :param theta_t: :param base_name: :param logger: :return:
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts.run_linear_opf_ts(grid: ~VeraGridEngine.Devices.multi_circuit.MultiCircuit, time_indices: ~numpy.ndarray[tuple[~typing.Any, ...], ~numpy.dtype[~numpy.int64]] | None, dispatch_mode: ~VeraGridEngine.enumerations.OpfDispatchMode = Normal, solver_type: ~VeraGridEngine.enumerations.MIPSolvers = HIGHS, zonal_grouping: ~VeraGridEngine.enumerations.ZonalGrouping = No grouping, skip_generation_limits: bool = False, consider_contingencies: bool = False, contingency_groups_used: ~typing.List[~VeraGridEngine.Devices.Events.contingency_group.ContingencyGroup] | None = None, ramp_constraints: bool = False, consider_time_up_down: bool = False, area_spinning_reserve: bool = False, lodf_threshold: float = 0.001, inter_aggregation_info: ~VeraGridEngine.Devices.Aggregation.inter_aggregation_info.InterAggregationInfo | None = None, energy_0: ~numpy.ndarray[tuple[~typing.Any, ...], ~numpy.dtype[~numpy.float64]] | None = None, fluid_level_0: ~numpy.ndarray[tuple[~typing.Any, ...], ~numpy.dtype[~numpy.float64]] | None = None, nodal_capacity_sign: float = 1.0, capacity_nodes_idx: ~numpy.ndarray[tuple[~typing.Any, ...], ~numpy.dtype[~numpy.int64]] | None = None, use_glsk_as_cost: bool = False, add_losses_approximation: bool = False, logger: ~VeraGridEngine.basic_structures.Logger = <VeraGridEngine.basic_structures.Logger object>, progress_text: None | ~typing.Callable[[str], None] = None, progress_func: None | ~typing.Callable[[float], None] = None, verbose: int = 0, robust: bool = False, mip_framework: ~VeraGridEngine.enumerations.MIPFramework = PuLP) Tuple[OpfVars, PulpLpModel | None][source]ο
Formulate linear optimal power flow :param grid: MultiCircuit instance :param time_indices: Time indices (in the general scheme) :param dispatch_mode: OpfDispatchMode :param solver_type: MIP solver to use :param zonal_grouping: Zonal grouping? :param skip_generation_limits: Skip the generation limits? :param consider_contingencies: Consider the contingencies? :param contingency_groups_used: List of contingency groups to use :param ramp_constraints: Formulate ramp constraints? :param consider_time_up_down: Consider the time up/down? :param area_spinning_reserve: Area spinning reserve? :param lodf_threshold: LODF threshold value to consider contingencies :param inter_aggregation_info: Inter rea (or country, etc) information :param energy_0: Vector of initial energy for batteries (size: Number of batteries) :param fluid_level_0: initial fluid level of the nodes :param nodal_capacity_sign: if > 0 the generation is maximized, if < 0 the load is maximized :param capacity_nodes_idx: Array of bus indices to optimize their nodal capacity for :param use_glsk_as_cost: If true the generators use the GLSK as dispatch values :param add_losses_approximation: If true the distribution factors losses approximation is used :param logger: logger instance :param progress_text: Text progress callback :param progress_func: Numerical progress callback :param verbose: verbosity level :param robust: Robust optimization? :param mip_framework: MIP framework to use :return: OpfVars
VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b 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.Formulations.linear_opf_ts_b.BatteryVars(nt: int, n_elm: int)[source]ο
Bases:
GenerationVarsstruct extending the generation vars to handle the battery vars
- get_values(Sbase: float, model: PulpLpModel | None, gen_emissions_rates_matrix: csc_matrix = None, gen_fuel_rates_matrix: csc_matrix = None) BatteryVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :return: GenerationVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.BranchVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the branch related vars
- add_contingency_flow(t: int, m: int, c: int, flow_var: float | LpVariable | None | LpAffineExpression, neg_slack: LpVariable | None, pos_slack: LpVariable | None)[source]ο
Add contingency flow :param t: time index :param m: monitored index :param c: contingency group index :param flow_var: flow var :param neg_slack: negative flow slack variable :param pos_slack: positive flow slack variable
- get_values(Sbase: float, model: PulpLpModel | None) BranchVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :return: BranchVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.BusVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the bus related vars
- get_values(Sbase: float, model: PulpLpModel | None) BusVars[source]ο
Return an instance of this class where the arrayβs content is not LP vars but their value :return: BusVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.FluidInjectionVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the vars of injections of fluid type
- get_values(model: PulpLpModel | None) FluidInjectionVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :param model: LP model from where we extract the values :return: FluidInjectionVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.FluidNodeVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the vars of nodes of fluid type
- get_values(model: PulpLpModel | None) FluidNodeVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :param model: LP model from where we extract the values :return: FluidNodeVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.FluidPathVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the vars of paths of fluid type
- get_values(model: PulpLpModel | None) FluidPathVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :param model: LP model from where we extract the values :return: FluidPathVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.GenerationVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the generation vars
- get_values(Sbase: float, model: PulpLpModel | None, gen_emissions_rates_matrix: csc_matrix, gen_fuel_rates_matrix: csc_matrix) GenerationVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :param Sbase: Base power (100 MVA) :param model: LpModel :param gen_emissions_rates_matrix: emissins rates matrix (n_emissions, n_gen) :param gen_fuel_rates_matrix: fuel rates matrix (n_fuels, n_gen) :return: GenerationVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.HvdcVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the generation vars
- get_values(Sbase: float, model: PulpLpModel | None) HvdcVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :return: HvdcVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.LoadVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the load related vars
- get_values(Sbase: float, model: PulpLpModel | None) LoadVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :return: LoadVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.NodalCapacityVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the nodal capacity related vars
- get_values(Sbase: float, model: PulpLpModel | None) NodalCapacityVars[source]ο
Return an instance of this class where the arrayβs content is not LP vars but their value :return: BusVars
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.OpfVars(nt: int, nbus: int, ng: int, nb: int, nl: int, nbr: int, n_hvdc: int, n_vsc: int, n_fluid_node: int, n_fluid_path: int, n_fluid_inj: int, n_cap_buses: int)[source]ο
Bases:
objectStructure to host the opf variables
- get_values(Sbase: float, model: PulpLpModel | None, gen_emissions_rates_matrix: csc_matrix, gen_fuel_rates_matrix: csc_matrix, gen_tech_shares_matrix: csc_matrix, batt_tech_shares_matrix: csc_matrix) OpfVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :return: OpfVars instance
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.SystemVars(nt: int)[source]ο
Bases:
objectStruct to store the system vars
- compute(gen_emissions_rates_matrix: csc_matrix, gen_fuel_rates_matrix: csc_matrix, gen_tech_shares_matrix: csc_matrix, batt_tech_shares_matrix: csc_matrix, gen_p: 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_p: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]], shedding_cost: ndarray[tuple[Any, ...], dtype[float64]] | ndarray[tuple[int, int], dtype[float64]])[source]ο
Compute the system values :param gen_emissions_rates_matrix: emissions rates matrix (n_emissions, n_gen) :param gen_fuel_rates_matrix: fuel rates matrix (n_fuels, n_gen) :param gen_tech_shares_matrix: technology shares of the generators :param batt_tech_shares_matrix technology shares of the batteries :param gen_p: Generation power values (nt, ngen) :param gen_cost: Generation cost values (nt, ngen) :param batt_p: Battery power values (nt, nbatt) :param shedding_cost: Shedding cost values (nt, ngen)
- class VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.VscVars(nt: int, n_elm: int)[source]ο
Bases:
objectStruct to store the generation vars
- get_values(Sbase: float, model: PulpLpModel | None) HvdcVars[source]ο
Return an instance of this class where the arrays content are not LP vars but their value :return: HvdcVars
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.add_copper_plate_balance(t_idx: int, bus_vars: BusVars, prob: PulpLpModel | None)[source]ο
Add the copperplate equality :param t_idx: time step :param bus_vars: BusVars :param prob: LpModel
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.add_hydro_formulation(local_t: int | None, global_t: int | None, grid: MultiCircuit, time_array: DatetimeIndex, Sbase: float, node_vars: FluidNodeVars, path_vars: FluidPathVars, inj_vars: FluidInjectionVars, generator_vars: GenerationVars, fluid_level_0: ndarray[tuple[Any, ...], dtype[float64]], prob: PulpLpModel | None, logger: Logger)[source]ο
Formulate the branches :param local_t: local time index :param global_t: global time index :param grid: MultiCircuit :param time_array: list of time indices :param Sbase: base power of the system :param node_vars: FluidNodeVars :param path_vars: FluidPathVars :param inj_vars: FluidInjectionVars :param generator_vars: GeneratorVars :param fluid_level_0: Initial node level :param prob: OR problem :param logger: log of the LP :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.add_linear_battery_formulation(local_t: int, global_t: int | None, grid: MultiCircuit, bus_idx_dict: Dict[Bus, int], Sbase: float, time_array: DatetimeIndex, bus_vars: BusVars, batt_vars: BatteryVars, prob: PulpLpModel | None, unit_commitment: bool, ramp_constraints: bool, skip_generation_limits: bool, generation_expansion_planning: bool, energy_0: ndarray[tuple[Any, ...], dtype[float64]])[source]ο
Add MIP generation formulation :param local_t: time step (possibly reduced or from an interval) :param global_t: global time (integer or None to signal for the snapshot) :param grid: MultiCircuit instance :param bus_idx_dict: Bus-index dictionary :param Sbase: base power (100 MVA) :param time_array: complete time array :param bus_vars: BusVars :param batt_data_t: BatteryData structure :param batt_vars: BatteryVars structure :param prob: ORTools problem :param unit_commitment: formulate unit commitment? :param ramp_constraints: formulate ramp constraints? :param skip_generation_limits: skip the generation limits? :param generation_expansion_planning: generation expansion planning? :param energy_0: initial value of the energy stored :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.add_linear_branches_contingencies_formulation(local_t: int, global_t: int | None, grid: MultiCircuit, Sbase: float, hvdc_vars: HvdcVars, vsc_vars: VscVars, branch_vars: BranchVars, bus_vars: BusVars, prob: PulpLpModel | None, linear_multi_contingencies: LinearMultiContingencies)[source]ο
Formulate the branches :param local_t: time step (possibly reduced or from an interval) :param global_t: global time (integer or None to signal for the snapshot) :param grid: MultiCircuit instance :param Sbase: base power (100 MVA) :param hvdc_vars: HvdcVars :param vsc_vars: VscVars :param branch_vars: BranchVars :param bus_vars: BusVars :param prob: OR problem :param linear_multi_contingencies: LinearMultiContingencies :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.add_linear_branches_formulation(local_t: int, global_t: int | None, grid: MultiCircuit, bus_idx_dict: Dict[Bus, int], Sbase: float, branch_vars: BranchVars, bus_vars: BusVars, prob: PulpLpModel | None, inf=1e+20, add_losses_approximation: bool = False)[source]ο
Formulate the branches :param local_t: time step (possibly reduced or from an interval) :param global_t: global time (integer or None to signal for the snapshot) :param grid: MultiCircuit instance :param bus_idx_dict: Bus-index dictionary :param Sbase: base power (100 MVA) :param branch_vars: BranchVars :param bus_vars: BusVars :param prob: OR problem :param inf: number considered infinite :param add_losses_approximation: If true the distribution factors losses approximation is used :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.add_linear_generation_formulation(local_t: int, global_t: int | None, grid: MultiCircuit, bus_idx_dict: Dict[Bus, int], Sbase: float, time_array: DatetimeIndex, bus_vars: BusVars, gen_vars: GenerationVars, prob: PulpLpModel | None, unit_commitment: bool, ramp_constraints: bool, skip_generation_limits: bool, all_generators_fixed: bool, vd: ndarray[tuple[Any, ...], dtype[int64]], nodal_capacity_active: bool, generation_expansion_planning: bool, use_glsk_as_cost: bool, logger: Logger)[source]ο
Add MIP generation formulation :param local_t: time step (possibly reduced or from an interval) :param global_t: global time (integer or None to signal for the snapshot) :param grid: MultiCircuit instance :param bus_idx_dict: Bus-index dictionary :param Sbase: base power (100 MVA) :param time_array: complete time array :param bus_vars: BusVars :param gen_vars: GenerationVars structure :param prob: LpModel :param unit_commitment: formulate unit commitment? :param ramp_constraints: formulate ramp constraints? :param skip_generation_limits: skip the generation limits? :param all_generators_fixed: All generators take their snapshot or profile values
instead of resorting to dispatchable status
- Parameters:
vd β slack indices
nodal_capacity_active β nodal capacity active?
generation_expansion_planning β generation expansion plan?
use_glsk_as_cost β if true, the GLSK values are used instead of the traditional costs
logger β Logger instance
:return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.add_linear_hvdc_formulation(local_t: int, global_t: int | None, grid: MultiCircuit, bus_idx_dict: Dict[Bus, int], Sbase: float, hvdc_vars: HvdcVars, bus_vars: BusVars, prob: PulpLpModel | None)[source]ο
- Parameters:
local_t
global_t
grid
bus_idx_dict
Sbase
hvdc_vars
bus_vars
prob
- Returns:
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.add_linear_load_formulation(local_t: int, global_t: int | None, grid: MultiCircuit, bus_idx_dict: Dict[Bus, int], Sbase: float, bus_vars: BusVars, load_vars: LoadVars, prob: PulpLpModel | None)[source]ο
Add MIP generation formulation :param local_t: time step (possibly reduced or from an interval) :param global_t: global time (integer or None to signal for the snapshot) :param grid: MultiCircuit instance :param bus_idx_dict: Bus-index dictionary :param Sbase: base power (100 MVA) :param bus_vars: BusVars :param load_data_t: BatteryData structure :param load_vars: BatteryVars structure :param prob: ORTools problem :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.add_linear_node_balance(local_t: int, grid: MultiCircuit, vd: ndarray[tuple[Any, ...], dtype[int64]], bus_vars: BusVars, nodal_capacity_vars: NodalCapacityVars, capacity_nodes_idx: ndarray[tuple[Any, ...], dtype[int64]], prob: PulpLpModel | None, logger: Logger)[source]ο
Add the Kirchhoff nodal equality :param local_t: time step :param grid: MultiCircuit :param vd: List of slack node indices :param bus_vars: BusVars :param nodal_capacity_vars: NodalCapacityVars :param capacity_nodes_idx: IntVec :param prob: LpModel :param logger: Logger
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.add_linear_vsc_formulation(local_t: int, global_t: int | None, grid: MultiCircuit, bus_idx_dict: Dict[Bus, int], Sbase: float, vsc_vars: VscVars, bus_vars: BusVars, prob: PulpLpModel | None, logger: Logger)[source]ο
- Parameters:
local_t
global_t
grid
bus_idx_dict
Sbase
vsc_vars
bus_vars
prob
logger
- Returns:
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.add_nodal_capacity_formulation(t: int | None, nodal_capacity_vars: NodalCapacityVars, nodal_capacity_sign: float, capacity_nodes_idx: ndarray[tuple[Any, ...], dtype[int64]], prob: PulpLpModel | None)[source]ο
Add MIP generation formulation :param t: time step, if None we assume single time step :param nodal_capacity_vars: NodalCapacityVars structure :param nodal_capacity_sign: :param capacity_nodes_idx: IntVec :param prob: ORTools problem :return objective function
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.get_contingency_flow_with_filter(multi_contingency: LinearMultiContingency, base_flow: ndarray[tuple[Any, ...], dtype[float64]], injections: None | ndarray[tuple[Any, ...], dtype[float64]], threshold: float, m: int) LpAffineExpression | None[source]ο
Get contingency flow :param multi_contingency: MultiContingency object :param base_flow: Base branch flows (nbranch) :param injections: Bus injections increments (nbus) :param threshold: threshold to filter contingency elements :param m: branch monitor index (int) :return: New flows (nbranch)
- VeraGridEngine.Simulations.OPF.Formulations.linear_opf_ts_b.run_linear_opf_ts(grid: ~VeraGridEngine.Devices.multi_circuit.MultiCircuit, time_indices: ~numpy.ndarray[tuple[~typing.Any, ...], ~numpy.dtype[~numpy.int64]] | None, solver_type: ~VeraGridEngine.enumerations.MIPSolvers = HIGHS, zonal_grouping: ~VeraGridEngine.enumerations.ZonalGrouping = No grouping, skip_generation_limits: bool = False, consider_contingencies: bool = False, contingency_groups_used: ~typing.List[~VeraGridEngine.Devices.Events.contingency_group.ContingencyGroup] | None = None, unit_commitment: bool = False, ramp_constraints: bool = False, generation_expansion_planning: bool = False, all_generators_fixed: bool = False, lodf_threshold: float = 0.001, maximize_inter_area_flow: bool = False, inter_aggregation_info: ~VeraGridEngine.Devices.Aggregation.inter_aggregation_info.InterAggregationInfo | None = None, energy_0: ~numpy.ndarray[tuple[~typing.Any, ...], ~numpy.dtype[~numpy.float64]] | None = None, fluid_level_0: ~numpy.ndarray[tuple[~typing.Any, ...], ~numpy.dtype[~numpy.float64]] | None = None, 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, use_glsk_as_cost: bool = False, add_losses_approximation: bool = False, logger: ~VeraGridEngine.basic_structures.Logger = <VeraGridEngine.basic_structures.Logger object>, progress_text: None | ~typing.Callable[[str], None] = None, progress_func: None | ~typing.Callable[[float], None] = None, verbose: int = 0, robust: bool = False, mip_framework: ~VeraGridEngine.enumerations.MIPFramework = PuLP) OpfVars[source]ο
Run linear optimal power flow :param grid: MultiCircuit instance :param time_indices: Time indices (in the general scheme) :param solver_type: MIP solver to use :param zonal_grouping: Zonal grouping? :param skip_generation_limits: Skip the generation limits? :param consider_contingencies: Consider the contingencies? :param contingency_groups_used: List of contingency groups to use :param unit_commitment: Formulate unit commitment? :param ramp_constraints: Formulate ramp constraints? :param generation_expansion_planning: Generation expansion planning? :param all_generators_fixed: All generators take their snapshot or profile values
instead of resorting to dispatchable status
- Parameters:
lodf_threshold β LODF threshold value to consider contingencies
maximize_inter_area_flow β Maximize the inter-area flow?
inter_aggregation_info β Inter rea (or country, etc) information
energy_0 β Vector of initial energy for batteries (size: Number of batteries)
fluid_level_0 β initial fluid level of the nodes
optimize_nodal_capacity β Optimize the nodal capacity? (optional)
nodal_capacity_sign β if > 0 the generation is maximized, if < 0 the load is maximized
capacity_nodes_idx β Array of bus indices to optimize their nodal capacity for
use_glsk_as_cost β If true the generators use the GLSK as dispatch values
add_losses_approximation β If true the distribution factors losses approximation is used
logger β logger instance
progress_text β Text progress callback
progress_func β Numerical progress callback
verbose β verbosity level
robust β Robust optimization?
- Returns:
OpfVars