dos-group / vessim

A co-simulation testbed for carbon-aware applications and systems 🍃
https://vessim.readthedocs.io
MIT License
49 stars 5 forks source link

Incorrect monitoring of storage state #187

Closed kilianp14 closed 7 months ago

kilianp14 commented 8 months ago

When a monitoring controller is started, an improper monitor function is added that is supposed to monitor the storage state. https://github.com/dos-group/vessim/blob/5e2f94f2615ecaa6d59e5ac87e306c39c30353ac/vessim/controller.py#L61-L65 The storage_state variable is just a constant, containing the initial storage state, and so, the monitor function always returns the initial state instead of the correct current state. A fix that causes no typing errors could look like this:

    if microgrid.storage is not None:

        def fn(time):
            return microgrid.storage.state()

        self.add_monitor_fn(fn)