DampedHarmonic.hpp
Go to the documentation of this file.
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 ///\file
5 /// Defines Functions for calculating damped harmonic gauge quantities from
6 /// 3+1 quantities
7 
8 #pragma once
9 
10 #include <cstddef>
11 
14 #include "Domain/Tags.hpp"
15 #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
16 #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp"
17 #include "Time/Tags.hpp"
18 #include "Utilities/TMPL.hpp"
19 
20 /// \cond
21 class DataVector;
22 namespace gsl {
23 template <class T>
24 class not_null;
25 } // namespace gsl
26 class Time;
27 /// \endcond
28 
29 // IWYU pragma: no_forward_declare Tags::Time
30 // IWYU pragma: no_forward_declare Tags::Coordinates
31 // IWYU pragma: no_forward_declare Tags::deriv
32 // IWYU pragma: no_forward_declare Tensor
33 // IWYU pragma: no_forward_declare db::ComputeTag
34 // IWYU pragma: no_forward_declare gr::InverseSpatialMetric
35 // IWYU pragma: no_forward_declare gr::Tags::Lapse
36 // IWYU pragma: no_forward_declare gr::Tags::Shift
37 // IWYU pragma: no_forward_declare gr::Tags::SpacetimeMetric
38 // IWYU pragma: no_forward_declare gr::Tags::SpacetimeNormalOneForm
39 // IWYU pragma: no_forward_declare gr::Tags::SpacetimeNormalVector
40 // IWYU pragma: no_forward_declare gr::Tags::InverseSpatialMetric
41 // IWYU pragma: no_forward_declare gr::Tags::SqrtDetSpatialMetric
42 
43 namespace GeneralizedHarmonic {
44 /*!
45  * \brief Damped harmonic gauge source function.
46  *
47  * \details See damped_harmonic_h() for details.
48  */
49 template <size_t SpatialDim, typename Frame>
50 struct DampedHarmonicHCompute : Tags::GaugeH<SpatialDim, Frame>,
52  using argument_tags = tmpl::list<
60 
61  static typename db::item_type<Tags::GaugeH<SpatialDim, Frame>> function(
63  gauge_h_init,
65  const tnsr::I<DataVector, SpatialDim, Frame>& shift,
66  const Scalar<DataVector>& sqrt_det_spatial_metric,
67  const tnsr::aa<DataVector, SpatialDim, Frame>& spacetime_metric,
68  const Time& time, const double& t_start, const double& sigma_t,
69  const tnsr::I<DataVector, SpatialDim, Frame>& coords,
70  const double& sigma_r) noexcept;
71 };
72 
73 /*!
74  * \brief Damped harmonic gauge source function.
75  *
76  * \details Computes the gauge source function designed for binary black hole
77  * evolutions. These have been taken from \cite Szilagyi2009qz and
78  * \cite Deppe2018uye.
79  *
80  * The covariant form of the source function \f$H_a\f$ is written as:
81  *
82  * \f{align*}
83  * H_a := [1 - R_{H_\mathrm{init}}(t)] H_a^\mathrm{init} +
84  * [\mu_{L1} \mathrm{log}(\sqrt{g}/N) + \mu_{L2} \mathrm{log}(1/N)] t_a
85  * - \mu_S g_{ai} N^i / N
86  * \f}
87  *
88  * where \f$N, N^k\f$ are the lapse and shift respectively, \f$t_a\f$ is the
89  * unit normal one-form to the spatial slice, and \f$g_{ab}\f$ is
90  * the spatial metric (obtained by projecting the spacetime metric onto the
91  * 3-slice, i.e. \f$g_{ab} = \psi_{ab} + t_a t_b\f$). The prefactors are:
92  *
93  * \f{align*}
94  * \mu_{L1} &= A_{L1} R_{L1}(t) W(x^i) \mathrm{log}(\sqrt{g}/N)^{e_{L1}}, \\
95  * \mu_{L2} &= A_{L2} R_{L2}(t) W(x^i) \mathrm{log}(1/N)^{e_{L2}}, \\
96  * \mu_{S} &= A_{S} R_{S}(t) W(x^i) \mathrm{log}(\sqrt{g}/N)^{e_{S}},
97  * \f}
98  *
99  * temporal roll-on functions \f$ R_X(t)\f$ (with label \f$ X\f$) are:
100  *
101  * \f{align*}
102  * \begin{array}{ll}
103  * R_X(t) & = 1 - \exp[-((t - t_{0,X})/ \sigma_t^X)^4], & t\geq t_{0,X} \\
104  * & = 0, & t< t_{0,X} \\
105  * \end{array}
106  * \f}
107  *
108  * and the spatial weight function is:
109  *
110  * \f{align*}
111  * W(x^i) = \exp[-(r/\sigma_r)^2].
112  * \f}
113  * This weight function can be written with multiple constant factors in the
114  * exponent in literature \cite Deppe2018uye, but we absorb them all into
115  * \f$ \sigma_r\f$ here. The coordinate \f$ r\f$ is the Euclidean radius
116  * in Inertial coordinates.
117  *
118  * Note:
119  * - Amplitude factors \f$ A_{X} \f$ are input as amp\_coef\_X
120  * - \f$ R_{X} \f$ is specified by \f$\{ t_{0,X}, \sigma_t^X\}\f$, which are
121  * input as \f$\{\f$t\_start\_X, sigma\_t\_X \f$\}\f$.
122  * - Exponents \f$ e_X\f$ are input as exp\_X.
123  * - The spatial weight function is specified completely by \f$\{\f$sigma\_r
124  * \f$\}\f$.
125  */
126 template <size_t SpatialDim, typename Frame>
127 void damped_harmonic_h(
129  gauge_h,
131  gauge_h_init,
132  const Scalar<DataVector>& lapse,
133  const tnsr::I<DataVector, SpatialDim, Frame>& shift,
134  const Scalar<DataVector>& sqrt_det_spatial_metric,
135  const tnsr::aa<DataVector, SpatialDim, Frame>& spacetime_metric,
136  double time, const tnsr::I<DataVector, SpatialDim, Frame>& coords,
137  // Scaling coeffs in front of each term
138  double amp_coef_L1, double amp_coef_L2, double amp_coef_S,
139  // exponents
140  int exp_L1, int exp_L2, int exp_S,
141  // roll on function parameters for lapse / shift terms
142  double t_start_h_init, double sigma_t_h_init, double t_start_L1,
143  double sigma_t_L1, double t_start_L2, double sigma_t_L2, double t_start_S,
144  double sigma_t_S,
145  // weight function
146  double sigma_r) noexcept;
147 
148 /*!
149  * \brief Spacetime derivatives of the damped harmonic gauge source function.
150  *
151  * \details See spacetime_deriv_damped_harmonic_h() for details.
152  */
153 template <size_t SpatialDim, typename Frame>
155  : Tags::SpacetimeDerivGaugeH<SpatialDim, Frame>,
157  using argument_tags = tmpl::list<
170 
172  function(
174  gauge_h_init,
175  const typename db::item_type<
176  Tags::SpacetimeDerivInitialGaugeH<SpatialDim, Frame>>& dgauge_h_init,
177  const Scalar<DataVector>& lapse,
178  const tnsr::I<DataVector, SpatialDim, Frame>& shift,
179  const tnsr::a<DataVector, SpatialDim, Frame>&
180  spacetime_unit_normal_one_form,
181  const Scalar<DataVector>& sqrt_det_spatial_metric,
182  const tnsr::II<DataVector, SpatialDim, Frame>& inverse_spatial_metric,
183  const tnsr::aa<DataVector, SpatialDim, Frame>& spacetime_metric,
184  const tnsr::aa<DataVector, SpatialDim, Frame>& pi,
185  const tnsr::iaa<DataVector, SpatialDim, Frame>& phi, const Time& time,
186  const double& t_start, const double& sigma_t,
187  const tnsr::I<DataVector, SpatialDim, Frame>& coords,
188  const double& sigma_r) noexcept;
189 };
190 
191 /*!
192  * \brief Spacetime derivatives of the damped harmonic gauge source function.
193  *
194  * \details Compute spacetime derivatives, i.e. \f$\partial_a H_b\f$, of the
195  * damped harmonic source function H. Using notation from damped_harmonic_h(),
196  * we rewrite the same as: \f{align*}
197  * \partial_a H_b =& \partial_a T_1 + \partial_a T_2 + \partial_a T_3, \\
198  * H_a =& T_1 + T_2 + T_3,
199  * \f}
200  *
201  * where:
202  *
203  * \f{align*}
204  * T_1 =& [1 - R_{H_\mathrm{init}}(t)] H_a^\mathrm{init}, \\
205  * T_2 =& [\mu_{L1} \mathrm{log}(\sqrt{g}/N) + \mu_{L2} \mathrm{log}(1/N)] t_a,
206  * \\ T_3 =& - \mu_S g_{ai} N^i / N. \f}
207  *
208  * Derivation:
209  *
210  * \f$\blacksquare\f$ For \f$ T_1 \f$, the derivatives are:
211  * \f{align*}
212  * \partial_a T_1 = (1 - R_{H_\mathrm{init}}(t))
213  * \partial_a H_b^\mathrm{init}
214  * - H_b^\mathrm{init} \partial_a R_{H_\mathrm{init}}.
215  * \f}
216  *
217  * \f$\blacksquare\f$ Write \f$ T_2 \equiv (\mu_1 + \mu_2) t_b \f$. Then:
218  * \f{align*}
219  * \partial_a T_2 =& (\partial_a \mu_1 + \partial_a \mu_2) t_b \\
220  * +& (\mu_1 + \mu_2) \partial_a t_b,
221  * \f}
222  * where
223  * \f{align*}
224  * \partial_a t_b =& \left(-\partial_a N, 0, 0, 0\right) \\
225  *
226  * \partial_a \mu_1
227  * =& \partial_a [A_{L1} R_{L1}(t) W(x^i) \mathrm{log}(\sqrt{g}/N)^{e_{L1} +
228  * 1}], \\
229  * =& A_{L1} R_{L1}(t) W(x^i) \partial_a [\mathrm{log}(\sqrt{g}/N)^{e_{L1} +
230  * 1}] \\
231  * +& A_{L1} \mathrm{log}(\sqrt{g}/N)^{e_{L1} + 1} \partial_a [R_{L1}(t)
232  * W(x^i)],\\
233  *
234  * \partial_a \mu_2
235  * =& \partial_a [A_{L2} R_{L2}(t) W(x^i) \mathrm{log}(1/N)^{e_{L2} + 1}], \\
236  * =& A_{L2} R_{L2}(t) W(x^i) \partial_a [\mathrm{log}(1/N)^{e_{L2} + 1}] \\
237  * +& A_{L2} \mathrm{log}(1/N)^{e_{L2} + 1} \partial_a [R_{L2}(t) W(x^i)],
238  * \f}
239  * where \f$\partial_a [R W] = \left(\partial_0 R(t), \partial_i
240  * W(x^j)\right)\f$.
241  *
242  * \f$\blacksquare\f$ Finally, the derivatives of \f$ T_3 \f$ are:
243  * \f[
244  * \partial_a T_3 = -\partial_a(\mu_S/N) g_{bi} N^i
245  * -(\mu_S/N) \partial_a(g_{bi}) N^i
246  * -(\mu_S/N) g_{bi}\partial_a N^i,
247  * \f]
248  * where
249  * \f{align*}
250  * \partial_a(\mu_S / N) =& (1/N)\partial_a \mu_S
251  * - \frac{\mu_S}{N^2}\partial_a N, \,\,\mathrm{and}\\
252  * \partial_a \mu_S =& \partial_a [A_S R_S(t) W(x^i)
253  * \mathrm{log}(\sqrt{g}/N)^{e_S}], \\
254  * =& A_S R_S(t) W(x^i) \partial_a
255  * [\mathrm{log}(\sqrt{g}/N)^{e_S}] \\
256  * +& A_S \mathrm{log}(\sqrt{g} / N)^{e_S} \partial_a [R_S(t)
257  * W(x^i)]. \f}
258  */
259 template <size_t SpatialDim, typename Frame>
263  d4_gauge_h,
265  gauge_h_init,
266  const typename db::item_type<
268  const Scalar<DataVector>& lapse,
269  const tnsr::I<DataVector, SpatialDim, Frame>& shift,
270  const tnsr::a<DataVector, SpatialDim, Frame>&
271  spacetime_unit_normal_one_form,
272  const Scalar<DataVector>& sqrt_det_spatial_metric,
273  const tnsr::II<DataVector, SpatialDim, Frame>& inverse_spatial_metric,
274  const tnsr::aa<DataVector, SpatialDim, Frame>& spacetime_metric,
275  const tnsr::aa<DataVector, SpatialDim, Frame>& pi,
276  const tnsr::iaa<DataVector, SpatialDim, Frame>& phi, double time,
277  const tnsr::I<DataVector, SpatialDim, Frame>& coords,
278  // Scaling coeffs in front of each term
279  double amp_coef_L1, double amp_coef_L2, double amp_coef_S,
280  // exponents
281  int exp_L1, int exp_L2, int exp_S,
282  // roll on function parameters for lapse / shift terms
283  double t_start_h_init, double sigma_t_h_init, double t_start_L1,
284  double sigma_t_L1, double t_start_L2, double sigma_t_L2, double t_start_S,
285  double sigma_t_S,
286  // weight function
287  double sigma_r) noexcept;
288 } // namespace GeneralizedHarmonic
Implementations from the Guideline Support Library.
Definition: ConservativeFromPrimitive.hpp:10
Definition: Tags.hpp:15
Initial spacetime derivatives of the gauge source function for the generalized harmonic system...
Definition: Tags.hpp:114
Gauge source function for the generalized harmonic system.
Definition: Tags.hpp:67
The time in a simulation. Times can be safely compared for exact equality as long as they do not belo...
Definition: Time.hpp:31
Spacetime derivatives of the gauge source function for the generalized harmonic system.
Definition: Tags.hpp:82
Definition: Tags.hpp:47
Marks a DataBoxTag as being a compute item that executes a function.
Definition: DataBoxTag.hpp:155
Gauge control parameter to specify the spatial weighting function that enters damped harmonic gauge s...
Definition: Tags.hpp:262
Gauge control parameter determining when to start rolling-on the evolution gauge. ...
Definition: Tags.hpp:225
Tag for compute item for current Time (from TimeId)
Definition: Tags.hpp:50
void damped_harmonic_h(gsl::not_null< typename db::item_type< Tags::GaugeH< SpatialDim, Frame >> *> gauge_h, const typename db::item_type< Tags::InitialGaugeH< SpatialDim, Frame >> &gauge_h_init, const Scalar< DataVector > &lapse, const tnsr::I< DataVector, SpatialDim, Frame > &shift, const Scalar< DataVector > &sqrt_det_spatial_metric, const tnsr::aa< DataVector, SpatialDim, Frame > &spacetime_metric, double time, const tnsr::I< DataVector, SpatialDim, Frame > &coords, double amp_coef_L1, double amp_coef_L2, double amp_coef_S, int exp_L1, int exp_L2, int exp_S, double t_start_h_init, double sigma_t_h_init, double t_start_L1, double sigma_t_L1, double t_start_L2, double sigma_t_L2, double t_start_S, double sigma_t_S, double sigma_r) noexcept
Damped harmonic gauge source function.
Definition: Tags.hpp:57
Inverse of the spatial metric.
Definition: Tags.hpp:34
void spacetime_metric(gsl::not_null< tnsr::aa< DataType, Dim, Frame > *> spacetime_metric, const Scalar< DataType > &lapse, const tnsr::I< DataType, Dim, Frame > &shift, const tnsr::ii< DataType, Dim, Frame > &spatial_metric) noexcept
Computes the spacetime metric from the spatial metric, lapse, and shift.
tnsr::aa< DataType, SpatialDim, Frame > pi(const Scalar< DataType > &lapse, const Scalar< DataType > &dt_lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::I< DataType, SpatialDim, Frame > &dt_shift, const tnsr::ii< DataType, SpatialDim, Frame > &spatial_metric, const tnsr::ii< DataType, SpatialDim, Frame > &dt_spatial_metric, const tnsr::iaa< DataType, SpatialDim, Frame > &phi) noexcept
Computes the conjugate momentum of the spacetime metric .
Definition: ComputeGhQuantities.cpp:120
tnsr::iaa< DataType, SpatialDim, Frame > phi(const Scalar< DataType > &lapse, const tnsr::i< DataType, SpatialDim, Frame > &deriv_lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::iJ< DataType, SpatialDim, Frame > &deriv_shift, const tnsr::ii< DataType, SpatialDim, Frame > &spatial_metric, const tnsr::ijj< DataType, SpatialDim, Frame > &deriv_spatial_metric) noexcept
Computes the auxiliary variable used by the generalized harmonic formulation of Einstein&#39;s equations...
Definition: ComputeGhQuantities.cpp:59
Items related to evolving the first-order generalized harmonic system.
Definition: Characteristics.cpp:20
void spacetime_deriv_damped_harmonic_h(gsl::not_null< typename db::item_type< Tags::SpacetimeDerivGaugeH< SpatialDim, Frame >> *> d4_gauge_h, const typename db::item_type< Tags::InitialGaugeH< SpatialDim, Frame >> &gauge_h_init, const typename db::item_type< Tags::SpacetimeDerivInitialGaugeH< SpatialDim, Frame >> &dgauge_h_init, const Scalar< DataVector > &lapse, const tnsr::I< DataVector, SpatialDim, Frame > &shift, const tnsr::a< DataVector, SpatialDim, Frame > &spacetime_unit_normal_one_form, const Scalar< DataVector > &sqrt_det_spatial_metric, const tnsr::II< DataVector, SpatialDim, Frame > &inverse_spatial_metric, const tnsr::aa< DataVector, SpatialDim, Frame > &spacetime_metric, const tnsr::aa< DataVector, SpatialDim, Frame > &pi, const tnsr::iaa< DataVector, SpatialDim, Frame > &phi, double time, const tnsr::I< DataVector, SpatialDim, Frame > &coords, double amp_coef_L1, double amp_coef_L2, double amp_coef_S, int exp_L1, int exp_L2, int exp_S, double t_start_h_init, double sigma_t_h_init, double t_start_L1, double sigma_t_L1, double t_start_L2, double sigma_t_L2, double t_start_S, double sigma_t_S, double sigma_r) noexcept
Spacetime derivatives of the damped harmonic gauge source function.
Definition: Tags.hpp:52
Scalar< DataType > lapse(const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric) noexcept
Compute lapse from shift and spacetime metric.
Definition: ComputeSpacetimeQuantities.cpp:117
Defines a list of useful type aliases for tensors.
The coordinates in a given frame.
Definition: Tags.hpp:95
Definition: Tags.hpp:108
tnsr::I< DataType, SpatialDim, Frame > shift(const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric, const tnsr::II< DataType, SpatialDim, Frame > &inverse_spatial_metric) noexcept
Compute shift from spacetime metric and inverse spatial metric.
Definition: ComputeSpacetimeQuantities.cpp:101
Stores a collection of function values.
Definition: DataVector.hpp:42
Wraps the template metaprogramming library used (brigand)
typename DataBox_detail::item_type_impl< TagList, Tag >::type item_type
Get the type that is returned by the Tag. If it is a base tag then a TagList must be passed as a seco...
Definition: DataBoxTag.hpp:410
Defines tags related to domain quantities.
Spacetime derivatives of the damped harmonic gauge source function.
Definition: DampedHarmonic.hpp:154
Initial value of the gauge source function for the generalized harmonic system.
Definition: Tags.hpp:98
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21
Damped harmonic gauge source function.
Definition: DampedHarmonic.hpp:50
Gauge control parameter determining how long the transition to the evolution gauge should take at the...
Definition: Tags.hpp:241
Defines tags related to Time quantities.
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12