| name | laps |
| description | Self-contained guide to LAPS (Large Plasma Simulation) โ a 3D MPI-parallelized pseudo-spectral Hall-MHD Fortran code by Dr. Chen Shi. For agents and humans who want to run MHD simulations: install LAPS, configure parameters, write initial conditions, launch MPI runs, and analyze output. Progressive disclosure โ start here for routing, drill into reference/ for depth.
|
| version | 6.0.0 |
| tags | ["physics","fortran","mpi","mhd","plasma","simulation","alfven","hall-mhd","pseudo-spectral"] |
LAPS โ Complete Guide
LAPS = UCLA Pseudo-Spectral Hall-MHD code
Author: Dr. Chen Shi (cshi1993@ucla.edu)
GitHub: https://github.com/chenshihelio/LAPS
Papers: Shi et al. 2020, ApJ 888:68 ยท Shi et al. 2024, Frontiers 11:1412905
What LAPS does: Simulates magnetohydrodynamic (MHD) phenomena โ Alfvรฉn wave collisions, solar wind dynamics, plasma turbulence โ using incompressible or compressible Hall-MHD, parallelized with MPI, solved via Fourier pseudo-spectral methods on a 3D periodic grid.
Who this skill is for: Agents and researchers who want to understand, run, configure, and analyze LAPS simulations โ even if they are new to MHD codes.
Quick Decision Tree
"What do I need?"
โ
โโ ๐ First time โ what is LAPS and how do I set it up?
โ โโ Read: reference/getting-started.md
โ (prerequisites, install, compile, first run โ step by step)
โ
โโ ๐ I want to run a simulation
โ โโ How to configure mhd.input (the parameter file)
โ โ โโ Read: reference/input-parameters.md
โ โ (every parameter explained with physics context)
โ โโ How to write custom initial conditions
โ โโ Read: reference/initial-conditions.md
โ (background fields, perturbations, the uu array)
โ
โโ ๐ฌ I want to understand how LAPS works internally
โ โโ Code architecture โ what each file does
โ โ โโ Read: reference/architecture.md
โ โโ Numerical methods โ pseudo-spectral, RK, dealiasing
โ โ โโ Read: reference/architecture.md ยง "Numerical Methods"
โ โโ How div B = 0 is maintained (spectral constraint)
โ โโ Read: reference/architecture.md ยง "Divergence-Free Constraint"
โ
โโ ๐ I have output โ how do I analyze it?
โ โโ Read: reference/output-and-analysis.md
โ (rms.dat format, snapshots, Python readers, plots)
โ
โโ โฌ๏ธ I want to improve accuracy (SSPRK4 upgrade)
โ โโ Read: reference/ssprk4-upgrade.md
โ (coefficients, file-by-file changes, verification)
โ
โโ ๐ Something went wrong
โ โโ Read: reference/debugging.md
โ (segfaults, blow-ups, divergence, slow runs)
โ
โโ ๐ What is the research context?
โโ Read: reference/research-context.md
(manuscript status, referee feedback, open threads)
What's Inside LAPS
LAPS/
โโโ src_incompressible/ โ 3D incompressible Hall-MHD (main version)
โ โโโ mhd.f90 โ Main driver: time loop, I/O, MPI init
โ โโโ mhdinit.f90 โ YOU EDIT THIS: initial conditions
โ โโโ mhdrhs.f90 โ Right-hand side (forces, advection)
โ โโโ rktmod.f90 โ Runge-Kutta time integration coefficients
โ โโโ mhdoutput.f90 โ Snapshot output
โ โโโ mhdrms.f90 โ Energy & divergence diagnostics
โ โโโ parallel.f90 โ MPI domain decomposition
โ โโโ fftw.f90 โ FFT wrapper (FFTW3)
โ โโโ dealiasing.f90 โ Lanczos filtering (anti-aliasing)
โ โโโ AEBmod.f90 โ Expanding box model (optional)
โ โโโ restart.f90 โ Checkpoint/restart
โ โโโ makefile โ Build system
โ โโโ mhd.input โ Parameter file (Fortran namelist)
โ
โโโ src_compressible/ โ 3D compressible version
โโโ src_incompressible/2D/ โ 2D incompressible version
โโโ data_process/ โ Data processing utilities
โโโ README.md โ Original README
โโโ LICENSE.txt โ GPL v3
For most users: You only need src_incompressible/. The compressible version is a separate codebase with its own physics.
Critical Rules
- NEVER modify Fortran code without human approval. State the proposed change, explain why, and wait.
- Report before long simulations. State expected runtime and resource needs.
- If LAPS source is missing:
git clone https://github.com/chenshihelio/LAPS
- When in doubt, grep first โ search the source before asking questions.
Quick Start (5 commands)
git clone https://github.com/chenshihelio/LAPS
brew install fftw open-mpi
cd LAPS/src_incompressible
make clean && make
mpirun -np 4 mhd.exe > rec &
tail -f rms.dat
โ Full walkthrough in reference/getting-started.md
Standard Test Baseline
Verify your build is correct with these settings (default mhd.input):
| Parameter | Value | Where |
|---|
| Grid | 32ยณ | &grid nx/ny/nz |
| Box size | 5.0 | &grid Lx/Ly/Lz |
| Perturbation | ipert=7, db0=dv0=0.05 | &pert |
| Filter factor | af=0.495 | &numerical afx/afy/afz |
| End time | 5.0 | &genr tmax |
Expected at t=5:
- Kinetic energy: ~0.0111 (from initial ~0.0123, โ -10.2%)
- Magnetic energy: ~0.0117 (from initial ~0.0125, โ -6.3%)
- div B: ~3ร10โปยนโด (excellent)
- div V: ~0.05 (normal)
Reference Documents
| Document | What's inside | Lines |
|---|
reference/getting-started.md | Step-by-step: prerequisites โ install โ compile โ first run โ understand output | ~150 |
reference/input-parameters.md | Every mhd.input parameter with physics meaning, defaults, and tips | ~250 |
reference/initial-conditions.md | How to write custom ICs: the uu array, background fields, perturbations | ~200 |
reference/architecture.md | Code internals: all 11 .f90 files, numerical methods, Helmholtz, parallelization | ~250 |
reference/output-and-analysis.md | Output formats, rms.dat, snapshots, Python readers, publication plots | ~200 |
reference/ssprk4-upgrade.md | SSPRK4 implementation: coefficients, file changes, verification protocol | ~150 |
reference/debugging.md | 7 common failures, diagnostic thresholds, recovery procedures | ~200 |
reference/research-context.md | Manuscript status, referee feedback, open research threads | ~80 |