Debian Codegraph @

Codes/Isol_hor/isolhor_spher.C

raw
1
2 /*
3 * Main code for Isolated Horizon in spherical symmetry and flat
4 * conformal metric: to test kappa = const condition
5 *
6 */
7
8 /*
9 * Copyright (c) 2004-2005 Jose Luis Jaramillo
10 * Francois limousin
11 *
12 * This file is part of LORENE.
13 *
14 * LORENE is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2
16 * as published by the Free Software Foundation.
17 *
18 * LORENE is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with LORENE; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 */
28
29 char isolhor_C[] = "$Header: /cvsroot/Lorene/Codes/Isol_hor/isolhor_spher.C,v 1.3 2014/10/13 08:53:57 j_novak Exp $" ;
30
31
32
33 // C++ headers
34 #include "headcpp.h"
35
36 // C headers
37 #include <cstdlib>
38 #include <cmath>
39 #include <cstring>
40
41 // Lorene headers
42 #include "tenseur.h"
43 #include "metric.h"
44 #include "evolution.h"
45 #include "param.h"
46 #include "nbr_spx.h"
47 #include "utilitaires.h"
48 #include "graphique.h"
49 #include "time_slice.h"
50 #include "isol_hor.h"
51
52
53 using namespace Lorene ;
54
55 int main() {
56
57 //======================================================================
58 // Construction and initialization of the various objects
59 //======================================================================
60
61 // Setup of a multi-domain grid (Lorene class Mg3d)
62 // ------------------------------------------------
63
64 int nz, nt, np, nr1, nrp1 ;
65
66 ifstream fpar("par_hor.d") ;
67 fpar.ignore(1000, '\n') ;
68 fpar.ignore(1000, '\n') ;
69 fpar >> nz; fpar.ignore(1000, '\n');
70 fpar >> nt; fpar.ignore(1000, '\n');
71 fpar >> np; fpar.ignore(1000, '\n');
72 fpar >> nr1; fpar.ignore(1000, '\n');
73 fpar >> nrp1; fpar.ignore(1000, '\n');
74
75
76 int type_t = SYM ; // symmetry with respect to the equatorial plane
77 int type_p = NONSYM ; // no symmetry in phi
78
79 // Reading of the parameter file
80 // ------------------------------
81
82 int niter, bound_nn, bound_psi, bound_beta, solve_lapse, solve_psi ;
83 int solve_shift ;
84 double radius, relax, seuil, ang_vel, boost_x, boost_z, lim_nn ;
85 fpar >> radius; fpar.ignore(1000, '\n');
86 fpar >> relax; fpar.ignore(1000, '\n');
87 fpar >> seuil; fpar.ignore(1000, '\n');
88 fpar >> niter; fpar.ignore(1000, '\n');
89 fpar >> ang_vel; fpar.ignore(1000, '\n');
90 fpar >> boost_x ;
91 fpar >> boost_z; fpar.ignore(1000, '\n');
92 fpar >> bound_nn ;
93 fpar >> lim_nn ; fpar.ignore(1000, '\n');
94 fpar >> bound_psi ; fpar.ignore(1000, '\n');
95 fpar >> bound_beta ; fpar.ignore(1000, '\n');
96 fpar >> solve_lapse ; fpar.ignore(1000, '\n');
97 fpar >> solve_psi ; fpar.ignore(1000, '\n');
98 fpar >> solve_shift ; fpar.ignore(1000, '\n');
99
100
101 int* nr_tab = new int[nz];
102 int* nt_tab = new int[nz];
103 int* np_tab = new int[nz];
104 double* bornes = new double[nz+1];
105
106 for (int l=0; l<nz; l++) {
107 if (l==1) nr_tab[1] = nr1 ;
108 else nr_tab[l] = nrp1 ;
109 np_tab[l] = np ;
110 nt_tab[l] = nt ;
111 bornes[l] = pow(2., l-1) * radius ;
112 }
113 bornes[0] = 0. ;
114 bornes[nz] = __infinity ;
115
116 // Type of r sampling :
117 int* type_r = new int[nz];
118 type_r[0] = RARE ;
119 for (int l=1; l<nz-1; l++) {
120 type_r[l] = FIN ;
121 }
122 type_r[nz-1] = UNSURR ;
123
124 // Multi-domain grid construction:
125 Mg3d mgrid(nz, nr_tab, type_r, nt_tab, type_t, np_tab, type_p) ;
126
127 Map_af mp(mgrid, bornes) ; // Mapping construction
128
129 // Denomination of various coordinates associated with the mapping
130 // ---------------------------------------------------------------
131
132 const Coord& r = mp.r ; // r field
133 const Coord& theta = mp.tet ; // r field
134 const Coord& costt = mp.cost ; // cos(theta) field
135 const Coord& sintt = mp.sint ; // sin(theta) field
136 const Coord& cospp = mp.cosp ; // cos(phi) field
137 const Coord& sinpp = mp.sinp ; // sin(phi) field
138
139 Scalar rr(mp) ;
140 rr = r ;
141 rr.std_spectral_base() ;
142
143 Scalar cos2t (mp) ;
144 cos2t = cos(2.*theta) ;
145
146 Scalar cost (mp) ;
147 cost = costt ;
148
149 Scalar cosp (mp) ;
150 cosp = cospp ;
151
152 Scalar sint (mp) ;
153 sint = sintt ;
154
155 Scalar sinp (mp) ;
156 sinp = sinpp ;
157
158 // Flat metric f
159 // -------------
160
161 const Metric_flat& ff = mp.flat_met_spher() ;
162 const Base_vect_spher& otriad = mp.get_bvect_spher() ;
163
164 // Working stuff
165 // -------------
166
167 Scalar tmp_scal(mp) ;
168 Vector tmp_vect(mp, CON, otriad) ;
169 Sym_tensor tmp_sym(mp, CON, otriad) ;
170
171 // Key function
172 Scalar unsr(1./rr) ;
173 unsr.set_domain(0) = 1 ; // scalar set to 1 in the nucleus
174 unsr.std_spectral_base() ;
175
176 Scalar expmr (exp (- 1/((rr-1)*(rr-1)))) ;
177 expmr.std_spectral_base() ;
178
179 Scalar expmrr (exp(-pow(rr-3,2.))) ;
180 expmrr.std_spectral_base() ;
181
182
183 // =================================================================
184 // =================================================================
185
186 // Physical Parameters
187 //--------------------
188
189 // Set up of lapse function N
190 // --------------------------
191
192 Scalar nn_init(mp) ;
193 nn_init = 1. - 0.5*unsr ;
194 nn_init.std_spectral_base() ; // sets standard spectral bases
195
196 // Set up of field Psi
197 // -------------------
198
199 Scalar psi_init(mp) ;
200 psi_init = 1. ; //+ 0.1*unsr ;
201 psi_init.std_spectral_base() ; // sets standard spectral bases
202
203 // Set up of shift vector beta
204 // ---------------------------
205
206 Vector beta_init(mp, CON, mp.get_bvect_spher()) ;
207 beta_init.set(1) = 0.1*unsr*unsr ;
208 beta_init.set(2) = 0. ;
209 beta_init.set(3) = 0. ;
210 beta_init.annule_domain(0) ;
211 beta_init.std_spectral_base() ;
212
213 // TrK, TrK_point
214 // --------------
215
216 Scalar trK (mp) ;
217 trK = 0*0.1*unsr*unsr ;
218 trK.std_spectral_base() ;
219 trK.inc_dzpuis(2) ;
220
221 Scalar trK_point (mp) ;
222 trK_point = 0. ;
223 trK_point.std_spectral_base() ;
224 trK_point.inc_dzpuis(2) ;
225
226 // gamt, gamt_point
227 // ----------------
228
229
230 Sym_tensor gamt(mp, COV, mp.get_bvect_spher()) ;
231
232 gamt = ff.cov() ;
233
234 Metric met_gamt (gamt) ;
235
236 // Gamma-tilde_point
237 //------------------
238
239 Scalar khi(mp) ;
240 Scalar mu(mp) ;
241
242 khi = 0. ;
243 khi.std_spectral_base() ;
244
245 mu = 0. ;
246 mu.std_spectral_base() ;
247
248 Sym_tensor_tt hh_tmp (mp, otriad, ff) ;
249 hh_tmp.set_khi_mu(khi, mu) ;
250
251 Sym_tensor gamt_point(mp, CON, mp.get_bvect_spher()) ;
252 gamt_point = hh_tmp ;
253 gamt_point.inc_dzpuis(2) ;
254
255
256 // =================================================================
257 // =================================================================
258
259 double mm, aaa, hh ;
260
261 // Set up of extrinsic curvature
262 // -----------------------------
263
264 Metric met_gam(psi_init*psi_init*psi_init*psi_init*gamt) ;
265 Sym_tensor kk_init (mp, CON, mp.get_bvect_spher()) ;
266
267 int check ;
268 check = 0 ;
269 for (int k=0; k<np_tab[1]; k++)
270 for (int j=0; j<nt_tab[1]; j++){
271 if (nn_init.val_grid_point(1, k, j , 0) < 1e-12){
272 check = 1 ;
273 break ;
274 }
275 }
276 if (check == 0)
277 kk_init = - 0.5 * met_gam.con().derive_lie(beta_init) / nn_init ;
278 else {
279 Sym_tensor kk_temp (mp, CON, mp.get_bvect_spher()) ;
280 kk_temp = - 0.5 * met_gam.con().derive_lie(beta_init) ;
281
282 Scalar nn_sxpun (division_xpun (Cmp(nn_init), 0)) ;
283 nn_sxpun.set_domain(0) = 1. ;
284
285 Scalar auxi (mp) ;
286 for (int i=1 ; i<=3 ; i++)
287 for (int j=i ; j<=3 ; j++) {
288 auxi = kk_temp(i, j) ;
289 auxi.annule_domain(0) ;
290 auxi = division_xpun (auxi, 0) ;
291 kk_init.set(i,j) = auxi / nn_sxpun ;
292 }
293 }
294
295 Sym_tensor aa_init (mp, CON, mp.get_bvect_spher()) ;
296 aa_init = psi_init*psi_init*psi_init*psi_init*kk_init
297 - 1./3. * trK * met_gamt.con() ;
298
299
300 //-------------------------------------
301 // Construction of the space-time
302 //-------------------------------------
303
304 Isol_hor isolhor(mp, nn_init, psi_init, beta_init, aa_init, met_gamt,
305 gamt_point, trK, trK_point, ff, 3) ;
306
307 // In order to initialise isolhor.k_uu() and k_dd() at the good value
308 Sym_tensor bidon (mp, CON, mp.get_bvect_spher()) ;
309 bidon = isolhor.k_uu() ;
310 Sym_tensor bidon2 (isolhor.k_dd()) ;
311 Scalar bidon3 (isolhor.aa_quad()) ;
312
313
314 //-----------------------------------------
315 // "Call to init_data.C"
316 //-----------------------------------------
317
318 isolhor.set_omega(ang_vel) ;
319
320 isolhor.init_data_spher(bound_nn, lim_nn, bound_psi, bound_beta, solve_lapse,
321 solve_psi, solve_shift, seuil, relax, niter) ;
322
323
324 // Expansion
325 //----------
326
327 Scalar expansion = contract(isolhor.gam().radial_vect().derive_cov(isolhor.gam()), 0,1)
328 + contract(contract(isolhor.k_dd(), 0, isolhor.gam().radial_vect(), 0),
329 0, isolhor.gam().radial_vect(), 0)
330 - isolhor.trk() ;
331
332 expansion.dec_dzpuis(2) ;
333
334
335 double der_expansion_0 = expansion.derive_cov(isolhor.gam())(1)
336 .val_point(1.00000001, 0, 0.) ;
337 double der_expansion_1 = expansion.derive_cov(isolhor.gam())(1)
338 .val_point(1.00000001, M_PI/4, 0.) ;
339 double der_expansion_2 = expansion.derive_cov(isolhor.gam())(1)
340 .val_point(1.00000001, M_PI/2, 0.) ;
341
342 cout << "Radial derivative of the expansion at (1,0,0) = "
343 << der_expansion_0<<endl ;
344 cout << "Radial derivative of the expansion at (1,Pi/4,0) = "
345 << der_expansion_1<<endl ;
346 cout << "Radial derivative of the expansion at (1,Pi/2,0) = "
347 << der_expansion_2<<endl ;
348 cout << "------------------------------------------------------"<<endl;
349
350
351 // des_meridian(expansion, 1, 1.2, "Expansion theta", 2) ;
352 des_meridian(expansion, 1, 4., "Expansion theta", 1) ;
353 // des_meridian(expansion, 1, 10., "Expansion theta", 3) ;
354 arrete() ;
355
356
357 double max_exp = expansion.val_grid_point(1, 0, 0, 0) ;
358 double min_exp = expansion.val_grid_point(1, 0, 0, 0) ;
359 int nnp = mp.get_mg()->get_np(1) ;
360 int nnt = mp.get_mg()->get_nt(1) ;
361 for (int k=0 ; k<nnp ; k++)
362 for (int j=0 ; j<nnt ; j++){
363 if (expansion.val_grid_point(1, k, j, 0) > max_exp)
364 max_exp = expansion.val_grid_point(1, k, j, 0) ;
365 if (expansion.val_grid_point(1, k, j, 0) < min_exp)
366 min_exp = expansion.val_grid_point(1, k, j, 0) ;
367 }
368 cout << "max_exp = " << max_exp << endl
369 << "min_kss = " << min_exp << endl ;
370
371
372 // Save in a file
373 // --------------
374
375 FILE* fresu = fopen("resu.d", "w") ;
376 mgrid.sauve(fresu) ;
377 mp.sauve(fresu) ;
378 isolhor.sauve(fresu, true) ;
379 fclose(fresu) ;
380
381 // Test of the constraints
382 //------------------------
383
384 /*
385 if (solve_shift == 1)
386 isolhor.update_aa() ;
387 else
388 isolhor.aa_kerr_ww(mm, aaa) ;
389 */
390 cout<< "----------------------------------------" <<endl ;
391
392 Tbl check_ham = isolhor.check_hamiltonian_constraint() ;
393 Tbl check_mom = isolhor.check_momentum_constraint() ;
394
395 cout<< "----------------------------------------" <<endl ;
396
397
398 // Physical parameters of the Black Hole
399 //--------------------------------------
400
401 cout<< "------------------------------------------------" <<endl;
402 cout<< " Physical parameters of the Black Hole " <<endl;
403 cout<< "------------------------------------------------" <<endl;
404
405 double rr_hor = isolhor.radius_hor() ;
406 cout<< "Radius of the horizon = " << rr_hor <<endl ;
407
408 double jj_hor = isolhor.ang_mom_hor() ;
409 cout<< "Angular momentum of the horizon = " << jj_hor <<endl ;
410
411 double mm_hor = isolhor.mass_hor() ;
412 cout<< "Mass of the horizon = " << mm_hor <<endl ;
413
414 double kappa_hor = isolhor.kappa_hor() ;
415 cout<< "Surface gravity of the horizon = " << kappa_hor <<endl ;
416
417 double omega_hor = isolhor.omega_hor() ;
418 cout<< "Orbital velocity of the horizon = " << omega_hor <<endl ;
419
420
421 // Physical parameters of the Bulk
422 //--------------------------------
423
424 cout.precision(8) ;
425 cout<< endl;
426 cout<< "------------------------------------------------" <<endl;
427 cout<< " Physical parameters of the Bulk " <<endl;
428 cout<< "------------------------------------------------" <<endl;
429
430 double mm_adm = isolhor.adm_mass() ;
431 cout << "ADM mass= " << mm_adm <<endl ;
432
433 double jj_adm = isolhor.ang_mom_adm() ;
434 cout << "ADM angular momentum= " << jj_adm <<endl ;
435
436 double aa = jj_adm / mm_adm ;
437 cout << "J / M (ADM) : " << aa << endl ;
438
439 double aasmm = aa / mm_adm ;
440 cout << "J / M^2 : " << aasmm << endl ;
441
442 double epsa = isolhor.area_hor() /
443 (8*M_PI*(mm_adm*mm_adm + pow(pow(mm_adm, 4.) - jj_adm*jj_adm, 0.5))) ;
444 cout << "epsilon A : " << epsa << endl ;
445
446 double diff_mm = (mm_adm - mm_hor) / mm_adm ;
447 cout << "diff mass : " << diff_mm << endl ;
448
449 double diff_jj = (jj_adm - jj_hor) / jj_adm ;
450 cout << "diffangular momentum : " << diff_jj << endl ;
451
452 // Writing of all global quantities in a file
453 ofstream resformat("resformat.d") ;
454 resformat.precision(6) ;
455 resformat << "# Ham. constr. Mom. constr. " << endl ;
456 resformat << max(check_ham) << " " << max(check_mom) << endl ;
457 resformat.precision(10) ;
458 resformat << "# r_hor J_hor M_hor kappa_hor omega_hor" << endl ;
459 resformat << rr_hor << " " << jj_hor << " " << mm_hor << " "
460 << kappa_hor << " " << omega_hor << endl ;
461 resformat << "# M_adm J_adm J/M J/M2 Eps_a" << endl ;
462 resformat << mm_adm << " " << jj_adm << " " << aa << " "
463 << aasmm << " " << epsa << endl ;
464 resformat << "# diff_mm diff_jj" << endl ;
465 resformat << diff_mm << " " << diff_jj << endl ;
466
467 resformat.close() ;
468
469 //--------------------------------------
470 // Comparison
471 //--------------------------------------
472
473 cout<<"Tout va bien boudiou / Todo bien!!! (Viva Cai!)"<<endl ;
474
475 return EXIT_SUCCESS ;
476 }
477
478
479
480