# GROMACS-Molekulardynamik

> **GPU-beschleunigte Molekulardynamik-Simulationen — von Protein-Faltung bis Wirkstoffforschung**

GROMACS (GROningen MAchine for Chemical Simulations) ist das weltweit am häufigsten verwendete Paket für Molekulardynamik-Simulationen. Ursprünglich an der Universität Groningen entwickelt, wird es jetzt von einer globalen Community gepflegt und ist das Arbeitspferd in Laboren für rechnergestützte Chemie und Strukturbiologie weltweit.

Mit GPU-Beschleunigung kann GROMACS Systeme mit Millionen von Atomen mit Geschwindigkeiten simulieren, für die auf reiner CPU-Hardware Wochen nötig wären. Die erschwinglichen GPU-Vermietungen von Clore.ai machen groß angelegte MD-Simulationen für einzelne Forschende und kleine Labore zugänglich.

***

## Was können Sie simulieren?

* **Protein-Faltung und Dynamik** — beobachte Konformationsänderungen im Nanosekunden- bis Mikrosekundenbereich
* **Wirkstoff-Protein-Bindung** — berechne freie Bindungsenergien für die Wirkstoffforschung
* **Membran-Simulationen** — Lipiddoppelschichten, Membranproteine, Ionentransport
* **Protein-Protein-Wechselwirkungen** — untersuche Komplexbildung und Schnittstellen-Dynamik
* **Materialwissenschaft** — Polymere, Nanopartikel, Wassermodelle
* **Freie-Energie-Berechnungen** — alchemistische Transformationen, PME

***

## Voraussetzungen

* Clore.ai-Konto mit GPU-Vermietung
* Grundlegende Kenntnisse der Linux-Kommandozeile
* Molekulare Systemdateien (Topologie + Koordinaten) oder verwende Beispielsysteme
* Optional: GROMACS lokal zur Visualisierung (VMD, Pymol)

***

## Warum GPU-beschleunigtes GROMACS verwenden?

GROMACS mit GPU-Offloading bietet dramatische Beschleunigungen:

| Systemgröße | Nur CPU (ns/Tag) | Einzelne A100 (ns/Tag) | Beschleunigung |
| ----------- | ---------------- | ---------------------- | -------------- |
| 25K Atome   | \~50             | \~800                  | \~16x          |
| 100K Atome  | \~15             | \~400                  | \~27x          |
| 500K Atome  | \~3              | \~150                  | \~50x          |
| 1M Atome    | \~1              | \~80                   | \~80x          |

{% hint style="success" %}
**GPU-Beschleunigung ist besonders vorteilhaft für große Systeme (>100K Atome).** Bei kleinen Testsystemen kann die CPU-Leistung aufgrund von Datenübertragungs-Overhead vergleichbar sein.
{% endhint %}

***

## Schritt 1 — Mieten Sie eine GPU auf Clore.ai

1. Gehe zu [clore.ai](https://clore.ai) → **Marktplatz**
2. Filter nach GPU: **A100, RTX 4090 oder RTX 3090** empfohlen
3. Für große Systeme (>500K Atome): wähle A100 40GB oder 80GB
4. Für Standard-Simulationen: RTX 4090 oder RTX 3090 bieten ein hervorragendes Preis-Leistungs-Verhältnis

**Empfohlene Spezifikationen:**

* GPU: A100 40GB oder RTX 4090
* CPU: 16+ Kerne (GROMACS nutzt Mehrkernverarbeitung für nicht-bindende Wechselwirkungen)
* RAM: 32GB+
* Festplatte: 50GB+ (Trajektorien können groß sein)

***

## Schritt 2 — GROMACS-Container bereitstellen

Verwende das offizielle NVIDIA HPC GROMACS-Image — es ist für NVIDIA-GPUs mit CUDA-Unterstützung optimiert:

**Docker-Image:**

```
nvcr.io/hpc/gromacs:2023.2
```

**Offengelegte Ports:**

```
22
```

**Umgebungsvariablen:**

```
NVIDIA_VISIBLE_DEVICES=all
NVIDIA_DRIVER_CAPABILITIES=compute,utility
GMX_GPU_DD_COMMS=true
GMX_GPU_PME_PP_COMMS=true
GMX_FORCE_UPDATE_DEFAULT_GPU=true
```

{% hint style="info" %}
**NVIDIA-Umgebungsvariablen für GROMACS:**

* `GMX_GPU_DD_COMMS=true` — aktiviert GPU-basierte Domain-Decomposition-Kommunikation
* `GMX_GPU_PME_PP_COMMS=true` — aktiviert GPU-basierte PME-PP-Kommunikation
* `GMX_FORCE_UPDATE_DEFAULT_GPU=true` — erzwingt GPU-Koordinatenaktualisierung (erhebliche Beschleunigung)
  {% endhint %}

***

## Schritt 3 — Verbinden und Überprüfen

```bash
ssh root@<server-ip> -p <ssh-port>

# GROMACS-Version prüfen
gmx --version

# GPU-Verfügbarkeit prüfen
nvidia-smi

# Überprüfen, dass GROMACS die GPU sieht
gmx mdrun -h 2>&1 | grep -i gpu
```

Erwartete Ausgabe von `gmx --version` sollte Folgendes zeigen:

```
GROMACS-Version: 2023.2
CUDA-Version: 11.x oder 12.x
GPU-Unterstützung: CUDA
```

***

## Schritt 4 — Bereiten Sie Ihr System vor

### Verwendung eines Beispielsystems (Lysozym in Wasser)

Dies ist das klassische GROMACS-Tutorialsystem — perfekt zum Testen Ihrer Einrichtung:

```bash
# Arbeitsverzeichnis erstellen
mkdir -p /workspace/lysozyme && cd /workspace/lysozyme

# Lysozym-PDB-Struktur herunterladen
wget https://files.rcsb.org/download/1AKI.pdb -O 1AKI.pdb

# Wassermoleküle aus der Kristallstruktur entfernen
grep -v HOH 1AKI.pdb > 1AKI_clean.pdb

# Topologie mit AMBER99SB-Kraftfeld erzeugen
gmx pdb2gmx \
    -f 1AKI_clean.pdb \
    -o processed.gro \
    -water spce \
    -ff amber99sb-ildn
```

Wenn Sie zur Auswahl des Kraftfelds aufgefordert werden, wählen Sie `amber99sb-ildn` (typischerweise Option 6).

***

## Schritt 5 — Simulationsbox aufbauen

```bash
# Simulationsbox definieren (Dodekaeder, 1,0 nm vom Protein)
gmx editconf \
    -f processed.gro \
    -o boxed.gro \
    -c \
    -d 1.0 \
    -bt dodecahedron

# Die Box mit Wasser solvatisieren
gmx solvate \
    -cp boxed.gro \
    -cs spc216.gro \
    -o solvated.gro \
    -p topol.top

# Ionen hinzufügen, um die Ladung zu neutralisieren
# Zuerst TPR-Datei für die Ionenzugabe erstellen
gmx grompp \
    -f /usr/local/gromacs/share/gromacs/top/em.mdp \
    -c solvated.gro \
    -p topol.top \
    -o ions.tpr

# Na+ und Cl- Ionen hinzufügen (0.15M NaCl)
gmx genion \
    -s ions.tpr \
    -o ionized.gro \
    -p topol.top \
    -pname NA \
    -nname CL \
    -neutral \
    -conc 0.15
# Wählen Sie Gruppe 13 (SOL), wenn Sie dazu aufgefordert werden
```

***

## Schritt 6 — Energie-Minimierung

```bash
# Energie-Minimierungs-MDP-Datei erstellen
cat > em.mdp << 'EOF'
; Energie-Minimierungsparameter
integrator      = steep         ; Steepest-Descent-Minimierung
emtol           = 1000.0        ; Stop, wenn maximale Kraft < 1000 kJ/mol/nm
emstep          = 0.01          ; Anfangsschrittgröße
nsteps          = 50000         ; Maximale Minimierungsschritte
nstlist         = 1
cutoff-scheme   = Verlet
ns_type         = grid
coulombtype     = PME
rcoulomb        = 1.0
rvdw            = 1.0
pbc             = xyz
EOF

# TPR für Energie-Minimierung vorbereiten
gmx grompp \
    -f em.mdp \
    -c ionized.gro \
    -p topol.top \
    -o em.tpr

# Energie-Minimierung auf der GPU ausführen
gmx mdrun \
    -v \
    -deffnm em \
    -gpu_id 0 \
    -ntmpi 1 \
    -ntomp 8

# Prüfen, dass die Energie konvergiert ist
gmx energy -f em.edr -o em_potential.xvg
# Wähle 10 (Potential) und dann 0 zum Beenden
```

***

## Schritt 7 — NVT-Equilibrierung (Temperatur)

```bash
cat > nvt.mdp << 'EOF'
; NVT-Equilibrierung
define              = -DPOSRES      ; Positionsbindungen
integrator          = md            ; Leap-Frog-Integrator
nsteps              = 50000         ; 100 ps (2 fs Zeitschritt)
dt                  = 0.002         ; 2 fs Zeitschritt
nstxout             = 500
nstvout             = 500
nstenergy           = 500
nstlog              = 500
continuation        = no
constraint_algorithm = lincs
constraints         = h-bonds
lincs_iter          = 1
lincs_order         = 4
cutoff-scheme       = Verlet
ns_type             = grid
nstlist             = 10
rcoulomb            = 1.0
rvdw                = 1.0
DispCorr            = EnerPres
coulombtype         = PME
pme_order           = 4
fourierspacing      = 0.16
tcoupl              = V-rescale
tc-grps             = Protein Non-Protein
tau_t               = 0.1 0.1
ref_t               = 300 300
pcoupl              = no
pbc                 = xyz
EOF

gmx grompp \
    -f nvt.mdp \
    -c em.gro \
    -r em.gro \
    -p topol.top \
    -o nvt.tpr

gmx mdrun \
    -deffnm nvt \
    -gpu_id 0 \
    -ntmpi 1 \
    -ntomp 8 \
    -nb gpu \
    -bonded gpu \
    -pme gpu \
    -update gpu
```

***

## Schritt 8 — NPT-Equilibrierung (Druck)

```bash
cat > npt.mdp << 'EOF'
; NPT-Equilibrierung
define              = -DPOSRES
integrator          = md
nsteps              = 50000
dt                  = 0.002
nstxout             = 500
nstvout             = 500
nstenergy           = 500
nstlog              = 500
continuation        = yes
constraint_algorithm = lincs
constraints         = h-bonds
cutoff-scheme       = Verlet
ns_type             = grid
nstlist             = 10
rcoulomb            = 1.0
rvdw                = 1.0
DispCorr            = EnerPres
coulombtype         = PME
tcoupl              = V-rescale
tc-grps             = Protein Non-Protein
tau_t               = 0.1 0.1
ref_t               = 300 300
pcoupl              = Parrinello-Rahman
pcoupltype          = isotropic
tau_p               = 2.0
ref_p               = 1.0
compressibility     = 4.5e-5
refcoord_scaling    = com
pbc                 = xyz
EOF

gmx grompp \
    -f npt.mdp \
    -c nvt.gro \
    -r nvt.gro \
    -t nvt.cpt \
    -p topol.top \
    -o npt.tpr

gmx mdrun \
    -deffnm npt \
    -gpu_id 0 \
    -ntmpi 1 \
    -ntomp 8 \
    -nb gpu \
    -bonded gpu \
    -pme gpu \
    -update gpu
```

***

## Schritt 9 — Produktions-MD-Lauf

```bash
cat > md.mdp << 'EOF'
; Produktions-MD-Lauf
integrator          = md
nsteps              = 5000000      ; 10 ns (2 fs Zeitschritt)
dt                  = 0.002
nstxout-compressed  = 5000        ; Koordinaten alle 10 ps speichern
nstenergy           = 5000
nstlog              = 5000
continuation        = yes
constraint_algorithm = lincs
constraints         = h-bonds
cutoff-scheme       = Verlet
ns_type             = grid
nstlist             = 10
rcoulomb            = 1.0
rvdw                = 1.0
DispCorr            = EnerPres
coulombtype         = PME
tcoupl              = V-rescale
tc-grps             = Protein Non-Protein
tau_t               = 0.1 0.1
ref_t               = 300 300
pcoupl              = Parrinello-Rahman
pcoupltype          = isotropic
tau_p               = 2.0
ref_p               = 1.0
compressibility     = 4.5e-5
pbc                 = xyz
EOF

gmx grompp \
    -f md.mdp \
    -c npt.gro \
    -t npt.cpt \
    -p topol.top \
    -o md.tpr

# Produktionslauf mit vollständigem GPU-Offload
gmx mdrun \
    -deffnm md \
    -gpu_id 0 \
    -ntmpi 1 \
    -ntomp 16 \
    -nb gpu \
    -bonded gpu \
    -pme gpu \
    -update gpu \
    -v
```

{% hint style="info" %}
**Fortschritt in Echtzeit überwachen:**

```bash
tail -f md.log | grep -E "(ns/day|Step|Time)"
```

{% endhint %}

***

## Schritt 10 — Analyse

### Grundlegende Trajektorienanalyse

```bash
# RMSD (Stabilität des Rückgrats über die Zeit)
gmx rms \
    -s md.tpr \
    -f md.xtc \
    -o rmsd.xvg \
    -tu ns
# Wähle 4 (Backbone) sowohl für Referenz- als auch für Anpassungsgruppen

# RMSF (Residuum-spezifische Flexibilität)
gmx rmsf \
    -s md.tpr \
    -f md.xtc \
    -o rmsf.xvg \
    -res
# Wähle 4 (Backbone)

# Radius der Gyration (Kompaktheit)
gmx gyrate \
    -s md.tpr \
    -f md.xtc \
    -o gyrate.xvg
# Wähle 1 (Protein)

# Wasserstoffbrücken
gmx hbond \
    -s md.tpr \
    -f md.xtc \
    -num hbonds.xvg
# Wähle 1 (Protein) sowohl für Donor als auch Akzeptor
```

### XVG-Dateien plotten

```python
import numpy as np
import matplotlib.pyplot as plt

# RMSD-Daten laden
data = np.loadtxt('rmsd.xvg', comments=['@', '#'])
time = data[:, 0]      # in ns
rmsd = data[:, 1] * 10 # konvertiere nm in Ångström

plt.figure(figsize=(10, 4))
plt.plot(time, rmsd)
plt.xlabel('Time (ns)')
plt.ylabel('RMSD (Å)')
plt.title('Backbone RMSD')
plt.grid(True, alpha=0.3)
plt.savefig('rmsd_plot.png', dpi=150, bbox_inches='tight')
```

### Ergebnisse übertragen

```bash
# Von Ihrer lokalen Maschine:
rsync -avz -e "ssh -p <ssh-port>" \
    root@<server-ip>:/workspace/lysozyme/ \
    ./md_results/
```

***

## Multi-GPU-Simulationen

Für sehr große Systeme verwende mehrere GPUs mit Domain-Decomposition:

```bash
# 4-GPU-Lauf (passe -ntmpi an die GPU-Anzahl an)
gmx mdrun \
    -deffnm md \
    -gpu_id 0123 \
    -ntmpi 4 \
    -ntomp 4 \
    -nb gpu \
    -bonded gpu \
    -pme gpu \
    -npme 1 \
    -update gpu \
    -v
```

{% hint style="warning" %}
**Multi-GPU-Effizienz:** Skalierung über 4 GPUs hinaus ist normalerweise nur für Systeme >1 Million Atome vorteilhaft. Für kleinere Systeme ist eine einzelne High-End-GPU auf Clore.ai kosteneffizienter.
{% endhint %}

***

## Fehlerbehebung

### Fataler Fehler: Kein GPU-Offload

```bash
# Prüfen, ob CUDA funktioniert
nvidia-smi
python3 -c "import ctypes; ctypes.CDLL('libcuda.so')"

# Für Tests CPU-Fallback erzwingen
gmx mdrun -deffnm md -ntmpi 1 -ntomp 16
```

### System explodiert / Negative Volumina

Das deutet normalerweise auf ein Problem bei der Energie-Minimierung hin:

```bash
# Längere Minimierung mit kleinerer Schrittgröße ausführen
# Em.mdp bearbeiten: emstep = 0.001, emtol = 100
```

### Langsame Leistung

```bash
# GPU-Auslastung während des Laufs prüfen
watch -n 1 nvidia-smi

# GPU-Offload-Einstellungen optimieren
gmx mdrun -deffnm md -nb gpu -pme gpu -bonded gpu -update gpu \
    -ntmpi 1 -ntomp $(nproc)
```

***

## Gängige Kraftfelder

| Kraftfeld        | Am besten für                  |
| ---------------- | ------------------------------ |
| `amber99sb-ildn` | Proteine, allgemeiner Gebrauch |
| `charmm36m`      | Proteine + Lipidmembranen      |
| `gromos54a7`     | Wirkstoffähnliche Moleküle     |
| `oplsaa`         | Organische Moleküle, Lipide    |

***

## Kostenabschätzung

| Simulation     | Systemgröße | GPU      | Zeit     | Kosten  |
| -------------- | ----------- | -------- | -------- | ------- |
| 10 ns Protein  | 25K Atome   | RTX 3090 | \~2h     | \~$0.60 |
| 100 ns Protein | 25K Atome   | A100 40G | \~6h     | \~$4.50 |
| 100 ns Membran | 200K Atome  | A100 80G | \~12h    | \~$9    |
| 1 μs Protein   | 25K Atome   | A100 80G | \~3 Tage | \~$55   |

***

## Weitere Ressourcen

* [GROMACS-Dokumentation](https://manual.gromacs.org/)
* [GROMACS-Tutorials (Justin Lemkul)](http://www.mdtutorials.com/gmx/)
* [NVIDIA HPC GROMACS-Container](https://catalog.ngc.nvidia.com/orgs/hpc/containers/gromacs)
* [GROMACS GitHub](https://github.com/gromacs/gromacs)
* [Amber-Kraftfeld-Parameter](https://ambermd.org/)
* [CHARMM-GUI Membran-Builder](https://www.charmm-gui.org/)

***

*Das Ausführen von GROMACS auf Clore.ai ermöglicht Forschenden den Zugriff auf A100- und RTX 4090-GPUs zu einem Bruchteil der Preise von AWS oder Azure — wodurch lange MD-Simulationen für akademische Labore und einzelne Forschende wirtschaftlich machbar werden.*

***

## Clore.ai GPU-Empfehlungen

| Anwendungsfall              | Empfohlene GPU  | Geschätzte Kosten auf Clore.ai |
| --------------------------- | --------------- | ------------------------------ |
| Entwicklung/Tests           | RTX 3090 (24GB) | \~$0.12/gpu/hr                 |
| Standard-MD-Simulationen    | RTX 4090 (24GB) | \~$0.70/gpu/hr                 |
| Große Systeme / Lange Läufe | A100 80GB       | \~$1.20/gpu/hr                 |

> 💡 Alle Beispiele in diesem Leitfaden können bereitgestellt werden auf [Clore.ai](https://clore.ai/marketplace) GPU-Servern. Durchsuchen Sie verfügbare GPUs und mieten Sie stundenweise — keine Verpflichtungen, voller Root-Zugriff.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-de/wissenschaft-and-forschung/gromacs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
