iTensor System Architecture
Technical overview of the computational stack that powers symbolic and numerical tensor calculations
Core Components
iTensor consists of three principal components arranged in a layered architecture. Each layer is designed for a specific class of tensor operations required in general relativity and differential geometry.
Primary System Components
- Symbolic Engine (Python): SymPy-based tensor algebra system for exact, analytical calculations with full step-by-step derivations
- Numerical Library (Python/C++): Optimized tensor array operations built on NumPy with C++ extensions for high-performance calculations
- C++ Visualization Core: CUDA-accelerated raytracing engine for relativistic optics in curved spacetime
- Python API Layer: Unified interface exposing all capabilities with automatically generated documentation
- Optional Web Interface: Lightweight access for users without local installation
Computational Flow Diagram
The diagram below illustrates how a typical computation flows through the system layers:
┌────────────────────────────┐ ┌────────────────────────────────┐ │ │ │ │ │ User Input (Metric Tensor) │──┬──►│ Symbolic Processing │ │ │ │ │ (Algebraic calculations) │ └────────────────────────────┘ │ │ │ │ └───────────────┬────────────────┘ │ │ │ ▼ │ ┌────────────────────────────────┐ │ │ │ └──►│ Numerical Processing │ │ (Concrete value computation) │ │ │ └───────────────┬────────────────┘ │ ┌───────────────────────┐ │ │ │ │ │ Visualization Engine │◄────────┘ │ │ └───────────────────────┘
Symbolic Engine Architecture
The symbolic engine handles all exact tensor operations for derivation and mathematical proof. It forms the foundation of iTensor's ability to manipulate expressions containing variables like coordinates or metric parameters.
Technical Implementation
- Core Class: SymbolicTensor class with support for rank-N tensors in arbitrary coordinates
- Symbolic Framework: Built on SymPy with custom tensor simplification algorithms
- Coordinate Handling: Representation of covariant and contravariant indices with automatic handling of metric contractions
- Tensor Algebra: Implementation of key operations:
- Tensor addition, multiplication, and contraction
- Covariant differentiation with metric connection
- Lie derivatives and parallel transport
- Algebraic tensor symmetry operations
- Physics Functionality: Specialized objects for common tensors:
- Metric, connection, and curvature tensors
- Maxwell tensor and stress-energy tensors
- Killing vectors and geodesic equations
Numerical Engine Architecture
The numerical engine processes tensor calculations with concrete numerical values, enabling simulation, visualization, and practical application of tensor physics.
Implementation Features
Array Storage
Multi-dimensional NumPy arrays with index mapping optimized for sparse tensors. Efficient memory layout for both dense and sparse tensors with configurable precision (32/64-bit).
Computational Optimizations
Vectorized operations with SIMD parallelism, OpenMP thread parallelism for grid calculations, and BLAS/LAPACK acceleration for linear algebra operations.
C++ Extensions
Critical path calculations implemented in C++ with Python bindings for tensor contractions, einsum operations, and integration of tensor ODEs/PDEs.
GPU Acceleration
Optional CUDA kernels for large tensor calculations and field evaluations across spacetime grids, with automatic fallback to CPU implementation when CUDA is unavailable.
Differential Geometry Module
The differential geometry module implements computational methods for:
- Automatic calculation of connection coefficients (Christoffel symbols) from metric tensors
- Parallel transport along curves with configurable integration methods
- Geodesic equation solvers with adaptive step size control
- Calculation of curvature invariants (scalar curvature, Kretschmann scalar)
- Evaluation of Einstein tensor for non-vacuum spacetimes
- Tetrad-based calculations for observer-dependent quantities
Visualization Core
The visualization core is a specialized C++ engine for ray-tracing in curved spacetime. It numerically solves the geodesic equation for light rays to generate physically accurate renderings of black holes and other relativistic objects.
Technical Components
Ray Tracing System
- High-precision geodesic integration using adaptive Runge-Kutta methods
- Parallelized ray casting with configurable camera models
- Physically correct rendering of:
- Gravitational lensing of background stars
- Relativistic Doppler and gravitational redshift effects
- Accretion disk dynamics with thermal emission model
- Realistic light transport with polarization effects
- Support for various black hole metrics:
- Schwarzschild (non-rotating)
- Kerr (rotating)
- Reissner-Nordström (charged)
- Kerr-Newman (rotating and charged)
API Design
The Python API unifies all system components into a coherent interface with consistent method naming and parameter conventions.
API Design Principles
- Type Consistency: All tensor objects follow the same interface regardless of whether they are symbolic or numerical
- Physics-First Naming: Methods and parameters named according to standard physics notation rather than programming conventions
- Chainable Operations: Tensor methods return new tensor objects allowing method chaining
- Comprehensive Error Messages: Physics-specific error messages that explain not just what went wrong but why it fails mathematically
- Performance Transparency: Clear indication of computational complexity for operations on large tensors
Extensibility
iTensor is designed for extensibility in several key areas:
Custom Metrics
Define your own metric tensors either through direct component specification or as perturbations of known solutions. All tensor operations will automatically work with custom metrics.
Coordinate Systems
Implement additional coordinate systems beyond the built-in spherical, cylindrical, and cartesian systems. The framework automatically handles coordinate transformations and tensor component mapping.
Field Equations
Add custom field equation solvers for modified gravity theories or alternative formulations of general relativity. The solver architecture supports arbitrary tensor differential equations.
Visualization Plugins
Extend the visualization system with custom renderers for specialized physics or alternative rendering techniques, with hooks provided for custom shader inclusion.
For detailed information on extending iTensor, see the Extension Guide which covers plugin architecture and the relevant APIs.