Energy¶
Energy Conversion and Storage Components
Components for energy generation, conversion, and storage in biogas plants.
Modules:
chp: Combined Heat and Power (CHP) units including gas engines and micro-turbines,
with electrical and thermal efficiency curves, part-load behavior, maintenance
scheduling, and emissions calculation.
boiler: Auxiliary heating systems (gas, oil, biomass boilers) for peak heat demand
and backup heating, with efficiency curves, fuel consumption, and emission
factors.
gas_storage: Biogas storage systems including low-pressure (membrane, dome) and
high-pressure (compressed gas) storage, with pressure control, safety
management, and capacity utilization.
flare: Safety gas combustion system for excess biogas or emergency situations,
with destruction efficiency, emissions calculation, and automatic ignition
control.
Example:
>>> from pyadm1.components.energy import CHP, Boiler, GasStorage, Flare
>>>
>>> # CHP unit with 500 kW electrical output
>>> chp = CHP("chp1", P_el_nom=500, eta_el=0.40, eta_th=0.45,
... type="gas_engine")
>>>
>>> # Low-pressure gas storage (membrane roof)
>>> storage = GasStorage("storage1", volume=1000,
... storage_type="membrane", p_max=0.015)
>>>
>>> # Emergency flare
>>> flare = Flare("flare1", capacity=500, destruction_efficiency=0.98)
Classes¶
Boiler¶
Boiler component (stub for future implementation).
Signature:
Methods:
add_input()¶
Add an input connection.
add_output()¶
Add an output connection.
get_state()¶
Get current component state.
initialize()¶
set_state()¶
Set component state.
step()¶
to_dict()¶
CHP¶
Combined Heat and Power unit.
Converts biogas to electricity and heat with configurable efficiency.
Attributes:
P_el_nom (float): Nominal electrical power in kW.
eta_el (float): Electrical efficiency (0-1).
eta_th (float): Thermal efficiency (0-1).
load_factor (float): Current operating point (0-1).
Example:
>>> chp = CHP("chp1", P_el_nom=500, eta_el=0.40, eta_th=0.45)
>>> chp.initialize()
>>> result = chp.step(t=0, dt=1/24, inputs={"Q_ch4": 1000})
Signature:
Methods:
add_input()¶
Add an input connection.
add_output()¶
Add an output connection.
get_state()¶
Get current component state.
initialize()¶
Initialize CHP state.
Args:
initial_state (Optional[Dict[str, Any]]): Initial state with keys:
- 'load_factor': Initial load factor (0-1)
If None, uses default initialization.
set_state()¶
Set component state.
step()¶
Perform one simulation time step.
Args:
t (float): Current time in days.
dt (float): Time step in days.
inputs (Dict[str, Any]): Input data with keys:
- 'Q_ch4': Methane flow rate [m³/d] (direct input)
- 'Q_gas_supplied_m3_per_day': Available biogas from storage [m³/d]
- 'load_setpoint': Desired load factor [0-1] (optional)
Returns:
Dict[str, Any]: Output data with keys:
- 'P_el': Electrical power [kW]
- 'P_th': Thermal power [kW]
- 'Q_gas_consumed': Biogas consumption [m³/d]
- 'Q_gas_out_m3_per_day': Gas demand for connected storages [m³/d]
- 'Q_ch4_remaining': Remaining methane [m³/d]
to_dict()¶
Serialize to dictionary.
Returns:
Dict[str, Any]: Component configuration as dictionary.
Attributes:
- P_el_nom (float): Nominal electrical power in kW.
- eta_el (float): Electrical efficiency (0-1).
- eta_th (float): Thermal efficiency (0-1).
- load_factor (float): Current operating point (0-1).
Flare¶
Flare component for combusting vented biogas.
The flare accepts an input `Q_gas_in_m3_per_day` and will combust it.
It reports `vented_volume_m3` for the current timestep and `cumulative_vented_m3`.
Parameters
----------
component_id : str
Unique id for the flare component.
destruction_efficiency : float
Fraction of methane destroyed (0..1). Default 0.98.
name : Optional[str]
Human readable name.
Signature:
Methods:
add_input()¶
Add an input connection.
add_output()¶
Add an output connection.
get_state()¶
Get current component state.
initialize()¶
Initialize flare internal state.
Args:
initial_state: optional dict with 'cumulative_vented_m3' to restore state.
set_state()¶
Set component state.
step()¶
Process one timestep and combust incoming gas.
Args:
t: current simulation time [days]
dt: timestep length [days]
inputs: dictionary that may contain:
- 'Q_gas_in_m3_per_day': inflow (m³/day)
- 'CH4_fraction': methane fraction in the gas (0..1). Default 0.6
Returns:
outputs_data dict with keys:
- 'vented_volume_m3' (this timestep)
- 'cumulative_vented_m3'
- 'CH4_destroyed_m3' (m³ of CH4 destroyed this step)
to_dict()¶
Serialize flare configuration and state.
GasStorage¶
Gas storage component.
Arguments: component_id: unique id storage_type: 'membrane' | 'dome' | 'compressed' capacity_m3: usable gas volume at STP (m^3) p_min_bar: minimum operating pressure (bar) p_max_bar: maximum safe pressure (bar) name: optional human-readable name
Signature:
GasStorage(
component_id,
storage_type='membrane',
capacity_m3=1000.0,
p_min_bar=0.95,
p_max_bar=1.05,
initial_fill_fraction=0.1,
name=None
)
Methods:
add_input()¶
Add an input connection.
add_output()¶
Add an output connection.
get_state()¶
Get current component state.
initialize()¶
Initialize storage state; initial_state may contain stored_volume_m3, pressure_setpoint_bar.
set_state()¶
Set component state.
step()¶
One simulation step.
Args:
t:
dt:
inputs: Inputs dictionary may contain:
- 'Q_gas_in_m3_per_day' : gas inflow from digesters/other sources (m^3/day)
- 'Q_gas_out_m3_per_day' : requested gas outflow (demand) (m^3/day)
- 'set_pressure' : desired pressure setpoint (bar) (optional)
- 'vent_to_flare' : bool, if True allow venting to flare when overpressure (default True)
Returns:
object: Returns outputs_data with keys:
- 'stored_volume_m3'
- 'pressure_bar'
- 'utilization' (0-1)
- 'vented_volume_m3' (this timestep)
- 'Q_gas_supplied_m3_per_day' (actual supply that was delivered)
to_dict()¶
Serialize configuration + current state.