32 #include "star_rot_diff_cfc.h" 34 #include "graphique.h" 35 #include "utilitaires.h" 41 int ,
const Tbl& ent_limit,
43 const Tbl& control,
double mbar_wanted,
44 double aexp_mass,
Tbl& diff,
Param*){
52 char display_bold[]=
"x[1m" ; display_bold[0] = 27 ;
53 char display_normal[] =
"x[0m" ; display_normal[0] = 27 ;
65 assert( ( type_t == SYM) || (type_t == NONSYM) ) ;
67 int i_b = mg->
get_nr(l_b) - 1 ;
68 int j_b = (type_t == SYM ? mg->
get_nt(l_b) - 1 : mg->
get_nt(l_b)/2 ) ;
72 double ent_b = ent_limit(
nzet-1) ;
77 int mer_max = icontrol(0) ;
78 int mer_rot = icontrol(1) ;
79 int mer_change_omega = icontrol(2) ;
80 int mer_fix_omega = icontrol(3) ;
81 int mer_mass = icontrol(4) ;
82 int mer_triax = icontrol(5) ;
83 int delta_mer_kep = icontrol(6) ;
86 if (mer_change_omega < mer_rot) {
87 cout <<
"Star_rot_diff_CFC::equilibrium: mer_change_omega < mer_rot !" << endl ;
88 cout <<
" mer_change_omega = " << mer_change_omega << endl ;
89 cout <<
" mer_rot = " << mer_rot << endl ;
92 if (mer_fix_omega < mer_change_omega) {
93 cout <<
"Star_rot_diff_CFC::equilibrium: mer_fix_omega < mer_change_omega !" 95 cout <<
" mer_fix_omega = " << mer_fix_omega << endl ;
96 cout <<
" mer_change_omega = " << mer_change_omega << endl ;
102 bool change_ent = true ;
105 mer_mass =
abs(mer_mass) ;
108 double precis = control(0) ;
109 double omega_ini = control(1) ;
110 double relax = control(2) ;
111 double relax_prev = double(1) - relax ;
112 double ampli_triax = control(3) ;
119 double& diff_ent = diff.
set(0) ;
120 double& vit_triax = diff.
set(7) ;
130 double accrois_omega = (omega_c0 - omega_ini) /
131 double(mer_fix_omega - mer_change_omega) ;
150 ofstream fichconv(
"convergence.d") ;
151 fichconv <<
"# diff_ent GRV2 max_triax vit_triax" << endl ;
153 ofstream fichfreq(
"frequency.d") ;
154 fichfreq <<
"# f [Hz]" << endl ;
156 ofstream fichevol(
"evolution.d") ;
158 "# |dH/dr_eq/dH/dr_pole| r_pole/r_eq ent_c" 162 double err_grv2 = 1 ;
163 double max_triax_prev = 0 ;
170 for(
int mer=0 ; (diff_ent > precis) && (mer<mer_max) ; mer++ ) {
172 cout <<
"-----------------------------------------------" << endl ;
173 cout <<
"step: " << mer << endl ;
174 cout <<
"diff_ent = " << display_bold << diff_ent << display_normal
176 cout <<
"err_grv2 = " << err_grv2 << endl ;
182 if (mer >= mer_rot) {
184 if (mer < mer_change_omega) {
185 omega_c = omega_ini ;
188 if (mer <= mer_fix_omega) {
189 omega_c = omega_ini + accrois_omega *
190 (mer - mer_change_omega) ;
227 if (mer == mer_triax) {
229 if ( mg->
get_np(0) == 1 ) {
231 "Star_rot_diff::equilibrium: np must be stricly greater than 1" 232 << endl <<
" to set a triaxial perturbation !" << endl ;
239 perturb = 1 + ampli_triax * sint*sint *
cos(2*phi) ;
240 ln_f_new = ln_f_new * perturb ;
253 double max_triax = 0 ;
255 if ( mg->
get_np(0) > 1 ) {
257 for (
int l=0; l<nz; l++) {
258 for (
int j=0; j<mg->
get_nt(l); j++) {
259 for (
int i=0; i<mg->
get_nr(l); i++) {
262 double xcos2p = (*(va_nuf.
c_cf))(l, 2, j, i) ;
265 double xsin2p = (*(va_nuf.
c_cf))(l, 3, j, i) ;
267 double xx =
sqrt( xcos2p*xcos2p + xsin2p*xsin2p ) ;
269 max_triax = ( xx > max_triax ) ? xx : max_triax ;
276 cout <<
"Triaxial part of nuf : " << max_triax << endl ;
291 if (mer > mer_fix_omega + delta_mer_kep) {
293 omega_c *= fact_omega ;
297 bool omega_trop_grand = false ;
304 bool superlum = true ;
316 for (
int l=
nzet+1; l<nz; l++) {
341 if (F_e !=
double(0)) {
346 for (l=0; l<
nzet+1; l++) {
347 for (k=0; k<mg->
get_np(l); k++) {
348 for (j=0; j<mg->
get_nt(l); j++) {
349 for (i=0; i<mg->
get_nr(l); i++) {
351 if (om_lkji > om_max) {
353 omnp = om_max +
beta(3).val_grid_point(l, k, j, i) ;
365 if (lambda2 == -1.) {
369 lambda1 = (1 +
pow(F_max/(B2*omega_c), p))/(1 +
pow(F_max/(A2*omega_c), q+p)) ;
372 cout <<
"Warning: F_e=" << F_e <<
" < 0. Aborting." << endl ;
395 / ((lambda1-1)*
pow(F_e, p) - (lambda2-1)*
pow(F_max, p)), 1./(p+q) ) ;
397 / (lambda2*(lambda1-1)*
pow(F_e, p+q) - lambda1*(lambda2-1)*
pow(F_max, p+q)), 1./p) ;
399 cout << F_e <<
" " << F_max << endl ;
406 cout <<
"Parameters of Omega(F) : " <<
par_frot << endl ;
408 double omeg_min = 0 ;
409 double omeg_max = lambda1 * omega_c ;
410 double precis1 = 1.e-14 ;
411 int nitermax1 = 200 ;
421 double omeg_min = 0 ;
422 double omeg_max = omega_c ;
423 double precis1 = 1.e-14 ;
424 int nitermax1 = 100 ;
454 for (
int l=0; l<
nzet; l++) {
455 for (
int i=0; i<mg->
get_nr(l); i++) {
460 cout <<
"U > c for l, i : " << l <<
" " << i
461 <<
" U = " <<
sqrt(u2) << endl ;
466 cout <<
"**** VELOCITY OF LIGHT REACHED ****" << endl ;
467 omega_c /= fact_omega ;
468 cout <<
"New central rotation frequency : " 469 <<
omega/(2.*M_PI) * f_unit <<
" Hz" << endl ;
470 omega_trop_grand = true ;
500 double mlngamma_c = 0 ;
505 double alpha_r2 = ( ent_c - ent_b + mlngamma_c - mlngamma_b
506 + ln_q_c - ln_q_b + primf_c - primf_b)
507 / ( ln_f_b - ln_f_c ) ;
508 alpha_r =
sqrt(alpha_r2) ;
510 cout <<
"alpha_r = " << alpha_r << endl ;
519 logn = alpha_r2 * ln_f_new + ln_q_new ;
533 for (
int l=0; l<
nzet; l++) {
534 int imax = mg->
get_nr(l) - 1 ;
535 if (l == l_b) imax-- ;
536 for (
int i=0; i<imax; i++) {
539 cout <<
"ent < 0 for l, i : " << l <<
" " << i
546 cout <<
"**** KEPLERIAN VELOCITY REACHED ****" << endl ;
547 omega_c /= fact_omega ;
548 cout <<
"New central rotation frequency : " 549 << omega_c/(2.*M_PI) * f_unit <<
" Hz" << endl ;
550 omega_trop_grand = true ;
555 if ( omega_trop_grand ) {
557 fact_omega =
sqrt( fact_omega ) ;
558 cout <<
"**** New fact_omega : " << fact_omega << endl ;
586 logn = relax *
logn + relax_prev * logn_prev ;
588 psi = relax * psi_new + relax_prev * psi_prev ;
602 fichfreq <<
" " << omega_c / (2*M_PI) * f_unit ;
604 fichevol <<
" " << ent_c ;
610 if (mer > mer_mass) {
613 if (mbar_wanted > 0.) {
614 xx =
mass_b() / mbar_wanted - 1. ;
615 cout <<
"Discrep. baryon mass <-> wanted bar. mass : " << xx
619 xx =
mass_g() / fabs(mbar_wanted) - 1. ;
620 cout <<
"Discrep. grav. mass <-> wanted grav. mass : " << xx
623 double xprog = ( mer > 2*mer_mass) ? 1. :
624 double(mer-mer_mass)/double(mer_mass) ;
626 double ax = .5 * ( 2. + xx ) / (1. + xx ) ;
627 double fact =
pow(ax, aexp_mass) ;
628 cout <<
" xprog, xx, ax, fact : " << xprog <<
" " <<
629 xx <<
" " << ax <<
" " << fact << endl ;
635 if (mer%4 == 0) omega_c *= fact ;
646 diff_ent = diff_ent_tbl(0) ;
647 for (
int l=1; l<
nzet; l++) {
648 diff_ent += diff_ent_tbl(l) ;
652 fichconv <<
" " <<
log10( fabs(diff_ent) + 1.e-16 ) ;
653 fichconv <<
" " <<
log10( fabs(err_grv2) + 1.e-16 ) ;
654 fichconv <<
" " <<
log10( fabs(max_triax) + 1.e-16 ) ;
657 if ( (mer > mer_triax+1) && (max_triax_prev > 1e-13) ) {
658 vit_triax = (max_triax - max_triax_prev) / max_triax_prev ;
661 fichconv <<
" " << vit_triax ;
670 max_triax_prev = max_triax ;
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.
Map & mp
Mapping associated with the star.
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.
void solve_logn_q(Scalar &ln_q_new) const
Solution of the quadratic part of the Poisson equation for the lapse for rotating stars in CFC...
virtual void set_etat_zero()
Sets the logical state to ETATZERO (zero).
double omega_min
Minimum value of .
virtual void annule(int l_min, int l_max)
Sets the Scalar to zero in several domains.
Scalar psi
Conformal factor .
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.
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 omega_field
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.
Scalar psi4
Conformal factor .
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.
virtual void hydro_euler()
Computes the hydrodynamical quantities relative to the Eulerian observer from those in the fluid fram...
Tensor field of valence 1.
Cmp cos(const Cmp &)
Cosine.
Tbl & set_domain(int l)
Read/write of the value in a given domain.
Tbl diffrel(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (norme version).
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
int nzet
Number of domains of *mp occupied by the star.
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.
double omega
Rotation angular velocity ([f_unit] )
virtual void homothetie(double lambda)=0
Sets a new radial scale.
void solve_shift(Vector &shift_new) const
Solution of the shift equation for rotating stars in CFC.
void fait_omega_field(double omeg_min, double omeg_max, double precis, int nitermax)
Computes (member omega_field ).
Tbl par_frot
Parameters of the function .
int get_nzone() const
Returns the number of domains.
virtual double mass_b() const
Baryonic mass.
Vector u_euler
Fluid 3-velocity with respect to the Eulerian observer.
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.
void solve_logn_f(Scalar &ln_f_new) const
Solution of the `‘matter’' part of the Poisson equation for the lapse for rotating stars in CFC...
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.
void solve_psi(Scalar &psi_new)
Solution of the equations for the conformal factor for rotating stars in CFC.
virtual const Sym_tensor & cov() const
Read-only access to the covariant representation.
virtual void partial_display(ostream &) const
Printing of some informations, excluding all global quantities.
Scalar nn
Lapse function N .
double omega_max
Maximum value of .
Cmp log10(const Cmp &)
Basis 10 logarithm.
Cmp abs(const Cmp &)
Absolute value.
int get_taille() const
Gives the total size (ie dim.taille)
double ray_eq() const
Coordinate radius at , [r_unit].
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 equation_of_state()
Computes the proper baryon and energy density, as well as pressure from the enthalpy.
void update_metric()
Computes metric quantities from known potentials.
virtual double grv2() const
Error on the virial identity GRV2.
void annule_hard()
Sets the Tbl to zero in a hard way.
const Valeur & get_spectral_va() const
Returns va (read only version)
virtual double mass_g() const
Gravitational mass.