From f0f184d6598a76106ba8bd63228ccef14d23b68f Mon Sep 17 00:00:00 2001 From: DONNOT Benjamin Date: Wed, 24 Jul 2024 14:15:17 +0200 Subject: [PATCH] still debug windows CI --- lightsim2grid/lightSimBackend.py | 5 +++++ lightsim2grid/tests/test_n1contingencyrewards.py | 1 + src/linear_solvers/SparseLUSolver.cpp | 2 +- src/powerflow_algorithm/BaseDCAlgo.tpp | 8 ++++---- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lightsim2grid/lightSimBackend.py b/lightsim2grid/lightSimBackend.py index a473a4a..27b8a75 100644 --- a/lightsim2grid/lightSimBackend.py +++ b/lightsim2grid/lightSimBackend.py @@ -1053,6 +1053,7 @@ def apply_action(self, backendAction: Union["grid2op.Action._backendAction._Back raise BackendError(f"{exc_}") from exc_ if self.__has_storage: + print(f" storage_power {backendAction.storage_power.values[backendAction.storage_power.changed]}") # TODO DEBUG WINDOWS try: self._grid.update_storages_p(backendAction.storage_power.changed, backendAction.storage_power.values) @@ -1063,6 +1064,8 @@ def apply_action(self, backendAction: Union["grid2op.Action._backendAction._Back # handle shunts if type(self).shunts_data_available: shunt_p, shunt_q, shunt_bus = backendAction.shunt_p, backendAction.shunt_q, backendAction.shunt_bus + print(f"\tshunt_p (pass to ls) {backendAction.shunt_p.values[backendAction.shunt_p.changed]}") # TODO DEBUG WINDOWS + print(f"\tshunt_p (full) {backendAction.shunt_p.values}") # TODO DEBUG WINDOWS # shunt topology # (need to be done before to avoid error like "impossible to set reactive value of a disconnected shunt") for sh_id, new_bus in shunt_bus: @@ -1082,6 +1085,8 @@ def apply_action(self, backendAction: Union["grid2op.Action._backendAction._Back self._grid.change_q_shunt(sh_id, new_q) self._handle_dist_slack() + print(f"\tshunt_p (after) {self._grid.get_shunts_res_full()[0]}") + print(f"dcSbus_solver {self._grid.get_dcSbus_solver()}") self._timer_apply_act += time.perf_counter() - tick def _handle_dist_slack(self): diff --git a/lightsim2grid/tests/test_n1contingencyrewards.py b/lightsim2grid/tests/test_n1contingencyrewards.py index 43247f0..f471f00 100644 --- a/lightsim2grid/tests/test_n1contingencyrewards.py +++ b/lightsim2grid/tests/test_n1contingencyrewards.py @@ -128,6 +128,7 @@ def _aux_test_reward(self, obs, reward): print(f"Obs env {obs._obs_env.backend._grid.get_solver_type()}") print(f"Obs env {obs._obs_env.backend._grid.get_dc_solver_type()}") print("HERE HERE HERE") + print(f"shunt p (from obs): {obs._shunt_p}") sim_obs, sim_r, sim_d, sim_i = obs.simulate(self.env.action_space(), time_step=0) # print(f"without contingency: {sim_d = }, {sim_i['exception']}") print(f"without contingency: {sim_d = }, {sim_i}") diff --git a/src/linear_solvers/SparseLUSolver.cpp b/src/linear_solvers/SparseLUSolver.cpp index a127ee8..c1b60a9 100644 --- a/src/linear_solvers/SparseLUSolver.cpp +++ b/src/linear_solvers/SparseLUSolver.cpp @@ -40,7 +40,7 @@ ErrorType SparseLULinearSolver::solve(const Eigen::SparseMatrix & J, } if(!stop){ RealVect Va = solver_.solve(b); - std::cout << "\t\tSparseLUSolver.cpp: solver_.info: " << solver_.info() << std::endl; // TODO DEBUG WINDOWS + // std::cout << "\t\tSparseLUSolver.cpp: solver_.info: " << solver_.info() << std::endl; // TODO DEBUG WINDOWS if (solver_.info() != Eigen::Success) { err = ErrorType::SolverSolve; } diff --git a/src/powerflow_algorithm/BaseDCAlgo.tpp b/src/powerflow_algorithm/BaseDCAlgo.tpp index bfa34d9..8fec19f 100644 --- a/src/powerflow_algorithm/BaseDCAlgo.tpp +++ b/src/powerflow_algorithm/BaseDCAlgo.tpp @@ -59,7 +59,7 @@ bool BaseDCAlgo::compute_pf(const Eigen::SparseMatrix & // TODO SLACK (for now i put all slacks as PV, except the first one) // this should be handled in Sbus, because we know the amount of power absorbed by the slack // so we can compute it correctly ! - std::cout << "\t\t\tneed to retrieve slack\n"; + // std::cout << "\t\t\tneed to retrieve slack\n"; my_pv_ = retrieve_pv_with_slack(slack_ids, pv); // find the slack buses @@ -75,7 +75,7 @@ bool BaseDCAlgo::compute_pf(const Eigen::SparseMatrix & _solver_control.need_recompute_ybus() || _solver_control.ybus_change_sparsity_pattern() || _solver_control.has_ybus_some_coeffs_zero()) { - std::cout << "\t\t\tneed to sizeYbus_with_slack_\n"; + // std::cout << "\t\t\tneed to sizeYbus_with_slack_\n"; fill_dcYbus_noslack(sizeYbus_with_slack_, Ybus); has_just_been_factorized = false; // force a call to "factor" the linear solver as the lhs (ybus) changed // no need to refactor if ybus did not change @@ -92,7 +92,7 @@ bool BaseDCAlgo::compute_pf(const Eigen::SparseMatrix & // remove the slack bus from Sbus if(need_factorize_ || _solver_control.need_recompute_sbus()){ - std::cout << "\t\t\tneed to dcSbus_noslack_\n"; + // std::cout << "\t\t\tneed to dcSbus_noslack_\n"; dcSbus_noslack_ = RealVect::Constant(sizeYbus_without_slack_, my_zero_); for (int k=0; k < sizeYbus_with_slack_; ++k){ if(mat_bus_id_(k) == -1) continue; // I don't add anything to the slack bus @@ -103,7 +103,7 @@ bool BaseDCAlgo::compute_pf(const Eigen::SparseMatrix & // initialize the solver if needed if(need_factorize_){ - std::cout << "\t\t\tneed to factorize\n"; + // std::cout << "\t\t\tneed to factorize\n"; ErrorType status_init = _linear_solver.initialize(dcYbus_noslack_); if(status_init != ErrorType::NoError){ err_ = status_init;