64#include "boson_star.h"
69#include "utilitaires.h"
74 int nzadapt,
const Tbl& phi_limit,
const Itbl& icontrol,
84 char display_bold[]=
"x[1m" ; display_bold[0] = 27 ;
85 char display_normal[] =
"x[0m" ; display_normal[0] = 27 ;
90 const Mg3d* mg =
mp.get_mg() ;
102 int j_b = mg->
get_nt(l_b) - 1 ;
111 int mer_max = icontrol(0) ;
116 int mermax_poisson = icontrol(5) ;
117 int mer_triax = icontrol(6) ;
121 double precis = control(0) ;
123 double relax = control(2) ;
124 double relax_prev = double(1) - relax ;
125 double relax_poisson = control(3) ;
127 double ampli_triax = control(5) ;
128 double precis_adapt = control(6) ;
135 double& diff_phi = diff.
set(0) ;
136 double& diff_nuf = diff.
set(1) ;
137 double& diff_nuq = diff.
set(2) ;
140 double& diff_shift_x = diff.
set(5) ;
141 double& diff_shift_y = diff.
set(6) ;
142 double& vit_triax = diff.
set(7) ;
153 int nz_search = nzet + 1 ;
156 double reg_map = 1. ;
158 par_adapt.
add_int(nitermax, 0) ;
160 par_adapt.
add_int(nzadapt, 1) ;
163 par_adapt.
add_int(nz_search, 2) ;
165 par_adapt.
add_int(adapt_flag, 3) ;
184 par_adapt.
add_tbl(phi_limit, 0) ;
190 double precis_poisson = 1.e-16 ;
196 beta.change_triad(
mp.get_bvect_cart() ) ;
203 Tenseur cssjm1_wshift(
mp, 1, CON,
mp.get_bvect_cart() ) ;
205 for (
int i=1; i<=3; i++) {
211 for (
int i=1; i<=3; i++) {
215 Tenseur cw_shift(
mp, 1, CON,
mp.get_bvect_cart() ) ;
217 for (
int i=1; i<=3; i++) {
225 Param par_poisson_nuf ;
226 par_poisson_nuf.
add_int(mermax_poisson, 0) ;
227 par_poisson_nuf.
add_double(relax_poisson, 0) ;
228 par_poisson_nuf.
add_double(precis_poisson, 1) ;
232 Param par_poisson_nuq ;
233 par_poisson_nuq.
add_int(mermax_poisson, 0) ;
234 par_poisson_nuq.
add_double(relax_poisson, 0) ;
235 par_poisson_nuq.
add_double(precis_poisson, 1) ;
239 Param par_poisson_tggg ;
240 par_poisson_tggg.
add_int(mermax_poisson, 0) ;
241 par_poisson_tggg.
add_double(relax_poisson, 0) ;
242 par_poisson_tggg.
add_double(precis_poisson, 1) ;
248 Param par_poisson_dzeta ;
255 Param par_poisson_vect ;
257 par_poisson_vect.
add_int(mermax_poisson, 0) ;
258 par_poisson_vect.
add_double(relax_poisson, 0) ;
259 par_poisson_vect.
add_double(precis_poisson, 1) ;
269 beta.change_triad(
mp.get_bvect_spher() ) ;
272 beta.change_triad(
mp.get_bvect_cart() ) ;
287 Vector source_shift(
mp, CON,
mp.get_bvect_cart()) ;
291 ofstream fichconv(
"convergence.d") ;
292 fichconv <<
"# diff_phi GRV2 max_triax vit_triax" << endl ;
295 ofstream fichevol(
"evolution.d") ;
297 "# |dH/dr_eq/dH/dr_pole| r_pole/r_eq rphi_c"
301 double err_grv2 = 1 ;
302 double max_triax_prev = 0 ;
308 for(
int mer=0 ; (diff_phi > precis) && (mer<mer_max) ; mer++ ) {
310 cout <<
"-----------------------------------------------" << endl ;
311 cout <<
"step: " << mer << endl ;
312 cout <<
"diff_phi = " << display_bold << diff_phi << display_normal
314 cout <<
"err_grv2 = " << err_grv2 << endl ;
328 Vector d_logn =
logn.derive_cov(
mp.flat_met_spher() ) ;
334 source_nuq =
ak_car - d_logn(1)*(d_logn(1)+d_bet(1))
335 - d_logn(2)*(d_logn(2)+d_bet(2))
336 - d_logn(3)*(d_logn(3)+d_bet(3)) ;
339 source_nuq.std_spectral_base() ;
347 - d_logn(1)*d_logn(1) - d_logn(2)*d_logn(2) - d_logn(3)*d_logn(3) ;
365 source_shift = (-4*qpig) *
nn *
a_car * mom_euler_cart ;
369 - 2 *
logn.derive_con(
mp.flat_met_spher() ) ;
374 source_shift = source_shift + squad.
up(0,
mp.flat_met_cart() ) ;
382 cout <<
"Test of the Poisson equation for nuf :" << endl ;
384 diff_nuf = err(0, 0) ;
390 if (mer == mer_triax) {
392 if ( mg->
get_np(0) == 1 ) {
394 "Boson_star::equilibrium: np must be stricly greater than 1"
395 << endl <<
" to set a triaxial perturbation !" << endl ;
405 nuf.std_spectral_base() ;
414 const Valeur& va_nuf =
nuf.get_spectral_va() ;
416 double max_triax = 0 ;
418 if ( mg->
get_np(0) > 1 ) {
420 for (
int l=0; l<nz; l++) {
421 for (
int j=0; j<mg->
get_nt(l); j++) {
422 for (
int i=0; i<mg->
get_nr(l); i++) {
425 double xcos2p = (*(va_nuf.
c_cf))(l, 2, j, i) ;
428 double xsin2p = (*(va_nuf.
c_cf))(l, 3, j, i) ;
430 double xx =
sqrt( xcos2p*xcos2p + xsin2p*xsin2p ) ;
432 max_triax = ( xx > max_triax ) ? xx : max_triax ;
439 cout <<
"Triaxial part of nuf : " << max_triax << endl ;
445 source_nuq.poisson(par_poisson_nuq,
nuq) ;
447 cout <<
"Test of the Poisson equation for nuq :" << endl ;
448 err = source_nuq.test_poisson(
nuq, cout,
true) ;
449 diff_nuq = err(0, 0) ;
456 for (
int i=1; i<=3; i++) {
457 if(source_shift(i).get_etat() != ETATZERO) {
458 if(source_shift(i).dz_nonzero()) {
459 assert( source_shift(i).get_dzpuis() == 4 ) ;
462 (source_shift.
set(i)).set_dzpuis(4) ;
467 double lambda_shift = double(1) / double(3) ;
469 if ( mg->
get_np(0) == 1 ) {
473 Tenseur csource_shift(
mp, 1, CON,
mp.get_bvect_cart() ) ;
475 for (
int i=1; i<=3; i++) {
476 csource_shift.
set(i-1) = source_shift(i) ;
480 csource_shift.
poisson_vect(lambda_shift, par_poisson_vect,
481 cshift, cw_shift, ckhi_shift) ;
483 for (
int i=1; i<=3; i++) {
484 beta.set(i) = - cshift(i-1) ;
485 beta.set(i).set_dzpuis(0) ;
486 w_shift.set(i) = cw_shift(i-1) ;
490 cout <<
"Test of the Poisson equation for shift_x :" << endl ;
491 err = source_shift(1).test_poisson(-
beta(1), cout,
true) ;
492 diff_shift_x = err(0, 0) ;
494 cout <<
"Test of the Poisson equation for shift_y :" << endl ;
495 err = source_shift(2).test_poisson(-
beta(2), cout,
true) ;
496 diff_shift_y = err(0, 0) ;
535 Cmp csource_tggg(source_tggg) ;
537 mp.poisson2d(csource_tggg,
mp.cmp_zero(), par_poisson_tggg,
546 Cmp csource_dzf(source_dzf) ;
547 Cmp csource_dzq(source_dzq) ;
549 mp.poisson2d(csource_dzf, csource_dzq, par_poisson_dzeta,
553 err_grv2 = lbda_grv2 - 1;
554 cout <<
"GRV2: " << err_grv2 << endl ;
564 logn = relax *
logn + relax_prev * logn_prev ;
566 dzeta = relax *
dzeta + relax_prev * dzeta_prev ;
572 beta.change_triad(
mp.get_bvect_spher() ) ;
575 beta.change_triad(
mp.get_bvect_cart() ) ;
581 cout << *
this << endl ;
589 diff_phi = diff_phi_tbl(0) ;
590 for (
int l=1; l<nzet; l++) {
591 diff_phi += diff_phi_tbl(l) ;
595 fichconv <<
" " <<
log10( fabs(diff_phi) + 1.e-16 ) ;
596 fichconv <<
" " <<
log10( fabs(err_grv2) + 1.e-16 ) ;
597 fichconv <<
" " <<
log10( fabs(max_triax) + 1.e-16 ) ;
600 if ( (mer > mer_triax+1) && (max_triax_prev > 1e-13) ) {
601 vit_triax = (max_triax - max_triax_prev) / max_triax_prev ;
604 fichconv <<
" " << vit_triax ;
613 max_triax_prev = max_triax ;
630 for (
int i=1; i<=3; i++) {
635 beta.change_triad(
mp.get_bvect_spher() ) ;
Scalar rphi
Real part of the scalar field Phi.
virtual void equilibrium(double rphi_c, double iphi_c, int nzadapt, const Tbl &ent_limit, const Itbl &icontrol, const Tbl &control, Tbl &diff, Param *=0x0)
Solves the equation satisfied by the scalar field.
void update_ener_mom()
Computes the 3+1 components of the energy-momentum tensor (E, P_i and S_{ij}) from the values of the ...
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Scalar b_car
Square of the metric factor B.
Scalar bbb
Metric factor B.
Scalar a_car
Square of the metric factor A.
Sym_tensor kk
Extrinsic curvature tensor .
Vector mom_euler
Total 3-momentum density in the Eulerian frame.
Sym_tensor stress_euler
Stress tensor with respect to the Eulerian observer.
Scalar ener_euler
Total energy density E in the Eulerian frame.
Scalar nn
Lapse function N .
Vector beta
Shift vector .
Map & mp
Mapping describing the coordinate system (r,theta,phi).
Active physical coordinates and mapping derivatives.
Basic integer array class.
Radial mapping of rather general form.
int get_type_t() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the equatorial pl...
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
int get_nzone() const
Returns the number of domains.
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
void add_double(const double &x, int position=0)
Adds the the address of a new double to the list.
void add_cmp_mod(Cmp &ti, int position=0)
Adds the address of a new modifiable Cmp to the list.
void add_double_mod(double &x, int position=0)
Adds the address of a new modifiable double to the list.
void add_int_mod(int &n, int position=0)
Adds the address of a new modifiable int to the list.
void add_tenseur_mod(Tenseur &ti, int position=0)
Adds the address of a new modifiable Tenseur to the list.
void add_int(const int &n, int position=0)
Adds the address of a new int to the list.
void add_tbl(const Tbl &ti, int position=0)
Adds the address of a new Tbl to the list.
Tensor field of valence 0 (or component of a tensorial field).
const Vector & derive_cov(const Metric &gam) const
Returns the gradient (1-form = covariant vector) of *this.
Scalar poisson() const
Solves the scalar Poisson equation with *this as a source.
virtual void std_spectral_base()
Sets the spectral bases of the Valeur va to the standard ones for a scalar field.
Tbl test_poisson(const Scalar &uu, ostream &ostr, bool detail=false) const
Checks if a Poisson equation with *this as a source has been correctly solved.
void mult_rsint()
Multiplication by everywhere; dzpuis is not changed.
const Vector & derive_con(const Metric &gam) const
Returns the "contravariant" derivative of *this with respect to some metric , by raising the index of...
Vector w_shift
Vector used in the decomposition of shift , following Shibata's prescription [Prog.
Scalar logn
Logarithm of the lapse N .
Scalar nuq
Part of the Metric potential = logn generated by the quadratic terms.
Scalar ssjm1_khi
Effective source at the previous step for the resolution of the Poisson equation for the scalar by m...
Scalar nuf
Part of the Metric potential = logn generated by the matter terms.
Scalar ssjm1_nuq
Effective source at the previous step for the resolution of the Poisson equation for nuq by means of ...
void update_metric()
Computes metric coefficients from known potentials.
Vector ssjm1_wshift
Effective source at the previous step for the resolution of the vector Poisson equation for .
void fait_nphi()
Computes tnphi and nphi from the Cartesian components of the shift, stored in shift .
Scalar khi_shift
Scalar used in the decomposition of shift , following Shibata's prescription [Prog.
Scalar ssjm1_nuf
Effective source at the previous step for the resolution of the Poisson equation for nuf by means of ...
Scalar tggg
Metric potential .
Scalar ssjm1_tggg
Effective source at the previous step for the resolution of the Poisson equation for tggg .
Scalar dzeta
Metric potential .
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
double & set(int i)
Read/write of a particular element (index i) (1D case).
Tensor handling *** DEPRECATED : use class Tensor instead ***.
Cmp & set()
Read/write for a scalar (see also operator=(const Cmp&) ).
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
void poisson_vect(double lambda, Param &par, Tenseur &shift, Tenseur &vect, Tenseur &scal) const
Solves the vectorial Poisson equation : .
Values and coefficients of a (real-value) function.
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
void coef() const
Computes the coeffcients of *this.
Tensor field of valence 1.
virtual void change_triad(const Base_vect &)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
Scalar & set(int)
Read/write access to a component.
Cmp sqrt(const Cmp &)
Square root.
Cmp log10(const Cmp &)
Basis 10 logarithm.
Tbl diffrel(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (norme version).
Cmp cos(const Cmp &)
Cosine.
Cmp log(const Cmp &)
Neperian logarithm.
Tensor up(int ind, const Metric &gam) const
Computes a new tensor by raising an index of *this.
Tenseur contract(const Tenseur &, int id1, int id2)
Self contraction of two indices of a Tenseur .
Coord phi
coordinate centered on the grid
Standard units of space, time and mass.