Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
guilara committed Jun 25, 2024
1 parent e9d564c commit 3d24e12
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ void KerrSchild::IntermediateComputer<DataType, Frame>::operator()(
internal_tags::x_minus_center<DataType, Frame> /*meta*/) const {
const auto& x_minus_center = cache->get_var(
*this, internal_tags::x_minus_center_unboosted<DataType, Frame>{});
// Inverse-boost because the coordinates are given in the boosted frame
// Boost the coordinates to the rest frame
sr::lorentz_boost(x_minus_center_boosted, x_minus_center, 0.,
-solution_.boost_velocity());
solution_.boost_velocity());
}

template <typename DataType, typename Frame>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,11 @@ namespace Solutions {
*
* We add initial momentum to the solution by applying a Lorentz boost to the
* metric. Since the Kerr-Schild metric can be expressed covariantly in terms of
* the Minkowski metric, a scalar function and a one form, we constructing the
* metric by boosting the these objects individually. Notice that we also need
* to appropriately boost the coordinates to the boosted frame.
* the Minkowski metric, a scalar function and a one form, we construct the
* metric in the rest frame of the black hole and then apply an inverse boost to
* each of the covariant objects individually. Notice that we also need to
* appropriately boost the coordinates to the to the rest frame before computing
* the metric.
*
* \warning While technically the boosted Kerr-Schild metric is dependent on
* both the time and space coordinates, we have implemented it only at $t = 0$
Expand All @@ -230,7 +232,7 @@ namespace Solutions {
*
* Moreover, since the boosted solution is intended for use as initial data,
* we do not compute the time derivatives of the lapse and shift in the boosted
* frame. We use gauge freedom to set them to zero.
* frame but set them to zero.
*
* Consequently, the gr::Tags::SpacetimeChristoffelSecondKind computed here,
* corresponds to the boosted Kerr-Schild for the gauge where lapse and shift
Expand Down
13 changes: 7 additions & 6 deletions src/PointwiseFunctions/SpecialRelativity/LorentzBoostMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,19 @@ tnsr::Ab<double, SpatialDim, Frame::NoFrame> lorentz_boost_matrix(
template <typename DataType, size_t SpatialDim, typename Frame>
void lorentz_boost(
const gsl::not_null<tnsr::I<DataType, SpatialDim, Frame>*> result,
const tnsr::I<DataType, SpatialDim, Frame>& one_form,
const double one_form_component_0,
const tnsr::I<DataType, SpatialDim, Frame>& vector,
const double vector_component_0,
const std::array<double, SpatialDim>& velocity) {
if (velocity == make_array<SpatialDim>(0.)) {
*result = one_form;
*result = vector;
return;
}
const auto boost_matrix = lorentz_boost_matrix(velocity);
// Inverse matrix with respect to the boost applied to one forms
const auto boost_matrix = lorentz_boost_matrix(-velocity);
for (size_t i = 0; i < SpatialDim; ++i) {
result->get(i) = boost_matrix.get(i + 1, 0) * one_form_component_0;
result->get(i) = boost_matrix.get(i + 1, 0) * vector_component_0;
for (size_t j = 0; j < SpatialDim; ++j) {
result->get(i) += boost_matrix.get(i + 1, j + 1) * one_form.get(j);
result->get(i) += boost_matrix.get(i + 1, j + 1) * vector.get(j);
}
}
}
Expand Down
13 changes: 6 additions & 7 deletions src/PointwiseFunctions/SpecialRelativity/LorentzBoostMatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,15 @@ tnsr::Ab<double, SpatialDim, Frame::NoFrame> lorentz_boost_matrix(
/// @{
/*!
* \ingroup SpecialRelativityGroup
* \brief Apply a Lorentz boost to the spatial part of a one form.
* \details This requires passing the 0th component of the one form as an
* \brief Apply a Lorentz boost to the spatial part of a vector.
* \details This requires passing the 0th component of the vector as an
* additional argument.
*/
template <typename DataType, size_t SpatialDim, typename Frame>
void lorentz_boost(
gsl::not_null<tnsr::I<DataType, SpatialDim, Frame>*> result,
const tnsr::I<DataType, SpatialDim, Frame>& one_form,
double one_form_component_0,
const std::array<double, SpatialDim>& velocity);
void lorentz_boost(gsl::not_null<tnsr::I<DataType, SpatialDim, Frame>*> result,
const tnsr::I<DataType, SpatialDim, Frame>& vector,
double vector_component_0,
const std::array<double, SpatialDim>& velocity);
/// @}

/// @{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ void verify_consistency(const Solution& solution, const double time,
derivative_approx);
}

/// Check the consistency of quantities depenent on other metric quantities
/// Check the consistency of quantities dependent on other metric quantities
/// returned by a solution. This includes checking pointwise relations such as
/// consistency of the metric and inverse and comparing returned and
/// numerical derivatives.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ void test_zero_spin_optimization(const DataType& used_for_size) {

template <typename Frame, typename DataType>
void test_boosted_for_zero_velocity(const DataType& used_for_size) {
const std::array<double, 3> boost_velocity{{0.0, 0.0, 1.0e-50}};
const double epsilon = std::numeric_limits<double>::epsilon();
const std::array<double, 3> boost_velocity{{0.0, 0.0, epsilon}};

gr::Solutions::KerrSchild solution_zero_velocity(
3.0, {{0., 0., 0.}}, {{0.2, 0.3, 0.2}});
Expand All @@ -406,8 +407,8 @@ void test_boosted_for_zero_velocity(const DataType& used_for_size) {

template <typename Frame, typename DataType>
void test_boosted_spacetime_metric(const DataType& used_for_size) {
// Test that the extrinsic curvature of the boosted solution indeed
// corresponds to the boosted extrinsic curvature tensor
// Test that the spacetime metric of the boosted solution indeed
// corresponds to the boosted spacetime metric tensor

const auto x = spatial_coords<Frame>(used_for_size);
const double t = 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,35 @@ void test_lorentz_boost(const std::array<double, SpatialDim> velocity) {
CHECK_ITERABLE_APPROX(unboosted_covariant_vector, covariant_vector);

// Check boost of the spatial vector
auto contravariant_vector =
make_with_random_values<tnsr::a<DataType, SpatialDim, Frame>>(
make_not_null(&generator), make_not_null(&distribution),
used_for_size);
tnsr::I<DataType, SpatialDim, Frame> spatial_vector =
make_with_value<tnsr::I<DataType, SpatialDim, Frame>>(used_for_size, 0.0);
for (size_t i = 0; i < SpatialDim; ++i) {
spatial_vector.get(i) = covariant_vector.get(i + 1);
spatial_vector.get(i) = contravariant_vector.get(i + 1);
}
// Lower index, i.e. v_0
const double vector_component_0 = get<0>(covariant_vector);
const double vector_component_0 = get<0>(contravariant_vector);

tnsr::I<DataType, SpatialDim, Frame> boosted_spatial_vector =
make_with_value<tnsr::I<DataType, SpatialDim, Frame>>(used_for_size, 0.0);

sr::lorentz_boost<DataType, SpatialDim, Frame>(
make_not_null(&boosted_spatial_vector), spatial_vector,
vector_component_0, velocity);

// We don't have an overload of the Lorentz boost for 4d vectors (just for one
// forms). But we can just change the sign of the velocity to boost it with
// the inverse Lorentz matrix for testing
tnsr::a<DataType, SpatialDim, Frame> boosted_contravariant_vector;
sr::lorentz_boost<DataType, SpatialDim, Frame>(
make_not_null(&boosted_contravariant_vector), contravariant_vector,
-velocity);
tnsr::I<DataType, SpatialDim, Frame> expected_spatial_vector =
make_with_value<tnsr::I<DataType, SpatialDim, Frame>>(used_for_size, 0.0);
for (size_t i = 0; i < SpatialDim; ++i) {
expected_spatial_vector.get(i) = boosted_covariant_vector.get(i + 1);
expected_spatial_vector.get(i) = boosted_contravariant_vector.get(i + 1);
}
CHECK_ITERABLE_APPROX(expected_spatial_vector, boosted_spatial_vector);

Expand All @@ -123,7 +133,7 @@ void test_lorentz_boost(const std::array<double, SpatialDim> velocity) {
make_with_random_values<tnsr::a<DataType, SpatialDim, Frame>>(
make_not_null(&generator), make_not_null(&distribution),
used_for_size);
// We boost it as well, but with possibly another velocity
// We boost it as well
tnsr::a<DataType, SpatialDim, Frame> boosted_covariant_vector_2;
sr::lorentz_boost<DataType, SpatialDim, Frame>(
make_not_null(&boosted_covariant_vector_2), covariant_vector_2, velocity);
Expand Down Expand Up @@ -166,10 +176,7 @@ SPECTRE_TEST_CASE(

d = large_velocity_squared;
CHECK_FOR_DOUBLES(test_lorentz_boost_matrix_analytic, (1, 2, 3));
}

SPECTRE_TEST_CASE("Unit.PointwiseFunctions.SpecialRelativity.LorentzBoost",
"[PointwiseFunctions][Unit]") {
const std::array<double, 3> velocity{{0.1, -0.4, 0.3}};
test_lorentz_boost<double, 3, Frame::Inertial>(velocity);
}

0 comments on commit 3d24e12

Please sign in to comment.