-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5793 from nikwit/self-force-update-acc
Compute scalar self-force in `UpdateAcceleration`
- Loading branch information
Showing
9 changed files
with
268 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/Evolution/Systems/CurvedScalarWave/Worldtube/SelfForce.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#include "Evolution/Systems/CurvedScalarWave/Worldtube/SelfForce.hpp" | ||
|
||
#include <cstddef> | ||
|
||
#include "DataStructures/Tensor/Tensor.hpp" | ||
#include "Utilities/Gsl.hpp" | ||
|
||
namespace CurvedScalarWave::Worldtube { | ||
|
||
template <size_t Dim> | ||
void self_force_acceleration( | ||
gsl::not_null<tnsr::I<double, Dim>*> self_force_acc, | ||
const Scalar<double>& dt_psi_monopole, | ||
const tnsr::i<double, Dim>& psi_dipole, | ||
const tnsr::I<double, Dim>& particle_velocity, const double particle_charge, | ||
const double particle_mass, const tnsr::AA<double, Dim>& inverse_metric, | ||
const Scalar<double>& dilation_factor) { | ||
const double factor = | ||
particle_charge / particle_mass / square(get(dilation_factor)); | ||
for (size_t i = 0; i < Dim; ++i) { | ||
self_force_acc->get(i) = | ||
(inverse_metric.get(i + 1, 0) - | ||
particle_velocity.get(i) * inverse_metric.get(0, 0)) * | ||
get(dt_psi_monopole) * factor; | ||
for (size_t j = 0; j < Dim; ++j) { | ||
self_force_acc->get(i) += | ||
(inverse_metric.get(i + 1, j + 1) - | ||
particle_velocity.get(i) * inverse_metric.get(0, j + 1)) * | ||
psi_dipole.get(j) * factor; | ||
} | ||
} | ||
} | ||
|
||
template <size_t Dim> | ||
tnsr::I<double, Dim> self_force_acceleration( | ||
const Scalar<double>& dt_psi_monopole, | ||
const tnsr::i<double, Dim>& psi_dipole, | ||
const tnsr::I<double, Dim>& particle_velocity, const double particle_charge, | ||
const double particle_mass, const tnsr::AA<double, Dim>& inverse_metric, | ||
const Scalar<double>& dilation_factor) { | ||
tnsr::I<double, Dim> self_force_acc{}; | ||
self_force_acceleration(make_not_null(&self_force_acc), dt_psi_monopole, | ||
psi_dipole, particle_velocity, particle_charge, | ||
particle_mass, inverse_metric, dilation_factor); | ||
return self_force_acc; | ||
} | ||
|
||
// Instantiations | ||
template void self_force_acceleration( | ||
gsl::not_null<tnsr::I<double, 3>*> self_force_acc, | ||
const Scalar<double>& dt_psi_monopole, const tnsr::i<double, 3>& psi_dipole, | ||
const tnsr::I<double, 3>& particle_velocity, const double particle_charge, | ||
const double particle_mass, const tnsr::AA<double, 3>& inverse_metric, | ||
const Scalar<double>& dilation_factor); | ||
|
||
template tnsr::I<double, 3> self_force_acceleration( | ||
const Scalar<double>& dt_psi_monopole, const tnsr::i<double, 3>& psi_dipole, | ||
const tnsr::I<double, 3>& particle_velocity, const double particle_charge, | ||
const double particle_mass, const tnsr::AA<double, 3>& inverse_metric, | ||
const Scalar<double>& dilation_factor); | ||
} // namespace CurvedScalarWave::Worldtube |
51 changes: 51 additions & 0 deletions
51
src/Evolution/Systems/CurvedScalarWave/Worldtube/SelfForce.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#pragma once | ||
|
||
#include <cstddef> | ||
|
||
#include "DataStructures/Tensor/Tensor.hpp" | ||
#include "Utilities/Gsl.hpp" | ||
|
||
namespace CurvedScalarWave::Worldtube { | ||
|
||
/// @{ | ||
/*! | ||
* \brief Computes the coordinate acceleration due to the scalar self-force onto | ||
* the charge. | ||
* | ||
* \details It is given by | ||
* | ||
* \begin{equation} | ||
* (u^0)^2 \ddot{x}^i_p = \frac{q}{\mu}(g^{i | ||
* \alpha} - \dot{x}^i_p g^{0 \alpha} ) \partial_\alpha \Psi^R | ||
* \end{equation} | ||
* | ||
* where $\dot{x}^i_p$ is the position of the scalar charge, $\Psi^R$ is the | ||
* regular field, $q$ is the particle's charge, $\mu$ is the particle's mass, | ||
* $u^\alpha$ is the four-velocity and $g^{\alpha \beta}$ is the inverse | ||
* spacetime metric in the inertial frame, evaluated at the position of the | ||
* particle. An overdot denotes a derivative with respect to coordinate time. | ||
* Greek indices are spacetime indices and Latin indices are purely spatial. | ||
* Note that the coordinate geodesic acceleration is NOT included. | ||
*/ | ||
template <size_t Dim> | ||
void self_force_acceleration( | ||
gsl::not_null<tnsr::I<double, Dim>*> self_force_acc, | ||
const Scalar<double>& dt_psi_monopole, | ||
const tnsr::i<double, Dim>& psi_dipole, | ||
const tnsr::I<double, Dim>& particle_velocity, double particle_charge, | ||
double particle_mass, const tnsr::AA<double, Dim>& inverse_metric, | ||
const Scalar<double>& dilation_factor); | ||
|
||
template <size_t Dim> | ||
tnsr::I<double, Dim> self_force_acceleration( | ||
const Scalar<double>& dt_psi_monopole, | ||
const tnsr::i<double, Dim>& psi_dipole, | ||
const tnsr::I<double, Dim>& particle_velocity, double particle_charge, | ||
double particle_mass, const tnsr::AA<double, Dim>& inverse_metric, | ||
const Scalar<double>& dilation_factor); | ||
|
||
/// @} | ||
} // namespace CurvedScalarWave::Worldtube |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/SelfForce.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Distributed under the MIT License. | ||
# See LICENSE.txt for details. | ||
|
||
import numpy as np | ||
|
||
|
||
def self_force_acceleration( | ||
dt_psi_monopole, | ||
psi_dipole, | ||
vel, | ||
charge, | ||
mass, | ||
inverse_metric, | ||
dilation, | ||
): | ||
# Prepend extra value so dimensions work out for einsum. | ||
# The 0th component does not affect the final result | ||
four_vel = np.concatenate((np.empty(1), vel), axis=0) | ||
d_psi = np.concatenate(([dt_psi_monopole], psi_dipole), axis=0) | ||
self_force_acc = np.einsum("ij,j", inverse_metric, d_psi) | ||
self_force_acc -= np.einsum("i,j,j", four_vel, inverse_metric[0], d_psi) | ||
self_force_acc *= charge / mass / dilation**2 | ||
return self_force_acc[1:] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/Test_SelfForce.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#include "Framework/TestingFramework.hpp" | ||
|
||
#include <random> | ||
|
||
#include "Evolution/Systems/CurvedScalarWave/Worldtube/SelfForce.hpp" | ||
#include "Framework/CheckWithRandomValues.hpp" | ||
#include "Framework/SetupLocalPythonEnvironment.hpp" | ||
#include "Framework/TestCreation.hpp" | ||
#include "Framework/TestHelpers.hpp" | ||
#include "Utilities/TMPL.hpp" | ||
|
||
namespace CurvedScalarWave::Worldtube { | ||
namespace { | ||
|
||
void test_self_force_acceleration() { | ||
pypp::SetupLocalPythonEnvironment local_python_env{ | ||
"Evolution/Systems/CurvedScalarWave/Worldtube"}; | ||
pypp::check_with_random_values<1>( | ||
static_cast<tnsr::I<double, 3> (*)( | ||
const Scalar<double>&, const tnsr::i<double, 3>&, | ||
const tnsr::I<double, 3>&, const double, const double, | ||
const tnsr::AA<double, 3>&, const Scalar<double>&)>( | ||
self_force_acceleration<3>), | ||
"SelfForce", "self_force_acceleration", {{{-2.0, 2.0}}}, 1); | ||
} | ||
|
||
SPECTRE_TEST_CASE("Unit.Evolution.Systems.CSW.Worldtube.SelfForce", | ||
"[Unit][Evolution]") { | ||
test_self_force_acceleration(); | ||
} | ||
} // namespace | ||
} // namespace CurvedScalarWave::Worldtube |