SHTnsKit.jl
SHTnsKit.jl
High-Performance Spherical Harmonic Transforms for Julia
CPU | GPU | MPI Distributed | Auto-Differentiation
Features
Core Transforms
- Forward & backward spherical harmonic transforms
- Scalar, vector, and complex field support
- In-place operations for memory efficiency
GPU Acceleration
- CUDA/cuFFT for NVIDIA GPUs
- KernelAbstractions.jl backend
- Automatic CPU fallback
MPI Distributed
- PencilArrays domain decomposition
- Scalable to thousands of cores
- Efficient communication patterns
Analysis Tools
- Power spectrum analysis
- Energy diagnostics
- Wigner D-matrix rotations
Quick Start
Installation
using Pkg
# Basic installation
Pkg.add("SHTnsKit")
# With GPU support
Pkg.add(["SHTnsKit", "CUDA", "KernelAbstractions"])
# With MPI support
Pkg.add(["SHTnsKit", "MPI", "PencilArrays", "PencilFFTs"])Hello World
using SHTnsKit
# Create configuration for lmax=16
cfg = create_gauss_config(16, 18)
# Create a test pattern on the sphere
spatial = zeros(cfg.nlat, cfg.nlon)
for i in 1:cfg.nlat
x = cfg.x[i] # cos(θ)
spatial[i, :] .= (3*x^2 - 1)/2 # Y_2^0 pattern
end
# Transform: spatial → spectral → spatial
Alm = analysis(cfg, spatial)
recovered = synthesis(cfg, Alm)
# Verify roundtrip accuracy
println("Error: ", maximum(abs.(spatial - recovered))) # ~1e-14For large problems (lmax > 64), use GPU acceleration with gpu_analysis() and gpu_synthesis() for significant speedup.
GPU Example
using SHTnsKit, CUDA
cfg = create_gauss_config(128, 130)
spatial = rand(cfg.nlat, cfg.nlon)
# GPU-accelerated transforms
Alm = gpu_analysis(cfg, spatial)
recovered = gpu_synthesis(cfg, Alm)
# Safe version with automatic CPU fallback
Alm_safe = gpu_analysis_safe(cfg, spatial)Scientific Applications
Atmospheric dynamics, weather prediction, ocean circulation
Gravitational fields, magnetic anomalies, Earth surface modeling
CMB analysis, stellar dynamics, gravitational waves
Vorticity-divergence decomposition, turbulence on spheres
Documentation
Get started in minutes
CUDA acceleration
MPI parallelization
Complete documentation
- Quick Start Guide
- GPU Acceleration
- Distributed Computing
- API Reference
- Examples Gallery
- Performance Guide
- Advanced Usage Patterns
Installation Options
| Setup | Command | Use Case |
|---|---|---|
| Basic | Pkg.add("SHTnsKit") | Single CPU, getting started |
| GPU | + CUDA, KernelAbstractions | NVIDIA GPU acceleration |
| MPI | + MPI, PencilArrays, PencilFFTs | Cluster computing |
| Full | All of the above | Maximum flexibility |
- Julia 1.10 or later
- For GPU: NVIDIA GPU with CUDA support
- For MPI: OpenMPI or MPICH installed
Contributing
We welcome contributions! See our GitHub repository for:
- Bug reports and feature requests
- Documentation improvements
- Pull requests
Citation
If you use SHTnsKit.jl in your research, please cite:
@software{shtnskit,
author = {Kar, Subhajit},
title = {SHTnsKit.jl: High-Performance Spherical Harmonic Transforms},
url = {https://github.com/subhk/SHTnsKit.jl},
year = {2024}
}License
SHTnsKit.jl is released under the GNU General Public License v3.0.
Made for the scientific computing community