Skip to content

anjor/gandalf-paper

Repository files navigation

GANDALF Paper: An AI-Assisted Scientific Research Demonstration

Testing the Intelligence Explosion: Can AI turn one physicist into a research team?

This repository contains a complete scientific paper and verification study demonstrating AI-assisted research at scale. Both the GANDALF code and this paper were primarily written by AI, guided by domain expertise.

πŸ“– Read the full story: Testing the Intelligence Explosion: Can AI Turn One Physicist Into a Research Team?

πŸ“„ Read the paper: GANDALF_paper.pdf (pre-compiled, ready to view)


The Experiment

This project tests whether AI can produce research-grade scientific work, not just toy examples. The deliverables include:

  • A production code: GANDALF - 2,000+ lines of JAX implementing spectral KRMHD solver
  • This paper: ~1,000 lines of LaTeX for Journal of Plasma Physics submission
  • Rigorous verification: Three benchmark suites demonstrating spectral accuracy
  • Publication-quality figures: 12 figures generated from numerical experiments
  • Automated quality control: GitHub Actions with Claude-based review workflows

What's AI-Generated?

Nearly everything:

  • Complete JAX codebase (spectral methods, time integration, parallelization)
  • All paper sections (introduction through conclusions)
  • Mathematical formulation and LaTeX equations
  • Benchmark analysis and figure generation
  • Documentation and workflow automation

Human contributions:

  • Scientific direction and physics expertise
  • Verification criteria and benchmark selection
  • Quality review and refinement
  • Connection to existing research literature

The Science

GANDALF: GPU-Accelerated Numeric Dynamics of AlfvΓ©nic Turbulence

GANDALF is a modern reimplementation of Kinetic Reduced MHD (KRMHD) turbulence physics using JAX. It enables plasma turbulence research on commodity hardware (laptops, desktops, Apple Silicon) without requiring HPC clusters.

Key Features:

  • Fourier spectral discretization in perpendicular plane
  • Hermite spectral expansion in parallel velocity
  • GANDALF integrating factor time stepping (exact linear propagation)
  • Transparent CPU/GPU/TPU execution via JAX
  • Research-grade accuracy with ~2-3Γ— performance trade-off vs CUDA codes

Physical Regime:

  • Strong guide field: kβ€– β‰ͺ kβŠ₯
  • AlfvΓ©nic turbulence and phase mixing
  • Solar wind, magnetospheric, and fusion plasma applications

Verification Benchmarks

This paper demonstrates three levels of validation:

  1. Linear: Alfvén wave dispersion relations (machine precision: ~10⁻¹⁡ error)
  2. Nonlinear: Orszag-Tang vortex evolution (10⁻⁢ energy conservation)
  3. Turbulent: Forced cascade with kβŠ₯⁻⁡/Β³ spectrum over 200 AlfvΓ©n times
  4. Velocity Space: Phase mixing cascade with m⁻¹/² scaling

Each benchmark includes convergence studies and comparison with analytical/theoretical predictions.


Repository Structure

gandalf-paper/
β”œβ”€β”€ paper/
β”‚   β”œβ”€β”€ main.tex                    # Master LaTeX document
β”‚   β”œβ”€β”€ sections/
β”‚   β”‚   β”œβ”€β”€ introduction.tex        # Physics motivation
β”‚   β”‚   β”œβ”€β”€ formulation.tex         # KRMHD equations
β”‚   β”‚   β”œβ”€β”€ numerics.tex            # Spectral methods
β”‚   β”‚   β”œβ”€β”€ implementation.tex      # JAX architecture
β”‚   β”‚   β”œβ”€β”€ verification.tex        # Benchmark results
β”‚   β”‚   β”œβ”€β”€ discussion.tex          # Interpretation and ecosystem positioning
β”‚   β”‚   └── conclusions.tex         # Impact and future work
β”‚   β”œβ”€β”€ figures/                    # Publication-quality figures (12 PDFs/PNGs)
β”‚   β”œβ”€β”€ references.bib              # Bibliography
β”‚   β”œβ”€β”€ notation.tex                # Mathematical notation definitions
β”‚   └── main.pdf                    # Compiled paper
β”œβ”€β”€ data/
β”‚   └── benchmarks/                 # Raw benchmark data
β”‚       β”œβ”€β”€ alfven_wave/
β”‚       β”œβ”€β”€ orszag_tang/
β”‚       └── turbulent_cascade/
β”œβ”€β”€ scripts/                        # Python analysis and plotting scripts
β”œβ”€β”€ .github/workflows/              # Automated quality control
β”‚   β”œβ”€β”€ claude-code-review.yml      # Claude-based code review
β”‚   β”œβ”€β”€ notation-check.yml          # Notation consistency checks
β”‚   └── paper-review.yml            # Paper quality checks
└── CLAUDE.md                       # Detailed project guidelines

Building the Paper

Quick start: A pre-compiled PDF is available at the root: GANDALF_paper.pdf

To rebuild from source:

Prerequisites

# LaTeX distribution (TeX Live, MacTeX, or MiKTeX)
# Required packages: amsmath, amssymb, graphicx, hyperref, cleveref

# Python environment for regenerating figures
pip install jax numpy scipy matplotlib h5py

Compile the Paper

cd paper/
make                # Compiles main.tex β†’ main.pdf
make clean          # Removes auxiliary files

Or manually:

cd paper/
pdflatex main.tex
bibtex main
pdflatex main.tex
pdflatex main.tex

The compiled PDF will be paper/main.pdf.


Reproducibility

Scientific Reproducibility

All benchmark results can be regenerated from the GANDALF code:

# Clone the GANDALF repository
git clone https://github.com/anjor/gandalf.git
cd gandalf

# Run benchmarks (see GANDALF README for configuration)
python examples/alfven_wave_benchmark.py
python examples/orszag_tang_benchmark.py
python examples/turbulent_cascade_benchmark.py

Raw data is archived in data/benchmarks/ for figure regeneration without re-running simulations.

Workflow Reproducibility

This repository demonstrates an AI-assisted research workflow:

  1. Development: AI generates code/text with human guidance
  2. Verification: Automated tests and benchmark validation
  3. Review: GitHub Actions with Claude-based quality checks
  4. Iteration: PR-based workflow with AI code review
  5. Refinement: Human physicist reviews for correctness and clarity

The .github/workflows/ directory contains automation examples. See CLAUDE.md for detailed guidelines used to direct AI contributions.


Paper Status

  • Submission Target: Journal of Plasma Physics
  • Current Status: Pre-submission (final review in progress)
  • Preprint: Coming soon

Citation

@article{kanekar2025gandalf,
  title={GANDALF: GPU-Accelerated Numeric Dynamics of Alfv\'enic Turbulence with JAX},
  author={Kanekar, Anjor},
  journal={Journal of Plasma Physics},
  year={2025},
  note={In preparation}
}

Related Resources

Key Scientific References

  • Schekochihin et al. (2009) - KRMHD formulation (ApJS 182:310)
  • Numata et al. (2010) - AstroGK gyrokinetic code (JCP 229:9347)
  • Meyrand et al. (2019) - Plasma echo physics (PNAS 116:1185)

Contributing

This paper uses a PR-based workflow with automated quality checks:

  1. Create a feature branch: git checkout -b feature-name
  2. Make changes to paper/sections/*.tex
  3. Submit PR to main branch
  4. Claude-based review runs automatically
  5. Address feedback and merge

See CLAUDE.md for detailed writing guidelines (notation, style, figure formatting).


What This Demonstrates

AI Capabilities

βœ… Can AI produce research-grade work? Yes, with proper guidance.

  • Mathematical rigor: Correct KRMHD formulation with consistent notation
  • Numerical correctness: Spectral methods with verified convergence rates
  • Scientific writing: JPP-standard exposition for expert audience
  • Software engineering: Production-quality JAX implementation

AI Limitations

⚠️ What still requires human expertise:

  • Scientific direction and research questions
  • Physical intuition for interpreting results
  • Connection to broader research context
  • Quality judgment and refinement
  • Ethical oversight and verification

Insights

  1. AI as force multiplier: One physicist can produce the work of a small research team
  2. Iterative refinement essential: Initial AI output requires multiple rounds of review
  3. Domain expertise critical: Guiding AI requires deep understanding of the field
  4. Automation accelerates iteration: GitHub Actions enable rapid feedback cycles
  5. Transparency matters: Clear documentation of AI contributions builds trust

License

This paper and associated materials are available under MIT License. See LICENSE for details.

The GANDALF code is separately licensed (see main repository).


Acknowledgments

This work was made possible by:

  • Claude (Anthropic) for AI assistance in code and paper generation
  • JAX team (Google) for the numerical computing framework
  • Plasma physics community for theoretical foundations

Built on research by Schekochihin, Kunz, Loureiro, Dorland, Barnes, Howes, and many others in the plasma turbulence community.


Questions?

For questions about:

  • The AI experiment: See blog post
  • The physics: Read paper/main.pdf or open an issue
  • The code: Visit github.com/anjor/gandalf
  • Replicating this approach: See CLAUDE.md and .github/workflows/

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •