32 #include "star_rot_diff.h" 34 #include "graphique.h" 35 #include "utilitaires.h" 43 int nzadapt,
const Tbl& ent_limit,
45 const Tbl& control,
double mbar_wanted,
46 double aexp_mass,
Tbl& diff,
Param*){
54 char display_bold[]=
"x[1m" ; display_bold[0] = 27 ;
55 char display_normal[] =
"x[0m" ; display_normal[0] = 27 ;
71 int i_b = mg->
get_nr(l_b) - 1 ;
72 int j_b = mg->
get_nt(l_b) - 1 ;
76 double ent_b = ent_limit(
nzet-1) ;
81 int mer_max = icontrol(0) ;
82 int mer_rot = icontrol(1) ;
83 int mer_change_omega = icontrol(2) ;
84 int mer_fix_omega = icontrol(3) ;
85 int mer_mass = icontrol(4) ;
86 int mermax_poisson = icontrol(5) ;
87 int mer_triax = icontrol(6) ;
88 int delta_mer_kep = icontrol(7) ;
91 if (mer_change_omega < mer_rot) {
92 cout <<
"Star_rot_diff::equilibrium: mer_change_omega < mer_rot !" << endl ;
93 cout <<
" mer_change_omega = " << mer_change_omega << endl ;
94 cout <<
" mer_rot = " << mer_rot << endl ;
97 if (mer_fix_omega < mer_change_omega) {
98 cout <<
"Star_rot_diff::equilibrium: mer_fix_omega < mer_change_omega !" 100 cout <<
" mer_fix_omega = " << mer_fix_omega << endl ;
101 cout <<
" mer_change_omega = " << mer_change_omega << endl ;
107 bool change_ent = true ;
110 mer_mass =
abs(mer_mass) ;
113 double precis = control(0) ;
114 double omega_ini = control(1) ;
115 double relax = control(2) ;
116 double relax_prev = double(1) - relax ;
117 double relax_poisson = control(3) ;
118 double thres_adapt = control(4) ;
119 double ampli_triax = control(5) ;
120 double precis_adapt = control(6) ;
127 double& diff_ent = diff.
set(0) ;
128 double& diff_nuf = diff.
set(1) ;
129 double& diff_nuq = diff.
set(2) ;
132 double& diff_shift_x = diff.
set(5) ;
133 double& diff_shift_y = diff.
set(6) ;
134 double& vit_triax = diff.
set(7) ;
145 int nz_search =
nzet + 1 ;
148 double reg_map = 1. ;
150 par_adapt.
add_int(nitermax, 0) ;
152 par_adapt.
add_int(nzadapt, 1) ;
155 par_adapt.
add_int(nz_search, 2) ;
157 par_adapt.
add_int(adapt_flag, 3) ;
176 par_adapt.
add_tbl(ent_limit, 0) ;
182 double precis_poisson = 1.e-16 ;
188 for (
int i=1; i<=3; i++) {
194 for (
int i=1; i<=3; i++) {
195 cshift.set(i-1) = -
beta(i) ;
200 for (
int i=1; i<=3; i++) {
201 cw_shift.set(i-1) =
w_shift(i) ;
208 Param par_poisson_nuf ;
209 par_poisson_nuf.
add_int(mermax_poisson, 0) ;
210 par_poisson_nuf.
add_double(relax_poisson, 0) ;
211 par_poisson_nuf.
add_double(precis_poisson, 1) ;
215 Param par_poisson_nuq ;
216 par_poisson_nuq.
add_int(mermax_poisson, 0) ;
217 par_poisson_nuq.
add_double(relax_poisson, 0) ;
218 par_poisson_nuq.
add_double(precis_poisson, 1) ;
222 Param par_poisson_tggg ;
223 par_poisson_tggg.
add_int(mermax_poisson, 0) ;
224 par_poisson_tggg.
add_double(relax_poisson, 0) ;
225 par_poisson_tggg.
add_double(precis_poisson, 1) ;
231 Param par_poisson_dzeta ;
238 Param par_poisson_vect ;
240 par_poisson_vect.
add_int(mermax_poisson, 0) ;
241 par_poisson_vect.
add_double(relax_poisson, 0) ;
242 par_poisson_vect.
add_double(precis_poisson, 1) ;
254 double accrois_omega = (omega_c0 - omega_ini) /
255 double(mer_fix_omega - mer_change_omega) ;
307 ofstream fichconv(
"convergence.d") ;
308 fichconv <<
"# diff_ent GRV2 max_triax vit_triax" << endl ;
310 ofstream fichfreq(
"frequency.d") ;
311 fichfreq <<
"# f [Hz]" << endl ;
313 ofstream fichevol(
"evolution.d") ;
315 "# |dH/dr_eq/dH/dr_pole| r_pole/r_eq ent_c" 319 double err_grv2 = 1 ;
320 double max_triax_prev = 0 ;
326 for(
int mer=0 ; (diff_ent > precis) && (mer<mer_max) ; mer++ ) {
328 cout <<
"-----------------------------------------------" << endl ;
329 cout <<
"step: " << mer << endl ;
330 cout <<
"diff_ent = " << display_bold << diff_ent << display_normal
332 cout <<
"err_grv2 = " << err_grv2 << endl ;
338 if (mer >= mer_rot) {
340 if (mer < mer_change_omega) {
341 omega_c = omega_ini ;
344 if (mer <= mer_fix_omega) {
345 omega_c = omega_ini + accrois_omega *
346 (mer - mer_change_omega) ;
367 source_nuq =
ak_car - d_logn(1)*(d_logn(1)+d_bet(1))
368 - d_logn(2)*(d_logn(2)+d_bet(2))
369 - d_logn(3)*(d_logn(3)+d_bet(3)) ;
372 source_nuf = qpig *
nbar ;
385 - d_logn(1)*d_logn(1) - d_logn(2)*d_logn(2) - d_logn(3)*d_logn(3) ;
419 cout <<
"Test of the Poisson equation for nuf :" << endl ;
421 diff_nuf = err(0, 0) ;
427 if (mer == mer_triax) {
429 if ( mg->
get_np(0) == 1 ) {
431 "Star_rot_diff::equilibrium: np must be stricly greater than 1" 432 << endl <<
" to set a triaxial perturbation !" << endl ;
439 perturb = 1 + ampli_triax * sint*sint *
cos(2*phi) ;
453 double max_triax = 0 ;
455 if ( mg->
get_np(0) > 1 ) {
457 for (
int l=0; l<nz; l++) {
458 for (
int j=0; j<mg->
get_nt(l); j++) {
459 for (
int i=0; i<mg->
get_nr(l); i++) {
462 double xcos2p = (*(va_nuf.
c_cf))(l, 2, j, i) ;
465 double xsin2p = (*(va_nuf.
c_cf))(l, 3, j, i) ;
467 double xx =
sqrt( xcos2p*xcos2p + xsin2p*xsin2p ) ;
469 max_triax = ( xx > max_triax ) ? xx : max_triax ;
476 cout <<
"Triaxial part of nuf : " << max_triax << endl ;
486 cout <<
"Test of the Poisson equation for nuq :" << endl ;
488 diff_nuq = err(0, 0) ;
494 for (
int i=1; i<=3; i++) {
495 if(source_shift(i).get_etat() != ETATZERO) {
496 if(source_shift(i).dz_nonzero()) {
497 assert( source_shift(i).get_dzpuis() == 4 ) ;
500 (source_shift.set(i)).set_dzpuis(4) ;
505 double lambda_shift = double(1) / double(3) ;
507 if ( mg->
get_np(0) == 1 ) {
513 if ( (source_shift(1).get_etat() == ETATZERO) &&
514 (source_shift(2).get_etat() == ETATZERO) &&
515 (source_shift(3).get_etat() == ETATZERO) ) {
516 csource_shift.set_etat_zero() ;
519 csource_shift.set_etat_qcq() ;
520 for (
int i=1; i<=3; i++) {
521 csource_shift.set(i-1) = source_shift(i) ;
523 csource_shift.set(2).set_etat_zero() ;
526 csource_shift.poisson_vect(lambda_shift, par_poisson_vect,
527 cshift, cw_shift, ckhi_shift) ;
530 for (
int i=1; i<=3; i++) {
536 cout <<
"Test of the Poisson equation for shift_x :" << endl ;
537 err = source_shift(1).test_poisson(-
beta(1), cout,
true) ;
538 diff_shift_x = err(0, 0) ;
540 cout <<
"Test of the Poisson equation for shift_y :" << endl ;
541 err = source_shift(2).test_poisson(-
beta(2), cout,
true) ;
542 diff_shift_y = err(0, 0) ;
556 if (mer > mer_fix_omega + delta_mer_kep) {
558 omega_c *= fact_omega ;
562 bool omega_trop_grand = false ;
569 bool superlum = true ;
584 brst2 = brst2*brst2 ;
588 double F_e = brst2.val_grid_point(l_b, k_b, j_b, i_b) * omnp /
590 brst2.val_grid_point(l_b, k_b, j_b, i_b) * omnp * omnp ) ;
592 if (F_e ==
double(0)) {}
596 double om_lkji, F_max ;
597 for (l=0; l<
nzet+1; l++) {
598 for (k=0; k<mg->
get_np(l); k++) {
599 for (j=0; j<mg->
get_nt(l); j++) {
600 for (i=0; i<mg->
get_nr(l); i++) {
602 if (om_lkji > om_max) {
605 F_max = brst2.val_grid_point(l, k, j, i) * omnp /
607 brst2.val_grid_point(l, k, j, i) * omnp * omnp ) ;
620 / ((lambda1-1)*
pow(F_e, p) - (lambda2-1)*
pow(F_max, p)), 1./(p+q) ) ;
622 / (lambda2*(lambda1-1)*
pow(F_e, p+q) - lambda1*(lambda2-1)*
pow(F_max, p+q)), 1./p) ;
624 cout << F_e <<
" " << F_max << endl ;
629 cout <<
"Parameters of Omega(F) : " <<
par_frot << endl ;
631 double omeg_min = 0 ;
632 double omeg_max =
par_frot(1) * omega_c ;
633 double precis1 = 1.e-14 ;
634 int nitermax1 = 100 ;
643 double omeg_min = 0 ;
644 double omeg_max = omega_c ;
645 double precis1 = 1.e-14 ;
646 int nitermax1 = 100 ;
670 for (
int l=0; l<
nzet; l++) {
671 for (
int i=0; i<mg->
get_nr(l); i++) {
676 cout <<
"U > c for l, i : " << l <<
" " << i
677 <<
" U = " << u1 << endl ;
682 cout <<
"**** VELOCITY OF LIGHT REACHED ****" << endl ;
683 omega_c /= fact_omega ;
684 cout <<
"New central rotation frequency : " 685 <<
omega/(2.*M_PI) * f_unit <<
" Hz" << endl ;
686 omega_trop_grand = true ;
707 mlngamma = - 0.5 *
uuu*
uuu ;
713 double mlngamma_b = mlngamma.val_grid_point(l_b, k_b, j_b, i_b) ;
720 double mlngamma_c = 0 ;
725 double alpha_r2 = ( ent_c - ent_b + mlngamma_c - mlngamma_b
726 + nuq_c - nuq_b + primf_c - primf_b)
727 / ( nuf_b - nuf_c ) ;
728 alpha_r =
sqrt(alpha_r2) ;
729 cout <<
"alpha_r = " << alpha_r << endl ;
747 for (
int l=0; l<
nzet; l++) {
748 int imax = mg->
get_nr(l) - 1 ;
749 if (l == l_b) imax-- ;
750 for (
int i=0; i<imax; i++) {
753 cout <<
"ent < 0 for l, i : " << l <<
" " << i
760 cout <<
"**** KEPLERIAN VELOCITY REACHED ****" << endl ;
761 omega_c /= fact_omega ;
762 cout <<
"New central rotation frequency : " 763 << omega_c/(2.*M_PI) * f_unit <<
" Hz" << endl ;
764 omega_trop_grand = true ;
769 if ( omega_trop_grand ) {
771 fact_omega =
sqrt( fact_omega ) ;
772 cout <<
"**** New fact_omega : " << fact_omega << endl ;
784 double rap_dent = fabs( dent_eq / dent_pole ) ;
785 cout <<
"| dH/dr_eq / dH/dr_pole | = " << rap_dent << endl ;
787 if ( rap_dent < thres_adapt ) {
789 cout <<
"******* FROZEN MAPPING *********" << endl ;
835 Cmp csource_tggg(source_tggg) ;
846 Cmp csource_dzf(source_dzf) ;
847 Cmp csource_dzq(source_dzq) ;
849 mp.
poisson2d(csource_dzf, csource_dzq, par_poisson_dzeta,
853 err_grv2 = lbda_grv2 - 1;
854 cout <<
"GRV2: " << err_grv2 << endl ;
869 logn = relax *
logn + relax_prev * logn_prev ;
871 dzeta = relax *
dzeta + relax_prev * dzeta_prev ;
883 fichfreq <<
" " << omega_c / (2*M_PI) * f_unit ;
884 fichevol <<
" " << rap_dent ;
886 fichevol <<
" " << ent_c ;
892 if (mer > mer_mass) {
895 if (mbar_wanted > 0.) {
896 xx =
mass_b() / mbar_wanted - 1. ;
897 cout <<
"Discrep. baryon mass <-> wanted bar. mass : " << xx
901 xx =
mass_g() / fabs(mbar_wanted) - 1. ;
902 cout <<
"Discrep. grav. mass <-> wanted grav. mass : " << xx
905 double xprog = ( mer > 2*mer_mass) ? 1. :
906 double(mer-mer_mass)/double(mer_mass) ;
908 double ax = .5 * ( 2. + xx ) / (1. + xx ) ;
909 double fact =
pow(ax, aexp_mass) ;
910 cout <<
" xprog, xx, ax, fact : " << xprog <<
" " <<
911 xx <<
" " << ax <<
" " << fact << endl ;
917 if (mer%4 == 0) omega_c *= fact ;
927 diff_ent = diff_ent_tbl(0) ;
928 for (
int l=1; l<
nzet; l++) {
929 diff_ent += diff_ent_tbl(l) ;
933 fichconv <<
" " <<
log10( fabs(diff_ent) + 1.e-16 ) ;
934 fichconv <<
" " <<
log10( fabs(err_grv2) + 1.e-16 ) ;
935 fichconv <<
" " <<
log10( fabs(max_triax) + 1.e-16 ) ;
938 if ( (mer > mer_triax+1) && (max_triax_prev > 1e-13) ) {
939 vit_triax = (max_triax - max_triax_prev) / max_triax_prev ;
942 fichconv <<
" " << vit_triax ;
951 max_triax_prev = max_triax ;
968 for (
int i=1; i<=3; i++) {
virtual double mass_g() const
Gravitational mass.
void annule_domain(int l)
Sets the Tensor to zero in a given domain.
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 ssjm1_wshift
Effective source at the previous step for the resolution of the vector Poisson equation for ...
Scalar dzeta
Metric potential .
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Scalar a_car
Square of the metric factor A.
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.
Map & mp
Mapping associated with the star.
Scalar nuf
Part of the Metric potential = logn generated by the matter terms.
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.
Tbl par_frot
Parameters of the function .
Scalar khi_shift
Scalar used in the decomposition of shift , following Shibata's prescription [Prog.
bool relativistic
Indicator of relativity: true for a relativistic star, false for a Newtonian one. ...
Scalar bbb
Metric factor B.
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.
virtual double grv2() const
Error on the virial identity GRV2.
virtual void adapt(const Cmp &ent, const Param &par, int nbr=0)=0
Adaptation of the mapping to a given scalar field.
int get_type_t() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the equatorial pl...
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. ...
void update_metric()
Computes metric coefficients from known potentials.
Values and coefficients of a (real-value) function.
Scalar nuq
Part of the Metric potential = logn generated by the quadratic terms.
double omega
Rotation angular velocity ([f_unit] )
Scalar nbar
Baryon density in the fluid frame.
virtual void change_triad(const Base_vect &)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
Scalar s_euler
Trace of the stress scalar in the Eulerian frame.
virtual void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
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.
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).
virtual void hydro_euler()
Computes the hydrodynamical quantities relative to the Eulerian observer from those in the fluid fram...
Scalar ssjm1_tggg
Effective source at the previous step for the resolution of the Poisson equation for tggg ...
void add_double_mod(double &x, int position=0)
Adds the address of a new modifiable double to the list.
double val_grid_point(int l, int k, int j, int i) const
Returns the value of the field at a specified grid point.
Coord phi
coordinate centered on the grid
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
int nzet
Number of domains of *mp occupied by the star.
Scalar nphi
Metric coefficient .
virtual void equilibrium(double ent_c, double omega0, double fact_omega, int nzadapt, const Tbl &ent_limit, const Itbl &icontrol, const Tbl &control, double mbar_wanted, double aexp_mass, Tbl &diff, Param *=0x0)
Computes an equilibrium configuration.
Scalar gam_euler
Lorentz factor between the fluid and Eulerian observers.
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 press
Fluid pressure.
virtual double mass_b() const
Baryon mass.
Scalar ssjm1_nuq
Effective source at the previous step for the resolution of the Poisson equation for nuq by means of ...
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.
virtual void homothetie(double lambda)
Sets a new radial scale.
Vector u_euler
Fluid 3-velocity with respect to the Eulerian observer.
Sym_tensor tkij
Tensor related to the extrinsic curvature tensor by .
void mult_rsint()
Multiplication by everywhere; dzpuis is not changed.
Cmp pow(const Cmp &, int)
Power .
Tenseur contract(const Tenseur &, int id1, int id2)
Self contraction of two indices of a Tenseur .
Scalar logn
Logarithm of the lapse N .
Active physical coordinates and mapping derivatives.
double ray_pole() const
Coordinate radius at [r_unit].
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
virtual void partial_display(ostream &) const
Printing of some informations, excluding all global quantities.
void add_scalar_mod(Scalar &ti, int position=0)
Adds the address of a new modifiable Scalar to the list.
const Base_vect_cart & get_bvect_cart() const
Returns the Cartesian basis associated with the coordinates (x,y,z) of the mapping, i.e.
Scalar nn
Lapse function N .
Cmp log10(const Cmp &)
Basis 10 logarithm.
Cmp abs(const Cmp &)
Absolute value.
Scalar ssjm1_khi
Effective source at the previous step for the resolution of the Poisson equation for the scalar by m...
int get_taille() const
Gives the total size (ie dim.taille)
Scalar uuu
Norm of u_euler.
virtual void reevaluate(const Map *mp_prev, int nzet, Cmp &uu) const =0
Recomputes the values of a Cmp at the collocation points after a change in the mapping.
void add_double(const double &x, int position=0)
Adds the the address of a new double to the list.
double ray_eq() const
Coordinate radius at , [r_unit].
const Scalar & dsdr() const
Returns of *this .
Scalar ssjm1_nuf
Effective source at the previous step for the resolution of the Poisson equation for nuf by means of ...
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Valeur & set_spectral_va()
Returns va (read/write version)
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.
Scalar tggg
Metric potential .
void equation_of_state()
Computes the proper baryon and energy density, as well as pressure from the enthalpy.
void fait_nphi()
Computes tnphi and nphi from the Cartesian components of the shift, stored in shift ...
const Vector & derive_cov(const Metric &gam) const
Returns the gradient (1-form = covariant vector) of *this
Vector w_shift
Vector used in the decomposition of shift , following Shibata's prescription [Prog.
void fait_omega_field(double omeg_min, double omeg_max, double precis, int nitermax)
Computes (member omega_field ).
Scalar ener_euler
Total energy density in the Eulerian frame.
const Metric_flat & flat_met_spher() const
Returns the flat metric associated with the spherical coordinates and with components expressed in th...
Scalar omega_field
Field .
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)