123 #include "et_rot_bifluid.h" 127 #include "graphique.h" 128 #include "utilitaires.h" 141 (
double ent_c,
double ent2_c,
double omega0,
double omega20,
142 const Tbl& ent_limit,
const Tbl& ent2_limit,
const Itbl& icontrol,
143 const Tbl& control,
Tbl& diff,
144 int mer_mass,
double mbar1_wanted,
double mbar2_wanted,
double aexp_mass)
153 char display_bold[]=
"x[1m" ; display_bold[0] = 27 ;
154 char display_normal[] =
"x[0m" ; display_normal[0] = 27 ;
159 const Mg3d* mg = mp.get_mg() ;
168 int i_b = mg->
get_nr(l_b) - 1 ;
169 int j_b = mg->
get_nt(l_b) - 1 ;
173 double ent1_b = ent_limit(nzet-1) ;
174 double ent2_b = ent2_limit(nzet-1) ;
182 int mer_max = icontrol(0) ;
183 int mer_rot = icontrol(1) ;
184 int mer_change_omega = icontrol(2) ;
185 int mer_fix_omega = icontrol(3) ;
186 int mermax_poisson = icontrol(4) ;
187 int nzadapt = icontrol(5);
188 int kepler_fluid = icontrol(6);
189 int kepler_wait_steps = icontrol(7);
190 int mer_triax = icontrol(8) ;
195 if (mer_change_omega < mer_rot) {
196 cout <<
"Et_rot_bifluid::equilibrium: mer_change_omega < mer_rot !" << endl ;
197 cout <<
" mer_change_omega = " << mer_change_omega << endl ;
198 cout <<
" mer_rot = " << mer_rot << endl ;
201 if (mer_fix_omega < mer_change_omega) {
202 cout <<
"Et_rot_bifluid::equilibrium: mer_fix_omega < mer_change_omega !" 204 cout <<
" mer_fix_omega = " << mer_fix_omega << endl ;
205 cout <<
" mer_change_omega = " << mer_change_omega << endl ;
209 double precis = control(0) ;
210 double omega_ini = control(1) ;
211 double omega2_ini = control(2) ;
212 double relax = control(3) ;
213 double relax_prev = double(1) - relax ;
214 double relax_poisson = control(4) ;
216 double thres_adapt = control(5) ;
217 double precis_adapt = control(6) ;
218 double kepler_factor = control(7);
219 if (kepler_factor <= 1.0)
221 cout <<
"ERROR: Kepler factor has to be greater than 1!!\n";
224 double ampli_triax = control(8) ;
231 double& diff_ent1 = diff.
set(0) ;
232 double& diff_ent2 = diff.
set(1) ;
233 double& diff_nuf = diff.
set(2) ;
234 double& diff_nuq = diff.
set(3) ;
237 double& diff_shift_x = diff.
set(6) ;
238 double& diff_shift_y = diff.
set(7) ;
239 double& vit_triax = diff.
set(8) ;
249 int nz_search = nzet + 1 ;
252 double reg_map = 1. ;
254 par_adapt.
add_int(nitermax, 0) ;
256 par_adapt.
add_int(nzadapt, 1) ;
259 par_adapt.
add_int(nz_search, 2) ;
261 par_adapt.
add_int(adapt_flag, 3) ;
280 par_adapt.
add_tbl(ent_limit, 0) ;
287 double precis_poisson = 1.e-16 ;
289 Param par_poisson_nuf ;
290 par_poisson_nuf.
add_int(mermax_poisson, 0) ;
291 par_poisson_nuf.
add_double(relax_poisson, 0) ;
292 par_poisson_nuf.
add_double(precis_poisson, 1) ;
296 Param par_poisson_nuq ;
297 par_poisson_nuq.
add_int(mermax_poisson, 0) ;
298 par_poisson_nuq.
add_double(relax_poisson, 0) ;
299 par_poisson_nuq.
add_double(precis_poisson, 1) ;
303 Param par_poisson_tggg ;
304 par_poisson_tggg.
add_int(mermax_poisson, 0) ;
305 par_poisson_tggg.
add_double(relax_poisson, 0) ;
306 par_poisson_tggg.
add_double(precis_poisson, 1) ;
312 Param par_poisson_dzeta ;
319 Param par_poisson_vect ;
321 par_poisson_vect.
add_int(mermax_poisson, 0) ;
322 par_poisson_vect.
add_double(relax_poisson, 0) ;
323 par_poisson_vect.
add_double(precis_poisson, 1) ;
336 double accrois_omega = (omega0 - omega_ini) /
337 double(mer_fix_omega - mer_change_omega) ;
338 double accrois_omega2 = (omega20 - omega2_ini) /
339 double(mer_fix_omega - mer_change_omega) ;
344 equation_of_state() ;
363 Tenseur source_shift(mp, 1, CON, mp.get_bvect_cart()) ;
372 if (nuf.get_etat() == ETATZERO) {
378 if (nuq.get_etat() == ETATZERO) {
383 if (tggg.get_etat() == ETATZERO) {
384 tggg.set_etat_qcq() ;
388 if (dzeta.get_etat() == ETATZERO) {
389 dzeta.set_etat_qcq() ;
394 ofstream fichconv(
"convergence.d") ;
395 fichconv <<
"# diff_ent GRV2 max_triax vit_triax" << endl ;
397 ofstream fichfreq(
"frequency.d") ;
398 fichfreq <<
"# f1 [Hz] f2 [Hz]" << endl ;
400 ofstream fichevol(
"evolution.d") ;
401 fichevol <<
"# r_pole/r_eq ent_c ent2_c" << endl ;
404 double err_grv2 = 1 ;
405 double max_triax_prev = 0 ;
411 for(
int mer=0 ; (diff_ent > precis) && (mer<mer_max) ; mer++ ) {
413 cout <<
"-----------------------------------------------" << endl ;
414 cout <<
"step: " << mer << endl ;
415 cout <<
"diff_ent = " << display_bold << diff_ent << display_normal
417 cout <<
"err_grv2 = " << err_grv2 << endl ;
422 if (mer >= mer_rot) {
424 if (mer < mer_change_omega) {
426 omega2 = omega2_ini ;
429 if (mer <= mer_fix_omega) {
430 omega = omega_ini + accrois_omega *
431 (mer - mer_change_omega) ;
432 omega2 = omega2_ini + accrois_omega2 *
433 (mer - mer_change_omega) ;
449 source_nuf = qpig * a_car * enerps_euler;
457 source_nuq.set_std_base() ;
462 source_dzf = 2 * qpig * a_car * sphph_euler;
465 source_dzq = 1.5 * ak_car -
flat_scalar_prod(logn.gradient_spher(),logn.gradient_spher() ) ;
471 source_tggg = 2 * qpig * nnn * a_car * bbb * (s_euler - sphph_euler);
474 (source_tggg.
set()).mult_rsint() ;
481 source_shift = (-4*qpig) * nnn * a_car * j_euler;
494 for (
int i=0; i<3; i++) {
495 source_shift.set(i) += squad(i) ;
499 source_shift.set_std_base() ;
505 source_nuf().poisson(par_poisson_nuf, nuf.set()) ;
516 if (mer == mer_triax) {
518 if ( mg->
get_np(0) == 1 ) {
520 "Et_rot_bifluid::equilibrium: np must be stricly greater than 1" 521 << endl <<
" to set a triaxial perturbation !" << endl ;
525 const Coord& phi = mp.phi ;
526 const Coord& sint = mp.sint ;
528 perturb = 1 + ampli_triax * sint*sint *
cos(2*phi) ;
529 nuf.set() = nuf() * perturb ;
542 double max_triax = 0 ;
544 if ( mg->
get_np(0) > 1 ) {
546 for (
int l=0; l<nz; l++) {
547 for (
int j=0; j<mg->
get_nt(l); j++) {
548 for (
int i=0; i<mg->
get_nr(l); i++) {
551 double xcos2p = (*(va_nuf.
c_cf))(l, 2, j, i) ;
554 double xsin2p = (*(va_nuf.
c_cf))(l, 3, j, i) ;
556 double xx =
sqrt( xcos2p*xcos2p + xsin2p*xsin2p ) ;
558 max_triax = ( xx > max_triax ) ? xx : max_triax ;
563 cout <<
"Triaxial part of nuf : " << max_triax << endl ;
571 source_nuq().poisson(par_poisson_nuq, nuq.set()) ;
582 if (source_shift.get_etat() != ETATZERO) {
584 for (
int i=0; i<3; i++) {
585 if(source_shift(i).dz_nonzero()) {
586 assert( source_shift(i).get_dzpuis() == 4 ) ;
589 (source_shift.set(i)).set_dzpuis(4) ;
595 double lambda_shift = double(1) / double(3) ;
597 if ( mg->
get_np(0) == 1 ) {
601 source_shift.poisson_vect(lambda_shift, par_poisson_vect,
602 shift, w_shift, khi_shift) ;
627 bool too_fast =
false;
629 if ( (kepler_fluid > 0) && (mer > mer_fix_omega + kepler_wait_steps) )
631 if (kepler_fluid & 0x01)
632 omega *= kepler_factor;
633 if (kepler_fluid & 0x02)
634 omega2 *= kepler_factor;
654 mlngamma = -
log( gam_euler ) ;
655 mlngamma2 = -
log( gam_euler2) ;
658 mlngamma = - 0.5 * uuu*uuu ;
659 mlngamma2 = -0.5 * uuu2*uuu2 ;
663 double nuf_c = nuf()(0,0,0,0) ;
664 double nuq_c = nuq()(0,0,0,0) ;
673 double nuf_b = nuf()(l_b, k_b, j, i_b) ;
674 double nuq_b = nuq()(l_b, k_b, j, i_b) ;
675 double mlngamma_b = mlngamma()(l_b, k_b, j, i_b) ;
676 double mlngamma2_b = mlngamma2()(l_b, k_b, j, i_b) ;
681 if ( eos.identify() == 2 )
684 if (eos0.get_typeos() == 5)
686 double vn_b = uuu()(l_b, k_b, j, i_b);
687 double vp_b = uuu2()(l_b, k_b, j, i_b);
688 double D2_b = (vp_b - vn_b)*(vp_b - vn_b);
690 double kaps1 = kdet / ( eos0.
get_kap2() - kdet );
691 double kaps2 = kdet / ( eos0.
get_kap1() - kdet );
693 ent1_b = kaps1 * ( ent2_c - ent_c - mlngamma2_b + mlngamma_b );
694 ent2_b = kaps2 * ( ent_c - ent2_c - mlngamma_b + mlngamma2_b );
696 cout <<
"**********************************************************************\n";
697 cout <<
"DEBUG: Rescaling domain for slow-rot-style EOS inversion \n";
698 cout <<
"DEBUG: ent1_b = " << ent1_b <<
"; ent2_b = " << ent2_b << endl;
699 cout <<
"**********************************************************************\n";
705 double alpha1_r2 = ( ent_c - ent1_b - mlngamma_b + nuq_c - nuq_b) / ( nuf_b - nuf_c ) ;
706 double alpha2_r2 = ( ent2_c - ent2_b - mlngamma2_b + nuq_c - nuq_b) / ( nuf_b - nuf_c ) ;
708 cout <<
"DEBUG: j= "<< j<<
" ; alpha1 = " << alpha1_r2 <<
" ; alpha2 = " << alpha2_r2 << endl;
710 int outer_fluid = (alpha1_r2 > alpha2_r2) ? 1 : 2;
712 outer_ent_p = (outer_fluid == 1) ? (&ent) : (&ent2);
714 alpha_r2 = (outer_fluid == 1) ? alpha1_r2 : alpha2_r2 ;
716 alpha_r =
sqrt(alpha_r2);
718 cout <<
"alpha_r = " << alpha_r << endl ;
723 logn = alpha_r2 * nuf + nuq ;
724 double nu_c = logn()(0,0,0,0) ;
730 ent = (ent_c + nu_c) - logn - mlngamma ;
731 ent2 = (ent2_c + nu_c) - logn - mlngamma2 ;
738 for (
int l=0; l<nzet; l++) {
739 int imax = mg->
get_nr(l) - 1 ;
740 if (l == l_b) imax-- ;
741 for (
int i=0; i<imax; i++) {
742 if ( (*outer_ent_p)()(l, 0, j_b, i) < 0. ) {
744 cout <<
"(outer) ent < 0 for l, i : " << l <<
" " << i
745 <<
" ent = " << (*outer_ent_p)()(l, 0, j_b, i) << endl ;
752 cout <<
"**** KEPLERIAN VELOCITY REACHED ****" << endl ;
753 if (kepler_fluid & 0x01)
754 omega /= kepler_factor ;
755 if (kepler_fluid & 0x02)
756 omega2 /= kepler_factor;
758 cout <<
"New rotation frequencies : " 759 <<
"Omega = " << omega/(2.*M_PI) * f_unit <<
" Hz; " 760 <<
"Omega2 = " << omega2/(2.*M_PI) * f_unit << endl ;
770 kepler_factor =
sqrt( kepler_factor ) ;
771 cout <<
"**** New fact_omega : " << kepler_factor << endl ;
778 double dent_eq = (*outer_ent_p)().dsdr()(l_b, k_b, j_b, i_b) ;
779 double dent_pole = (*outer_ent_p)().dsdr()(l_b, k_b, 0, i_b) ;
780 double rap_dent = fabs( dent_eq / dent_pole ) ;
781 cout <<
"| dH/dr_eq / dH/dr_pole | = " << rap_dent << endl ;
783 if ( rap_dent < thres_adapt ) {
785 cout <<
"******* FROZEN MAPPING *********" << endl ;
790 if (adapt_flag && (nzadapt > 0) )
794 mp.
adapt( (*outer_ent_p)(), par_adapt) ;
798 mp.reevaluate(&mp_prev, nzet+1, ent.set()) ;
799 mp.reevaluate(&mp_prev, nzet+1, ent2.set()) ;
802 mp.homothetie (alpha_r);
809 equation_of_state() ;
830 mp.poisson2d(source_tggg(), mp.cmp_zero(), par_poisson_tggg, tggg.set()) ;
836 mp.poisson2d(source_dzf(), source_dzq(), par_poisson_dzeta, dzeta.set()) ;
838 err_grv2 = lbda_grv2 - 1;
839 cout <<
"GRV2: " << err_grv2 << endl ;
854 logn = relax * logn + relax_prev * logn_prev ;
856 dzeta = relax * dzeta + relax_prev * dzeta_prev ;
868 fichfreq <<
" " << omega / (2*M_PI) * f_unit ;
869 fichfreq <<
" " << omega2 / (2*M_PI) * f_unit ;
870 fichevol <<
" " << ray_pole() / ray_eq() ;
871 fichevol <<
" " << ent_c ;
872 fichevol <<
" " << ent2_c ;
880 cout <<
"DEBUG MODE : mbar1_wanted : " << mbar1_wanted/msol << endl ;
881 cout <<
"DEBUG MODE : mbar2_wanted : " << mbar2_wanted/msol << endl ;
887 if (mbar2_wanted > 0 )
889 if ((mer_mass>0) && (mer > mer_mass)) {
891 double xx, xprog, ax, fact;
894 xx = mass_b1() / mbar1_wanted - 1. ;
895 cout <<
"Discrep. baryon mass1 <-> wanted bar. mass1 : " << xx << endl ;
897 xprog = ( mer > 2*mer_mass) ? 1. :
double(mer - mer_mass)/double(mer_mass) ;
899 ax = 0.5 * ( 2. + xx ) / (1. + xx ) ;
900 fact =
pow(ax, aexp_mass) ;
901 cout <<
"Fluid1: xprog, xx, ax, fact : " << xprog <<
" " << xx <<
" " << ax <<
" " << fact << endl ;
905 xx = mass_b2() / mbar2_wanted - 1. ;
906 cout <<
"Discrep. baryon mass2 <-> wanted bar. mass2 : " << xx << endl ;
908 xprog = ( mer > 2*mer_mass) ? 1. :
double(mer - mer_mass)/double(mer_mass) ;
910 ax = 0.5 * ( 2. + xx ) / (1. + xx ) ;
911 fact =
pow(ax, aexp_mass) ;
912 cout <<
"Fluid2: xprog, xx, ax, fact : " << xprog <<
" " << xx <<
" " << ax <<
" " << fact << endl ;
914 cout <<
"H1c = " << ent_c <<
" H2c = " << ent2_c << endl ;
919 else if (mbar2_wanted/msol == -1. ) {
921 if ((mer_mass>0) && (mer > mer_mass)) {
923 double xx, xprog, ax, fact;
926 xx = mass_g() / mbar1_wanted - 1. ;
927 cout <<
"Discrep. baryon mass <-> wanted bar. mass : " << xx << endl ;
929 xprog = ( mer > 2*mer_mass) ? 1. :
double(mer - mer_mass)/double(mer_mass) ;
931 ax = 0.5 * ( 2. + xx ) / (1. + xx ) ;
932 fact =
pow(ax, aexp_mass) ;
933 cout <<
"Fluid1: xprog, xx, ax, fact : " << xprog <<
" " << xx <<
" " << ax <<
" " << fact << endl ;
936 double m1 = eos.get_m1() ;
937 double m2 = eos.get_m2() ;
938 cout <<
"m1 = " << m1 <<
" m2 = " << m2 << endl;
939 ent2_c = ent_c +
log(m1/m2);
940 cout <<
"DEBUG MODE : ent_c " << ent_c << endl ;
941 cout <<
"DEBUG MODE : ent2_c " << ent2_c << endl ;
942 cout <<
"H1c = " << ent_c <<
" H2c = " << ent2_c << endl ;
951 if ((mer_mass>0) && (mer > mer_mass)) {
953 double xx, xprog, ax, fact;
956 xx = mass_b() / mbar1_wanted - 1. ;
957 cout <<
"Discrep. baryon mass <-> wanted bar. mass : " << xx << endl ;
959 xprog = ( mer > 2*mer_mass) ? 1. :
double(mer - mer_mass)/double(mer_mass) ;
961 ax = 0.5 * ( 2. + xx ) / (1. + xx ) ;
962 fact =
pow(ax, aexp_mass) ;
963 cout <<
"Fluid1: xprog, xx, ax, fact : " << xprog <<
" " << xx <<
" " << ax <<
" " << fact << endl ;
966 double m1 = eos.get_m1() ;
967 double m2 = eos.get_m2() ;
968 cout <<
"m1 = " << m1 <<
" m2 = " << m2 << endl;
969 ent2_c = ent_c +
log(m1/m2);
970 cout <<
"DEBUG MODE : ent_c " << ent_c << endl ;
971 cout <<
"DEBUG MODE : ent2_c " << ent2_c << endl ;
972 cout <<
"H1c = " << ent_c <<
" H2c = " << ent2_c << endl ;
983 Tbl diff_ent_tbl =
diffrel( ent(), ent_prev() ) ;
984 diff_ent1 = diff_ent_tbl(0) ;
985 for (
int l=1; l<nzet; l++) {
986 diff_ent1 += diff_ent_tbl(l) ;
989 diff_ent_tbl =
diffrel( ent2(), ent2_prev() ) ;
990 diff_ent2 = diff_ent_tbl(0) ;
991 for (
int l=1; l<nzet; l++) {
992 diff_ent2 += diff_ent_tbl(l) ;
995 diff_ent = 0.5*(diff_ent1 + diff_ent2) ;
997 fichconv <<
" " <<
log10( fabs(diff_ent) + 1.e-16 ) ;
998 fichconv <<
" " <<
log10( fabs(err_grv2) + 1.e-16 ) ;
999 fichconv <<
" " <<
log10( fabs(max_triax) + 1.e-16 ) ;
1002 if ( (mer > mer_triax+1) && (max_triax_prev > 1e-13) ) {
1003 vit_triax = (max_triax - max_triax_prev) / max_triax_prev ;
1006 fichconv <<
" " << vit_triax ;
1015 dzeta_prev = dzeta ;
1016 max_triax_prev = max_triax ;
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.
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 Tenseur & gradient_spher() const
Returns the gradient of *this (Spherical coordinates) (scalar field only).
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 set_std_base()
Set the standard spectal basis of decomposition for each component.
double get_kap2() const
Returns the pressure coefficient [unit: ], where .
Standard units of space, time and mass.
double & set(int i)
Read/write of a particular element (index i) (1D case)
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...
int get_type_t() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the equatorial pl...
double get_kap3() const
Returns the pressure coefficient [unit: ], where .
Basic integer array class.
Values and coefficients of a (real-value) function.
Cmp cos(const Cmp &)
Cosine.
Tbl diffrel(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (norme version).
void add_double_mod(double &x, int position=0)
Adds the address of a new modifiable double to the list.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Cmp & set()
Read/write for a scalar (see also operator=(const Cmp&) ).
void change_triad(const Base_vect &new_triad)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
double get_kap1() const
Returns the pressure coefficient [unit: ], where .
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.
Analytic equation of state for two fluids (Newtonian case).
int get_etat() const
Returns the logical state.
Cmp pow(const Cmp &, int)
Power .
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.
virtual void adapt(const Cmp &ent, const Param &par, int nbr_filtre=0)
Adaptation of the mapping to a given scalar field.
Cmp log10(const Cmp &)
Basis 10 logarithm.
double get_beta() const
Returns the coefficient [unit: ], where .
void add_double(const double &x, int position=0)
Adds the the address of a new double to the list.
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
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.
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.
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.
Tbl & set(int l)
Read/write of the value in a given domain (configuration space).