Tarang.jl
Tarang.jl
A High-Performance Spectral PDE Solver for Julia
CPU | GPU | MPI Distributed | Symbolic Equations
Features
Spectral Methods
- Fourier, Chebyshev, and Legendre bases
- Spectral accuracy for smooth solutions
- Automatic differentiation operators
GPU Acceleration
- Native CUDA support with cuFFT
- KernelAbstractions.jl backend
- Automatic CPU/GPU dispatch
MPI Parallelization
- PencilArrays pencil decomposition
- Scalable to thousands of cores
- Efficient distributed FFTs
Symbolic Equations
- Natural mathematical syntax for PDEs
- Automatic operator construction
- Flexible boundary conditions
Quick Start
Installation
using Pkg
# Basic installation
Pkg.add(url="https://github.com/subhk/Tarang.jl")
# With GPU support
Pkg.add(["CUDA", "KernelAbstractions"])
# With MPI support
Pkg.add(["MPI", "PencilArrays", "PencilFFTs"])1D Diffusion
using Tarang
domain = PeriodicDomain(64) # 64-point periodic [0, 2π]
T = ScalarField(domain, "T") # Temperature field
problem = IVP([T])
add_parameters!(problem, kappa=0.01)
add_equation!(problem, "∂t(T) - kappa*Δ(T) = 0")
solver = InitialValueSolver(problem, RK222(); dt=0.01)
run!(solver; stop_time=1.0) # That's it!2D Rayleigh-Benard Convection
using Tarang
# Channel domain: periodic in x (Fourier), bounded in z (Chebyshev)
domain = ChannelDomain(256, 64; Lx=4.0, Lz=1.0)
u = VectorField(domain, "u") # Velocity
T = ScalarField(domain, "T") # Temperature
p = ScalarField(domain, "p") # Pressure
problem = IVP([u, p, T])
add_parameters!(problem, Pr=1.0, Ra=2e6)
add_equation!(problem, "∂t(u) - Pr*Δ(u) + ∇(p) - Ra*Pr*T*ez = -u⋅∇(u)")
add_equation!(problem, "div(u) = 0")
add_equation!(problem, "∂t(T) - Δ(T) = -u⋅∇(T)")
add_bc!(problem, "u(z=0) = 0")
add_bc!(problem, "u(z=1) = 0")
add_bc!(problem, "T(z=0) = 1")
add_bc!(problem, "T(z=1) = 0")
solver = InitialValueSolver(problem, RK222(); dt=1e-3)
diagnose(solver) # Print solver summary
run!(solver; stop_time=10.0, log_interval=100) # Run with progressUse diagnose(solver) at any time to inspect field layout, compiled RHS status, dealiasing mode, and memory usage.
GPU Example
using Tarang, CUDA
# Just add device=GPU() — everything else stays the same
domain = PeriodicDomain(512, 512; device=GPU(), dtype=Float32)
field = ScalarField(domain, "u")
forward_transform!(field) # Uses cuFFT automaticallyScientific Applications
Navier-Stokes, Rayleigh-Benard convection, channel flow, jets
LES models (Smagorinsky, AMD), stochastic forcing, GQL approximation
MHD with magnetic fields, dynamo problems, magnetic dissipation
Rotating shallow water, stratified turbulence, surface dynamics
Problem Types
| Type | Description | Example |
|---|---|---|
| IVP | Initial Value Problems | Time-dependent Navier-Stokes |
| BVP | Boundary Value Problems | Steady-state solutions |
| EVP | Eigenvalue Problems | Linear stability analysis |
| LBVP | Linear BVPs | Poisson equation |
| NLBVP | Nonlinear BVPs | Steady nonlinear systems |
Spectral Bases
| Basis | Domain | Usage |
|---|---|---|
RealFourier | Periodic | Horizontal directions, real-valued fields |
ComplexFourier | Periodic | Complex-valued fields |
ChebyshevT | Bounded | Wall-bounded domains, boundary conditions |
Legendre | Bounded | Alternative to Chebyshev |
Documentation
Setup and configuration
Step-by-step guides
CUDA acceleration
Complete documentation
Installation Options
| Setup | Command | Use Case |
|---|---|---|
| Basic | Pkg.add(url="...") | 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 Tarang.jl in your research, please cite:
@software{tarang_jl,
author = {Kar, Subhajit},
title = {Tarang.jl: A Spectral PDE Solver for Julia},
url = {https://github.com/subhk/Tarang.jl},
year = {2024}
}License
Tarang.jl is released under the MIT License.
Made for the scientific computing community