Skip to content

Generates finite-difference spatial‐derivative stencils and Taylor-series error-order expansions from the closed-form warp-bubble expressions in final_expressions.tex, and outputs a ready-to-compile LaTeX file discretization.tex

Notifications You must be signed in to change notification settings

arcticoder/warp-discretization

Repository files navigation

Warp Bubble Discretization

Python SymPy LaTeX

Automated finite-difference stencil generation for warp bubble spacetime discretization

This repository provides computational tools to generate finite-difference stencils and truncation-error expansions for spatial derivatives in warp-bubble spacetime expressions, enabling numerical simulation of exotic spacetime geometries.

Key Features

  • Finite-Difference Stencils: Automated generation of central difference formulas (2nd, 4th, 6th order)
  • Error Analysis: Complete Taylor-series truncation error characterization
  • LaTeX Output: Publication-ready discretization documentation
  • SymPy Integration: Symbolic mathematics for exact coefficient computation
  • Pipeline Ready: Integrates seamlessly with upstream warp-bubble repositories

Mathematical Framework

The tool processes closed-form warp-bubble expressions to generate numerical discretization schemes:

Input: Analytic Expressions

  • Metric Components: g_μν(x) from warp-bubble geometry
  • Curvature Invariants: R, R_μν R^μν, Riemann tensor components
  • Stress-Energy Tensor: T_μν(x) exotic matter distributions
  • Source: final_expressions.tex from upstream pipeline

Output: Discretization Schemes

  • Spatial Derivative Stencils: Central finite-difference formulas for ∇_i, ∇_i∇_j operators
  • Error Order Expansions: Complete O(h²), O(h⁴), O(h⁶) truncation analysis
  • Coefficient Tables: Exact symbolic coefficients for each stencil point
  • LaTeX Documentation: Ready-to-compile discretization.tex with all formulas

Supported Orders

  • 2nd Order: O(h²) accuracy, 3-point stencils
  • 4th Order: O(h⁴) accuracy, 5-point stencils
  • 6th Order: O(h⁶) accuracy, 7-point stencils
  • Custom: User-configurable stencil orders and grid arrangements

Installation & Setup

Prerequisites

# Core dependencies
pip install sympy>=1.9 numpy scipy matplotlib

# LaTeX distribution (for output compilation)
# Ubuntu/Debian: sudo apt-get install texlive-full
# macOS: brew install mactex
# Windows: Install MiKTeX or TeX Live

Repository Setup

git clone https://github.com/arcticoder/warp-discretization.git
cd warp-discretization
pip install -r requirements.txt

Usage Guide

Basic Stencil Generation

# Generate all discretization stencils
python scripts/generate_stencils.py --input final_expressions.tex --output discretization.tex

# Specify stencil order
python scripts/generate_stencils.py --input final_expressions.tex --output discretization.tex --order 4

# Generate with error analysis
python scripts/generate_stencils.py --input final_expressions.tex --output discretization.tex --error-analysis

Advanced Options

# Custom grid spacing
python scripts/generate_stencils.py --input final_expressions.tex --spacing-symbol "Delta_x"

# Export individual stencils
python scripts/generate_stencils.py --input final_expressions.tex --export-individual --output-dir stencils/

# Generate validation code
python scripts/generate_stencils.py --input final_expressions.tex --generate-tests

Output Structure

discretization.tex          # Main LaTeX document with all stencils
stencils/                   # Individual stencil files (optional)
├── first_derivatives.tex   # ∂/∂x, ∂/∂y, ∂/∂z stencils
├── second_derivatives.tex  # ∂²/∂x², ∂²/∂y², ∂²/∂z² stencils
├── mixed_derivatives.tex   # ∂²/∂x∂y, etc. stencils
└── error_analysis.tex      # Truncation error bounds

🔗 Pipeline Integration

This repository is part of the comprehensive warp-bubble simulation pipeline:

Upstream Dependencies

Downstream Applications

Data Flow

Analytic Expressions → Finite-Difference Stencils → Time Integration → Validation

🧪 Validation & Testing

Automated Tests

# Run all validation tests
python -m pytest tests/ -v

# Test stencil accuracy
python tests/test_stencil_accuracy.py

# Validate error bounds
python tests/test_error_analysis.py

Benchmarking

# Compare with analytical derivatives
python scripts/benchmark_accuracy.py

# Performance profiling
python scripts/profile_generation.py

📖 Mathematical Details

Finite-Difference Formulas

For a scalar field f(x), the nth-order central difference approximation:

f'(x) ≈ (1/h) Σ c_i f(x + ih)    [2nd order: c = [-1/2, 0, 1/2]]
f''(x) ≈ (1/h²) Σ c_i f(x + ih)   [2nd order: c = [1, -2, 1]]

Error Analysis

Truncation error bounds for each stencil:

|Error| ≤ (h^p/p!) max|f^(p)(ξ)|    where p = order + 1

Grid Considerations

  • Uniform spacing: h = constant throughout domain
  • Boundary handling: One-sided and modified stencils near boundaries
  • Stability analysis: CFL conditions for time-stepping schemes

Applications

  • Numerical Relativity: Spacetime evolution simulations
  • Warp Drive Research: Exotic matter field dynamics
  • Computational Physics: General PDE discretization
  • Algorithm Development: Finite-difference method validation

Contributing

Contributions welcome! Areas of interest:

  • Higher-order stencil implementations
  • Adaptive grid refinement support
  • GPU acceleration for large-scale problems
  • Integration with finite element methods

References

  1. Finite Difference Methods: LeVeque, R. J., "Finite Difference Methods for ODEs and PDEs"
  2. Numerical Relativity: Baumgarte & Shapiro, "Numerical Relativity: Solving Einstein's Equations on the Computer"
  3. Warp Drive Physics: Alcubierre, M., Phys. Rev. D 53, 3571 (1994)

About

Generates finite-difference spatial‐derivative stencils and Taylor-series error-order expansions from the closed-form warp-bubble expressions in final_expressions.tex, and outputs a ready-to-compile LaTeX file discretization.tex

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published