113#include "utilitaires.h"
117#include "graphique.h"
120double fonc_binaire_axe(
double ,
const Param& ) ;
121double fonc_binaire_orbit(
double ,
const Param& ) ;
134 double dnulg[2], asn2[2], dasn2[2], ny[2], dny[2], npn[2], dnpn[2], xgg[2] ;
135 double nyso[2], dnyso[2], npnso2[2], dnpnso2[2], ori_x[2] ;
137 for (
int i=0; i<2; i++) {
139 const Map& mp =
et[i]->get_mp() ;
141 const Cmp& logn_auto_regu =
et[i]->get_logn_auto_regu()() ;
142 const Cmp& logn_comp =
et[i]->get_logn_comp()() ;
143 const Cmp& loggam =
et[i]->get_loggam()() ;
144 const Cmp& nnn =
et[i]->get_nnn()() ;
145 const Cmp& a_car =
et[i]->get_a_car()() ;
146 const Tenseur& shift =
et[i]->get_shift() ;
147 const Tenseur& d_logn_auto_div =
et[i]->get_d_logn_auto_div() ;
149 Tenseur dln_auto_div = d_logn_auto_div ;
167 if (fabs(mp.get_rot_phi()) < 1.e-14) {
171 if (fabs(mp.get_rot_phi() - M_PI) < 1.e-14) {
175 cout <<
"Binaire::orbit : unknown value of rot_phi !" << endl ;
180 Cmp tmp = logn_auto_regu + logn_comp + loggam ;
183 dnulg[i] = dln_auto_div(0)(0, 0, 0, 0)
184 + factx * tmp.
dsdx()(0, 0, 0, 0) ;
186 tmp = logn_auto_regu + logn_comp ;
187 cout <<
"dlnndx_div_c : " << dln_auto_div(0)(0, 0, 0, 0) << endl ;
188 cout <<
"dlnndx_c : " << dln_auto_div(0)(0, 0, 0, 0) + factx*tmp.
dsdx()(0, 0, 0, 0) << endl ;
190 cout <<
"dloggamdx_c : " << factx*loggam.
dsdx()(0, 0, 0, 0) << endl ;
192 save_profile(stmp, 0., 10., 0.5*M_PI, 0.,
"prof_logn.d") ;
194 save_profile(stmp, 0., 1.8, 0.5*M_PI, 0.,
"prof_loggam.d") ;
200 double nc = nnn(0, 0, 0, 0) ;
201 double a2c = a_car(0, 0, 0, 0) ;
202 asn2[i] = a2c / (nc * nc) ;
204 if (
et[i]->is_relativistic() ) {
210 double da2c = factx * a_car.
dsdx()(0, 0, 0, 0) ;
211 double dnc = factx * nnn.
dsdx()(0, 0, 0, 0) ;
213 dasn2[i] = ( da2c - 2 * a2c / nc * dnc ) / (nc*nc) ;
219 ny[i] = shift(1)(0, 0, 0, 0) ;
220 nyso[i] = ny[i] /
omega ;
226 dny[i] = factx * shift(1).dsdx()(0, 0, 0, 0) ;
227 dnyso[i] = dny[i] /
omega ;
236 npn[i] = tmp(0, 0, 0, 0) ;
244 dnpn[i] = factx * tmp.
dsdx()(0, 0, 0, 0) ;
260 cout <<
"Binaire::orbit: central d(nu+log(Gam))/dX : "
261 << dnulg[i] << endl ;
262 cout <<
"Binaire::orbit: central A^2/N^2 : " << asn2[i] << endl ;
263 cout <<
"Binaire::orbit: central d(A^2/N^2)/dX : " << dasn2[i] << endl ;
264 cout <<
"Binaire::orbit: central N^Y : " << ny[i] << endl ;
265 cout <<
"Binaire::orbit: central dN^Y/dX : " << dny[i] << endl ;
266 cout <<
"Binaire::orbit: central N.N : " << npn[i] << endl ;
267 cout <<
"Binaire::orbit: central d(N.N)/dX : " << dnpn[i] << endl ;
275 ori_x[i] = (
et[i]->get_mp()).get_ori_x() ;
277 xgg[i] = factx * (
et[i]->xa_barycenter() - ori_x[i]) ;
288 int relat = (
et[0]->is_relativistic() ) ? 1 : 0 ;
289 double ori_x1 = ori_x[0] ;
290 double ori_x2 = ori_x[1] ;
292 if (
et[0]->get_eos() ==
et[1]->get_eos() &&
293 et[0]->get_ent()()(0,0,0,0) ==
et[1]->get_ent()()(0,0,0,0) ) {
319 int nitmax_axe = 200 ;
321 double precis_axe = 1.e-13 ;
323 x_axe =
zerosec(fonc_binaire_axe, paraxe, 0.9*ori_x1, 0.9*ori_x2,
324 precis_axe, nitmax_axe, nit_axe) ;
326 cout <<
"Binaire::orbit : Number of iterations in zerosec for x_axe : "
330 cout <<
"Binaire::orbit : x_axe [km] : " <<
x_axe / km << endl ;
348 double omega1 = fact_omeg_min *
omega ;
349 double omega2 = fact_omeg_max *
omega ;
350 cout <<
"Binaire::orbit: omega1, omega2 [rad/s] : "
351 << omega1 * f_unit <<
" " << omega2 * f_unit << endl ;
358 zero_list(fonc_binaire_orbit, parf, omega1, omega2, nsub,
363 double omeg_min, omeg_max ;
365 cout <<
"Binaire:orbit : " << nzer <<
366 " zero(s) found in the interval [omega1, omega2]." << endl ;
367 cout <<
"omega, omega1, omega2 : " <<
omega <<
" " << omega1
368 <<
" " << omega2 << endl ;
369 cout <<
"azer : " << *azer << endl ;
370 cout <<
"bzer : " << *bzer << endl ;
374 "Binaire::orbit: WARNING : no zero detected in the interval"
375 << endl <<
" [" << omega1 * f_unit <<
", "
376 << omega2 * f_unit <<
"] rad/s !" << endl ;
381 double dist_min = fabs(omega2 - omega1) ;
382 int i_dist_min = -1 ;
383 for (
int i=0; i<nzer; i++) {
386 double dist = fabs(
omega - 0.5 * ( (*azer)(i) + (*bzer)(i) ) ) ;
387 if (dist < dist_min) {
392 omeg_min = (*azer)(i_dist_min) ;
393 omeg_max = (*bzer)(i_dist_min) ;
399 cout <<
"Binaire:orbit : interval selected for the search of the zero : "
400 << endl <<
" [" << omeg_min <<
", " << omeg_max <<
"] = ["
401 << omeg_min * f_unit <<
", " << omeg_max * f_unit <<
"] rad/s " << endl ;
407 double precis = 1.e-13 ;
409 precis, nitermax, niter) ;
411 cout <<
"Binaire::orbit : Number of iterations in zerosec for omega : "
414 cout <<
"Binaire::orbit : omega [rad/s] : "
415 <<
omega * f_unit << endl ;
468 double mass1,
double mass2,
469 double& xgg1,
double& xgg2) {
477 double dnulg[2], asn2[2], dasn2[2], ny[2], dny[2], npn[2], dnpn[2], xgg[2] ;
478 double nyso[2], dnyso[2], npnso2[2], dnpnso2[2], ori_x[2] ;
480 for (
int i=0; i<2; i++) {
482 const Map& mp =
et[i]->get_mp() ;
484 const Cmp& logn_auto_regu =
et[i]->get_logn_auto_regu()() ;
485 const Cmp& logn_comp =
et[i]->get_logn_comp()() ;
486 const Cmp& loggam =
et[i]->get_loggam()() ;
487 const Cmp& nnn =
et[i]->get_nnn()() ;
488 const Cmp& a_car =
et[i]->get_a_car()() ;
489 const Tenseur& shift =
et[i]->get_shift() ;
490 const Tenseur& d_logn_auto_div =
et[i]->get_d_logn_auto_div() ;
492 Tenseur dln_auto_div = d_logn_auto_div ;
510 if (fabs(mp.get_rot_phi()) < 1.e-14) {
514 if (fabs(mp.get_rot_phi() - M_PI) < 1.e-14) {
518 cout <<
"Binaire::orbit : unknown value of rot_phi !" << endl ;
523 Cmp tmp = logn_auto_regu + logn_comp + loggam ;
526 dnulg[i] = dln_auto_div(0)(0, 0, 0, 0)
527 + factx * tmp.
dsdx()(0, 0, 0, 0) ;
533 double nc = nnn(0, 0, 0, 0) ;
534 double a2c = a_car(0, 0, 0, 0) ;
535 asn2[i] = a2c / (nc * nc) ;
537 if (
et[i]->is_relativistic() ) {
543 double da2c = factx * a_car.
dsdx()(0, 0, 0, 0) ;
544 double dnc = factx * nnn.
dsdx()(0, 0, 0, 0) ;
546 dasn2[i] = ( da2c - 2 * a2c / nc * dnc ) / (nc*nc) ;
552 ny[i] = shift(1)(0, 0, 0, 0) ;
553 nyso[i] = ny[i] /
omega ;
559 dny[i] = factx * shift(1).dsdx()(0, 0, 0, 0) ;
560 dnyso[i] = dny[i] /
omega ;
569 npn[i] = tmp(0, 0, 0, 0) ;
577 dnpn[i] = factx * tmp.
dsdx()(0, 0, 0, 0) ;
593 cout <<
"Binaire::orbit: central d(nu+log(Gam))/dX : "
594 << dnulg[i] << endl ;
595 cout <<
"Binaire::orbit: central A^2/N^2 : " << asn2[i] << endl ;
596 cout <<
"Binaire::orbit: central d(A^2/N^2)/dX : " << dasn2[i] << endl ;
597 cout <<
"Binaire::orbit: central N^Y : " << ny[i] << endl ;
598 cout <<
"Binaire::orbit: central dN^Y/dX : " << dny[i] << endl ;
599 cout <<
"Binaire::orbit: central N.N : " << npn[i] << endl ;
600 cout <<
"Binaire::orbit: central d(N.N)/dX : " << dnpn[i] << endl ;
608 ori_x[i] = (
et[i]->get_mp()).get_ori_x() ;
610 xgg[i] = factx * (
et[i]->xa_barycenter() - ori_x[i]) ;
621 int relat = (
et[0]->is_relativistic() ) ? 1 : 0 ;
622 double ori_x1 = ori_x[0] ;
623 double ori_x2 = ori_x[1] ;
625 if (
et[0]->get_eos() ==
et[1]->get_eos() && mass1 == mass2 ) {
651 int nitmax_axe = 200 ;
653 double precis_axe = 1.e-13 ;
655 x_axe =
zerosec(fonc_binaire_axe, paraxe, 0.9*ori_x1, 0.9*ori_x2,
656 precis_axe, nitmax_axe, nit_axe) ;
658 cout <<
"Binaire::orbit : Number of iterations in zerosec for x_axe : "
662 cout <<
"Binaire::orbit : x_axe [km] : " <<
x_axe / km << endl ;
680 double omega1 = fact_omeg_min *
omega ;
681 double omega2 = fact_omeg_max *
omega ;
682 cout <<
"Binaire::orbit: omega1, omega2 [rad/s] : "
683 << omega1 * f_unit <<
" " << omega2 * f_unit << endl ;
690 zero_list(fonc_binaire_orbit, parf, omega1, omega2, nsub,
695 double omeg_min, omeg_max ;
697 cout <<
"Binaire:orbit : " << nzer <<
698 " zero(s) found in the interval [omega1, omega2]." << endl ;
699 cout <<
"omega, omega1, omega2 : " <<
omega <<
" " << omega1
700 <<
" " << omega2 << endl ;
701 cout <<
"azer : " << *azer << endl ;
702 cout <<
"bzer : " << *bzer << endl ;
706 "Binaire::orbit: WARNING : no zero detected in the interval"
707 << endl <<
" [" << omega1 * f_unit <<
", "
708 << omega2 * f_unit <<
"] rad/s !" << endl ;
713 double dist_min = fabs(omega2 - omega1) ;
714 int i_dist_min = -1 ;
715 for (
int i=0; i<nzer; i++) {
718 double dist = fabs(
omega - 0.5 * ( (*azer)(i) + (*bzer)(i) ) ) ;
719 if (dist < dist_min) {
724 omeg_min = (*azer)(i_dist_min) ;
725 omeg_max = (*bzer)(i_dist_min) ;
731 cout <<
"Binaire:orbit : interval selected for the search of the zero : "
732 << endl <<
" [" << omeg_min <<
", " << omeg_max <<
"] = ["
733 << omeg_min * f_unit <<
", " << omeg_max * f_unit <<
"] rad/s " << endl ;
739 double precis = 1.e-13 ;
741 precis, nitermax, niter) ;
743 cout <<
"Binaire::orbit : Number of iterations in zerosec for omega : "
746 cout <<
"Binaire::orbit : omega [rad/s] : "
747 <<
omega * f_unit << endl ;
803double fonc_binaire_axe(
double x_rot,
const Param& paraxe) {
827 double x1 = ori_x1 - x_rot ;
828 double x2 = ori_x2 - x_rot ;
832 double andan_1 = 0.5 * dasn2_1 + asn2_1 * dnulg_1 ;
833 double andan_2 = 0.5 * dasn2_2 + asn2_2 * dnulg_2 ;
835 double bpb_1 = x1 * x1 - 2. * nyso_1 * x1 + npnso2_1 ;
836 double bpb_2 = x2 * x2 - 2. * nyso_2 * x2 + npnso2_2 ;
838 double cpc_1 = 0.5 * dnpnso2_1 + x1 * (1. - dnyso_1) - nyso_1 ;
839 double cpc_2 = 0.5 * dnpnso2_2 + x2 * (1. - dnyso_2) - nyso_2 ;
841 om2_star1 = dnulg_1 / (andan_1 * bpb_1 + asn2_1 * cpc_1) ;
842 om2_star2 = dnulg_2 / (andan_2 * bpb_2 + asn2_2 * cpc_2) ;
847 om2_star1 = dnulg_1 / x1 ;
848 om2_star2 = dnulg_2 / x2 ;
852 return om2_star1 - om2_star2 ;
860double fonc_binaire_orbit(
double om,
const Param& parf) {
862 int relat = parf.get_int() ;
864 double xc = parf.get_double(0) ;
865 double dnulg = parf.get_double(1) ;
866 double asn2 = parf.get_double(2) ;
867 double dasn2 = parf.get_double(3) ;
868 double ny = parf.get_double(4) ;
869 double dny = parf.get_double(5) ;
870 double npn = parf.get_double(6) ;
871 double dnpn = parf.get_double(7) ;
872 double x_axe = parf.get_double(8) ;
874 double xx = xc - x_axe ;
880 double bpb = om2 * xx*xx - 2*om * ny * xx + npn ;
882 dphi_cent = ( asn2* ( om* (ny + xx*dny) - om2*xx - 0.5*dnpn )
884 / ( 1 - asn2 * bpb ) ;
887 dphi_cent = - om2*xx ;
890 return dnulg + dphi_cent ;
Etoile_bin * et[2]
Array of the two stars (to perform loops on the stars): {\tt et[0]} contains the address of {\tt star...
void orbit_eqmass(double fact_omeg_min, double fact_omeg_max, double mass1, double mass2, double &xgg1, double &xgg2)
Computes the orbital angular velocity {\tt omega} and the position of the rotation axis {\tt x_axe}...
const Base_vect_cart ref_triad
Cartesian triad of the absolute reference frame.
double omega
Angular velocity with respect to an asymptotically inertial observer.
void orbit(double fact_omeg_min, double fact_omeg_max, double &xgg1, double &xgg2)
Computes the orbital angular velocity {\tt omega} and the position of the rotation axis {\tt x_axe}...
double x_axe
Absolute X coordinate of the rotation axis.
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
const Cmp & dsdx() const
Returns of *this , where .
void add_double(const double &x, int position=0)
Adds the the address of a new double to the list.
const int & get_int(int position=0) const
Returns the reference of a int stored in the list.
const double & get_double(int position=0) const
Returns the reference of a double stored in the list.
void add_int(const int &n, int position=0)
Adds the address of a new int to the list.
Tensor field of valence 0 (or component of a tensorial field).
int get_taille() const
Gives the total size (ie dim.taille).
Tensor handling *** DEPRECATED : use class Tensor instead ***.
const Base_vect * get_triad() const
Returns the vectorial basis (triad) on which the components are defined.
void change_triad(const Base_vect &new_triad)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
void zero_list(double(*f)(double, const Param &), const Param &par, double xmin, double xmax, int nsub, Tbl *&az, Tbl *&bz)
Locates approximatively all the zeros of a function in a given interval.
double zerosec_b(double(*f)(double, const Param &), const Param &par, double a, double b, double precis, int nitermax, int &niter)
Finding the zero a function on a bounded domain.
double zerosec(double(*f)(double, const Param &), const Param &par, double a, double b, double precis, int nitermax, int &niter, bool abort=true)
Finding the zero a function.
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...
Map(const Mg3d &)
Constructor from a multi-domain 3D grid.
Standard units of space, time and mass.