Debian Codegraph @

C++/Source/Binary/binary_dirac.C

raw
1 /*
2 * Methods of Bin_star::dirac_gauge
3 *
4 * (see file star.h for documentation)
5 *
6 */
7
8 /*
9 * Copyright (c) 2005 Francois Limousin
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 as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
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 binary_dirac_C[] = "$Header: /cvsroot/Lorene/C++/Source/Binary/binary_dirac.C,v 1.3 2014/10/13 08:52:44 j_novak Exp $" ;
30
31 /*
32 * $Id: binary_dirac.C,v 1.3 2014/10/13 08:52:44 j_novak Exp $
33 * $Log: binary_dirac.C,v $
34 * Revision 1.3 2014/10/13 08:52:44 j_novak
35 * Lorene classes and functions now belong to the namespace Lorene.
36 *
37 * Revision 1.2 2006/04/11 14:25:15 f_limousin
38 * New version of the code : improvement of the computation of some
39 * critical sources, estimation of the dirac gauge, helical symmetry...
40 *
41 * Revision 1.1 2005/11/08 20:17:01 f_limousin
42 * Function used to impose Dirac gauge during an iteration.
43 *
44 *
45 * $Header: /cvsroot/Lorene/C++/Source/Binary/binary_dirac.C,v 1.3 2014/10/13 08:52:44 j_novak Exp $ *
46 */
47
48
49 // Headers Lorene
50 #include "tenseur.h"
51 #include "binary.h"
52 #include "star.h"
53 #include "graphique.h"
54 #include "utilitaires.h"
55 #include "param.h"
56
57
58 namespace Lorene {
59 void Binary::dirac_gauge() {
60
61 int nz = star1.mp.get_mg()->get_nzone() ;
62 int nr = star1.mp.get_mg()->get_nr(0);
63 int nt = star1.mp.get_mg()->get_nt(0);
64 int np = star1.mp.get_mg()->get_np(0);
65
66 // Importations
67 // ------------
68
69 // Star 1
70
71 star1.hij_comp.set_triad(star1.mp.get_bvect_cart()) ;
72 Sym_tensor comp_hij1(star2.hij_auto) ;
73 comp_hij1.change_triad(star2.mp.get_bvect_cart()) ;
74 comp_hij1.change_triad(star1.mp.get_bvect_cart()) ;
75
76 assert ( *(star1.hij_comp.get_triad()) == *(comp_hij1.get_triad())) ;
77
78 for(int i=1; i<=3; i++)
79 for(int j=i; j<=3; j++) {
80 star1.hij_comp.set(i,j).set_etat_qcq() ;
81 star1.hij_comp.set(i,j).import( (comp_hij1)(i,j) ) ;
82 }
83 star1.hij_comp.std_spectral_base() ;//set the bases for spectral expansions
84
85 for(int i=1; i<=3; i++)
86 for(int j=i; j<=3; j++)
87 star1.hij.set(i,j) = star1.hij_auto(i,j) + star1.hij_comp(i,j) ;
88
89 // Star 2
90
91 star2.hij_comp.set_triad(star2.mp.get_bvect_cart()) ;
92 Sym_tensor comp_hij2(star1.hij_auto) ;
93 comp_hij2.change_triad(star1.mp.get_bvect_cart()) ;
94 comp_hij2.change_triad(star2.mp.get_bvect_cart()) ;
95
96 assert ( *(star2.hij_comp.get_triad()) == *(comp_hij2.get_triad())) ;
97
98 for(int i=1; i<=3; i++)
99 for(int j=i; j<=3; j++) {
100 star2.hij_comp.set(i,j).set_etat_qcq() ;
101 star2.hij_comp.set(i,j).import( (comp_hij2)(i,j) ) ;
102 }
103 star2.hij_comp.std_spectral_base() ;//set the bases for spectral expansions
104
105 for(int i=1; i<=3; i++)
106 for(int j=i; j<=3; j++)
107 star2.hij.set(i,j) = star2.hij_auto(i,j) + star2.hij_comp(i,j) ;
108
109 // -----------------------------------------
110 // Resolution of the Poisson equation for xi
111 // -----------------------------------------
112
113 cout << "Function Binary::dirac_gauge()" << endl ;
114
115 // Star 1
116 // ----------
117
118 int mermax = 50 ;
119 double precis = 1e-5 ;
120 double precis_poisson = 1e-14 ;
121 double relax_poisson = 1.5 ;
122 int mer_poisson = 4 ;
123
124 Scalar rr1 (star1.mp) ;
125 rr1 = star1.mp.r ;
126 Scalar rr2 (star2.mp) ;
127 rr2 = star2.mp.r ;
128
129 Vector xi1(star1.mp, CON, star1.mp.get_bvect_cart()) ;
130 xi1.set(1) = 0. ;
131 xi1.set(2) = 0. ;
132 xi1.set(3) = 0. ;
133 xi1.std_spectral_base() ;
134 Vector xi1_old(xi1) ;
135
136 Scalar ssjm1_xi11 (xi1(1)) ;
137 Scalar ssjm1_xi12 (xi1(2)) ;
138 Scalar ssjm1_xi13 (xi1(3)) ;
139
140
141 for(int mer=0; mer<mermax; mer++){
142
143 xi1_old = xi1 ;
144
145 // Function exp(-(r-r_0)^2/sigma^2)
146 // --------------------------------
147
148 double r0_1 = star1.mp.val_r(nz-2, 1, 0, 0) ;
149 double sigma = 3.*r0_1 ;
150
151 Scalar ff1 (star1.mp) ;
152 ff1 = exp( -(rr1 - r0_1)*(rr1 - r0_1)/sigma/sigma ) ;
153 for (int ii=0; ii<nz-1; ii++)
154 ff1.set_domain(ii) = 1. ;
155 ff1.set_outer_boundary(nz-1, 0) ;
156 ff1.std_spectral_base() ;
157
158 // Source
159
160 Vector source_xi1 (star1.hij.divergence(star1.flat)) ;
161 source_xi1.inc_dzpuis() ; // dzpuis = 3
162
163 double lambda = 0. ;
164 Vector source_reg1 = - (1./3. - lambda) * xi1.divergence(star1.flat)
165 .derive_con(star1.flat) ;
166 source_xi1 += source_reg1 ;
167
168 // Resolution of the Poisson equations
169
170 Cmp ssjm1xi11 (ssjm1_xi11) ;
171 Cmp ssjm1xi12 (ssjm1_xi12) ;
172 Cmp ssjm1xi13 (ssjm1_xi13) ;
173 ssjm1xi11.set_etat_qcq() ;
174 ssjm1xi12.set_etat_qcq() ;
175 ssjm1xi13.set_etat_qcq() ;
176
177 Param par_xi11 ;
178 int niter ;
179 par_xi11.add_int(mer_poisson, 0) ; // maximum number of iterations
180 par_xi11.add_double(relax_poisson, 0) ; // relaxation parameter
181 par_xi11.add_double(precis_poisson, 1) ; // required precision
182 par_xi11.add_int_mod(niter, 0) ; // number of iterations actually used
183 par_xi11.add_cmp_mod(ssjm1xi11) ;
184
185 Param par_xi12 ;
186 par_xi12.add_int(mer_poisson, 0) ; // maximum number of iterations
187 par_xi12.add_double(relax_poisson, 0) ; // relaxation parameter
188 par_xi12.add_double(precis_poisson, 1) ; // required precision
189 par_xi12.add_int_mod(niter, 0) ; // number of iterations actually used
190 par_xi12.add_cmp_mod(ssjm1xi12) ;
191
192 Param par_xi13 ;
193 par_xi13.add_int(mer_poisson, 0) ; // maximum number of iterations
194 par_xi13.add_double(relax_poisson, 0) ; // relaxation parameter
195 par_xi13.add_double(precis_poisson, 1) ; // required precision
196 par_xi13.add_int_mod(niter, 0) ; // number of iterations actually used
197 par_xi13.add_cmp_mod(ssjm1xi13) ;
198
199 source_xi1(1).poisson(par_xi11, xi1.set(1)) ;
200 source_xi1(2).poisson(par_xi12, xi1.set(2)) ;
201 source_xi1(3).poisson(par_xi13, xi1.set(3)) ;
202
203 ssjm1_xi11 = ssjm1xi11 ;
204 ssjm1_xi12 = ssjm1xi12 ;
205 ssjm1_xi13 = ssjm1xi13 ;
206
207 // Check: has the equation for xi been correctly solved ?
208 // --------------------------------------------------------------
209
210 Vector lap_xi1 = (xi1.derive_con(star1.flat)).divergence(star1.flat)
211 + lambda* xi1.divergence(star1.flat).derive_con(star1.flat) ;
212
213 Tbl tdiff_xi1_x = diffrel(lap_xi1(1), source_xi1(1)) ;
214 Tbl tdiff_xi1_y = diffrel(lap_xi1(2), source_xi1(2)) ;
215 Tbl tdiff_xi1_z = diffrel(lap_xi1(3), source_xi1(3)) ;
216
217 cout <<
218 "Relative error in the resolution of the equation for xi1 : "
219 << endl ;
220 cout << "x component : " ;
221 for (int l=0; l<nz; l++) {
222 cout << tdiff_xi1_x(l) << " " ;
223 }
224 cout << endl ;
225 cout << "y component : " ;
226 for (int l=0; l<nz; l++) {
227 cout << tdiff_xi1_y(l) << " " ;
228 }
229 cout << endl ;
230 cout << "z component : " ;
231 for (int l=0; l<nz; l++) {
232 cout << tdiff_xi1_z(l) << " " ;
233 }
234 cout << endl ;
235
236
237 double erreur = 0 ;
238 Tbl diff (diffrelmax (xi1_old(1), xi1(1))) ;
239 for (int i=1 ; i<nz ; i++)
240 if (diff(i) > erreur)
241 erreur = diff(i) ;
242
243 cout << "Step : " << mer << " Difference : " << erreur << endl ;
244 cout << "-------------------------------------" << endl ;
245 if (erreur < precis)
246 mer = mermax ;
247
248 }
249
250 // Star 2
251 // ----------
252
253 Vector xi2(star2.mp, CON, star2.mp.get_bvect_cart()) ;
254 xi2.set(1) = 0. ;
255 xi2.set(2) = 0. ;
256 xi2.set(3) = 0. ;
257 xi2.std_spectral_base() ;
258 Vector xi2_old(xi2) ;
259
260 Scalar ssjm1_xi21 (xi2(1)) ;
261 Scalar ssjm1_xi22 (xi2(2)) ;
262 Scalar ssjm1_xi23 (xi2(3)) ;
263
264
265 for(int mer=0; mer<mermax; mer++){
266
267 xi2_old = xi2 ;
268
269 // Function exp(-(r-r_0)^2/sigma^2)
270 // --------------------------------
271
272 double r0_2 = star2.mp.val_r(nz-2, 1, 0, 0) ;
273 double sigma = 3.*r0_2 ;
274
275 Scalar ff2 (star2.mp) ;
276 ff2 = exp( -(rr2 - r0_2)*(rr2 - r0_2)/sigma/sigma ) ;
277 for (int ii=0; ii<nz-1; ii++)
278 ff2.set_domain(ii) = 1. ;
279 ff2.set_outer_boundary(nz-1, 0) ;
280 ff2.std_spectral_base() ;
281
282 // Source
283
284 Vector source_xi2 (star2.hij.divergence(star2.flat)) ;
285 source_xi2.inc_dzpuis() ; // dzpuis = 3
286
287 double lambda = 0. ;
288 Vector source_reg2 = - (1./3. - lambda) * xi2.divergence(star2.flat)
289 .derive_con(star2.flat) ;
290 source_xi2 += source_reg2 ;
291
292 // Resolution of the Poisson equations
293
294 Cmp ssjm1xi21 (ssjm1_xi21) ;
295 Cmp ssjm1xi22 (ssjm1_xi22) ;
296 Cmp ssjm1xi23 (ssjm1_xi23) ;
297 ssjm1xi21.set_etat_qcq() ;
298 ssjm1xi22.set_etat_qcq() ;
299 ssjm1xi23.set_etat_qcq() ;
300
301 Param par_xi21 ;
302 int niter ;
303 par_xi21.add_int(mer_poisson, 0) ; // maximum number of iterations
304 par_xi21.add_double(relax_poisson, 0) ; // relaxation parameter
305 par_xi21.add_double(precis_poisson, 1) ; // required precision
306 par_xi21.add_int_mod(niter, 0) ; // number of iterations actually used
307 par_xi21.add_cmp_mod(ssjm1xi21) ;
308
309 Param par_xi22 ;
310 par_xi22.add_int(mer_poisson, 0) ; // maximum number of iterations
311 par_xi22.add_double(relax_poisson, 0) ; // relaxation parameter
312 par_xi22.add_double(precis_poisson, 1) ; // required precision
313 par_xi22.add_int_mod(niter, 0) ; // number of iterations actually used
314 par_xi22.add_cmp_mod(ssjm1xi22) ;
315
316 Param par_xi23 ;
317 par_xi23.add_int(mer_poisson, 0) ; // maximum number of iterations
318 par_xi23.add_double(relax_poisson, 0) ; // relaxation parameter
319 par_xi23.add_double(precis_poisson, 1) ; // required precision
320 par_xi23.add_int_mod(niter, 0) ; // number of iterations actually used
321 par_xi23.add_cmp_mod(ssjm1xi23) ;
322
323 source_xi2(1).poisson(par_xi21, xi2.set(1)) ;
324 source_xi2(2).poisson(par_xi22, xi2.set(2)) ;
325 source_xi2(3).poisson(par_xi23, xi2.set(3)) ;
326
327 ssjm1_xi21 = ssjm1xi21 ;
328 ssjm1_xi22 = ssjm1xi22 ;
329 ssjm1_xi23 = ssjm1xi23 ;
330
331 // Check: has the equation for xi been correctly solved ?
332 // --------------------------------------------------------------
333
334 Vector lap_xi2 = (xi2.derive_con(star2.flat)).divergence(star2.flat)
335 + lambda* xi2.divergence(star2.flat).derive_con(star2.flat) ;
336
337 Tbl tdiff_xi2_x = diffrel(lap_xi2(1), source_xi2(1)) ;
338 Tbl tdiff_xi2_y = diffrel(lap_xi2(2), source_xi2(2)) ;
339 Tbl tdiff_xi2_z = diffrel(lap_xi2(3), source_xi2(3)) ;
340
341 cout <<
342 "Relative error in the resolution of the equation for xi2 : "
343 << endl ;
344 cout << "x component : " ;
345 for (int l=0; l<nz; l++) {
346 cout << tdiff_xi2_x(l) << " " ;
347 }
348 cout << endl ;
349 cout << "y component : " ;
350 for (int l=0; l<nz; l++) {
351 cout << tdiff_xi2_y(l) << " " ;
352 }
353 cout << endl ;
354 cout << "z component : " ;
355 for (int l=0; l<nz; l++) {
356 cout << tdiff_xi2_z(l) << " " ;
357 }
358 cout << endl ;
359
360
361 double erreur = 0 ;
362 Tbl diff (diffrelmax (xi2_old(1), xi2(1))) ;
363 for (int i=1 ; i<nz ; i++)
364 if (diff(i) > erreur)
365 erreur = diff(i) ;
366
367 cout << "Step : " << mer << " Difference : " << erreur << endl ;
368 cout << "-------------------------------------" << endl ;
369 if (erreur < precis)
370 mer = mermax ;
371
372 }
373
374 // -----------------------------
375 // Computation of the new metric
376 // -----------------------------
377
378 // Star 1
379 // -------
380
381 Sym_tensor guu_dirac1 (star1.mp, CON, star1.mp.get_bvect_cart()) ;
382 guu_dirac1 = star1.gamma.con().derive_lie(xi1) ;
383 guu_dirac1.dec_dzpuis(2) ;
384 guu_dirac1 = guu_dirac1 + star1.gamma.con() ;
385 star1.gamma = guu_dirac1 ;
386
387 Sym_tensor gtilde_con1(star1.mp, CON, star1.mp.get_bvect_cart()) ;
388 Sym_tensor hij_dirac1(star1.mp, CON, star1.mp.get_bvect_cart()) ;
389
390 gtilde_con1 = pow(star1.gamma.determinant(), 1./3.) * guu_dirac1 ;
391 gtilde_con1.std_spectral_base() ;
392 for(int i=1; i<=3; i++)
393 for(int j=i; j<=3; j++)
394 hij_dirac1.set(i,j) = gtilde_con1(i,j) - star1.flat.con()(i,j) ;
395
396
397 star1.gtilde = gtilde_con1 ;
398 star1.psi4 = pow(star1.gamma.determinant(), 1./3.) ;
399 star1.psi4.std_spectral_base() ;
400
401 cout << "norme de h_uu avant :" << endl ;
402 for (int i=1; i<=3; i++)
403 for (int j=1; j<=i; j++) {
404 cout << " Comp. " << i << " " << j << " : " ;
405 for (int l=0; l<nz; l++){
406 cout << norme(star1.hij(i,j)/(nr*nt*np))(l) << " " ;
407 }
408 cout << endl ;
409 }
410 cout << endl ;
411
412 cout << "norme de h_uu en jauge de dirac :" << endl ;
413 for (int i=1; i<=3; i++)
414 for (int j=1; j<=i; j++) {
415 cout << " Comp. " << i << " " << j << " : " ;
416 for (int l=0; l<nz; l++){
417 cout << norme(hij_dirac1(i,j)/(nr*nt*np))(l) << " " ;
418 }
419 cout << endl ;
420 }
421 cout << endl ;
422
423
424 // Check of the Dirac gauge
425 // ------------------------
426
427 Vector hh_dirac (star1.hij.divergence(star1.flat)) ;
428 cout << "For comparaison H^i before computation = " << endl
429 << norme(hh_dirac(1))/(nr*nt*np)
430 << endl
431 << norme(hh_dirac(2))/(nr*nt*np)
432 << endl
433 << norme(hh_dirac(3))/(nr*nt*np)
434 << endl ;
435
436 Vector hh_dirac_new (hij_dirac1.divergence(star1.flat)) ;
437 cout << "Vector H^i after the computation" << endl ;
438 for (int i=1; i<=3; i++){
439 cout << " Comp. " << i << " : " << norme(hh_dirac_new(i)
440 /(nr*nt*np)) << endl ;
441 }
442
443 star1.hij_auto = star1.hij_auto + (hij_dirac1 - star1.hij) *
444 star1.decouple ;
445 star1.hij_comp = star1.hij_comp + (hij_dirac1 - star1.hij) *
446 (1 - star1.decouple) ;
447 star1.hij = hij_dirac1 ;
448
449
450 // Star 2
451 // -------
452
453 Sym_tensor guu_dirac2 (star2.mp, CON, star2.mp.get_bvect_cart()) ;
454 guu_dirac2 = star2.gamma.con().derive_lie(xi2) ;
455 guu_dirac2.dec_dzpuis(2) ;
456 guu_dirac2 = guu_dirac2 + star2.gamma.con() ;
457 star2.gamma = guu_dirac2 ;
458
459 Sym_tensor gtilde_con2(star2.mp, CON, star2.mp.get_bvect_cart()) ;
460 Sym_tensor hij_dirac2(star2.mp, CON, star2.mp.get_bvect_cart()) ;
461
462 gtilde_con2 = pow(star2.gamma.determinant(), 1./3.) * guu_dirac2 ;
463 gtilde_con2.std_spectral_base() ;
464 for(int i=1; i<=3; i++)
465 for(int j=i; j<=3; j++)
466 hij_dirac2.set(i,j) = gtilde_con2(i,j) - star2.flat.con()(i,j) ;
467
468
469 star2.gtilde = gtilde_con2 ;
470 star2.psi4 = pow(star2.gamma.determinant(), 1./3.) ;
471 star2.psi4.std_spectral_base() ;
472
473
474 star2.hij_auto = star2.hij_auto + (hij_dirac2 - star2.hij) *
475 star2.decouple ;
476 star2.hij_comp = star2.hij_comp + (hij_dirac2 - star2.hij) *
477 (1 - star2.decouple) ;
478 star2.hij = hij_dirac2 ;
479
480 //arrete() ;
481 }
482 }