| 1 |
/* |
| 2 |
* Test of Metric and Connection classes through the Kerr metric |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/* |
| 7 |
* Copyright (c) 2003-2004 Eric Gourgoulhon & Jerome Novak |
| 8 |
* |
| 9 |
* This file is part of LORENE. |
| 10 |
* |
| 11 |
* LORENE is free software; you can redistribute it and/or modify |
| 12 |
* it under the terms of the GNU General Public License version 2 |
| 13 |
* as published by the Free Software Foundation. |
| 14 |
* |
| 15 |
* LORENE is distributed in the hope that it will be useful, |
| 16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
* GNU General Public License for more details. |
| 19 |
* |
| 20 |
* You should have received a copy of the GNU General Public License |
| 21 |
* along with LORENE; if not, write to the Free Software |
| 22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
char test_kerr_C[] = "$Header: /cvsroot/Lorene/Codes/Test/Metric/test_kerr.C,v 1.15 2014/10/13 08:54:01 j_novak Exp $" ; |
| 27 |
|
| 28 |
/* |
| 29 |
* $Id: test_kerr.C,v 1.15 2014/10/13 08:54:01 j_novak Exp $ |
| 30 |
* $Log: test_kerr.C,v $ |
| 31 |
* Revision 1.15 2014/10/13 08:54:01 j_novak |
| 32 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 33 |
* |
| 34 |
* Revision 1.14 2014/10/06 15:12:53 j_novak |
| 35 |
* Modified #include directives to use c++ syntax. |
| 36 |
* |
| 37 |
* Revision 1.13 2004/02/26 22:53:08 e_gourgoulhon |
| 38 |
* The Lie derivative of K along beta is now computed thanks to the |
| 39 |
* new method Sym_tensor::derive_lie. |
| 40 |
* |
| 41 |
* Revision 1.12 2004/02/19 22:13:46 e_gourgoulhon |
| 42 |
* Usage of new argument comment in Tensor::spectral_display and |
| 43 |
* in functions maxabs. |
| 44 |
* |
| 45 |
* Revision 1.11 2004/02/18 18:53:41 e_gourgoulhon |
| 46 |
* -- Trace of K now computed directly, thanks to the new |
| 47 |
* method Tensor::trace. |
| 48 |
* -- Method Tensor::scontract renamed Tensor::trace. |
| 49 |
* |
| 50 |
* Revision 1.10 2004/02/18 15:58:29 e_gourgoulhon |
| 51 |
* Double contraction K_ij K^ij in Hamiltonian constraint now handled |
| 52 |
* by the new function contract for contraction on two indices. |
| 53 |
* |
| 54 |
* Revision 1.9 2004/02/04 15:47:07 e_gourgoulhon |
| 55 |
* Changed declaration of ricci and ricci_c from "const Tensor&" to |
| 56 |
* "const Sym_tensor&". |
| 57 |
* |
| 58 |
* Revision 1.8 2004/01/29 16:07:58 e_gourgoulhon |
| 59 |
* More polishing. |
| 60 |
* |
| 61 |
* Revision 1.7 2004/01/29 15:22:47 e_gourgoulhon |
| 62 |
* Introduced call to method Tensor::divergence in momentum constraint. |
| 63 |
* Polishing. |
| 64 |
* |
| 65 |
* Revision 1.6 2004/01/28 15:28:27 e_gourgoulhon |
| 66 |
* Added tests with Cartesian components. |
| 67 |
* |
| 68 |
* Revision 1.5 2004/01/23 13:28:14 e_gourgoulhon |
| 69 |
* Scalar::set_val_hor --> Scalar::set_inner_boundary. |
| 70 |
* |
| 71 |
* Revision 1.4 2004/01/23 08:01:36 e_gourgoulhon |
| 72 |
* All Einstein equations are now verified. |
| 73 |
* |
| 74 |
* Revision 1.3 2004/01/19 16:58:49 e_gourgoulhon |
| 75 |
* Momemtum constraint OK ! |
| 76 |
* Next step: Hamiltonian constraint. |
| 77 |
* |
| 78 |
* Revision 1.2 2004/01/04 21:03:12 e_gourgoulhon |
| 79 |
* Still some improvements... |
| 80 |
* More to come... |
| 81 |
* |
| 82 |
* Revision 1.1 2003/12/30 23:11:28 e_gourgoulhon |
| 83 |
* First version: not ready yet. |
| 84 |
* |
| 85 |
* |
| 86 |
* $Header: /cvsroot/Lorene/Codes/Test/Metric/test_kerr.C,v 1.15 2014/10/13 08:54:01 j_novak Exp $ |
| 87 |
* |
| 88 |
*/ |
| 89 |
|
| 90 |
// C++ headers |
| 91 |
#include <cheadcpp> |
| 92 |
|
| 93 |
// C headers |
| 94 |
#include <cstdlib> |
| 95 |
#include <cmath> |
| 96 |
|
| 97 |
// Lorene headers |
| 98 |
#include "metric.h" |
| 99 |
#include "nbr_spx.h" |
| 100 |
#include "utilitaires.h" |
| 101 |
#include "cmp.h" |
| 102 |
#include "proto.h" |
| 103 |
|
| 104 |
using namespace Lorene ; |
| 105 |
|
| 106 |
int main() { |
| 107 |
|
| 108 |
cout << "Value of the Kerr parameter a/M ?" << endl ; |
| 109 |
double aasm ; |
| 110 |
cin >> aasm ; |
| 111 |
|
| 112 |
// Setup of a multi-domain grid (Lorene class Mg3d) |
| 113 |
// ------------------------------------------------ |
| 114 |
|
| 115 |
int nz = 4 ; // Number of domains |
| 116 |
int nzm1 = nz - 1 ; // Index of outermost domain |
| 117 |
int nr = 25 ; // Number of collocation points in r in each domain |
| 118 |
int nt = 17 ; // Number of collocation points in theta in each domain |
| 119 |
int np = 8 ; // Number of collocation points in phi in each domain |
| 120 |
int symmetry_theta = SYM ; // symmetry with respect to the equatorial plane |
| 121 |
int symmetry_phi = NONSYM ; // no symmetry in phi |
| 122 |
bool compact = true ; // external domain is compactified |
| 123 |
|
| 124 |
// Multi-domain grid construction: |
| 125 |
Mg3d mgrid(nz, nr, nt, np, symmetry_theta, symmetry_phi, compact) ; |
| 126 |
|
| 127 |
cout << mgrid << endl ; |
| 128 |
|
| 129 |
|
| 130 |
// Setup of an affine mapping : grid --> physical space (Lorene class Map_af) |
| 131 |
// -------------------------------------------------------------------------- |
| 132 |
|
| 133 |
// radial boundaries of each domain: |
| 134 |
double r_limits[] = {0., 2., 3., 6., __infinity} ; |
| 135 |
assert( nz == 4 ) ; // since the above array describes only 3 domains |
| 136 |
|
| 137 |
Map_af map(mgrid, r_limits) ; // Mapping construction |
| 138 |
|
| 139 |
cout << map << endl ; |
| 140 |
|
| 141 |
// Denomination of various coordinates associated with the mapping |
| 142 |
// --------------------------------------------------------------- |
| 143 |
|
| 144 |
const Coord& r = map.r ; // r field |
| 145 |
const Coord& cost = map.cost ; // cos(theta) field |
| 146 |
const Coord& sint = map.sint ; // sin(theta) field |
| 147 |
|
| 148 |
cout << "*********************************************************" << endl |
| 149 |
<< " Tests in spherical components" << endl |
| 150 |
<< "*********************************************************" |
| 151 |
<< endl ; |
| 152 |
|
| 153 |
// Analytic form of the Kerr metric in quasi-isotropic coordinates |
| 154 |
// --------------------------------------------------------------- |
| 155 |
|
| 156 |
// Twice the radius at the horizon: |
| 157 |
double hh = 2. * map.val_r(0, 1., 0., 0.) ; |
| 158 |
|
| 159 |
double mm = hh / sqrt(1. - aasm*aasm) ; // total mass M |
| 160 |
|
| 161 |
double aa = aasm * mm ; // angular momentum parameter a = J / M |
| 162 |
|
| 163 |
|
| 164 |
// R (Boyer-Lindquist radial coordinate): |
| 165 |
Mtbl r_bl = r + mm + (mm*mm - aa*aa) / (4*r) ; |
| 166 |
|
| 167 |
Mtbl r_blsr = 1 + mm/r + (mm*mm - aa*aa) / (4*r*r) ; // ratio R / r : |
| 168 |
|
| 169 |
Mtbl sigmasr = r_bl + (aa*aa* cost*cost) / r_bl ; // Sigma / R |
| 170 |
|
| 171 |
Scalar a2(map) ; Scalar b2(map) ; |
| 172 |
a2 = r_blsr * r_blsr + (aa*aa*cost*cost)/(r*r) ; // A^2 = Sigma^2 / r^2 |
| 173 |
|
| 174 |
b2 = r_blsr * r_blsr + aa*aa/(r*r) |
| 175 |
+ 2*aa*aa*sint*sint*mm/(sigmasr*r*r) ; // B^2 |
| 176 |
|
| 177 |
a2.set_domain(0) = 1. ; // Metric set to 1 in the nucleus |
| 178 |
b2.set_domain(0) = 1. ; // ("inside" the horizon) |
| 179 |
a2.std_spectral_base() ; |
| 180 |
b2.std_spectral_base() ; |
| 181 |
|
| 182 |
// Spatial metric |
| 183 |
// -------------- |
| 184 |
|
| 185 |
Sym_tensor gij_spher(map, COV, map.get_bvect_spher()) ; |
| 186 |
gij_spher.set(1,1) = a2 ; |
| 187 |
gij_spher.set(1,2) = 0 ; |
| 188 |
gij_spher.set(1,3) = 0 ; |
| 189 |
gij_spher.set(2,2) = a2 ; |
| 190 |
gij_spher.set(2,3) = 0 ; |
| 191 |
gij_spher.set(3,3) = b2 ; |
| 192 |
|
| 193 |
Metric gam(gij_spher) ; // construction from the covariant components |
| 194 |
|
| 195 |
cout << |
| 196 |
"Minimum val. of the covariant components of the metric in each domain: " |
| 197 |
<< endl ; |
| 198 |
min(gam.cov()) ; |
| 199 |
cout << |
| 200 |
"Maximum val. of the covariant components of the metric in each domain: " |
| 201 |
<< endl ; |
| 202 |
max(gam.cov()) ; |
| 203 |
arrete() ; |
| 204 |
|
| 205 |
Scalar tmp(map) ; // working scalar |
| 206 |
|
| 207 |
// Comparison with Schwarzschild metric in the non-rotating case |
| 208 |
// ------------------------------------------------------------- |
| 209 |
if (aasm == double(0)) { |
| 210 |
|
| 211 |
// Flat metric : |
| 212 |
const Metric_flat& fmet = map.flat_met_spher() ; |
| 213 |
|
| 214 |
// Schwarzchild metric : |
| 215 |
|
| 216 |
Scalar psi4(map) ; |
| 217 |
psi4 = pow( 1 + mm / (2*r), 4) ; // conformal factor |
| 218 |
psi4.set_domain(0) = 1 ; |
| 219 |
psi4.std_spectral_base() ; |
| 220 |
|
| 221 |
Vector dpsi4 = psi4.derive_cov( fmet ) ; |
| 222 |
tmp = - 2 * mm / (r*r) * pow( 1 + mm / (2*r), 3) ; |
| 223 |
tmp.set_domain(0) = 0 ; |
| 224 |
Vector vtmp(map, COV, map.get_bvect_spher()) ; |
| 225 |
vtmp.set(1) = tmp ; |
| 226 |
tmp = - 2 * mm * pow( 1 + mm / (2*r), 3) ; |
| 227 |
vtmp.set(1).set_domain(nzm1) = tmp.domain(nzm1) ; |
| 228 |
vtmp.set(1).set_dzpuis(2) ; |
| 229 |
vtmp.set(2) = 0 ; |
| 230 |
vtmp.set(3) = 0 ; |
| 231 |
vtmp.std_spectral_base() ; |
| 232 |
vtmp -= dpsi4 ; |
| 233 |
vtmp.spectral_display("Error on Grad(Psi^4)") ; |
| 234 |
maxabs(vtmp, "Error on Grad(Psi^4) (max absolute value in each domain)") ; |
| 235 |
arrete() ; |
| 236 |
|
| 237 |
Sym_tensor gij_schw = psi4 * fmet.cov() ; |
| 238 |
|
| 239 |
Sym_tensor diff_schw = gam.cov() - gij_schw ; |
| 240 |
maxabs(diff_schw, |
| 241 |
"Comparison with the Schwarzschild metric (max absolute error)") ; |
| 242 |
arrete() ; |
| 243 |
|
| 244 |
// Test: covariant derivative of the metric / flat metric: |
| 245 |
|
| 246 |
const Tensor& dg_cov = gam.cov().derive_cov( fmet ) ; |
| 247 |
|
| 248 |
Tensor_sym d_gij_schw = fmet.cov() * dpsi4 ; |
| 249 |
|
| 250 |
Tensor diff_dg = dg_cov - d_gij_schw ; |
| 251 |
diff_dg.spectral_display("Error on the covariant derivative of the metric / flat metric") ; |
| 252 |
maxabs(diff_dg, |
| 253 |
"Error on the covariant derivative of the metric / flat metric") ; |
| 254 |
arrete() ; |
| 255 |
|
| 256 |
} |
| 257 |
|
| 258 |
|
| 259 |
// Test: covariant derivative of the metric / itself: |
| 260 |
// -------------------------------------------------- |
| 261 |
|
| 262 |
const Tensor& dg_auto = gam.cov().derive_cov( gam ) ; |
| 263 |
|
| 264 |
cout << "\n Error on the covariant derivative of the metric / itself \n" ; |
| 265 |
cout << " (maximum absolute value in each domain) : \n" ; |
| 266 |
maxabs(dg_auto) ; |
| 267 |
arrete() ; |
| 268 |
|
| 269 |
|
| 270 |
// Lapse function |
| 271 |
// -------------- |
| 272 |
|
| 273 |
tmp = 1 - 2*mm / sigmasr |
| 274 |
+ 4*aa*aa*mm*mm* sint* sint / |
| 275 |
( sigmasr* (sigmasr * ( r_bl * r_bl + aa*aa) |
| 276 |
+ 2*aa*aa*mm* sint*sint ) ) ; |
| 277 |
tmp.set_domain(0) = 1 ; |
| 278 |
|
| 279 |
Scalar nn = sqrt(abs(tmp)) ; |
| 280 |
nn.set_inner_boundary(1, 0.) ; |
| 281 |
|
| 282 |
nn.std_spectral_base() ; |
| 283 |
|
| 284 |
min(nn, "Minimum value of the lapse N in each domain", cout) ; |
| 285 |
max(nn, "Maximum value of the lapse N in each domain", cout) ; |
| 286 |
arrete() ; |
| 287 |
|
| 288 |
// Shift vector |
| 289 |
// ------------ |
| 290 |
|
| 291 |
Scalar nphi(map) ; |
| 292 |
nphi = ( 2*aa*mm / (sigmasr * ( r_blsr * r_bl + aa*aa/r) |
| 293 |
+ 2*aa*aa*mm* sint*sint/r ) ) * sint ; |
| 294 |
nphi.annule_domain(0) ; |
| 295 |
|
| 296 |
Vector beta(map, CON, map.get_bvect_spher() ) ; |
| 297 |
beta.set(1) = 0 ; |
| 298 |
beta.set(2) = 0 ; |
| 299 |
beta.set(3) = - nphi ; |
| 300 |
beta.std_spectral_base() ; |
| 301 |
|
| 302 |
cout << "Minimum value of the shift vector beta^i in each domain : \n" ; |
| 303 |
min(beta) ; |
| 304 |
cout << "Maximum value of the shift vector beta^i in each domain : \n" ; |
| 305 |
max(beta) ; |
| 306 |
cout << endl ; |
| 307 |
|
| 308 |
Vector beta_cov = beta.down(0, gam) ; |
| 309 |
cout << "Minimum value of the covariant comp. beta_i in each domain : \n" ; |
| 310 |
min(beta_cov) ; |
| 311 |
cout << "Maximum value of the covariant comp. beta_i in each domain : \n" ; |
| 312 |
max(beta_cov) ; |
| 313 |
arrete() ; |
| 314 |
|
| 315 |
// Extrinsic curvature |
| 316 |
// ------------------- |
| 317 |
|
| 318 |
cout << "D_j beta_i : " << endl ; |
| 319 |
beta_cov.derive_cov(gam).spectral_display() ; |
| 320 |
cout << "D_j beta_i (max. absolute value in each domain) : " << endl ; |
| 321 |
maxabs(beta_cov.derive_cov(gam)) ; |
| 322 |
arrete() ; |
| 323 |
|
| 324 |
// Division of the lapse by (xi+1) (where xi is the grid radial |
| 325 |
// variable) in the first shell to get a non-vanishing quantity |
| 326 |
// at the horizon (horizon <=> xi=-1) : |
| 327 |
|
| 328 |
Scalar nn_xip1 = Scalar( division_xpun(Cmp(nn), 0) ) ; |
| 329 |
|
| 330 |
Sym_tensor kk(map, COV, map.get_bvect_spher()) ; |
| 331 |
|
| 332 |
for (int i=1; i<=3; i++) { |
| 333 |
for (int j=1; j<=i; j++) { |
| 334 |
|
| 335 |
tmp = 0.5 * ( beta_cov.derive_cov(gam)(i,j) |
| 336 |
+ beta_cov.derive_cov(gam)(j,i) ) ; |
| 337 |
|
| 338 |
cout << "## Horizon values of D_(i beta_j) component " << i |
| 339 |
<< " " << j << endl ; |
| 340 |
for (int k=0; k<mgrid.get_np(1); k++) { |
| 341 |
for (int jj=0; jj<mgrid.get_nt(1); jj++) { |
| 342 |
cout << " " << tmp.get_spectral_va()(1,k,jj,0) ; |
| 343 |
} |
| 344 |
cout << endl ; |
| 345 |
} |
| 346 |
|
| 347 |
tmp.set_inner_boundary(1, 0.) ; |
| 348 |
|
| 349 |
// Division by (xi+1) (where xi is the grid radial |
| 350 |
// variable) in the first shell to get a non-vanishing quantity |
| 351 |
// at the horizon (horizon <=> xi=-1) |
| 352 |
// and then division by N/(xi+1) to get K_{ij] : |
| 353 |
|
| 354 |
kk.set(i,j) = Scalar( division_xpun(Cmp(tmp), 0) ) / nn_xip1 ; |
| 355 |
|
| 356 |
} |
| 357 |
} |
| 358 |
arrete() ; |
| 359 |
|
| 360 |
cout << "Extrinsic curvature : " << endl ; |
| 361 |
kk.spectral_display() ; |
| 362 |
cout << |
| 363 |
"Extrinsic curvature K_{ij} (max. absolute value in each domain) : \n" ; |
| 364 |
maxabs(kk) ; |
| 365 |
|
| 366 |
// Trace of K |
| 367 |
// ---------- |
| 368 |
|
| 369 |
Scalar trkk = kk.trace(gam) ; |
| 370 |
cout << "Trace of K (max. absolute value in each domain) :" << endl ; |
| 371 |
maxabs(trkk) ; |
| 372 |
|
| 373 |
// Test: |
| 374 |
Scalar div_beta = beta.divergence(gam) ; |
| 375 |
cout << "Divergence of beta (max. absolute value in each domain) :\n" ; |
| 376 |
maxabs(div_beta) ; |
| 377 |
|
| 378 |
tmp = nn * trkk - div_beta ; |
| 379 |
cout << "N K - div(beta) (max. absolute value in each domain) : \n" ; |
| 380 |
maxabs(tmp) ; |
| 381 |
|
| 382 |
arrete() ; |
| 383 |
|
| 384 |
// Momentum constraint |
| 385 |
// ------------------- |
| 386 |
|
| 387 |
Tensor kk_du = kk.up(1, gam) ; |
| 388 |
Vector mom_constr = kk_du.divergence(gam) - trkk.derive_cov(gam) ; |
| 389 |
|
| 390 |
cout << "Momentum constraint : " << endl ; |
| 391 |
mom_constr.spectral_display() ; |
| 392 |
cout << "Momentum constraint (max absolute error in each domain): " << endl ; |
| 393 |
maxabs(mom_constr) ; |
| 394 |
|
| 395 |
const Tensor& dkk = kk_du.derive_cov(gam) ; |
| 396 |
mom_constr = dkk.trace(1,2) - trkk.derive_cov(gam) ; |
| 397 |
cout << "Momentum constraint by direct computation of divergence\n " |
| 398 |
<< " (max absolute error in each domain) : " << endl ; |
| 399 |
maxabs(mom_constr) ; |
| 400 |
|
| 401 |
|
| 402 |
arrete() ; |
| 403 |
|
| 404 |
// Hamiltonian constraint |
| 405 |
// ---------------------- |
| 406 |
|
| 407 |
const Scalar& ricci_scal = gam.ricci_scal() ; |
| 408 |
|
| 409 |
cout << "Ricci scalar : " << endl ; |
| 410 |
ricci_scal.spectral_display() ; |
| 411 |
maxabs(ricci_scal) ; |
| 412 |
|
| 413 |
Tensor kk_uu = kk_du.up(0, gam) ; |
| 414 |
|
| 415 |
tmp = trkk * trkk - contract(kk, 0, 1, kk_uu, 0, 1) ; |
| 416 |
|
| 417 |
tmp.dec_dzpuis() ; |
| 418 |
|
| 419 |
Scalar ham_constr = ricci_scal + tmp ; |
| 420 |
|
| 421 |
cout << "Hamiltonian constraint : " << endl ; |
| 422 |
ham_constr.spectral_display() ; |
| 423 |
cout << "Hamiltonian constraint (max absolute error in each domain): " << endl ; |
| 424 |
maxabs(ham_constr) ; |
| 425 |
arrete() ; |
| 426 |
|
| 427 |
// ham_constr.visu_section('y', 0., 0., 5., 0., 5., "Ham. constr.") ; |
| 428 |
|
| 429 |
// Dynamical Einstein equations |
| 430 |
//----------------------------- |
| 431 |
|
| 432 |
const Sym_tensor& ricci = gam.ricci() ; |
| 433 |
|
| 434 |
Sym_tensor dyn1 = - (nn.derive_cov(gam)).derive_cov(gam) ; |
| 435 |
|
| 436 |
Sym_tensor dyn2 = nn * ricci ; |
| 437 |
|
| 438 |
Sym_tensor dyn3 = nn * ( trkk * kk - 2 * contract(kk_du, 1, kk, 0) ) ; |
| 439 |
dyn3.dec_dzpuis() ; |
| 440 |
|
| 441 |
Sym_tensor dyn4 = kk.derive_lie(beta) ; // Lie derivative of K along beta |
| 442 |
|
| 443 |
Sym_tensor dyn_einstein = dyn1 + dyn2 + dyn3 + dyn4; |
| 444 |
|
| 445 |
cout << "Dynamical Einstein equations:" << endl ; |
| 446 |
dyn_einstein.spectral_display() ; |
| 447 |
cout << "Dynamical Einstein equations (max absolute error in each domain): " << endl ; |
| 448 |
maxabs(dyn_einstein) ; |
| 449 |
|
| 450 |
cout << "maxabs(dyn1) : " << endl ; |
| 451 |
maxabs(dyn1) ; |
| 452 |
cout << "maxabs(dyn2) : " << endl ; |
| 453 |
maxabs(dyn2) ; |
| 454 |
cout << "maxabs(dyn3) : " << endl ; |
| 455 |
maxabs(dyn3) ; |
| 456 |
cout << "maxabs(dyn4) : " << endl ; |
| 457 |
maxabs(dyn4) ; |
| 458 |
|
| 459 |
cout << "Dynamical Einstein equations (relative error in each domain): " << endl ; |
| 460 |
diffrel(dyn2+dyn3+dyn4, -dyn1) ; |
| 461 |
arrete() ; |
| 462 |
|
| 463 |
//==============================================================// |
| 464 |
// Tests in Cartesian components // |
| 465 |
//==============================================================// |
| 466 |
|
| 467 |
cout << "*********************************************************" << endl |
| 468 |
<< " Tests in Cartesian components" << endl |
| 469 |
<< "*********************************************************" |
| 470 |
<< endl ; |
| 471 |
|
| 472 |
Sym_tensor gij_cart = gam.cov() ; |
| 473 |
gij_cart.change_triad( map.get_bvect_cart() ) ; |
| 474 |
|
| 475 |
Metric gam_c(gij_cart) ; // construction from the covariant components |
| 476 |
|
| 477 |
cout << "Metric in Cartesian components : \n" ; |
| 478 |
gam_c.cov().spectral_display() ; |
| 479 |
arrete() ; |
| 480 |
|
| 481 |
Vector beta_c = beta ; |
| 482 |
beta_c.change_triad( map.get_bvect_cart() ) ; |
| 483 |
|
| 484 |
cout << "Shift vector in Cartesian components : \n" ; |
| 485 |
beta_c.spectral_display() ; |
| 486 |
arrete() ; |
| 487 |
|
| 488 |
// Extrinsic curvature in Cartesian components |
| 489 |
// ------------------------------------------- |
| 490 |
|
| 491 |
Vector beta_c_cov = beta_c.down(0, gam_c) ; |
| 492 |
cout << "beta_c_cov : " << endl ; |
| 493 |
maxabs(beta_c_cov) ; |
| 494 |
arrete() ; |
| 495 |
|
| 496 |
Sym_tensor kk_c(map, COV, map.get_bvect_cart()) ; |
| 497 |
|
| 498 |
for (int i=1; i<=3; i++) { |
| 499 |
for (int j=1; j<=i; j++) { |
| 500 |
|
| 501 |
tmp = 0.5 * ( beta_c_cov.derive_cov(gam_c)(i,j) |
| 502 |
+ beta_c_cov.derive_cov(gam_c)(j,i) ) ; |
| 503 |
|
| 504 |
|
| 505 |
cout << "## Horizon values of D_(i beta_j) component " << i |
| 506 |
<< " " << j << endl ; |
| 507 |
|
| 508 |
for (int k=0; k<mgrid.get_np(1); k++) { |
| 509 |
for (int jj=0; jj<mgrid.get_nt(1); jj++) { |
| 510 |
cout << " " << tmp.get_spectral_va()(1,k,jj,0) ; |
| 511 |
} |
| 512 |
cout << endl ; |
| 513 |
} |
| 514 |
|
| 515 |
// tmp.set_inner_boundary(1, 0.) ; |
| 516 |
|
| 517 |
kk_c.set(i,j) = Scalar( division_xpun(Cmp(tmp), 0) ) / nn_xip1 ; |
| 518 |
|
| 519 |
} |
| 520 |
} |
| 521 |
arrete() ; |
| 522 |
|
| 523 |
cout << "Extrinsic curvature (Cartesian components) : " << endl ; |
| 524 |
kk_c.spectral_display() ; |
| 525 |
cout << "Extrinsic curvature K_{ij} \n" << |
| 526 |
" (max. absolute value of Cartesian components in each domain) : \n" ; |
| 527 |
maxabs(kk_c) ; |
| 528 |
|
| 529 |
// Test : |
| 530 |
Sym_tensor kk_test = kk ; |
| 531 |
kk_test.change_triad( map.get_bvect_cart() ) ; |
| 532 |
cout << "Relative error on the Cartesian components of K_{ij}: \n" ; |
| 533 |
diffrelmax(kk_c, kk_test) ; |
| 534 |
arrete() ; |
| 535 |
|
| 536 |
// Trace of K |
| 537 |
// ---------- |
| 538 |
|
| 539 |
Scalar trkk_c = kk_c.trace(gam_c) ; |
| 540 |
cout << "Trace of K:" << endl ; |
| 541 |
maxabs(trkk_c) ; |
| 542 |
|
| 543 |
// Test: |
| 544 |
Scalar div_beta_c = beta_c.divergence(gam_c) ; |
| 545 |
cout << "Divergence of beta:\n" ; |
| 546 |
maxabs(div_beta_c) ; |
| 547 |
|
| 548 |
tmp = nn * trkk_c - div_beta_c ; |
| 549 |
cout << "N K - div(beta): \n" ; |
| 550 |
maxabs(tmp) ; |
| 551 |
|
| 552 |
arrete() ; |
| 553 |
|
| 554 |
// Momentum constraint |
| 555 |
// ------------------- |
| 556 |
|
| 557 |
Tensor kk_du_c = kk_c.up(1, gam_c) ; |
| 558 |
Vector mom_constr_c = kk_du_c.divergence(gam_c) - trkk_c.derive_cov(gam_c) ; |
| 559 |
|
| 560 |
cout << "Momentum constraint (Cart.) : " << endl ; |
| 561 |
mom_constr_c.spectral_display() ; |
| 562 |
cout << "Momentum constraint (Cart.) (max absolute error in each domain): " << endl ; |
| 563 |
maxabs(mom_constr_c) ; |
| 564 |
|
| 565 |
const Tensor& dkk_c = kk_du_c.derive_cov(gam_c) ; |
| 566 |
mom_constr_c = dkk_c.trace(1,2) - trkk_c.derive_cov(gam_c) ; |
| 567 |
|
| 568 |
cout << "Momentum constraint (Cart.) by direct computation of divergence \n" |
| 569 |
<< " (max absolute error in each domain) : " << endl ; |
| 570 |
maxabs(mom_constr_c) ; |
| 571 |
arrete() ; |
| 572 |
|
| 573 |
// Hamiltonian constraint |
| 574 |
// ---------------------- |
| 575 |
|
| 576 |
const Scalar& ricci_scal_c = gam_c.ricci_scal() ; |
| 577 |
|
| 578 |
cout << "Ricci scalar (Cart) : " << endl ; |
| 579 |
ricci_scal_c.spectral_display() ; |
| 580 |
maxabs(ricci_scal_c) ; |
| 581 |
|
| 582 |
Tensor kk_uu_c = kk_du_c.up(0, gam_c) ; |
| 583 |
|
| 584 |
tmp = trkk_c * trkk_c - contract(kk_c, 0, 1, kk_uu_c, 0, 1) ; |
| 585 |
|
| 586 |
tmp.dec_dzpuis() ; |
| 587 |
|
| 588 |
Scalar ham_constr_c = ricci_scal_c + tmp ; |
| 589 |
|
| 590 |
cout << "Hamiltonian constraint (Cart) : " << endl ; |
| 591 |
ham_constr_c.spectral_display() ; |
| 592 |
cout << "Hamiltonian constraint (max absolute error in each domain): " << endl ; |
| 593 |
maxabs(ham_constr_c) ; |
| 594 |
arrete() ; |
| 595 |
|
| 596 |
// Dynamical Einstein equations |
| 597 |
//----------------------------- |
| 598 |
|
| 599 |
const Sym_tensor& ricci_c = gam_c.ricci() ; |
| 600 |
|
| 601 |
// Test : |
| 602 |
Sym_tensor ricci_test = ricci ; |
| 603 |
ricci_test.change_triad( map.get_bvect_cart() ) ; |
| 604 |
cout << "Relative error on the Cartesian components of Ricci: \n" ; |
| 605 |
diffrelmax(ricci_c, ricci_test) ; |
| 606 |
arrete() ; |
| 607 |
|
| 608 |
Sym_tensor dyn1_c = - (nn.derive_cov(gam_c)).derive_cov(gam_c) ; |
| 609 |
|
| 610 |
Sym_tensor dyn2_c = nn * ricci_c ; |
| 611 |
|
| 612 |
Sym_tensor dyn3_c = nn * ( trkk_c * kk_c |
| 613 |
- 2 * contract(kk_du_c, 1, kk_c, 0) ) ; |
| 614 |
dyn3_c.dec_dzpuis() ; |
| 615 |
|
| 616 |
Sym_tensor dyn4_c = kk_c.derive_lie(beta_c) ; // Lie derivative of K along beta: |
| 617 |
|
| 618 |
Sym_tensor dyn_einstein_c = dyn1_c + dyn2_c + dyn3_c + dyn4_c ; |
| 619 |
|
| 620 |
cout << "Dynamical Einstein equations:" << endl ; |
| 621 |
dyn_einstein_c.spectral_display() ; |
| 622 |
cout << "Dynamical Einstein equations (max absolute error in each domain): " << endl ; |
| 623 |
maxabs(dyn_einstein_c) ; |
| 624 |
|
| 625 |
cout << "maxabs(dyn1_c) : " << endl ; |
| 626 |
maxabs(dyn1_c) ; |
| 627 |
cout << "maxabs(dyn2_c) : " << endl ; |
| 628 |
maxabs(dyn2_c) ; |
| 629 |
cout << "maxabs(dyn3_c) : " << endl ; |
| 630 |
maxabs(dyn3_c) ; |
| 631 |
cout << "maxabs(dyn4_c) : " << endl ; |
| 632 |
maxabs(dyn4_c) ; |
| 633 |
|
| 634 |
cout << "Dynamical Einstein equations (relative error in each domain): " << endl ; |
| 635 |
diffrel(dyn2_c+dyn3_c+dyn4_c, -dyn1_c) ; |
| 636 |
|
| 637 |
return EXIT_SUCCESS ; |
| 638 |
|
| 639 |
} |