Debian Codegraph @

Codes/App_hor/kerrschild_ah.C

raw
1 /*
2 * Test of the AH finder on Kerr-Schild metric
3 *
4 * (see file ah_finder.h for documentation).
5 *
6 */
7
8 /*
9 * Copyright (c) 2005 Lap-Ming Lin & 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 kerrschild_ah_C[] = "$Header: /cvsroot/Lorene/Codes/App_hor/kerrschild_ah.C,v 1.7 2014/10/13 08:53:52 j_novak Exp $" ;
29
30 /*
31 * $Id: kerrschild_ah.C,v 1.7 2014/10/13 08:53:52 j_novak Exp $
32 * $Log: kerrschild_ah.C,v $
33 * Revision 1.7 2014/10/13 08:53:52 j_novak
34 * Lorene classes and functions now belong to the namespace Lorene.
35 *
36 * Revision 1.6 2014/10/06 15:09:40 j_novak
37 * Modified #include directives to use c++ syntax.
38 *
39 * Revision 1.5 2012/01/02 13:52:57 j_novak
40 * New parameter 'verbose' to get less output if needed.
41 *
42 * Revision 1.4 2006/05/30 13:06:13 n_vasset
43 * Implemented function P_COSSIN_I in base_val_phi_funct.C
44 *
45 * Revision 1.3 2005/12/07 11:11:46 lm_lin
46 *
47 * Add option to turn off screen output during iterations.
48 *
49 * Revision 1.2 2005/11/17 14:27:51 lm_lin
50 *
51 * Modified according to the latest changes in the AH finder.
52 *
53 * Revision 1.1 2005/10/13 08:53:22 j_novak
54 * Main program to test the apparent horizon finder.
55 *
56 *
57 * $Header: /cvsroot/Lorene/Codes/App_hor/kerrschild_ah.C,v 1.7 2014/10/13 08:53:52 j_novak Exp $
58 *
59 */
60
61 // C headers
62 #include <cmath>
63
64 // Lorene headers
65 #include "app_hor.h"
66 #include "nbr_spx.h"
67 #include "utilitaires.h"
68 #include "graphique.h"
69
70
71 using namespace Lorene ;
72
73 int main() {
74
75 const int nz = 3 ; // Number of domains
76 int nr = 17 ; // Number of collocation points in r in each domain
77 int nt = 17 ; // Number of collocation points in theta in each domain
78 int np = 4 ; // 4 points in phi for rotation to/from cartesian components
79
80 int symmetry_theta = SYM ; // symmetry w.r.t. the equatoial plane
81 // ##Bug report: symmetry_theta=NONSYM does not work correctly!
82 // (related to change_triad....)
83 int symmetry_phi = SYM ; // symmetry in phi
84
85 int nbr[] = {nr, nr, nr} ;
86 int nbt[] = {nt, nt, nt} ;
87 int nbp[] = {np, np, np} ;
88
89 int type_r_std[] = {FIN, FIN, UNSURR} ; // sampling for the standard mapping
90 int type_r_2[] = {FIN, FIN, FIN} ; // sampling for the 2nd mapping
91
92 // Construct 3D grid for the standard mapping (with nucleus)
93 Mg3d mgrid(nz, nbr, type_r_std, nbt, symmetry_theta, nbp, symmetry_phi) ;
94
95
96 // Construct 3D grid for the 2nd mapping (without nucleus)
97 // The apparent horizon is defined on the 2nd mapping
98 Mg3d mgrid_2(nz, nbr, type_r_2, nbt, symmetry_theta, nbp, symmetry_phi) ;
99
100
101 // Construct angular grid for h(theta,phi)
102 const Mg3d& g_angu = *mgrid_2.get_angu() ;
103
104 // orig_lim_1(2) is used to cut out the singular region....
105 // note: For the purpose of interpolating the metric defined on the 1st mapping to
106 // that on the 2nd one, you must choose orig_lim_2 >= orig_lim_1
107 double orig_lim_1 = 0.55 ;
108 double orig_lim_2 = 0.55 ;
109
110 double r_limits_std[] = {orig_lim_1, 1.5, 3.5, __infinity} ; // for the 1st mapping
111 double r_limits_2[] = {orig_lim_2, 1., 2., 3.} ; // for the 2nd mapping
112 //note: the outer boundary of the 2nd mapping should not be in the compactified domain
113 // of the 1st mapping (for the purpose of interpolation)
114
115
116 // Standard mapping
117 Map_af map(mgrid, r_limits_std) ;
118
119 // 2nd mapping
120 Map_af map_2(mgrid_2, r_limits_2) ;
121
122 const Base_vect_spher& bspher = map.get_bvect_spher() ;
123 const Base_vect_spher& bspher2 = map_2.get_bvect_spher() ;
124
125 // Some helpful stuff...
126 // const Coord& rr = map_2.r ;
127 const Coord& theta = map_2.tet ;
128 const Coord& phi = map_2.phi ;
129 const Coord& costh = map_2.cost ;
130 const Coord& cosph = map_2.cosp ;
131 const Coord& sinth = map_2.sint ;
132 const Coord& sinph = map_2.sinp ;
133
134
135 // User's input of \gamma_{ij} & K_{ij}
136 Sym_tensor gam_dd_in(map, COV, bspher) ;
137 Sym_tensor k_dd_in(map, COV, bspher) ;
138
139 // The \gamma_{ij} & K_{ij} defined on the 2nd mapping
140 Sym_tensor gam_dd(map_2, COV, bspher2) ;
141 Sym_tensor k_dd(map_2, COV, bspher2) ;
142
143
144
145 //Parameters to control the iteration
146
147 bool verbose = true ;
148 bool print = true ;
149 double tol = 1.e-10 ;
150 double tol_exp = 1.e-8 ;
151 int it_max = 100 ;
152 int it_relax = 100 ;
153 double relax_fac = 1. ;
154
155 // Parameters for the initial guess to the 2-surface h
156 // "aa=bb=cc=R" corresponds to a sphere of radius R (usually good enough)
157 // If you want aa != bb, remember to set "symmetry_phi = NONSYM"
158 double aa = 1.5 ;
159 double bb = 1.5 ;
160 double cc = 1.5 ;
161
162
163 // Parameters for the analytic model input:
164
165 double mass = 0.5 ;
166 double kerr_a = 0.3 ;
167
168
169 Valeur h_correct(g_angu) ; // Analytic result h(\theta,phi) for comparison
170 h_correct.annule_hard() ;
171
172
173
174 //***** Kerr-Schild data (original Cartesian form) ********//
175
176
177 const Coord& xx = map.x ;
178 const Coord& yy = map.y ;
179 const Coord& zz = map.z ;
180 const Coord& rr1 = map.r ;
181
182 Scalar x(map) ;
183 x = xx ;
184
185 Scalar y(map) ;
186 y = yy ;
187
188 Scalar z(map) ;
189 z = zz ;
190
191 Scalar r_rho(map) ;
192 r_rho = rr1 ;
193
194
195 // Define Boyer-Lindquist radial coordinate
196 Scalar rbl(map) ;
197 rbl = 0.5*(r_rho*r_rho - kerr_a*kerr_a) +
198 sqrt( 0.25*pow(r_rho*r_rho - kerr_a*kerr_a , 2) + kerr_a*kerr_a*z*z ) ;
199
200 rbl = sqrt(rbl) ;
201 rbl.std_spectral_base() ;
202
203
204 Scalar hhh(map) ;
205 hhh = mass*pow(rbl,3) / ( pow(rbl,4) + kerr_a*kerr_a*z*z ) ;
206 hhh.std_spectral_base() ;
207
208
209 // Define Ingoing null vector
210 const Base_vect_cart& bcart = map.get_bvect_cart() ; //Cartesian base vector
211
212 Vector lmu(map, COV, bcart) ;
213
214 lmu.set(1) = (rbl*x + kerr_a*y) / (rbl*rbl + kerr_a*kerr_a) ;
215 lmu.set(2) = (rbl*y - kerr_a*x) / (rbl*rbl + kerr_a*kerr_a) ;
216 lmu.set(3) = z / rbl ;
217 lmu.std_spectral_base() ;
218
219
220 // Lapse
221 Scalar lapse(map) ;
222
223 lapse = pow( 1. + 2.*hhh , -0.5 ) ;
224 lapse.std_spectral_base() ;
225
226
227 //Shift
228 Vector beta(map, COV, bcart) ;
229
230 beta.set(1) = 2.*hhh*lmu.set(1) ;
231 beta.set(2) = 2.*hhh*lmu.set(2) ;
232 beta.set(3) = 2.*hhh*lmu.set(3) ;
233 beta.std_spectral_base() ;
234
235
236 // Define 3-metric (in cartesian basis)
237
238 Sym_tensor g_tmp(map, COV, bcart) ;
239
240 g_tmp.set(1,1) = 1. + 2.*hhh*lmu.set(1)*lmu.set(1) ;
241 g_tmp.set(1,2) = 2.*hhh*lmu.set(1)*lmu.set(2) ;
242 g_tmp.set(1,3) = 2.*hhh*lmu.set(1)*lmu.set(3) ;
243 g_tmp.set(2,2) = 1. + 2.*hhh*lmu.set(2)*lmu.set(2) ;
244 g_tmp.set(2,3) = 2.*hhh*lmu.set(2)*lmu.set(3) ;
245 g_tmp.set(3,3) = 1. + 2.*hhh*lmu.set(3)*lmu.set(3) ;
246
247 g_tmp.std_spectral_base() ;
248
249
250 //Change to spherical orthonormal basis
251
252 g_tmp.change_triad(bspher) ;
253 beta.change_triad(bspher) ;
254
255 gam_dd_in = g_tmp ;
256
257 const Metric gam_met(g_tmp) ;
258
259 k_dd_in = 0.5*beta.ope_killing(gam_met) / lapse ;
260
261 gam_dd_in.std_spectral_base() ;
262 k_dd_in.std_spectral_base() ;
263
264 // Done with input data
265
266
267 //-------------------------------------------------------------
268 // Calculate the analytic AH surface for Kerr-Schild data
269
270 Scalar ct(map_2) ;
271 ct = costh ;
272 ct.std_spectral_base() ;
273
274 Scalar st(map_2) ;
275 st = sinth ;
276 st.std_spectral_base() ;
277
278 Scalar cp(map_2) ;
279 cp = cosph ;
280 cp.std_spectral_base() ;
281
282 Scalar sp(map_2) ;
283 sp = sinph ;
284 sp.std_spectral_base() ;
285
286
287 Scalar h_tmp(map_2) ;
288
289 double r_analy = mass + sqrt( mass*mass - kerr_a*kerr_a ) ;
290
291
292 h_tmp = st*st / ( r_analy*r_analy + kerr_a*kerr_a ) + ct*ct/(r_analy*r_analy) ;
293 h_tmp = 1./ sqrt( h_tmp ) ;
294
295 h_tmp.std_spectral_base() ;
296
297
298 for (int l=0; l<nz; l++) {
299 for (int k=0; k<np; k++) {
300 for (int j=0; j<nt; j++) {
301 for (int i=0; i<nr; i++) {
302
303 h_correct.set(l,k,j,0) = h_tmp.val_grid_point(l,k,j,i) ;
304
305 }
306 }
307 }
308 }
309
310 h_correct.std_base_scal() ;
311
312
313 // End calculate the correct AH surface
314 //-------------------------------------------------------------
315
316 //******** End Kerr-Schild data (original Cartesian form) *********//
317
318
319 // Interpolate the input data from the mapping "map" to "map_2"
320 // on which the apparent horizon is to be found.
321 // Interpolate gam_dd_in (k_dd_in) to gam_dd (k_dd)
322 // (This part is to be removed later.....)
323
324 k_dd_in.dec_dzpuis(2) ; //The dzpuis of the Scalar to be imported
325 //must be zero!
326
327 gam_dd.set(1,1).import( gam_dd_in.set(1,1) ) ;
328 gam_dd.set(1,2).import( gam_dd_in.set(1,2) ) ;
329 gam_dd.set(1,3).import( gam_dd_in.set(1,3) ) ;
330 gam_dd.set(2,2).import( gam_dd_in.set(2,2) ) ;
331 gam_dd.set(2,3).import( gam_dd_in.set(2,3) ) ;
332 gam_dd.set(3,3).import( gam_dd_in.set(3,3) ) ;
333 gam_dd.std_spectral_base() ;
334
335 Metric gamma(gam_dd) ; // Set up the 3-metric
336
337 k_dd.set(1,1).import( k_dd_in.set(1,1) ) ;
338 k_dd.set(1,2).import( k_dd_in.set(1,2) ) ;
339 k_dd.set(1,3).import( k_dd_in.set(1,3) ) ;
340 k_dd.set(2,2).import( k_dd_in.set(2,2) ) ;
341 k_dd.set(2,3).import( k_dd_in.set(2,3) ) ;
342 k_dd.set(3,3).import( k_dd_in.set(3,3) ) ;
343 k_dd.std_spectral_base() ;
344
345 k_dd_in.inc_dzpuis(2) ; //Increase the dzpuis of k_dd_in back to two
346
347 // End importing data
348
349
350 // Call the AH finder (return the 2-surface h & expansion function)
351
352 Valeur h(g_angu) ; // 2-surface of the apparent horizon
353 h.annule_hard() ;
354 Scalar exp_fcn(map_2) ; // expansion function
355
356
357 cout << " AH flag = "
358 << ah_finder(gamma, k_dd, h, exp_fcn, aa, bb, cc, verbose,
359 print, tol, tol_exp, it_max, it_relax, relax_fac) << endl ;
360
361
362 // Test and analysis.....
363
364 cout << "########################" << endl ;
365 cout << "Done with the AH finder" << endl ;
366 cout << "########################" << endl ;
367 cout << " " << endl ;
368 cout << "Print the 2-surface h(theta,phi) of the apparent horizon" << endl ;
369 cout << h(0) << endl ;
370
371 cout << "########################" << endl ;
372 cout << " Print (h_analytic - h) / h_analytic " << endl ;
373 cout << ( h_correct(0) - h(0) ) / h_correct(0) << endl ;
374
375
376 exp_fcn.std_spectral_base() ;
377
378 Valeur exp_AH(g_angu) ; // expansion function evaluated on the apparent
379 // horizon (which should be zero)
380 exp_AH.annule_hard() ;
381
382 for (int l=0; l<nz; l++) {
383 for (int k=0; k<np; k++) {
384 for (int j=0; j<nt; j++) {
385
386 exp_AH.set(l,k,j,0) = exp_fcn.val_point(h(l,k,j,0),(+theta)(l,k,j,0)
387 ,(+phi)(l,k,j,0)) ;
388 }
389 }
390 }
391
392 cout << "##############################################" << endl ;
393 cout << "Test: evaluate the expansion function on the apparent horizon " << endl ;
394 cout << " " << endl ;
395
396 cout << exp_AH(0) << endl ;
397
398 des_profile(exp_fcn, orig_lim_2, 2., 0., 0.) ;
399
400
401 } // End main
402
403