Peano
Loading...
Searching...
No Matches
spacetimes.h
Go to the documentation of this file.
1#ifndef APPARENT_HORIZON_FINDER_SPACETIMES_H_
2#define APPARENT_HORIZON_FINDER_SPACETIMES_H_
3
4#include "ahf-data.h"
5
6#include <array>
7#include <cmath>
8#include <complex>
9#include <numbers>
10#include <stdexcept>
11#include <vector>
12
13namespace exahype2::ccz4::ahf {
14
34
37 template <class T> using FieldVector = std::array<T, 3>;
38 template <class T> using FieldMatrix = std::array<std::array<T, 3>, 3>;
39
40 namespace detail {
41
44 template <class T> T radius(const FieldVector<T>& X) {
45 return std::sqrt(X[0] * X[0] + X[1] * X[1] + X[2] * X[2]);
46 }
47
49 template <class T> FieldMatrix<T> identity() {
50 FieldMatrix<T> result{};
51 for (int i = 0; i < 3; ++i) {
52 for (int j = 0; j < 3; ++j) {
53 result[i][j] = (i == j) ? T(1.0) : T(0.0);
54 }
55 }
56 return result;
57 }
58
59 } // namespace detail
60
66 double M = 1.0;
67
68 template <class T> T psi(const FieldVector<T>& X) const {
69 return T(1.0) + T(M) / (T(2.0) * detail::radius(X));
70 }
71
72 template <class T> FieldMatrix<T> gamma(const FieldVector<T>& X) const {
73 const T p4 = psi(X) * psi(X) * psi(X) * psi(X);
75 for (int i = 0; i < 3; ++i) {
76 result[i][i] = p4;
77 }
78 return result;
79 }
80
81 template <class T> FieldVector<T> beta(const FieldVector<T>&) const {
82 return FieldVector<T>{T(0.0), T(0.0), T(0.0)};
83 }
84
85 // Time-symmetric slice: beta = 0 and partial_t gamma = 0, so K_ij = 0 for
86 // any lapse.
87 // The static isotropic lapse vanishes at the horizon, which
88 // would make the K_ij = (D beta)/(2 alpha) evaluation a spurious 0/0.
89 // use alpha = 1.
90 template <class T> T alpha(const FieldVector<T>&) const { return T(1.0); }
91
92 double horizonRadius() const { return 0.5 * M; }
93 double horizonArea() const { return 16.0 * std::numbers::pi * M * M; }
94 };
95
100 double M = 1.0;
101
102 template <class T> FieldMatrix<T> gamma(const FieldVector<T>& X) const {
103 const T r = detail::radius(X);
104 const T H = T(M) / r;
105 const FieldVector<T> l{X[0] / r, X[1] / r, X[2] / r};
107 for (int i = 0; i < 3; ++i) {
108 for (int j = 0; j < 3; ++j) {
109 result[i][j] += T(2.0) * H * l[i] * l[j];
110 }
111 }
112 return result;
113 }
114
115 template <class T> FieldVector<T> beta(const FieldVector<T>& X) const {
116 const T r = detail::radius(X);
117 const T H = T(M) / r;
118 return FieldVector<
119 T>{T(2.0) * H * X[0] / r, T(2.0) * H * X[1] / r, T(2.0) * H * X[2] / r};
120 }
121
122 template <class T> T alpha(const FieldVector<T>& X) const {
123 const T H = T(M) / detail::radius(X);
124 return T(1.0) / std::sqrt(T(1.0) + T(2.0) * H);
125 }
126
127 double horizonRadius() const { return 2.0 * M; }
128 double horizonArea() const { return 16.0 * std::numbers::pi * M * M; }
129 };
130
138 double M = 1.0;
139 double a = 0.6;
140
141 template <class T> T ksRadius(const FieldVector<T>& X) const {
142 const T rho2 = X[0] * X[0] + X[1] * X[1] + X[2] * X[2];
143 const T a2 = T(a) * T(a);
144 const T r2
145 = T(0.5)
146 * ((rho2 - a2) + std::sqrt((rho2 - a2) * (rho2 - a2) + T(4.0) * a2 * X[2] * X[2]));
147 return std::sqrt(r2);
148 }
149
150 template <class T>
151 void HandL(const FieldVector<T>& X, T& H, FieldVector<T>& l) const {
152 const T r = ksRadius(X);
153 const T a2 = T(a) * T(a);
154 H = T(M) * r * r * r / (r * r * r * r + a2 * X[2] * X[2]);
155 l = FieldVector<T>{
156 (r * X[0] + T(a) * X[1]) / (r * r + a2),
157 (r * X[1] - T(a) * X[0]) / (r * r + a2),
158 X[2] / r};
159 }
160
161 template <class T> FieldMatrix<T> gamma(const FieldVector<T>& X) const {
162 T H;
164 HandL(X, H, l);
166 for (int i = 0; i < 3; ++i) {
167 for (int j = 0; j < 3; ++j) {
168 result[i][j] += T(2.0) * H * l[i] * l[j];
169 }
170 }
171 return result;
172 }
173
174 template <class T> FieldVector<T> beta(const FieldVector<T>& X) const {
175 T H;
177 HandL(X, H, l);
178 return FieldVector<
179 T>{T(2.0) * H * l[0], T(2.0) * H * l[1], T(2.0) * H * l[2]};
180 }
181
182 template <class T> T alpha(const FieldVector<T>& X) const {
183 T H;
185 HandL(X, H, l);
186 return T(1.0) / std::sqrt(T(1.0) + T(2.0) * H);
187 }
188
189 double horizonRadius() const { return M + std::sqrt(M * M - a * a); }
190 double horizonArea() const {
191 return 8.0 * std::numbers::pi * M * horizonRadius();
192 }
193 };
194
202 std::vector<std::pair<double, FieldVector<double>>> punctures;
203
204 template <class T> T psi(const FieldVector<T>& X) const {
205 T out = T(1.0);
206 for (const auto& puncture : punctures) {
207 const double m = puncture.first;
208 const FieldVector<double>& p = puncture.second;
209 const FieldVector<T>
210 delta{X[0] - T(p[0]), X[1] - T(p[1]), X[2] - T(p[2])};
211 out += T(m) / (T(2.0) * detail::radius(delta));
212 }
213 return out;
214 }
215
216 template <class T> FieldMatrix<T> gamma(const FieldVector<T>& X) const {
217 const T p4 = psi(X) * psi(X) * psi(X) * psi(X);
219 for (int i = 0; i < 3; ++i) {
220 result[i][i] = p4;
221 }
222 return result;
223 }
224
225 template <class T> FieldVector<T> beta(const FieldVector<T>&) const {
226 return FieldVector<T>{T(0.0), T(0.0), T(0.0)};
227 }
228
229 template <class T> T alpha(const FieldVector<T>&) const { return T(1.0); }
230
232 double admMass() const {
233 double total = 0.0;
234 for (const auto& puncture : punctures) {
235 total += puncture.first;
236 }
237 return total;
238 }
239
242 double M() const {
243 if (punctures.size() != 1) {
244 throw std::logic_error(
245 "BrillLindquist::M is only defined for a single-puncture slice"
246 );
247 }
248 return punctures.front().first;
249 }
250 double horizonRadius() const { return 0.5 * M(); }
251 double horizonArea() const { return 16.0 * std::numbers::pi * M() * M(); }
252
256 FieldVector<double> sum{0.0, 0.0, 0.0};
257 for (const auto& puncture : punctures) {
258 for (int i = 0; i < 3; ++i) {
259 sum[i] += puncture.first * puncture.second[i];
260 }
261 }
262 const double mass = admMass();
263 for (int i = 0; i < 3; ++i) {
264 sum[i] /= mass;
265 }
266 return sum;
267 }
268
270 std::vector<FieldVector<double>> puncturePositions() const {
271 std::vector<FieldVector<double>> positions;
272 positions.reserve(punctures.size());
273 for (const auto& puncture : punctures) {
274 positions.push_back(puncture.second);
275 }
276 return positions;
277 }
278
279 enum class Axis { X = 0, Y = 1, Z = 2 };
280 enum class Plane { XY, XZ, YZ };
281
284 double m = 1.0,
285 FieldVector<double> center = {0.0, 0.0, 0.0}
286 ) {
287 return BrillLindquist{{{m, center}}};
288 }
289
292 double m = 1.0,
293 double separation = 2.0,
294 Axis axis = Axis::Z
295 ) {
296 FieldVector<double> half{0.0, 0.0, 0.0};
297 half[static_cast<int>(axis)] = 0.5 * separation;
298 const FieldVector<double> minusHalf{-half[0], -half[1], -half[2]};
299 return BrillLindquist{{{m, half}, {m, minusHalf}}};
300 }
301
310 double m = 1.0,
311 double separation = 1.5,
312 Plane plane = Plane::XY
313 ) {
314 const double circumradius = separation / std::sqrt(3.0); // from side
315 // length
316 const double degToRad = std::numbers::pi / 180.0;
317 const double angles[3] = {
318 90.0 * degToRad,
319 210.0 * degToRad,
320 330.0 * degToRad};
321 int a0 = 0;
322 int a1 = 1;
323 switch (plane) {
324 case Plane::XY:
325 a0 = 0;
326 a1 = 1;
327 break;
328 case Plane::XZ:
329 a0 = 0;
330 a1 = 2;
331 break;
332 case Plane::YZ:
333 a0 = 1;
334 a1 = 2;
335 break;
336 }
337 std::vector<std::pair<double, FieldVector<double>>> punctures;
338 for (double angle : angles) {
339 FieldVector<double> p{0.0, 0.0, 0.0};
340 p[a0] = circumradius * std::cos(angle);
341 p[a1] = circumradius * std::sin(angle);
342 punctures.push_back({m, p});
343 }
345 }
346 };
347
358 template <class Spacetime>
360 const Spacetime& spacetime,
361 const Vector3& X
362 );
363
364} // namespace exahype2::ccz4::ahf
365
366#endif // APPARENT_HORIZON_FINDER_SPACETIMES_H_
T radius(const FieldVector< T > &X)
Euclidean radius |X| = sqrt(sum_i X_i^2); valid for real or complex T.
Definition spacetimes.h:44
FieldMatrix< T > identity()
3x3 identity in the scalar type T.
Definition spacetimes.h:49
InterpolatedGeometryData MetricData(const Spacetime &spacetime, const Vector3 &X)
Geometry derived from an analytic spacetime at the Cartesian point X, packed into the same Interpolat...
std::array< double, 3 > Vector3
Definition ahf-data.h:518
std::array< std::array< T, 3 >, 3 > FieldMatrix
Definition spacetimes.h:38
std::array< T, 3 > FieldVector
Analytic spacetimes and the geometry they induce.
Definition spacetimes.h:37
Brill-Lindquist multi-puncture initial data (time symmetric, K_ij = 0).
Definition spacetimes.h:201
FieldVector< T > beta(const FieldVector< T > &) const
Definition spacetimes.h:225
double M() const
Bare mass of the sole puncture; defined only for single-puncture slices.
Definition spacetimes.h:242
static BrillLindquist single(double m=1.0, FieldVector< double > center={0.0, 0.0, 0.0})
One puncture of mass m at center (equals Schwarzschild isotropic).
Definition spacetimes.h:283
std::vector< FieldVector< double > > puncturePositions() const
Puncture positions, in construction order.
Definition spacetimes.h:270
static BrillLindquist triangle(double m=1.0, double separation=1.5, Plane plane=Plane::XY)
Three equal punctures of mass m on an equilateral triangle of side length separation,...
Definition spacetimes.h:309
T alpha(const FieldVector< T > &) const
Definition spacetimes.h:229
static BrillLindquist binary(double m=1.0, double separation=2.0, Axis axis=Axis::Z)
Two equal punctures of mass m at +/- separation/2 along axis.
Definition spacetimes.h:291
FieldMatrix< T > gamma(const FieldVector< T > &X) const
Definition spacetimes.h:216
T psi(const FieldVector< T > &X) const
Definition spacetimes.h:204
std::vector< std::pair< double, FieldVector< double > > > punctures
Definition spacetimes.h:202
double admMass() const
Exact ADM mass sum_n m_n.
Definition spacetimes.h:232
FieldVector< double > centroid() const
Mass-weighted centroid of the punctures (natural common-horizon centre).
Definition spacetimes.h:255
Physical and geometrical quantities shared by shell and surface samples.
Definition ahf-data.h:627
Kerr in Kerr-Schild Cartesian coordinates, spin a along z.
Definition spacetimes.h:137
FieldMatrix< T > gamma(const FieldVector< T > &X) const
Definition spacetimes.h:161
T ksRadius(const FieldVector< T > &X) const
Definition spacetimes.h:141
T alpha(const FieldVector< T > &X) const
Definition spacetimes.h:182
void HandL(const FieldVector< T > &X, T &H, FieldVector< T > &l) const
Definition spacetimes.h:151
FieldVector< T > beta(const FieldVector< T > &X) const
Definition spacetimes.h:174
Schwarzschild in isotropic coordinates (time symmetric, K_ij = 0).
Definition spacetimes.h:65
T alpha(const FieldVector< T > &) const
Definition spacetimes.h:90
T psi(const FieldVector< T > &X) const
Definition spacetimes.h:68
FieldVector< T > beta(const FieldVector< T > &) const
Definition spacetimes.h:81
FieldMatrix< T > gamma(const FieldVector< T > &X) const
Definition spacetimes.h:72
Schwarzschild in Kerr-Schild coordinates (K_ij != 0, horizon at r = 2M).
Definition spacetimes.h:99
T alpha(const FieldVector< T > &X) const
Definition spacetimes.h:122
FieldVector< T > beta(const FieldVector< T > &X) const
Definition spacetimes.h:115
FieldMatrix< T > gamma(const FieldVector< T > &X) const
Definition spacetimes.h:102