Module nemo.storage
Storage classes.
Storage objects are usually shared between a load and a generator (for example, a pumped hydro system having a pump, a turbine and a storage system.
Classes
class BatteryStorage (maxstorage, label=None)
-
Expand source code
class BatteryStorage(GenericStorage): """Battery storage."""
Battery storage.
Construct a storage object.
The storage capacity (in MWh) is specified by maxstorage.
Ancestors
Inherited members
class GenericStorage (maxstorage, label=None)
-
Expand source code
class GenericStorage: """A simple electrical storage system. The storage has unity efficiency. It is up to the load and generator to handle the round trip efficiency of the relevant technologies. """ def __init__(self, maxstorage, label=None): """Construct a storage object. The storage capacity (in MWh) is specified by maxstorage. """ self.label = label # initialise to silence pylint self.storage = 0 self.set_storage(maxstorage) def set_storage(self, maxstorage): """Change the storage capacity. >>> r = GenericStorage(1000) >>> r.set_storage(1200) >>> r.maxstorage 1200 >>> r.storage 600.0 """ self.storage = maxstorage / 2 self.maxstorage = maxstorage def reset(self): """Reset storage to 50% SOC. >>> r = GenericStorage(1000) >>> r.storage = 200 >>> r.reset() >>> r.storage 500.0 """ self.storage = self.maxstorage / 2 def soc(self): """Return the storage SOC (state of charge). >>> r = GenericStorage(1000) >>> r.soc() 0.5 """ return self.storage / self.maxstorage def empty_p(self): """Return True if the storage is empty. >>> r = GenericStorage(1000) >>> r.storage = 0 >>> r.empty_p(), r.full_p() (True, False) """ return self.storage == 0 def full_p(self): """Return True if the storage is full. >>> r = GenericStorage(1000) >>> r.storage = 1000 >>> r.full_p(), r.empty_p() (True, False) """ return self.maxstorage == self.storage def charge(self, amt): """Charge the storage by amt. >>> stg = GenericStorage(1000, 'test') >>> stg.charge(600) 500.0 >>> stg.full_p() True >>> stg.charge(-1) Traceback (most recent call last): ... ValueError: -1 """ if amt < 0: raise ValueError(amt) delta = min(self.maxstorage - self.storage, amt) self.storage = min(self.maxstorage, self.storage + amt) if not 0 <= self.storage <= self.maxstorage: raise AssertionError return delta def discharge(self, amt): """Discharge the storage by 'amt'. >>> stg = GenericStorage(1000, 'test') >>> stg.discharge(600) 500.0 >>> stg.empty_p() True >>> stg.discharge(-1) Traceback (most recent call last): ... ValueError: -1 """ if amt < 0: raise ValueError(amt) delta = min(self.storage, amt) self.storage = max(0, self.storage - amt) if not 0 <= self.storage <= self.maxstorage: raise AssertionError return delta
A simple electrical storage system.
The storage has unity efficiency. It is up to the load and generator to handle the round trip efficiency of the relevant technologies.
Construct a storage object.
The storage capacity (in MWh) is specified by maxstorage.
Subclasses
Methods
def charge(self, amt)
-
Expand source code
def charge(self, amt): """Charge the storage by amt. >>> stg = GenericStorage(1000, 'test') >>> stg.charge(600) 500.0 >>> stg.full_p() True >>> stg.charge(-1) Traceback (most recent call last): ... ValueError: -1 """ if amt < 0: raise ValueError(amt) delta = min(self.maxstorage - self.storage, amt) self.storage = min(self.maxstorage, self.storage + amt) if not 0 <= self.storage <= self.maxstorage: raise AssertionError return delta
Charge the storage by amt.
>>> stg = GenericStorage(1000, 'test') >>> stg.charge(600) 500.0 >>> stg.full_p() True >>> stg.charge(-1) Traceback (most recent call last): ... ValueError: -1
def discharge(self, amt)
-
Expand source code
def discharge(self, amt): """Discharge the storage by 'amt'. >>> stg = GenericStorage(1000, 'test') >>> stg.discharge(600) 500.0 >>> stg.empty_p() True >>> stg.discharge(-1) Traceback (most recent call last): ... ValueError: -1 """ if amt < 0: raise ValueError(amt) delta = min(self.storage, amt) self.storage = max(0, self.storage - amt) if not 0 <= self.storage <= self.maxstorage: raise AssertionError return delta
Discharge the storage by 'amt'.
>>> stg = GenericStorage(1000, 'test') >>> stg.discharge(600) 500.0 >>> stg.empty_p() True >>> stg.discharge(-1) Traceback (most recent call last): ... ValueError: -1
def empty_p(self)
-
Expand source code
def empty_p(self): """Return True if the storage is empty. >>> r = GenericStorage(1000) >>> r.storage = 0 >>> r.empty_p(), r.full_p() (True, False) """ return self.storage == 0
Return True if the storage is empty.
>>> r = GenericStorage(1000) >>> r.storage = 0 >>> r.empty_p(), r.full_p() (True, False)
def full_p(self)
-
Expand source code
def full_p(self): """Return True if the storage is full. >>> r = GenericStorage(1000) >>> r.storage = 1000 >>> r.full_p(), r.empty_p() (True, False) """ return self.maxstorage == self.storage
Return True if the storage is full.
>>> r = GenericStorage(1000) >>> r.storage = 1000 >>> r.full_p(), r.empty_p() (True, False)
def reset(self)
-
Expand source code
def reset(self): """Reset storage to 50% SOC. >>> r = GenericStorage(1000) >>> r.storage = 200 >>> r.reset() >>> r.storage 500.0 """ self.storage = self.maxstorage / 2
Reset storage to 50% SOC.
>>> r = GenericStorage(1000) >>> r.storage = 200 >>> r.reset() >>> r.storage 500.0
def set_storage(self, maxstorage)
-
Expand source code
def set_storage(self, maxstorage): """Change the storage capacity. >>> r = GenericStorage(1000) >>> r.set_storage(1200) >>> r.maxstorage 1200 >>> r.storage 600.0 """ self.storage = maxstorage / 2 self.maxstorage = maxstorage
Change the storage capacity.
>>> r = GenericStorage(1000) >>> r.set_storage(1200) >>> r.maxstorage 1200 >>> r.storage 600.0
def soc(self)
-
Expand source code
def soc(self): """Return the storage SOC (state of charge). >>> r = GenericStorage(1000) >>> r.soc() 0.5 """ return self.storage / self.maxstorage
Return the storage SOC (state of charge).
>>> r = GenericStorage(1000) >>> r.soc() 0.5
class HydrogenStorage (maxstorage, label=None)
-
Expand source code
class HydrogenStorage(GenericStorage): """Hydrogen storage."""
Hydrogen storage.
Construct a storage object.
The storage capacity (in MWh) is specified by maxstorage.
Ancestors
Inherited members
class PumpedHydroStorage (maxstorage, label=None)
-
Expand source code
class PumpedHydroStorage(GenericStorage): """A pair of reservoirs for pumped storage.""" def __init__(self, maxstorage, label=None): """Construct a pumped hydro storage reservoir pair. The storage capacity (in MWh) is specified by maxstorage. """ GenericStorage.__init__(self, maxstorage, label) # Communicate between pump and turbine here to prevent both # generators running in the same hour. self.last_gen = None self.last_pump = None def reset(self): """Reset the storage.""" GenericStorage.reset(self) self.last_gen = None self.last_pump = None
A pair of reservoirs for pumped storage.
Construct a pumped hydro storage reservoir pair.
The storage capacity (in MWh) is specified by maxstorage.
Ancestors
Methods
def reset(self)
-
Expand source code
def reset(self): """Reset the storage.""" GenericStorage.reset(self) self.last_gen = None self.last_pump = None
Reset the storage.
Inherited members