Skip to content

Commit

Permalink
Update LocalTetrad test to include direction
Browse files Browse the repository at this point in the history
  • Loading branch information
shabibti committed Nov 28, 2023
1 parent eff50f8 commit e0be214
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
29 changes: 27 additions & 2 deletions tests/Unit/PointwiseFunctions/GeneralRelativity/LocalTetrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,21 @@

import numpy as np

def local_tetrad(lapse, shift, spatial_metric, inverse_spatial_metric):
'''
direction: 1 = xi, 2 = eta, 3 = zeta
'''
def local_tetrad(lapse, shift, spatial_metric, inverse_spatial_metric, direction):
if direction == 2 or direction == -2:
permutation = [1, 2, 0]
shift = np.array([shift[i] for i in permutation])
spatial_metric = np.array([[spatial_metric[i][j] for j in permutation] for i in permutation])
inverse_spatial_metric = np.array([[spatial_metric[i][j] for j in permutation] for i in permutation])
elif direction == 3 or direction == -3:
permutation = [2, 0, 1]
shift = np.array([shift[i] for i in permutation])
spatial_metric = np.array([[inverse_spatial_metric[i][j] for j in permutation] for i in permutation])
inverse_spatial_metric = np.array([[inverse_spatial_metric[i][j] for j in permutation] for i in permutation])

#helper variable
D = 1/np.sqrt(spatial_metric[2][2] * (spatial_metric[1][1]*spatial_metric[2][2] - spatial_metric[1][2]*spatial_metric[1][2]))

Expand All @@ -14,7 +28,18 @@ def local_tetrad(lapse, shift, spatial_metric, inverse_spatial_metric):

return M

def inverse_local_tetrad(lapse, shift, spatial_metric, inverse_spatial_metric):
def inverse_local_tetrad(lapse, shift, spatial_metric, inverse_spatial_metric, direction):
if direction == 2 or direction == -2:
permutation = [1, 2, 0]
shift = np.array([shift[i] for i in permutation])
spatial_metric = np.array([[spatial_metric[i][j] for j in permutation] for i in permutation])
inverse_spatial_metric = np.array([[spatial_metric[i][j] for j in permutation] for i in permutation])
elif direction == 3 or direction == -3:
permutation = [2, 0, 1]
shift = np.array([shift[i] for i in permutation])
spatial_metric = np.array([[inverse_spatial_metric[i][j] for j in permutation] for i in permutation])
inverse_spatial_metric = np.array([[inverse_spatial_metric[i][j] for j in permutation] for i in permutation])

#helper variables
B = 1/np.sqrt(lapse**(-4.)*inverse_spatial_metric[0][0])
C = 1/np.sqrt(spatial_metric[2][2])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ void test_local_tetrad_scalar(const DataType& used_for_size) {
const auto python_local_tetrad =
pypp::call<tnsr::Ab<DataType, 3, Frame::Inertial>>(
"LocalTetrad", "local_tetrad", lapse, shift, spatial_metric,
inverse_spatial_metric);
inverse_spatial_metric, 3);
const auto python_inverse_local_tetrad =
pypp::call<tnsr::Ab<DataType, 3, Frame::Inertial>>(
"LocalTetrad", "inverse_local_tetrad", lapse, shift, spatial_metric,
inverse_spatial_metric);
inverse_spatial_metric, 3);
const auto local_tetrad =
gr::local_tetrad(lapse, shift, spatial_metric, inverse_spatial_metric,
Direction<3>::upper_xi());
Direction<3>::upper_zeta());
CHECK_ITERABLE_APPROX(local_tetrad.first, python_local_tetrad);
CHECK_ITERABLE_APPROX(local_tetrad.second, python_inverse_local_tetrad);

Expand Down

0 comments on commit e0be214

Please sign in to comment.