30char et_bfrot_equilibre_C[] =
"$Header: /cvsroot/Lorene/C++/Source/Etoile/et_bfrot_equilibre.C,v 1.20 2015/06/10 14:39:17 a_sourie Exp $" ;
117#include "et_rot_bifluid.h"
121#include "graphique.h"
122#include "utilitaires.h"
135(
double ent_c,
double ent2_c,
double omega0,
double omega20,
136 const Tbl& ent_limit,
const Tbl& ent2_limit,
const Itbl& icontrol,
137 const Tbl& control,
Tbl& diff,
138 int mer_mass,
double mbar1_wanted,
double mbar2_wanted,
double aexp_mass)
147 char display_bold[]=
"x[1m" ; display_bold[0] = 27 ;
148 char display_normal[] =
"x[0m" ; display_normal[0] = 27 ;
162 int i_b = mg->
get_nr(l_b) - 1 ;
163 int j_b = mg->
get_nt(l_b) - 1 ;
167 double ent1_b = ent_limit(
nzet-1) ;
168 double ent2_b = ent2_limit(
nzet-1) ;
176 int mer_max = icontrol(0) ;
177 int mer_rot = icontrol(1) ;
178 int mer_change_omega = icontrol(2) ;
179 int mer_fix_omega = icontrol(3) ;
180 int mermax_poisson = icontrol(4) ;
181 int nzadapt = icontrol(5);
182 int kepler_fluid = icontrol(6);
183 int kepler_wait_steps = icontrol(7);
184 int mer_triax = icontrol(8) ;
189 if (mer_change_omega < mer_rot) {
190 cout <<
"Et_rot_bifluid::equilibrium: mer_change_omega < mer_rot !" << endl ;
191 cout <<
" mer_change_omega = " << mer_change_omega << endl ;
192 cout <<
" mer_rot = " << mer_rot << endl ;
195 if (mer_fix_omega < mer_change_omega) {
196 cout <<
"Et_rot_bifluid::equilibrium: mer_fix_omega < mer_change_omega !"
198 cout <<
" mer_fix_omega = " << mer_fix_omega << endl ;
199 cout <<
" mer_change_omega = " << mer_change_omega << endl ;
203 double precis = control(0) ;
204 double omega_ini = control(1) ;
205 double omega2_ini = control(2) ;
206 double relax = control(3) ;
207 double relax_prev = double(1) - relax ;
208 double relax_poisson = control(4) ;
210 double thres_adapt = control(5) ;
211 double precis_adapt = control(6) ;
212 double kepler_factor = control(7);
213 if (kepler_factor <= 1.0)
215 cout <<
"ERROR: Kepler factor has to be greater than 1!!\n";
218 double ampli_triax = control(8) ;
225 double& diff_ent1 = diff.
set(0) ;
226 double& diff_ent2 = diff.
set(1) ;
227 double& diff_nuf = diff.
set(2) ;
228 double& diff_nuq = diff.
set(3) ;
231 double& diff_shift_x = diff.
set(6) ;
232 double& diff_shift_y = diff.
set(7) ;
233 double& vit_triax = diff.
set(8) ;
243 int nz_search =
nzet + 1 ;
246 double reg_map = 1. ;
248 par_adapt.
add_int(nitermax, 0) ;
250 par_adapt.
add_int(nzadapt, 1) ;
253 par_adapt.
add_int(nz_search, 2) ;
255 par_adapt.
add_int(adapt_flag, 3) ;
274 par_adapt.
add_tbl(ent_limit, 0) ;
281 double precis_poisson = 1.e-16 ;
283 Param par_poisson_nuf ;
284 par_poisson_nuf.
add_int(mermax_poisson, 0) ;
285 par_poisson_nuf.
add_double(relax_poisson, 0) ;
286 par_poisson_nuf.
add_double(precis_poisson, 1) ;
290 Param par_poisson_nuq ;
291 par_poisson_nuq.
add_int(mermax_poisson, 0) ;
292 par_poisson_nuq.
add_double(relax_poisson, 0) ;
293 par_poisson_nuq.
add_double(precis_poisson, 1) ;
297 Param par_poisson_tggg ;
298 par_poisson_tggg.
add_int(mermax_poisson, 0) ;
299 par_poisson_tggg.
add_double(relax_poisson, 0) ;
300 par_poisson_tggg.
add_double(precis_poisson, 1) ;
306 Param par_poisson_dzeta ;
313 Param par_poisson_vect ;
315 par_poisson_vect.
add_int(mermax_poisson, 0) ;
316 par_poisson_vect.
add_double(relax_poisson, 0) ;
317 par_poisson_vect.
add_double(precis_poisson, 1) ;
330 double accrois_omega = (omega0 - omega_ini) /
331 double(mer_fix_omega - mer_change_omega) ;
332 double accrois_omega2 = (omega20 - omega2_ini) /
333 double(mer_fix_omega - mer_change_omega) ;
388 ofstream fichconv(
"convergence.d") ;
389 fichconv <<
"# diff_ent GRV2 max_triax vit_triax" << endl ;
391 ofstream fichfreq(
"frequency.d") ;
392 fichfreq <<
"# f1 [Hz] f2 [Hz]" << endl ;
394 ofstream fichevol(
"evolution.d") ;
395 fichevol <<
"# r_pole/r_eq ent_c ent2_c" << endl ;
398 double err_grv2 = 1 ;
399 double max_triax_prev = 0 ;
405 for(
int mer=0 ; (diff_ent > precis) && (mer<mer_max) ; mer++ ) {
407 cout <<
"-----------------------------------------------" << endl ;
408 cout <<
"step: " << mer << endl ;
409 cout <<
"diff_ent = " << display_bold << diff_ent << display_normal
411 cout <<
"err_grv2 = " << err_grv2 << endl ;
416 if (mer >= mer_rot) {
418 if (mer < mer_change_omega) {
423 if (mer <= mer_fix_omega) {
424 omega = omega_ini + accrois_omega *
425 (mer - mer_change_omega) ;
426 omega2 = omega2_ini + accrois_omega2 *
427 (mer - mer_change_omega) ;
468 (source_tggg.
set()).mult_rsint() ;
488 for (
int i=0; i<3; i++) {
489 source_shift.
set(i) += squad(i) ;
499 source_nuf().poisson(par_poisson_nuf,
nuf.
set()) ;
510 if (mer == mer_triax) {
512 if ( mg->
get_np(0) == 1 ) {
514 "Et_rot_bifluid::equilibrium: np must be stricly greater than 1"
515 << endl <<
" to set a triaxial perturbation !" << endl ;
522 perturb = 1 + ampli_triax * sint*sint *
cos(2*phi) ;
536 double max_triax = 0 ;
538 if ( mg->
get_np(0) > 1 ) {
540 for (
int l=0; l<nz; l++) {
541 for (
int j=0; j<mg->
get_nt(l); j++) {
542 for (
int i=0; i<mg->
get_nr(l); i++) {
545 double xcos2p = (*(va_nuf.
c_cf))(l, 2, j, i) ;
548 double xsin2p = (*(va_nuf.
c_cf))(l, 3, j, i) ;
550 double xx =
sqrt( xcos2p*xcos2p + xsin2p*xsin2p ) ;
552 max_triax = ( xx > max_triax ) ? xx : max_triax ;
557 cout <<
"Triaxial part of nuf : " << max_triax << endl ;
565 source_nuq().poisson(par_poisson_nuq,
nuq.
set()) ;
576 if (source_shift.
get_etat() != ETATZERO) {
578 for (
int i=0; i<3; i++) {
579 if(source_shift(i).dz_nonzero()) {
580 assert( source_shift(i).get_dzpuis() == 4 ) ;
583 (source_shift.
set(i)).set_dzpuis(4) ;
589 double lambda_shift = double(1) / double(3) ;
591 if ( mg->
get_np(0) == 1 ) {
595 source_shift.
poisson_vect(lambda_shift, par_poisson_vect,
621 bool too_fast =
false;
623 if ( (kepler_fluid > 0) && (mer > mer_fix_omega + kepler_wait_steps) )
625 if (kepler_fluid & 0x01)
626 omega *= kepler_factor;
627 if (kepler_fluid & 0x02)
652 mlngamma = - 0.5 *
uuu*
uuu ;
657 double nuf_c =
nuf()(0,0,0,0) ;
658 double nuq_c =
nuq()(0,0,0,0) ;
667 double nuf_b =
nuf()(l_b, k_b, j, i_b) ;
668 double nuq_b =
nuq()(l_b, k_b, j, i_b) ;
669 double mlngamma_b = mlngamma()(l_b, k_b, j, i_b) ;
670 double mlngamma2_b = mlngamma2()(l_b, k_b, j, i_b) ;
678 if (eos0.get_typeos() == 5)
680 double vn_b =
uuu()(l_b, k_b, j, i_b);
681 double vp_b =
uuu2()(l_b, k_b, j, i_b);
682 double D2_b = (vp_b - vn_b)*(vp_b - vn_b);
684 double kaps1 = kdet / ( eos0.
get_kap2() - kdet );
685 double kaps2 = kdet / ( eos0.
get_kap1() - kdet );
687 ent1_b = kaps1 * ( ent2_c - ent_c - mlngamma2_b + mlngamma_b );
688 ent2_b = kaps2 * ( ent_c - ent2_c - mlngamma_b + mlngamma2_b );
690 cout <<
"**********************************************************************\n";
691 cout <<
"DEBUG: Rescaling domain for slow-rot-style EOS inversion \n";
692 cout <<
"DEBUG: ent1_b = " << ent1_b <<
"; ent2_b = " << ent2_b << endl;
693 cout <<
"**********************************************************************\n";
699 double alpha1_r2 = ( ent_c - ent1_b - mlngamma_b + nuq_c - nuq_b) / ( nuf_b - nuf_c ) ;
700 double alpha2_r2 = ( ent2_c - ent2_b - mlngamma2_b + nuq_c - nuq_b) / ( nuf_b - nuf_c ) ;
702 cout <<
"DEBUG: j= "<< j<<
" ; alpha1 = " << alpha1_r2 <<
" ; alpha2 = " << alpha2_r2 << endl;
704 int outer_fluid = (alpha1_r2 > alpha2_r2) ? 1 : 2;
706 outer_ent_p = (outer_fluid == 1) ? (&
ent) : (&
ent2);
708 alpha_r2 = (outer_fluid == 1) ? alpha1_r2 : alpha2_r2 ;
710 alpha_r =
sqrt(alpha_r2);
712 cout <<
"alpha_r = " << alpha_r << endl ;
718 double nu_c =
logn()(0,0,0,0) ;
724 ent = (ent_c + nu_c) -
logn - mlngamma ;
725 ent2 = (ent2_c + nu_c) -
logn - mlngamma2 ;
732 for (
int l=0; l<
nzet; l++) {
733 int imax = mg->
get_nr(l) - 1 ;
734 if (l == l_b) imax-- ;
735 for (
int i=0; i<imax; i++) {
736 if ( (*outer_ent_p)()(l, 0, j_b, i) < 0. ) {
738 cout <<
"(outer) ent < 0 for l, i : " << l <<
" " << i
739 <<
" ent = " << (*outer_ent_p)()(l, 0, j_b, i) << endl ;
746 cout <<
"**** KEPLERIAN VELOCITY REACHED ****" << endl ;
747 if (kepler_fluid & 0x01)
748 omega /= kepler_factor ;
749 if (kepler_fluid & 0x02)
752 cout <<
"New rotation frequencies : "
753 <<
"Omega = " <<
omega/(2.*M_PI) * f_unit <<
" Hz; "
754 <<
"Omega2 = " <<
omega2/(2.*M_PI) * f_unit << endl ;
764 kepler_factor =
sqrt( kepler_factor ) ;
765 cout <<
"**** New fact_omega : " << kepler_factor << endl ;
772 double dent_eq = (*outer_ent_p)().dsdr()(l_b, k_b, j_b, i_b) ;
773 double dent_pole = (*outer_ent_p)().dsdr()(l_b, k_b, 0, i_b) ;
774 double rap_dent = fabs( dent_eq / dent_pole ) ;
775 cout <<
"| dH/dr_eq / dH/dr_pole | = " << rap_dent << endl ;
777 if ( rap_dent < thres_adapt ) {
779 cout <<
"******* FROZEN MAPPING *********" << endl ;
784 if (adapt_flag && (nzadapt > 0) )
788 mp.
adapt( (*outer_ent_p)(), par_adapt) ;
832 err_grv2 = lbda_grv2 - 1;
833 cout <<
"GRV2: " << err_grv2 << endl ;
848 logn = relax *
logn + relax_prev * logn_prev ;
850 dzeta = relax *
dzeta + relax_prev * dzeta_prev ;
862 fichfreq <<
" " <<
omega / (2*M_PI) * f_unit ;
863 fichfreq <<
" " <<
omega2 / (2*M_PI) * f_unit ;
865 fichevol <<
" " << ent_c ;
866 fichevol <<
" " << ent2_c ;
876 cout <<
"DEBUG MODE : mbar1_wanted : " << mbar1_wanted << endl ;
877 cout <<
"DEBUG MODE : mbar2_wanted : " << mbar2_wanted << endl ;
878 if (mbar2_wanted != 0 )
881 if ((mer_mass>0) && (mer > mer_mass)) {
883 double xx, xprog, ax, fact;
886 xx =
mass_b1() / mbar1_wanted - 1. ;
887 cout <<
"Discrep. baryon mass1 <-> wanted bar. mass1 : " << xx << endl ;
889 xprog = ( mer > 2*mer_mass) ? 1. : double(mer - mer_mass)/double(mer_mass) ;
891 ax = 0.5 * ( 2. + xx ) / (1. + xx ) ;
892 fact =
pow(ax, aexp_mass) ;
893 cout <<
"Fluid1: xprog, xx, ax, fact : " << xprog <<
" " << xx <<
" " << ax <<
" " << fact << endl ;
897 xx =
mass_b2() / mbar2_wanted - 1. ;
898 cout <<
"Discrep. baryon mass2 <-> wanted bar. mass2 : " << xx << endl ;
900 xprog = ( mer > 2*mer_mass) ? 1. : double(mer - mer_mass)/double(mer_mass) ;
902 ax = 0.5 * ( 2. + xx ) / (1. + xx ) ;
903 fact =
pow(ax, aexp_mass) ;
904 cout <<
"Fluid2: xprog, xx, ax, fact : " << xprog <<
" " << xx <<
" " << ax <<
" " << fact << endl ;
906 cout <<
"H1c = " << ent_c <<
" H2c = " << ent2_c << endl ;
915 if ((mer_mass>0) && (mer > mer_mass)) {
917 double xx, xprog, ax, fact;
920 xx =
mass_b() / mbar1_wanted - 1. ;
921 cout <<
"Discrep. baryon mass <-> wanted bar. mass : " << xx << endl ;
923 xprog = ( mer > 2*mer_mass) ? 1. : double(mer - mer_mass)/double(mer_mass) ;
925 ax = 0.5 * ( 2. + xx ) / (1. + xx ) ;
926 fact =
pow(ax, aexp_mass) ;
927 cout <<
"Fluid1: xprog, xx, ax, fact : " << xprog <<
" " << xx <<
" " << ax <<
" " << fact << endl ;
930 double m1 = 1.009000285 ;
931 double m2 = 1.008160139 ;
932 ent2_c = ent_c +
log(m1/m2);
933 cout <<
"DEBUG MODE : ent_c " << ent_c << endl ;
934 cout <<
"DEBUG MODE : ent2_c " << ent2_c << endl ;
935 cout <<
"H1c = " << ent_c <<
" H2c = " << ent2_c << endl ;
950 diff_ent1 = diff_ent_tbl(0) ;
951 for (
int l=1; l<
nzet; l++) {
952 diff_ent1 += diff_ent_tbl(l) ;
956 diff_ent2 = diff_ent_tbl(0) ;
957 for (
int l=1; l<
nzet; l++) {
958 diff_ent2 += diff_ent_tbl(l) ;
961 diff_ent = 0.5*(diff_ent1 + diff_ent2) ;
963 fichconv <<
" " <<
log10( fabs(diff_ent) + 1.e-16 ) ;
964 fichconv <<
" " <<
log10( fabs(err_grv2) + 1.e-16 ) ;
965 fichconv <<
" " <<
log10( fabs(max_triax) + 1.e-16 ) ;
968 if ( (mer > mer_triax+1) && (max_triax_prev > 1e-13) ) {
969 vit_triax = (max_triax - max_triax_prev) / max_triax_prev ;
972 fichconv <<
" " << vit_triax ;
982 max_triax_prev = max_triax ;
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Valeur va
The numerical value of the Cmp
Active physical coordinates and mapping derivatives.
Analytic equation of state for two fluids (Newtonian case).
double get_kap1() const
Returns the pressure coefficient [unit: ], where .
double get_kap3() const
Returns the pressure coefficient [unit: ], where .
double get_beta() const
Returns the coefficient [unit: ], where .
double get_kap2() const
Returns the pressure coefficient [unit: ], where .
virtual int identify() const =0
Returns a number to identify the sub-classe of Eos_bifluid the object belongs to.
void equilibrium_bi(double ent_c, double ent_c2, double omega0, double omega20, const Tbl &ent_limit, const Tbl &ent2_limit, const Itbl &icontrol, const Tbl &control, Tbl &diff, int mer_mass, double mbar1_wanted, double mbar2_wanted, double aexp_mass)
Computes an equilibrium configuration.
Tenseur gam_euler2
Lorentz factor between the fluid 2 and Eulerian observers
Tenseur enerps_euler
the combination : useful because in the Newtonian limit .
Tenseur sphph_euler
The component of the stress tensor .
virtual double mass_b() const
Total Baryon mass.
Tenseur j_euler
Total angular momentum (flat-space!) 3-vector , which is related to of the "3+1" decomposition,...
virtual void equation_of_state()
Computes the proper baryon and energy densities, as well as pressure and the coefficients Knn,...
double omega2
Rotation angular velocity for fluid 2 ([f_unit] )
const Eos_bifluid & eos
Equation of state for two-fluids model.
double mass_b1() const
Baryon mass of fluid 1.
Tenseur uuu2
Norm of the (fluid no.2) 3-velocity with respect to the eulerian observer.
double mass_b2() const
Baryon mass of fluid 2.
virtual double grv2() const
Error on the virial identity GRV2.
Tenseur ent2
Log-enthalpy for the second fluid.
virtual void hydro_euler()
Computes the hydrodynamical quantities relative to the Eulerian observer from those in the fluid fram...
Tenseur ssjm1_wshift
Effective source at the previous step for the resolution of the vector Poisson equation for .
Tenseur uuu
Norm of u_euler.
double omega
Rotation angular velocity ([f_unit] )
Tenseur & logn
Metric potential = logn_auto.
Tenseur nuq
Part of the Metric potential = logn generated by the quadratic terms.
Tenseur khi_shift
Scalar used in the decomposition of shift , following Shibata's prescription [Prog.
Tenseur tggg
Metric potential .
Tenseur nuf
Part of the Metric potential = logn generated by the matter terms.
Cmp ssjm1_tggg
Effective source at the previous step for the resolution of the Poisson equation for tggg .
Tenseur bbb
Metric factor B.
void update_metric()
Computes metric coefficients from known potentials.
Tenseur & dzeta
Metric potential = beta_auto.
Cmp ssjm1_nuf
Effective source at the previous step for the resolution of the Poisson equation for nuf by means of ...
void fait_nphi()
Computes tnphi and nphi from the Cartesian components of the shift, stored in shift .
Cmp ssjm1_khi
Effective source at the previous step for the resolution of the Poisson equation for the scalar by m...
Tenseur_sym tkij
Tensor related to the extrinsic curvature tensor by .
Cmp ssjm1_nuq
Effective source at the previous step for the resolution of the Poisson equation for nuq by means of ...
Tenseur w_shift
Vector used in the decomposition of shift , following Shibata's prescription [Prog.
int nzet
Number of domains of *mp occupied by the star.
double ray_eq() const
Coordinate radius at , [r_unit].
Tenseur nnn
Total lapse function.
Tenseur gam_euler
Lorentz factor between the fluid and Eulerian observers.
Map & mp
Mapping associated with the star.
bool relativistic
Indicator of relativity: true for a relativistic star, false for a Newtonian one.
Tenseur shift
Total shift vector.
Tenseur s_euler
Trace of the stress tensor in the Eulerian frame.
Tenseur ent
Log-enthalpy (relativistic case) or specific enthalpy (Newtonian case)
Tenseur a_car
Total conformal factor .
double ray_pole() const
Coordinate radius at [r_unit].
Basic integer array class.
Radial mapping of rather general form.
virtual void homothetie(double lambda)
Sets a new radial scale.
const Base_vect_cart & get_bvect_cart() const
Returns the Cartesian basis associated with the coordinates (x,y,z) of the mapping,...
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.
virtual void homothetie(double lambda)=0
Sets a new radial scale.
virtual void adapt(const Cmp &ent, const Param &par, int nbr=0)=0
Adaptation of the mapping to a given scalar field.
const Cmp & cmp_zero() const
Returns the null Cmp defined on *this.
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.
Coord phi
coordinate centered on the grid
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
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.
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 set_std_base()
Set the standard spectal basis of decomposition for each component.
const Tenseur & gradient_spher() const
Returns the gradient of *this (Spherical coordinates) (scalar field only).
void change_triad(const Base_vect &new_triad)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
void poisson_vect(double lambda, Param &par, Tenseur &shift, Tenseur &vect, Tenseur &scal) const
Solves the vectorial Poisson equation : .
int get_etat() const
Returns the logical state.
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.
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 pow(const Cmp &, int)
Power .
Cmp cos(const Cmp &)
Cosine.
Cmp log(const Cmp &)
Neperian logarithm.
Tenseur flat_scalar_prod(const Tenseur &t1, const Tenseur &t2)
Scalar product of two Tenseur when the metric is : performs the contraction of the last index of t1 w...
Standard units of space, time and mass.