Skip to content

Commit 940a6e1

Browse files
committed
still improving code cpp part
Signed-off-by: DONNOT Benjamin <[email protected]>
1 parent 6f0b352 commit 940a6e1

11 files changed

+108
-47
lines changed

src/batch_algorithm/BaseBatchSolverSynch.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class BaseBatchSolverSynch : protected BaseConstants
2626
typedef Eigen::Matrix<real_type, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> RealMat;
2727
typedef Eigen::Matrix<cplx_type, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> CplxMat;
2828

29-
BaseBatchSolverSynch(const GridModel & init_grid_model) noexcept:
29+
explicit BaseBatchSolverSynch(const GridModel & init_grid_model) noexcept:
3030
_grid_model(init_grid_model),
3131
n_line_(init_grid_model.nb_powerline()),
3232
n_trafos_(init_grid_model.nb_trafo()),

src/batch_algorithm/ContingencyAnalysis.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ have been disconnected
1919
class ContingencyAnalysis final: public BaseBatchSolverSynch
2020
{
2121
public:
22-
ContingencyAnalysis(const GridModel & init_grid_model) noexcept:
22+
explicit ContingencyAnalysis(const GridModel & init_grid_model) noexcept:
2323
BaseBatchSolverSynch(init_grid_model),
2424
_li_defaults(),
2525
_li_coeffs(),
2626
_timer_total(0.),
2727
_timer_modif_Ybus(0.),
2828
_timer_pre_proc(0.)
2929
{ }
30-
30+
3131
~ContingencyAnalysis() noexcept = default;
3232
ContingencyAnalysis(const ContingencyAnalysis&) = delete;
3333
ContingencyAnalysis(ContingencyAnalysis&&) = delete;

src/batch_algorithm/TimeSeries.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ series of injections (productions and loads) to compute powerflows/
1818
class TimeSeries final: public BaseBatchSolverSynch
1919
{
2020
public:
21-
TimeSeries(const GridModel & init_grid_model) noexcept:
21+
explicit TimeSeries(const GridModel & init_grid_model) noexcept:
2222
BaseBatchSolverSynch(init_grid_model),
2323
_Sbuses(),
2424
_status(1), // 1: success, 0: failure

src/element_container/DCLineContainer.hpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,15 @@ class DCLineContainer final : public TwoSidesContainer<GeneratorContainer>, publ
9090
side_2_.reactivate(dcline_id, solver_control);
9191
}
9292

93-
// for buses only connected through dc line, i don't add them
94-
// they are not in the same "connected component"
9593
virtual void reconnect_connected_buses(SubstationContainer & Substation) const {
96-
// from_gen_.reconnect_connected_buses(bus_status);
97-
// to_gen_.reconnect_connected_buses(bus_status);
94+
side_1_.reconnect_connected_buses(Substation);
95+
side_2_.reconnect_connected_buses(Substation);
9896
}
9997

100-
// for buses only connected through dc line, i don't add them
101-
// they are not in the same "connected component"
102-
virtual void get_graph(std::vector<Eigen::Triplet<real_type> > & res) const {};
103-
104-
// virtual void nb_line_end(std::vector<int> & res) const;
98+
virtual void get_graph(std::vector<Eigen::Triplet<real_type> > & res) const {
99+
// for buses only connected through dc line, i don't add them
100+
// they are not in the same "connected component"
101+
};
105102

106103
real_type get_qmin_or(int dcline_id) {return side_1_.get_qmin(dcline_id);}
107104
real_type get_qmax_or(int dcline_id) {return side_1_.get_qmax(dcline_id);}
@@ -146,7 +143,9 @@ class DCLineContainer final : public TwoSidesContainer<GeneratorContainer>, publ
146143
std::vector<Eigen::Triplet<real_type> > & Bpp,
147144
const std::vector<SolverBusId> & id_grid_to_solver,
148145
real_type sn_mva,
149-
FDPFMethod xb_or_bx) const {}
146+
FDPFMethod xb_or_bx) const {
147+
// no Bp coeffs for dc lines
148+
}
150149

151150
void init_q_vector(int nb_bus,
152151
Eigen::VectorXi & total_gen_per_bus,

src/element_container/GeneratorContainer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ void GeneratorContainer::change_v_nothrow(int gen_id, real_type new_v_pu, Solver
321321
}
322322
}
323323

324-
void GeneratorContainer::_change_bus(int el_id, GlobalBusId new_bus_id, SolverControl & solver_control, int nb_bus) {
324+
void GeneratorContainer::_change_bus(int el_id, GridModelBusId new_bus_id, SolverControl & solver_control, int nb_bus) {
325325
if(bus_id_(el_id) == new_bus_id) return; // nothing to do if the bus did not changed
326326
solver_control.tell_recompute_sbus();
327327
solver_control.tell_one_el_changed_bus();

src/element_container/GeneratorContainer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class GeneratorContainer: public OneSideContainer_PQ, public IteratorAdder<Gener
6666
> StateRes;
6767

6868
GeneratorContainer() noexcept :OneSideContainer_PQ(), turnedoff_gen_pv_(true){};
69-
GeneratorContainer(bool turnedoff_gen_pv) noexcept :OneSideContainer_PQ(), turnedoff_gen_pv_(turnedoff_gen_pv) {};
69+
explicit GeneratorContainer(bool turnedoff_gen_pv) noexcept :OneSideContainer_PQ(), turnedoff_gen_pv_(turnedoff_gen_pv) {};
7070
virtual ~GeneratorContainer() noexcept = default;
7171

7272
// TODO add pmin and pmax here !

src/element_container/GenericContainer.hpp

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,41 +31,72 @@ class GenericContainer : public BaseConstants
3131
virtual void fillYbus(std::vector<Eigen::Triplet<cplx_type> > & res,
3232
bool ac,
3333
const std::vector<SolverBusId> & id_grid_to_solver,
34-
real_type sn_mva) const {};
34+
real_type sn_mva) const {
35+
// nothing to do by default
36+
// is overriden mainly for "branches" (lines, transformers etc.)
37+
};
3538

3639
virtual void fillBp_Bpp(std::vector<Eigen::Triplet<real_type> > & Bp,
3740
std::vector<Eigen::Triplet<real_type> > & Bpp,
3841
const std::vector<SolverBusId> & id_grid_to_solver,
3942
real_type sn_mva,
40-
FDPFMethod xb_or_bx) const {};
43+
FDPFMethod xb_or_bx) const {
44+
// nothing to do by default
45+
// is overriden mainly for "branches" (lines, transformers etc.)
46+
};
4147

4248
virtual void fillBf_for_PTDF(std::vector<Eigen::Triplet<real_type> > & Bf,
4349
const std::vector<SolverBusId> & id_grid_to_solver,
4450
real_type sn_mva,
4551
int nb_line,
46-
bool transpose) const {};
47-
48-
// no more used !
49-
virtual void fillYbus(Eigen::SparseMatrix<cplx_type> & res, bool ac, const std::vector<SolverBusId> & id_grid_to_solver) const {};
50-
51-
virtual void fillSbus(CplxVect & Sbus, const std::vector<SolverBusId> & id_grid_to_solver, bool ac) const {};
52+
bool transpose) const {
53+
// nothing to do by default
54+
// is overriden mainly for "branches" (lines, transformers etc.)
55+
};
56+
57+
virtual void fillSbus(CplxVect & Sbus, const std::vector<SolverBusId> & id_grid_to_solver, bool ac) const {
58+
// nothing to do by default
59+
// is overriden mainly for "one side elements" (loads, generators etc.)
60+
};
5261
virtual void fillpv(std::vector<int>& bus_pv,
5362
std::vector<bool> & has_bus_been_added,
5463
const SolverBusIdVect& slack_bus_id_solver,
55-
const std::vector<SolverBusId> & id_grid_to_solver) const {};
64+
const std::vector<SolverBusId> & id_grid_to_solver) const {
65+
// nothing to do by default
66+
// is overriden mainly for "generators"
67+
};
5668

57-
virtual void get_q(std::vector<real_type>& q_by_bus) {};
69+
virtual void get_q(std::vector<real_type>& q_by_bus) {
70+
// nothing to do by default
71+
// is overriden mainly for "generators"
72+
};
5873

59-
void set_p_slack(const RealVect& node_mismatch, const std::vector<SolverBusId> & id_grid_to_solver) {};
74+
void set_p_slack(const RealVect& node_mismatch, const std::vector<SolverBusId> & id_grid_to_solver) {
75+
// nothing to do by default
76+
// is overriden mainly for "generators"
77+
};
6078

6179
static const int _deactivated_bus_id;
62-
virtual void reconnect_connected_buses(SubstationContainer & substation) const {};
80+
virtual void reconnect_connected_buses(SubstationContainer & substation) const {
81+
// nothing to do by default
82+
};
6383

6484
/**computes the total amount of power for each bus (for generator only)**/
65-
virtual void gen_p_per_bus(std::vector<real_type> & res) const {};
66-
virtual void nb_line_end(std::vector<int> & res) const {};
67-
virtual void get_graph(std::vector<Eigen::Triplet<real_type> > & res) const {};
68-
virtual void disconnect_if_not_in_main_component(std::vector<bool> & busbar_in_main_component) {};
85+
virtual void gen_p_per_bus(std::vector<real_type> & res) const {
86+
// nothing to do by default
87+
// is overriden mainly for "one side elements" (loads, generators etc.)
88+
};
89+
virtual void nb_line_end(std::vector<int> & res) const {
90+
// nothing to do by default
91+
// is overriden mainly for "branches" (lines, transformers etc.)
92+
};
93+
virtual void get_graph(std::vector<Eigen::Triplet<real_type> > & res) const {
94+
// nothing to do by default
95+
// is overriden mainly for "branches" (lines, transformers etc.)
96+
};
97+
virtual void disconnect_if_not_in_main_component(std::vector<bool> & busbar_in_main_component) {
98+
// nothing to do by default
99+
};
69100

70101
void set_names(const std::vector<std::string> & names){
71102
names_ = names;

src/element_container/OneSideContainer.hpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -413,20 +413,33 @@ class OneSideContainer : public GenericContainer
413413
}
414414

415415
protected:
416-
virtual void _reset_results() {};
416+
virtual void _reset_results() {
417+
// nothing to do by default
418+
};
417419
virtual void _compute_results(const Eigen::Ref<const RealVect> & Va,
418420
const Eigen::Ref<const RealVect> & Vm,
419421
const Eigen::Ref<const CplxVect> & V,
420422
const std::vector<SolverBusId> & id_grid_to_solver,
421423
const RealVect & bus_vn_kv,
422424
real_type sn_mva,
423-
bool ac) {};
424-
virtual void _deactivate(int el_id, SolverControl & solver_control) {};
425-
virtual void _reactivate(int el_id, SolverControl & solver_control) {};
426-
virtual void _change_bus(int load_id, GridModelBusId new_bus_id, SolverControl & solver_control, int nb_bus) {};
427-
virtual void _change_p(int el_id, real_type new_p, bool my_status, SolverControl & solver_control) {};
428-
virtual void _change_q(int el_id, real_type new_p, bool my_status,SolverControl & solver_control) {};
429-
// virtual void _change_v(int el_id, real_type new_p, SolverControl & solver_control) {};
425+
bool ac) {
426+
// nothing to do by default
427+
};
428+
virtual void _deactivate(int el_id, SolverControl & solver_control) {
429+
// nothing do to by default
430+
};
431+
virtual void _reactivate(int el_id, SolverControl & solver_control) {
432+
// nothing to do by default
433+
};
434+
virtual void _change_bus(int load_id, GridModelBusId new_bus_id, SolverControl & solver_control, int nb_bus) {
435+
// nothing to do by default
436+
};
437+
virtual void _change_p(int el_id, real_type new_p, bool my_status, SolverControl & solver_control) {
438+
// nothing to do by default
439+
};
440+
virtual void _change_q(int el_id, real_type new_p, bool my_status,SolverControl & solver_control) {
441+
// nothing to do by default
442+
};
430443

431444
void _check_pos_topo_vect_filled(){
432445
if((nb() > 0) && (pos_topo_vect_.size() == 0)){

src/element_container/OneSideContainer_PQ.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,21 @@ class OneSideContainer_PQ : public OneSideContainer
192192
}
193193

194194
protected:
195-
virtual void _reset_results() {};
195+
virtual void _reset_results() {
196+
// nothing to do by default, as this class should be used as template for "one side" (eg loads or generators)
197+
// elements
198+
};
196199
virtual void _compute_results(const Eigen::Ref<const RealVect> & Va,
197200
const Eigen::Ref<const RealVect> & Vm,
198201
const Eigen::Ref<const CplxVect> & V,
199202
const std::vector<SolverBusId> & id_grid_to_solver,
200203
const RealVect & bus_vn_kv,
201204
real_type sn_mva,
202-
bool ac) {};
205+
bool ac) {
206+
// nothing to do by default, as this class should be used as template for "one side" (eg loads or generators)
207+
// elements
208+
};
209+
203210
virtual void _deactivate(int el_id, SolverControl & solver_control) {
204211
if(status_[el_id]){
205212
solver_control.tell_recompute_sbus();
@@ -228,7 +235,6 @@ class OneSideContainer_PQ : public OneSideContainer
228235
solver_control.tell_recompute_sbus();
229236
}
230237
};
231-
// virtual void _change_v(int el_id, real_type new_p, SolverControl & solver_control) {};
232238

233239
protected:
234240
// physical properties

src/element_container/OneSideContainer_forBranch.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,22 @@ class OneSideContainer_ForBranch : public OneSideContainer
104104
}
105105

106106
protected:
107-
virtual void _reset_results() {};
107+
virtual void _reset_results() {
108+
// nothing to do by default, as this class should be used as template for "branch" (eg lines or trafos)
109+
// elements
110+
};
108111
virtual void _compute_results(const Eigen::Ref<const RealVect> & Va,
109112
const Eigen::Ref<const RealVect> & Vm,
110113
const Eigen::Ref<const CplxVect> & V,
111114
const std::vector<SolverBusId> & id_grid_to_solver,
112115
const RealVect & bus_vn_kv,
113116
real_type sn_mva,
114-
bool ac) {};
117+
bool ac) {
118+
119+
// nothing to do by default, as this class should be used as template for "branch" (eg lines or trafos)
120+
// elements
121+
};
122+
115123
virtual void _deactivate(int el_id, SolverControl & solver_control) {
116124
if(status_[el_id]){
117125
solver_control.tell_ybus_some_coeffs_zero();

0 commit comments

Comments
 (0)