GeoDynamo.jl

High-performance spherical-MHD solver for geodynamo and planetary-core simulations

Julia License


New to GeoDynamo.jl?

Get up and running in minutes with our Getting Started guide.


What is GeoDynamo.jl?

GeoDynamo.jl is a modern Julia package for simulating magnetohydrodynamic (MHD) flows in rapidly rotating planetary interiors. It couples:

  • Spectral spherical-harmonic transforms via SHTnsKit
  • Domain-decomposed finite differences via PencilArrays
  • Scalable MPI parallelism for multi-node simulations
using GeoDynamo

# Configure and run a simulation
params = GeoDynamoParameters(geometry=:shell, i_N=64, i_L=31, d_E=1e-4, d_Ra=1e6)
set_parameters!(params)
state = initialize_simulation(Float64)
run_simulation!(state; t_end=0.1)

Highlights

End-to-End MHD Pipeline

Temperature, composition, velocity, and magnetic fields evolved in a single tightly coupled solver.

Hybrid Spectral-Radial Discretization

SHTnsKit for fast spherical harmonics + pencil-decomposed finite differences for radial terms.

Multiple Time Integrators

CNAB2 IMEX, exponential AB2 (EAB2), and exponential RK2 (ERK2) with Krylov-based operators.

Scalable MPI I/O

Per-rank checkpoint/output with selectable precision (Float32/Float64) and NetCDF metadata.

Boundary Topography

Linearized non-spherical CMB/ICB boundaries with Gaunt tensor mode coupling.


Architecture

┌─────────────────────────────────────────────────────────────────────────┐
│                          GeoDynamo.jl                                   │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                         │
│   ┌───────────────┐   ┌───────────────┐   ┌───────────────┐            │
│   │    Fields     │   │  Parameters   │   │    Pencil     │            │
│   │  & Transforms │   │  & Config     │   │ Decomposition │            │
│   └───────┬───────┘   └───────┬───────┘   └───────┬───────┘            │
│           │                   │                   │                     │
│           └───────────────────┼───────────────────┘                     │
│                               ▼                                         │
│   ┌─────────────────────────────────────────────────────────┐          │
│   │                   Physics Kernels                        │          │
│   │  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────────┐   │          │
│   │  │Velocity │ │Magnetic │ │ Thermal │ │Compositional│   │          │
│   │  └─────────┘ └─────────┘ └─────────┘ └─────────────┘   │          │
│   └─────────────────────────────────────────────────────────┘          │
│                               │                                         │
│                               ▼                                         │
│   ┌─────────────────────────────────────────────────────────┐          │
│   │              Time Integration (CNAB2/EAB2/ERK2)          │          │
│   └─────────────────────────────────────────────────────────┘          │
│                               │                                         │
│                               ▼                                         │
│   ┌─────────────────────────────────────────────────────────┐          │
│   │                  NetCDF Output & Restart                 │          │
│   └─────────────────────────────────────────────────────────┘          │
│                                                                         │
└─────────────────────────────────────────────────────────────────────────┘

Core Modules

Infrastructure

ModuleDescription
fields.jlPencilArray-backed spectral and physical fields
parameters.jlGeoDynamoParameters configuration management
pencil_decomps.jlMPI domain decomposition via PencilArrays
linear_algebra.jlBanded matrix operations for radial derivatives

SHTnsKit Integration

ModuleDescription
shtnskit_transforms.jlGrid setup, FFT plans, transpose operators
shtnskit_field_functions.jlTransforms, energy spectra, rotations

Physics

ModuleDescription
velocity.jlToroidal-poloidal velocity evolution
magnetic.jlMagnetic field induction and diffusion
thermal.jlTemperature advection-diffusion
compositional.jlComposition advection-diffusion

Boundary Conditions

ModuleDescription
bcs/Modular BC system (thermal, velocity, magnetic, composition)
bcs/topography/Non-spherical CMB/ICB with Gaunt tensors

Dependencies

GeoDynamo.jl builds on a robust stack of Julia packages:

                    ┌─────────────────┐
                    │   GeoDynamo.jl  │
                    └────────┬────────┘
                             │
        ┌────────────────────┼────────────────────┐
        │                    │                    │
        ▼                    ▼                    ▼
┌───────────────┐   ┌───────────────┐   ┌───────────────┐
│   SHTnsKit    │   │ PencilArrays  │   │    MPI.jl     │
│  (Harmonics)  │   │(Decomposition)│   │  (Parallel)   │
└───────────────┘   └───────────────┘   └───────────────┘
                             │
                             ▼
                    ┌───────────────┐
                    │   NetCDF.jl   │
                    │     (I/O)     │
                    └───────────────┘
Automatic Installation

All dependencies are pulled in automatically via the package manifest. You only need a working MPI implementation and NetCDF C libraries at runtime.


Governing Equations

┌─────────────────────────────────────────────────────────────────────┐
│                                                                     │
│   ∂u/∂t  =  viscous diffusion  +  buoyancy  +  Lorentz force       │
│                     ↓                 ↓              ↓              │
│                   E∇²u            Ra·T·r̂        (∇×B)×B            │
│                                                                     │
│   ∂T/∂t  =  thermal diffusion  -  advection                        │
│                     ↓                  ↓                            │
│                (Pm/Pr)∇²T            u·∇T                           │
│                                                                     │
│   ∂B/∂t  =  magnetic diffusion  +  induction                       │
│                     ↓                  ↓                            │
│                   ∇²B              ∇×(u×B)                          │
│                                                                     │
│   Constraints:      ∇·u = 0           ∇·B = 0                      │
│                                                                     │
└─────────────────────────────────────────────────────────────────────┘

The solver advances the nondimensional Boussinesq MHD system from Sreenivasan & Kar, Phys. Rev. Fluids 3, 093801 (2018).

Momentum

\[\frac{E}{\mathrm{Pm}}\frac{\partial \boldsymbol{u}}{\partial t} + (\nabla \times \boldsymbol{u}) \times \boldsymbol{u} + \hat{\boldsymbol{z}} \times \boldsymbol{u} = -\nabla p^\star + \frac{\mathrm{Pm}}{\mathrm{Pr}}\,\mathrm{Ra}\,T\,\boldsymbol{r} + (\nabla \times \boldsymbol{B}) \times \boldsymbol{B} + E \nabla^2 \boldsymbol{u}\]

Temperature & Magnetic Field

\[\frac{\partial T}{\partial t} + \boldsymbol{u} \cdot \nabla T = \frac{\mathrm{Pm}}{\mathrm{Pr}} \nabla^2 T\]

\[\frac{\partial \boldsymbol{B}}{\partial t} = \nabla \times (\boldsymbol{u} \times \boldsymbol{B}) + \nabla^2 \boldsymbol{B}\]

Constraints

\[\nabla \cdot \boldsymbol{u} = 0 \qquad \nabla \cdot \boldsymbol{B} = 0\]

Toroidal-Poloidal Decomposition

Both velocity and magnetic fields use toroidal-poloidal decomposition, which spectrally enforces the divergence-free constraints.


Documentation

PageDescription
Getting StartedInstallation and first simulation
ConfigurationAll parameter options explained
Boundary ConditionsVelocity, magnetic, thermal, and compositional BCs
Time IntegrationCNAB2, EAB2, ERK2 schemes
Spherical HarmonicsSHTnsKit transforms and operators
Boundary TopographyNon-spherical boundary coupling
Data OutputNetCDF files, restarts, diagnostics
Developer GuideContributing and code structure
API ReferenceComplete function documentation

Compatibility

EnvironmentVersionsStatus
Julia1.10, 1.11Supported
LinuxOpenMPI, MPICHTested in CI
macOSMPICH (Homebrew)Tested in CI
WindowsMicrosoft MPITested in CI

Citation

If GeoDynamo.jl supports your research, please cite:

@software{geodynamo_jl,
  author = {Kar, Subhajit},
  title  = {GeoDynamo.jl: Spherical-MHD Solver for Planetary Cores},
  url    = {https://github.com/subhk/GeoDynamo.jl},
  year   = {2024}
}

Get Involved

Community feedback via GitHub Issues and PRs is the fastest way to expand physics modules and add diagnostic hooks!