Differential Equations in iTensor
Solve ODEs and PDEs with both symbolic and numerical methods for physics applications
Overview
Differential equations are essential in physics, describing how systems evolve in space and time. iTensor implements both symbolic and numerical solvers specifically optimized for tensor-based equations.
Unlike general-purpose ODE/PDE solvers, iTensor preserves tensor structure throughout the solution process, maintaining covariance and tracking index positions automatically.
The differential equation module connects directly to the symbolic tensor engine, allowing you to derive equations symbolically and then solve them numerically without manual conversion between representations.
ODE Solvers
iTensor implements specialized ODE solvers that maintain tensor properties:
Implemented Methods
RK4
- Classic 4th-order Runge-Kutta with fixed step sizeRK45
- Adaptive step-size control using error estimationImplicitEuler
- For stiff equations with stability guaranteesVerlet
- Symplectic integrator preserving energy in Hamiltonian systems
Example: Harmonic Oscillator
Performance Note
For systems with many equations or stiff problems, use the compiled C++ backend by setting use_compiled=True
in the solve method. This can accelerate computation by 10-50x.
Example: Coupled Predator-Prey System
PDE Solvers
iTensor's PDE solvers handle multi-dimensional problems across several types of equations:
Elliptic PDEs
Poisson and Laplace equations for equilibrium problems:
Application: Electrostatic potentials, gravitational fields
Parabolic PDEs
Diffusion and heat equations:
Application: Heat transfer, diffusion processes
Hyperbolic PDEs
Wave equations describing propagation:
Application: Electromagnetic waves, sound propagation
Numerical Methods
- Finite Difference - Implemented for regular grids with customizable stencils
- Spectral Methods - For high-accuracy solutions with periodic boundaries
- Finite Element - For complex geometries (requires mesh definition)
Example: 2D Heat Equation
Tensor Differential Equations
One of iTensor's unique features is solving differential equations where the unknown quantities are tensors, not just scalar fields.
Einstein Field Equations
Solve for the metric tensor components given a stress-energy tensor:
Maxwell's Equations in Tensor Form
Solve for the electromagnetic field tensor Fμν:
Working with Results
Solution objects from iTensor's differential equation solvers provide analysis methods:
- Data Extraction:t_values, u_values = solution.get_data('u')
- Visualization:solution.plot_field('u', time_index=50) # Specific time slice
- Animation:animation = solution.animate(component='u', fps=30)
- Data Export:solution.save('simulation_results.h5') # HDF5 format
- Derived Quantities:energy = solution.compute_total_energy()
Common Applications
Particle Trajectories in Curved Spacetime
Solve the geodesic equation to simulate how particles and light move near black holes.
Accretion Disk Simulation
Model fluid dynamics around compact objects using relativistic hydrodynamics equations.