LORENE
binary_global_xcts.C
1 /*
2  * Methods of class Binary_xcts to compute global quantities
3  * (see file binary_xcts.h for documentation)
4  */
5 
6 /*
7  * Copyright (c) 2010 Michal Bejger
8  *
9  * This file is part of LORENE.
10  *
11  * LORENE is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2
13  * as published by the Free Software Foundation.
14  *
15  * LORENE is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with LORENE; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */
25 
26 
27 
28 /*
29  * $Id: binary_global_xcts.C,v 1.12 2016/12/05 16:17:47 j_novak Exp $
30  * $Log: binary_global_xcts.C,v $
31  * Revision 1.12 2016/12/05 16:17:47 j_novak
32  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
33  *
34  * Revision 1.11 2014/10/13 08:52:45 j_novak
35  * Lorene classes and functions now belong to the namespace Lorene.
36  *
37  * Revision 1.10 2010/12/21 11:15:46 m_bejger
38  * Linear momentum properly defined
39  *
40  * Revision 1.9 2010/12/20 15:45:40 m_bejger
41  * Spectral basis in lin_mom() was not defined
42  *
43  * Revision 1.8 2010/12/20 09:54:09 m_bejger
44  * Angular momentum correction, stub for linear momentum added
45  *
46  * Revision 1.7 2010/12/09 10:39:41 m_bejger
47  * Further corrections to integral quantities
48  *
49  * Revision 1.6 2010/10/26 19:16:26 m_bejger
50  * Cleanup of some diagnostic messages
51  *
52  * Revision 1.5 2010/10/25 15:02:08 m_bejger
53  * mass_kom_vol() corrected
54  *
55  * Revision 1.4 2010/10/24 21:45:24 m_bejger
56  * mass_adm() corrected
57  *
58  * Revision 1.3 2010/06/17 14:48:14 m_bejger
59  * Minor corrections
60  *
61  * Revision 1.2 2010/06/04 19:54:19 m_bejger
62  * Minor corrections, mass volume integrals need to be checked out
63  *
64  * Revision 1.1 2010/05/04 07:35:54 m_bejger
65  * Initial version
66  *
67  * $Header: /cvsroot/Lorene/C++/Source/Binary_xcts/binary_global_xcts.C,v 1.12 2016/12/05 16:17:47 j_novak Exp $
68  *
69  */
70 
71 // Headers C
72 #include "math.h"
73 
74 // Headers Lorene
75 #include "nbr_spx.h"
76 #include "binary_xcts.h"
77 #include "unites.h"
78 #include "metric.h"
79 
80  //---------------------------------//
81  // ADM mass //
82  //---------------------------------//
83 
84 namespace Lorene {
85 double Binary_xcts::mass_adm() const {
86 
87  using namespace Unites ;
88 
89  if (p_mass_adm == 0x0) { // a new computation is required
90 
91  p_mass_adm = new double ;
92  *p_mass_adm = 0 ;
93 
94  const Map_af map0 (et[0]->get_mp()) ;
95  const Metric& flat = (et[0]->get_flat()) ;
96 
97  Vector dpsi((et[0]->get_Psi()).derive_cov(flat)) ;
98 
99  dpsi.change_triad(map0.get_bvect_spher()) ;
100 
101  Scalar integrand ( dpsi(1) ) ;
102 
103  *p_mass_adm = - 2.* map0.integrale_surface_infini(integrand)/ qpig ;
104 
105  }
106 
107  return *p_mass_adm ;
108 
109 }
110 
111  //---------------------------------//
112  // ADM mass //
113  // (volume integral) //
114  //---------------------------------//
115 
117 
118  using namespace Unites ;
119 
120  double massadm = 0. ;
121 
122  for (int i=0; i<=1; i++) { // loop on the stars
123 
124  // Declaration of all fields
125 
126  const Scalar& psi(et[i]->get_Psi()) ;
127  Scalar psi5 = pow(psi, 5.) ;
128  psi5.std_spectral_base() ;
129 
130  Scalar spsi7 = pow(psi, -7.) ;
131  spsi7.std_spectral_base() ;
132 
133  const Scalar& ener_euler = et[i]->get_ener_euler() ;
134  const Scalar& hacar_auto = et[i]->get_hacar_auto() ;
135  const Scalar& hacar_comp = et[i]->get_hacar_comp() ;
136 
137  Scalar source = psi5 % ener_euler
138  + spsi7 % (hacar_auto + hacar_comp)/(4.*qpig) ;
139 
140  source.std_spectral_base() ;
141 
142  massadm += source.integrale() ;
143  }
144 
145  return massadm ;
146 }
147 
148  //---------------------------------//
149  // Komar mass //
150  //---------------------------------//
151 
152 double Binary_xcts::mass_kom() const {
153 
154  using namespace Unites ;
155 
156  if (p_mass_kom == 0x0) { // a new computation is requireed
157 
158  p_mass_kom = new double ;
159  *p_mass_kom = 0 ;
160 
161  const Scalar& logn = et[0]->get_logn() ;
162  const Metric& flat = et[0]->get_flat() ;
163 
164  Map_af map0 (et[0]->get_mp()) ;
165 
166  Vector vect = logn.derive_con(flat) ;
167  vect.change_triad(map0.get_bvect_spher()) ;
168 
169  Scalar integrant (vect(1)) ;
170 
171  *p_mass_kom = map0.integrale_surface_infini (integrant) / qpig ;
172 
173  } // End of the case where a new computation was necessary
174 
175  return *p_mass_kom ;
176 
177 }
178 
180 
181  using namespace Unites ;
182 
183  double masskom = 0.;
184 
185  for (int i=0; i<=1; i++) { // loop on the stars
186 
187  const Scalar& Psi = et[i]->get_Psi() ;
188  const Scalar& psi4 = et[i]->get_psi4() ;
189  const Scalar& chi = et[i]->get_chi() ;
190 
191  const Scalar& ener_euler = et[i]->get_ener_euler() ;
192  const Scalar& s_euler = et[i]->get_s_euler() ;
193  const Scalar& hacar_auto = et[i]->get_hacar_auto() ;
194  const Scalar& hacar_comp = et[i]->get_hacar_comp() ;
195 
196  Scalar psi4chi = psi4 % chi ;
197  psi4chi.std_spectral_base() ;
198 
199  Scalar source = 0.5 * ener_euler * (psi4chi + psi4 % Psi)
200  + psi4chi * s_euler + pow(Psi, -7.) * (7.*chi/Psi + 1.)
201  * (hacar_auto + hacar_comp) / (8.*qpig) ;
202  source.std_spectral_base() ;
203 
204  masskom += source.integrale() ;
205 
206  }
207 
208  return masskom ;
209 
210 }
211 
212  //-------------------------------------//
213  // Total angular momentum (z-axis) //
214  //-------------------------------------//
215 
216 const Tbl& Binary_xcts::angu_mom() const {
217 
218  using namespace Unites ;
219 
220  if (p_angu_mom == 0x0) { // a new computation is required
221 
222  p_angu_mom = new Tbl(3) ;
223  p_angu_mom->annule_hard() ; // fills the double array with zeros
224 
225  // Reference Cartesian vector basis of the Absolute frame
226  Base_vect_cart bvect_ref(0.) ; // 0. = parallel to the Absolute frame
227 
228  for (int i=0; i<=1; i++) { // loop on the stars
229 
230  const Map& mp = et[i]->get_mp() ;
231 
232  // Azimuthal vector d/dphi
233  Vector vphi(mp, CON, bvect_ref) ;
234  Scalar yya (mp) ; yya = mp.ya ;
235  Scalar xxa (mp) ; xxa = mp.xa ;
236  vphi.set(1) = - yya ; // phi^X
237  vphi.set(2) = xxa ;
238  vphi.set(3) = 0 ;
239 
240  vphi.std_spectral_base() ;
241  vphi.change_triad(mp.get_bvect_cart()) ;
242 
243  // Matter part
244  // -----------
245  const Scalar& ee = et[i]->get_ener_euler() ;
246  const Scalar& pp = et[i]->get_press() ;
247 
248  Vector jmom = pow(et[i]->get_Psi(), 10) * (ee + pp)
249  * (et[i]->get_u_euler()) ;
250  jmom.std_spectral_base() ;
251 
252  const Metric& flat = et[i]->get_flat() ;
253  Vector vphi_cov = vphi.up_down(flat) ;
254 
255  Scalar integrand = contract(jmom, 0, vphi_cov, 0) ;
256 
257  p_angu_mom->set(2) += integrand.integrale() ;
258 
259  } // End of the loop on the stars
260 
261  } // End of the case where a new computation was necessary
262 
263  return *p_angu_mom ;
264 
265 }
266 
267  //---------------------------------//
268  // Total linear momentum //
269  //---------------------------------//
270 
271 const Tbl& Binary_xcts::lin_mom() const {
272 
273  using namespace Unites ;
274 
275  if (p_lin_mom == 0x0) { // a new computation is required
276 
277  p_lin_mom = new Tbl(3) ;
279 
280  // Reference Cartesian vector basis of the Absolute frame
281  Base_vect_cart bvect_ref(0.) ; // 0. = parallel to the Absolute frame
282 
283  for (int i=0; i<=1; i++) { // loop on the stars
284 
285  const Scalar& ee = et[i]->get_ener_euler() ;
286  const Scalar& pp = et[i]->get_press() ;
287  Vector lmom = pow(et[i]->get_Psi(), 10) * (ee + pp)
288  * ( et[i]->get_u_euler() ) ;
289 
290  lmom.std_spectral_base() ;
291  lmom.change_triad(bvect_ref) ;
292 
293  // loop on the components
294  for (int j=1; j<=2; j++)
295  p_lin_mom->set(j-1) += lmom(j).integrale() ;
296 
297 
298  } // End of the loop on the stars
299 
300  } // End of the case where a new computation was necessary
301 
302  return *p_lin_mom ;
303 
304 }
305 
306  //---------------------------------//
307  // Total energy //
308  //---------------------------------//
309 
310 double Binary_xcts::total_ener() const {
311 
312  if (p_total_ener == 0x0) { // a new computation is requireed
313 
314  p_total_ener = new double ;
315 
316  *p_total_ener = mass_adm() - star1.mass_b() - star2.mass_b() ;
317 
318  } // End of the case where a new computation was necessary
319 
320  return *p_total_ener ;
321 
322 }
323 
324 
325  //---------------------------------//
326  // Error on the virial theorem //
327  //---------------------------------//
328 
329 double Binary_xcts::virial() const {
330 
331  if (p_virial == 0x0) { // a new computation is requireed
332 
333  p_virial = new double ;
334 
335  *p_virial = 1. - mass_kom() / mass_adm() ;
336 
337  }
338 
339  return *p_virial ;
340 
341 }
342 
343  //---------------------------------//
344  // Error on the virial theorem //
345  // (volume version) //
346  //---------------------------------//
347 
348 double Binary_xcts::virial_vol() const {
349 
350  if (p_virial_vol == 0x0) { // a new computation is requireed
351 
352  p_virial_vol = new double ;
353 
354  *p_virial_vol = 1. - mass_kom_vol() / mass_adm_vol() ;
355 
356  }
357 
358  return *p_virial_vol ;
359 
360 }
361 }
Coord xa
Absolute x coordinate.
Definition: map.h:748
Metric for tensor calculation.
Definition: metric.h:90
const Scalar & get_press() const
Returns the fluid pressure.
Definition: star.h:373
const Scalar & get_ener_euler() const
Returns the total energy density with respect to the Eulerian observer.
Definition: star.h:376
double integrale_surface_infini(const Cmp &ci) const
Performs the surface integration of ci at infinity.
Star_bin_xcts * et[2]
Array of the two stars (to perform loops on the stars): et[0] contains the address of star1 and et[1]...
Definition: binary_xcts.h:75
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.
double & set(int i)
Read/write of a particular element (index i) (1D case)
Definition: tbl.h:301
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:393
Base class for coordinate mappings.
Definition: map.h:688
double integrale() const
Computes the integral over all space of *this .
Definition: scalar_integ.C:64
Tensor up_down(const Metric &gam) const
Computes a new tensor by raising or lowering all the indices of *this .
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
const Map & get_mp() const
Returns the mapping.
Definition: star.h:355
virtual void change_triad(const Base_vect &)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
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 Scalar & get_Psi() const
Return the conformal factor .
Definition: star.h:1389
const Scalar & get_psi4() const
Return the conformal factor .
Definition: star.h:1395
virtual void std_spectral_base()
Sets the standard spectal bases of decomposition for each component.
Definition: vector.C:322
const Scalar & get_logn() const
Returns the logarithm of the lapse N.
Definition: star.h:396
Tbl * p_angu_mom
Total angular momentum of the system.
Definition: binary_xcts.h:97
const Metric & get_flat() const
Return the flat metric defined on the mapping (Spherical components with respect to the mapping of th...
Definition: star.h:1400
Star_bin_xcts star2
Second star of the system.
Definition: binary_xcts.h:69
const Tbl & angu_mom() const
Total angular momentum.
double mass_adm() const
Total ADM mass.
double * p_mass_kom
Total Komar mass of the system.
Definition: binary_xcts.h:94
const Scalar & get_s_euler() const
Returns the trace of the stress tensor in the Eulerian frame.
Definition: star.h:379
const Tbl & lin_mom() const
Total linear momentum.
const Scalar & get_chi() const
Return the function .
Definition: star.h:1392
Cmp pow(const Cmp &, int)
Power .
Definition: cmp_math.C:351
Tenseur contract(const Tenseur &, int id1, int id2)
Self contraction of two indices of a Tenseur .
Cartesian vectorial bases (triads).
Definition: base_vect.h:201
const Scalar & get_hacar_auto() const
Returns the part of generated by beta_auto.
Definition: star.h:1417
Coord ya
Absolute y coordinate.
Definition: map.h:749
double mass_kom_vol() const
Total Komar mass (computed by a volume integral)
Affine radial mapping.
Definition: map.h:2048
const Base_vect_cart & get_bvect_cart() const
Returns the Cartesian basis associated with the coordinates (x,y,z) of the mapping, i.e.
Definition: map.h:809
double * p_total_ener
Total energy of the system.
Definition: binary_xcts.h:103
Star_bin_xcts star1
First star of the system.
Definition: binary_xcts.h:66
const Scalar & get_hacar_comp() const
Returns the part of generated by beta_comp.
Definition: star.h:1422
double virial_vol() const
Estimates the relative error on the virial theorem (volume version)
double * p_virial
Virial theorem error.
Definition: binary_xcts.h:106
double total_ener() const
Total energy (excluding the rest mass energy).
virtual double mass_b() const
Baryon mass.
double mass_kom() const
Total Komar mass.
double mass_adm_vol() const
Total ADM mass (computed by a volume integral)
Basic array class.
Definition: tbl.h:164
Scalar & set(int)
Read/write access to a component.
Definition: vector.C:302
double * p_mass_adm
Total ADM mass of the system.
Definition: binary_xcts.h:91
void annule_hard()
Sets the Tbl to zero in a hard way.
Definition: tbl.C:375
double * p_virial_vol
Virial theorem error (volume version)
Definition: binary_xcts.h:109
Tbl * p_lin_mom
Total linear momentum of the system.
Definition: binary_xcts.h:100
double virial() const
Estimates the relative error on the virial theorem.