diff --git a/AGENTS.md b/AGENTS.md index ed2b4cd..6f26ed6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,3 +9,6 @@ - **Cleanup**: Temporary files (e.g., build artifacts like `site/`, log files, `changes.diff`) must be deleted before creating a Pull Request or submitting. - **Documentation**: If the navigation structure in `mkdocs.yml` is changed, ensure that `nav_translations` in the `i18n` plugin are updated and landing pages (`index.md`) are synchronized. - **Testing**: Run relevant unit tests to ensure no regressions are introduced. + +## Skills +- **MkDocs Documentation Ecosystem**: [SKILL_docs.md](https://github.com/dgaida/auto-version-action/blob/main/skills/SKILL_docs.md) diff --git a/docs/assets/colab-badge.svg b/docs/assets/colab-badge.svg new file mode 100644 index 0000000..e5830d5 --- /dev/null +++ b/docs/assets/colab-badge.svg @@ -0,0 +1 @@ + Open in ColabOpen in Colab diff --git a/docs/de/index.md b/docs/de/index.md index a58491a..58a5abb 100644 --- a/docs/de/index.md +++ b/docs/de/index.md @@ -4,7 +4,7 @@ Willkommen bei PyADM1ODE - Einem Python-Framework zur Modellierung, Simulation u ## 🎯 Quick Links
- Open In Colab + Open In Colab: Basic Digester Open In Colab: Complex Plant
diff --git a/docs/de/user_guide/llm_api.md b/docs/de/user_guide/llm_api.md new file mode 100644 index 0000000..2fe41b8 --- /dev/null +++ b/docs/de/user_guide/llm_api.md @@ -0,0 +1,130 @@ +# API für LLM + +Diese Seite bietet eine strukturierte Referenz der Methoden und Klassen, die benötigt werden, um ein PyADM1ODE-Simulationsmodell automatisch zu erstellen. Diese Dokumentation ist darauf optimiert, von Large Language Models (LLMs) gelesen zu werden, um Biogasanlagenkonfigurationen zu generieren. + +## Kern-Workflow + +Um eine Simulation zu erstellen, folgen Sie diesem Ablauf: +1. Erstellen Sie ein `Feedstock`-Objekt. +2. Erstellen Sie ein `BiogasPlant`-Objekt. +3. Verwenden Sie den `PlantConfigurator`, um Komponenten hinzuzufügen und zu verbinden. +4. Initialisieren Sie die Anlage und starten Sie die Simulation. + +## 1. Substrat-Konfiguration (Feedstock) + +Das `Feedstock`-Objekt definiert, welche Substrate in der Anlage verwendet werden. + +```python +from pyadm1.substrates import Feedstock + +# Erstellt ein Feedstock mit Maissilage und Schweinegülle +feedstock = Feedstock( + substrates=["maize_silage_milk_ripeness", "swine_manure"], + feeding_freq=24, # Fütterungsfrequenz pro Tag + total_simtime=30 # Gesamte Simulationsdauer in Tagen +) +``` + +## 2. Anlagen-Basis (BiogasPlant) + +```python +from pyadm1.configurator import BiogasPlant + +plant = BiogasPlant("Name der Anlage") +``` + +## 3. Anlagen-Konfigurator (PlantConfigurator) + +Der `PlantConfigurator` ist das Hauptwerkzeug zum Aufbau der Topologie. + +```python +from pyadm1.configurator import PlantConfigurator + +configurator = PlantConfigurator(plant, feedstock) +``` + +### Fermenter hinzufügen + +```python +# Fügt einen Fermenter hinzu. Erstellt automatisch einen Gasspeicher. +# Q_substrates gibt die Menge der im Feedstock definierten Substrate in [m³/d] an. +digester, state_info = configurator.add_digester( + digester_id="main_digester", + V_liq=2000.0, # Flüssigkeitsvolumen [m³] + V_gas=300.0, # Gasraum [m³] + T_ad=308.15, # Temperatur [K] (35°C = 308.15K) + Q_substrates=[15.0, 10.0] # Mengen korrespondierend zur Feedstock-Liste +) +``` + +### Energie-Komponenten + +```python +# Blockheizkraftwerk (BHKW) hinzufügen +configurator.add_chp( + chp_id="chp_1", + P_el_nom=500.0 # Nominale elektrische Leistung [kW] +) + +# Heizung hinzufügen +configurator.add_heating( + heating_id="heating_1", + target_temperature=308.15 # Zieltemperatur [K] +) +``` + +### Mechanische Komponenten + +Mechanische Komponenten müssen direkt zur `plant` hinzugefügt werden: + +```python +from pyadm1.components.mechanical import Pump, Mixer +from pyadm1.components.feeding import SubstrateStorage, Feeder + +# Pumpe +pump = Pump("pump1", pump_type="progressive_cavity", Q_nom=15.0) +plant.add_component(pump) + +# Rührwerk +mixer = Mixer("mix1", tank_volume=2000.0, intermittent=True, on_time_fraction=0.25) +plant.add_component(mixer) + +# Substratlager +storage = SubstrateStorage("silo1", storage_type="vertical_silo", capacity=1000.0) +plant.add_component(storage) + +# Dosierer +feeder = Feeder("feed1", feeder_type="screw", Q_max=20.0) +plant.add_component(feeder) +``` + +### Verbindungen herstellen + +```python +# Manuelle Verbindung +configurator.connect("source_id", "target_id", connection_type="liquid") # oder "gas", "heat", "default" + +# Automatische Verbindungs-Helfer (empfohlen) +configurator.auto_connect_digester_to_chp("main_digester", "chp_1") +configurator.auto_connect_chp_to_heating("chp_1", "heating_1") +``` + +## 4. Simulation ausführen + +```python +plant.initialize() +results = plant.simulate( + duration=30, # Dauer in Tagen + dt=1/24, # Zeitschritt (z.B. stündlich) + save_interval=1.0 # Intervall für Ergebnis-Snapshots +) +``` + +## Zusammenfassung für LLM-Prompts + +Verwenden Sie diese Klassen für den Aufbau: +- **Biologische Stufe**: `configurator.add_digester()` +- **Energie**: `configurator.add_chp()`, `configurator.add_heating()` +- **Mechanik**: `Pump`, `Mixer` +- **Logistik**: `SubstrateStorage`, `Feeder` +- **Infrastruktur**: `PlantConfigurator.connect()` diff --git a/docs/en/index.md b/docs/en/index.md index 1d842cf..4724cfa 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -4,7 +4,7 @@ Welcome to PyADM1ODE - A Python framework for modeling, simulating, and optimizi ## 🎯 Quick Links
- Open In Colab + Open In Colab: Basic Digester Open In Colab: Complex Plant
diff --git a/docs/en/user_guide/llm_api.md b/docs/en/user_guide/llm_api.md new file mode 100644 index 0000000..1779c91 --- /dev/null +++ b/docs/en/user_guide/llm_api.md @@ -0,0 +1,130 @@ +# API for LLM + +This page provides a structured reference of the methods and classes required to automatically create a PyADM1ODE simulation model. This documentation is optimized for reading by Large Language Models (LLMs) to generate biogas plant configurations. + +## Core Workflow + +To create a simulation, follow this sequence: +1. Create a `Feedstock` object. +2. Create a `BiogasPlant` object. +3. Use the `PlantConfigurator` to add and connect components. +4. Initialize the plant and start the simulation. + +## 1. Substrate Configuration (Feedstock) + +The `Feedstock` object defines which substrates are used in the plant. + +```python +from pyadm1.substrates import Feedstock + +# Create a feedstock with maize silage and swine manure +feedstock = Feedstock( + substrates=["maize_silage_milk_ripeness", "swine_manure"], + feeding_freq=24, # Feeding frequency per day + total_simtime=30 # Total simulation time in days +) +``` + +## 2. Plant Basis (BiogasPlant) + +```python +from pyadm1.configurator import BiogasPlant + +plant = BiogasPlant("Plant Name") +``` + +## 3. Plant Configurator (PlantConfigurator) + +The `PlantConfigurator` is the primary tool for building the topology. + +```python +from pyadm1.configurator import PlantConfigurator + +configurator = PlantConfigurator(plant, feedstock) +``` + +### Adding Digesters + +```python +# Adds a digester. Automatically creates a gas storage unit. +# Q_substrates specifies the amount of substrates defined in the feedstock in [m³/d]. +digester, state_info = configurator.add_digester( + digester_id="main_digester", + V_liq=2000.0, # Liquid volume [m³] + V_gas=300.0, # Gas headspace [m³] + T_ad=308.15, # Temperature [K] (35°C = 308.15K) + Q_substrates=[15.0, 10.0] # Amounts corresponding to the feedstock list +) +``` + +### Energy Components + +```python +# Add Combined Heat and Power (CHP) unit +configurator.add_chp( + chp_id="chp_1", + P_el_nom=500.0 # Nominal electrical power [kW] +) + +# Add heating system +configurator.add_heating( + heating_id="heating_1", + target_temperature=308.15 # Target temperature [K] +) +``` + +### Mechanical Components + +Mechanical components must be added directly to the `plant`: + +```python +from pyadm1.components.mechanical import Pump, Mixer +from pyadm1.components.feeding import SubstrateStorage, Feeder + +# Pump +pump = Pump("pump1", pump_type="progressive_cavity", Q_nom=15.0) +plant.add_component(pump) + +# Mixer +mixer = Mixer("mix1", tank_volume=2000.0, intermittent=True, on_time_fraction=0.25) +plant.add_component(mixer) + +# Substrate Storage +storage = SubstrateStorage("silo1", storage_type="vertical_silo", capacity=1000.0) +plant.add_component(storage) + +# Feeder +feeder = Feeder("feed1", feeder_type="screw", Q_max=20.0) +plant.add_component(feeder) +``` + +### Establishing Connections + +```python +# Manual connection +configurator.connect("source_id", "target_id", connection_type="liquid") # or "gas", "heat", "default" + +# Automatic connection helpers (recommended) +configurator.auto_connect_digester_to_chp("main_digester", "chp_1") +configurator.auto_connect_chp_to_heating("chp_1", "heating_1") +``` + +## 4. Running the Simulation + +```python +plant.initialize() +results = plant.simulate( + duration=30, # Duration in days + dt=1/24, # Time step (e.g., hourly) + save_interval=1.0 # Interval for result snapshots +) +``` + +## Summary for LLM Prompts + +Use these classes for construction: +- **Biological Stage**: `configurator.add_digester()` +- **Energy**: `configurator.add_chp()`, `configurator.add_heating()` +- **Mechanics**: `Pump`, `Mixer` +- **Logistics**: `SubstrateStorage`, `Feeder` +- **Infrastructure**: `PlantConfigurator.connect()` diff --git a/examples/colab_01_basic_digester.ipynb b/examples/colab_01_basic_digester.ipynb index 98e0ffc..20763a3 100644 --- a/examples/colab_01_basic_digester.ipynb +++ b/examples/colab_01_basic_digester.ipynb @@ -113,6 +113,33 @@ " print(f\" Methane: {c.get('Q_ch4', 0):>8.1f} m^3/d\")\n", " print(f\" pH: {c.get('pH', 0):>8.2f}\")" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 5. Plot methane production" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt\n", + "\n", + "times = [r[\"time\"] for r in results]\n", + "q_ch4 = [r[\"components\"][\"main_digester\"].get(\"Q_ch4\", 0) for r in results]\n", + "\n", + "plt.figure(figsize=(10, 6))\n", + "plt.plot(times, q_ch4, marker='o', linestyle='-', color='b')\n", + "plt.xlabel(\"Time [d]\")\n", + "plt.ylabel(\"Methane production [m³/d]\")\n", + "plt.title(\"Methane Production over Time\")\n", + "plt.grid(True)\n", + "plt.show()" + ] } ], "metadata": { diff --git a/mkdocs.yml b/mkdocs.yml index 005f973..f16512b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -70,6 +70,7 @@ plugins: Anwendungen: Applications Fortgeschrittene Funktionen: Advanced Features Fehlerbehebung: Troubleshooting + API für LLM: API for LLM ADM1-Implementierung: ADM1 Implementation Architektur: Architecture Validierung: Validation @@ -143,6 +144,7 @@ nav: - Anwendungen: user_guide/applications.md - Fortgeschrittene Funktionen: user_guide/advanced_features.md - Fehlerbehebung: user_guide/troubleshooting.md + - API für LLM: user_guide/llm_api.md - Modell & Theorie: - ADM1-Implementierung: user_guide/adm1_implementation.md - Architektur: architecture/index.md