Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions docs/assets/colab-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/de/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Willkommen bei PyADM1ODE - Einem Python-Framework zur Modellierung, Simulation u

## 🎯 Quick Links
<div align="center">
<a href="https://colab.research.google.com/github/dgaida/PyADM1ODE/blob/master/examples/colab_01_basic_digester.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a>
<a href="https://colab.research.google.com/github/dgaida/PyADM1ODE/blob/master/examples/colab_01_basic_digester.ipynb"><img src="assets/colab-badge.svg" alt="Open In Colab: Basic Digester"></a> <a href="https://colab.research.google.com/github/dgaida/PyADM1ODE/blob/master/examples/colab_02_complex_plant.ipynb"><img src="assets/colab-badge.svg" alt="Open In Colab: Complex Plant"></a>
</div>

<div class="grid cards" markdown>
Expand Down
130 changes: 130 additions & 0 deletions docs/de/user_guide/llm_api.md
Original file line number Diff line number Diff line change
@@ -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()`
2 changes: 1 addition & 1 deletion docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Welcome to PyADM1ODE - A Python framework for modeling, simulating, and optimizi

## 🎯 Quick Links
<div align="center">
<a href="https://colab.research.google.com/github/dgaida/PyADM1ODE/blob/master/examples/colab_01_basic_digester.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a>
<a href="https://colab.research.google.com/github/dgaida/PyADM1ODE/blob/master/examples/colab_01_basic_digester.ipynb"><img src="assets/colab-badge.svg" alt="Open In Colab: Basic Digester"></a> <a href="https://colab.research.google.com/github/dgaida/PyADM1ODE/blob/master/examples/colab_02_complex_plant.ipynb"><img src="assets/colab-badge.svg" alt="Open In Colab: Complex Plant"></a>
</div>

<div class="grid cards" markdown>
Expand Down
130 changes: 130 additions & 0 deletions docs/en/user_guide/llm_api.md
Original file line number Diff line number Diff line change
@@ -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()`
27 changes: 27 additions & 0 deletions examples/colab_01_basic_digester.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading