Integrates geodesic equations using the classical RK4 method.
Integrates geodesic equations using the classical RK4 method.The Christoffel symbols are evaluated once per step from the supplied metric (constant-metric approximation, valid for small step sizes dτ).
GeodesicSolver solver;
GeodesicState init{{0,0,0,0}, {1,0,0,0}};
auto metric = MetricTensor::minkowski();
auto final_state = solver.solve(init, metric, 100, 0.01);
#pragma once
#include <array>
#include <cmath>
#include <optional>
#include "../manifold/spacetime_manifold.hpp"
using manifold::MetricTensor;
struct GeodesicState {
std::array<double, DIM>
x{};
std::array<double, DIM>
u{};
[[nodiscard]]
bool is_finite()
const noexcept;
};
class GeodesicSolver {
public:
[[nodiscard]] std::optional<GeodesicState>
solve(
const GeodesicState& initial,
const MetricTensor& metric,
int steps,
double dt) const noexcept;
};
}
std::optional< GeodesicState > solve(const GeodesicState &initial, const MetricTensor &metric, int steps, double dt) const noexcept
Integrate the geodesic equation for steps RK4 steps.
GeodesicSolver() noexcept=default
constexpr int NUM_CHRISTOFFEL
Total Christoffel symbols: DIM³ = 64.
constexpr int DIM
Number of spacetime dimensions.
constexpr int christoffel_index(int lambda, int mu, int nu) noexcept
Pack (λ, μ, ν) into flat index in [0, 64).
std::array< double, DIM > u
4-velocity u^μ = dx^μ/dτ
bool is_finite() const noexcept
True iff all position and velocity components are finite.
std::array< double, DIM > x
Position x^μ (μ = 0…3)