Debian Codegraph @

Codes/Test/Einstein/test_kerr.C

raw
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_C[] = "$Header: /cvsroot/Lorene/Codes/Test/Einstein/test_kerr.C,v 1.5 2014/10/13 08:54:00 j_novak Exp $" ;
28
29 /*
30 * $Id: test_kerr.C,v 1.5 2014/10/13 08:54:00 j_novak Exp $
31 * $Log: test_kerr.C,v $
32 * Revision 1.5 2014/10/13 08:54:00 j_novak
33 * Lorene classes and functions now belong to the namespace Lorene.
34 *
35 * Revision 1.4 2014/10/06 15:12:52 j_novak
36 * Modified #include directives to use c++ syntax.
37 *
38 * Revision 1.3 2002/10/16 14:37:17 j_novak
39 * Reorganization of #include instructions of standard C++, in order to
40 * use experimental version 3 of gcc.
41 *
42 * Revision 1.2 2002/09/11 08:31:26 j_novak
43 * *** empty log message ***
44 *
45 * Revision 1.1 2002/09/10 13:23:19 j_novak
46 * A test code for LORENE on Kerr metric is now available.
47 *
48 *
49 * $Header: /cvsroot/Lorene/Codes/Test/Einstein/test_kerr.C,v 1.5 2014/10/13 08:54:00 j_novak Exp $
50 *
51 */
52
53 //standard
54 #include <cmath>
55
56 // Headers Lorene :
57 #include "utilitaires.h"
58 #include "param.h"
59 #include "tenseur.h"
60 #include "metrique.h"
61 #include "graphique.h"
62 #include "proto.h"
63 #include "nbr_spx.h"
64
65 using namespace Lorene ;
66
67 int main() {
68
69 double M = 1. ;
70 double a = 0.99 ;
71
72 int nz = 2 ;
73 double R = 2*M ;
74
75 // Nombre points en r
76 int nr = 21 ;
77
78 // echantillonnage en phi :
79 int* np = new int [nz] ;
80 for (int l=0 ; l<nz ; l++)
81 np[l] = 4 ;
82 int type_p = SYM ;
83
84 // echantillonnage en theta :
85 int* nt = new int [nz] ;
86 for (int l=0 ; l<nz ; l++)
87 nt[l] = 9 ;
88 int type_t = SYM ;
89
90 int* type_r = new int[nz] ;
91 type_r[0] = FIN ;
92 for (int l=1 ; l<nz ; l++)
93 type_r[l] = FIN ;
94 type_r[nz-1] = UNSURR ;
95
96 // Construction de la grille
97
98 // echantillonage en r :
99 int* nr0 = new int [nz] ;
100 for (int l=0 ; l<nz ; l++)
101 nr0[l] = nr ;
102
103 Mg3d grille (nz, nr0, type_r, nt, type_t, np, type_p) ;
104 cout << grille ;
105
106 //Construction du mapping :
107 double* bornes = new double[nz+1] ;
108 bornes[0] = R ;
109 for (int i=1 ; i<nz ; i++)
110 bornes[i] = R*double(i+nz)/double(nz) ;
111 bornes[nz] = __infinity ;
112 Map_af mapping(grille, bornes) ;
113
114 Coord& r = mapping.r ;
115 Coord& sint = mapping.sint ;
116 Coord& cost = mapping.cost ;
117 Mtbl erre(1.+M/r + (M*M - a*a)/(4*r*r)) ;
118 Mtbl rs(r + M + (M*M - a*a)/(4*r)) ;
119 Mtbl sigmasr(rs + (a*a*cost*cost)/rs) ;
120 Cmp adeux(mapping) ; Cmp bdeux(mapping) ;
121 adeux = erre*erre + (a*a*cost*cost)/(r*r) ; //Kerr dans la jauge quasi-
122 bdeux = erre*erre + a*a/(r*r) + 2*a*a*sint*sint*M/(sigmasr*r*r) ; //isotrope
123
124 Tenseur_sym gspher(mapping, 2, COV, mapping.get_bvect_spher() ) ;
125 gspher.set_etat_qcq() ;
126 for (int i=0; i<3; i++)
127 for (int j=0; j<i; j++)
128 gspher.set(i,j) = 0 ;
129 gspher.set(0,0) = adeux ;
130 gspher.set(1,1) = adeux ;
131 gspher.set(2,2) = bdeux ;
132 gspher.set_std_base() ;
133
134 Tenseur shift(mapping, 1, CON, mapping.get_bvect_spher() ) ;
135 shift.set_etat_qcq() ;
136 shift.set(0) = 0 ;
137 shift.set(1) = 0 ;
138 Cmp bphi(mapping) ;
139 bphi = 2*a*M*sint/(sigmasr*(rs*erre + a*a/r) + 2*a*a*M*sint*sint/r) ;
140 shift.set(2) = bphi ;
141 shift.set_std_base() ;
142
143 shift.change_triad(mapping.get_bvect_cart()) ;
144 shift.set_std_base() ;
145
146 Tenseur lapse(mapping) ;
147 lapse.set_etat_qcq() ;
148 Cmp enne2(mapping) ;
149 enne2 = 1 - 2*M/sigmasr +
150 1./(sigmasr*sigmasr*(rs*rs + a*a)/(4*a*a*M*M*sint*sint)
151 + sigmasr/(2*M)) ;
152 lapse.set() = sqrt(enne2 ) ;
153 lapse.set_std_base() ;
154
155 Tenseur_sym gcart(gspher) ;
156 gcart.change_triad(mapping.get_bvect_cart() ) ;
157 gcart.set_std_base() ;
158
159 Metrique gij(gcart) ;
160 Tenseur_sym plat(mapping, 2, COV, mapping.get_bvect_cart() ) ;
161 plat.set_etat_qcq() ;
162 for (int i=0; i<3; i++) {
163 for (int j=0; j<i; j++)
164 plat.set(i,j) = 0 ;
165 plat.set(i,i) = 1 ;
166 }
167 plat.set_std_base() ;
168
169 Metrique fij(plat, true) ;
170 Metconf gtilde(pow(gij.determinant(),(-1./3.))*gcart, fij) ;
171
172 cout << "----------------------" << endl ;
173 cout << "D_k(metrique conforme)" << endl ;
174 cout << "----------------------" << endl ;
175 Tenseur_sym dcov(gtilde.cov().derive_cov(gij)) ;
176 Tenseur_sym dcon(gtilde.con().derive_cov(gij)) ;
177 for (int i=0; i<3; i++)
178 for (int j=0; j<3; j++)
179 for (int k=j; k<3; k++) {
180 cout << "i, j, k: " << i << ", " << j << ", " << k << endl ;
181 cout << "Rep. covariante: " << max(abs(dcov(i,j,k))) ;
182 cout << "Rep. contravariante: " << max(abs(dcon(i,j,k))) ;
183 cout << "-----------------------------------------" << endl ;
184 }
185
186 cout << "---------------------" << endl ;
187 cout << "Norme de la trace K " << endl ;
188 cout << "---------------------" << endl ;
189 Tenseur_sym Kij(0.5*lie_derive(gij.cov(), shift)/lapse) ;
190 Tenseur tra(contract(gij.con(), 0, Kij, 0)) ;
191 Cmp trace(mapping) ; trace.set_etat_zero() ;
192 for (int i=0; i<3; i++)
193 trace += tra(i,i) ;
194 cout << norme(trace)/norme(Kij(0,0)) ;
195 arrete() ;
196
197 Tenseur trK(trace) ;
198 trK.dec_dzpuis() ;
199
200 cout << "-------------------------------" << endl ;
201 cout << "Verification du calcul de Kij " << endl ;
202 cout << "-------------------------------" << endl ;
203 Tenseur betad(manipule(shift, gij, 0)) ;
204 Tenseur dbeta(betad.derive_cov(gij)) ;
205 Tenseur ver(0.5*dbeta/lapse) ;
206 for (int i=0; i<3; i++)
207 for (int j=i; j<3; j++) {
208 cout << "i,j : " << i << ", " << j << endl ;
209 cout << norme(Kij(i,j) - ver(i,j) - ver(j,i)) ;
210 }
211 arrete() ;
212
213 cout << "**********************************************" << endl ;
214 cout << "*** Verifications des equations d'Einstein ***" << endl ;
215 cout << "*** en 3+1 ecrites avec la derivee D~ ***" << endl ;
216 cout << "**********************************************" << endl ;
217
218 cout << "-------------------------------" << endl ;
219 cout << "Membre de droite des equations " << endl ;
220 cout << " d'evolution de Kij " << endl ;
221 cout << "-------------------------------" << endl ;
222 Tenseur h13(pow(gij.determinant(), -1./3.)) ;
223 Tenseur_sym Aij(h13*Kij) ;
224 Tenseur_sym Aij_copie(Aij) ;
225 Aij_copie.dec2_dzpuis() ;
226 Tenseur_sym L1(lie_derive(Aij_copie, shift)) ;
227 L1.inc_dzpuis() ;
228 Tenseur_sym KK(contract(contract(gtilde.con(),0, Aij,1),0, Aij, 1)) ;
229 KK.dec_dzpuis() ;
230 Tenseur dN(lapse.derive_cov(gij)) ;
231 dN.dec2_dzpuis() ;
232 Tenseur_sym ddN(dN.derive_cov(gij)) ;
233 ddN.inc_dzpuis() ;
234 Tenseur_sym L2(lapse*(h13*sans_trace(gij.ricci(),gij) - 2*KK + trK*Aij)
235 + L1) ;
236 Tenseur_sym dKdt(L2 - h13*sans_trace(ddN,gij)) ;
237
238 Tenseur_sym Kij_copie(Kij) ;
239 Kij_copie.dec2_dzpuis() ;
240 Tenseur_sym L10(lie_derive(Kij_copie, shift)) ;
241 L10.inc_dzpuis() ;
242 Tenseur_sym KK0(contract(contract(gij.con(), 0, Kij, 1), 0, Kij, 0)) ;
243 KK0.dec_dzpuis() ;
244 Tenseur_sym L20(lapse*(gij.ricci() - 2*KK0 + trK*Kij) + L10) ;
245 Tenseur dN0(lapse.derive_cov(gij)) ;
246 dN0.dec2_dzpuis() ;
247 Tenseur_sym ddN0(dN0.derive_cov(gij)) ;
248 ddN0.inc_dzpuis() ;
249 ddN0 = ddN0 - L20 ;
250
251 for (int i=0; i<3; i++)
252 for (int j=i; j<3; j++) {
253 cout << "i,j: " << i << ", " << j << endl ;
254 cout << "Formulation avec ~Aij:" << max(abs(dKdt(i,j)))
255 /max(abs(L2(i,j))) ;
256 cout << "Formulation avec Kij:" <<max(abs(ddN0(i,j)))
257 /max(abs(L20(i,j))) ;
258 }
259 arrete() ;
260
261 cout << "--------------------------------" << endl ;
262 cout << "Eq. de contrainte hamiltonienne " << endl ;
263 cout << "--------------------------------" << endl ;
264 Tenseur AA(Aij.carre_scal(gtilde)) ;
265 AA.dec_dzpuis() ;
266 Tenseur Ham(gij.ricci_scal() - AA) ;
267 Ham.dec_dzpuis() ; Ham.dec2_dzpuis() ;
268 AA.dec_dzpuis() ; AA.dec2_dzpuis() ;
269 cout << max(abs(Ham()))/max(abs(AA())) ;
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 Aup.dec2_dzpuis() ;
277 Tenseur_sym dA(Aup.derive_cov(gij)) ;
278 Tenseur divA(contract(dA,0,2)) ; divA.dec2_dzpuis() ;
279 for (int i=0; i<3; i++) {
280 cout << "i:" << i << max(divA(i)) ;
281 }
282
283 delete [] np ;
284 delete [] nt ;
285 delete [] nr0 ;
286 delete [] type_r ;
287 delete [] bornes ;
288 return EXIT_SUCCESS ;
289 }
290
291
292
293
294
295