Skip to content

Commit

Permalink
Compute KleinGordon Cce sources
Browse files Browse the repository at this point in the history
  • Loading branch information
Sizheng-Ma committed Mar 2, 2024
1 parent 122c739 commit 6a80ba0
Show file tree
Hide file tree
Showing 6 changed files with 367 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Evolution/Systems/Cce/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ spectre_target_sources(
BoundaryData.cpp
Equations.cpp
GaugeTransformBoundaryData.cpp
KleinGordonSource.cpp
LinearOperators.cpp
LinearSolve.cpp
NewmanPenrose.cpp
Expand Down Expand Up @@ -47,6 +48,7 @@ spectre_target_headers(
SpecBoundaryData.hpp
SwshDerivatives.hpp
System.hpp
KleinGordonSource.hpp
KleinGordonSystem.hpp
Tags.hpp
WorldtubeBufferUpdater.hpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Evolution/Systems/Cce/Actions/InitializeKleinGordonVariables.hpp"
#include "Evolution/Systems/Cce/Actions/PrecomputeKleinGordonSourceVariables.hpp"
#include "Evolution/Systems/Cce/Components/CharacteristicEvolution.hpp"
#include "Evolution/Systems/Cce/KleinGordonSource.hpp"
#include "Evolution/Systems/Cce/KleinGordonSystem.hpp"
#include "Parallel/GlobalCache.hpp"
#include "Parallel/Local.hpp"
Expand Down Expand Up @@ -89,6 +90,10 @@ struct KleinGordonCharacteristicEvolution
Actions::CalculatePsi0AndDerivAtInnerBoundary,
tmpl::list<>>,
Actions::PrecomputeKleinGordonSourceVariables,
tmpl::transform<
bondi_hypersurface_step_tags,
tmpl::bind<::Actions::MutateApply,
tmpl::bind<ComputeKleinGordonSource, tmpl::_1>>>,
tmpl::transform<bondi_hypersurface_step_tags,
tmpl::bind<hypersurface_computation, tmpl::_1>>,
Actions::FilterSwshVolumeQuantity<Tags::BondiH>,
Expand Down Expand Up @@ -126,6 +131,10 @@ struct KleinGordonCharacteristicEvolution
Actions::CalculatePsi0AndDerivAtInnerBoundary,
tmpl::list<>>,
Actions::PrecomputeKleinGordonSourceVariables,
tmpl::transform<
bondi_hypersurface_step_tags,
tmpl::bind<::Actions::MutateApply,
tmpl::bind<ComputeKleinGordonSource, tmpl::_1>>>,
tmpl::transform<bondi_hypersurface_step_tags,
tmpl::bind<hypersurface_computation, tmpl::_1>>,
Actions::FilterSwshVolumeQuantity<Tags::BondiH>,
Expand Down
57 changes: 57 additions & 0 deletions src/Evolution/Systems/Cce/KleinGordonSource.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Distributed under the MIT License.
// See LICENSE.txt for details.

#include "Evolution/Systems/Cce/KleinGordonSource.hpp"

namespace Cce {

void ComputeKleinGordonSource<Tags::BondiBeta>::apply(
gsl::not_null<Scalar<SpinWeighted<ComplexDataVector, 0>>*> kg_source_beta,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& dy_kg_psi,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& one_minus_y) {
get(*kg_source_beta) = 2. * M_PI * get(one_minus_y) * square(get(dy_kg_psi));
}

void ComputeKleinGordonSource<Tags::BondiQ>::apply(
gsl::not_null<Scalar<SpinWeighted<ComplexDataVector, 1>>*> kg_source_q,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& dy_kg_psi,
const Scalar<SpinWeighted<ComplexDataVector, 1>>& eth_kg_psi) {
get(*kg_source_q) = 16. * M_PI * get(eth_kg_psi) * get(dy_kg_psi);
}

void ComputeKleinGordonSource<Tags::BondiU>::apply(
gsl::not_null<Scalar<SpinWeighted<ComplexDataVector, 1>>*> kg_source_u,
const size_t l_max, const size_t number_of_radial_points) {
const size_t volume_size =
Spectral::Swsh::number_of_swsh_collocation_points(l_max) *
number_of_radial_points;
get(*kg_source_u) = SpinWeighted<ComplexDataVector, 1>{volume_size, 0.0};
}

void ComputeKleinGordonSource<Tags::BondiW>::apply(
gsl::not_null<Scalar<SpinWeighted<ComplexDataVector, 0>>*> kg_source_w,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& exp_2_beta,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& bondi_r,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& bondi_k,
const Scalar<SpinWeighted<ComplexDataVector, 2>>& bondi_j,
const Scalar<SpinWeighted<ComplexDataVector, 1>>& eth_kg_psi) {
SpinWeighted<ComplexDataVector, 0> complex_part;
SpinWeighted<ComplexDataVector, 0> real_part;

complex_part.data() =
2.0 * real(get(bondi_j).data() * square(conj(get(eth_kg_psi))).data());
real_part.data() =
-2.0 * get(bondi_k).data() * square(abs(get(eth_kg_psi).data()));
get(*kg_source_w) =
M_PI * get(exp_2_beta) / get(bondi_r) * (complex_part + real_part);
}

void ComputeKleinGordonSource<Tags::BondiH>::apply(
gsl::not_null<Scalar<SpinWeighted<ComplexDataVector, 2>>*> kg_source_h,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& exp_2_beta,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& bondi_r,
const Scalar<SpinWeighted<ComplexDataVector, 1>>& eth_kg_psi) {
get(*kg_source_h) =
2 * M_PI * get(exp_2_beta) / get(bondi_r) * square(get(eth_kg_psi));
}
} // namespace Cce
139 changes: 139 additions & 0 deletions src/Evolution/Systems/Cce/KleinGordonSource.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// Distributed under the MIT License.
// See LICENSE.txt for details.

#pragma once

#include "Evolution/Systems/Cce/OptionTags.hpp"
#include "Evolution/Systems/Cce/Tags.hpp"
#include "Utilities/Gsl.hpp"
#include "Utilities/TMPL.hpp"

namespace Cce {

/*!
* \brief Computes `Tags::KleinGordonSource<Tag>` for the tags evolved by
* Klein-Gordon Cce.
*
* \details In scalar-tensor theory, the Cce hypersurface equations get
* additional source terms contributed by the stress-energy tensor of the scalar
* field. The tag `Tags::KleinGordonSource<Tag>` stores the corresponding volume
* data.
*/
template <typename Tag>
struct ComputeKleinGordonSource;

/*!
* \brief Computes the Klein-Gordon source of the Bondi \f$\beta\f$
*
* \details The source reads:
*
* \f{align*}{
* 2 \pi (1-y) (\partial_y\psi)^2,
* \f}
* where \f$\psi\f$ is the Klein-Gordon (scalar) field.
*/
template <>
struct ComputeKleinGordonSource<Tags::BondiBeta> {
using return_tags = tmpl::list<Tags::KleinGordonSource<Tags::BondiBeta>>;
using argument_tags =
tmpl::list<Tags::Dy<Tags::KleinGordonPsi>, Tags::OneMinusY>;
static void apply(
gsl::not_null<Scalar<SpinWeighted<ComplexDataVector, 0>>*> kg_source_beta,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& dy_kg_psi,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& one_minus_y);
};

/*!
* \brief Computes the Klein-Gordon source of the Bondi \f$Q\f$
*
* \details Following the nomenclature of \cite Moxon2020gha and their Eq. (49),
* the scalar field contributes only to the regular part of the source term
* \f$S_2^R\f$. The expression reads:
*
* \f{align*}{
* 16 \pi \eth\psi \partial_y\psi,
* \f}
* where \f$\psi\f$ is the Klein-Gordon (scalar) field.
*/
template <>
struct ComputeKleinGordonSource<Tags::BondiQ> {
using return_tags = tmpl::list<Tags::KleinGordonSource<Tags::BondiQ>>;
using argument_tags =
tmpl::list<Tags::Dy<Tags::KleinGordonPsi>,
Spectral::Swsh::Tags::Derivative<Tags::KleinGordonPsi,
Spectral::Swsh::Tags::Eth>>;
static void apply(
gsl::not_null<Scalar<SpinWeighted<ComplexDataVector, 1>>*> kg_source_q,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& dy_kg_psi,
const Scalar<SpinWeighted<ComplexDataVector, 1>>& eth_kg_psi);
};

/*!
* \brief Computes the Klein-Gordon source of the Bondi \f$U\f$
*
* \details The source vanishes.
*/
template <>
struct ComputeKleinGordonSource<Tags::BondiU> {
using return_tags = tmpl::list<Tags::KleinGordonSource<Tags::BondiU>>;
using argument_tags = tmpl::list<Tags::LMax, Tags::NumberOfRadialPoints>;
static void apply(
gsl::not_null<Scalar<SpinWeighted<ComplexDataVector, 1>>*> kg_source_u,
size_t l_max, size_t number_of_radial_points);
};

/*!
* \brief Computes the Klein-Gordon source of the Bondi \f$W\f$
*
* \details Following the nomenclature of \cite Moxon2020gha and their Eq. (49),
* the scalar field contributes only to the regular part of the source term
* \f$S_2^R\f$. The expression reads:
*
* \f{align*}{
* \frac{\pi e^{2\beta}}{R} \left[J(\bar{\eth}\psi)^2 + \bar{J}(\eth
* \psi)^2-2K \eth\psi\bar{\eth}\psi\right],
* \f}
* where \f$\psi\f$ is the Klein-Gordon (scalar) field.
*/
template <>
struct ComputeKleinGordonSource<Tags::BondiW> {
using return_tags = tmpl::list<Tags::KleinGordonSource<Tags::BondiW>>;
using argument_tags =
tmpl::list<Tags::Exp2Beta, Tags::BondiR, Tags::BondiK, Tags::BondiJ,
Spectral::Swsh::Tags::Derivative<Tags::KleinGordonPsi,
Spectral::Swsh::Tags::Eth>>;
static void apply(
gsl::not_null<Scalar<SpinWeighted<ComplexDataVector, 0>>*> kg_source_w,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& exp_2_beta,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& bondi_r,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& bondi_k,
const Scalar<SpinWeighted<ComplexDataVector, 2>>& bondi_j,
const Scalar<SpinWeighted<ComplexDataVector, 1>>& eth_kg_psi);
};

/*!
* \brief Computes the Klein-Gordon source of the Bondi \f$H\f$
*
* \details Following the nomenclature of \cite Moxon2020gha and their Eq. (50),
* the scalar field contributes only to the regular part of the source term
* \f$S_3^R\f$. The expression reads:
*
* \f{align*}{
* 2 \pi \frac{e^{2\beta}}{R}(\eth\psi)^2,
* \f}
* where \f$\psi\f$ is the Klein-Gordon (scalar) field.
*/
template <>
struct ComputeKleinGordonSource<Tags::BondiH> {
using return_tags = tmpl::list<Tags::KleinGordonSource<Tags::BondiH>>;
using argument_tags =
tmpl::list<Tags::Exp2Beta, Tags::BondiR,
Spectral::Swsh::Tags::Derivative<Tags::KleinGordonPsi,
Spectral::Swsh::Tags::Eth>>;
static void apply(
gsl::not_null<Scalar<SpinWeighted<ComplexDataVector, 2>>*> kg_source_h,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& exp_2_beta,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& bondi_r,
const Scalar<SpinWeighted<ComplexDataVector, 1>>& eth_kg_psi);
};
} // namespace Cce
1 change: 1 addition & 0 deletions tests/Unit/Evolution/Systems/Cce/Actions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ set(LIBRARY_SOURCES
Test_InitializeKleinGordonFirstHypersurface.cpp
Test_InitializeKleinGordonWorldtubeBoundary.cpp
Test_InitializeWorldtubeBoundary.cpp
Test_KleinGordonCceCalculations.cpp
Test_KleinGordonH5BoundaryCommunication.cpp
Test_Psi0Matching.cpp
Test_RequestBoundaryData.cpp
Expand Down
Loading

0 comments on commit 6a80ba0

Please sign in to comment.