| 1 |
/* |
| 2 |
* Test code for LORENE: given the Kerr metric in quasi-isotropic |
| 3 |
* gauge, it tests it within the 3+1 formalism, in cartesian components. |
| 4 |
* |
| 5 |
*/ |
| 6 |
|
| 7 |
/* |
| 8 |
* Copyright (c) 2002 Jerome Novak |
| 9 |
* |
| 10 |
* This file is part of LORENE. |
| 11 |
* |
| 12 |
* LORENE is free software; you can redistribute it and/or modify |
| 13 |
* it under the terms of the GNU General Public License version 2 |
| 14 |
* as published by the Free Software Foundation. |
| 15 |
* |
| 16 |
* LORENE is distributed in the hope that it will be useful, |
| 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
* GNU General Public License for more details. |
| 20 |
* |
| 21 |
* You should have received a copy of the GNU General Public License |
| 22 |
* along with LORENE; if not, write to the Free Software |
| 23 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 |
* |
| 25 |
*/ |
| 26 |
|
| 27 |
char test_kerr_dbarre_C[] = "$Header: /cvsroot/Lorene/Codes/Test/Einstein/test_kerr_dbarre.C,v 1.4 2014/10/13 08:54:00 j_novak Exp $" ; |
| 28 |
|
| 29 |
/* |
| 30 |
* $Id: test_kerr_dbarre.C,v 1.4 2014/10/13 08:54:00 j_novak Exp $ |
| 31 |
* $Log: test_kerr_dbarre.C,v $ |
| 32 |
* Revision 1.4 2014/10/13 08:54:00 j_novak |
| 33 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 34 |
* |
| 35 |
* Revision 1.3 2014/10/06 15:12:52 j_novak |
| 36 |
* Modified #include directives to use c++ syntax. |
| 37 |
* |
| 38 |
* Revision 1.2 2002/10/16 14:37:18 j_novak |
| 39 |
* Reorganization of #include instructions of standard C++, in order to |
| 40 |
* use experimental version 3 of gcc. |
| 41 |
* |
| 42 |
* Revision 1.1 2002/09/11 16:11:04 j_novak |
| 43 |
* *** empty log message *** |
| 44 |
* |
| 45 |
* |
| 46 |
* $Header: /cvsroot/Lorene/Codes/Test/Einstein/test_kerr_dbarre.C,v 1.4 2014/10/13 08:54:00 j_novak Exp $ |
| 47 |
* |
| 48 |
*/ |
| 49 |
|
| 50 |
//standard |
| 51 |
#include <cmath> |
| 52 |
|
| 53 |
// Headers Lorene : |
| 54 |
#include "utilitaires.h" |
| 55 |
#include "param.h" |
| 56 |
#include "tenseur.h" |
| 57 |
#include "metconf.h" |
| 58 |
#include "graphique.h" |
| 59 |
#include "proto.h" |
| 60 |
#include "nbr_spx.h" |
| 61 |
|
| 62 |
using namespace Lorene ; |
| 63 |
|
| 64 |
int main() { |
| 65 |
|
| 66 |
double M = 1. ; |
| 67 |
double a = 0.99 ; |
| 68 |
|
| 69 |
int nz = 2 ; |
| 70 |
double R = 2*M ; |
| 71 |
|
| 72 |
// Nombre points en r |
| 73 |
int nr = 21 ; |
| 74 |
|
| 75 |
// echantillonnage en phi : |
| 76 |
int* np = new int [nz] ; |
| 77 |
for (int l=0 ; l<nz ; l++) |
| 78 |
np[l] = 4 ; |
| 79 |
int type_p = SYM ; |
| 80 |
|
| 81 |
// echantillonnage en theta : |
| 82 |
int* nt = new int [nz] ; |
| 83 |
for (int l=0 ; l<nz ; l++) |
| 84 |
nt[l] = 17 ; |
| 85 |
int type_t = SYM ; |
| 86 |
|
| 87 |
int* type_r = new int[nz] ; |
| 88 |
type_r[0] = FIN ; |
| 89 |
for (int l=1 ; l<nz ; l++) |
| 90 |
type_r[l] = FIN ; |
| 91 |
type_r[nz-1] = UNSURR ; |
| 92 |
|
| 93 |
// Construction de la grille |
| 94 |
|
| 95 |
// echantillonage en r : |
| 96 |
int* nr0 = new int [nz] ; |
| 97 |
for (int l=0 ; l<nz ; l++) |
| 98 |
nr0[l] = nr ; |
| 99 |
|
| 100 |
Mg3d grille (nz, nr0, type_r, nt, type_t, np, type_p) ; |
| 101 |
cout << grille ; |
| 102 |
|
| 103 |
//Construction du mapping : |
| 104 |
double* bornes = new double[nz+1] ; |
| 105 |
bornes[0] = R ; |
| 106 |
for (int i=1 ; i<nz ; i++) |
| 107 |
bornes[i] = R*double(i+nz)/double(nz) ; |
| 108 |
bornes[nz] = __infinity ; |
| 109 |
Map_af mapping(grille, bornes) ; |
| 110 |
|
| 111 |
Coord& r = mapping.r ; |
| 112 |
Coord& sint = mapping.sint ; |
| 113 |
Coord& cost = mapping.cost ; |
| 114 |
Mtbl erre(1.+M/r + (M*M - a*a)/(4*r*r)) ; |
| 115 |
Mtbl rs(r + M + (M*M - a*a)/(4*r)) ; |
| 116 |
Mtbl sigmasr(rs + (a*a*cost*cost)/rs) ; |
| 117 |
Cmp adeux(mapping) ; Cmp bdeux(mapping) ; |
| 118 |
adeux = erre*erre + (a*a*cost*cost)/(r*r) ; //Kerr dans la jauge quasi- |
| 119 |
bdeux = erre*erre + a*a/(r*r) + 2*a*a*sint*sint*M/(sigmasr*r*r) ; //isotrope |
| 120 |
|
| 121 |
Tenseur_sym gspher(mapping, 2, COV, mapping.get_bvect_spher() ) ; |
| 122 |
gspher.set_etat_qcq() ; |
| 123 |
for (int i=0; i<3; i++) |
| 124 |
for (int j=0; j<i; j++) |
| 125 |
gspher.set(i,j) = 0 ; |
| 126 |
gspher.set(0,0) = adeux ; |
| 127 |
gspher.set(1,1) = adeux ; |
| 128 |
gspher.set(2,2) = bdeux ; |
| 129 |
gspher.set_std_base() ; |
| 130 |
|
| 131 |
Tenseur shift(mapping, 1, CON, mapping.get_bvect_spher() ) ; |
| 132 |
shift.set_etat_qcq() ; |
| 133 |
shift.set(0) = 0 ; |
| 134 |
shift.set(1) = 0 ; |
| 135 |
Cmp bphi(mapping) ; |
| 136 |
bphi = 2*a*M*sint/(sigmasr*(rs*erre + a*a/r) + 2*a*a*M*sint*sint/r) ; |
| 137 |
shift.set(2) = bphi ; |
| 138 |
shift.set_std_base() ; |
| 139 |
|
| 140 |
shift.change_triad(mapping.get_bvect_cart()) ; |
| 141 |
shift.set_std_base() ; |
| 142 |
|
| 143 |
Tenseur lapse(mapping) ; |
| 144 |
lapse.set_etat_qcq() ; |
| 145 |
Cmp enne2(mapping) ; |
| 146 |
enne2 = 1 - 2*M/sigmasr + |
| 147 |
1./(sigmasr*sigmasr*(rs*rs + a*a)/(4*a*a*M*M*sint*sint) |
| 148 |
+ sigmasr/(2*M)) ; |
| 149 |
lapse.set() = sqrt(enne2 ) ; |
| 150 |
lapse.set_std_base() ; |
| 151 |
|
| 152 |
Tenseur_sym gcart(gspher) ; |
| 153 |
gcart.change_triad(mapping.get_bvect_cart() ) ; |
| 154 |
gcart.set_std_base() ; |
| 155 |
|
| 156 |
Metrique gij(gcart) ; |
| 157 |
Tenseur_sym plat(mapping, 2, COV, mapping.get_bvect_cart() ) ; |
| 158 |
plat.set_etat_qcq() ; |
| 159 |
for (int i=0; i<3; i++) { |
| 160 |
for (int j=0; j<i; j++) |
| 161 |
plat.set(i,j) = 0 ; |
| 162 |
plat.set(i,i) = 1 ; |
| 163 |
} |
| 164 |
plat.set_std_base() ; |
| 165 |
|
| 166 |
Metrique fij(plat, true) ; |
| 167 |
Metconf gtilde(pow(gij.determinant(),(-1./3.))*gcart, fij) ; |
| 168 |
|
| 169 |
cout << "----------------------" << endl ; |
| 170 |
cout << " Vecteur H^i " << endl ; |
| 171 |
cout << "----------------------" << endl ; |
| 172 |
for (int i=0; i<3; i++) |
| 173 |
cout << "i: " << i << " " << max(abs(gtilde.Hi()(i))) ; |
| 174 |
|
| 175 |
|
| 176 |
cout << "---------------------" << endl ; |
| 177 |
cout << "Norme de la trace K " << endl ; |
| 178 |
cout << "---------------------" << endl ; |
| 179 |
Tenseur_sym Kij(0.5*lie_derive(gij.cov(), shift)/lapse) ; |
| 180 |
Tenseur tra(contract(gij.con(), 0, Kij, 0)) ; |
| 181 |
Cmp trace(mapping) ; trace.set_etat_zero() ; |
| 182 |
for (int i=0; i<3; i++) |
| 183 |
trace += tra(i,i) ; |
| 184 |
cout << norme(trace)/norme(Kij(0,0)) ; |
| 185 |
arrete() ; |
| 186 |
|
| 187 |
cout << "**********************************************" << endl ; |
| 188 |
cout << "*** Verifications des equations d'Einstein ***" << endl ; |
| 189 |
cout << "*** en 3+1 ecrites avec la derivee Dbarre ***" << endl ; |
| 190 |
cout << "**********************************************" << endl ; |
| 191 |
|
| 192 |
cout << "-------------------------------" << endl ; |
| 193 |
cout << "Membre de droite des equations " << endl ; |
| 194 |
cout << " d'evolution de A~ij " << endl ; |
| 195 |
cout << "-------------------------------" << endl ; |
| 196 |
Tenseur h13(pow(gij.determinant(), -1./3.)) ; |
| 197 |
Tenseur_sym Aij(h13*Kij) ; |
| 198 |
Tenseur_sym Aij_copie(Aij) ; |
| 199 |
Aij_copie.dec2_dzpuis() ; |
| 200 |
Tenseur_sym L1(lie_derive(Aij_copie, shift)) ; |
| 201 |
L1.inc_dzpuis() ; |
| 202 |
Tenseur_sym KK(contract(contract(gtilde.con(),0, Aij,1),0, Aij, 1)) ; |
| 203 |
KK.dec_dzpuis() ; |
| 204 |
Tenseur dN(lapse.derive_cov(fij)) ; |
| 205 |
Tenseur dN1(dN) ; |
| 206 |
dN.dec2_dzpuis() ; |
| 207 |
dN1.dec_dzpuis() ; |
| 208 |
Tenseur_sym ddN(dN.derive_cov(fij)) ; |
| 209 |
ddN.inc_dzpuis() ; |
| 210 |
dN.inc2_dzpuis() ; |
| 211 |
Tenseur logg(log(gij.determinant())) ; |
| 212 |
logg.set_std_base() ; |
| 213 |
Tenseur dlg(logg.derive_cov(fij)) ; |
| 214 |
Tenseur dlg1(dlg) ; |
| 215 |
dlg.dec2_dzpuis() ; |
| 216 |
dlg1.dec_dzpuis() ; |
| 217 |
Tenseur ddlg(dlg.derive_cov(fij)) ; |
| 218 |
ddlg.inc_dzpuis() ; |
| 219 |
dlg.inc2_dzpuis() ; |
| 220 |
Tenseur_sym dgcov(gtilde.cov().derive_cov(fij)) ; |
| 221 |
Tenseur_sym dgcon(gtilde.con().derive_cov(fij)) ; |
| 222 |
Tenseur_sym dgcov1(dgcov) ; |
| 223 |
dgcov1.dec_dzpuis() ; |
| 224 |
dgcov.dec2_dzpuis() ; |
| 225 |
Tenseur_sym ddg(dgcov.derive_cov(fij)) ; |
| 226 |
ddg.inc_dzpuis() ; dgcov.inc2_dzpuis() ; |
| 227 |
Tenseur Hi(gtilde.Hi()) ; |
| 228 |
Hi.dec2_dzpuis() ; |
| 229 |
Tenseur dHi(Hi.derive_cov(fij)) ; |
| 230 |
Hi.inc2_dzpuis() ; dHi.inc_dzpuis() ; |
| 231 |
Tenseur_sym X1(contract(contract(gtilde.con(), 0, ddg, 0), 0, 1) + |
| 232 |
contract(gtilde.cov(), 1, dHi, 1) + |
| 233 |
contract(dHi, 1, gtilde.cov(), 1) + |
| 234 |
contract(Hi, 0, dgcov1, 0) + |
| 235 |
contract(contract(dgcon, 1, dgcov1, 0), 1, 2) + |
| 236 |
contract(contract(dgcov1, 0, dgcon, 1), 1, 3) ) ; |
| 237 |
Tenseur_sym X2(contract(contract(gtilde.delta(), 0, gtilde.delta(), 2), |
| 238 |
1, 2) ); |
| 239 |
X2.dec_dzpuis() ; |
| 240 |
Tenseur_sym X3(ddlg - 1./6.*dlg*dlg1 |
| 241 |
- contract(gtilde.delta(), 0, dlg1, 0) ) ; |
| 242 |
Tenseur_sym L2(lapse*(h13*sans_trace(-0.5*X1 - X2, gtilde) |
| 243 |
- 1./6.*h13*sans_trace(X3, gtilde) |
| 244 |
-2*KK) + L1) ; |
| 245 |
Tenseur_sym dKdt(L2 - h13*(sans_trace(ddN,gtilde) |
| 246 |
- 1./6.*sans_trace(dlg*dN1 + dN*dlg1, gtilde) |
| 247 |
- sans_trace( contract(gtilde.delta(), 0, dN1, 0), gtilde) )); |
| 248 |
|
| 249 |
for (int i=0; i<3; i++) |
| 250 |
for (int j=i; j<3; j++) { |
| 251 |
cout << "i,j: " << i << ", " << j << endl ; |
| 252 |
cout << max(abs(dKdt(i,j))) / max(abs(L2(i,j))+1.) ; |
| 253 |
} |
| 254 |
arrete() ; |
| 255 |
|
| 256 |
cout << "--------------------------------" << endl ; |
| 257 |
cout << "Eq. de contrainte hamiltonienne " << endl ; |
| 258 |
cout << "--------------------------------" << endl ; |
| 259 |
Tenseur AA(Aij.carre_scal(gtilde)) ; |
| 260 |
AA.dec_dzpuis() ; |
| 261 |
Tenseur H1(contract(contract(gtilde.con(), 0, ddlg, 0), 0, 1) + |
| 262 |
1./12.*contract(contract(gtilde.con(), 0, dlg*dlg1, 0), 0, 1) + |
| 263 |
contract(Hi, 0, dlg1, 0) ) ; |
| 264 |
Tenseur H2(contract(contract(dgcon, 1, dgcov, 1), 1, 3) -2* |
| 265 |
contract(contract(dgcon, 1, dgcov, 1), 1, 2) ) ; |
| 266 |
Tenseur H3(contract(contract(gtilde.con(), 0, H2, 0), 0, 1)) ; |
| 267 |
H3.dec_dzpuis() ; |
| 268 |
Tenseur Ham( H1 + 1.5*(contract(dHi, 0, 1) - 0.25*H3 + AA/h13) ) ; |
| 269 |
cout << max(abs(Ham()))/max(abs(H1())+1.) ; |
| 270 |
arrete() ; |
| 271 |
|
| 272 |
cout << "---------------------------------" << endl ; |
| 273 |
cout << "Eq. de contrainte impulsionnelle " << endl ; |
| 274 |
cout << "---------------------------------" << endl ; |
| 275 |
Tenseur_sym Aup(contract(contract(Aij,0,gtilde.con(),0), 0, gtilde.con(), 0)) ; |
| 276 |
Tenseur Adl(0.5*contract(Aup, 1, dlg1, 0)) ; |
| 277 |
Aup.dec2_dzpuis() ; |
| 278 |
Tenseur_sym dA(Aup.derive_cov(fij)) ; |
| 279 |
Tenseur divA(contract(dA,0,2)) ; |
| 280 |
divA.inc_dzpuis() ; |
| 281 |
Tenseur del(contract(contract(gtilde.delta(), 1, Aup, 0), 1, 2)) ; |
| 282 |
del.inc_dzpuis() ; |
| 283 |
for (int i=0; i<3; i++) { |
| 284 |
cout << "i:" << i << max(abs( divA(i) + Adl(i) + del(i))) / |
| 285 |
max(abs(divA(i))+1.) ; |
| 286 |
} |
| 287 |
arrete() ; |
| 288 |
|
| 289 |
cout << "-----------------------" << endl ; |
| 290 |
cout << "Eq. d'evolution pour K " << endl ; |
| 291 |
cout << "-----------------------" << endl ; |
| 292 |
Tenseur dK(contract(contract(gtilde.con(), 0, ddN, 0), 0, 1) + |
| 293 |
contract(Hi, 0, dN1, 0) + |
| 294 |
1./6.*contract(contract(gtilde.con(), 0, dlg1*dN, 0), 0, 1) - |
| 295 |
lapse*AA/h13) ; |
| 296 |
|
| 297 |
cout << max(abs(dK()))/max(abs(H1())+1.) ; |
| 298 |
arrete() ; |
| 299 |
|
| 300 |
cout << "-------------------------------" << endl ; |
| 301 |
cout << "Membre de droite des equations " << endl ; |
| 302 |
cout << " reliant Kij a hij " << endl ; |
| 303 |
cout << "-------------------------------" << endl ; |
| 304 |
Tenseur betad(manipule(shift, gij)) ; |
| 305 |
Tenseur_sym Lgij(2*lapse*Aij) ; |
| 306 |
Tenseur dbeta(betad.derive_cov(fij)) ; |
| 307 |
Tenseur dshift(shift.derive_cov(fij)) ; |
| 308 |
Tenseur B2(h13*(dbeta - 1./3.*dlg*betad) ) ; |
| 309 |
Tenseur_sym B3(-2*h13*contract(gtilde.delta(), 0, betad, 0) - 2./3.* |
| 310 |
contract(dshift, 0, 1)*gtilde.cov()) ; |
| 311 |
|
| 312 |
for (int i=0; i<3; i++) |
| 313 |
for (int j=i; j<3; j++) { |
| 314 |
cout << "i, j:" << i << ", " << j << endl ; |
| 315 |
B3.set(i,j) += B2(i,j) + B2(j,i) -Lgij(i,j) ; |
| 316 |
cout << max(abs(B3(i,j))) / max(abs(Aij(i,j)) + 1.) ; |
| 317 |
} |
| 318 |
|
| 319 |
delete [] np ; |
| 320 |
delete [] nt ; |
| 321 |
delete [] nr0 ; |
| 322 |
delete [] type_r ; |
| 323 |
delete [] bornes ; |
| 324 |
return EXIT_SUCCESS ; |
| 325 |
} |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|