LORENE
bin_ns_bh_orbit.C
1 /*
2  * Method of class Bin_ns_bh to compute the orbital angular velocity
3  * {\tt omega}
4  *
5  * (see file bin_ns_bh.h for documentation).
6  *
7  */
8 
9 /*
10  * Copyright (c) 2003 Keisuke Taniguchi
11  *
12  * This file is part of LORENE.
13  *
14  * LORENE is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License version 2
16  * as published by the Free Software Foundation.
17  *
18  * LORENE is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with LORENE; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26  *
27  */
28 
29 char bin_ns_bh_orbit_C[] = "$Header: /cvsroot/Lorene/C++/Source/Bin_ns_bh/bin_ns_bh_orbit.C,v 1.7 2014/10/24 14:10:24 j_novak Exp $" ;
30 
31 /*
32  * $Id: bin_ns_bh_orbit.C,v 1.7 2014/10/24 14:10:24 j_novak Exp $
33  * $Log: bin_ns_bh_orbit.C,v $
34  * Revision 1.7 2014/10/24 14:10:24 j_novak
35  * Minor change to prevent weird error from g++-4.8...
36  *
37  * Revision 1.6 2014/10/13 08:52:43 j_novak
38  * Lorene classes and functions now belong to the namespace Lorene.
39  *
40  * Revision 1.5 2014/10/06 15:13:02 j_novak
41  * Modified #include directives to use c++ syntax.
42  *
43  * Revision 1.4 2004/06/09 07:26:16 k_taniguchi
44  * Minor changes.
45  *
46  * Revision 1.3 2004/06/09 06:20:11 k_taniguchi
47  * Set the standard basis for some Cmp.
48  *
49  * Revision 1.2 2004/03/25 10:28:58 j_novak
50  * All LORENE's units are now defined in the namespace Unites (in file unites.h).
51  *
52  * Revision 1.1 2003/10/24 16:57:43 k_taniguchi
53  * Method for the calculation of the orbital angular velocity
54  *
55  *
56  * $Header: /cvsroot/Lorene/C++/Source/Bin_ns_bh/bin_ns_bh_orbit.C,v 1.7 2014/10/24 14:10:24 j_novak Exp $
57  *
58  */
59 
60 // C headers
61 #include <cmath>
62 
63 // Lorene headers
64 #include "bin_ns_bh.h"
65 #include "eos.h"
66 #include "param.h"
67 #include "utilitaires.h"
68 #include "unites.h"
69 
70 namespace Lorene {
71 double fonc_bin_ns_bh_orbit(double , const Param& ) ;
72 
73 //*************************************************************************
74 
75 void Bin_ns_bh::orbit_omega(double fact_omeg_min, double fact_omeg_max) {
76 
77  using namespace Unites ;
78 
79  //------------------------------------------------------------------
80  // Evaluation of various quantities at the center of a neutron star
81  //------------------------------------------------------------------
82 
83  double dnulg, asn2, dasn2, ny, dny, npn, dnpn ;
84 
85  const Map& mp = star.get_mp() ;
86 
87  const Cmp& loggam = star.get_loggam()() ;
88  const Cmp& nnn = star.get_nnn()() ;
89  const Cmp& confpsi = star.get_confpsi()() ;
90  const Tenseur& shift = star.get_shift() ;
91 
92  Cmp confpsi_q = pow(confpsi, 4.) ;
93  confpsi_q.std_base_scal() ;
94 
95  //-----------------------------------------------------------------
96  // Calculation of d/dX( nu + ln(Gamma) ) at the center of the star
97  // ---> dnulg
98  //-----------------------------------------------------------------
99 
100  // Factor for the coordinate transformation x --> X :
101  double factx ;
102  if (fabs(mp.get_rot_phi()) < 1.e-14) {
103  factx = 1. ;
104  }
105  else {
106  if (fabs(mp.get_rot_phi() - M_PI) < 1.e-14) {
107  factx = - 1. ;
108  }
109  else {
110  cout << "Bin_ns_bh::orbit_omega : unknown value of rot_phi !"
111  << endl ;
112  abort() ;
113  }
114  }
115 
116  Cmp tmp = log( nnn ) + loggam ;
117  tmp.std_base_scal() ;
118 
119  // ... gradient
120  dnulg = factx * tmp.dsdx()(0, 0, 0, 0) ;
121 
122  //------------------------------------------------------------
123  // Calculation of A^2/N^2 at the center of the star ---> asn2
124  //------------------------------------------------------------
125  double nc = nnn(0, 0, 0, 0) ;
126  double a2c = confpsi_q(0, 0, 0, 0) ;
127  asn2 = a2c / (nc * nc) ;
128 
129  if ( star.is_relativistic() ) {
130 
131  //------------------------------------------------------------------
132  // Calculation of d/dX(A^2/N^2) at the center of the star ---> dasn
133  //------------------------------------------------------------------
134  double da2c = factx * confpsi_q.dsdx()(0, 0, 0, 0) ;
135  double dnc = factx * nnn.dsdx()(0, 0, 0, 0) ;
136 
137  dasn2 = ( da2c - 2 * a2c / nc * dnc ) / (nc*nc) ;
138 
139  //------------------------------------------------------
140  // Calculation of N^Y at the center of the star ---> ny
141  //------------------------------------------------------
142  ny = shift(1)(0, 0, 0, 0) ;
143 
144  //-----------------------------------------------------------
145  // Calculation of dN^Y/dX at the center of the star ---> dny
146  //-----------------------------------------------------------
147  dny = factx * shift(1).dsdx()(0, 0, 0, 0) ;
148 
149  //--------------------------------------------
150  // Calculation of (N^X)^2 + (N^Y)^2 + (N^Z)^2
151  // at the center of the star ---> npn
152  //--------------------------------------------
153  tmp = flat_scalar_prod(shift, shift)() ;
154  npn = tmp(0, 0, 0, 0) ;
155 
156  //----------------------------------------------------
157  // Calculation of d/dX( (N^X)^2 + (N^Y)^2 + (N^Z)^2 )
158  // at the center of the star ---> dnpn
159  //----------------------------------------------------
160  dnpn = factx * tmp.dsdx()(0, 0, 0, 0) ;
161 
162  } // Finish of the relativistic case
163  else {
164  cout << "Bin_ns_bh::orbit_omega : "
165  << "It should be the relativistic calculation !" << endl ;
166  abort() ;
167  }
168 
169  cout << "Bin_ns_bh::orbit_omega: central d(nu+log(Gam))/dX : "
170  << dnulg << endl ;
171  cout << "Bin_ns_bh::orbit_omega: central A^2/N^2 : " << asn2 << endl ;
172  cout << "Bin_ns_bh::orbit_omega: central d(A^2/N^2)/dX : "
173  << dasn2 << endl ;
174  cout << "Bin_ns_bh::orbit_omega: central N^Y : " << ny << endl ;
175  cout << "Bin_ns_bh::orbit_omega: central dN^Y/dX : " << dny << endl ;
176  cout << "Bin_ns_bh::orbit_omega: central N.N : " << npn << endl ;
177  cout << "Bin_ns_bh::orbit_omega: central d(N.N)/dX : "
178  << dnpn << endl ;
179 
180  //------------------------------------------------------
181  // Start of calculation of the orbital angular velocity
182  //------------------------------------------------------
183  int relat = ( star.is_relativistic() ) ? 1 : 0 ;
184 
185  double ori_x = (star.get_mp()).get_ori_x() ;
186  Param parf ;
187  parf.add_int(relat) ;
188  parf.add_double( ori_x, 0) ;
189  parf.add_double( dnulg, 1) ;
190  parf.add_double( asn2, 2) ;
191  parf.add_double( dasn2, 3) ;
192  parf.add_double( ny, 4) ;
193  parf.add_double( dny, 5) ;
194  parf.add_double( npn, 6) ;
195  parf.add_double( dnpn, 7) ;
196  parf.add_double( x_axe, 8) ;
197 
198  double omega1 = fact_omeg_min * omega ;
199  double omega2 = fact_omeg_max * omega ;
200 
201  cout << "Bin_ns_bh::orbit_omega: omega1, omega2 [rad/s] : "
202  << omega1 * f_unit << " " << omega2 * f_unit << endl ;
203 
204  // Search for the various zeros in the interval [omega1,omega2]
205  // ------------------------------------------------------------
206  int nsub = 50 ; // total number of subdivisions of the interval
207  Tbl* azer = 0x0 ;
208  Tbl* bzer = 0x0 ;
209  zero_list(fonc_bin_ns_bh_orbit, parf, omega1, omega2, nsub,
210  azer, bzer) ;
211 
212  // Search for the zero closest to the previous value of omega
213  // ----------------------------------------------------------
214  double omeg_min, omeg_max ;
215  int nzer = azer->get_taille() ; // number of zeros found by zero_list
216  cout << "Bin_ns_bh:orbit_omega : " << nzer <<
217  "zero(s) found in the interval [omega1, omega2]." << endl ;
218  cout << "omega, omega1, omega2 : " << omega << " " << omega1
219  << " " << omega2 << endl ;
220  cout << "azer : " << *azer << endl ;
221  cout << "bzer : " << *bzer << endl ;
222 
223  if (nzer == 0) {
224  cout << "Bin_ns_bh::orbit_omega: WARNING : "
225  << "no zero detected in the interval" << endl
226  << " [" << omega1 * f_unit << ", "
227  << omega2 * f_unit << "] rad/s !" << endl ;
228  omeg_min = omega1 ;
229  omeg_max = omega2 ;
230  }
231  else {
232  double dist_min = fabs(omega2 - omega1) ;
233  int i_dist_min = -1 ;
234  for (int i=0; i<nzer; i++) {
235  // Distance of previous value of omega from the center of the
236  // interval [azer(i), bzer(i)]
237  double dist = fabs( omega - 0.5 * ( (*azer)(i) + (*bzer)(i) ) ) ;
238 
239  if (dist < dist_min) {
240  dist_min = dist ;
241  i_dist_min = i ;
242  }
243  }
244  omeg_min = (*azer)(i_dist_min) ;
245  omeg_max = (*bzer)(i_dist_min) ;
246  }
247 
248  delete azer ; // Tbl allocated by zero_list
249  delete bzer ; //
250 
251  cout << "Bin_ns_bh:orbit_omega : "
252  << "interval selected for the search of the zero : "
253  << endl << " [" << omeg_min << ", " << omeg_max << "] = ["
254  << omeg_min * f_unit << ", " << omeg_max * f_unit << "] rad/s "
255  << endl ;
256 
257  // Computation of the zero in the selected interval by the secant method
258  // ---------------------------------------------------------------------
259 
260  int nitermax = 200 ;
261  int niter ;
262  double precis = 1.e-13 ;
263  omega = zerosec_b(fonc_bin_ns_bh_orbit, parf, omeg_min, omeg_max,
264  precis, nitermax, niter) ;
265 
266  cout << "Bin_ns_bh::orbit_omega : "
267  << "Number of iterations in zerosec for omega : "
268  << niter << endl ;
269 
270  cout << "Bin_ns_bh::orbit_omega : omega [rad/s] : "
271  << omega * f_unit << endl ;
272 
273 }
274 
275 //***********************************************************
276 // Function used for search of the orbital angular velocity
277 //***********************************************************
278 
279 double fonc_bin_ns_bh_orbit(double om, const Param& parf) {
280 
281  int relat = parf.get_int() ;
282 
283  double xc = parf.get_double(0) ;
284  double dnulg = parf.get_double(1) ;
285  double asn2 = parf.get_double(2) ;
286  double dasn2 = parf.get_double(3) ;
287  double ny = parf.get_double(4) ;
288  double dny = parf.get_double(5) ;
289  double npn = parf.get_double(6) ;
290  double dnpn = parf.get_double(7) ;
291  double x_axe = parf.get_double(8) ;
292 
293  double xx = xc - x_axe ;
294  double om2 = om*om ;
295 
296  double dphi_cent ;
297 
298  if (relat == 1) {
299  double bpb = om2 * xx*xx - 2*om * ny * xx + npn ;
300 
301  dphi_cent = ( asn2* ( om* (ny + xx*dny) - om2*xx - 0.5*dnpn )
302  - 0.5*bpb* dasn2 )
303  / ( 1 - asn2 * bpb ) ;
304  }
305  else {
306  cout << "Bin_ns_bh::orbit_omega : "
307  << "It should be the relativistic calculation !" << endl ;
308  abort() ;
309  }
310 
311  return dnulg + dphi_cent ;
312 
313 }
314 }
Cmp log(const Cmp &)
Neperian logarithm.
Definition: cmp_math.C:296
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition: cmp.h:443
const Cmp & dsdx() const
Returns of *this , where .
Definition: cmp_deriv.C:148
const Map & get_mp() const
Returns the mapping.
Definition: etoile.h:659
void add_int(const int &n, int position=0)
Adds the address of a new int to the list.
Definition: param.C:246
Lorene prototypes.
Definition: app_hor.h:64
Standard units of space, time and mass.
const Tenseur & get_shift() const
Returns the total shift vector .
Definition: etoile.h:730
Base class for coordinate mappings.
Definition: map.h:670
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...
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.
Definition: zerosec_borne.C:68
double get_rot_phi() const
Returns the angle between the x –axis and X –axis.
Definition: map.h:775
const int & get_int(int position=0) const
Returns the reference of a int stored in the list.
Definition: param.C:292
const Tenseur & get_loggam() const
Returns the logarithm of the Lorentz factor between the fluid and the co-orbiting observer...
Definition: etoile.h:1111
double x_axe
Absolute X coordinate of the rotation axis.
Definition: bin_ns_bh.h:140
Et_bin_nsbh star
The neutron star.
Definition: bin_ns_bh.h:128
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.
Definition: zero_list.C:57
Parameter storage.
Definition: param.h:125
const Tenseur & get_nnn() const
Returns the total lapse function N.
Definition: etoile.h:727
double omega
Angular velocity with respect to an asymptotically inertial observer.
Definition: bin_ns_bh.h:136
const Tenseur & get_confpsi() const
Returns the part of the conformal factor $$.
Definition: et_bin_nsbh.h:257
Cmp pow(const Cmp &, int)
Power .
Definition: cmp_math.C:348
void orbit_omega(double fact_omeg_min, double fact_omeg_max)
Computes the orbital angular velocity { omega}.
void std_base_scal()
Sets the spectral bases of the Valeur va to the standard ones for a scalar.
Definition: cmp.C:644
int get_taille() const
Gives the total size (ie dim.taille)
Definition: tbl.h:397
void add_double(const double &x, int position=0)
Adds the the address of a new double to the list.
Definition: param.C:315
const double & get_double(int position=0) const
Returns the reference of a double stored in the list.
Definition: param.C:361
Basic array class.
Definition: tbl.h:161
bool is_relativistic() const
Returns true for a relativistic star, false for a Newtonian one.
Definition: etoile.h:667
Tensor handling *** DEPRECATED : use class Tensor instead ***.
Definition: tenseur.h:298