GridModel module (doc in progress)
The main class of the lightsim2grid python package is the GridModel class, that is a python class created from the the c++ GridModel (thanks fo pybind11).
This class basically represents a powergrid (what elements it is made for, their electro technical properties etc.)
To create such class, for now the only way is to get it from a pandapower grid (and it does not model every elements there !)
For example, you can init it like (NOT RECOMMENDED, though sometimes needed):
from lightsim2grid.gridmodel import init
pp_net = ... # any pandapower grid eg. pp_net = pn.case118()
lightsim_grid_model = init(pp_net) # some warnings might be issued as well as some warnings
A better initialization is through the lightsim2grid.LightSimBackend.LightSimBackend
class:
from lightsim2grid.gridmodel import init
# create a lightsim2grid "gridmodel"
env_name = ... # eg. "l2rpn_case14_test"
env = grid2op.make(env_name, backend=LightSimBackend())
grid_model = env.backend._grid
Warning
We do not recommend to manipulate directly the lightsim2grid.gridmodel.GridModel
directy, but to use
it via the backend class. This is much more tested this way.
Elements modeled
Generators (standard)
Static Generators (more exotic)
Loads and Storage Units
Shunts
Lines
Transformers
DC Powerlines (more exotic)
Detailed documentation
Classes:
This class represent a lightsim2grid power network. 
Functions:

Convert a pandapower network as input into a GridModel. 
 class lightsim2grid.gridmodel.GridModel
This class represent a lightsim2grid power network. All the elements that can be manipulated by lightsim2grid are represented here.
We do not recommend to use this class directly, but rather to use a
lightsim2grid.LightSimBackend.LightSimBackend
.Examples
We DO NOT recommend to do:
import lightsim2grid from lightsim2grid.gridmodel import init pp_net = ... # any pandapower network for example pp_net = pn.case118() grid_model = init(pp_net)
It’s better to do:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # any grid2op environment grid2op_env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = grid2op_env.backend._grid
The best way to use this class is through the LightSimBackend and not to use it directly !
Methods:
ac_pf
(self, arg0, arg1, arg2)Allows to perform an AC (alternating current) powerflow.
add_gen_slackbus
(self, arg0, arg1)INTERNAL
TODO
available_solvers
(self)Return the list of solver available on the current lightsim2grid installation.
change_bus_dcline_ex
(self, arg0, arg1)INTERNAL
change_bus_dcline_or
(self, arg0, arg1)INTERNAL
change_bus_gen
(self, arg0, arg1)INTERNAL
change_bus_load
(self, arg0, arg1)INTERNAL
change_bus_powerline_ex
(self, arg0, arg1)INTERNAL
change_bus_powerline_or
(self, arg0, arg1)INTERNAL
change_bus_sgen
(self, arg0, arg1)INTERNAL
change_bus_shunt
(self, arg0, arg1)INTERNAL
change_bus_storage
(self, arg0, arg1)INTERNAL
change_bus_trafo_hv
(self, arg0, arg1)INTERNAL
change_bus_trafo_lv
(self, arg0, arg1)INTERNAL
change_p_dcline
(self, arg0, arg1)INTERNAL
change_p_gen
(self, arg0, arg1)INTERNAL
change_p_load
(self, arg0, arg1)INTERNAL
change_p_sgen
(self, arg0, arg1)INTERNAL
change_p_shunt
(self, arg0, arg1)INTERNAL
change_p_storage
(self, arg0, arg1)INTERNAL
change_q_load
(self, arg0, arg1)INTERNAL
change_q_sgen
(self, arg0, arg1)INTERNAL
change_q_shunt
(self, arg0, arg1)INTERNAL
change_q_storage
(self, arg0, arg1)INTERNAL
change_solver
(self, arg0)This function allows to control which solver is used during the powerflow.
change_v_ex_dcline
(self, arg0, arg1)INTERNAL
change_v_gen
(self, arg0, arg1)INTERNAL
change_v_or_dcline
(self, arg0, arg1)INTERNAL
check_solution
(self, arg0, arg1)This function allows to check that a given complex voltage vector satisfies the KCL or not, given the state of the sytem.
compute_newton
(self, arg0, arg1, arg2)Allows to perform an AC (alternating current) powerflow.
TODO and TODO DC LINE: one side might be in the connected comp and not the other !
copy
(self)dc_pf
(self, arg0, arg1, arg2)This function has the same interface, inputs, outputs, behaviour, etc.
deactivate_bus
(self, arg0)INTERNAL
deactivate_dcline
(self, arg0)INTERNAL
deactivate_gen
(self, arg0)INTERNAL
deactivate_load
(self, arg0)INTERNAL
deactivate_powerline
(self, arg0)INTERNAL
Allows to deactivate the computation of the flows, reactive power absorbed by generators etc.
deactivate_sgen
(self, arg0)INTERNAL
deactivate_shunt
(self, arg0)INTERNAL
deactivate_storage
(self, arg0)INTERNAL
deactivate_trafo
(self, arg0)INTERNAL
debug_get_Bp_python
(self, arg0)INTERNAL
debug_get_Bpp_python
(self, arg0)INTERNAL
get_Bf
(self)INTERNAL
get_J
(self)Returns the Jacobian matrix used for solving the powerflow as a scipy sparse CSC matrix matrix of real number.
get_Sbus
(self)This function returns the (complex) Sbus vector, which is the vector of active / reactive power injected at each active bus
get_V
(self)Returns the complex voltage for each buses as a numpy vector of complex number.
get_Va
(self)Returns the voltage angles for each buses as a numpy vector of real number.
get_Vm
(self)Returns the voltage magnitude for each buses as a numpy vector of real number.
get_Ybus
(self)This function returns the (complex) Ybus matrix used to compute the powerflow.
get_all_shunt_buses
(self)INTERNAL
get_bus_dcline_ex
(self, arg0)INTERNAL
get_bus_dcline_or
(self, arg0)INTERNAL
get_bus_gen
(self, arg0)INTERNAL
get_bus_load
(self, arg0)INTERNAL
get_bus_powerline_ex
(self, arg0)INTERNAL
get_bus_powerline_or
(self, arg0)INTERNAL
get_bus_sgen
(self, arg0)INTERNAL
get_bus_shunt
(self, arg0)INTERNAL
get_bus_status
(self)INTERNAL
get_bus_storage
(self, arg0)INTERNAL
get_bus_trafo_hv
(self, arg0)INTERNAL
get_bus_trafo_lv
(self, arg0)INTERNAL
get_bus_vn_kv
(self)INTERNAL
get_computation_time
(self)Return the total computation time (in second) spend in the solver when performing a powerflow.
get_dcSbus
(self)INTERNAL
get_dcYbus
(self)It is the equivalent of
lightsim2grid.gridmodel.GridModel.get_Ybus()
but for the dc solver.get_dc_computation_time
(self)Return the total computation time (in second) spend in the solver (used to perform DC approximation) when performing a DC powerflow.
get_dc_solver
(self)Return the solver currently in use as a
lightsim2grid.solver.AnySolver()
instance for the dc powerflow.get_dc_solver_type
(self)Return the type of the solver currently used to compute DC powerflow.
get_dclineex_res_full
(self)INTERNAL
get_dclineor_res_full
(self)INTERNAL
get_dclines
(self)This function allows to retrieve the dc powerlines (as a
lightsim2grid.elements.DCLineContainer
object, see Elements modeled for more information)get_gen_res
(self)INTERNAL
get_gen_res_full
(self)INTERNAL
get_gen_status
(self)INTERNAL
get_gen_theta
(self)INTERNAL
get_generators
(self)This function allows to retrieve the (standard) generators (as a
lightsim2grid.elements.GeneratorContainer
object, see Elements modeled for more information)get_init_vm_pu
(self)INTERNAL
get_lineex_res
(self)INTERNAL
get_lineex_res_full
(self)INTERNAL
get_lineex_theta
(self)INTERNAL
get_lineor_res
(self)INTERNAL
get_lineor_res_full
(self)INTERNAL
get_lineor_theta
(self)INTERNAL
get_lines
(self)This function allows to retrieve the powerlines (as a
lightsim2grid.elements.LineContainer
object, see Elements modeled for more information)get_lines_status
(self)INTERNAL
get_load_theta
(self)INTERNAL
get_loads
(self)This function allows to retrieve the loads (as a
lightsim2grid.elements.LoadContainer
object, see Elements modeled for more information)get_loads_res
(self)INTERNAL
get_loads_res_full
(self)INTERNAL
get_loads_status
(self)INTERNAL
get_lodf
(self)INTERNAL
get_pq
(self)Returns the ids of the buses that are labelled as "PQ".
get_ptdf
(self)INTERNAL
get_pv
(self)Returns the ids of the buses that are labelled as "PV" (ie the buses on which at least a generator is connected.).
get_sgens_res
(self)INTERNAL
get_sgens_res_full
(self)INTERNAL
get_sgens_status
(self)INTERNAL
get_shunt_theta
(self)INTERNAL
get_shunts
(self)This function allows to retrieve the shunts (as a
lightsim2grid.elements.ShuntContainer
object, see Elements modeled for more information)get_shunts_res
(self)INTERNAL
get_shunts_res_full
(self)INTERNAL
get_shunts_status
(self)INTERNAL
get_slack_ids
(self)Returns the ids of the buses that are part of the distributed slack.
get_slack_weights
(self)For each bus used by the solver, it outputs its participation to the distributed slack.
get_sn_mva
(self)INTERNAL
get_solver
(self)Return the solver currently in use as a
lightsim2grid.solver.AnySolver()
instance.get_solver_control
(self)TODO
get_solver_type
(self)Return the type of the solver currently used.
get_static_generators
(self)This function allows to retrieve the (more exotic) static generators (as a
lightsim2grid.elements.SGenContainer
object, see Elements modeled for more information)get_storage_theta
(self)INTERNAL
get_storages
(self)This function allows to retrieve the storage units (as a
lightsim2grid.elements.LoadContainer
object, see Elements modeled for more information)get_storages_res
(self)INTERNAL
get_storages_res_full
(self)INTERNAL
get_storages_status
(self)INTERNAL
get_trafo_status
(self)INTERNAL
get_trafohv_res
(self)INTERNAL
get_trafohv_res_full
(self)INTERNAL
get_trafohv_theta
(self)INTERNAL
get_trafolv_res
(self)INTERNAL
get_trafolv_res_full
(self)INTERNAL
get_trafolv_theta
(self)INTERNAL
get_trafos
(self)This function allows to retrieve the transformers (as a
lightsim2grid.elements.LineContainer
object, see Elements modeled for more information)get_turnedoff_gen_pv
(self)TODO
id_ac_solver_to_me
(self)In lightsim2grid, buses are labelled from 0 to n1 (if n denotes the total number of buses on the grid) [this is called "grid model bus id"]
id_dc_solver_to_me
(self)Same as
lightsim2grid.gridmodel.GridModel.id_ac_solver_to_me
but only used for the DC approximation.id_me_to_ac_solver
(self)In lightsim2grid, buses are labelled from 0 to n1 (if n denotes the total number of buses on the grid) [this is called "grid model bus id"]
id_me_to_dc_solver
(self)Same as
lightsim2grid.gridmodel.GridModel.id_me_to_ac_solver
but only used for the DC approximation.init_bus
(self, arg0, arg1, arg2)INTERNAL
init_bus_status
(self)INTERNAL
init_dclines
(self, arg0, arg1, arg2, arg3, ...)INTERNAL
init_generators
(self, arg0, arg1, arg2, ...)INTERNAL
init_generators_full
(self, arg0, arg1, arg2, ...)INTERNAL
init_loads
(self, arg0, arg1, arg2)INTERNAL
init_powerlines
(self, arg0, arg1, arg2, ...)INTERNAL
init_powerlines_full
(self, arg0, arg1, arg2, ...)INTERNAL
init_sgens
(self, arg0, arg1, arg2, arg3, ...)INTERNAL
init_shunt
(self, arg0, arg1, arg2)INTERNAL
init_storages
(self, arg0, arg1, arg2)INTERNAL
init_trafo
(self, arg0, arg1, arg2, arg3, ...)INTERNAL
nb_bus
(self)Returns (>0 integer) the number of connected buses on the powergrid (ignores the disconnected bus).
reactivate_bus
(self, arg0)INTERNAL
reactivate_dcline
(self, arg0)INTERNAL
reactivate_gen
(self, arg0)INTERNAL
reactivate_load
(self, arg0)INTERNAL
reactivate_powerline
(self, arg0)INTERNAL
Allows to reactivate the computation of the flows, reactive power absorbed by generators etc.
reactivate_sgen
(self, arg0)INTERNAL
reactivate_shunt
(self, arg0)INTERNAL
reactivate_storage
(self, arg0)INTERNAL
reactivate_trafo
(self, arg0)INTERNAL
remove_gen_slackbus
(self, arg0)INTERNAL
set_dcline_names
(self, arg0)TODO
set_gen_names
(self, arg0)TODO
set_gen_pos_topo_vect
(self, arg0)INTERNAL
set_gen_to_subid
(self, arg0)INTERNAL
set_init_vm_pu
(self, arg0)INTERNAL
set_line_ex_pos_topo_vect
(self, arg0)INTERNAL
set_line_ex_to_subid
(self, arg0)INTERNAL
set_line_names
(self, arg0)TODO
set_line_or_pos_topo_vect
(self, arg0)INTERNAL
set_line_or_to_subid
(self, arg0)INTERNAL
set_load_names
(self, arg0)TODO
set_load_pos_topo_vect
(self, arg0)INTERNAL
set_load_to_subid
(self, arg0)INTERNAL
set_max_nb_bus_per_sub
(self, arg0)INTERNAL
set_n_sub
(self, arg0)INTERNAL
set_sgen_names
(self, arg0)TODO
set_shunt_names
(self, arg0)TODO
set_sn_mva
(self, arg0)INTERNAL
set_storage_names
(self, arg0)TODO
set_storage_pos_topo_vect
(self, arg0)INTERNAL
set_storage_to_subid
(self, arg0)INTERNAL
set_trafo_hv_pos_topo_vect
(self, arg0)INTERNAL
set_trafo_hv_to_subid
(self, arg0)INTERNAL
set_trafo_lv_pos_topo_vect
(self, arg0)INTERNAL
set_trafo_lv_to_subid
(self, arg0)INTERNAL
set_trafo_names
(self, arg0)TODO
tell_recompute_sbus
(self)INTERNAL
tell_recompute_ybus
(self)INTERNAL
tell_solver_need_reset
(self)INTERNAL
INTERNAL
total_bus
(self)Returns (>0 integer) the total number of buses in the powergrid (both connected and disconnected)
turnedoff_no_pv
(self)Turned off (or generators with p = 0) generators will not be pv buses, they will not maintain voltage
turnedoff_pv
(self)Turned off (or generators with p = 0) generators will be pv buses, they will maintain voltage (default)
unset_changes
(self)INTERNAL
update_gens_p
(self, arg0, arg1)INTERNAL
update_gens_v
(self, arg0, arg1)INTERNAL
update_loads_p
(self, arg0, arg1)INTERNAL
update_loads_q
(self, arg0, arg1)INTERNAL
update_sgens_p
(self, arg0, arg1)INTERNAL
update_slack_weights
(self, arg0)TODO
update_storages_p
(self, arg0, arg1)INTERNAL
update_topo
(self, arg0, arg1)INTERNAL
Attributes:
TODO
TODO
 ac_pf(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.complex128[m, 1]], arg1: int, arg2: float) numpy.ndarray[numpy.complex128[m, 1]]
Allows to perform an AC (alternating current) powerflow.
Note
It is expected that you provide a complex number even for the buses that are disconnected in the grid model. They will not be affected (if the powerflow converges) and you can put anything you want there. We keep the public interface this way to avoid headaches with the bus order between the grid model and the solver (you can refer to
lightsim2grid.gridmodel.GridModel.id_me_to_ac_solver()
andlightsim2grid.gridmodel.GridModel.id_ac_solver_to_me()
if you still want to have a look)See also
lightsim2grid.gridmodel.GridModel.dc_pf()
if you want to perform DC powerflow (same interface, same results, same behaviour)Warning
The input vector V is modified (and is equal to the resulting vector V)
 Parameters:
V – It expects a complex voltage vector (having as many components as the total number of buses in the grid.) representing the initial guess of the resulting flows. This vector will be modified !
max_iter (
int
) – Maximum number of iterations allowed (this might be ignored) and should be a >= 0 integertol (
float
) – Tolerance criteria to stop the computation. This should be > 0 real number.
 Returns:
A complex vector given the complex voltage at each buses of the grid model. Will be empty when the powerflow diverged.
 Return type:
V
Examples
# create a grid model import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg "l2rpn_case14_sandbox" env = grid2op.make(env_name, backend=LightSimbackend()) grid_model = env.backend._grid V = grid_model.ac_pf(V, 10, 1e8) # if the powerflow has converged, V.shape > 0 otherwise V is empty (size 0) # the original V is modified in the process !
 add_gen_slackbus(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 assign_slack_to_most_connected(self: lightsim2grid_cpp.GridModel) tuple[int, int]
TODO
 available_solvers(self: lightsim2grid_cpp.GridModel) list[lightsim2grid_cpp.SolverType]
Return the list of solver available on the current lightsim2grid installation.
This is a list of
lightsim2grid.solver.SolverType
.
 change_bus_dcline_ex(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_bus_dcline_or(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_bus_gen(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_bus_load(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_bus_powerline_ex(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_bus_powerline_or(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_bus_sgen(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_bus_shunt(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_bus_storage(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_bus_trafo_hv(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_bus_trafo_lv(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_p_dcline(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_p_gen(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_p_load(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_p_sgen(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_p_shunt(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_p_storage(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_q_load(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_q_sgen(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_q_shunt(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_q_storage(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_solver(self: lightsim2grid_cpp.GridModel, arg0: lightsim2grid_cpp.SolverType) None
This function allows to control which solver is used during the powerflow. See the section Even more advanced usage for more information about them.
See also
lightsim2grid.solver.SolverType
for a list of the available solver (NB: some solvers might not be available on all platform)Note
If the solver type entered is a DC solver (eg from
lightsim2grid.solver.SolverType
, DC, KLUDC or NICSLUDC), it will change the _dc_solver otherwise the regular _solver is modified.Examples
from lightsim2grid.solver import SolverType # init the grid model from lightsim2grid.gridmodel import init pp_net = ... # any pandapower grid lightsim_grid_model = init(pp_net) # some warnings might be issued as well as some warnings # change the solver used for the powerflow # to use internally a solver based on Newton Raphson algorithme using Eigen sparse LU lightsim_grid_model.change_solver(SolverType.SparseLUSolver)
 change_v_ex_dcline(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_v_gen(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 change_v_or_dcline(self: lightsim2grid_cpp.GridModel, arg0: int, arg1: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 check_solution(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.complex128[m, 1]], arg1: bool) numpy.ndarray[numpy.complex128[m, 1]]
This function allows to check that a given complex voltage vector satisfies the KCL or not, given the state of the sytem.
Note
It is expected that you provide a complex number even for the buses that are disconnected in the grid model. They will not be ignored so you can put anything you want. We keep the public interface this way to avoid headaches with the bus order between the grid model and the solver (you can refer to
lightsim2grid.gridmodel.GridModel.id_me_to_ac_solver()
andlightsim2grid.gridmodel.GridModel.id_ac_solver_to_me()
if you still want to have a look)See also
lightsim2grid.physical_law_checker.PhysicalLawChecker
for an easier to use, more pythonic function ! Parameters:
V – It expects a complex voltage vector (having as many components as the total number of buses in the grid.) representing the vector you want to test.
check_q_limits (
bool
) – whether you want to take into account the reactive limit of generators when performing the check
 Returns:
A complex vector having the size of the number of total buses on the grid, given, for each of them, the active / reactive power mismatch at each bus (ie the power you would need to take from the grid and have the input vector V checking the KCL given the current state of the grid)
 Return type:
mismatch
 compute_newton(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.complex128[m, 1]], arg1: int, arg2: float) numpy.ndarray[numpy.complex128[m, 1]]
Allows to perform an AC (alternating current) powerflow.
Note
It is expected that you provide a complex number even for the buses that are disconnected in the grid model. They will not be affected (if the powerflow converges) and you can put anything you want there. We keep the public interface this way to avoid headaches with the bus order between the grid model and the solver (you can refer to
lightsim2grid.gridmodel.GridModel.id_me_to_ac_solver()
andlightsim2grid.gridmodel.GridModel.id_ac_solver_to_me()
if you still want to have a look)See also
lightsim2grid.gridmodel.GridModel.dc_pf()
if you want to perform DC powerflow (same interface, same results, same behaviour)Warning
The input vector V is modified (and is equal to the resulting vector V)
 Parameters:
V – It expects a complex voltage vector (having as many components as the total number of buses in the grid.) representing the initial guess of the resulting flows. This vector will be modified !
max_iter (
int
) – Maximum number of iterations allowed (this might be ignored) and should be a >= 0 integertol (
float
) – Tolerance criteria to stop the computation. This should be > 0 real number.
 Returns:
A complex vector given the complex voltage at each buses of the grid model. Will be empty when the powerflow diverged.
 Return type:
V
Examples
# create a grid model import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg "l2rpn_case14_sandbox" env = grid2op.make(env_name, backend=LightSimbackend()) grid_model = env.backend._grid V = grid_model.ac_pf(V, 10, 1e8) # if the powerflow has converged, V.shape > 0 otherwise V is empty (size 0) # the original V is modified in the process !
 consider_only_main_component(self: lightsim2grid_cpp.GridModel) None
TODO and TODO DC LINE: one side might be in the connected comp and not the other !
 copy(self: lightsim2grid_cpp.GridModel) lightsim2grid_cpp.GridModel
 dc_pf(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.complex128[m, 1]], arg1: int, arg2: float) numpy.ndarray[numpy.complex128[m, 1]]
This function has the same interface, inputs, outputs, behaviour, etc. as the
lightsim2grid.gridmodel.GridModel.ac_pf()
.
 deactivate_bus(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 deactivate_dcline(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 deactivate_gen(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 deactivate_load(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 deactivate_powerline(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 deactivate_result_computation(self: lightsim2grid_cpp.GridModel) None
Allows to deactivate the computation of the flows, reactive power absorbed by generators etc. to gain a bit of time when it is not needed.
 deactivate_sgen(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 deactivate_shunt(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 deactivate_storage(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 deactivate_trafo(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 debug_get_Bp_python(self: lightsim2grid_cpp.GridModel, arg0: lightsim2grid_cpp.FDPFMethod) scipy.sparse.csc_matrix[numpy.float64]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 debug_get_Bpp_python(self: lightsim2grid_cpp.GridModel, arg0: lightsim2grid_cpp.FDPFMethod) scipy.sparse.csc_matrix[numpy.float64]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_Bf(self: lightsim2grid_cpp.GridModel) scipy.sparse.csc_matrix[numpy.float64]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_J(self: lightsim2grid_cpp.GridModel) scipy.sparse.csc_matrix[numpy.float64]
Returns the Jacobian matrix used for solving the powerflow as a scipy sparse CSC matrix matrix of real number.
Note
Some powerflows (eg DC or Gauss Seidel) do not rely on jacobian matrix, in this case, calling this function will return an exception.
J has the shape:
 s  slack_bus   (pvpq+1,1)  (1, pvpq)  (1, pq)   l         a  J11  J12  = dimensions:   (pvpq, pvpq)  (pvpq, pq)   c          k  J21  J22   (pq, 1)  (pq, pvpq)  (pq, pq) 
With:
J11 = dS_dVa[array([pvpq]).T, pvpq].real (= real part of dS / dVa for all pv and pq buses)
J12 = dS_dVm[array([pvpq]).T, pq].real
J21 = dS_dVa[array([pq]).T, pvpq].imag
J22 = dS_dVm[array([pq]).T, pq].imag (= imaginary part of dS / dVm for all pq buses)
slack_bus = is the representation of the equation for the reference slack bus dS_dVa[slack_bus_id, pvpq].real and dS_dVm[slack_bus_id, pq].real
slack is the representation of the equation connecting together the slack buses (represented by slack_weights) the remaining pq components are all 0.
Note
By default (and this cannot be changed at the moment), all buses in ref will be pv buses except the first one.
Note
the notation pvpq above means “the concatenation of the pv vector and the pq vector” (after the distributed slack is taken into account  see note just above)
 get_Sbus(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.complex128[m, 1]]
This function returns the (complex) Sbus vector, which is the vector of active / reactive power injected at each active bus
The resulting vector is a vector of complex number having the size of the number of connected buses on the grid.
Warning
Each row / columns of this matrix represents a “solver bus” (and not a “grid model bus”). In other word, the first row / column of this matrix is not necessarily the first bus of the grid model.
Warning
This is given in the pair unit system and in load convention (so generation will be negative)
See also
lightsim2grid.gridmodel.GridModel.id_me_to_ac_solver()
andlightsim2grid.gridmodel.GridModel.id_ac_solver_to_me()
for ways to link the “grid model” bus id to the “solver” bus id.Notes
Suppose that the grid model bus of id k is connected. Then the row / column id_me_to_ac_solver[k] (will be >= 0) and will represent this bus: Sbus[id_me_to_ac_solver[k]] is the total power injected at the grid model bus solver k.
Warning
The above only holds when the bus of id k is connected which is when id_me_to_ac_solver[k] >= 0 !
 get_V(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.complex128[m, 1]]
Returns the complex voltage for each buses as a numpy vector of complex number. This vector have the size of the total number of active buses on the system.
You can use the
lightsim2grid.gridmodel.GridModel.id_ac_solver_to_me
(orlightsim2grid.gridmodel.GridModel.id_dc_solver_to_me
) to know at which bus (on the grid) they corresponds.
 get_Va(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, 1]]
Returns the voltage angles for each buses as a numpy vector of real number. This vector have the size of the total number of active buses on the system.
You can use the
lightsim2grid.gridmodel.GridModel.id_ac_solver_to_me
(orlightsim2grid.gridmodel.GridModel.id_dc_solver_to_me
) to know at which bus (on the grid) they corresponds.
 get_Vm(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, 1]]
Returns the voltage magnitude for each buses as a numpy vector of real number. This vector have the size of the total number of active buses on the system.
You can use the
lightsim2grid.gridmodel.GridModel.id_ac_solver_to_me
(orlightsim2grid.gridmodel.GridModel.id_dc_solver_to_me
) to know at which bus (on the grid) they corresponds.
 get_Ybus(self: lightsim2grid_cpp.GridModel) scipy.sparse.csc_matrix[numpy.complex128]
This function returns the (complex) Ybus matrix used to compute the powerflow.
The resulting matrix is a CSC scipy sparse matrix of complex number.
It is a square matrix, as many rows (columns) as there are connected buses on the grid.
Warning
Each row / columns of this matrix represents a “solver bus” (and not a “grid model bus”). In other word, the first row / column of this matrix is not necessarily the first bus of the grid model.
Warning
This is given in the pair unit system !
See also
lightsim2grid.gridmodel.GridModel.id_me_to_ac_solver()
andlightsim2grid.gridmodel.GridModel.id_ac_solver_to_me()
for ways to link the “grid model” bus id to the “solver” bus id.Notes
Suppose that the grid model bus of id k is connected. Then the row / column id_me_to_ac_solver[k] (will be >= 0) and will represent this bus: Ybus[id_me_to_ac_solver[k],:] (rows of this bus), Ybus[:, id_me_to_ac_solver[k]] (column for this bus)
Warning
The above only holds when the bus of id k is connected which is when id_me_to_ac_solver[k] >= 0 !
 get_all_shunt_buses(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.int32[m, 1]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_bus_dcline_ex(self: lightsim2grid_cpp.GridModel, arg0: int) int
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_bus_dcline_or(self: lightsim2grid_cpp.GridModel, arg0: int) int
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_bus_gen(self: lightsim2grid_cpp.GridModel, arg0: int) int
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_bus_load(self: lightsim2grid_cpp.GridModel, arg0: int) int
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_bus_powerline_ex(self: lightsim2grid_cpp.GridModel, arg0: int) int
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_bus_powerline_or(self: lightsim2grid_cpp.GridModel, arg0: int) int
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_bus_sgen(self: lightsim2grid_cpp.GridModel, arg0: int) int
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_bus_shunt(self: lightsim2grid_cpp.GridModel, arg0: int) int
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_bus_status(self: lightsim2grid_cpp.GridModel) list[bool]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_bus_storage(self: lightsim2grid_cpp.GridModel, arg0: int) int
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_bus_trafo_hv(self: lightsim2grid_cpp.GridModel, arg0: int) int
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_bus_trafo_lv(self: lightsim2grid_cpp.GridModel, arg0: int) int
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_bus_vn_kv(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, 1]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_computation_time(self: lightsim2grid_cpp.GridModel) float
Return the total computation time (in second) spend in the solver when performing a powerflow.
This is equivalent to the get_computation_time of the
lightsim2grid.solver.AnySolver.get_computation_time()
of the solver used (lightsim2grid.gridmodel.GridModel.get_solver()
)
 get_dcSbus(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.complex128[m, 1]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_dcYbus(self: lightsim2grid_cpp.GridModel) scipy.sparse.csc_matrix[numpy.complex128]
It is the equivalent of
lightsim2grid.gridmodel.GridModel.get_Ybus()
but for the dc solver.Warning
As opposed to some other librairies (for example Matpower of pandapower), the Ybus for the dc approximation in lightsim2grid has no imaginary components.
It could have returned a real matrix, but we choose (out of consistency with other solvers) to keep the representation as a complex numbers.
 get_dc_computation_time(self: lightsim2grid_cpp.GridModel) float
Return the total computation time (in second) spend in the solver (used to perform DC approximation) when performing a DC powerflow.
This is equivalent to the get_computation_time of the
lightsim2grid.solver.AnySolver.get_computation_time()
of the DC solver used (lightsim2grid.gridmodel.GridModel.get_dc_solver()
)
 get_dc_solver(self: lightsim2grid_cpp.GridModel) lightsim2grid_cpp.AnySolver
Return the solver currently in use as a
lightsim2grid.solver.AnySolver()
instance for the dc powerflow.
 get_dc_solver_type(self: lightsim2grid_cpp.GridModel) lightsim2grid_cpp.SolverType
Return the type of the solver currently used to compute DC powerflow.
 get_dclineex_res_full(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_dclineor_res_full(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_dclines(self: lightsim2grid_cpp.GridModel) lightsim2grid_cpp.DCLineContainer
This function allows to retrieve the dc powerlines (as a
lightsim2grid.elements.DCLineContainer
object, see Elements modeled for more information)Examples
# init the grid model from lightsim2grid.gridmodel import init pp_net = ... # any pandapower grid lightsim_grid_model = init(pp_net) # some warnings might be issued as well as some warnings # usage example: print some information about the powerlines print([el.x_pu for el in lightsim_grid_model.get_dclines()]) # to print the "x" for each powerlines
 get_gen_res(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_gen_res_full(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_gen_status(self: lightsim2grid_cpp.GridModel) list[bool]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_gen_theta(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, 1]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_generators(self: lightsim2grid_cpp.GridModel) lightsim2grid_cpp.GeneratorContainer
This function allows to retrieve the (standard) generators (as a
lightsim2grid.elements.GeneratorContainer
object, see Elements modeled for more information)Examples
# init the grid model from lightsim2grid.gridmodel import init pp_net = ... # any pandapower grid lightsim_grid_model = init(pp_net) # some warnings might be issued as well as some warnings # usage example: print some information about the generators print([el.target_p_mw for el in lightsim_grid_model.get_generators()]) # to print the active production setpoint for each generators
 get_init_vm_pu(self: lightsim2grid_cpp.GridModel) float
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_lineex_res(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_lineex_res_full(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_lineex_theta(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, 1]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_lineor_res(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_lineor_res_full(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_lineor_theta(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, 1]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_lines(self: lightsim2grid_cpp.GridModel) lightsim2grid_cpp.LineContainer
This function allows to retrieve the powerlines (as a
lightsim2grid.elements.LineContainer
object, see Elements modeled for more information)Examples
# init the grid model from lightsim2grid.gridmodel import init pp_net = ... # any pandapower grid lightsim_grid_model = init(pp_net) # some warnings might be issued as well as some warnings # usage example: print some information about the powerlines print([el.x_pu for el in lightsim_grid_model.get_lines()]) # to print the "x" for each powerlines
 get_lines_status(self: lightsim2grid_cpp.GridModel) list[bool]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_load_theta(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, 1]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_loads(self: lightsim2grid_cpp.GridModel) lightsim2grid_cpp.LoadContainer
This function allows to retrieve the loads (as a
lightsim2grid.elements.LoadContainer
object, see Elements modeled for more information)Examples
# init the grid model from lightsim2grid.gridmodel import init pp_net = ... # any pandapower grid lightsim_grid_model = init(pp_net) # some warnings might be issued as well as some warnings # print the target consumption of each loads print([el.target_p_mw for el in lightsim_grid_model.get_loads()]) # to print the active consumption for each load
 get_loads_res(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_loads_res_full(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_loads_status(self: lightsim2grid_cpp.GridModel) list[bool]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_lodf(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, n]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_pq(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.int32[m, 1]]
Returns the ids of the buses that are labelled as “PQ”.
It returns a vector of integer.
Warning
The index are given in the “solver bus” convention. This means that it will might be the bus of the original grid model.
See also
lightsim2grid.gridmodel.GridModel.id_me_to_ac_solver()
andlightsim2grid.gridmodel.GridModel.id_ac_solver_to_me()
for ways to link the “grid model” bus id to the “solver” bus id.
 get_ptdf(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, n]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_pv(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.int32[m, 1]]
Returns the ids of the buses that are labelled as “PV” (ie the buses on which at least a generator is connected.).
It returns a vector of integer.
Warning
The index are given in the “solver bus” convention. This means that it might not be the bus of the original grid model.
See also
lightsim2grid.gridmodel.GridModel.id_me_to_ac_solver()
andlightsim2grid.gridmodel.GridModel.id_ac_solver_to_me()
for ways to link the “grid model” bus id to the “solver” bus id.
 get_sgens_res(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_sgens_res_full(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_sgens_status(self: lightsim2grid_cpp.GridModel) list[bool]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_shunt_theta(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, 1]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_shunts(self: lightsim2grid_cpp.GridModel) lightsim2grid_cpp.ShuntContainer
This function allows to retrieve the shunts (as a
lightsim2grid.elements.ShuntContainer
object, see Elements modeled for more information)Examples
# init the grid model from lightsim2grid.gridmodel import init pp_net = ... # any pandapower grid lightsim_grid_model = init(pp_net) # some warnings might be issued as well as some warnings # usage example: print some information about the shunts print([el.target_q_mvar for el in lightsim_grid_model.get_shunts()]) # to print the reactive consumption for each shunts
 get_shunts_res(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_shunts_res_full(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_shunts_status(self: lightsim2grid_cpp.GridModel) list[bool]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_slack_ids(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.int32[m, 1]]
Returns the ids of the buses that are part of the distributed slack.
It returns a vector of integer.
Warning
The index are given in the “solver bus” convention. This means that it might not be the bus of the original grid model.
See also
lightsim2grid.gridmodel.GridModel.id_me_to_ac_solver()
andlightsim2grid.gridmodel.GridModel.id_ac_solver_to_me()
for ways to link the “grid model” bus id to the “solver” bus id.
 get_slack_weights(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, 1]]
For each bus used by the solver, it outputs its participation to the distributed slack.
It’s 0 if the current bus does not participate to it, otherwise it is made of > 0. real numbers.
This vector sums to 1 and has the same size as the number of active buses on the grid.
Warning
This vector represents “solver buses” and not “original grid model buses”.
See also
lightsim2grid.gridmodel.GridModel.id_me_to_ac_solver()
andlightsim2grid.gridmodel.GridModel.id_ac_solver_to_me()
for ways to link the “grid model” bus id to the “solver” bus id.
 get_sn_mva(self: lightsim2grid_cpp.GridModel) float
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_solver(self: lightsim2grid_cpp.GridModel) lightsim2grid_cpp.AnySolver
Return the solver currently in use as a
lightsim2grid.solver.AnySolver()
instance.
 get_solver_control(self: lightsim2grid_cpp.GridModel) lightsim2grid_cpp.SolverControl
TODO
 get_solver_type(self: lightsim2grid_cpp.GridModel) lightsim2grid_cpp.SolverType
Return the type of the solver currently used.
This is equivalent to the get_type of the
lightsim2grid.solver.AnySolver.get_type()
of the solver used.
 get_static_generators(self: lightsim2grid_cpp.GridModel) lightsim2grid_cpp.SGenContainer
This function allows to retrieve the (more exotic) static generators (as a
lightsim2grid.elements.SGenContainer
object, see Elements modeled for more information)Examples
# init the grid model from lightsim2grid.gridmodel import init pp_net = ... # any pandapower grid lightsim_grid_model = init(pp_net) # some warnings might be issued as well as some warnings # usage example: print some information about the static generators print([el.target_p_mw for el in lightsim_grid_model.get_static_generators()]) # to print the active production setpoint for each static generator
 get_storage_theta(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, 1]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_storages(self: lightsim2grid_cpp.GridModel) lightsim2grid_cpp.LoadContainer
This function allows to retrieve the storage units (as a
lightsim2grid.elements.LoadContainer
object, see Elements modeled for more information)Note
We want to emphize that, as far as lightsim2grid is concerned, the storage units are modeled as loads. This is why this function will return a
lightsim2grid.elements.LoadContainer
.Examples
# init the grid model from lightsim2grid.gridmodel import init pp_net = ... # any pandapower grid lightsim_grid_model = init(pp_net) # some warnings might be issued as well as some warnings # print the target consumption of each storage units print([el.target_p_mw for el in lightsim_grid_model.get_storages()]) # to print the active consumption for each storage unit
 get_storages_res(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_storages_res_full(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_storages_status(self: lightsim2grid_cpp.GridModel) list[bool]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_trafo_status(self: lightsim2grid_cpp.GridModel) list[bool]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_trafohv_res(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_trafohv_res_full(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_trafohv_theta(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, 1]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_trafolv_res(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_trafolv_res_full(self: lightsim2grid_cpp.GridModel) tuple[numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]], numpy.ndarray[numpy.float64[m, 1]]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_trafolv_theta(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, 1]]
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 get_trafos(self: lightsim2grid_cpp.GridModel) lightsim2grid_cpp.TrafoContainer
This function allows to retrieve the transformers (as a
lightsim2grid.elements.LineContainer
object, see Elements modeled for more information)Examples
# init the grid model from lightsim2grid.gridmodel import init pp_net = ... # any pandapower grid lightsim_grid_model = init(pp_net) # some warnings might be issued as well as some warnings # usage example: print some information about the trafos print([el.x_pu for el in lightsim_grid_model.get_trafos()]) # to print the "x" for each transformer
 get_turnedoff_gen_pv(self: lightsim2grid_cpp.GridModel) bool
TODO
 id_ac_solver_to_me(self: lightsim2grid_cpp.GridModel) list[int]
In lightsim2grid, buses are labelled from 0 to n1 (if n denotes the total number of buses on the grid) [this is called “grid model bus id”]
At any given point in time, some buses might be deactivated (for example because nothing is connected to them).
On the other end, the solvers need a contiguous list of only active buses (otherwise they might run into divergence issue) [this will be called “solver bus id” later on]
This function allows, for all buses exported in the solver, to retrieve which was the initial bus in the
lightsim2grid.gridmodel.GridModel
. It has the same size as the number of active buses on the grid.Examples
# create a grid model import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg "l2rpn_case14_sandbox" env = grid2op.make(env_name, backend=LightSimbackend()) grid_model = env.backend._grid id_ac_solver_to_me = grid.id_ac_solver_to_me() # is [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] # put everything to bus 2 on substation O _ = env.step(env.action_space({"set_bus": {"substations_id": [(0, (2, 2, 2))]}})) id_ac_solver_to_me2 = grid.id_ac_solver_to_me() # is [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
See also
lightsim2grid.gridmodel.GridModel.id_dc_solver_to_me
for its counterpart when a dc powerflow is usedSee also
lightsim2grid.gridmodel.GridModel.id_me_to_ac_solver
for the “reverse” operation (given a “solver bus” id, returns the “gridmodel bus id”)Notes
For all steps, you have the propertie that, if id_ac_solver_to_me = gridmodel.id_ac_solver_to_me() and id_me_to_ac_solver = gridmodel.id_me_to_ac_solver() and by denoting gridmodel_bus_id = np.arange(gridmodel.total_bus()) and solver_bus_id = np.arange(gridmodel.nb_bus()):
solver_bus_id and id_ac_solver_to_me have the same shape
gridmodel_bus_id and id_me_to_ac_solver have the same shape
solver_bus_id is shorter (or of the same length) than gridmodel_bus_id
the connected bus (in the grid model) are given by gridmodel_bus_id[id_ac_solver_to_me], and it gives their order
 id_dc_solver_to_me(self: lightsim2grid_cpp.GridModel) list[int]
Same as
lightsim2grid.gridmodel.GridModel.id_ac_solver_to_me
but only used for the DC approximation.
 id_me_to_ac_solver(self: lightsim2grid_cpp.GridModel) list[int]
In lightsim2grid, buses are labelled from 0 to n1 (if n denotes the total number of buses on the grid) [this is called “grid model bus id”]
At any given point in time, some buses might be deactivated (for example because nothing is connected to them).
On the other end, the solvers need a contiguous list of only active buses (otherwise they might run into divergence issue) [this will be called “solver bus id” later on]
This function allows, for all buses of the
lightsim2grid.gridmodel.GridModel
to know on which “solver bus” they are affected. It has the same size as the total number of buses on the grid. And for each of them it tells to which “solver bus” it is connected (unless there is a 1, meaning the associated bus is deactivated).Examples
# create a grid model import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg "l2rpn_case14_sandbox" env = grid2op.make(env_name, backend=LightSimbackend()) grid_model = env.backend._grid id_me_to_ac_solver = grid.id_me_to_ac_solver() # is [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] # put everything to bus 2 on substation O _ = env.step(env.action_space({"set_bus": {"substations_id": [(0, (2, 2, 2))]}})) id_me_to_ac_solver2 = grid.id_me_to_ac_solver() # is [1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
See also
lightsim2grid.gridmodel.GridModel.id_me_to_dc_solver
for its counterpart when a dc powerflow is usedSee also
lightsim2grid.gridmodel.GridModel.id_ac_solver_to_me
for the “reverse” operation (given a “solver bus” id, returns the “gridmodel bus id”)Notes
For all steps, you have the propertie that, if id_ac_solver_to_me = gridmodel.id_ac_solver_to_me() and id_me_to_ac_solver = gridmodel.id_me_to_ac_solver() and by denoting gridmodel_bus_id = np.arange(gridmodel.total_bus()) and solver_bus_id = np.arange(gridmodel.nb_bus()):
solver_bus_id and id_ac_solver_to_me have the same shape
gridmodel_bus_id and id_me_to_ac_solver have the same shape
solver_bus_id is shorter (or of the same length) than gridmodel_bus_id
the connected bus (in the grid model) are given by gridmodel_bus_id[id_ac_solver_to_me], and it gives their order
 id_me_to_dc_solver(self: lightsim2grid_cpp.GridModel) list[int]
Same as
lightsim2grid.gridmodel.GridModel.id_me_to_ac_solver
but only used for the DC approximation.
 init_bus(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.float64[m, 1]], arg1: int, arg2: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 init_bus_status(self: lightsim2grid_cpp.GridModel) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 init_dclines(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1]], arg1: numpy.ndarray[numpy.int32[m, 1]], arg2: numpy.ndarray[numpy.float64[m, 1]], arg3: numpy.ndarray[numpy.float64[m, 1]], arg4: numpy.ndarray[numpy.float64[m, 1]], arg5: numpy.ndarray[numpy.float64[m, 1]], arg6: numpy.ndarray[numpy.float64[m, 1]], arg7: numpy.ndarray[numpy.float64[m, 1]], arg8: numpy.ndarray[numpy.float64[m, 1]], arg9: numpy.ndarray[numpy.float64[m, 1]], arg10: numpy.ndarray[numpy.float64[m, 1]]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 init_generators(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.float64[m, 1]], arg1: numpy.ndarray[numpy.float64[m, 1]], arg2: numpy.ndarray[numpy.float64[m, 1]], arg3: numpy.ndarray[numpy.float64[m, 1]], arg4: numpy.ndarray[numpy.int32[m, 1]]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 init_generators_full(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.float64[m, 1]], arg1: numpy.ndarray[numpy.float64[m, 1]], arg2: numpy.ndarray[numpy.float64[m, 1]], arg3: list[bool], arg4: numpy.ndarray[numpy.float64[m, 1]], arg5: numpy.ndarray[numpy.float64[m, 1]], arg6: numpy.ndarray[numpy.int32[m, 1]]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 init_loads(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.float64[m, 1]], arg1: numpy.ndarray[numpy.float64[m, 1]], arg2: numpy.ndarray[numpy.int32[m, 1]]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 init_powerlines(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.float64[m, 1]], arg1: numpy.ndarray[numpy.float64[m, 1]], arg2: numpy.ndarray[numpy.complex128[m, 1]], arg3: numpy.ndarray[numpy.int32[m, 1]], arg4: numpy.ndarray[numpy.int32[m, 1]]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 init_powerlines_full(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.float64[m, 1]], arg1: numpy.ndarray[numpy.float64[m, 1]], arg2: numpy.ndarray[numpy.complex128[m, 1]], arg3: numpy.ndarray[numpy.complex128[m, 1]], arg4: numpy.ndarray[numpy.int32[m, 1]], arg5: numpy.ndarray[numpy.int32[m, 1]]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 init_sgens(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.float64[m, 1]], arg1: numpy.ndarray[numpy.float64[m, 1]], arg2: numpy.ndarray[numpy.float64[m, 1]], arg3: numpy.ndarray[numpy.float64[m, 1]], arg4: numpy.ndarray[numpy.float64[m, 1]], arg5: numpy.ndarray[numpy.float64[m, 1]], arg6: numpy.ndarray[numpy.int32[m, 1]]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 init_shunt(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.float64[m, 1]], arg1: numpy.ndarray[numpy.float64[m, 1]], arg2: numpy.ndarray[numpy.int32[m, 1]]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 init_storages(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.float64[m, 1]], arg1: numpy.ndarray[numpy.float64[m, 1]], arg2: numpy.ndarray[numpy.int32[m, 1]]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 init_trafo(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.float64[m, 1]], arg1: numpy.ndarray[numpy.float64[m, 1]], arg2: numpy.ndarray[numpy.complex128[m, 1]], arg3: numpy.ndarray[numpy.float64[m, 1]], arg4: numpy.ndarray[numpy.float64[m, 1]], arg5: numpy.ndarray[numpy.float64[m, 1]], arg6: list[bool], arg7: numpy.ndarray[numpy.int32[m, 1]], arg8: numpy.ndarray[numpy.int32[m, 1]]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 nb_bus(self: lightsim2grid_cpp.GridModel) int
Returns (>0 integer) the number of connected buses on the powergrid (ignores the disconnected bus).
 reactivate_bus(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 reactivate_dcline(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 reactivate_gen(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 reactivate_load(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 reactivate_powerline(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 reactivate_result_computation(self: lightsim2grid_cpp.GridModel) None
Allows to reactivate the computation of the flows, reactive power absorbed by generators etc. when they are needed again after having been deactivated.
 reactivate_sgen(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 reactivate_shunt(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 reactivate_storage(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 reactivate_trafo(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 remove_gen_slackbus(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_dcline_names(self: lightsim2grid_cpp.GridModel, arg0: list[str]) None
TODO
 set_gen_names(self: lightsim2grid_cpp.GridModel, arg0: list[str]) None
TODO
 set_gen_pos_topo_vect(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_gen_to_subid(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_init_vm_pu(self: lightsim2grid_cpp.GridModel, arg0: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_line_ex_pos_topo_vect(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_line_ex_to_subid(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_line_names(self: lightsim2grid_cpp.GridModel, arg0: list[str]) None
TODO
 set_line_or_pos_topo_vect(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_line_or_to_subid(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_load_names(self: lightsim2grid_cpp.GridModel, arg0: list[str]) None
TODO
 set_load_pos_topo_vect(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_load_to_subid(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_max_nb_bus_per_sub(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_n_sub(self: lightsim2grid_cpp.GridModel, arg0: int) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_sgen_names(self: lightsim2grid_cpp.GridModel, arg0: list[str]) None
TODO
 set_shunt_names(self: lightsim2grid_cpp.GridModel, arg0: list[str]) None
TODO
 set_sn_mva(self: lightsim2grid_cpp.GridModel, arg0: float) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_storage_names(self: lightsim2grid_cpp.GridModel, arg0: list[str]) None
TODO
 set_storage_pos_topo_vect(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_storage_to_subid(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_trafo_hv_pos_topo_vect(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_trafo_hv_to_subid(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_trafo_lv_pos_topo_vect(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_trafo_lv_to_subid(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 set_trafo_names(self: lightsim2grid_cpp.GridModel, arg0: list[str]) None
TODO
 tell_recompute_sbus(self: lightsim2grid_cpp.GridModel) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 tell_recompute_ybus(self: lightsim2grid_cpp.GridModel) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 tell_solver_need_reset(self: lightsim2grid_cpp.GridModel) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 tell_ybus_change_sparsity_pattern(self: lightsim2grid_cpp.GridModel) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 property timer_last_ac_pf
TODO
 property timer_last_dc_pf
TODO
 total_bus(self: lightsim2grid_cpp.GridModel) int
Returns (>0 integer) the total number of buses in the powergrid (both connected and disconnected)
 turnedoff_no_pv(self: lightsim2grid_cpp.GridModel) None
Turned off (or generators with p = 0) generators will not be pv buses, they will not maintain voltage
 turnedoff_pv(self: lightsim2grid_cpp.GridModel) None
Turned off (or generators with p = 0) generators will be pv buses, they will maintain voltage (default)
 unset_changes(self: lightsim2grid_cpp.GridModel) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 update_gens_p(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[bool[m, 1], flags.writeable], arg1: numpy.ndarray[numpy.float32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 update_gens_v(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[bool[m, 1], flags.writeable], arg1: numpy.ndarray[numpy.float32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 update_loads_p(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[bool[m, 1], flags.writeable], arg1: numpy.ndarray[numpy.float32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 update_loads_q(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[bool[m, 1], flags.writeable], arg1: numpy.ndarray[numpy.float32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 update_sgens_p(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[bool[m, 1], flags.writeable], arg1: numpy.ndarray[numpy.float32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 update_slack_weights(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[bool[m, 1], flags.writeable]) None
TODO
 update_storages_p(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[bool[m, 1], flags.writeable], arg1: numpy.ndarray[numpy.float32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 update_topo(self: lightsim2grid_cpp.GridModel, arg0: numpy.ndarray[bool[m, 1], flags.writeable], arg1: numpy.ndarray[numpy.int32[m, 1], flags.writeable]) None
INTERNAL
Warning
/!\ Internal, do not use unless you know what you are doing /!\
This is used as part of a dedicated code for
lightsim2grid.LightSimBackend.LightSimBackend
 lightsim2grid.gridmodel.init(pp_net: pandapowerNet) GridModel [source]
Convert a pandapower network as input into a GridModel.
This can fail to convert the grid and still not throw any error, use with care (for example, you can run a powerflow after this conversion, run a powerflow with pandapower, and compare the results to make sure they match !)
Cases for which conversion is not possible include, but are not limited to:
the pandapower grid has 3 winding transformers
the pandapower grid has xwards
the pandapower grid has dcline
the pandapower grid has switch, motor, assymetric loads, etc.
the pandapower grid any parrallel “elements” (at least one of the column “parrallel” is not 1)
the bus indexes in pandapower do not start at 0 or are not contiguous (you can check pp_net.bus.index)
some g_us_per_km for some lines are not zero ? TODO not sure if that is still the case !
some p_mw for some shunts are not zero ? TODO not sure if that is still the case !
if you really need any of the above, please submit a github issue and we will work on their support.
This conversion has been extensively studied for the case118() of pandapower.networks and should work really well for this grid. Actually, this grid is used for testing the GridModel class.
 Parameters:
pp_net (
pandapower.auxiliary.pandapowerNet
) – The initial pandapower network you want to convert Returns:
model – The initialize gridmodel
 Return type: