From 0192e3d170cc9d3866bfae8623caf85235e8ecca Mon Sep 17 00:00:00 2001 From: Nikolas Date: Thu, 5 Sep 2024 21:17:36 +0200 Subject: [PATCH] Add self-force turn on tags --- .../EvolveWorldtubeCurvedScalarWave.hpp | 2 + .../CurvedScalarWave/Worldtube/Tags.cpp | 12 ++- .../CurvedScalarWave/Worldtube/Tags.hpp | 78 ++++++++++++++++++- .../CurvedScalarWave/Worldtube/Test_Tags.cpp | 12 ++- 4 files changed, 99 insertions(+), 5 deletions(-) diff --git a/src/Evolution/Executables/CurvedScalarWave/EvolveWorldtubeCurvedScalarWave.hpp b/src/Evolution/Executables/CurvedScalarWave/EvolveWorldtubeCurvedScalarWave.hpp index 050cd86c9ddb..90d9f6a0eaf9 100644 --- a/src/Evolution/Executables/CurvedScalarWave/EvolveWorldtubeCurvedScalarWave.hpp +++ b/src/Evolution/Executables/CurvedScalarWave/EvolveWorldtubeCurvedScalarWave.hpp @@ -271,6 +271,8 @@ struct EvolutionMetavars { CurvedScalarWave::Worldtube::Tags::ExcisionSphere, CurvedScalarWave::Worldtube::Tags::ExpansionOrder, CurvedScalarWave::Worldtube::Tags::Charge, + CurvedScalarWave::Worldtube::Tags::SelfForceTurnOnTime, + CurvedScalarWave::Worldtube::Tags::SelfForceTurnOnInterval, CurvedScalarWave::Worldtube::Tags::Mass, CurvedScalarWave::Worldtube::Tags::MaxIterations, CurvedScalarWave::Worldtube::Tags::ObserveCoefficientsTrigger>; diff --git a/src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.cpp b/src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.cpp index 61c3ad50881b..d5f27d317241 100644 --- a/src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.cpp +++ b/src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.cpp @@ -29,12 +29,20 @@ namespace CurvedScalarWave::Worldtube::OptionTags { SelfForceOptions::SelfForceOptions() = default; -SelfForceOptions::SelfForceOptions(double mass_in, size_t iterations_in) - : mass(mass_in), iterations(iterations_in) {} +SelfForceOptions::SelfForceOptions(const double mass_in, + const size_t iterations_in, + const double turn_on_time_in, + const double turn_on_interval_in) + : mass(mass_in), + iterations(iterations_in), + turn_on_time(turn_on_time_in), + turn_on_interval(turn_on_interval_in) {} void SelfForceOptions::pup(PUP::er& p) { p | mass; p | iterations; + p | turn_on_time; + p | turn_on_interval; } } // namespace CurvedScalarWave::Worldtube::OptionTags diff --git a/src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.hpp b/src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.hpp index 759319c2824d..86637f66066a 100644 --- a/src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.hpp +++ b/src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.hpp @@ -69,6 +69,15 @@ struct Charge { /*! * \brief Options for the scalar self-force. Select `None` for a purely geodesic * evolution + * + *\details The self force is turned on using the smooth transition function + * + * \begin{equation} + * w(t) = 1 - \exp{ \left(- \left(\frac{t - t_1}{\sigma} \right)^4 \right)}. + * \end{equation} + * + * The turn on time is given by \f$t_1\f$ and the turn on interval is given by + *\f$sigma\f$. */ struct SelfForceOptions { static constexpr Options::String help = { @@ -92,14 +101,33 @@ struct SelfForceOptions { "acceleration."}; static size_t lower_bound() { return 1; } }; + + struct TurnOnTime { + using type = double; + static constexpr Options::String help{ + "The time at which the scalar self force is turned on."}; + static double lower_bound() { return 0.; } + }; + + struct TurnOnInterval { + using type = double; + static constexpr Options::String help{ + "The interval over which the scalar self force is smoothly turned on. " + "We require a minimum of 1 M for the interval."}; + static double lower_bound() { return 1.; } + }; + SelfForceOptions(); - SelfForceOptions(double mass_in, size_t iterations_in); + SelfForceOptions(double mass_in, size_t iterations_in, double turn_on_time_in, + double turn_on_interval_in); void pup(PUP::er& p); - using options = tmpl::list; + using options = tmpl::list; double mass{}; size_t iterations{}; + double turn_on_time{}; + double turn_on_interval{}; }; /*! @@ -251,6 +279,52 @@ struct Charge : db::SimpleTag { static double create_from_options(const double charge) { return charge; }; }; +/*! + * \brief The time at which the self-force is smoothly turned on. + * + * \details The self force is turned on using the smooth transition function + * + * \begin{equation} + * w(t) = 1 - \exp{ \left(- \left(\frac{t - t_1}{\sigma} \right)^4 \right)}. + * \end{equation} + * + * The turn on time is given by \f$t_1\f$. + */ +struct SelfForceTurnOnTime : db::SimpleTag { + using type = std::optional; + using option_tags = tmpl::list; + static constexpr bool pass_metavariables = false; + static std::optional create_from_options( + const std::optional& self_force_options) { + return self_force_options.has_value() + ? std::make_optional(self_force_options->turn_on_time) + : std::nullopt; + }; +}; + +/*! + * \brief The interval over which the self-force is smoothly turned on. + * + * \details The self force is turned on using the smooth transition function + * + * \begin{equation} + * w(t) = 1 - \exp{ \left(- \left(\frac{t - t_1}{\sigma} \right)^4 \right)}. + * \end{equation} + * + * The turn on interval is given by \f$\sigma\f$. + */ +struct SelfForceTurnOnInterval : db::SimpleTag { + using type = std::optional; + using option_tags = tmpl::list; + static constexpr bool pass_metavariables = false; + static std::optional create_from_options( + const std::optional& self_force_options) { + return self_force_options.has_value() + ? std::make_optional(self_force_options->turn_on_interval) + : std::nullopt; + }; +}; + /*! * \brief The mass of the scalar charge. Only has a value if the scalar self * force is applied. diff --git a/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/Test_Tags.cpp b/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/Test_Tags.cpp index f14e3733f488..435dc425df79 100644 --- a/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/Test_Tags.cpp +++ b/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/Test_Tags.cpp @@ -681,9 +681,13 @@ void test_check_input_file() { void test_self_force_options() { const auto options = TestHelpers::test_creation( "Mass: 0.1\n" - "Iterations: 3"); + "Iterations: 3\n" + "TurnOnTime: 1234.\n" + "TurnOnInterval: 987."); CHECK(options.mass == 0.1); CHECK(options.iterations == 3); + CHECK(options.turn_on_time == 1234.); + CHECK(options.turn_on_interval == 987.); } } // namespace @@ -704,6 +708,12 @@ SPECTRE_TEST_CASE("Unit.Evolution.Systems.CurvedScalarWave.Worldtube.Tags", "Charge"); TestHelpers::db::test_simple_tag( "Mass"); + TestHelpers::db::test_simple_tag< + CurvedScalarWave::Worldtube::Tags::SelfForceTurnOnTime>( + "SelfForceTurnOnTime"); + TestHelpers::db::test_simple_tag< + CurvedScalarWave::Worldtube::Tags::SelfForceTurnOnInterval>( + "SelfForceTurnOnInterval"); TestHelpers::db::test_simple_tag< CurvedScalarWave::Worldtube::Tags::MaxIterations>("MaxIterations"); TestHelpers::db::test_simple_tag<