Skip to content

Commit

Permalink
Add self-force turn on tags
Browse files Browse the repository at this point in the history
  • Loading branch information
nikwit committed Sep 23, 2024
1 parent c68f8e7 commit 0192e3d
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ struct EvolutionMetavars {
CurvedScalarWave::Worldtube::Tags::ExcisionSphere<volume_dim>,
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>;
Expand Down
12 changes: 10 additions & 2 deletions src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
78 changes: 76 additions & 2 deletions src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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<Mass, Iterations>;
using options = tmpl::list<Mass, Iterations, TurnOnTime, TurnOnInterval>;

double mass{};
size_t iterations{};
double turn_on_time{};
double turn_on_interval{};
};

/*!
Expand Down Expand Up @@ -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<double>;
using option_tags = tmpl::list<OptionTags::SelfForceOptions>;
static constexpr bool pass_metavariables = false;
static std::optional<double> create_from_options(
const std::optional<OptionTags::SelfForceOptions>& 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<double>;
using option_tags = tmpl::list<OptionTags::SelfForceOptions>;
static constexpr bool pass_metavariables = false;
static std::optional<double> create_from_options(
const std::optional<OptionTags::SelfForceOptions>& 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,13 @@ void test_check_input_file() {
void test_self_force_options() {
const auto options = TestHelpers::test_creation<OptionTags::SelfForceOptions>(
"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
Expand All @@ -704,6 +708,12 @@ SPECTRE_TEST_CASE("Unit.Evolution.Systems.CurvedScalarWave.Worldtube.Tags",
"Charge");
TestHelpers::db::test_simple_tag<CurvedScalarWave::Worldtube::Tags::Mass>(
"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<
Expand Down

0 comments on commit 0192e3d

Please sign in to comment.