64 #include "boson_star.h" 68 #include "graphique.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 ;
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 ;
205 for (
int i=1; i<=3; i++) {
211 for (
int i=1; i<=3; i++) {
212 cshift.set(i-1) = -
beta(i) ;
217 for (
int i=1; i<=3; i++) {
218 cw_shift.set(i-1) =
w_shift(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) ;
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 ;
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 ;
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 ;
402 perturb = 1 + ampli_triax * sint*sint *
cos(2*phi) ;
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 ) {
475 for (
int i=1; i<=3; i++) {
476 csource_shift.set(i-1) = source_shift(i) ;
478 csource_shift.set(2).set_etat_zero() ;
480 csource_shift.poisson_vect(lambda_shift, par_poisson_vect,
481 cshift, cw_shift, ckhi_shift) ;
483 for (
int i=1; i<=3; i++) {
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) ;
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 ;
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++) {
Scalar logn
Logarithm of the lapse N .
Scalar khi_shift
Scalar used in the decomposition of shift , following Shibata's prescription [Prog.
Cmp log(const Cmp &)
Neperian logarithm.
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
void add_tenseur_mod(Tenseur &ti, int position=0)
Adds the address of a new modifiable Tenseur to the list.
Vector mom_euler
Total 3-momentum density in the Eulerian frame.
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Radial mapping of rather general form.
void add_int(const int &n, int position=0)
Adds the address of a new int to the list.
const Cmp & cmp_zero() const
Returns the null Cmp defined on *this.
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
void coef() const
Computes the coeffcients of *this.
Cmp sqrt(const Cmp &)
Square root.
const Base_vect_spher & get_bvect_spher() const
Returns the orthonormal vectorial basis associated with the coordinates of the mapping.
Standard units of space, time and mass.
Tensor up(int ind, const Metric &gam) const
Computes a new tensor by raising an index of *this.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
double & set(int i)
Read/write of a particular element (index i) (1D case)
Tensor field of valence 0 (or component of a tensorial field).
Scalar poisson() const
Solves the scalar Poisson equation with *this as a source.
Scalar nuq
Part of the Metric potential = logn generated by the quadratic terms.
int get_type_t() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the equatorial pl...
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 ...
Basic integer array class.
virtual void std_spectral_base()
Sets the spectral bases of the Valeur va to the standard ones for a scalar field. ...
Values and coefficients of a (real-value) function.
Scalar ssjm1_nuq
Effective source at the previous step for the resolution of the Poisson equation for nuq by means of ...
virtual void change_triad(const Base_vect &)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
Scalar ssjm1_khi
Effective source at the previous step for the resolution of the Poisson equation for the scalar by m...
Sym_tensor kk
Extrinsic curvature tensor .
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.
const Vector & derive_con(const Metric &gam) const
Returns the "contravariant" derivative of *this with respect to some metric , by raising the index of...
Tensor field of valence 1.
Scalar a_car
Square of the metric factor A.
Cmp cos(const Cmp &)
Cosine.
const Metric_flat & flat_met_cart() const
Returns the flat metric associated with the Cartesian coordinates and with components expressed in th...
Tbl diffrel(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (norme version).
Scalar nuf
Part of the Metric potential = logn generated by the matter terms.
void set_dzpuis(int)
Modifies the dzpuis flag.
void add_double_mod(double &x, int position=0)
Adds the address of a new modifiable double to the list.
Coord phi
coordinate centered on the grid
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Scalar b_car
Square of the metric factor B.
Scalar tggg
Metric potential .
Cmp & set()
Read/write for a scalar (see also operator=(const Cmp&) ).
virtual void poisson2d(const Cmp &source_mat, const Cmp &source_quad, Param &par, Cmp &uu) const =0
Computes the solution of a 2-D Poisson equation.
Scalar bbb
Metric factor B.
Scalar ssjm1_tggg
Effective source at the previous step for the resolution of the Poisson equation for tggg ...
Vector beta
Shift vector .
void add_tbl(const Tbl &ti, int position=0)
Adds the address of a new Tbl to the list.
int get_nzone() const
Returns the number of domains.
Vector ssjm1_wshift
Effective source at the previous step for the resolution of the vector Poisson equation for ...
Scalar rphi
Real part of the scalar field Phi.
void mult_rsint()
Multiplication by everywhere; dzpuis is not changed.
Scalar dzeta
Metric potential .
Tenseur contract(const Tenseur &, int id1, int id2)
Self contraction of two indices of a Tenseur .
Active physical coordinates and mapping derivatives.
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
const Base_vect_cart & get_bvect_cart() const
Returns the Cartesian basis associated with the coordinates (x,y,z) of the mapping, i.e.
Cmp log10(const Cmp &)
Basis 10 logarithm.
Scalar ener_euler
Total energy density E in the Eulerian frame.
Scalar ssjm1_nuf
Effective source at the previous step for the resolution of the Poisson equation for nuf by means of ...
void add_double(const double &x, int position=0)
Adds the the address of a new double to the list.
Scalar nn
Lapse function N .
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.
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Scalar & set(int)
Read/write access to a component.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
void add_cmp_mod(Cmp &ti, int position=0)
Adds the address of a new modifiable Cmp to the list.
const Vector & derive_cov(const Metric &gam) const
Returns the gradient (1-form = covariant vector) of *this
const Metric_flat & flat_met_spher() const
Returns the flat metric associated with the spherical coordinates and with components expressed in th...
Tensor handling *** DEPRECATED : use class Tensor instead ***.
void add_int_mod(int &n, int position=0)
Adds the address of a new modifiable int to the list.
const Valeur & get_spectral_va() const
Returns va (read only version)
void fait_nphi()
Computes tnphi and nphi from the Cartesian components of the shift, stored in shift ...
void update_metric()
Computes metric coefficients from known potentials.
Tensor trace(int ind1, int ind2) const
Trace on two different type indices.
Vector w_shift
Vector used in the decomposition of shift , following Shibata's prescription [Prog.
Map & mp
Mapping describing the coordinate system (r,theta,phi)
Sym_tensor stress_euler
Stress tensor with respect to the Eulerian observer.