PyADM1ODE Documentation¶
Welcome to PyADM1ODE - A Python framework for modeling, simulating, and optimizing agricultural biogas plants based on the Anaerobic Digestion Model No. 1 (ADM1).
π― Quick Links¶
-
Quick Start
Get started in minutes with your first biogas plant simulation
-
Installation
Install PyADM1ODE on Windows, Linux, or macOS
-
Components Guide
Learn about digesters, CHP units, pumps, and more
-
Examples
Real-world examples from basic to advanced plants
What is PyADM1ODE?¶
PyADM1ODE is a comprehensive Python framework for agricultural biogas plant modeling that combines:
- Scientific accuracy: Based on IWA's ADM1 model, the international standard for anaerobic digestion
- Modular architecture: Mix and match components (digesters, CHP units, pumps, mixers) to build any plant configuration
- Real-world applicability: Validated with data from operating biogas plants
- Python ecosystem: Integrates with NumPy, SciPy, Pandas, and visualization libraries
Key Features¶
β¨ Comprehensive Component Library
- Biological: Single/multi-stage digesters, hydrolysis tanks, separators
- Energy: CHP units, heating systems, gas storage, flares
- Mechanical: Pumps, mixers with realistic power consumption
- Feeding: Substrate storage, automated dosing systems
π§ Flexible Plant Configuration
- Build complex plants programmatically or via templates
- Automatic component connection and validation
- Save/load configurations as JSON
π Advanced Simulation
- Parallel execution for parameter sweeps and Monte Carlo analysis
- Adaptive ODE solvers optimized for stiff biogas systems
- Time-series data handling and result analysis
π Educational & Professional
- Suitable for teaching biogas plant design
- Research tool for process optimization
- Engineering applications for plant planning
System Architecture¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PyADM1ODE Framework β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Biological β β Energy β β Mechanical β β
β β Components β β Components β β Components β β
β ββββββββββββββββ€ ββββββββββββββββ€ ββββββββββββββββ€ β
β β β’ Digesters β β β’ CHP Units β β β’ Pumps β β
β β β’ Hydrolysis β β β’ Heating β β β’ Mixers β β
β β β’ Separators β β β’ Storage β β β β
β β β β β’ Flares β β β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Feeding β β Sensors β β Configurator β β
β β Components β β (planned) β β β β
β ββββββββββββββββ€ ββββββββββββββββ€ ββββββββββββββββ€ β
β β β’ Storage β β β’ pH β β β’ Builder β β
β β β’ Feeders β β β’ VFA β β β’ Templates β β
β β β β β’ Gas β β β’ Validator β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Core ADM1 Engine β
β β’ 37 state variables β’ pH dynamics β’ Gas-liquid transfer β
β β’ Temperature-dependent kinetics β’ Inhibition modeling β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Substrate Management β
β β’ 10 pre-configured agricultural substrates β
β β’ Automatic ADM1 input stream generation β
β β’ Time-varying feed schedules β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Quick Example¶
Build and simulate a complete biogas plant in just a few lines:
from pyadm1.configurator import BiogasPlant, PlantConfigurator
from pyadm1.substrates import Feedstock
# Create plant
feedstock = Feedstock(feeding_freq=48)
plant = BiogasPlant("My Biogas Plant")
configurator = PlantConfigurator(plant, feedstock)
# Add digester (automatically creates gas storage)
configurator.add_digester(
digester_id="main_digester",
V_liq=2000.0, # 2000 mΒ³ liquid volume
V_gas=300.0, # 300 mΒ³ gas headspace
T_ad=308.15, # 35Β°C mesophilic
Q_substrates=[15, 10, 0, 0, 0, 0, 0, 0, 0, 0] # Corn silage + manure
)
# Add CHP and heating (automatically creates flare)
configurator.add_chp("chp_main", P_el_nom=500.0)
configurator.add_heating("heating_main", target_temperature=308.15)
# Connect components
configurator.auto_connect_digester_to_chp("main_digester", "chp_main")
configurator.auto_connect_chp_to_heating("chp_main", "heating_main")
# Simulate
plant.initialize()
results = plant.simulate(duration=30, dt=1/24, save_interval=1.0)
# Analyze
final = results[-1]["components"]["main_digester"]
print(f"Biogas: {final['Q_gas']:.1f} mΒ³/d")
print(f"Methane: {final['Q_ch4']:.1f} mΒ³/d")
print(f"pH: {final['pH']:.2f}")
Output:
Typical Applications¶
1. Plant Design and Optimization¶
# Test different digester sizes
for V_liq in [1500, 2000, 2500]:
plant = BiogasPlant(f"Plant_{V_liq}")
configurator = PlantConfigurator(plant, feedstock)
configurator.add_digester("dig1", V_liq=V_liq, Q_substrates=[15, 10, 0, 0, 0, 0, 0, 0, 0, 0])
plant.initialize()
results = plant.simulate(duration=30, dt=1/24)
final = results[-1]["components"]["dig1"]
print(f"V={V_liq} mΒ³ β CH4={final['Q_ch4']:.1f} mΒ³/d")
2. Substrate Optimization¶
# Compare different substrate mixes
mixes = {
'high_energy': [20, 5, 0, 0, 0, 0, 0, 0, 0, 0],
'balanced': [15, 10, 0, 0, 0, 0, 0, 0, 0, 0],
'waste_based': [0, 15, 0, 0, 0, 0, 0, 0, 10, 5]
}
for name, Q in mixes.items():
# ... configure and simulate ...
print(f"{name}: {final['Q_ch4']:.1f} mΒ³/d methane")
3. Energy Balance Analysis¶
# Calculate net energy production
chp_power = results[-1]["components"]["chp_main"]["P_el"]
mixer_power = results[-1]["components"]["mixer_1"]["P_consumed"]
pump_power = results[-1]["components"]["pump_1"]["P_consumed"]
parasitic_load = mixer_power + pump_power
net_power = chp_power - parasitic_load
print(f"Net power: {net_power:.1f} kW")
print(f"Parasitic ratio: {parasitic_load/chp_power:.1%}")
4. Two-Stage Process Design¶
# Temperature-phased anaerobic digestion (TPAD)
configurator.add_digester("hydrolysis", V_liq=500, T_ad=318.15) # 45Β°C
configurator.add_digester("main", V_liq=2000, T_ad=308.15) # 35Β°C
configurator.connect("hydrolysis", "main", "liquid")
# Enhanced hydrolysis in stage 1, stable methanogenesis in stage 2
Component Categories¶
Biological Components¶
Model the core biological processes:
- Digester: Main fermenter with ADM1 model
- Single or multi-stage configurations
- Temperature control (psychrophilic, mesophilic, thermophilic)
- Automatic gas storage creation
-
Calibration parameter support (using PyADM1ODE_calibration)
-
Hydrolysis: Pre-treatment tank (planned)
- Separator: Digestate processing (planned)
Energy Components¶
Complete energy integration:
-
CHP: Combined heat and power generation
- Variable efficiency curves
- Load-following operation
- Automatic flare creation
-
Heating: Temperature control systems
- CHP waste heat utilization
- Auxiliary heating calculation
-
Gas Storage: Biogas buffering
- Low-pressure (membrane, dome) and high-pressure options
- Automatic pressure management
- Safety venting
-
Flare: Safety gas combustion
- 98% methane destruction efficiency
- Automatic activation on overpressure
Mechanical Components¶
Material handling and process control:
-
Pump: Substrate and digestate transfer
- Progressive cavity, centrifugal, piston types
- Power consumption modeling
- Variable frequency drive support
-
Mixer: Digester agitation
- Propeller, paddle, jet mixer types
- Intermittent operation for energy savings
- Reynolds number and mixing time calculation
Feeding Components¶
Substrate management:
-
Substrate Storage: Material inventory
- Multiple storage types (silos, tanks, bunkers)
- Quality degradation modeling
- Capacity and utilization tracking
-
Feeder: Automated dosing
- Screw, piston, progressive cavity feeders
- Realistic dosing accuracy and noise
- Blockage detection
Pre-configured Substrates¶
PyADM1ODE includes 10 agricultural substrates with literature-validated parameters:
| Substrate | Type | Typical Use | Biogas Potential |
|---|---|---|---|
| Corn silage | Energy crop | Main feedstock | High (600-700 L/kg VS) |
| Liquid manure | Animal waste | Co-substrate | Medium (200-400 L/kg VS) |
| Green rye | Energy crop | Early harvest | Medium-High |
| Grass silage | Grassland | Renewable | Medium (400-550 L/kg VS) |
| Wheat | Cereal | Energy crop | High |
| GPS | Grain silage | Whole-crop | High |
| CCM | Corn-cob-mix | Energy crop | High |
| Feed lime | Additive | pH buffer | N/A |
| Cow manure | Animal waste | Co-substrate | Medium (200-350 L/kg VS) |
| Onions | Waste | Vegetable waste | Medium-High |
All substrates are characterized with:
- Dry matter (DM) and volatile solids (VS) content
- ADM1 fractionation (carbohydrates, proteins, lipids)
- Biochemical methane potential (BMP)
- pH and alkalinity
Advanced Features¶
Parallel Simulation¶
Run multiple scenarios concurrently (see Example: Parallel Simulation):
from pyadm1.simulation import ParallelSimulator
# Parameter sweep
parallel = ParallelSimulator(adm1, n_workers=4)
scenarios = [
{"k_dis": 0.5, "Q": [15, 10, 0, 0, 0, 0, 0, 0, 0, 0]},
{"k_dis": 0.6, "Q": [15, 10, 0, 0, 0, 0, 0, 0, 0, 0]},
{"k_dis": 0.7, "Q": [15, 10, 0, 0, 0, 0, 0, 0, 0, 0]}
]
results = parallel.run_scenarios(scenarios, duration=30, initial_state=state)
Configuration Management¶
Save and reuse plant designs:
# Save configuration
plant.to_json("two_stage_plant.json")
# Load later
plant = BiogasPlant.from_json("two_stage_plant.json", feedstock)
plant.initialize()
results = plant.simulate(duration=30, dt=1/24)
Scientific Foundation¶
PyADM1ODE is based on the Anaerobic Digestion Model No. 1 (ADM1), developed by the International Water Association (IWA) Task Group:
- 37 state variables: Complete representation of liquid and gas phases
- 19 biochemical processes: Disintegration, hydrolysis, acidogenesis, acetogenesis, methanogenesis
- Temperature-dependent kinetics: Arrhenius relationships for all rate constants
- pH dynamics: Full acid-base equilibrium with 6 ionic species
- Gas-liquid transfer: Henry's law implementation for Hβ, CHβ, COβ
- Inhibition modeling: pH, ammonia, and hydrogen inhibition
Key References:
- Batstone, D.J., et al. (2002). Anaerobic Digestion Model No. 1 (ADM1). IWA Publishing.
- Sadrimajd, P., et al. (2021). PyADM1: a Python implementation of Anaerobic Digestion Model No. 1. bioRxiv.
Installation¶
Install PyADM1ODE via pip (not yet existing):
For development or the latest features:
Platform-specific requirements:
- Linux/macOS: Mono runtime (for C# DLLs)
- Windows: .NET Framework (usually pre-installed)
See the Installation Guide for detailed instructions.
Getting Started¶
- Install PyADM1ODE on your system
- Follow the Quickstart to run your first simulation
- Explore Components to understand available building blocks
- Study Examples for real-world applications
Extension Packages¶
PyADM1ODE_mcp - LLM-Driven Plant Design¶
Natural language interface for biogas plant modeling:
Features:
- Interact with Claude or other LLMs to design plants via natural language
- MCP server for seamless LLM integration
- Automated configuration parsing and validation
Use case: "Design a two-stage biogas plant with 2000 mΒ³ main digester, 500 mΒ³ hydrolysis tank at 45Β°C, and a 500 kW CHP unit. Use corn silage and cattle manure as substrates."
PyADM1ODE_calibration - Parameter Estimation¶
Automated model calibration from measurement data:
git clone https://github.com/dgaida/PyADM1ODE_calibration.git
cd PyADM1ODE_calibration
pip install -e .
Features:
- Initial calibration from historical data
- Online re-calibration during operation
- Multiple optimization algorithms (Differential Evolution, PSO, Nelder-Mead)
- Comprehensive validation metrics
Use case: Fit ADM1 parameters to real plant measurements for accurate predictions.
Community and Support¶
- GitHub Repository: dgaida/PyADM1ODE
- Issue Tracker: Report bugs or request features
- Discussions: Ask questions and share ideas
- Email: daniel.gaida@th-koeln.de
License¶
PyADM1ODE is open-source software licensed under the MIT License.
Citation¶
If you use PyADM1ODE in your research, please cite:
@software{gaida2025pyadm1ode,
author = {Gaida, Daniel; Nordhoff, Tim Yago},
title = {PyADM1ODE: Python Framework for Agricultural Biogas Plant Modeling},
year = {2026},
url = {https://github.com/dgaida/PyADM1ODE}
}
Acknowledgments¶
PyADM1ODE builds upon:
- IWA ADM1 Task Group - Original model development
- PyADM1 by Sadrimajd et al. - Initial Python implementation
- SIMBA#biogas - Substrate characterization and validation data
Ready to start? Head over to the Quickstart Guide and build your first biogas plant in minutes! π