Overview
Dedalus provides three bases for spherical coordinate problems:- SphereBasis: For problems on the surface of a sphere (θ, φ)
- ShellBasis: For problems in a spherical shell (φ, θ, r ∈ [R_i, R_o])
- BallBasis: For problems inside a full sphere/ball (φ, θ, r ∈ [0, R])
Shallow Water on Sphere
File:examples/ivp_sphere_shallow_water/shallow_water.py
Description
Simulates the viscous shallow water equations on a rotating sphere, implementing the classic test case of a barotropically unstable mid-latitude jet from Galewsky et al. (2004). This example demonstrates:- Solving an LBVP for balanced initial conditions
- Time-evolving an IVP on the sphere
- Including rotation (Coriolis force)
- Using dimensional units
Physical Setup
- Geometry: Full sphere (Earth)
- Resolution: (N_φ, N_θ) = (256, 128)
- Initial condition: Zonal jet at mid-latitudes
- Parameters:
- Radius: 6.37×10⁶ m
- Rotation: Ω = 7.29×10⁻⁵ s⁻¹
- Gravity: g = 9.81 m/s²
- Mean height: H = 10⁴ m
Setting Up the Geometry
Initial Conditions: Balanced Jet
First, set up a zonal jet:Governing Equations
Running the Example
Expected Results
- Runtime: ~5 cpu-minutes
- Physics: Mid-latitude jet becomes unstable, forming Rossby wave patterns
- Output: Height and vorticity fields on the sphere
Shell Convection
File:examples/ivp_shell_convection/shell_convection.py
Description
Simulates Boussinesq convection in a spherical shell—the geometry relevant to planetary mantles and stellar convection zones. This example demonstrates the full 3D spherical shell geometry with radial boundary conditions.Physical Setup
- Geometry: Spherical shell with R_i = 14, R_o = 15 (thin shell)
- Resolution: (N_φ, N_θ, N_r) = (192, 96, 6)
- Boundary conditions: Fixed temperatures, no-slip walls
- Parameters: Ra = 3500, Pr = 1
- Non-dimensionalization: Shell thickness and freefall time
Setting Up the Shell
Radial Direction
Define radial unit vector and position vector:First-Order Formulation
Boundary Conditions
Initial Conditions
Running the Example
Expected Results
- Runtime: ~20 cpu-minutes
- Physics: Convective plumes form and rise/fall in the shell
- Output: Temperature slices at various radii and longitudes
Ball Internally Heated Convection
File:examples/ivp_ball_internally_heated_convection/internally_heated_convection.py
Description
Simulates internally-heated Boussinesq convection inside a full sphere (ball). The gravity is proportional to radius (constant density). Features stress-free boundary conditions and demonstrates restart capability.Physical Setup
- Geometry: Full ball with radius = 1
- Resolution: (N_φ, N_θ, N_r) = (128, 64, 96)
- Boundary conditions: Stress-free, constant flux
- Parameters: Ra = 10⁶, Pr = 1
- Heating: Volumetric internal heating (T_source = 6)
- Equilibrium: Conductive state T(r) = 1 - r²
Setting Up the Ball
Stress-Free Boundary Conditions
Internal Heating
Restart Capability
Running the Example
Expected Results
- Runtime: ~30 cpu-minutes per segment
- Physics: Convective plumes rise from interior to boundary
- Output: Temperature slices at various radii and longitudes
Lane-Emden Equation
File:examples/nlbvp_ball_lane_emden/lane_emden.py
Description
Solves the Lane-Emden equation—a nonlinear boundary value problem describing polytropic stellar structure. This example demonstrates:- Nonlinear boundary value problems (NLBVP)
- Newton iteration
- Spherically symmetric problems (1D in ball)
- Convergence to reference solutions
Mathematical Problem
The Lane-Emden equation in rescaled form:Setting Up the NLBVP
Initial Guess
Newton Iteration
Running the Example
Expected Results
- Runtime: A few seconds
- Convergence: Typically ~10-12 Newton iterations
- Output:
- Convergence information printed to console
- Plot showing Newton iteration progress
lane_emden.png - For n = 3: R ≈ 6.8968 (matches reference to high precision)
Reference Solutions
The example includes reference values from Boyd (2011) for validation:Spherical Coordinate Tips
Surface Operators
Radial Operations
Spherically Symmetric Problems
For 1D (spherically symmetric) problems, use shape(1, 1, Nr):