Skip to content

Commit

Permalink
fixing an issue with storage units, behaviour was not specified grid2…
Browse files Browse the repository at this point in the history
…op side, now it is

Signed-off-by: DONNOT Benjamin <[email protected]>
  • Loading branch information
BDonnot committed Dec 16, 2024
1 parent 6ad01dc commit 3d9794a
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 18 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ TODO: in `main.cpp` check the returned policy of pybind11 and also the `py::call
TODO: a cpp class that is able to compute (DC powerflow) ContingencyAnalysis and TimeSeries using PTDF and LODF
TODO: integration test with pandapower (see `pandapower/contingency/contingency.py` and import `lightsim2grid_installed` and check it's True)

[0.9.3] 2024-12-16
[0.10.0] 2024-12-16
-------------------
- [BREAKING] disconnected storage now raises errors if some power is produced / absorbed
- [FIXED] an issue with the storage units (when asking it to produce / consume
but deactivating them with the same action the grid did not diverge)
- [IMPROVED] add the grid2op "detachement" support (loads and generators are allowed
to be disconnected from the grid)

[0.9.2.post2] 2024-11-29
--------------------------
- [FIXED] The attribute `can_output_theta` (of base `Backend` class)
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
author = 'Benjamin DONNOT'

# The full version, including alpha/beta/rc tags
release = "0.9.3"
version = '0.9'
release = "0.10.0"
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.9.3"
__version__ = "0.10.0"

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

Expand Down
5 changes: 3 additions & 2 deletions lightsim2grid/tests/test_issue_66.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ def test_disco_storage(self):

act = self.env.action_space({"set_storage": [(0, -1)]})
obs, reward, done, info = self.env.step(act)
assert len(info['exception']) == 0
assert not done
# grid2op >= 1.11.0 requires this
assert len(info['exception']) == 1
assert done
# should not raise any RuntimeError


Expand Down
2 changes: 1 addition & 1 deletion 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.9.3"
__version__ = "0.10.0"
KLU_SOLVER_AVAILABLE = False

# Try to link against SuiteSparse (if available)
Expand Down
4 changes: 2 additions & 2 deletions src/GridModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ class GridModel : public GenericContainer
// reactivate_storage(storage_id); // requirement from grid2op, might be discussed
// storages_.change_p(storage_id, new_p, need_reset_);
// }
storages_.change_p(storage_id, new_p, solver_control_);
storages_.change_p_nothrow(storage_id, new_p, solver_control_);
}
void change_q_storage(int storage_id, real_type new_q) {storages_.change_q(storage_id, new_q, solver_control_); }
void change_q_storage(int storage_id, real_type new_q) {storages_.change_q_nothrow(storage_id, new_q, solver_control_); }
int get_bus_storage(int storage_id) {return storages_.get_bus(storage_id);}

//deactivate a powerline (disconnect it)
Expand Down
10 changes: 2 additions & 8 deletions src/element_container/LoadContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ void LoadContainer::change_p(int load_id, real_type new_p, SolverControl & solve
exc_ << ")";
throw std::runtime_error(exc_.str());
}
if (p_mw_(load_id) != new_p) {
solver_control.tell_recompute_sbus();
p_mw_(load_id) = new_p;
}
change_p_nothrow(load_id, new_p, solver_control);
}

void LoadContainer::change_q(int load_id, real_type new_q, SolverControl & solver_control)
Expand All @@ -134,10 +131,7 @@ void LoadContainer::change_q(int load_id, real_type new_q, SolverControl & solve
exc_ << ")";
throw std::runtime_error(exc_.str());
}
if (q_mvar_(load_id) != new_q) {
solver_control.tell_recompute_sbus();
q_mvar_(load_id) = new_q;
}
change_q_nothrow(load_id, new_q, solver_control);
}

void LoadContainer::reconnect_connected_buses(std::vector<bool> & bus_status) const {
Expand Down
14 changes: 14 additions & 0 deletions src/element_container/LoadContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,21 @@ class LoadContainer : public GenericContainer
void change_bus(int load_id, int new_bus_id, SolverControl & solver_control, int nb_bus) {_change_bus(load_id, new_bus_id, bus_id_, solver_control, nb_bus);}
int get_bus(int load_id) {return _get_bus(load_id, status_, bus_id_);}
void change_p(int load_id, real_type new_p, SolverControl & solver_control);
void change_p_nothrow(int load_id, real_type new_p, SolverControl & solver_control)
{
if (p_mw_(load_id) != new_p) {
solver_control.tell_recompute_sbus();
p_mw_(load_id) = new_p;
}
}
void change_q(int load_id, real_type new_q, SolverControl & solver_control);
void change_q_nothrow(int load_id, real_type new_q, SolverControl & solver_control)
{
if (q_mvar_(load_id) != new_q) {
solver_control.tell_recompute_sbus();
q_mvar_(load_id) = new_q;
}
}
virtual void reconnect_connected_buses(std::vector<bool> & bus_status) const;
virtual void disconnect_if_not_in_main_component(std::vector<bool> & busbar_in_main_component);

Expand Down

0 comments on commit 3d9794a

Please sign in to comment.