Skip to content

Commit

Permalink
still debug windows CI
Browse files Browse the repository at this point in the history
  • Loading branch information
BDonnot committed Jul 24, 2024
1 parent a9e6fdb commit f0f184d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions lightsim2grid/lightSimBackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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):
Expand Down
1 change: 1 addition & 0 deletions lightsim2grid/tests/test_n1contingencyrewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion src/linear_solvers/SparseLUSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ErrorType SparseLULinearSolver::solve(const Eigen::SparseMatrix<real_type> & 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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/powerflow_algorithm/BaseDCAlgo.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bool BaseDCAlgo<LinearSolver>::compute_pf(const Eigen::SparseMatrix<cplx_type> &
// 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
Expand All @@ -75,7 +75,7 @@ bool BaseDCAlgo<LinearSolver>::compute_pf(const Eigen::SparseMatrix<cplx_type> &
_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
Expand All @@ -92,7 +92,7 @@ bool BaseDCAlgo<LinearSolver>::compute_pf(const Eigen::SparseMatrix<cplx_type> &

// 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
Expand All @@ -103,7 +103,7 @@ bool BaseDCAlgo<LinearSolver>::compute_pf(const Eigen::SparseMatrix<cplx_type> &

// 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;
Expand Down

0 comments on commit f0f184d

Please sign in to comment.