30 #include "star_rot_cfc.h" 32 #include "utilitaires.h" 37 double fact_omega,
int ,
const Tbl& ent_limit,
38 const Itbl& icontrol,
const Tbl& control,
39 double mbar_wanted,
double aexp_mass,
Tbl& diff){
48 char display_bold[]=
"x[1m" ; display_bold[0] = 27 ;
49 char display_normal[] =
"x[0m" ; display_normal[0] = 27 ;
60 assert( ( type_t == SYM) || (type_t == NONSYM) ) ;
62 int i_b = mg->
get_nr(l_b) - 1 ;
63 int j_b = (type_t == SYM ? mg->
get_nt(l_b) - 1 : mg->
get_nt(l_b)/2 ) ;
67 double ent_b = ent_limit(
nzet-1) ;
72 int mer_max = icontrol(0) ;
73 int mer_rot = icontrol(1) ;
74 int mer_change_omega = icontrol(2) ;
75 int mer_fix_omega = icontrol(3) ;
76 int mer_mass = icontrol(4) ;
77 int delta_mer_kep = icontrol(5) ;
80 if (mer_change_omega < mer_rot) {
81 cout <<
"Star_rot_CFC::equilibrium: mer_change_omega < mer_rot !" 83 cout <<
" mer_change_omega = " << mer_change_omega << endl ;
84 cout <<
" mer_rot = " << mer_rot << endl ;
87 if (mer_fix_omega < mer_change_omega) {
88 cout <<
"Star_rot_CFC::equilibrium: mer_fix_omega < mer_change_omega !" 90 cout <<
" mer_fix_omega = " << mer_fix_omega << endl ;
91 cout <<
" mer_change_omega = " << mer_change_omega << endl ;
97 bool change_ent = true ;
100 mer_mass =
abs(mer_mass) ;
104 double precis = control(0) ;
105 double omega_ini = control(1) ;
106 double relax = control(2) ;
107 double relax_prev = double(1) - relax ;
113 double& diff_ent = diff.
set(0) ;
123 double accrois_omega = (omega0 - omega_ini) /
124 double(mer_fix_omega - mer_change_omega) ;
143 ofstream fichconv(
"convergence.d") ;
144 fichconv <<
"# diff_ent GRV2 max_triax vit_triax" << endl ;
146 ofstream fichfreq(
"frequency.d") ;
147 fichfreq <<
"# f [Hz]" << endl ;
149 ofstream fichevol(
"evolution.d") ;
151 "# |dH/dr_eq/dH/dr_pole| r_pole/r_eq ent_c" 155 double err_grv2 = 1 ;
163 for(
int mer=0 ; (diff_ent > precis) && (mer<mer_max) ; mer++) {
165 cout <<
"-----------------------------------------------" << endl ;
166 cout <<
"step: " << mer << endl ;
167 cout <<
"diff_ent = " << display_bold << diff_ent << display_normal
169 cout <<
"err_grv2 = " << err_grv2 << endl ;
176 if (mer >= mer_rot) {
178 if (mer < mer_change_omega) {
182 if (mer <= mer_fix_omega) {
183 omega = omega_ini + accrois_omega *
184 (mer - mer_change_omega) ;
230 if (mer > mer_fix_omega + delta_mer_kep) {
232 omega *= fact_omega ;
235 bool omega_trop_grand = false ;
242 bool superlum = true ;
271 for (
int l=0; l<
nzet; l++) {
272 for (
int i=0; i<mg->
get_nr(l); i++) {
277 cout <<
"U > c for l, i : " << l <<
" " << i
278 <<
" U = " <<
sqrt( u2 ) << endl ;
283 cout <<
"**** VELOCITY OF LIGHT REACHED ****" << endl ;
284 omega /= fact_omega ;
285 cout <<
"New rotation frequency : " 286 <<
omega/(2.*M_PI) * f_unit <<
" Hz" << endl ;
287 omega_trop_grand = true ;
315 double mlngamma_c = 0 ;
319 double alpha_r2 = ( ent_c - ent_b + mlngamma_c - mlngamma_b
320 + ln_q_c - ln_q_b) / ( ln_f_b - ln_f_c ) ;
322 alpha_r =
sqrt(alpha_r2) ;
324 cout <<
"alpha_r = " << alpha_r << endl ;
333 logn = alpha_r2 * ln_f_new + ln_q_new ;
340 ent = (ent_c + logn_c + mlngamma_c) -
logn - mlngamma ;
349 for (
int l=0; l<
nzet; l++) {
350 int imax = mg->
get_nr(l) - 1 ;
351 if (l == l_b) imax-- ;
352 for (
int i=0; i<imax; i++) {
355 cout <<
"ent < 0 for l, i : " << l <<
" " << i
362 cout <<
"**** KEPLERIAN VELOCITY REACHED ****" << endl ;
363 omega /= fact_omega ;
364 cout <<
"New rotation frequency : " 365 <<
omega/(2.*M_PI) * f_unit <<
" Hz" << endl ;
366 omega_trop_grand = true ;
371 if ( omega_trop_grand ) {
373 fact_omega =
sqrt( fact_omega ) ;
374 cout <<
"**** New fact_omega : " << fact_omega << endl ;
402 logn = relax *
logn + relax_prev * logn_prev ;
404 psi = relax * psi_new + relax_prev * psi_prev ;
418 fichfreq <<
" " <<
omega / (2*M_PI) * f_unit ;
419 fichevol <<
" " << ent_c ;
426 if (mer > mer_mass) {
429 if (mbar_wanted > 0.) {
430 xx =
mass_b() / mbar_wanted - 1. ;
431 cout <<
"Discrep. baryon mass <-> wanted bar. mass : " << xx
435 xx =
mass_g() / fabs(mbar_wanted) - 1. ;
436 cout <<
"Discrep. grav. mass <-> wanted grav. mass : " << xx
439 double xprog = ( mer > 2*mer_mass) ? 1. :
440 double(mer-mer_mass)/double(mer_mass) ;
442 double ax = .5 * ( 2. + xx ) / (1. + xx ) ;
443 double fact =
pow(ax, aexp_mass) ;
444 cout <<
" xprog, xx, ax, fact : " << xprog <<
" " <<
445 xx <<
" " << ax <<
" " << fact << endl ;
451 if (mer%4 == 0)
omega *= fact ;
462 diff_ent = diff_ent_tbl(0) ;
463 for (
int l=1; l<
nzet; l++) {
464 diff_ent += diff_ent_tbl(l) ;
468 fichconv <<
" " <<
log10( fabs(diff_ent) + 1.e-16 ) ;
469 fichconv <<
" " <<
log10( fabs(err_grv2) + 1.e-16 ) ;
Cmp log(const Cmp &)
Neperian logarithm.
Map & mp
Mapping associated with the star.
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).
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).
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. ...
Tensor field of valence 1.
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.
int nzet
Number of domains of *mp occupied by the star.
virtual void hydro_euler()
Computes the hydrodynamical quantities relative to the Eulerian observer from those in the fluid fram...
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.
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 .
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...
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.
Scalar nn
Lapse function N .
Cmp log10(const Cmp &)
Basis 10 logarithm.
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)
Computes an equilibrium configuration.
Cmp abs(const Cmp &)
Absolute value.
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.
virtual double mass_g() const
Gravitational mass.