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)
- class lightsim2grid.elements.GenInfo
This class represents what you get from retrieving some elements from
lightsim2grid.elements.GeneratorContainer
It allows to read information from each generator of the powergrid.
Warning
Data ca only be accessed from this element. You cannot modify (yet) the grid using this class.
Examples
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_generator = grid_model.get_generators()[0] # first generator is a `GenInfo` for gen in grid_model.get_generators(): # gen is a `GenInfo` gen.bus_id
Attributes:
Get the bus id (as an integer) at which each element of a
lightsim2grid.gridmodel.GridModel
is connected.Get the status (True = connected, False = disconnected) of each element of a
lightsim2grid.gridmodel.GridModel
This property specify whether or not a given element contains some "result" information.
Get the id of the element.
Tells whether or not this generator paticipated to the distributed slack bus.
Maximum reactive value that can be produced / absorbed by this generator given MVAr.
Minimum reactive value that can be produced / absorbed by this generator given MVAr.
Get the name of the element.
Get the active production (or consumption) in MW for element of the grid supporting this feature.
Get the reactive production (or consumption) in MVAr for element of the grid supporting this feature.
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this object is connected.
Get the magnitude of the complex voltage (in kV) of the bus at which this object is connected.
For each generators, gives the participation (for the distributed slack) of this particular generator.
Get the active production (or consumption) setpoint in MW for element of the grid supporting this feature.
TODO
Get the voltage magnitude setpoint (in pair unit and NOT in kV) for each element of the grid supporting this feature.
TODO
- property bus_id
Get the bus id (as an integer) at which each element of a
lightsim2grid.gridmodel.GridModel
is connected. If -1 is returned it means that the object is disconnected.
- property connected
Get the status (True = connected, False = disconnected) of each element of a
lightsim2grid.gridmodel.GridModel
- property has_res
This property specify whether or not a given element contains some “result” information. If set to
True
then the fields starting with res_ (eg res_p_mw) are filled otherwise they are initialized with an arbitrary (and meaningless) value.
- property id
Get the id of the element. Ids are integer from 0 to n-1 (if n denotes the number of such elements on the grid.)
Examples
We give the example only for generators, but it works similarly for every other types of objects in a
lightsim2grid.gridmodel.GridModel
.This gives something like:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_gen = grid_model.get_generators()[0] # or get_loads for loads, etc. first_gen.id # should be 0
- property is_slack
Tells whether or not this generator paticipated to the distributed slack bus.
Note
Depending on the solver used, it is possible that a generator we asked to participate to the distributed slack bus do not participate to it (for example if there is a more than one generator where is_slack is
True
but the model used to computed the powerflow do not support distributed slack buses - eglightsim2grid.solver.SparseLUSingleSlack
)This is why we recommend to use the (slower) but more accurate
lightsim2grid.solver.SparseLUSolver
orlightsim2grid.solver.KLUSolver
for example.
- property max_q_mvar
Maximum reactive value that can be produced / absorbed by this generator given MVAr.
Note
This is for now not taken into account by the solver. It is only used in
lightsim2grid.gridmodel.check_solution()
if check_q_limits is set toTrue
- property min_q_mvar
Minimum reactive value that can be produced / absorbed by this generator given MVAr.
Note
This is for now not taken into account by the solver. It is only used in
lightsim2grid.gridmodel.check_solution()
if check_q_limits is set toTrue
- property name
Get the name of the element. Names are string that should be unique. But if you really want things unique, use the id
Warning
Names are optional and might not be set when reading the grid.
Examples
We give the example only for generators, but it works similarly for every other types of objects in a
lightsim2grid.gridmodel.GridModel
.This gives something like:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_gen = grid_model.get_generators()[0] # or get_loads for loads, etc. first_gen.name
- property res_p_mw
Get the active production (or consumption) in MW for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_q_mvar
Get the reactive production (or consumption) in MVAr for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_theta_deg
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this object is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_theta_deg”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_v_kv
Get the magnitude of the complex voltage (in kV) of the bus at which this object is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_v_kv”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property slack_weight
For each generators, gives the participation (for the distributed slack) of this particular generator.
Note
Weights do not scale to one for this variable thus this number has no meaning by itself and should be compared with the others.
- property target_p_mw
Get the active production (or consumption) setpoint in MW for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
- property target_q_mvar
TODO
- property target_vm_pu
Get the voltage magnitude setpoint (in pair unit and NOT in kV) for each element of the grid supporting this feature.
Warning
This is given in “pair unit” (pu) system and not in kilo Volt (kV) !
- property voltage_regulator_on
TODO
Static Generators (more exotic)
- class lightsim2grid.elements.SGenInfo
This class represents what you get from retrieving some elements from
lightsim2grid.elements.SGenContainer
It allows to read information from each static generator of the powergrid.
Warning
Data ca only be accessed from this element. You cannot modify (yet) the grid using this class.
Examples
import grid2op from lightsim2grid import LightSimBackend # create a lightsim2grid "gridmodel" env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid # do something with the static generators first_static_generator = grid_model.get_static_generators()[0] # first static generator is a `SGenInfo` for sgen in grid_model.get_static_generators(): # sgen is a `SGenInfo` sgen.bus_id
Attributes:
Get the bus id (as an integer) at which each element of a
lightsim2grid.gridmodel.GridModel
is connected.Get the status (True = connected, False = disconnected) of each element of a
lightsim2grid.gridmodel.GridModel
This property specify whether or not a given element contains some "result" information.
Get the id of the element.
Maximum active value that can be produced / absorbed by this generator given in MW.
Maximum reactive value that can be produced / absorbed by this generator given MVAr.
Minimum active value that can be produced / absorbed by this generator given in MW.
Minimum reactive value that can be produced / absorbed by this generator given MVAr.
Get the name of the element.
Get the active production (or consumption) in MW for element of the grid supporting this feature.
Get the reactive production (or consumption) in MVAr for element of the grid supporting this feature.
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this object is connected.
Get the magnitude of the complex voltage (in kV) of the bus at which this object is connected.
Get the active production (or consumption) setpoint in MW for element of the grid supporting this feature.
Get the reactive production (or consumption) setpoint in MVAr for element of the grid supporting this feature.
- property bus_id
Get the bus id (as an integer) at which each element of a
lightsim2grid.gridmodel.GridModel
is connected. If -1 is returned it means that the object is disconnected.
- property connected
Get the status (True = connected, False = disconnected) of each element of a
lightsim2grid.gridmodel.GridModel
- property has_res
This property specify whether or not a given element contains some “result” information. If set to
True
then the fields starting with res_ (eg res_p_mw) are filled otherwise they are initialized with an arbitrary (and meaningless) value.
- property id
Get the id of the element. Ids are integer from 0 to n-1 (if n denotes the number of such elements on the grid.)
Examples
We give the example only for generators, but it works similarly for every other types of objects in a
lightsim2grid.gridmodel.GridModel
.This gives something like:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_gen = grid_model.get_generators()[0] # or get_loads for loads, etc. first_gen.id # should be 0
- property max_p_mw
Maximum active value that can be produced / absorbed by this generator given in MW.
Note
This is for now not taken into account by the solver. It is only used in
lightsim2grid.gridmodel.check_solution()
if check_q_limits is set toTrue
- property max_q_mvar
Maximum reactive value that can be produced / absorbed by this generator given MVAr.
Note
This is for now not taken into account by the solver. It is only used in
lightsim2grid.gridmodel.check_solution()
if check_q_limits is set toTrue
- property min_p_mw
Minimum active value that can be produced / absorbed by this generator given in MW.
Note
This is for now not taken into account by the solver. It is only used in
lightsim2grid.gridmodel.check_solution()
if check_q_limits is set toTrue
- property min_q_mvar
Minimum reactive value that can be produced / absorbed by this generator given MVAr.
Note
This is for now not taken into account by the solver. It is only used in
lightsim2grid.gridmodel.check_solution()
if check_q_limits is set toTrue
- property name
Get the name of the element. Names are string that should be unique. But if you really want things unique, use the id
Warning
Names are optional and might not be set when reading the grid.
Examples
We give the example only for generators, but it works similarly for every other types of objects in a
lightsim2grid.gridmodel.GridModel
.This gives something like:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_gen = grid_model.get_generators()[0] # or get_loads for loads, etc. first_gen.name
- property res_p_mw
Get the active production (or consumption) in MW for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_q_mvar
Get the reactive production (or consumption) in MVAr for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_theta_deg
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this object is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_theta_deg”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_v_kv
Get the magnitude of the complex voltage (in kV) of the bus at which this object is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_v_kv”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property target_p_mw
Get the active production (or consumption) setpoint in MW for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
- property target_q_mvar
Get the reactive production (or consumption) setpoint in MVAr for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
Loads and Storage Units
- class lightsim2grid.elements.LoadInfo
This class represents what you get from retrieving some elements from
lightsim2grid.elements.LoadContainer
. We remind the reader that storage units are also modeled as load in lightsim2grid.It allows to read information from each load / storage unit of the powergrid.
Warning
Data ca only be accessed from this element. You cannot modify (yet) the grid using this class.
Note
lightsim2grid Storages are modeled as load.
Examples
import grid2op from lightsim2grid import LightSimBackend # create a lightsim2grid "gridmodel" env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid # for loads first_load = grid_model.get_loads()[0] # first static generator is a `LoadInfo` for load in grid_model.get_loads(): # load is a `LoadInfo` load.bus_id # for loads first_storage_unit = grid_model.get_storages()[0] # first static generator is a `LoadInfo` for storage in grid_model.get_storages(): # storage is a `LoadInfo` storage.bus_id
Attributes:
Get the bus id (as an integer) at which each element of a
lightsim2grid.gridmodel.GridModel
is connected.Get the status (True = connected, False = disconnected) of each element of a
lightsim2grid.gridmodel.GridModel
This property specify whether or not a given element contains some "result" information.
Get the id of the element.
Get the name of the element.
Get the active production (or consumption) in MW for element of the grid supporting this feature.
Get the reactive production (or consumption) in MVAr for element of the grid supporting this feature.
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this object is connected.
Get the magnitude of the complex voltage (in kV) of the bus at which this object is connected.
Get the active production (or consumption) setpoint in MW for element of the grid supporting this feature.
Get the reactive production (or consumption) setpoint in MVAr for element of the grid supporting this feature.
- property bus_id
Get the bus id (as an integer) at which each element of a
lightsim2grid.gridmodel.GridModel
is connected. If -1 is returned it means that the object is disconnected.
- property connected
Get the status (True = connected, False = disconnected) of each element of a
lightsim2grid.gridmodel.GridModel
- property has_res
This property specify whether or not a given element contains some “result” information. If set to
True
then the fields starting with res_ (eg res_p_mw) are filled otherwise they are initialized with an arbitrary (and meaningless) value.
- property id
Get the id of the element. Ids are integer from 0 to n-1 (if n denotes the number of such elements on the grid.)
Examples
We give the example only for generators, but it works similarly for every other types of objects in a
lightsim2grid.gridmodel.GridModel
.This gives something like:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_gen = grid_model.get_generators()[0] # or get_loads for loads, etc. first_gen.id # should be 0
- property name
Get the name of the element. Names are string that should be unique. But if you really want things unique, use the id
Warning
Names are optional and might not be set when reading the grid.
Examples
We give the example only for generators, but it works similarly for every other types of objects in a
lightsim2grid.gridmodel.GridModel
.This gives something like:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_gen = grid_model.get_generators()[0] # or get_loads for loads, etc. first_gen.name
- property res_p_mw
Get the active production (or consumption) in MW for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_q_mvar
Get the reactive production (or consumption) in MVAr for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_theta_deg
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this object is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_theta_deg”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_v_kv
Get the magnitude of the complex voltage (in kV) of the bus at which this object is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_v_kv”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property target_p_mw
Get the active production (or consumption) setpoint in MW for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
- property target_q_mvar
Get the reactive production (or consumption) setpoint in MVAr for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
Shunts
- class lightsim2grid.elements.ShuntInfo
This class represents what you get from retrieving the shunts from
lightsim2grid.elements.ShuntContainer
.It allows to read information from each shunt of the powergrid.
Warning
Data ca only be accessed from this element. You cannot modify (yet) the grid using this class.
Examples
import grid2op from lightsim2grid import LightSimBackend # create a lightsim2grid "gridmodel" env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid # for shunts first_shunt = grid_model.get_shunts()[0] # first shunt, this is a `ShuntInfo` for shunt in grid_model.get_shunts(): # shunt is a `ShuntInfo` shunt.bus_id
Attributes:
Get the bus id (as an integer) at which each element of a
lightsim2grid.gridmodel.GridModel
is connected.Get the status (True = connected, False = disconnected) of each element of a
lightsim2grid.gridmodel.GridModel
This property specify whether or not a given element contains some "result" information.
Get the id of the element.
Get the name of the element.
Get the active production (or consumption) in MW for element of the grid supporting this feature.
Get the reactive production (or consumption) in MVAr for element of the grid supporting this feature.
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this object is connected.
Get the magnitude of the complex voltage (in kV) of the bus at which this object is connected.
Get the active production (or consumption) setpoint in MW for element of the grid supporting this feature.
Get the reactive production (or consumption) setpoint in MVAr for element of the grid supporting this feature.
- property bus_id
Get the bus id (as an integer) at which each element of a
lightsim2grid.gridmodel.GridModel
is connected. If -1 is returned it means that the object is disconnected.
- property connected
Get the status (True = connected, False = disconnected) of each element of a
lightsim2grid.gridmodel.GridModel
- property has_res
This property specify whether or not a given element contains some “result” information. If set to
True
then the fields starting with res_ (eg res_p_mw) are filled otherwise they are initialized with an arbitrary (and meaningless) value.
- property id
Get the id of the element. Ids are integer from 0 to n-1 (if n denotes the number of such elements on the grid.)
Examples
We give the example only for generators, but it works similarly for every other types of objects in a
lightsim2grid.gridmodel.GridModel
.This gives something like:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_gen = grid_model.get_generators()[0] # or get_loads for loads, etc. first_gen.id # should be 0
- property name
Get the name of the element. Names are string that should be unique. But if you really want things unique, use the id
Warning
Names are optional and might not be set when reading the grid.
Examples
We give the example only for generators, but it works similarly for every other types of objects in a
lightsim2grid.gridmodel.GridModel
.This gives something like:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_gen = grid_model.get_generators()[0] # or get_loads for loads, etc. first_gen.name
- property res_p_mw
Get the active production (or consumption) in MW for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_q_mvar
Get the reactive production (or consumption) in MVAr for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_theta_deg
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this object is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_theta_deg”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_v_kv
Get the magnitude of the complex voltage (in kV) of the bus at which this object is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_v_kv”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property target_p_mw
Get the active production (or consumption) setpoint in MW for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
- property target_q_mvar
Get the reactive production (or consumption) setpoint in MVAr for element of the grid supporting this feature.
For generators (and static generators) it is given following the “generator convention” (positive = power is injected to the grid)
For loads (and storage units) it is given following the “load convention” (positive = power is absorbed from the grid)
Lines
- class lightsim2grid.elements.LineInfo
This class represents what you get from retrieving the powerlines from
lightsim2grid.elements.LineContainer
.It allows to read information from each powerline of the powergrid.
Powerlines have two sides, one is “or” for “origin” and one is “ex” for “extremity” that are connected and linked to each other by some equations.
For accessing the results, it’s basically the same as having two “elements” (so you get two “voltage_magnitude” res_v_kv, two “injected power” res_p_mw etc.)
Warning
Data ca only be accessed from this element. You cannot modify (yet) the grid using this class.
Examples
import grid2op from lightsim2grid import LightSimBackend # create a lightsim2grid "gridmodel" env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid # for powerlines first_line = grid_model.get_lines()[0] # first line, this is a `LineInfo` for line in grid_model.get_lines(): # line is a `LineInfo` line.bus_or_id
Notes
Line are modeled using the “line model” as shown in the schema at the end of the paragraph.
The tap ratio n on this schema will be 1.0 for all powerline. If you want to model phase shifters, please model them as Trafo (see
lightsim2grid.elements.TrafoInfo
)For more information about the model and the equations linking all the quantities, please visit matpower manual , especially the “3. Modeling” and the “3.2 Branches” subsection, as well as the equation 3.1, 3.2 and 3.3 therein.
The “line model” (also valid for transformers) is:
ior ________ iex `or bus` o------> -----------------|r + j.x|---------<-------o `ex bus` | ) ( | | | | ) ( | | | | | | vor ) ( n:1 |1/2*h| |1/2*h| | vex | ) ( | | | | | \/ ) ( | | \/ ground---o------- -------------------------------------------o---- ground
(fyi: ior, iex, n and y are all complex numbers. r and x are real numbers. j is a complex number such that j^2 = -1)
Attributes:
Get the bus id (as an integer) at which the "lv" side of the line is connected.
Get the bus id (as an integer) at which the "or" side of the line is connected.
Get the status (True = connected, False = disconnected) of each element of a
lightsim2grid.gridmodel.GridModel
Retrieve the capacitance (real part) and dielectric conductance (imaginary part) (given in pair unit system) of the powerlines or the transformers.
Retrieve the capacitance (real part) and dielectric conductance (imaginary part) (given in pair unit system) of the powerlines or the transformers.
Retrieve the reactance (given in pair unit system, and not in Ohm) of the powerlines or the transformers.
This property specify whether or not a given element contains some "result" information.
Get the id of the element.
Get the name of the element.
Retrieve the resistance (given in pair unit system, and not in Ohm) of the powerlines or the transformers.
Get the current flows (in kA) at the "ex" side of the line.
Get the current flows (in kA) at the "or" side of the line.
Get the active power in MW for at the "ex" side of the line.
Get the active power in MW for at the "or" side of the line.
Get the reactive power in MVAr for at the "ex" side of the line.
Get the reactive power in MVAr for at the "or" side of the line.
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this "ex" side of the line is connected.
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this "or" side of the line is connected.
Get the magnitude of the complex voltage (in kV) of the bus at which this "ex" side of the line is connected.
Get the magnitude of the complex voltage (in kV) of the bus at which this "or" side of the line is connected.
Retrieve the reactance (given in pair unit system, and not in Ohm) of the powerlines or the transformers.
- property bus_ex_id
Get the bus id (as an integer) at which the “lv” side of the line is connected. If -1 is returned it means that the line is disconnected.
- property bus_or_id
Get the bus id (as an integer) at which the “or” side of the line is connected. If -1 is returned it means that the line is disconnected.
- property connected
Get the status (True = connected, False = disconnected) of each element of a
lightsim2grid.gridmodel.GridModel
- property h_ex_pu
Retrieve the capacitance (real part) and dielectric conductance (imaginary part) (given in pair unit system) of the powerlines or the transformers.
This is a complex number and is represented by the number h in the line model.
The “line model” (also valid for transformers) is:
ior ________ iex `or bus` o------> -----------------|r + j.x|---------<-------o `ex bus` | ) ( | | | | ) ( | | | | | | vor ) ( n:1 |1/2*h| |1/2*h| | vex | ) ( | | | | | \/ ) ( | | \/ ground---o------- -------------------------------------------o---- ground
(fyi: ior, iex, n and y are all complex numbers. r and x are real numbers. j is a complex number such that j^2 = -1)
- property h_or_pu
Retrieve the capacitance (real part) and dielectric conductance (imaginary part) (given in pair unit system) of the powerlines or the transformers.
This is a complex number and is represented by the number h in the line model.
The “line model” (also valid for transformers) is:
ior ________ iex `or bus` o------> -----------------|r + j.x|---------<-------o `ex bus` | ) ( | | | | ) ( | | | | | | vor ) ( n:1 |1/2*h| |1/2*h| | vex | ) ( | | | | | \/ ) ( | | \/ ground---o------- -------------------------------------------o---- ground
(fyi: ior, iex, n and y are all complex numbers. r and x are real numbers. j is a complex number such that j^2 = -1)
- property h_pu
Retrieve the reactance (given in pair unit system, and not in Ohm) of the powerlines or the transformers. This is a real number and is represented by the number x in the line model.
The “line model” (also valid for transformers) is:
ior ________ iex `or bus` o------> -----------------|r + j.x|---------<-------o `ex bus` | ) ( | | | | ) ( | | | | | | vor ) ( n:1 |1/2*h| |1/2*h| | vex | ) ( | | | | | \/ ) ( | | \/ ground---o------- -------------------------------------------o---- ground
(fyi: ior, iex, n and y are all complex numbers. r and x are real numbers. j is a complex number such that j^2 = -1)
- property has_res
This property specify whether or not a given element contains some “result” information. If set to
True
then the fields starting with res_ (eg res_p_mw) are filled otherwise they are initialized with an arbitrary (and meaningless) value.
- property id
Get the id of the element. Ids are integer from 0 to n-1 (if n denotes the number of such elements on the grid.)
Examples
We give the example only for generators, but it works similarly for every other types of objects in a
lightsim2grid.gridmodel.GridModel
.This gives something like:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_gen = grid_model.get_generators()[0] # or get_loads for loads, etc. first_gen.id # should be 0
- property name
Get the name of the element. Names are string that should be unique. But if you really want things unique, use the id
Warning
Names are optional and might not be set when reading the grid.
Examples
We give the example only for generators, but it works similarly for every other types of objects in a
lightsim2grid.gridmodel.GridModel
.This gives something like:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_gen = grid_model.get_generators()[0] # or get_loads for loads, etc. first_gen.name
- property r_pu
Retrieve the resistance (given in pair unit system, and not in Ohm) of the powerlines or the transformers. This is a real number and is represented by the number r in the line model.
The “line model” (also valid for transformers) is:
ior ________ iex `or bus` o------> -----------------|r + j.x|---------<-------o `ex bus` | ) ( | | | | ) ( | | | | | | vor ) ( n:1 |1/2*h| |1/2*h| | vex | ) ( | | | | | \/ ) ( | | \/ ground---o------- -------------------------------------------o---- ground
(fyi: ior, iex, n and y are all complex numbers. r and x are real numbers. j is a complex number such that j^2 = -1)
- property res_a_ex_ka
Get the current flows (in kA) at the “ex” side of the line.
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_a_or_ka
Get the current flows (in kA) at the “or” side of the line.
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_p_ex_mw
Get the active power in MW for at the “ex” side of the line. If it is positive it means power is absorbed by the line.
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_p_or_mw
Get the active power in MW for at the “or” side of the line. If it is positive it means power is absorbed by the line.
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_q_ex_mvar
Get the reactive power in MVAr for at the “ex” side of the line. If it is positive it means power is absorbed by the line.
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_q_or_mvar
Get the reactive power in MVAr for at the “or” side of the line. If it is positive it means power is absorbed by the line.
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_theta_ex_deg
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this “ex” side of the line is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_theta_deg”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_theta_or_deg
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this “or” side of the line is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_theta_deg”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_v_ex_kv
Get the magnitude of the complex voltage (in kV) of the bus at which this “ex” side of the line is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_v_kv”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_v_or_kv
Get the magnitude of the complex voltage (in kV) of the bus at which this “or” side of the line is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_v_kv”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property x_pu
Retrieve the reactance (given in pair unit system, and not in Ohm) of the powerlines or the transformers. This is a real number and is represented by the number x in the line model.
The “line model” (also valid for transformers) is:
ior ________ iex `or bus` o------> -----------------|r + j.x|---------<-------o `ex bus` | ) ( | | | | ) ( | | | | | | vor ) ( n:1 |1/2*h| |1/2*h| | vex | ) ( | | | | | \/ ) ( | | \/ ground---o------- -------------------------------------------o---- ground
(fyi: ior, iex, n and y are all complex numbers. r and x are real numbers. j is a complex number such that j^2 = -1)
Transformers
- class lightsim2grid.elements.TrafoInfo
This class represents what you get from retrieving the transformers from
lightsim2grid.elements.TrafoContainer
.It allows to read information from each transformer of the powergrid.
Transformers have two sides, one is “hv” for “high voltage” and one is “lv” for “low voltage” that are connected and linked to each other by some equations.
For accessing the results, it’s basically the same as having two “elements” (so you get two “voltage_magnitude” res_v_kv, two “injected power” res_p_mw etc.)
Warning
Data ca only be accessed from this element. You cannot modify (yet) the grid using this class.
Examples
import grid2op from lightsim2grid import LightSimBackend # create a lightsim2grid "gridmodel" env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid # for transformers first_transformer = grid_model.get_trafos()[0] # first transformer, this is a `TrafoInfo` for trafo in grid_model.get_trafos(): # trafo is a `TrafoInfo` trafo.bus_hv_id
Notes
Transformer are modeled using the “line model”.
Usually, the “or” side is the “hv” side and the “ex” side is the “lv” side.
The tap ratio n bellow is a complex number with its magnitude corresponding to the tap ratio and its angle to the phase shifter.
For more information about the model and the equations linking all the quantities, please visit matpower manual , especially the “3. Modeling” and the “3.2 Branches” subsection, as well as the equation 3.1, 3.2 and 3.3 therein.
The “line model” (also valid for transformers) is:
ior ________ iex `or bus` o------> -----------------|r + j.x|---------<-------o `ex bus` | ) ( | | | | ) ( | | | | | | vor ) ( n:1 |1/2*h| |1/2*h| | vex | ) ( | | | | | \/ ) ( | | \/ ground---o------- -------------------------------------------o---- ground
(fyi: ior, iex, n and y are all complex numbers. r and x are real numbers. j is a complex number such that j^2 = -1)
Attributes:
Get the bus id (as an integer) at which the "hv" side of the transformer is connected.
Get the bus id (as an integer) at which the "lv" side of the transformer is connected.
Get the status (True = connected, False = disconnected) of each element of a
lightsim2grid.gridmodel.GridModel
Retrieve the capacitance (real part) and dielectric conductance (imaginary part) (given in pair unit system) of the powerlines or the transformers.
This property specify whether or not a given element contains some "result" information.
Get the id of the element.
Gives whether the tap (both for the ratio and the phase shifter) is located "hv" side (default, when
True
) or "lv" side (whenFalse
).Get the name of the element.
Retrieve the resistance (given in pair unit system, and not in Ohm) of the powerlines or the transformers.
Retrieve the ratio (absolute value of the complex coefficient n in the powerline model).
Get the current flows (in kA) at the "hv" side of the transformer.
Get the current flows (in kA) at the "lv" side of the transformer.
Get the active power in MW for at the "hv" side of the transformer.
Get the active power in MW for at the "lv" side of the transformer.
Get the reactive power in MVAr for at the "hv" side of the transformer.
Get the reactive power in MVAr for at the "lv" side of the transformer.
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this "hv" side of the transformer is connected.
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this "lv" side of the transformer is connected.
Get the magnitude of the complex voltage (in kV) of the bus at which this "hv" side of the transformer is connected.
Get the magnitude of the complex voltage (in kV) of the bus at which this "lv" side of the transformer is connected.
Retrieve the shift angle (angle of the complex coefficient n in the powerline model).
Retrieve the reactance (given in pair unit system, and not in Ohm) of the powerlines or the transformers.
- property bus_hv_id
Get the bus id (as an integer) at which the “hv” side of the transformer is connected. If -1 is returned it means that the transformer is disconnected.
- property bus_lv_id
Get the bus id (as an integer) at which the “lv” side of the transformer is connected. If -1 is returned it means that the transformer is disconnected.
- property connected
Get the status (True = connected, False = disconnected) of each element of a
lightsim2grid.gridmodel.GridModel
- property h_pu
Retrieve the capacitance (real part) and dielectric conductance (imaginary part) (given in pair unit system) of the powerlines or the transformers.
This is a complex number and is represented by the number h in the line model.
The “line model” (also valid for transformers) is:
ior ________ iex `or bus` o------> -----------------|r + j.x|---------<-------o `ex bus` | ) ( | | | | ) ( | | | | | | vor ) ( n:1 |1/2*h| |1/2*h| | vex | ) ( | | | | | \/ ) ( | | \/ ground---o------- -------------------------------------------o---- ground
(fyi: ior, iex, n and y are all complex numbers. r and x are real numbers. j is a complex number such that j^2 = -1)
- property has_res
This property specify whether or not a given element contains some “result” information. If set to
True
then the fields starting with res_ (eg res_p_mw) are filled otherwise they are initialized with an arbitrary (and meaningless) value.
- property id
Get the id of the element. Ids are integer from 0 to n-1 (if n denotes the number of such elements on the grid.)
Examples
We give the example only for generators, but it works similarly for every other types of objects in a
lightsim2grid.gridmodel.GridModel
.This gives something like:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_gen = grid_model.get_generators()[0] # or get_loads for loads, etc. first_gen.id # should be 0
- property is_tap_hv_side
Gives whether the tap (both for the ratio and the phase shifter) is located “hv” side (default, when
True
) or “lv” side (whenFalse
).
- property name
Get the name of the element. Names are string that should be unique. But if you really want things unique, use the id
Warning
Names are optional and might not be set when reading the grid.
Examples
We give the example only for generators, but it works similarly for every other types of objects in a
lightsim2grid.gridmodel.GridModel
.This gives something like:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_gen = grid_model.get_generators()[0] # or get_loads for loads, etc. first_gen.name
- property r_pu
Retrieve the resistance (given in pair unit system, and not in Ohm) of the powerlines or the transformers. This is a real number and is represented by the number r in the line model.
The “line model” (also valid for transformers) is:
ior ________ iex `or bus` o------> -----------------|r + j.x|---------<-------o `ex bus` | ) ( | | | | ) ( | | | | | | vor ) ( n:1 |1/2*h| |1/2*h| | vex | ) ( | | | | | \/ ) ( | | \/ ground---o------- -------------------------------------------o---- ground
(fyi: ior, iex, n and y are all complex numbers. r and x are real numbers. j is a complex number such that j^2 = -1)
- property ratio
Retrieve the ratio (absolute value of the complex coefficient n in the powerline model). It has no units
The “line model” (also valid for transformers) is:
ior ________ iex `or bus` o------> -----------------|r + j.x|---------<-------o `ex bus` | ) ( | | | | ) ( | | | | | | vor ) ( n:1 |1/2*h| |1/2*h| | vex | ) ( | | | | | \/ ) ( | | \/ ground---o------- -------------------------------------------o---- ground
(fyi: ior, iex, n and y are all complex numbers. r and x are real numbers. j is a complex number such that j^2 = -1)
- property res_a_hv_ka
Get the current flows (in kA) at the “hv” side of the transformer.
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_a_lv_ka
Get the current flows (in kA) at the “lv” side of the transformer.
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_p_hv_mw
Get the active power in MW for at the “hv” side of the transformer. If it is positive it means power is absorbed by the transformer.
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_p_lv_mw
Get the active power in MW for at the “lv” side of the transformer. If it is positive it means power is absorbed by the transformer.
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_q_hv_mvar
Get the reactive power in MVAr for at the “hv” side of the transformer. If it is positive it means power is absorbed by the transformer.
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_q_lv_mvar
Get the reactive power in MVAr for at the “lv” side of the transformer. If it is positive it means power is absorbed by the transformer.
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_theta_hv_deg
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this “hv” side of the transformer is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_theta_deg”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_theta_lv_deg
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this “lv” side of the transformer is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_theta_deg”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_v_hv_kv
Get the magnitude of the complex voltage (in kV) of the bus at which this “hv” side of the transformer is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_v_kv”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_v_lv_kv
Get the magnitude of the complex voltage (in kV) of the bus at which this “lv” side of the transformer is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_v_kv”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property shift_rad
Retrieve the shift angle (angle of the complex coefficient n in the powerline model). It is given in radian (and not in degree)
The “line model” (also valid for transformers) is:
ior ________ iex `or bus` o------> -----------------|r + j.x|---------<-------o `ex bus` | ) ( | | | | ) ( | | | | | | vor ) ( n:1 |1/2*h| |1/2*h| | vex | ) ( | | | | | \/ ) ( | | \/ ground---o------- -------------------------------------------o---- ground
(fyi: ior, iex, n and y are all complex numbers. r and x are real numbers. j is a complex number such that j^2 = -1)
- property x_pu
Retrieve the reactance (given in pair unit system, and not in Ohm) of the powerlines or the transformers. This is a real number and is represented by the number x in the line model.
The “line model” (also valid for transformers) is:
ior ________ iex `or bus` o------> -----------------|r + j.x|---------<-------o `ex bus` | ) ( | | | | ) ( | | | | | | vor ) ( n:1 |1/2*h| |1/2*h| | vex | ) ( | | | | | \/ ) ( | | \/ ground---o------- -------------------------------------------o---- ground
(fyi: ior, iex, n and y are all complex numbers. r and x are real numbers. j is a complex number such that j^2 = -1)
DC Powerlines (more exotic)
- class lightsim2grid.elements.DCLineInfo
This class represents what you get from retrieving the dc powerlines from
lightsim2grid.elements.DCLineContainer
.It allows to read information from each dc powerline of the powergrid.
DC Powerlines have two sides, one is “or” for “origin” and one is “ex” for “extremity” that are connected and linked to each other by some equations.
For accessing the results, it’s basically the same as having two “elements” (so you get two “voltage_magnitude” res_v_kv, two “injected power” res_p_mw etc.)
Warning
Data ca only be accessed from this element. You cannot modify (yet) the grid using this class.
Examples
import grid2op from lightsim2grid import LightSimBackend # create a lightsim2grid "gridmodel" env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid # for powerlines first_line = grid_model.get_dclines()[0] # first dcline, this is a `DCLineInfo` for dcline in grid_model.get_dclines(): # dcline is a `LineInfo` dcline.bus_or_id
Notes
DC lines are modeled by two underlying generators.
Each of them can be controlled independantly for the voltage setpoint.
But they are linked together for their active value. A dc powerline has some losses (both in MW loss_mw and in percent loss_percent) and the formula for computing the power injected / produced by each generator is:
if xx is positive, then yy = -1.0 * (xx - loss_mw) * (1.0 - 0.01 * loss_percent)
if xx is negative, then `yy = -1.0 * xx / (1.0 - 0.01 * loss_percent) + loss_mw
The first formula directly comes from pandapower. The second one ensures that if the direction of the flow is inverted, then flows should also be inverted (xx becomes yy and reciprocally).
For the sake of simplicity, you can only control the active value at the or side of the dc powerline. The active value at the ex side is then computed by the GridModel.
Attributes:
Get the bus id (as an integer) at which the "lv" side of the line is connected.
Get the bus id (as an integer) at which the "or" side of the line is connected.
Get the status (True = connected, False = disconnected) of each element of a
lightsim2grid.gridmodel.GridModel
Direct access to the "ex" generators, directly returns a
lightsim2grid.elements.GenInfo
Direct access to the "or" generators, directly returns a
lightsim2grid.elements.GenInfo
This property specify whether or not a given element contains some "result" information.
Get the id of the element.
The value of the loss_mw parameter for the dc line.
The value of the loss percent parameter for the dc line.
Get the name of the element.
The amount of active power injected at the ex side of the dc powerline (in MW).
The amount of active power injected at the or side of the dc powerline (in MW).
The amount of reactive power injected at the ex side of the dc powerline (in MVAr).
The amount of reactive power injected at the or side of the dc powerline (in MVAr).
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this "ex" side of the dc line is connected.
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this "or" side of the dc line is connected.
Get the magnitude of the complex voltage (in kV) of the bus at which this "ex" side of the dc line is connected.
Get the magnitude of the complex voltage (in kV) of the bus at which this "or" side of the dc line is connected.
The target active production setpoint at the or side of the dc powerline (in MW).
The target active voltage setpoint at the ex side of the powerline (in pu NOT in kV).
The target active voltage setpoint at the or side of the powerline (in pu NOT in kV).
- property bus_ex_id
Get the bus id (as an integer) at which the “lv” side of the line is connected. If -1 is returned it means that the line is disconnected.
- property bus_or_id
Get the bus id (as an integer) at which the “or” side of the line is connected. If -1 is returned it means that the line is disconnected.
- property connected
Get the status (True = connected, False = disconnected) of each element of a
lightsim2grid.gridmodel.GridModel
- property gen_ex
Direct access to the “ex” generators, directly returns a
lightsim2grid.elements.GenInfo
Note
A DC line is modeled by two connected generators and some losses to convert the power from one to the other.
Two types of losses are considered:
flat losses: loss_mw (in MW)
relative losses: loss_percent (no unit)
The formula for computing the power injected / produced by each generator is:
if or_mw is positive, then ex_mw = -1.0 * (or_mw - loss_mw) * (1.0 - 0.01 * loss_percent)
if or_mw is negative, then `ex_mw = -1.0 * or_mw / (1.0 - 0.01 * loss_percent) + loss_mw
Where or_mw denotes the power injected at the origin side and ex_mw the power injected at the extremity side.
Note
By convention, a dc powerline adopts the load convention.
This means that if or_mw is positive then power is consumed at the or side, so the power flows from or to ex and vice versa.
- property gen_or
Direct access to the “or” generators, directly returns a
lightsim2grid.elements.GenInfo
Note
A DC line is modeled by two connected generators and some losses to convert the power from one to the other.
Two types of losses are considered:
flat losses: loss_mw (in MW)
relative losses: loss_percent (no unit)
The formula for computing the power injected / produced by each generator is:
if or_mw is positive, then ex_mw = -1.0 * (or_mw - loss_mw) * (1.0 - 0.01 * loss_percent)
if or_mw is negative, then `ex_mw = -1.0 * or_mw / (1.0 - 0.01 * loss_percent) + loss_mw
Where or_mw denotes the power injected at the origin side and ex_mw the power injected at the extremity side.
Note
By convention, a dc powerline adopts the load convention.
This means that if or_mw is positive then power is consumed at the or side, so the power flows from or to ex and vice versa.
- property has_res
This property specify whether or not a given element contains some “result” information. If set to
True
then the fields starting with res_ (eg res_p_mw) are filled otherwise they are initialized with an arbitrary (and meaningless) value.
- property id
Get the id of the element. Ids are integer from 0 to n-1 (if n denotes the number of such elements on the grid.)
Examples
We give the example only for generators, but it works similarly for every other types of objects in a
lightsim2grid.gridmodel.GridModel
.This gives something like:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_gen = grid_model.get_generators()[0] # or get_loads for loads, etc. first_gen.id # should be 0
- property loss_mw
The value of the loss_mw parameter for the dc line.
Note
A DC line is modeled by two connected generators and some losses to convert the power from one to the other.
Two types of losses are considered:
flat losses: loss_mw (in MW)
relative losses: loss_percent (no unit)
The formula for computing the power injected / produced by each generator is:
if or_mw is positive, then ex_mw = -1.0 * (or_mw - loss_mw) * (1.0 - 0.01 * loss_percent)
if or_mw is negative, then `ex_mw = -1.0 * or_mw / (1.0 - 0.01 * loss_percent) + loss_mw
Where or_mw denotes the power injected at the origin side and ex_mw the power injected at the extremity side.
Note
By convention, a dc powerline adopts the load convention.
This means that if or_mw is positive then power is consumed at the or side, so the power flows from or to ex and vice versa.
- property loss_pct
The value of the loss percent parameter for the dc line.
Note
A DC line is modeled by two connected generators and some losses to convert the power from one to the other.
Two types of losses are considered:
flat losses: loss_mw (in MW)
relative losses: loss_percent (no unit)
The formula for computing the power injected / produced by each generator is:
if or_mw is positive, then ex_mw = -1.0 * (or_mw - loss_mw) * (1.0 - 0.01 * loss_percent)
if or_mw is negative, then `ex_mw = -1.0 * or_mw / (1.0 - 0.01 * loss_percent) + loss_mw
Where or_mw denotes the power injected at the origin side and ex_mw the power injected at the extremity side.
Note
By convention, a dc powerline adopts the load convention.
This means that if or_mw is positive then power is consumed at the or side, so the power flows from or to ex and vice versa.
- property name
Get the name of the element. Names are string that should be unique. But if you really want things unique, use the id
Warning
Names are optional and might not be set when reading the grid.
Examples
We give the example only for generators, but it works similarly for every other types of objects in a
lightsim2grid.gridmodel.GridModel
.This gives something like:
import grid2op from lightsim2grid import LightSimBackend env_name = ... # eg. "l2rpn_case14_test" env = grid2op.make(env_name, backend=LightSimBackend()) grid_model = env.backend._grid first_gen = grid_model.get_generators()[0] # or get_loads for loads, etc. first_gen.name
- property res_p_ex_mw
The amount of active power injected at the ex side of the dc powerline (in MW).
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
Note
A DC line is modeled by two connected generators and some losses to convert the power from one to the other.
Two types of losses are considered:
flat losses: loss_mw (in MW)
relative losses: loss_percent (no unit)
The formula for computing the power injected / produced by each generator is:
if or_mw is positive, then ex_mw = -1.0 * (or_mw - loss_mw) * (1.0 - 0.01 * loss_percent)
if or_mw is negative, then `ex_mw = -1.0 * or_mw / (1.0 - 0.01 * loss_percent) + loss_mw
Where or_mw denotes the power injected at the origin side and ex_mw the power injected at the extremity side.
Note
By convention, a dc powerline adopts the load convention.
This means that if or_mw is positive then power is consumed at the or side, so the power flows from or to ex and vice versa.
- property res_p_or_mw
The amount of active power injected at the or side of the dc powerline (in MW).
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
Note
A DC line is modeled by two connected generators and some losses to convert the power from one to the other.
Two types of losses are considered:
flat losses: loss_mw (in MW)
relative losses: loss_percent (no unit)
The formula for computing the power injected / produced by each generator is:
if or_mw is positive, then ex_mw = -1.0 * (or_mw - loss_mw) * (1.0 - 0.01 * loss_percent)
if or_mw is negative, then `ex_mw = -1.0 * or_mw / (1.0 - 0.01 * loss_percent) + loss_mw
Where or_mw denotes the power injected at the origin side and ex_mw the power injected at the extremity side.
Note
By convention, a dc powerline adopts the load convention.
This means that if or_mw is positive then power is consumed at the or side, so the power flows from or to ex and vice versa.
- property res_q_ex_mvar
The amount of reactive power injected at the ex side of the dc powerline (in MVAr).
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_q_or_mvar
The amount of reactive power injected at the or side of the dc powerline (in MVAr).
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_theta_ex_deg
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this “ex” side of the dc line is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_theta_deg”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_theta_or_deg
Get the angle of the complex voltage (in degree, not in radian) of the bus at which this “or” side of the dc line is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_theta_deg”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_v_ex_kv
Get the magnitude of the complex voltage (in kV) of the bus at which this “ex” side of the dc line is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_v_kv”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property res_v_or_kv
Get the magnitude of the complex voltage (in kV) of the bus at which this “or” side of the dc line is connected.
Note
All elements (load, generators, side of powerline etc.) connected at the same bus have the same “res_v_kv”
Warning
This feature is only relevant if the results have been computed (for example if a powerflow has successfully run)
- property target_p_or_mw
The target active production setpoint at the or side of the dc powerline (in MW).
Note
If it’s positive it means that power is actually injected at the or side, so the power flows from ex to or.
- property target_vm_ex_pu
The target active voltage setpoint at the ex side of the powerline (in pu NOT in kV).
- property target_vm_or_pu
The target active voltage setpoint at the or side of the powerline (in pu NOT in kV).
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)Returns the "Bus from" matrix, with the bus having the gridmodel id (sparse matrix).
get_Bf_solver
(self)Returns the "Bus from" matrix, with the bus having the solver id (sparse matrix).
get_J_solver
(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 of the gridmodel.
get_Sbus_solver
(self)This function returns the (complex) Sbus vector used by the AC solver.
get_V
(self)Returns the complex voltage for each buses as a numpy vector of complex number.
get_V_solver
(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_Va_solver
(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_Vm_solver
(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 (for the AC powerflow) with the gridmodel convention.
get_Ybus_solver
(self)This function returns the (complex) Ybus matrix used to compute the AC 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)This function returns the (complex) Sbus vector of the gridmodel for the DC solver (imaginary part should be 0.).
get_dcSbus_solver
(self)This function returns the (complex) Sbus vector used by the DC sovler.
get_dcYbus
(self)This function returns the (complex) Ybus matrix (for the DC powerflow) (its imaginary part should be 0.) with the gridmodel convention.
get_dcYbus_solver
(self)This function returns the (complex) Ybus matrix used to compute the DC powerflow (its imaginary part should be 0.).
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)This function returns the LODF (Line Outage Distribution Factor) which tells you how much the flows on each powerline / tranformer will vary if some given powerline / transformer is disconnected.
get_n_sub
(self)INTERNAL
get_pq
(self)Returns the ids of the buses that are labelled as "PQ".
get_pq_solver
(self)Returns the ids of the buses that are labelled as "PQ".
get_ptdf
(self)This function returns the PTDF (Power Transfer Distribution Factor) which tells you how much the flows on each powerline / tranformer will vary if some given power is injected on each bus of the grid.
get_ptdf_solver
(self)This function returns the PTDF (Power Transfer Distribution Factor) which tells you how much the flows on each powerline / tranformer will vary if some given power is injected on each bus of the grid.
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_pv_solver
(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_ids_dc
(self)Returns the ids of the buses that are part of the distributed slack (for DC, currently not taken into account).
get_slack_ids_dc_solver
(self)Returns the ids of the buses that are part of the distributed slack (for DC, currently not taken into account).
get_slack_ids_solver
(self)Returns the ids of the buses that are part of the distributed slack.
get_slack_weights
(self)For each bus in the gridmodel solver, it outputs its participation to the distributed slack.
get_slack_weights_solver
(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 n-1 (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 n-1 (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 # have an initial guess for the complex voltage at each bus Vinit = np.ones(grid_model.total_bus(), dtype=complex) # maximum number of iteration nb_iter = 10 # a good default # tolerance tol = 1e-8 V = grid_model.ac_pf(Vinit, nb_iter, tol) # 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 # have an initial guess for the complex voltage at each bus Vinit = np.ones(grid_model.total_bus(), dtype=complex) # maximum number of iteration nb_iter = 10 # a good default # tolerance tol = 1e-8 V = grid_model.ac_pf(Vinit, nb_iter, tol) # 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]
Returns the “Bus from” matrix, with the bus having the gridmodel id (sparse matrix).
More specifically, it is a matrix with (nb line + nb trafo) rows and (nb total bus) columns.
For each powerline / transformer (row i), there is a +1 for the “origin side” bus and a -1 for the “extremity side” bus if the line / trafo is connected. If it is disconnected then the associated row will be full of 0.
Note
First len(gridmodel.get_lines()) rows represent the powerlines, the remaining len(gridmodel.get_trafos()) represent transformers.
See also
lightsim2grid.gridmodel.GridModel.get_Bf_solver()
which will give the same matrix but with buses with the “solver” labelling (thus having no columns of 0)
- get_Bf_solver(self: lightsim2grid_cpp.GridModel) scipy.sparse.csc_matrix[numpy.float64]
Returns the “Bus from” matrix, with the bus having the solver id (sparse matrix).
More specifically, it is a matrix with (nb line + nb trafo) rows and (nb connected bus) columns.
For each powerline / transformer (row i), there is a +1 for the “origin side” bus and a -1 for the “extremity side” bus if the line / trafo is connected. If it is disconnected then the associated row will be full of 0.
Note
First len(gridmodel.get_lines()) rows represent the powerlines, the remaining len(gridmodel.get_trafos()) represent transformers.
See also
lightsim2grid.gridmodel.GridModel.get_Bf()
which will give the same matrix but with the buses having the “gridmodel” labelling
- get_J_solver(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.
The “jacobian” matrix is only available for some powerflow algorithms (the one based on the Newton Raphson algorithm) and we provide it only for the last computed iteration.
Danger
They are labelled with the solver labelling, which corresponds to the previous behaviour in
lightsim2grid.gridmodel.GridModel.get_J()
(before version 0.9.0)New in version 0.9.0: This function replace the
lightsim2grid.gridmodel.GridModel.get_J()
of earlier lightsim2grid version. The new version oflightsim2grid.gridmodel.GridModel.get_J()
now returns the id labelled with the gridmodel convention (for consistency).Note
Some powerflows (eg DC or Gauss Seidel) do not rely on jacobian matrix, in this case, calling this function will return an exception.
For the distributed slack, 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)
Note
All notation here are notation for the solver. You should use gridmodel.get_pq_solver() and gridmodel.get_pv_solver() to retrieve their value.
Note
For distributed slack, the pvpq here also integrate all the buses in the slack (except for the first one which is the reference)
- get_Sbus(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.complex128[m, 1]]
This function returns the (complex) Sbus vector of the gridmodel. It is build using the “Sbus” passed to the AC solver for which the buses have been properly relabelled in the gridmodel convention.
The resulting vector is a vector of complex number having the size of the number of total buses on the grid.
See also
If you want to retrieve the Sbus with the “solver” convention, you can use
lightsim2grid.gridmodel.get_Sbus_solver()
Danger
Major change in version 0.9.0 of lightsim2grid (see versionchanged below)
Changed in version 0.9.0: It has not the same definition as the “old” behaviour. In the old behaviour, the get_Sbus used the solver convention. To get the “old” behaviour, you need to use
lightsim2grid.gridmodel.get_Sbus_solver()
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_Sbus_solver(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.complex128[m, 1]]
This function returns the (complex) Sbus vector used by the AC solver. It 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.
See also
If you want to retrieve the Sbus with the “gridmodel” convention, you can use
lightsim2grid.gridmodel.get_Sbus()
New in version 0.9.0: It was named get_Sbus before this version, but the name has been changed to avoid confusing AND a new function (this one) has been made with the proper gridmodel labelling.
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 buses on the system, including the disconnected bus. It adopts the “gridmodel” labelling.
Changed in version 0.9.0: They are labelled with the grimodel labelling. To retrieve the previous behaviour (solver labelling) you can use the current
lightsim2grid.gridmodel.GridModel.get_V_solver()
(before version 0.9.0)Danger
Some breaking change have been introduced in lighsim2grid 0.9.0. You can
lightsim2grid.gridmodel.GridModel.get_V_solver()
to get the previous (before 0.9.0) behaviour.Note
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_V_solver(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 number of active buses on the system and adopts the “solver” labelling.
Danger
They are labelled with the solver labelling, which corresponds to the previous behaviour in
lightsim2grid.gridmodel.GridModel.get_V()
(before version 0.9.0)New in version 0.9.0: This function replace the
lightsim2grid.gridmodel.GridModel.get_V()
of earlier lightsim2grid version. The new version oflightsim2grid.gridmodel.GridModel.get_V()
now returns the id labelled with the gridmodel convention (for consistency).Note
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 buses on the system, including the disconnected bus. It adopts the “gridmodel” labelling.
Changed in version 0.9.0: They are labelled with the grimodel labelling. To retrieve the previous behaviour (solver labelling) you can use the current
lightsim2grid.gridmodel.GridModel.get_Va_solver()
(before version 0.9.0)Danger
Some breaking change have been introduced in lighsim2grid 0.9.0. You can
lightsim2grid.gridmodel.GridModel.get_Va_solver()
to get the previous (before 0.9.0) behaviour.Note
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_solver(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 number of active buses on the system and adopts the “solver” labelling.
Danger
They are labelled with the solver labelling, which corresponds to the previous behaviour in
lightsim2grid.gridmodel.GridModel.get_Va()
(before version 0.9.0)New in version 0.9.0: This function replace the
lightsim2grid.gridmodel.GridModel.get_Va()
of earlier lightsim2grid version. The new version oflightsim2grid.gridmodel.GridModel.get_Va()
now returns the id labelled with the gridmodel convention (for consistency).Note
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 buses on the system, including the disconnected bus. It adopts the “gridmodel” labelling.
Changed in version 0.9.0: They are labelled with the grimodel labelling. To retrieve the previous behaviour (solver labelling) you can use the current
lightsim2grid.gridmodel.GridModel.get_Vm_solver()
(before version 0.9.0)Danger
Some breaking change have been introduced in lighsim2grid 0.9.0. You can
lightsim2grid.gridmodel.GridModel.get_Vm_solver()
to get the previous (before 0.9.0) behaviour.Note
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_solver(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 number of active buses on the system and adopts the “solver” labelling.
Danger
They are labelled with the solver labelling, which corresponds to the previous behaviour in
lightsim2grid.gridmodel.GridModel.get_Vm()
(before version 0.9.0)New in version 0.9.0: This function replace the
lightsim2grid.gridmodel.GridModel.get_Vm()
of earlier lightsim2grid version. The new version oflightsim2grid.gridmodel.GridModel.get_Vm()
now returns the id labelled with the gridmodel convention (for consistency).Note
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 (for the AC powerflow) with the gridmodel convention.
The resulting matrix is a CSC scipy sparse matrix of complex number.
It is a square matrix, as many rows (columns) as there are total buses on the grid.
See also
If you want to retrieve the Ybus adopting the “solver” bus labelling (old behaviour), you can use
lightsim2grid.gridmodel.get_Ybus_solver()
Danger
Major change in version 0.9.0 of lightsim2grid (see versionchanged below)
Changed in version 0.9.0: It has not the same definition as the “old” behaviour. In the old behaviour, the get_Ybus used the solver convention. To get the “old” behaviour, you need to use
lightsim2grid.gridmodel.get_Ybus_solver()
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_Ybus_solver(self: lightsim2grid_cpp.GridModel) scipy.sparse.csc_matrix[numpy.complex128]
This function returns the (complex) Ybus matrix used to compute the AC 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.
See also
If you want to retrieve the Ybus adopting the “gridmodel” bus labelling, you can use
lightsim2grid.gridmodel.get_Ybus()
New in version 0.9.0: It was named get_Ybus before this version, but the name has been changed to avoid confusing AND a new function (this one) has been made with the proper gridmodel labelling.
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]]
This function returns the (complex) Sbus vector of the gridmodel for the DC solver (imaginary part should be 0.). It is build using the “dcSbus” passed to the DC solver for which the buses have been properly relabelled in the gridmodel convention.
The resulting vector is a vector of complex number having the size of the number of total buses on the grid.
See also
If you want to retrieve the Sbus with the “sovler” convention, you can use
lightsim2grid.gridmodel.get_dcSbus_solver()
New in version 0.9.0.
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_dcSbus_solver(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.complex128[m, 1]]
This function returns the (complex) Sbus vector used by the DC sovler. It 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.
See also
If you want to retrieve the Sbus with the “gridmodel” convention, you can use
lightsim2grid.gridmodel.get_dcSbus()
New in version 0.9.0.
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_dcYbus(self: lightsim2grid_cpp.GridModel) scipy.sparse.csc_matrix[numpy.complex128]
This function returns the (complex) Ybus matrix (for the DC powerflow) (its imaginary part should be 0.) with the gridmodel convention.
The resulting matrix is a CSC scipy sparse matrix of complex number.
It is a square matrix, as many rows (columns) as there are total buses on the grid.
See also
If you want to retrieve the Ybus adopting the “solver” bus labelling (old behaviour), you can use
lightsim2grid.gridmodel.get_dcYbus_solver()
Danger
Major change in version 0.9.0 of lightsim2grid (see versionchanged below)
Changed in version 0.9.0: It has not the same definition as the “old” behaviour. In the old behaviour, the get_dcYbus used the solver convention. To get the “old” behaviour, you need to use
lightsim2grid.gridmodel.get_dcYbus_solver()
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_dcYbus_solver(self: lightsim2grid_cpp.GridModel) scipy.sparse.csc_matrix[numpy.complex128]
This function returns the (complex) Ybus matrix used to compute the DC powerflow (its imaginary part should be 0.).
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.
See also
If you want to retrieve the Ybus adopting the “gridmodel” bus labelling, you can use
lightsim2grid.gridmodel.get_dcYbus()
New in version 0.9.0: It was named get_dcYbus before this version, but the name has been changed to avoid confusing AND a new function (this one) has been made with the proper gridmodel labelling.
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_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]]
This function returns the LODF (Line Outage Distribution Factor) which tells you how much the flows on each powerline / tranformer will vary if some given powerline / transformer is disconnected.
It is a dense matrix, with (nb lines + nb tranformers) rows and (nb lines + nb tranformers) columns.
Each rows / columns represent a powerline / transformers. More concretely, the coefficient at row i and column j represents how much the flows on line / transformer i will vary if line / transformer j is disconnected.
Note
First len(gridmodel.get_lines()) rows / columns represent the powerlines, the remaining len(gridmodel.get_trafos()) represent transformers.
Note
You need to run a DC powerflow before calling this method (otherwise an exception is raised.)
Internally, this method will compute the PTDF
It is an alternative to compute DC powerflows when powerlines are disconnected.
import numpy as np # 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 # have an initial guess for the complex voltage at each bus Vinit = np.ones(grid_model.total_bus(), dtype=complex) Vdc = grid_model.dc_pf(Vinit, 1, 1e-8) LODF_mat = 1. * grid_model.get_lodf() lor_p, *_ = grid_model.get_lineor_res() tor_p, *_ = grid_model.get_trafohv_res() init_powerflow = np.concatenate((lor_p, tor_p)) # if you want to see the impact of a single line disconnected l_id = 0 # (or anything between 0 and n_line + n_trafo) por_lodf = init_powerflow + LODF_mat[:, l_id] * init_powerflow[l_id] # the effect when disconnecting all powerlines (one powerline disconnected each steps) mat_flow = np.tile(init_powerflow, LODF_mat.shape[0]).reshape(LODF_mat.shape) por_lodf = mat_flow + LODF_mat.T * mat_flow.T
- get_n_sub(self: lightsim2grid_cpp.GridModel) 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_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.
Danger
From lightsim2grid 0.9.0 they are labelled with the gridmodel labelling.
This behaviour is now accessible with the
lightsim2grid.gridmodel.GridModel.get_pq()
before version 0.9.0Changed in version 0.9.0: The new version of this function returns the id labelled with the gridmodel convention (for consistency).
Earlier version returned the labelling in the “solver” convention. To access the earlier function, please use the
lightsim2grid.gridmodel.GridModel.get_pq()
function.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_pq_solver(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.
Danger
They are labelled with the solver labelling, which corresponds to the previous behaviour in
lightsim2grid.gridmodel.GridModel.get_pq()
before version 0.9.0New in version 0.9.0: This function replace the
lightsim2grid.gridmodel.GridModel.get_pq()
of earlier lightsim2grid version. The new version oflightsim2grid.gridmodel.GridModel.get_pq()
now returns the id labelled with the gridmodel convention (for consistency).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]]
This function returns the PTDF (Power Transfer Distribution Factor) which tells you how much the flows on each powerline / tranformer will vary if some given power is injected on each bus of the grid.
It adopts the gridmodel bus labelling.
It is a dense matrix, with (nb lines + nb tranformers) rows and (nb total bus) columns.
Note
You need to run a DC powerflow before calling this method (otherwise an exception is raised.)
It is an alternative to compute DC powerflows (provided that the topology of the grid is not modified). You can do it with:
import numpy as np # 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 # have an initial guess for the complex voltage at each bus Vinit = np.ones(grid_model.total_bus(), dtype=complex) Vdc = grid_model.dc_pf(Vinit, 1, 1e-8) PTDF = grid_model.get_ptdf() new_Sbus = 1.7 * grid_model.get_dcSbus() new_flows = np.dot(PTDF, new_Sbus * grid_model.get_sn_mva()) # the flows on the grid if every injection is multiplied by 1.7
Note
If a bus is disconnected, then the associated columns is full of 0.
Note
If the vector Sbus does not sum to 0. the “slack” used is the first slack of the slack vector. No distributed slack is used for DC at the moment.
If you want distributed slack in this case, please open a feature request on github.
Note
The ‘power’ “injected” at disconnected buses (buses with colums of PTDF full of 0.) is completely discarded (multiplied by 0.)
- get_ptdf_solver(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.float64[m, n]]
This function returns the PTDF (Power Transfer Distribution Factor) which tells you how much the flows on each powerline / tranformer will vary if some given power is injected on each bus of the grid.
It adopts the solver bus labelling.
It is a dense matrix, with (nb lines + nb tranformers) rows and (nb activated bus) columns.
Each rows represents a powerline (or a transformer) and each columns represent a bus.
So the coefficient at row i and column j of this matrix represents the increase of flow (in MW) of powerline i if the power on bus j is increased of 1MW.
Note
First len(gridmodel.get_lines()) rows represent the powerlines, the remaining len(gridmodel.get_trafos()) represent transformers.
Note
You need to run a DC powerflow before calling this method (otherwise an exception is raised.)
It is an alternative to compute DC powerflows (provided that the topology of the grid is not modified). You can do it with:
import numpy as np # 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 # have an initial guess for the complex voltage at each bus Vinit = np.ones(grid_model.total_bus(), dtype=complex) Vdc = grid_model.dc_pf(Vinit, 1, 1e-8) PTDF = grid_model.get_ptdf_solver() new_Sbus = 1.7 * grid_model.get_dcSbus_solver() new_flows = np.dot(PTDF, new_Sbus * grid_model.get_sn_mva()) # the flows on the grid if every injection is multiplied by 1.7 # spoiler: it will be multiplied by 1.7, but you get the idea, # you can change Sbus in a different ways...
Note
If a bus is disconnected, then the associated columns is full of 0.
Note
If the vector Sbus does not sum to 0. the “slack” used is the first slack of the slack vector. No distributed slack is used for DC at the moment.
If you want distributed slack in this case, please open a feature request on github.
Note
With this convention, the disconnected bus are not modeled.
- 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.
Danger
From lightsim2grid 0.9.0 they are labelled with the gridmodel labelling.
This behaviour is now accessible with the
lightsim2grid.gridmodel.GridModel.get_pv()
before version 0.9.0Changed in version 0.9.0: The new version of this function returns the id labelled with the gridmodel convention (for consistency).
Earlier version returned the labelling in the “solver” convention. To access the earlier function, please use the
lightsim2grid.gridmodel.GridModel.get_pv()
function.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_pv_solver(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.
Danger
They are labelled with the solver labelling, which corresponds to the previous behaviour in
lightsim2grid.gridmodel.GridModel.get_pv()
before version 0.9.0New in version 0.9.0: This function replace the
lightsim2grid.gridmodel.GridModel.get_pv()
of earlier lightsim2grid version. The new version oflightsim2grid.gridmodel.GridModel.get_pv()
now returns the id labelled with the gridmodel convention (for consistency).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.
Danger
From lightsim2grid 0.9.0 they are labelled with the gridmodel labelling.
This behaviour is now accessible with the
lightsim2grid.gridmodel.GridModel.get_slack_ids_solver()
before version 0.9.0Changed in version 0.9.0: The new version of this function returns the id labelled with the gridmodel convention (for consistency).
Earlier version returned the labelling in the “solver” convention. To access the earlier function, please use the
lightsim2grid.gridmodel.GridModel.get_slack_ids_solver()
function.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_ids_dc(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.int32[m, 1]]
Returns the ids of the buses that are part of the distributed slack (for DC, currently not taken into account).
It returns a vector of integer.
Danger
From lightsim2grid 0.9.0 they are labelled with the gridmodel labelling.
This behaviour is now accessible with the
lightsim2grid.gridmodel.GridModel.get_slack_ids_dc_solver()
before version 0.9.0Changed in version 0.9.0: The new version of this function returns the id labelled with the gridmodel convention (for consistency).
Earlier version returned the labelling in the “solver” convention. To access the earlier function, please use the
lightsim2grid.gridmodel.GridModel.get_slack_ids_dc_solver()
function.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_ids_dc_solver(self: lightsim2grid_cpp.GridModel) numpy.ndarray[numpy.int32[m, 1]]
Returns the ids of the buses that are part of the distributed slack (for DC, currently not taken into account).
It returns a vector of integer.
New in version 0.9.0: Only what is now
lightsim2grid.gridmodel.GridModel.get_slack_ids_solver()
(that used to be calledlightsim2grid.gridmodel.GridModel.get_slack_ids()
) was available.There were no possibility to retrieve that for DC powerflow.
Danger
They are labelled with the solver labelling, which corresponds to the previous behaviour in
lightsim2grid.gridmodel.GridModel.get_slack_ids()
before version 0.9.0Warning
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_ids_solver(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.
Danger
They are labelled with the solver labelling, which corresponds to the previous behaviour in
lightsim2grid.gridmodel.GridModel.get_slack_ids()
before version 0.9.0New in version 0.9.0: This function replace the
lightsim2grid.gridmodel.GridModel.get_slack_ids()
of earlier lightsim2grid version. The new version oflightsim2grid.gridmodel.GridModel.get_slack_ids()
now returns the id labelled with the gridmodel convention (for consistency).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 in the gridmodel 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.
Danger
From lightsim2grid 0.9.0 they are labelled with the gridmodel labelling.
This behaviour is now accessible with the
lightsim2grid.gridmodel.GridModel.get_slack_weights_solver()
before version 0.9.0Changed in version 0.9.0: The new version of this function returns the id labelled with the gridmodel convention (for consistency).
Earlier version returned the labelling in the “solver” convention. To access the earlier function, please use the
lightsim2grid.gridmodel.GridModel.get_slack_weights_solver()
function.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_solver(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.
Danger
They are labelled with the solver labelling, which corresponds to the previous behaviour in
lightsim2grid.gridmodel.GridModel.get_slack_weights()
before version 0.9.0New in version 0.9.0: This function replace the
lightsim2grid.gridmodel.GridModel.get_slack_weights_solver()
of earlier lightsim2grid version. The new version oflightsim2grid.gridmodel.GridModel.get_slack_weights_solver()
now returns the id labelled with the gridmodel convention (for consistency).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 n-1 (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 n-1 (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_from_pandapower(pp_net: pandapowerNet) GridModel
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: