storage ¶
BiogasStorage ¶
BiogasStorage(max_vol, p_store, vol_init, capex_sp, opex_factor, biogas, gas_composition)
A class that represents a gas storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_vol | int | Maximum volume of the storage [Nm³]. | required |
p_store | int | Pressure of the storage [bar]. | required |
vol_init | int | Initial volume of the storage [Nm³]. | required |
capex_sp | int | Capital expenditure per volume of the storage [€/Nm³]. | required |
opex_factor | int | Operational expenditure factor [1/h]. | required |
biogas | GasMix | Mixture of gas. Contains fractions of each gas. | required |
gas_composition | ndarray | Initial gas composition of the storage.
| required |
Source code in src/bsm2_python/energy_management/storage.py
def __init__(
self,
max_vol: int | float,
p_store: int | float,
vol_init: int | float,
capex_sp: int | float,
opex_factor: int | float,
biogas: GasMix,
gas_composition: np.ndarray,
):
self.tendency = 0.0
self.max_vol = max_vol
self.vol = vol_init
self.p_store = p_store
self.inflow = 0.0
self.outflow = 0.0
self.surplus = 0.0
self.deficiency = 0.0
self.capex_sp = capex_sp
self.capex = capex_sp * max_vol
self.opex_factor = opex_factor
self.biogas = biogas
self.gas_composition = gas_composition
update_inflow ¶
update_inflow(gas_flow_in, gas_flow_in_composition, time_diff)
Updates the gas composition and volume of the storage with only the inflow.
Volume can at first be higher than the maximum volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gas_flow_in | int or float | The gas flow that is coming into the storage [Nm³/h]. | required |
gas_flow_in_composition | ndarray | The gas composition of the incoming gas.
| required |
time_diff | int or float | The time difference since the last update [h]. | required |
Returns:
| Type | Description |
|---|---|
GasMix | The biogas object with the updated gas composition. |
Source code in src/bsm2_python/energy_management/storage.py
def update_inflow(self, gas_flow_in: int | float, gas_flow_in_composition: np.ndarray, time_diff: int | float):
"""Updates the gas composition and volume of the storage with only the inflow.
Volume can at first be higher than the maximum volume.
Parameters
----------
gas_flow_in : int or float
The gas flow that is coming into the storage [Nm³/h].
gas_flow_in_composition : np.ndarray
The gas composition of the incoming gas. <br>
[ch4_frac, co2_frac, h2_frac, h2o_frac, n2_frac] \n
- ch4_frac: Mixture fraction of methane.
- co2_frac: Mixture fraction of carbon dioxide.
- h2_frac: Mixture fraction of hydrogen.
- h2o_frac: Mixture fraction of water.
- n2_frac: Mixture fraction of nitrogen.
time_diff : int or float
The time difference since the last update [h].
Returns
-------
GasMix
The biogas object with the updated gas composition.
"""
self.gas_composition = self.biogas.mix(self.gas_composition, self.vol, gas_flow_in_composition, gas_flow_in)
self.vol += gas_flow_in * time_diff
return self.biogas
update_outflow ¶
update_outflow(gas_flow_out, time_diff)
Updates the gas composition and volume of the storage with only the outflow.
Maximum volume is now considered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gas_flow_out | int or float | The gas flow that is coming out of the storage [Nm³/h]. | required |
time_diff | int or float | The time difference since the last update [h]. | required |
Returns:
| Type | Description |
|---|---|
Tuple | The surplus and deficiency of the storage, respectively [Nm³]. |
Source code in src/bsm2_python/energy_management/storage.py
def update_outflow(self, gas_flow_out: int | float, time_diff: int | float):
"""Updates the gas composition and volume of the storage with only the outflow.
Maximum volume is now considered.
Parameters
----------
gas_flow_out : int or float
The gas flow that is coming out of the storage [Nm³/h].
time_diff : int or float
The time difference since the last update [h].
Returns
-------
Tuple
The surplus and deficiency of the storage, respectively [Nm³].
"""
self.vol -= gas_flow_out * time_diff
if self.vol > self.max_vol:
self.surplus = self.vol - self.max_vol
self.vol = self.max_vol
else:
self.surplus = 0
if self.vol < 0:
self.deficiency = -self.vol
self.vol = 0
else:
self.deficiency = 0
return self.surplus, self.deficiency