Configuration & Parameters

GeoDynamo.jl follows a grid → model → simulation setup style. Build a SphericalShellGrid or SphericalBallGrid, pass it to GeodynamoModel with physical and boundary-condition keywords, then advance a Simulation.

GPU Backend

The current :gpu backend is an explicit single-device solver path:

  • dense GPU field containers hold scalar, vector, nonlinear-history, and implicit-solve arrays on the selected architecture
  • scalar transforms, Stage-2 solenoidal vector transforms, spectral curls, nonlinear projections, CNAB2 right-hand sides, batched radial solves, and the gpu_run! stepping loop have GPU-path implementations
  • the CUDA extension routes SHTnsKit scalar and vector transforms to CUDA when the arrays and SHTnsKit configuration are device-backed
  • each solver runtime owns a TransformWorkspace; on GPU-marked runtimes its scratch allocations can be sourced from the backend-provided scratch_zeros hook
  • with_gpu_backend(...) can temporarily install alternate backend implementations for tests or experimental integrations and restores the previous backend automatically afterward
  • full parity with the production CPU SolverState path is still guarded by broken tests while the remaining solver-integration differences are closed
  • conducting inner-core magnetic coupling is not yet wired into build_gpu_solver_state; insulating magnetic cases are the supported solver-state path

To use :gpu, load CUDA before creating the solver state:

using GeoDynamo
using CUDA

grid = SphericalShellGrid(GPU(); nr = 64, lmax = 31)
model = GeodynamoModel(grid; include_magnetic = true)
simulation = Simulation(model; Δt = 1e-5, stop_time = 0.02)

If CUDA is not installed or no functional device is available, backend creation fails explicitly instead of silently downgrading to CPU.

GeoDynamo.SphericalShellGridType
SphericalShellGrid(arch=CPU(); lmax, nr, mmax=lmax, nlat=3lmax÷2,
                   nlon=2nlat, nr_inner=max(2, nr÷4),
                   r_inner=0.35, r_outer=1.0)

Spherical shell geometry: fluid contained between two concentric spheres (r_inner < r < r_outer), like Earth's outer core. This is the grid passed to GeodynamoModel.

Arguments

  • arch: compute architecture, CPU() or GPU (positional or arch=).
  • lmax: maximum spherical-harmonic degree (required).
  • nr: number of radial points (required).
  • mmax: maximum order (defaults to lmax).
  • nlat, nlon: latitude/longitude grid sizes (defaults follow the transform's anti-aliasing rule).
  • nr_inner: radial points resolving the inner-core region.
  • r_inner, r_outer: dimensionless shell radii (0 < r_inner < r_outer).

Example

grid = SphericalShellGrid(lmax = 31, nr = 64)
source
GeoDynamo.SphericalBallGridType
SphericalBallGrid(arch=CPU(); lmax, nr, mmax=lmax, nlat=3lmax÷2, nlon=2nlat)

Full-sphere geometry: fluid filling a ball (0 ≤ r ≤ 1) with no inner boundary, like a stellar core or early planetary interior. This is the grid passed to GeodynamoModel.

Arguments

  • arch: compute architecture, CPU() or GPU (positional or arch=).
  • lmax: maximum spherical-harmonic degree (required).
  • nr: number of radial points (required).
  • mmax: maximum order (defaults to lmax).
  • nlat, nlon: latitude/longitude grid sizes (defaults follow the transform's anti-aliasing rule).

Unlike SphericalShellGrid there is no r_inner/nr_inner; regularity at the origin is enforced by the ball solver.

Example

grid = SphericalBallGrid(lmax = 31, nr = 48)
source
GeoDynamo.GeodynamoModelType
GeodynamoModel(grid; T=Float64, Ek=1e-4, Pr=1.0, Pm=1.0, Sc=1.0, Ra=1e6,
               velocity_bcs, temperature_bcs, composition_bcs,
               boundary_conditions=nothing,
               include_magnetic=false, include_composition=false,
               initial_conditions=nothing, kwargs...)

Physical model built on a SphericalShellGrid or SphericalBallGrid. It bundles the solver state, the grid, and a Clock, and is the object handed to a Simulation.

Arguments

  • grid: a SphericalShellGrid or SphericalBallGrid.
  • T: floating-point element type (Float64 by default).
  • Ek, Pr, Pm, Sc, Ra: Ekman, Prandtl, magnetic-Prandtl, Schmidt, and Rayleigh numbers.
  • velocity_bcs, temperature_bcs, composition_bcs: per-field inner/outer BoundaryConditions (convenience kwargs, aliases for the NamedTuple form).
  • boundary_conditions: Oceananigans-style NamedTuple of BCs, e.g. (temperature = FieldBoundaryConditions(inner=…, outer=…),). Keys must be a subset of (:velocity, :temperature, :composition). Passing the same field through both boundary_conditions and a per-field kwarg is an error.
  • include_magnetic, include_composition: enable the magnetic / compositional equations.
  • initial_conditions: initial-condition spec, or nothing to start from rest.

Topography- and Stefan-coupling keywords (topography_enabled, topography_epsilon, stefan_enabled, …) are also accepted; see the configuration guide.

Example

grid  = SphericalShellGrid(lmax = 31, nr = 64)
model = GeodynamoModel(grid; Ra = 1e6, include_magnetic = true)
# Oceananigans-style boundary conditions:
t_bcs = FieldBoundaryConditions(inner = ValueBoundaryCondition(1.0),
                                outer = ValueBoundaryCondition(0.0))
model = GeodynamoModel(grid; Ra = 1e6, boundary_conditions = (temperature = t_bcs,))
source
GeoDynamo.SimulationType
mutable struct Simulation{M,C,O}

Holds a GeodynamoModel together with time-stepping controls, callbacks, and output writers. Create with Simulation(model; Δt, ...) and advance with run!(sim).

source

Quick Reference

Essential Parameters

For most simulations, you'll primarily configure:

  • Geometry: SphericalShellGrid, SphericalBallGrid, nr, nr_inner, lmax, mmax, nlat, nlon
  • Physics: Ek, Ra, Pr, Pm
  • Time: Simulation(model; Δt, stop_time, stop_iteration)
  • Boundaries: BoundaryConditions(inner=..., outer=...)

Geometry & Resolution

Grid Parameters

ParameterTypeDescription
geometrySymbol:shell or :ball — determines boundary conditions and initialization
nrIntRadial grid points (applies to outer-core and inner-core grids)
lmaxIntMaximum spherical harmonic degree
mmaxIntMaximum spherical harmonic order (defaults to lmax)
nlatIntPhysical θ grid resolution
nlonIntPhysical φ grid resolution
radial_bandwidthIntRadial finite-difference bandwidth (stencil width)
Resolution Guidelines
  • Choose lmax ≈ nr for balanced spectral/radial workload
  • SHTnsKit requires nlat ≥ lmax + 2 and nlon ≥ 2*lmax + 1
  • If nlat/nlon are incompatible, SHTnsKit will override them

SHTnsKit Transform Options

These flags control SHTnsKit v1.1.15 optimizations (set in transforms/spectral.jl):

FlagDefaultEffect
SHTNSKIT_USE_DISTRIBUTEDtrueUse native MPI-distributed transforms
SHTNSKIT_USE_QSTtrueUse full QST decomposition for 3D vectors
SHTNSKIT_USE_SCRATCH_BUFFERStruePre-allocate transform buffers

Check feature availability at runtime:

info = get_shtnskit_version_info()
println("Version: ", info.version)
println("QST transforms: ", info.has_qst_transforms)
println("Energy functions: ", info.has_energy_functions)

See Spherical Harmonics for the complete transform API.


Physical Parameters

Dimensionless Numbers

ParameterSymbolDescription
radius_ratioInner-to-outer radius ratio (shell geometry)
RaRaThermal Rayleigh number
RaCRa_CCompositional Rayleigh number
EkEEkman number
PrPrPrandtl number
PmPmMagnetic Prandtl number
ScScSchmidt number

Magnetic Field Control

ParameterTypeDescription
include_magneticBoolEnable magnetic field evolution
impose_magnetic_fieldBoolEnable imposed background magnetic field

Time Integration

Choose a timestepper object in the Simulation constructor:

simulation = Simulation(model; Δt = 1e-5, timestepper = CNAB2())
ObjectDescription
CNAB2()Crank-Nicolson Adams-Bashforth 2; production default
CNAB2(theta = 0.6)CNAB2 with extra implicit damping
ExponentialAdamsBashforth2(krylov_dimension = 20, tolerance = 1e-8)Exponential Adams-Bashforth 2 for stiff diffusion
ExponentialRungeKutta2()Explicit second-order Runge-Kutta path
ETD(krylov_dimension = 20, tolerance = 1e-8)Exponential time differencing path
ThetaMethod(theta = 0.5)Direct theta-method configuration
Scheme Selection
SchemeBest For
CNAB2Production dynamo runs, moderate timesteps
ExponentialAdamsBashforth2Strongly diffusive regimes (low E, Pm)
ExponentialRungeKutta2Wave propagation, accuracy-critical applications

See Time Integration for detailed scheme documentation.


Boundary Conditions

For complete documentation of all boundary condition types and their physical interpretation, see the dedicated Boundary Conditions page.

Quick Reference

Model keywordFieldOptions
velocity_bcsVelocityBoundaryConditions(inner = NoSlip(), outer = StressFree())
temperature_bcsTemperatureFixedTemperature(value) or FixedFlux(value) at each boundary
composition_bcsCompositionFixedTemperature(value) or FixedFlux(value) at each boundary

Summary of BC Types

FieldAvailable Options
VelocityNo-slip (T=0, ∂P/∂r=0), Stress-free (∂T/∂r=T/r, ∂²P/∂r²=0)
MagneticInsulating (default, automatic); Conducting inner core via magnetic_inner_bc=:conducting_inner_core (shell + CNAB2; equal σ, no inner-core rotation). Perfect conductor not yet implemented.
TemperatureFixed temperature (Dirichlet), Fixed flux (Neumann)
CompositionFixed composition (Dirichlet), Fixed flux (Neumann)
Neumann-Neumann Special Case

When both boundaries use flux (Neumann) conditions for temperature or composition, the l=0 mode automatically uses Dirichlet at the inner boundary to pin the mean value.

Loading Custom Boundaries

using GeoDynamo

grid = SphericalShellGrid(nr = 64, lmax = 31)
model = GeodynamoModel(grid)
simulation = Simulation(model; Δt = 1e-5, stop_time = 0.02)
state = simulation.model.state

GeoDynamo.bcs.load_boundary_conditions!(state.temperature, GeoDynamo.TEMPERATURE, Dict(
    :inner => (:uniform, 1.0),
    :outer => (:dirichlet, 0.0),
))

GeoDynamo.bcs.load_boundary_conditions!(state.composition, GeoDynamo.COMPOSITION, Dict(
    :inner => (:neumann, 0.0),
    :outer => (:dirichlet, 0.0),
))

Use this helper for programmatic scalar boundaries after the simulation state is created. File-based scalar BC workflows should use the lower-level NetCDF and spectral BC utilities directly.


Boundary Topography

For non-spherical boundaries, these parameters control topography coupling. See Boundary Topography for full theory.

Master Controls

ParameterTypeDefaultDescription
topography_enabledBoolfalseMaster switch for topography coupling
topography_epsilonFloat640.01Topography amplitude parameter ε
topography_degreeInt-1Max spherical harmonic degree (-1 = auto)

Field-Specific Switches

ParameterTypeDefaultDescription
include_topography_velocityBooltrueEnable velocity BC corrections
include_topography_magneticBooltrueEnable magnetic BC corrections
include_topography_thermalBooltrueEnable thermal BC corrections
include_topography_slope_termsBooltrueInclude ∇h slope coupling terms
include_topography_shift_termsBooltrueInclude h shift terms

Stefan Condition (Phase Change)

ParameterTypeDefaultDescription
stefan_enabledBoolfalseEnable Stefan condition for ICB evolution
stefan_numberFloat641.0Stefan number St = c_p ΔT / L

Topography Data Files

ParameterTypeDescription
icb_topography_fileStringPath to ICB topography NetCDF file
ocb_topography_fileStringPath to CMB topography NetCDF file

Example Configuration

Via constructor:

grid = SphericalShellGrid(nr = 64, lmax = 31)
model = GeodynamoModel(
    grid;
    topography_enabled = true,
    topography_epsilon = 0.01,
    include_topography_velocity = true,
    include_topography_magnetic = true,
    ocb_topography_file = "config/cmb_topography.nc",
)
simulation = Simulation(model; Δt = 1e-5, stop_time = 0.02)

At runtime:

enable_topography!(epsilon = 0.02, velocity = true, magnetic = true)

Initial Conditions & Restarts

The InitialConditions module provides high-level setup helpers:

Available Functions

Public APIPurpose
set!(model; field = value)Apply initial conditions after constructing a model
initial_conditions = (...)Apply initial conditions during GeodynamoModel construction
RandomPerturbation(amplitude, lmax, seed)Spectral random perturbations for scalar and vector fields
AnalyticIC(pattern; ...)Named deterministic patterns such as :conductive, :dipole, and :convective
FileIC(path)Load a compatible initial-condition file
ZeroIC()Explicit zero initial condition

Typical Setup

grid = SphericalShellGrid(nr = 64, lmax = 31)
model = GeodynamoModel(grid;
    include_magnetic = true,
    initial_conditions = (
        temperature = AnalyticIC(:conductive),
        velocity = RandomPerturbation(amplitude = 1e-4, lmax = 8),
        magnetic = AnalyticIC(:dipole; amplitude = 1.0),
    ),
)

set!(model; temperature = (r, θ, φ) -> (1 - r) + 1e-3 * sin(θ))
simulation = Simulation(model; Δt = 1e-5, stop_time = 0.02)

Restarts

For reproducible continuation runs:

# Recommended: schedule checkpoints on the simulation.
checkpoint = CheckpointWriter("output"; schedule = TimeInterval(0.5))
simulation = Simulation(model; Δt = 1e-5, stop_time = 1.0,
                        output_writers = (checkpoint,))
run!(simulation)

# Resume later from the restart directory. This is collective and should be
# called under MPI after MPI.Init().
simulation = Simulation(model; Δt = 1e-5, stop_time = 2.0,
                        restart_from = "output")
run!(simulation)

Output Configuration

ParameterTypeDescription
output_precisionSymbol:float32 or :float64 for NetCDF data
output_intervalFloat64Output cadence in simulation time; prefer explicit FieldWriter schedules for new runs
Parallel I/O

All ranks write concurrently to a single shared NetCDF file via parallel HDF5 (MPI-IO). The independent_output_files parameter is deprecated and ignored.

Storage Optimization

Use output_precision = :float32 to halve disk usage. Diagnostics remain in Float64 where accuracy is required.

See Data Output & Restart Files for complete I/O configuration.


Managing Parameters

Creating and Setting

# Create with specific values
grid = SphericalShellGrid(nr = 96, lmax = 47)
model = GeodynamoModel(
    grid;
    Ek = 3e-5,
    Pr = 1.0,
    Pm = 1.0,
    Sc = 1.0,
    Ra = 1e6,
)

simulation = Simulation(model; Δt = 1e-5, stop_time = 0.02)

Saving and Loading

Put the grid, model, and simulation construction in a Julia script such as config/run_highres.jl, then run that script directly or under MPI.

Note

Configuration files under config/ are plain Julia scripts. Prefer storing the high-level grid/model/simulation construction rather than separate parameter constants.


Next Steps

GoalResource
Understand boundary condition physicsBoundary Conditions
Understand time integration schemesTime Integration
Configure output and restartsData Output & Restart Files
Non-spherical boundary couplingBoundary Topography
Contribute to developmentDeveloper Guide