64 #include "star_bhns.h" 68 #include "utilitaires.h" 74 const double& sepa,
bool kerrschild,
75 int,
int mermax_ns,
int mermax_potvit,
76 int mermax_poisson,
int filter_r,
77 int filter_r_s,
int filter_p_s,
78 double relax_poisson,
double relax_potvit,
79 double thres_adapt,
double resize_ns,
80 const Tbl& fact_resize,
Tbl& diff) {
98 int i_b = mg->
get_nr(l_b) - 1 ;
108 double& diff_ent = diff.
set(0) ;
109 double& diff_vel_pot = diff.
set(1) ;
110 double& diff_lapconf = diff.
set(2) ;
111 double& diff_confo = diff.
set(3) ;
112 double& diff_shift_x = diff.
set(4) ;
113 double& diff_shift_y = diff.
set(5) ;
114 double& diff_shift_z = diff.
set(6) ;
115 double& diff_dHdr = diff.
set(7) ;
116 double& diff_dHdr_min = diff.
set(8) ;
117 double& diff_phi_min = diff.
set(9) ;
118 double& diff_radius = diff.
set(10) ;
131 int nz_search =
nzet + 1 ;
134 double precis_secant = 1.e-14 ;
136 double reg_map = 1. ;
140 par_adapt.
add_int(nitermax, 0) ;
145 par_adapt.
add_int(nz_search, 2) ;
147 par_adapt.
add_int(adapt_flag, 3) ;
163 par_adapt.
add_tbl(ent_limit, 0) ;
172 double precis_poisson = 1.e-14 ;
179 par_lapconf.
add_int(mermax_poisson, 0) ;
190 par_confo.
add_int(mermax_poisson, 0) ;
201 par_shift2.
add_int(mermax_poisson, 0) ;
211 for (
int i=0; i<3; i++) {
235 for (
int mer_ns=0; mer_ns<mermax_ns; mer_ns++) {
237 cout <<
"-----------------------------------------------" << endl ;
238 cout <<
"step: " << mer_ns << endl ;
239 cout <<
"diff_ent = " << diff_ent << endl ;
248 mermax_potvit, precis_poisson,
273 double hhh_c =
exp(ent_c) ;
274 double hhh_b =
exp(ent_b) ;
280 double alpha_r2 = 0. ;
282 for (
int k=0; k<mg->
get_np(l_b); k++) {
283 for (
int j=0; j<mg->
get_nt(l_b); j++) {
285 double lapconf_auto_b =
287 double lapconf_comp_b =
295 double aaa = (gam0_c*gam_b*hhh_b*confo_c)
296 / (gam0_b*gam_c*hhh_c*confo_b) ;
299 double alpha_r2_jk = (aaa * lapconf_comp_b - lapconf_comp_c
301 / (lapconf_auto_c - aaa * lapconf_auto_b ) ;
303 if (alpha_r2_jk > alpha_r2) {
304 alpha_r2 = alpha_r2_jk ;
311 alpha_r =
sqrt(alpha_r2) ;
313 cout <<
"k_b, j_b, alpha_r: " << k_b <<
" " << j_b <<
" " 345 ent = (ent_c + log_lapconf_c - log_confo_c + loggam_c + pot_centri_c)
358 cout <<
"dH/dx|_center = " << dentdx << endl ;
359 cout <<
"dH/dy|_center = " << dentdy << endl ;
361 double dec_fact_x = 1. ;
362 double dec_fact_y = 1. ;
365 func_in = 1. - dec_fact_x * (dentdx/ent_c) *
mp.
x 366 - dec_fact_y * (dentdy/ent_c) *
mp.
y ;
378 ent =
ent * (func_in + func_ex) ;
384 cout <<
"dH/dx|_new = " << dentdx_new << endl ;
385 cout <<
"dH/dy|_new = " << dentdy_new << endl ;
393 double rap_dent = fabs( dent_eq / dent_pole ) ;
394 cout <<
"| dH/dr_eq / dH/dr_pole | = " << rap_dent << endl ;
395 diff_dHdr = rap_dent ;
397 if ( rap_dent < thres_adapt ) {
399 cout <<
"******* FROZEN MAPPING *********" << endl ;
407 for (
int l=0; l<
nzet; l++) {
410 ent_limit.
set(
nzet-1) = ent_b ;
421 double rr_in_1 =
mp.
val_r(1, -1., M_PI/2., 0.) ;
424 double rr_out_nm2 =
mp.
val_r(nz-2, 1., M_PI/2., 0.) ;
425 mp.
resize(nz-2, rr_in_1/rr_out_nm2 * fact_resize(1)) ;
428 double rr_out_nm3 =
mp.
val_r(nz-3, 1., M_PI/2., 0.) ;
429 mp.
resize(nz-3, rr_in_1/rr_out_nm3 * fact_resize(0)) ;
436 double rr_out_1 =
mp.
val_r(1, 1., M_PI/2., 0.) ;
437 mp.
resize(1, rr_in_1/rr_out_1 * resize_ns) ;
442 double rr_out_nm3_new =
mp.
val_r(nz-3, 1., M_PI/2., 0.) ;
444 for (
int i=1; i<nz-4; i++) {
446 double rr_out_i =
mp.
val_r(i, 1., M_PI/2., 0.) ;
448 double rr_mid = rr_out_i
449 + (rr_out_nm3_new - rr_out_i) /
double(nz - 3 - i) ;
451 double rr_2timesi = 2. * rr_out_i ;
453 if (rr_2timesi < rr_mid) {
455 double rr_out_ip1 =
mp.
val_r(i+1, 1., M_PI/2., 0.) ;
456 mp.
resize(i+1, rr_2timesi / rr_out_ip1) ;
461 double rr_out_ip1 =
mp.
val_r(i+1, 1., M_PI/2., 0.) ;
462 mp.
resize(i+1, rr_mid / rr_out_ip1) ;
484 double ent_s_max = -1 ;
488 for (
int k=0; k<mg->
get_np(l_b); k++) {
489 for (
int j=0; j<mg->
get_nt(l_b); j++) {
491 if (xx > ent_s_max) {
498 cout <<
"Max. abs(enthalpy) at the boundary between domains nzet-1" 499 <<
" and nzet : " << endl ;
500 cout <<
" " << ent_s_max <<
" reached for k = " << k_s_max
501 <<
" and j = " << j_s_max << endl ;
523 double rad_chi_min =
radius_p(azimu_min) ;
524 double chi_min =
chi_rp(rad_chi_min, azimu_min) ;
526 cout <<
"| dH/dr_eq / dH/dr_pole | (minimum) = " << chi_min << endl ;
527 cout <<
" phi = " << azimu_min / M_PI <<
" [M_PI]" << endl ;
528 cout <<
" radius = " << rad_chi_min / km <<
" [km]" << endl ;
530 diff_dHdr_min = chi_min ;
531 diff_phi_min = azimu_min ;
532 diff_radius = rad_chi_min ;
554 source_lapconf = sou_lap1 + sou_lap2 ;
560 if (source_lapconf.
get_etat() != ETATZERO) {
561 source_lapconf.
filtre(filter_r) ;
573 source_lapconf.
poisson(par_lapconf, lapconf_m1) ;
581 "Relative error in the resolution of the equation for lapconf_auto : " 583 for (
int l=0; l<nz; l++) {
584 cout << tdiff_lapconf(l) <<
" " ;
587 diff_lapconf =
max(
abs(tdiff_lapconf)) ;
613 source_confo = sou_con1 + sou_con2 ;
619 if (source_confo.
get_etat() != ETATZERO) {
620 source_confo.
filtre(filter_r) ;
632 source_confo.
poisson(par_confo, confo_m1) ;
640 "Relative error in the resolution of the equation for confo_auto : " 642 for (
int l=0; l<nz; l++) {
643 cout << tdiff_confo(l) <<
" " ;
646 diff_confo =
max(
abs(tdiff_confo)) ;
664 for (
int i=1; i<=3; i++) {
665 sou_shif1.set(i) = 4.*qpig * lapconf_tot_tmp
671 sou_shif1.annule(
nzet, nz-1) ;
673 for (
int i=1; i<=3; i++) {
674 (sou_shif1.set(i)).inc_dzpuis(4) ;
679 for (
int i=1; i<=3; i++) {
680 sou_shif2.set(i) = 2. *
692 sou_shif2.std_spectral_base() ;
694 source_shift = sou_shif1 + sou_shif2 ;
696 source_shift.std_spectral_base() ;
704 if (filter_r_s != 0) {
705 for (
int i=1; i<=3; i++) {
706 if (source_shift(i).get_etat() != ETATZERO) {
707 source_shift.set(i).filtre(filter_r_s) ;
713 if (filter_p_s != 0) {
714 for (
int i=1; i<=3; i++) {
715 if (source_shift(i).get_etat() != ETATZERO) {
716 (source_shift.set(i)).filtre_phi(filter_p_s, nz-1) ;
722 for (
int i=1; i<=3; i++) {
723 if(source_shift(i).dz_nonzero()) {
724 assert( source_shift(i).get_dzpuis() == 4 ) ;
727 (source_shift.set(i)).set_dzpuis(4) ;
731 double lambda = double(1) / double(3) ;
735 for (
int i=0; i<3; i++) {
736 source_p.set(i) =
Cmp(source_shift(i+1)) ;
741 for (
int i=0; i<3 ;i++) {
742 vect_auxi.set(i) = 0. ;
752 source_p.poisson_vect(lambda, par_shift2, resu_p, vect_auxi,
755 for (
int i=1; i<=3; i++)
760 for (
int i=0; i<3; i++) {
772 Tbl tdiff_shift_x =
diffrel(lap_shift(1), source_shift(1)) ;
773 Tbl tdiff_shift_y =
diffrel(lap_shift(2), source_shift(2)) ;
774 Tbl tdiff_shift_z =
diffrel(lap_shift(3), source_shift(3)) ;
777 "Relative error in the resolution of the equation for shift_auto : " 779 cout <<
"x component : " ;
780 for (
int l=0; l<nz; l++) {
781 cout << tdiff_shift_x(l) <<
" " ;
784 cout <<
"y component : " ;
785 for (
int l=0; l<nz; l++) {
786 cout << tdiff_shift_y(l) <<
" " ;
789 cout <<
"z component : " ;
790 for (
int l=0; l<nz; l++) {
791 cout << tdiff_shift_z(l) <<
" " ;
795 diff_shift_x =
max(
abs(tdiff_shift_x)) ;
796 diff_shift_y =
max(
abs(tdiff_shift_y)) ;
797 diff_shift_z =
max(
abs(tdiff_shift_z)) ;
805 diff_ent = diff_ent_tbl(0) ;
806 for (
int l=0; l<
nzet; l++) {
807 diff_ent += diff_ent_tbl(l) ;
Vector d_lapconf_auto
Derivative of the lapconf function generated by the star .
Cmp log(const Cmp &)
Neperian logarithm.
virtual void set_etat_qcq()
Sets the logical state of all components to ETATQCQ (ordinary state).
void hydro_euler_bhns(bool kerrschild, const double &mass_bh, const double &sepa)
Computes the hydrodynamical quantities relative to the Eulerian observer from those in the fluid fram...
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 ***.
Cmp exp(const Cmp &)
Exponential.
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 ssjm1_khi
Effective source at the previous step for the resolution of the Poisson equation for the scalar by m...
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Cmp sqrt(const Cmp &)
Square root.
virtual void annule(int l_min, int l_max)
Sets the Scalar to zero in several domains.
void set_std_base()
Set the standard spectal basis of decomposition for each component.
Standard units of space, time and mass.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
const Scalar & laplacian(int ced_mult_r=4) const
Returns the Laplacian of *this.
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 void adapt(const Cmp &ent, const Param &par, int nbr=0)=0
Adaptation of the mapping to a given scalar field.
Scalar loggam
Logarithm of the Lorentz factor between the fluid and the co-orbiting observer.
const Scalar & dsdx() const
Returns of *this , where .
virtual void std_spectral_base()
Sets the spectral bases of the Valeur va to the standard ones for a scalar field. ...
void annule_hard()
Sets the Cmp to zero in a hard way.
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
Vector shift_auto
Shift vector generated by the star.
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).
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.
void smooth(int nzet, Valeur &uuva) const
Changes the function *this as a smooth one when there exists a discontinuity between the nucleus and ...
Tbl diffrel(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (norme version).
Scalar gam
Lorentz factor between the fluid and the co-orbiting observer.
double val_grid_point(int l, int k, int j, int i) const
Returns the value of the field at a specified grid point.
virtual void std_spectral_base()
Sets the standard spectal bases of decomposition for each component.
virtual void dec_dzpuis(int dec=1)
Decreases by dec units the value of dzpuis and changes accordingly the values in the compactified ext...
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
int nzet
Number of domains of *mp occupied by the star.
Metric_flat flat
Flat metric defined on the mapping (Spherical components with respect to the mapping of the star )...
Scalar confo_tot
Total conformal factor.
virtual double val_r(int l, double xi, double theta, double pphi) const =0
Returns the value of the radial coordinate r for a given in a given domain.
Cmp & set()
Read/write for a scalar (see also operator=(const Cmp&) ).
virtual void inc_dzpuis(int inc=1)
Increases by inc units the value of dzpuis and changes accordingly the values of the Scalar in the co...
Scalar press
Fluid pressure.
const Scalar & dsdy() const
Returns of *this , where .
int get_dzpuis() const
Returns dzpuis.
void add_tbl(const Tbl &ti, int position=0)
Adds the address of a new Tbl to the list.
double radius_p(double phi)
Radius of the star to the direction of and .
int get_nzone() const
Returns the number of domains.
virtual void homothetie(double lambda)
Sets a new radial scale.
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
const Scalar & divergence(const Metric &) const
The divergence of this with respect to a Metric .
Scalar lapconf_comp
Lapconf function generated by the companion black hole.
Vector u_euler
Fluid 3-velocity with respect to the Eulerian observer.
double ray_eq_pi() const
Coordinate radius at , [r_unit].
Scalar taij_quad_auto
Part of the scalar generated by .
Cmp pow(const Cmp &, int)
Power .
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
void filtre(int n)
Sets the n lasts coefficients in r to 0 in the external domain.
Scalar gam0
Lorentz factor between the co-orbiting observer and the Eulerian one.
Vector ssjm1_wshift
Effective source at the previous step for the resolution of the vector Poisson equation for by means...
virtual void resize(int l, double lambda)=0
Rescales the outer boundary of one domain.
Scalar pot_centri
Centrifugal potential.
const Tensor & divergence(const Metric &gam) const
Computes the divergence of this with respect to some metric .
double val_point(double r, double theta, double phi) const
Computes the value of the field at an arbitrary point , by means of the spectral expansion.
double phi_min()
Azimuthal angle when the indicator of the mass-shedding takes its minimum chi_min.
double ray_pole() const
Coordinate radius at [r_unit].
double chi_rp(double radius, double phi)
Sensitive indicator of the mass-shedding to the direction of , , .
Scalar lapconf_auto
Lapconf function generated by the star.
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
const Tensor & derive_con(const Metric &gam) const
Returns the "contravariant" derivative of this with respect to some metric , by raising the last inde...
bool irrotational
true for an irrotational star, false for a corotating one
const Base_vect_cart & get_bvect_cart() const
Returns the Cartesian basis associated with the coordinates (x,y,z) of the mapping, i.e.
Vector d_confo_auto
Derivative of the conformal factor generated by the star .
Scalar confo_auto
Conformal factor generated by the star.
Coord y
y coordinate centered on the grid
Cmp abs(const Cmp &)
Absolute value.
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.
const Scalar & dsdr() const
Returns of *this .
Sym_tensor taij_auto
Part of the extrinsic curvature tensor generated by shift_auto , lapse_auto , and confo_auto ...
Coord x
x coordinate centered on the grid
void equilibrium_bhns(double ent_c, const double &mass_bh, const double &sepa, bool kerrschild, int mer, int mermax_ns, int mermax_potvit, int mermax_poisson, int filter_r, int filter_r_s, int filter_p_s, double relax_poisson, double relax_potvit, double thres_adapt, double resize_ns, const Tbl &fact_resize, Tbl &diff)
Computes an equilibrium configuration.
Scalar ssjm1_lapconf
Effective source at the previous step for the resolution of the Poisson equation for lapconf_auto ...
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.
void equation_of_state()
Computes the proper baryon and energy density, as well as pressure from the enthalpy.
Scalar ssjm1_confo
Effective source at the previous step for the resolution of the Poisson equation for confo_auto ...
Scalar ener_euler
Total energy density in the Eulerian frame.
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.
double velo_pot_bhns(const double &mass_bh, const double &sepa, bool kerrschild, int mermax, double precis, double relax)
Computes the non-translational part of the velocity scalar potential by solving the continuity equat...