Skip to content

Commit

Permalink
synch with bd-dev
Browse files Browse the repository at this point in the history
Signed-off-by: DONNOT Benjamin <[email protected]>
  • Loading branch information
BDonnot committed Jan 9, 2025
2 parents 26d8d32 + cf80467 commit 20c9276
Show file tree
Hide file tree
Showing 16 changed files with 495 additions and 729 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Change Log
- maybe have a look at suitesparse "sliplu" tools ?
- easier building (get rid of the "make" part)

TODO: speed directly update the pv, pq, Sbus and Ybus part when updating the elements
(less error prone and faster to recompute). Then what is passed to the solver
is "only" a "mask" of these data when null
TODO: https://github.com/haranjackson/NewtonKrylov for another type of algorithm ?
TODO HVDC in Jacobian (see pandapower)
TODO: in ContingencyAnalysisCpp: add back the `if(!ac_solver_used)` inside the `remove_from_Ybus`
Expand All @@ -29,12 +32,19 @@ TODO: integration test with pandapower (see `pandapower/contingency/contingency.
[0.10.1] 2025-01-xx
----------------------
- [FIXED] some timings on the benchmarks were not measured at the right time
- [FIXED] an error when changing of bus one of the slack (did not trigger the
recompute of pv bus ids)
- [FIXED] an issue when turning off a generator: it was still declared as "slack"
if it was one.
- [FIXED] could not disconnect a generator when it was a slack bus
- [ADDED] more benchmarks especially for DC powerflow
- [ADDED] a `dfpc` function that can replace the pandapower `dcpf` interal function
- [ADDED] packaging package as a dependency
- [IMPROVED] benchmark on the documentation
(clarity of what is done)
- [IMPROVED] consistency of the names and measured times accross the different benchmarks
- [IMPROVED] refactoring of the c++ side container element to reduce
code (for "one end" elements such as loads, generators, static generators and shunts)

[0.10.0] 2024-12-17
-------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Benjamin DONNOT'

# The full version, including alpha/beta/rc tags
release = "0.10.0"
release = "0.10.1.dev0"
version = '0.10'

# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lightsim2grid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# SPDX-License-Identifier: MPL-2.0
# This file is part of LightSim2grid, LightSim2grid implements a c++ backend targeting the Grid2Op platform.

__version__ = "0.10.0"
__version__ = "0.10.1.dev0"

__all__ = ["newtonpf", "SolverType", "ErrorType", "solver", "compilation_options"]

Expand Down
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pybind11.setup_helpers import Pybind11Extension, build_ext


__version__ = "0.10.0"
__version__ = "0.10.1.dev0"
KLU_SOLVER_AVAILABLE = False

# Try to link against SuiteSparse (if available)
Expand Down Expand Up @@ -152,14 +152,16 @@
"src/batch_algorithm/BaseBatchSolverSynch.cpp",
"src/batch_algorithm/TimeSeries.cpp",
"src/batch_algorithm/ContingencyAnalysis.cpp",
"src/element_container/LineContainer.cpp",
"src/element_container/GenericContainer.cpp",
"src/element_container/OneSideContainer.cpp",
"src/element_container/ShuntContainer.cpp",
"src/element_container/TrafoContainer.cpp",
"src/element_container/LoadContainer.cpp",
"src/element_container/GeneratorContainer.cpp",
"src/element_container/SGenContainer.cpp",
"src/element_container/DCLineContainer.cpp"]
"src/element_container/DCLineContainer.cpp",
"src/element_container/LineContainer.cpp",
]

if KLU_SOLVER_AVAILABLE:
src_files.append("src/linear_solvers/KLUSolver.cpp")
Expand Down
14 changes: 9 additions & 5 deletions src/GridModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,9 @@ CplxVect GridModel::pre_process_solver(const CplxVect & Vinit,
if (solver_control.need_reset_solver() ||
solver_control.ybus_change_sparsity_pattern() ||
solver_control.has_dimension_changed()){
init_Ybus(Ybus, id_me_to_solver, id_solver_to_me);
init_converter_bus_id(id_me_to_solver, id_solver_to_me);
const int nb_bus_solver = static_cast<int>(id_solver_to_me.size());
init_Ybus(Ybus, nb_bus_solver);
}
if (solver_control.need_reset_solver() ||
solver_control.ybus_change_sparsity_pattern() ||
Expand Down Expand Up @@ -642,9 +644,9 @@ void GridModel::process_results(bool conv,
}
}

void GridModel::init_Ybus(Eigen::SparseMatrix<cplx_type> & Ybus,
std::vector<int>& id_me_to_solver,
std::vector<int>& id_solver_to_me){
void GridModel::init_converter_bus_id(std::vector<int>& id_me_to_solver,
std::vector<int>& id_solver_to_me){

//TODO get disconnected bus !!! (and have some conversion for it)
//1. init the conversion bus
const int nb_bus_init = static_cast<int>(bus_vn_kv_.size());
Expand All @@ -660,8 +662,10 @@ void GridModel::init_Ybus(Eigen::SparseMatrix<cplx_type> & Ybus,
++bus_id_solver;
}
}
const int nb_bus_solver = static_cast<int>(id_solver_to_me.size());
}

void GridModel::init_Ybus(Eigen::SparseMatrix<cplx_type> & Ybus,
int nb_bus_solver){
Ybus = Eigen::SparseMatrix<cplx_type>(nb_bus_solver, nb_bus_solver);
Ybus.reserve(nb_bus_solver + 2*powerlines_.nb() + 2*trafos_.nb());
}
Expand Down
22 changes: 12 additions & 10 deletions src/GridModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,32 +452,33 @@ class GridModel : public GenericContainer
void deactivate_load(int load_id) {loads_.deactivate(load_id, solver_control_); }
void reactivate_load(int load_id) {loads_.reactivate(load_id, solver_control_); }
void change_bus_load(int load_id, int new_bus_id) {loads_.change_bus(load_id, new_bus_id, solver_control_, static_cast<int>(bus_vn_kv_.size())); }
void change_p_load(int load_id, real_type new_p) {loads_.change_p(load_id, new_p, solver_control_); }
void change_q_load(int load_id, real_type new_q) {loads_.change_q(load_id, new_q, solver_control_); }
void change_p_load(int load_id, real_type new_p) {loads_.change_p_nothrow(load_id, new_p, solver_control_); }
void change_q_load(int load_id, real_type new_q) {loads_.change_q_nothrow(load_id, new_q, solver_control_); }
int get_bus_load(int load_id) {return loads_.get_bus(load_id);}

//generator
void deactivate_gen(int gen_id) {generators_.deactivate(gen_id, solver_control_); }
void reactivate_gen(int gen_id) {generators_.reactivate(gen_id, solver_control_); }
void change_bus_gen(int gen_id, int new_bus_id) {generators_.change_bus(gen_id, new_bus_id, solver_control_, static_cast<int>(bus_vn_kv_.size())); }
void change_p_gen(int gen_id, real_type new_p) {generators_.change_p(gen_id, new_p, solver_control_); }
void change_v_gen(int gen_id, real_type new_v_pu) {generators_.change_v(gen_id, new_v_pu, solver_control_); }
void change_p_gen(int gen_id, real_type new_p) {generators_.change_p_nothrow(gen_id, new_p, solver_control_); }
void change_q_gen(int gen_id, real_type new_q) {generators_.change_q_nothrow(gen_id, new_q, solver_control_); }
void change_v_gen(int gen_id, real_type new_v_pu) {generators_.change_v_nothrow(gen_id, new_v_pu, solver_control_); }
int get_bus_gen(int gen_id) {return generators_.get_bus(gen_id);}

//shunt
void deactivate_shunt(int shunt_id) {shunts_.deactivate(shunt_id, solver_control_); }
void reactivate_shunt(int shunt_id) {shunts_.reactivate(shunt_id, solver_control_); }
void change_bus_shunt(int shunt_id, int new_bus_id) {shunts_.change_bus(shunt_id, new_bus_id, solver_control_, static_cast<int>(bus_vn_kv_.size())); }
void change_p_shunt(int shunt_id, real_type new_p) {shunts_.change_p(shunt_id, new_p, solver_control_); }
void change_q_shunt(int shunt_id, real_type new_q) {shunts_.change_q(shunt_id, new_q, solver_control_); }
void change_p_shunt(int shunt_id, real_type new_p) {shunts_.change_p_nothrow(shunt_id, new_p, solver_control_); }
void change_q_shunt(int shunt_id, real_type new_q) {shunts_.change_q_nothrow(shunt_id, new_q, solver_control_); }
int get_bus_shunt(int shunt_id) {return shunts_.get_bus(shunt_id);}

//static gen
void deactivate_sgen(int sgen_id) {sgens_.deactivate(sgen_id, solver_control_); }
void reactivate_sgen(int sgen_id) {sgens_.reactivate(sgen_id, solver_control_); }
void change_bus_sgen(int sgen_id, int new_bus_id) {sgens_.change_bus(sgen_id, new_bus_id, solver_control_, static_cast<int>(bus_vn_kv_.size())); }
void change_p_sgen(int sgen_id, real_type new_p) {sgens_.change_p(sgen_id, new_p, solver_control_); }
void change_q_sgen(int sgen_id, real_type new_q) {sgens_.change_q(sgen_id, new_q, solver_control_); }
void change_p_sgen(int sgen_id, real_type new_p) {sgens_.change_p_nothrow(sgen_id, new_p, solver_control_); }
void change_q_sgen(int sgen_id, real_type new_q) {sgens_.change_q_nothrow(sgen_id, new_q, solver_control_); }
int get_bus_sgen(int sgen_id) {return sgens_.get_bus(sgen_id);}

//storage units
Expand Down Expand Up @@ -1048,8 +1049,9 @@ class GridModel : public GenericContainer
// init the Ybus matrix (its size, it is filled up elsewhere) and also the
// converter from "my bus id" to the "solver bus id" (id_me_to_solver and id_solver_to_me)
void init_Ybus(Eigen::SparseMatrix<cplx_type> & Ybus,
std::vector<int> & id_me_to_solver,
std::vector<int>& id_solver_to_me);
int nb_bus_solver);
void init_converter_bus_id(std::vector<int>& id_me_to_solver,
std::vector<int>& id_solver_to_me);

// converts the slack_bus_id from gridmodel ordering into solver ordering
void init_slack_bus(const CplxVect & Sbus,
Expand Down
Loading

0 comments on commit 20c9276

Please sign in to comment.