Skip to content

Commit

Permalink
fixup: change CoM parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
iago-mendes committed Sep 16, 2024
1 parent a487791 commit 14d7a3a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
18 changes: 11 additions & 7 deletions src/PointwiseFunctions/Xcts/CenterOfMass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "PointwiseFunctions/Xcts/CenterOfMass.hpp"

#include "DataStructures/Tensor/EagerMath/Magnitude.hpp"

namespace Xcts {

void center_of_mass_surface_integrand(
Expand All @@ -27,20 +29,22 @@ void center_of_mass_volume_integrand(
gsl::not_null<tnsr::I<DataVector, 3>*> result,
const Scalar<DataVector>& conformal_factor,
const tnsr::i<DataVector, 3, Frame::Inertial>& deriv_conformal_factor,
const tnsr::I<DataVector, 3>& unit_normal) {
tenex::evaluate<ti::I>(result, 3. / (8. * M_PI) * 4. *
pow<3>(conformal_factor()) *
deriv_conformal_factor(ti::j) *
unit_normal(ti::I) * unit_normal(ti::J));
const tnsr::I<DataVector, 3>& coords) {
tenex::evaluate<ti::I>(
result,
3. / (4. * M_PI * pow<2>(magnitude(coords)())) *
(2. * pow<3>(conformal_factor()) * deriv_conformal_factor(ti::j) *
coords(ti::I) * coords(ti::J) +
pow<4>(conformal_factor()) * coords(ti::I)));
}

tnsr::I<DataVector, 3> center_of_mass_volume_integrand(
const Scalar<DataVector>& conformal_factor,
const tnsr::i<DataVector, 3, Frame::Inertial>& deriv_conformal_factor,
const tnsr::I<DataVector, 3>& unit_normal) {
const tnsr::I<DataVector, 3>& coords) {
tnsr::I<DataVector, 3> result;
center_of_mass_volume_integrand(make_not_null(&result), conformal_factor,
deriv_conformal_factor, unit_normal);
deriv_conformal_factor, coords);
return result;
}

Expand Down
18 changes: 14 additions & 4 deletions src/PointwiseFunctions/Xcts/CenterOfMass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,38 @@ tnsr::II<DataVector, 3> center_of_mass_surface_integrand(
*
* \begin{equation}
* C_\text{CoM}^i = \frac{3}{8 \pi M_\text{ADM}}
* \int_{V_\infty} 4 \psi^3 \partial_j \psi n^i n^j \, dV.
* \int_{V_\infty} \Big(
* 4 \psi^3 \partial_j \psi n^i n^j
* + \frac{2}{r} \psi^4 n^i
* \Big) dV
* = \frac{3}{4 \pi M_\text{ADM}}
* \int_{V_\infty} \frac{1}{r^2} \Big(
* 2 \psi^3 \partial_j \psi x^i x^j
* + \psi^4 x^i
* \Big) dV,
* \end{equation}
*
* where $n^i = x^i / r$ and $r = \sqrt{x^2 + y^2 + z^2}$.
*
* \see `center_of_mass_surface_integrand`
*
* \param result output pointer
* \param conformal_factor the conformal factor $\psi$
* \param deriv_conformal_factor the gradient of the conformal factor
* $\partial_i \psi$
* \param unit_normal the outward-pointing unit normal $n^i = x^i / r$
* \param coords the inertial coordinates $x^i$
*/
void center_of_mass_volume_integrand(
gsl::not_null<tnsr::I<DataVector, 3>*> result,
const Scalar<DataVector>& conformal_factor,
const tnsr::i<DataVector, 3, Frame::Inertial>& deriv_conformal_factor,
const tnsr::I<DataVector, 3>& unit_normal);
const tnsr::I<DataVector, 3>& coords);

/// Return-by-value overload
tnsr::I<DataVector, 3> center_of_mass_volume_integrand(
const Scalar<DataVector>& conformal_factor,
const tnsr::i<DataVector, 3, Frame::Inertial>& deriv_conformal_factor,
const tnsr::I<DataVector, 3>& unit_normal);
const tnsr::I<DataVector, 3>& coords);
/// @}

} // namespace Xcts
3 changes: 2 additions & 1 deletion tests/Unit/PointwiseFunctions/Xcts/Test_CenterOfMass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void test_infinite_volume_integral(const double distance,

// Evaluate volume integral.
const auto volume_integrand = Xcts::center_of_mass_volume_integrand(
conformal_factor, deriv_conformal_factor, unit_normal);
conformal_factor, deriv_conformal_factor, inertial_coords);
for (int I = 0; I < 3; I++) {
total_integral.get(I) +=
definite_integral(volume_integrand.get(I) * get(det_jacobian), mesh);
Expand Down Expand Up @@ -302,6 +302,7 @@ SPECTRE_TEST_CASE("Unit.PointwiseFunctions.Xcts.CenterOfMass",
for (const double distance : std::array<double, 3>({1.e4, 1.e5, 1.e6})) {
test_infinite_surface_integral(distance, 0.1);
// Note: the infinite volume integral blows up for non-zero shifts.
// TODO: figure out why the test below fails with the recent changes.

Check failure on line 305 in tests/Unit/PointwiseFunctions/Xcts/Test_CenterOfMass.cpp

View workflow job for this annotation

GitHub Actions / Clang-tidy (Release)

missing username/bug in TODO
test_infinite_volume_integral(distance, 0.);
}
}

0 comments on commit 14d7a3a

Please sign in to comment.