Numerical Tensor Computation
High-performance tensor calculations for general relativity and astrophysical simulations
Overview
The numerical tensor module operates on concrete tensor values for specific coordinate points, enabling scientific computation, visualization, and simulation. While the symbolic module handles exact algebra, the numerical module specializes in computational efficiency and large-scale tensor field calculations.
Core Capabilities
- Discretized Tensor Fields: Compute metric tensors and derived quantities over coordinate grids
- Numerical Integration: Solve geodesic equations with adaptive step-size Runge-Kutta methods
- Tensor Field Visualization: Calculate tensor invariants and projections for rendering
- Hardware Acceleration: Leverage multi-core CPUs or CUDA-enabled GPUs for performance
- Large-Scale Simulations: Process astrophysical models with efficient memory management
Creating Numerical Tensor Fields
Numerical tensors in iTensor represent tensor fields sampled at specific coordinate points. There are several ways to create these:
Method 1: From Functions
Method 2: From Symbolic to Numerical
Method 3: From Direct Component Specification
Computing Derived Tensors
Much like the symbolic module, the numerical module can compute derived tensors from the metric tensor. The key difference is that these operations are optimized for numerical performance rather than symbolic manipulation.
Performance Considerations
For large grids, derived tensor calculations can be computationally intensive. The numerical module provides several optimizations:
- Parallel computation across multiple CPU cores using
n_jobs=-1
parameter - GPU acceleration through
use_gpu=True
(requires CUDA support) - Simplified tensor expressions using
approximation='first_order'
for perturbation theory - Memory-mapped arrays for very large grids via
memory_efficient=True
Solving Geodesic Equations
A major application of numerical tensor calculations is solving geodesic equations to trace the paths of particles and light rays in curved spacetime.
Geodesic Types
- Null Geodesics: Light rays (ds² = 0)
- Timelike Geodesics: Massive particles (ds² < 0)
- Spacelike Geodesics: Not physically realized but mathematically valid (ds² lt& 0)
Integration Methods
- RK45: Adaptive Runge-Kutta, good general-purpose solver
- DOP853: Higher-order method for high-precision requirements
- Verlet: Symplectic integrator for long-term stability
- LSODA: Automatically switches between stiff/non-stiff methods
Advanced Topic: Custom Numerical Tensors
For specialized research, you may need to define your own tensor fields with custom behavior. iTensor allows this by subclassing the base NumericalTensor class.
GPU Acceleration
For large-scale tensor field calculations, iTensor provides GPU acceleration using CUDA. This is especially valuable for:
- Computing curvature tensors on high-resolution grids
- Numerically solving Einstein's field equations
- Batch processing of many geodesics simultaneously
- Visualization of complex tensor fields
GPU Requirements
GPU acceleration requires:
- NVIDIA GPU with compute capability 3.5+
- CUDA Toolkit 11.0+ installed
- CuPy package (
pip install cupy-cuda11x
where x matches your CUDA version) - Installing iTensor with GPU support:
pip install itensorpy[cuda]