00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "math.h"
00031
00032
00033 #include "tenseur.h"
00034 #include "star.h"
00035 #include "param.h"
00036 #include "graphique.h"
00037 #include "unites.h"
00038 #include "spheroid.h"
00039 #include "excision_surf.h"
00040 #include "excision_hor.h"
00041 #include "param_elliptic.h"
00042 #include "vector.h"
00043 #include "scalar.h"
00044 #include "diff.h"
00045 #include "proto.h"
00046 #include "excised_slice.h"
00047
00048
00049 void Excised_slice::compute_stat_metric(double precis, double Omega, bool NorKappa, Scalar boundNoK, bool isCF,double relax, int mer_max, int mer_max2, bool isvoid){
00050
00051
00052
00053 using namespace Unites ;
00054
00055
00056 assert(type_hor==1);
00057
00058
00059
00060 cout << "================================================================" << endl;
00061 cout << "STARTING THE MAIN ITERATION FOR COMPUTING METRIC FIELDS" << endl;
00062 cout << " iteration parameters are the following: " << endl;
00063 cout << " convergence precision required:" << precis << endl;
00064 cout << " max number of global steps :" << mer_max << endl;
00065 cout << " relaxation parameter :" << relax << endl;
00066 cout << "================================================================" << endl;
00067
00068
00069
00070
00071 const Map_af* map = dynamic_cast<const Map_af*>(&mp) ;
00072 const Mg3d* mgrid = (*map).get_mg();
00073
00074
00075 const Mg3d* g_angu = (*mgrid).get_angu_1dom() ;
00076
00077 const int nz = (*mgrid).get_nzone();
00078 int nt = (*mgrid).get_nt(1);
00079 const int np = (*mgrid).get_np(1);
00080 const Coord& rr = (*map).r;
00081 Scalar rrr (*map) ;
00082 rrr = rr ;
00083 rrr.std_spectral_base();
00084 assert((rrr.val_grid_point(1,0,0,0) - 1.) <= 1.e-9);
00085
00086
00087
00088 double r_limits2[] = {rrr.val_grid_point(1,0,0,0), rrr.val_grid_point(2,0,0,0)} ;
00089 const Map_af map_2(*g_angu, r_limits2);
00090 const Metric_flat& mets = (*map).flat_met_spher() ;
00091
00092
00093
00094
00095
00096
00097
00098 Scalar logn (*map) ; logn = log(lapse) ;
00099 logn.std_spectral_base();
00100
00101
00102 Scalar logpsi(*map) ; logpsi = log(conf_fact) ;
00103 logpsi.std_spectral_base();
00104 Scalar psi4 (*map) ; psi4 = conf_fact*conf_fact*conf_fact*conf_fact ;
00105 Scalar npsi (*map) ; npsi =conf_fact*lapse ;
00106
00107
00108 Scalar conf_fact_new(*map) ; conf_fact_new.annule_hard(); conf_fact_new.std_spectral_base();
00109 Scalar npsi_new(*map); npsi_new.annule_hard(); npsi_new.std_spectral_base();
00110
00111 Vector shift_new (*map, CON, (*map).get_bvect_spher());
00112 for(int i=1; i<=3; i++){
00113 shift_new.set(i)=0;
00114 }
00115 shift_new.std_spectral_base();
00116
00117
00118
00119
00120 Sym_tensor gamtuu = mets.con() + hij;
00121 Metric gamt(gamtuu);
00122 Metric gam(gamt.cov()*psi4) ;
00123 Sym_tensor gamma = gam.cov();
00124
00125
00126
00127
00128 Sym_tensor aa(*map, CON, (*map).get_bvect_spher());
00129 for (int iii= 1; iii<=3; iii++){
00130 for(int j=1; j<=3; j++){
00131 aa.set(iii,j)= 0;
00132 }
00133 }
00134 aa.std_spectral_base();
00135 Scalar aa_quad_scal(*map) ; aa_quad_scal = 0. ;
00136
00137 Sym_tensor aa_hat(*map, CON, (*map).get_bvect_spher());
00138 for (int iii= 1; iii<=3; iii++){
00139 for(int j=1; j<=3; j++){
00140 aa_hat.set(iii,j)= 0;
00141 }
00142 }
00143
00144 Sym_tensor kuu = aa/psi4 ;
00145 Sym_tensor kuu2 = aa_hat/(psi4*psi4*sqrt(psi4));
00146 Sym_tensor kdd = contract (gamma, 0, contract(gamma, 1, kuu, 0),1);
00147
00148
00149
00150
00151 Tensor delta = -0.5*contract( hij, 1, gamt.cov().derive_cov(mets), 2);
00152 Scalar tmp(*map);
00153
00154 for (int i=1; i<=3; i++) {
00155 for (int j=1; j<=3; j++) {
00156 for (int k=1; k<=3; k++) {
00157 tmp = 0.;
00158 tmp = -0.5 *(gamt.cov().derive_con(mets))(i,j,k);
00159 for (int l=1; l<=3; l++) {
00160 tmp += -0.5*( gamt.cov()(i,l)*(hij.derive_cov(mets))(k,l,j) + gamt.cov()(l,j)*(hij.derive_cov(mets))(k,l,i));
00161 }
00162 delta.set(k,i,j) += tmp ;
00163 }
00164 }
00165 }
00166
00167
00168
00169 Scalar Rstar =
00170 0.25 * contract(gamt.con(), 0, 1,
00171 contract(hij.derive_cov(mets), 0, 1, gamt.cov().derive_cov(mets), 0, 1), 0, 1 )
00172 - 0.5 * contract(gamt.con(), 0, 1,
00173 contract(hij.derive_cov(mets), 0, 1, gamt.cov().derive_cov(mets), 0, 2), 0, 1 ) ;
00174
00175 Scalar norm(*map);
00176 Scalar norm3(*map);
00177
00178
00179 if (isvoid == false){
00180
00181 cout <<"FAIL: case of non-void spacetime not treated yet" << endl;
00182 }
00183
00184 else
00185 {
00186
00187
00188
00189
00190 double diff_ent = 1 ;
00191
00192 int util = 0;
00193
00197
00198
00199 for(int mer=0 ;(diff_ent > precis) && (mer<mer_max) ; mer++) {
00200
00201
00202
00203
00204 norm = sqrt(1. + hij(1,1)); norm.std_spectral_base();
00205 norm3 = sqrt(1. + hij(3,3)); norm3.std_spectral_base();
00206
00207
00208
00212
00213
00214
00216
00218
00219
00220
00221
00222 double diric= 0.;
00223 double neum = 1.;
00224
00225 Vector ssalt = rrr.derive_cov(gam);
00226 Vector ssaltcon = ssalt.up_down(gam);
00227 Scalar ssnormalt = sqrt(contract (ssalt,0, ssaltcon, 0));
00228 ssnormalt.std_spectral_base();
00229
00230 ssalt.annule_domain(nz-1);
00231 ssalt.annule_domain(0);
00232 ssaltcon.annule_domain(nz-1);
00233 ssaltcon.annule_domain(0);
00234
00235 ssalt = ssalt/ssnormalt;
00236 ssaltcon = ssaltcon/ssnormalt;
00237 Vector ssconalt = ssaltcon*conf_fact*conf_fact;
00238 ssconalt.std_spectral_base();
00239 ssconalt.annule_domain(nz-1);
00240 Scalar bound3bis = -((1./conf_fact)*contract((contract(kdd,1,ssconalt,0)),0, ssconalt,0));
00241
00242 bound3bis.annule_domain(nz-1);
00243 bound3bis += -conf_fact*ssconalt.divergence(gamt);
00244 bound3bis.annule_domain(nz-1);
00245 bound3bis = 0.25*bound3bis;
00246 bound3bis += -contract(conf_fact.derive_cov(gamt),0,ssconalt,0) + conf_fact.dsdr();
00247 bound3bis.annule_domain(nz-1);
00248 bound3bis.std_spectral_base();
00249 bound3bis.set_spectral_va().ylm();
00250
00251 Mtbl_cf *boundd3bis = bound3bis.set_spectral_va().c_cf;
00252
00253
00255
00256
00257
00258
00259
00260 Scalar source_conf_fact(*map) ; source_conf_fact=3. ;
00261 source_conf_fact.std_spectral_base();
00262
00263 Scalar d2logpsi = contract(conf_fact.derive_cov(mets).derive_cov(mets), 0, 1, hij, 0,1);
00264 d2logpsi.inc_dzpuis(1);
00265
00266 source_conf_fact = -(0.125* aa_quad_scal )/(psi4*conf_fact*conf_fact*conf_fact) + conf_fact* 0.125* Rstar - d2logpsi;
00267
00268 source_conf_fact.std_spectral_base();
00269
00270 if (source_conf_fact.get_etat() == ETATZERO) {
00271 source_conf_fact.annule_hard() ;
00272 source_conf_fact.set_dzpuis(4) ;
00273 source_conf_fact.std_spectral_base() ;
00274 }
00275 source_conf_fact.set_spectral_va().ylm();
00276
00277
00278
00280
00281
00282
00283 Param_elliptic source11(source_conf_fact);
00284 conf_fact_new = source_conf_fact.sol_elliptic_boundary(source11, *boundd3bis, diric , neum) + 1 ;
00285
00286
00288
00289
00290
00291 Scalar baba2 = (conf_fact_new-1).laplacian();
00292
00293
00294
00295 Scalar psinewbis = conf_fact_new -1. ; psinewbis.annule_domain(nz -1);
00296 psinewbis.std_spectral_base();
00297 psinewbis = psinewbis.dsdr();
00298 Scalar psinewfin2 (map_2) ;
00299 psinewfin2.allocate_all();
00300 psinewfin2.set_etat_qcq();
00301 psinewfin2.std_spectral_base();
00302
00303 for (int k=0; k<np; k++)
00304 for (int j=0; j<nt; j++) {
00305
00306 psinewfin2.set_grid_point(0, k, j, 0) = psinewbis.val_grid_point(1, k,j,0) - bound3bis.val_grid_point(1, k, j, 0);
00307
00308 }
00309
00310
00311
00312
00314
00315
00316
00317 conf_fact = conf_fact_new* (1-relax) + conf_fact* relax ;
00318 psi4 = conf_fact*conf_fact*conf_fact*conf_fact;
00319 logpsi = log(conf_fact) ;
00320 logpsi.std_spectral_base();
00321
00322
00323
00324
00328
00329
00330
00332
00334
00335
00336
00337 assert (NorKappa == false) ;
00338 Scalar bound(*map);
00339 bound = (boundNoK)*conf_fact -1;
00340 bound.annule_domain(nz -1);
00341 bound.std_spectral_base();
00342 bound.set_spectral_va().ylm();
00343 Mtbl_cf *boundd = bound.get_spectral_va().c_cf;
00344
00345 diric =1;
00346 neum = 0 ;
00347
00348
00349
00351
00352
00353 Scalar d2lognpsi = contract(npsi.derive_cov(mets).derive_cov(mets), 0, 1, hij, 0,1);
00354 d2lognpsi.inc_dzpuis(1);
00355
00356 Scalar source_npsi = npsi*(aa_quad_scal*(7./8.)/(psi4*psi4) + Rstar/8.) - d2lognpsi;
00357 source_npsi.std_spectral_base();
00358 if (source_npsi.get_etat() == ETATZERO) {
00359 source_npsi.annule_hard() ;
00360 source_npsi.set_dzpuis(4) ;
00361 source_npsi.std_spectral_base() ;
00362 }
00363
00364
00366
00367
00368 Param_elliptic source1 (source_npsi);
00369 npsi_new = source_npsi.sol_elliptic_boundary(source1, *boundd, diric, neum) ;
00370
00371 npsi_new = npsi_new +1;
00372
00373
00375
00376
00377 Scalar baba = npsi_new.laplacian();
00378
00379
00380
00381
00382
00383 Scalar npsibound2 (map_2) ;
00384 npsibound2.allocate_all();
00385 npsibound2.set_etat_qcq();
00386 npsibound2.std_spectral_base();
00387 for (int k=0; k<np; k++)
00388 for (int j=0; j<nt; j++) {
00389
00390 npsibound2.set_grid_point(0, k, j, 0) = npsi_new.val_grid_point(1, k,j,0) - bound.val_grid_point(1, k, j, 0) -1.;
00391
00392 }
00393
00394
00395
00396
00398
00399
00400
00401
00402 npsi = npsi_new*(1-relax) + npsi* relax;
00403 lapse = npsi/conf_fact;
00404 logn = log(lapse);
00405 logn.std_spectral_base();
00406
00407
00411
00413
00415
00416
00417
00418
00419 bound = (boundNoK)/(conf_fact*conf_fact) ;
00420 bound.annule_domain(nz -1);
00421
00422
00423 Scalar hor_rot(*map); hor_rot.annule_hard(); hor_rot = Omega;
00424 hor_rot.std_spectral_base() ; hor_rot.mult_rsint();
00425 hor_rot.annule_domain(nz -1);
00426
00427 Vector limit = shift_new;
00428 Vector ephi(*map, CON, (*map).get_bvect_spher());
00429 ephi.set(1).annule_hard();
00430 ephi.set(2).annule_hard();
00431 ephi.set(3) = 1;
00432 ephi.std_spectral_base();
00433 ephi.annule_domain(nz -1);
00434
00435 limit = bound*ssconalt + hor_rot*ephi;
00436 limit.std_spectral_base();
00437
00438 Scalar Vrb = limit(1); Vrb.set_spectral_va().ylm();
00439 Scalar mmub = limit.mu(); mmub.set_spectral_va().ylm();
00440 Scalar etab = limit.eta(); etab.set_spectral_va().ylm();
00441
00442
00443
00445
00446
00447 Vector deltaA = - 2*lapse*contract(delta, 1,2, aa, 0,1);
00448 Vector hijddb = - contract (shift.derive_cov(mets).derive_cov(mets), 1,2, hij, 0,1) ;
00449 Vector hijddivb = - 0.3333333333333* contract (shift.divergence(mets).derive_cov(mets),0, hij,1);
00450 hijddb.inc_dzpuis();
00451 hijddivb.inc_dzpuis();
00452
00453 Vector sourcevect2(*map,CON, (*map).get_bvect_spher());
00454 sourcevect2= (2.* contract(aa, 1, lapse.derive_cov(mets),0)-12*lapse*contract(aa, 1, logpsi.derive_cov(mets), 0)) + deltaA + hijddb + hijddivb ;
00455
00456 sourcevect2.set(1).set_dzpuis(4);
00457 sourcevect2.set(2).set_dzpuis(4);
00458 sourcevect2.set(3).set_dzpuis(4);
00459 sourcevect2.std_spectral_base();
00460 if(sourcevect2.eta().get_etat() == ETATZERO)
00461 { sourcevect2.set(2).annule_hard();}
00462
00463
00464 double lam = (1./3.);
00465
00466
00467
00469
00470
00471 sourcevect2.poisson_boundary2(lam, shift_new, Vrb, etab, mmub, 1., 0., 1. ,0. ,1. ,0.) ;
00472
00473
00474
00476
00477
00478 Vector source2 = contract(shift_new.derive_con(mets).derive_cov(mets), 1,2) + lam* contract(shift_new.derive_cov(mets), 0,1).derive_con(mets);
00479 source2.inc_dzpuis(1);
00480
00481
00482 Scalar mufin = shift_new.mu();
00483 mufin.set_spectral_va().coef();
00484
00485 Scalar mufin2 (map_2) ;
00486 mufin2.allocate_all();
00487 mufin2.set_etat_qcq();
00488 mufin2.std_spectral_base();
00489
00490 for (int k=0; k<np; k++)
00491 for (int j=0; j<nt; j++) {
00492
00493 mufin2.set_grid_point(0, k, j, 0) = mufin.val_grid_point(1, k,j,0) - mmub.val_grid_point(1, k, j, 0);
00494
00495 }
00496
00497
00498
00499
00500 Scalar brfin = shift_new(1);
00501 brfin.set_spectral_va().coef();
00502
00503 Scalar brfin2 (map_2) ;
00504 brfin2.allocate_all();
00505 brfin2.set_etat_qcq();
00506 brfin2.std_spectral_base();
00507
00508 for (int k=0; k<np; k++)
00509 for (int j=0; j<nt; j++) {
00510
00511 brfin2.set_grid_point(0, k, j, 0) = brfin.val_grid_point(1, k,j,0) - Vrb.val_grid_point(1, k, j, 0);
00512
00513 }
00514
00515
00516
00517
00519
00520
00521 for (int ii=1; ii <=3; ii++){
00522 shift.set(ii) = shift_new(ii)*(1-relax) + shift(ii)* relax;
00523 }
00524
00525
00526 diff_ent = max(maxabs(npsi_new - npsi ));
00527
00528
00529
00533
00534
00535
00537
00539
00540 if (isCF == false){
00541
00542 if (diff_ent <=5.e-3) {
00543
00544
00545 util = util+1;
00546
00547
00551
00552
00553 double precis2 = 1.e5*precis ;
00554
00555 double diff_ent2 = 1 ;
00556 double relax2 = 0.5;
00557
00558
00559 Sym_tensor sourcehij = hij;
00560
00561
00562
00563 for(int mer2=0 ;(diff_ent2 > precis2) && (mer2<mer_max2) ; mer2++) {
00564
00566
00567
00568
00569
00570
00571 secmembre_kerr(sourcehij);
00572
00573
00575
00576
00577
00578 Sym_tensor hij_new = hij;
00579
00580 hij_new = boundfree_tensBC (sourcehij, shift , conf_fact, lapse, hij, precis2);
00581
00582 cout << "maximum of convergence marker for the subiteration" << endl;
00583
00584 diff_ent2 = max(maxabs(hij - hij_new));
00585 hij = relax2*hij_new + (1 - relax2)*hij;
00586
00587 cout << "mer2, diffent2" << endl;
00588
00589 cout << mer2 << endl;
00590 cout << diff_ent2 << endl;
00591
00592
00593 }
00594
00596
00597
00598
00599 Sym_tensor gammatilde = mets.con() + hij;
00600 Metric gammatilde2(gammatilde); Scalar detgam = gammatilde2.determinant();
00601
00602
00603
00604
00605
00606 Sym_tensor test =contract (hij.derive_cov(mets).derive_con(mets), 2,3);
00607 test.annule(nz-1, nz-1);
00608 test = test - hij.derive_lie(shift).derive_lie(shift)/ ((lapse/(conf_fact*conf_fact))*(lapse/(conf_fact*conf_fact)));
00609 test.annule(nz-1, nz-1);
00610 Sym_tensor youps = test - sourcehij/((lapse/(conf_fact*conf_fact))*(lapse/(conf_fact*conf_fact)));
00611
00612
00613
00614
00615
00616
00617
00618 }
00619 }
00620
00621
00622
00623
00627
00628
00629
00631
00633
00634
00635 gamtuu = mets.con() + hij;
00636 gamt = gamtuu;
00637 gam = gamt.cov()*psi4;
00638 gamma = gam.cov();
00639
00640
00641 for (int i=1; i<=3; i++) {
00642 for (int j=1; j<=3; j++) {
00643
00644 tmp = 0;
00645 tmp = ((shift.derive_con(mets))(i,j) + (shift.derive_con(mets))(j,i) - (2./3.)*shift.divergence(mets) * mets.con()(i,j))*(1./(2.*lapse));
00646 aa.set(i,j) = tmp ;
00647
00648 }
00649 }
00650
00651 aa = aa - (hij.derive_lie(shift) + (2./3.)*shift.divergence(mets)*hij)*(1./(2.*lapse));
00652
00653 aa_hat = aa*psi4*sqrt(psi4);
00654 aa_hat.std_spectral_base();
00655
00656
00657 hatA = aa_hat;
00658
00659 Sym_tensor aaud = aa.up_down(gamt);
00660 Sym_tensor aaud_hat = aa_hat.up_down(gamt);
00661 aa_quad_scal = contract(contract (aa_hat, 0, aaud_hat, 0), 0,1);
00662
00663 delta = -0.5*contract( hij, 1, gamt.cov().derive_cov(mets), 2);
00664
00665
00666 for (int i=1; i<=3; i++) {
00667 for (int j=1; j<=3; j++) {
00668 for (int k=1; k<=3; k++) {
00669 tmp = 0.;
00670 tmp = -0.5 *(gamt.cov().derive_con(mets))(i,j,k);
00671 for (int l=1; l<=3; l++) {
00672 tmp += -0.5*( gamt.cov()(i,l)*(hij.derive_cov(mets))(k,l,j) + gamt.cov()(l,j)*(hij.derive_cov(mets))(k,l,i));
00673 }
00674 delta.set(k,i,j) += tmp ;
00675 }
00676 }
00677 }
00678
00679 Rstar =
00680 0.25 * contract(gamt.con(), 0, 1,
00681 contract(gamt.con().derive_cov(mets), 0, 1, gamt.cov().derive_cov(mets), 0, 1), 0, 1 )
00682 - 0.5 * contract(gamt.con(), 0, 1,
00683 contract(gamt.con().derive_cov(mets), 0, 1, gamt.cov().derive_cov(mets), 0, 2), 0, 1 ) ;
00684
00685 kuu = aa/(psi4);
00686 kdd = contract (gamma, 0, contract(gamma, 1, kuu, 0),1);
00687
00688
00689
00691
00692
00693 cout << "diffent" << endl;
00694 cout<< diff_ent << endl;
00695 cout <<"mer" << mer << endl;
00696
00697
00698
00699
00703
00704
00705
00706
00707
00708
00709
00710
00711 Scalar lapse2(*map) ;
00712 lapse2 = lapse ;
00713 lapse2.std_spectral_base();
00714
00715
00716
00717
00718
00719 Sym_tensor gamt2(*map, COV, (*map).get_bvect_spher());
00720 for (int i=1; i<=3; i++)
00721 for (int j=1; j<=3; j++)
00722 { gamt2.set(i,j)=gam.cov()(i,j);
00723 }
00724
00725
00726 Vector beta = shift ;
00727
00728
00729
00730
00731 Scalar TrK3(*map);
00732 Sym_tensor k_uu = aa/(psi4) ;
00733 k_uu.dec_dzpuis(k_uu(1,1).get_dzpuis());
00734 Sym_tensor k_dd = k_uu.up_down(gam);
00735
00736 TrK3 = k_uu.trace(gam);
00737
00738
00739
00740
00741 Scalar ham_constr = gam.ricci_scal() ;
00742 ham_constr.dec_dzpuis(3) ;
00743 ham_constr += TrK3*TrK3 - contract(k_uu, 0, 1, k_dd, 0, 1) ;
00744
00745
00746 ham_constr.set_spectral_va().ylm();
00747
00748
00749
00750
00751
00752
00753 Vector mom_constr = k_uu.divergence(gam) - TrK3.derive_con(gam) ;
00754 mom_constr.dec_dzpuis(2) ;
00755
00756
00757
00758
00759
00760
00761
00762
00763 Sym_tensor evol_eq = lapse2*gam.ricci()
00764 - lapse2.derive_cov(gam).derive_cov(gam);
00765 evol_eq.dec_dzpuis() ;
00766 evol_eq += k_dd.derive_lie(beta) ;
00767 evol_eq.dec_dzpuis(2) ;
00768 evol_eq += lapse2*(TrK3*k_dd - 2*contract(k_dd, 1, k_dd.up(0, gam), 0) ) ;
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778 }
00779
00780
00781
00782 cout << "================================================================" << endl;
00783 cout << " THE ITERATION HAS NOW CONVERGED" << endl;
00784 cout << "================================================================" << endl;
00785 }
00786 return;
00787 }
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798