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