-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolver.py
More file actions
59 lines (46 loc) · 1.73 KB
/
solver.py
File metadata and controls
59 lines (46 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
"""
Basic RK4 solver implementation for warp metric validation.
This is a simplified version for testing purposes.
"""
import numpy as np
def integrate_step(X, dt):
"""
Performs one RK4 time step on the state vector X.
For this validation implementation, we use a simple placeholder
that preserves the input (since we're testing with static profiles
like Minkowski and Schwarzschild).
Args:
X: State vector (numpy array)
dt: Time step size
Returns:
Updated state vector after one RK4 step
"""
# For validation purposes with static analytical solutions,
# the time derivative should be zero, so X remains unchanged
# This is correct for Minkowski (always zero) and Schwarzschild
# (static metric, no time evolution)
# Simple RK4 implementation with zero derivatives
k1 = np.zeros_like(X) # dX/dt = 0 for static metrics
k2 = np.zeros_like(X)
k3 = np.zeros_like(X)
k4 = np.zeros_like(X)
# RK4 update formula
X_new = X + (dt/6.0) * (k1 + 2*k2 + 2*k3 + k4)
return X_new
def compute_rhs(X, t=0.0):
"""
Compute the right-hand side of the differential equation dX/dt = F(X,t).
For static metrics (Minkowski, Schwarzschild), this should return zero.
"""
return np.zeros_like(X)
# Additional utility functions that might be needed
def setup_grid(r_min, r_max, N):
"""Create a radial grid."""
return np.linspace(r_min, r_max, N)
def initial_conditions_minkowski(grid):
"""Initial conditions for Minkowski metric."""
return np.zeros_like(grid)
def initial_conditions_schwarzschild(grid, M=1.0):
"""Initial conditions for Schwarzschild metric."""
return 2 * M / grid