LORENE
strot_dirac_global.C
1 /*
2  * Methods for computing global quantities within the class Star_rot_Dirac
3  *
4  * (see file star.h for documentation).
5  *
6  */
7 
8 /*
9  * Copyright (c) 2005 Lap-Ming Lin & Jerome Novak
10  *
11  * This file is part of LORENE.
12  *
13  * LORENE is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License version 2
15  * as published by the Free Software Foundation.
16  *
17  * LORENE is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with LORENE; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  */
27 
28 
29 
30 /*
31  * $Id: strot_dirac_global.C,v 1.14 2016/12/05 16:18:15 j_novak Exp $
32  * $Log: strot_dirac_global.C,v $
33  * Revision 1.14 2016/12/05 16:18:15 j_novak
34  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
35  *
36  * Revision 1.13 2014/10/13 08:53:40 j_novak
37  * Lorene classes and functions now belong to the namespace Lorene.
38  *
39  * Revision 1.12 2014/10/06 15:13:18 j_novak
40  * Modified #include directives to use c++ syntax.
41  *
42  * Revision 1.11 2010/11/17 11:21:52 j_novak
43  * Corrected minor problems in the case nz=1 and nt=1.
44  *
45  * Revision 1.10 2010/10/22 08:08:40 j_novak
46  * Removal of the method Star_rot_dirac::lambda_grv2() and call to the C++ version of integrale2d.
47  *
48  * Revision 1.9 2009/10/26 10:54:33 j_novak
49  * Added the case of a NONSYM base in theta.
50  *
51  * Revision 1.8 2008/05/30 08:27:38 j_novak
52  * New global quantities rp_circ and ellipt (circumferential polar coordinate and
53  * ellipticity).
54  *
55  * Revision 1.7 2008/02/18 13:51:20 j_novak
56  * Change of a dzpuis
57  *
58  * Revision 1.6 2005/03/25 14:11:49 j_novak
59  * In the 1D case, GRV2 returns -1 (because of a problem in integral2d).
60  *
61  * Revision 1.5 2005/02/17 17:30:42 f_limousin
62  * Change the name of some quantities to be consistent with other classes
63  * (for instance nnn is changed to nn, shift to beta, beta to lnq...)
64  *
65  * Revision 1.4 2005/02/09 13:36:01 lm_lin
66  *
67  * Add the calculations of GRV2, T/W, R_circ, and flattening.
68  *
69  * Revision 1.3 2005/02/02 10:11:24 j_novak
70  * Better calculation of the GRV3 identity.
71  *
72  *
73  *
74  * $Header: /cvsroot/Lorene/C++/Source/Star/strot_dirac_global.C,v 1.14 2016/12/05 16:18:15 j_novak Exp $
75  *
76  */
77 
78 
79 // C headers
80 #include <cmath>
81 #include <cassert>
82 
83 // Lorene headers
84 #include "star_rot_dirac.h"
85 #include "unites.h"
86 #include "utilitaires.h"
87 #include "proto.h"
88 
89  //-------------------------------------------------------//
90  // Baryonic mass //
91  // //
92  // Note: In Lorene units, mean particle mass is unity //
93  //-------------------------------------------------------//
94 
95 
96 namespace Lorene {
97 double Star_rot_Dirac::mass_b() const {
98 
99  if (p_mass_b == 0x0) { // a new computation is required
100 
101  Scalar dens = sqrt( gamma.determinant() ) * gam_euler * nbar ;
102 
103  dens.std_spectral_base() ;
104 
105  p_mass_b = new double( dens.integrale() ) ;
106 
107  }
108 
109  return *p_mass_b ;
110 
111 }
112 
113  //---------------------------------------------------------//
114  // Gravitational mass //
115  // //
116  // Note: This is the Komar mass for stationary and //
117  // asymptotically flat spacetime (see, eg, Wald) //
118  //---------------------------------------------------------//
119 
120 double Star_rot_Dirac::mass_g() const {
121 
122  if (p_mass_g == 0x0) { // a new computation is required
123 
124  Scalar j_source = 2.* contract(contract(gamma.cov(), 0, j_euler, 0),
125  0, beta, 0) ;
126 
127  Scalar dens = sqrt( gamma.determinant() ) *
128  ( nn * (ener_euler + s_euler) - j_source ) ;
129 
130  dens.std_spectral_base() ;
131 
132  p_mass_g = new double( dens.integrale() ) ;
133 
134  }
135 
136  return *p_mass_g ;
137 
138 }
139 
140  //--------------------------------------//
141  // Angular momentum //
142  // //
143  // Komar-type integral (see, eg, Wald) //
144  //--------------------------------------//
145 
146 double Star_rot_Dirac::angu_mom() const {
147 
148  if (p_angu_mom == 0x0) { // a new computation is required
149 
150  // phi_kill = axial killing vector
151 
152  Vector phi_kill(mp, CON, mp.get_bvect_spher()) ;
153 
154  phi_kill.set(1).set_etat_zero() ;
155  phi_kill.set(2).set_etat_zero() ;
156  phi_kill.set(3) = 1. ;
157  phi_kill.set(3).std_spectral_base() ;
158  phi_kill.set(3).mult_rsint() ;
159 
160  Scalar j_source = contract(contract(gamma.cov(), 0, j_euler, 0),
161  0, phi_kill, 0) ;
162 
163  Scalar dens = sqrt( gamma.determinant() ) * j_source ;
164 
165  dens.std_spectral_base() ;
166 
167  p_angu_mom = new double( dens.integrale() ) ;
168 
169 
170  }
171 
172  return *p_angu_mom ;
173 
174 }
175 
176  //---------------------//
177  // T/W //
178  //---------------------//
179 
180 double Star_rot_Dirac::tsw() const {
181 
182  if (p_tsw == 0x0) { // a new computation is required
183 
184  double tcin = 0.5 * omega * angu_mom() ;
185 
186  Scalar dens = sqrt( gamma.determinant() ) * gam_euler * ener ;
187 
188  dens.std_spectral_base() ;
189 
190  double mass_p = dens.integrale() ;
191 
192  p_tsw = new double( tcin / ( mass_p + tcin - mass_g() ) ) ;
193 
194  }
195 
196  return *p_tsw ;
197 
198 }
199 
200 
201  //--------------------------------------------------------------//
202  // GRV2 //
203  // cf. Eq. (28) of Bonazzola & Gourgoulhon CQG, 11, 1775 (1994) //
204  // //
205  //--------------------------------------------------------------//
206 
207 double Star_rot_Dirac::grv2() const {
208 
209  using namespace Unites ;
210 
211  if (p_grv2 == 0x0) { // a new computation is required
212 
213  // determinant of the 2-metric k_{ab}
214 
215  Scalar k_det = gamma.cov()(1,1)*gamma.cov()(2,2) -
216  gamma.cov()(1,2)*gamma.cov()(1,2) ;
217 
218 
219  //**
220  // sou_m = 8\pi T_{\mu\nu} m^{\mu}m^{\nu}
221  // => sou_m = 8\pi [ (E+P) U^2 + P ], where v^2 = v_i v^i
222  //
223  //**
224 
225  Scalar sou_m = 2 * qpig * ( (ener_euler + press)*v2 + press ) ;
226 
227  sou_m = sqrt( k_det )*sou_m ;
228 
229  sou_m.std_spectral_base() ;
230 
231 
232  // This is the term 3k_a k^a.
233 
234  Scalar sou_q = 3 *( taa(1,3) * aa(1,3) + taa(2,3)*aa(2,3) ) ;
235 
236 
237  // This is the term \nu_{|| a}\nu^{|| a}.
238  //
239 
240  Scalar sou_tmp = gamma.con()(1,1) * logn.dsdr() * logn.dsdr() ;
241 
242  Scalar term_2 = 2 * gamma.con()(1,2) * logn.dsdr() * logn.dsdt() ;
243 
244  term_2.div_r_dzpuis(4) ;
245 
246  Scalar term_3 = gamma.con()(2,2) * logn.dsdt() * logn.dsdt() ;
247 
248  term_3.div_r_dzpuis(2) ;
249  term_3.div_r_dzpuis(4) ;
250 
251  sou_tmp += term_2 + term_3 ;
252 
253 
254  // Source of the gravitational part
255 
256  sou_q -= sou_tmp ;
257 
258  sou_q = sqrt( k_det )*sou_q ;
259 
260  sou_q.std_spectral_base() ;
261 
262  p_grv2 = new double( double(1) + integrale2d(sou_m)/integrale2d(sou_q) ) ;
263 
264  }
265 
266  return *p_grv2 ;
267 
268 }
269 
270 
271  //-------------------------------------------------------------//
272  // GRV3 //
273  // cf. Eq. (29) of Gourgoulhon & Bonazzola CQG, 11, 443 (1994) //
274  //-------------------------------------------------------------//
275 
276 double Star_rot_Dirac::grv3() const {
277 
278  using namespace Unites ;
279 
280  if (p_grv3 == 0x0) { // a new computation is required
281 
282  // Gravitational term
283  // -------------------
284 
285  Scalar sou_q = 0.75*aa_quad - contract(logn.derive_cov(gamma), 0,
286  logn.derive_con(gamma), 0) ;
287 
288 
289  Tensor t_tmp = contract(gamma.connect().get_delta(), 2,
290  gamma.connect().get_delta(), 0) ;
291 
292  Scalar tmp_1 = 0.25* contract( gamma.con(), 0, 1,
293  contract(t_tmp, 0, 3), 0, 1 ) ;
294 
295  Scalar tmp_2 = 0.25* contract( gamma.con(), 0, 1,
296  contract( contract( gamma.connect().get_delta(), 0, 1),
297  0, gamma.connect().get_delta(), 0), 0, 1) ;
298 
299  sou_q = sou_q + tmp_1 - tmp_2 ;
300 
301  sou_q = sqrt( gamma.determinant() ) * sou_q ;
302 
303  sou_q.std_spectral_base() ;
304 
305  double int_grav = sou_q.integrale() ;
306 
307 
308  // Matter term
309  // --------------
310 
311  Scalar sou_m = qpig*s_euler ;
312 
313  sou_m = sqrt( gamma.determinant() ) * sou_m ;
314 
315  sou_m.std_spectral_base() ;
316 
317  double int_mat = sou_m.integrale() ;
318 
319  p_grv3 = new double( (int_grav + int_mat) / int_mat ) ;
320 
321 
322 
323  }
324 
325  return *p_grv3 ;
326 
327 }
328 
329 
330  //--------------------//
331  // R_circ //
332  //--------------------//
333 
334 double Star_rot_Dirac::r_circ() const {
335 
336  if (p_r_circ ==0x0) { // a new computation is required
337 
338  // Index of the point at phi=0, theta=pi/2 at the surface of the star:
339  const Mg3d* mg = mp.get_mg() ;
340  int l_b = nzet - 1 ;
341  int i_b = mg->get_nr(l_b) - 1 ;
342  int j_b = (mg->get_type_t() == SYM ? mg->get_nt(l_b) - 1 : mg->get_nt(l_b) / 2) ;
343  int k_b = 0 ;
344 
345  double gamma_phi = gamma.cov()(3,3).val_grid_point(l_b, k_b, j_b, i_b) ;
346 
347  p_r_circ = new double( sqrt( gamma_phi ) * ray_eq() ) ;
348 
349  }
350 
351  return *p_r_circ ;
352 
353 }
354 
355 
356  //--------------------//
357  // R_circ //
358  //--------------------//
359 
360 double Star_rot_Dirac::rp_circ() const {
361 
362  if (p_rp_circ ==0x0) { // a new computation is required
363  const Mg3d& mg = *mp.get_mg() ;
364  int nz = mg.get_nzone() ;
365  assert(nz>2) ;
366  int np = mg.get_np(0) ;
367  if (np != 1) {
368  cout << "The polar circumferential radius is only well defined\n"
369  << "with np = 1!" << endl ;
370  abort() ;
371  }
372  int nt = mg.get_nt(0) ;
373  Sym_tensor gam = gamma.cov() ;
374  const Coord& tet = mp.tet ;
375  Scalar rrr(mp) ;
376  rrr.annule_hard() ;
377  rrr.annule(nzet,nz-1) ;
378  double phi = 0 ;
379  for (int j=0; j<nt; j++) {
380  double theta = (+tet)(0, 0, j, 0) ;
381  double erre =
382  mp.val_r(l_surf()(0,j), xi_surf()(0, j), theta, phi) ;
383  for (int lz=0; lz<nzet; lz++) {
384  int nrz = mg.get_nr(lz) ;
385  for (int i=0; i<nrz; i++) {
386  rrr.set_grid_point(lz, 0, j, i) = erre ;
387  }
388  }
389  }
390  rrr.std_spectral_base() ;
391  Scalar drrr = rrr.dsdt() ;
392 
393  Scalar fff(mp) ;
394  fff.annule_hard() ;
395  fff.annule(nzet,nz-1) ;
396  for (int j=0; j<nt; j++) {
397  double theta = (+tet)(0, 0, j, 0) ;
398  int ls = l_surf()(0, j) ;
399  double xs = xi_surf()(0, j) ;
400  double grr = gam(1,1).get_spectral_va().val_point_jk(ls, xs, j, 0) ;
401  double grt = gam(1,2).get_spectral_va().val_point_jk(ls, xs, j, 0) ;
402  double gtt = gam(2,2).get_spectral_va().val_point_jk(ls, xs, j, 0) ;
403  double rr = mp.val_r(ls, xs, theta, phi) ;
404  double dr = drrr.get_spectral_va().val_point_jk(ls, xs, j, 0) ;
405  for (int i=0; i< mg.get_nr(nzet-1); i++) {
406  fff.set_grid_point(nzet-1, 0, j, i)
407  = sqrt(grr*dr*dr + 2*grt*rr*dr + gtt*rr*rr) ;
408  }
409  }
410  fff.std_spectral_base() ;
411  fff.set_spectral_va().coef() ;
412  p_rp_circ = new double((*fff.get_spectral_va().c_cf)(nzet-1, 0, 0, 0)) ;
413  }
414  return *p_rp_circ ;
415 }
416 
417  //--------------------------//
418  // Flattening //
419  //--------------------------//
420 
421 double Star_rot_Dirac::aplat() const {
422 
423  return ray_pole() / ray_eq() ;
424 
425 }
426 
427  //--------------------------//
428  // Ellipticity //
429  //--------------------------//
430 
431 double Star_rot_Dirac::ellipt() const {
432 
433  return sqrt(1. - (rp_circ()*rp_circ())/(r_circ()*r_circ())) ;
434 
435 }
436 }
virtual double grv3() const
Error on the virial identity GRV3.
double * p_mass_b
Baryon mass.
Definition: star.h:268
double * p_angu_mom
Angular momentum.
virtual const Sym_tensor & con() const
Read-only access to the contravariant representation.
Definition: metric.C:293
double * p_rp_circ
Circumferential polar radius.
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
Definition: valeur.h:312
double omega
Rotation angular velocity ([f_unit] )
Map & mp
Mapping associated with the star.
Definition: star.h:180
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition: grilles.h:479
void coef() const
Computes the coeffcients of *this.
Definition: valeur_coef.C:151
Cmp sqrt(const Cmp &)
Square root.
Definition: cmp_math.C:223
virtual void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Definition: scalar.C:330
virtual void annule(int l_min, int l_max)
Sets the Scalar to zero in several domains.
Definition: scalar.C:397
Metric gamma
3-metric
Definition: star.h:235
const Base_vect_spher & get_bvect_spher() const
Returns the orthonormal vectorial basis associated with the coordinates of the mapping.
Definition: map.h:801
Lorene prototypes.
Definition: app_hor.h:67
Standard units of space, time and mass.
const Scalar & dsdt() const
Returns of *this .
Definition: scalar_deriv.C:208
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition: map.h:783
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:393
double integrale() const
Computes the integral over all space of *this .
Definition: scalar_integ.C:64
int get_type_t() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the equatorial pl...
Definition: grilles.h:502
virtual void std_spectral_base()
Sets the spectral bases of the Valeur va to the standard ones for a scalar field. ...
Definition: scalar.C:790
virtual double r_circ() const
Circumferential equatorial radius.
Scalar nbar
Baryon density in the fluid frame.
Definition: star.h:192
Scalar s_euler
Trace of the stress scalar in the Eulerian frame.
Definition: star.h:201
Vector beta
Shift vector.
Definition: star.h:228
const Vector & derive_con(const Metric &gam) const
Returns the "contravariant" derivative of *this with respect to some metric , by raising the index of...
Definition: scalar_deriv.C:402
Tensor field of valence 1.
Definition: vector.h:188
const Tensor_sym & get_delta() const
Returns the tensor which defines the connection with respect to the flat one: is the difference bet...
Definition: connection.h:271
Coord tet
coordinate centered on the grid
Definition: map.h:737
const Tbl & xi_surf() const
Description of the stellar surface: returns a 2-D Tbl containing the values of the radial coordinate ...
Definition: star_global.C:92
void annule_hard()
Sets the Scalar to zero in a hard way.
Definition: scalar.C:386
virtual double angu_mom() const
Angular momentum.
int nzet
Number of domains of *mp occupied by the star.
Definition: star.h:183
double * p_r_circ
Circumferential equatorial radius.
Scalar gam_euler
Lorentz factor between the fluid and Eulerian observers.
Definition: star.h:204
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.
Scalar ener
Total energy density in the fluid frame.
Definition: star.h:193
virtual double tsw() const
Ratio T/W.
virtual double mass_g() const
Gravitational mass.
Scalar press
Fluid pressure.
Definition: star.h:194
virtual double ellipt() const
Ellipticity e.
virtual const Connection & connect() const
Returns the connection.
Definition: metric.C:304
virtual const Itbl & l_surf() const
Description of the stellar surface: returns a 2-D Itbl containing the values of the domain index l on...
Definition: star_global.C:66
double * p_tsw
Ratio T/W.
virtual double grv2() const
Error on the virial identity GRV2.
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:465
double * p_grv3
Error on the virial identity GRV3.
double val_point_jk(int l, double x, int j, int k) const
Computes the value of the field represented by *this at an arbitrary point in , but collocation point...
Definition: valeur.C:903
Tensor handling.
Definition: tensor.h:294
double * p_grv2
Error on the virial identity GRV2.
Tenseur contract(const Tenseur &, int id1, int id2)
Self contraction of two indices of a Tenseur .
Scalar logn
Logarithm of the lapse N .
Definition: star.h:222
virtual double mass_b() const
Baryonic mass.
Active physical coordinates and mapping derivatives.
Definition: coord.h:90
virtual const Scalar & determinant() const
Returns the determinant.
Definition: metric.C:395
virtual double aplat() const
Flattening r_pole/r_eq.
double ray_pole() const
Coordinate radius at [r_unit].
Definition: star_global.C:281
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition: grilles.h:469
virtual const Sym_tensor & cov() const
Read-only access to the covariant representation.
Definition: metric.C:283
Multi-domain grid.
Definition: grilles.h:279
double & set_grid_point(int l, int k, int j, int i)
Setting the value of the field at a given grid point.
Definition: scalar.h:690
Scalar nn
Lapse function N .
Definition: star.h:225
virtual double rp_circ() const
Circumferential polar radius.
double ray_eq() const
Coordinate radius at , [r_unit].
Definition: star_global.C:111
const Scalar & dsdr() const
Returns of *this .
Definition: scalar_deriv.C:113
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition: grilles.h:474
Valeur & set_spectral_va()
Returns va (read/write version)
Definition: scalar.h:610
Scalar & set(int)
Read/write access to a component.
Definition: vector.C:302
void div_r_dzpuis(int ced_mult_r)
Division by r everywhere but with the output flag dzpuis set to ced_mult_r .
const Vector & derive_cov(const Metric &gam) const
Returns the gradient (1-form = covariant vector) of *this
Definition: scalar_deriv.C:390
Vector j_euler
Momentum density 3-vector with respect to the Eulerian observer.
Scalar ener_euler
Total energy density in the Eulerian frame.
Definition: star.h:198
double * p_mass_g
Gravitational mass.
Definition: star.h:269
Class intended to describe valence-2 symmetric tensors.
Definition: sym_tensor.h:226
const Valeur & get_spectral_va() const
Returns va (read only version)
Definition: scalar.h:607