LORENE
et_bin_hydro.C
1 /*
2  * Methods of the class Etoile_bin for computing hydro quantities
3  *
4  * (see file etoile.h for documentation)
5  */
6 
7 /*
8  * Copyright (c) 2000-2001 Eric Gourgoulhon
9  *
10  * This file is part of LORENE.
11  *
12  * LORENE is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
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 /*
32  * $Id: et_bin_hydro.C,v 1.7 2016/12/05 16:17:53 j_novak Exp $
33  * $Log: et_bin_hydro.C,v $
34  * Revision 1.7 2016/12/05 16:17:53 j_novak
35  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
36  *
37  * Revision 1.6 2014/10/13 08:52:55 j_novak
38  * Lorene classes and functions now belong to the namespace Lorene.
39  *
40  * Revision 1.5 2005/08/29 15:10:16 p_grandclement
41  * Addition of things needed :
42  * 1) For BBH with different masses
43  * 2) Provisory files for the mixted binaries (Bh and NS) : THIS IS NOT
44  * WORKING YET !!!
45  *
46  * Revision 1.4 2003/03/03 19:46:09 f_limousin
47  * Set standard bases for s_euler.
48  *
49  * Revision 1.3 2003/01/17 13:34:56 f_limousin
50  * Replace A^2*flat_scalar_prod by sprod
51  *
52  * Revision 1.2 2002/12/10 15:29:29 k_taniguchi
53  * Change the multiplication "*" to "%"
54  * and flat_scalar_prod to flat_scalar_prod_desal.
55  *
56  * Revision 1.1.1.1 2001/11/20 15:19:28 e_gourgoulhon
57  * LORENE
58  *
59  * Revision 2.11 2000/12/22 13:10:32 eric
60  * Modif des annulations en dehors de l'etoile.
61  *
62  * Revision 2.10 2000/03/29 11:47:53 eric
63  * Suppression affichage.
64  *
65  * Revision 2.9 2000/03/01 16:12:09 eric
66  * Appel de set_std_base sur u_euler dans le cas irrotationnel.
67  *
68  * Revision 2.8 2000/02/24 09:34:10 keisuke
69  * Ajout de l'appel a set_std_base() sur wit_w.
70  *
71  * Revision 2.7 2000/02/21 13:59:09 eric
72  * Appel de set_dzpuis(0) sur loggam.
73  *
74  * Revision 2.6 2000/02/21 08:43:17 keisuke
75  * Ajout de l'appel a set_std_base() sur loggam.
76  *
77  * Revision 2.5 2000/02/17 14:42:45 eric
78  * Ajout de l'appel a set_std_base() sur gam_euler.
79  *
80  * Revision 2.4 2000/02/14 11:06:15 eric
81  * Suppression de l'appel a annule(nzet.nzm1) sur gam_euler dans le cas en
82  * corotation.
83  * Ajout de l'appel a annule(nzet,nzm1) sur wit_w.
84  *
85  * Revision 2.3 2000/02/12 18:36:23 eric
86  * Appel de set_std_base sur loggam.
87  *
88  * Revision 2.2 2000/02/08 19:29:03 eric
89  * Calcul sur les tenseurs.
90  * wit_w est calcule.
91  *
92  * Revision 2.1 2000/02/04 16:37:28 eric
93  * Premiere version implementee (non testee !)/
94  *
95  * Revision 2.0 2000/01/31 15:57:30 eric
96  * *** empty log message ***
97  *
98  *
99  * $Header: /cvsroot/Lorene/C++/Source/Etoile/et_bin_hydro.C,v 1.7 2016/12/05 16:17:53 j_novak Exp $
100  *
101  */
102 
103 // Headers C
104 
105 // Headers Lorene
106 #include "etoile.h"
107 
108 namespace Lorene {
110 
111  int nz = mp.get_mg()->get_nzone() ;
112  int nzm1 = nz - 1 ;
113 
114  //----------------------------------
115  // Specific relativistic enthalpy ---> hhh
116  //----------------------------------
117 
118  Tenseur hhh = exp(unsurc2 * ent) ; // = 1 at the Newtonian limit
119  hhh.set_std_base() ;
120 
121  //---------------------------------------------------
122  // Lorentz factor between the co-orbiting ---> gam0
123  // observer and the Eulerian one
124  // See Eq (23) and (24) from Gourgoulhon et al. (2001)
125  //---------------------------------------------------
126 
127  Tenseur gam0 = 1/sqrt(1-unsurc2*sprod(bsn,bsn)) ;
128  gam0.set_std_base() ;
129 
130  //------------------------------------------
131  // Lorentz factor and 3-velocity of the fluid
132  // with respect to the Eulerian observer
133  //------------------------------------------
134 
135  if (irrotational) {
136 
137 //## cout << "Etoile_bin::hydro_euler : ### warning : " << endl ;
138 // cout << " d_psi.d_psi would be better computed in spher. coord. !"
139 //## << endl ;
140 
141  d_psi.set_std_base() ;
142 
143  // See Eq (32) from Gourgoulhon et al. (2001)
145  / (hhh%hhh) ) ;
146 
147  gam_euler.set_std_base() ; // sets the standard spectral bases for
148  // a scalar field
149 
150 
151  // See Eq (31) from Gourgoulhon et al. (2001)
152  Tenseur vtmp = d_psi / ( hhh % gam_euler % a_car ) ;
153 
154  // The assignment of u_euler is performed component by component
155  // because u_euler is contravariant and d_psi is covariant
156  if (vtmp.get_etat() == ETATZERO) {
158  }
159  else{
160  assert(vtmp.get_etat() == ETATQCQ) ;
161  u_euler.set_etat_qcq() ;
162  for (int i=0; i<3; i++) {
163  u_euler.set(i) = vtmp(i) ;
164  }
165  u_euler.set_triad( *(vtmp.get_triad()) ) ;
166  }
167 
168  u_euler.set_std_base() ;
169 
170  }
171  else { // Rigid rotation
172  // --------------
173 
174  gam_euler = gam0 ;
175  gam_euler.set_std_base() ; // sets the standard spectral bases for
176  // a scalar field
177 
178  u_euler = -bsn ;
179 
180  }
181 
182  //------------------------------------
183  // Energy density E with respect to the Eulerian observer
184  // See Eq (53) from Gourgoulhon et al. (2001)
185  //------------------------------------
186 
187  ener_euler = gam_euler % gam_euler % ( ener + press ) - press ;
188 
189  //------------------------------------
190  // Trace of the stress tensor with respect to the Eulerian observer
191  // See Eq (54) from Gourgoulhon et al. (2001)
192  //------------------------------------
193 
194  //Tenseur tmp00 = sprod(u_euler, u_euler) ;
195  //cout << hex << u_euler(0).va.base.b[0] << endl ;
196  //cout << hex << u_euler(1).va.base.b[0] << endl ;
197  //cout << hex << u_euler(2).va.base.b[0] << endl ;
198  //cout << hex << tmp00().va.base.b[0] << endl ;
199 
200  s_euler = 3 * press + ( ener_euler + press ) *
201  sprod(u_euler, u_euler) ;
202  s_euler.set_std_base() ;
203 
204 
205  //-------------------------------------------
206  // Lorentz factor between the fluid and ---> gam
207  // co-orbiting observers
208  // See Eq (58) from Gourgoulhon et al. (2001)
209  //--------------------------------------------
210 
211  Tenseur tmp = ( 1+unsurc2*sprod(bsn,u_euler) ) ;
212  tmp.set_std_base() ;
213  Tenseur gam = gam0 % gam_euler % tmp ;
214 
215  //-------------------------------------------
216  // Spatial projection of the fluid 3-velocity
217  // with respect to the co-orbiting observer
218  //--------------------------------------------
219 
220  wit_w = gam_euler / gam % u_euler + gam0 % bsn ;
221 
222  wit_w.set_std_base() ; // set the bases for spectral expansions
223 
224  wit_w.annule(nzm1) ; // zero in the ZEC
225 
226 
227  //-------------------------------------------
228  // Logarithm of the Lorentz factor between
229  // the fluid and co-orbiting observers
230  //--------------------------------------------
231 
232  if (relativistic) {
233 
234  loggam = log( gam ) ;
235 
236  loggam.set_std_base() ; // set the bases for spectral expansions
237  }
238  else {
239 
241 
242  loggam.set_std_base() ; // set the bases for spectral expansions
243 
244 //### Forcage a zero des termes en sin(m*phi) :
245 // loggam.coef() ;
246 // int np = mgrille->np[0] ;
247 // int nt = mgrille->nt[0] ;
248 // int nr = mgrille->nr[0] ;
249 // int ntnr = nt * nr ;
250 // for (int k = 1; k < np+2; k+=2) {
251 // for (int j = 0; j < nt; j++) {
252 // for (int i = 0; i<nr; i++) {
253 // loggam.c_cf[0]->t[0]->t[ntnr*k + nr*j + i] = 0 ;
254 // }
255 // }
256 // }
257 // loggam.c_ajx[0] = 0 ;
258 // loggam.c_aj = 0 ;
259 // loggam.coef_i() ;
260 //###
261  }
262 
263 
264  //-------------------------------------------------
265  // Velocity fields set to zero in external domains
266  //-------------------------------------------------
267 
268  loggam.annule(nzm1) ; // zero in the ZEC only
269 
270  wit_w.annule(nzm1) ; // zero outside the star
271 
272  u_euler.annule(nzm1) ; // zero outside the star
273 
274 
275  if (loggam.get_etat() != ETATZERO) {
276  (loggam.set()).set_dzpuis(0) ;
277  }
278 
279  //################
280  // verification: test on gam_euler
281 
282  // if (irrotational) {
283 
284  // Tenseur gam_test = 1. / sqrt( 1 - unsurc2 * sprod(u_euler, u_euler) ) ;
285 
286  // cout << "Etoile_bin::hydro_euler: test of gam_euler : " << endl ;
287  // cout << " maximum error : " << endl ;
288  // cout << max(gam_test() - gam_euler()) << endl ;
289  //cout << " relative error : " << endl ;
290  // cout << diffrel(gam_test(), gam_euler()) << endl ;
291 
292  // }
293 
294  //##################
295 
296 
297  //### Test
298 
299  if (!irrotational) {
300 
301  // Tenseur diff = gam - 1 ;
302  // cout << "Etoile_bin::hydro_euler: rigid motion: difference gam <-> 1 : "
303  // << endl ;
304  // cout << norme(diff()) / norme(gam()) << endl ;
305  //
306  // cout << "Etoile_bin::hydro_euler: rigid motion: difference wit_w <-> 0 : "
307  // << endl ;
308  // cout << "Component x : " << endl << norme(wit_w(0)) << endl ;
309  // cout << "Component y : " << endl << norme(wit_w(1)) << endl ;
310  // cout << "Component z : " << endl << norme(wit_w(2)) << endl ;
311 
312 //####
313  gam = 1 ;
314  loggam = 0 ;
315  wit_w = 0 ;
316  }
317 
318  // The derived quantities are obsolete
319  // -----------------------------------
320 
321  del_deriv() ;
322 
323 
324 }
325 }
Cmp log(const Cmp &)
Neperian logarithm.
Definition: cmp_math.C:299
void annule(int l)
Sets the Tenseur to zero in a given domain.
Definition: tenseur.C:916
Cmp exp(const Cmp &)
Exponential.
Definition: cmp_math.C:273
void set_triad(const Base_vect &new_triad)
Assigns a new vectorial basis (triad) of decomposition.
Definition: tenseur.C:690
Cmp sqrt(const Cmp &)
Square root.
Definition: cmp_math.C:223
void set_std_base()
Set the standard spectal basis of decomposition for each component.
Definition: tenseur.C:1186
Lorene prototypes.
Definition: app_hor.h:67
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition: map.h:777
Tenseur s_euler
Trace of the stress tensor in the Eulerian frame.
Definition: etoile.h:471
Tenseur wit_w
Spatial projection of the fluid 3-velocity with respect to the co-orbiting observer.
Definition: etoile.h:847
double unsurc2
: unsurc2=1 for a relativistic star, 0 for a Newtonian one.
Definition: etoile.h:445
Tenseur press
Fluid pressure.
Definition: etoile.h:464
bool irrotational
true for an irrotational star, false for a corotating one
Definition: etoile.h:825
Cmp & set()
Read/write for a scalar (see also operator=(const Cmp&) ).
Definition: tenseur.C:840
Tenseur u_euler
Fluid 3-velocity with respect to the Eulerian observer.
Definition: etoile.h:477
virtual void del_deriv() const
Deletes all the derived quantities.
Definition: etoile_bin.C:450
Tenseur flat_scalar_prod_desal(const Tenseur &t1, const Tenseur &t2)
Same as flat_scalar_prod but with desaliasing.
Tenseur bsn
3-vector shift, divided by N , of the rotating coordinates, .
Definition: etoile.h:953
const Base_vect * get_triad() const
Returns the vectorial basis (triad) on which the components are defined.
Definition: tenseur.h:707
Tenseur gam_euler
Lorentz factor between the fluid and Eulerian observers.
Definition: etoile.h:474
Map & mp
Mapping associated with the star.
Definition: etoile.h:432
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:465
int get_etat() const
Returns the logical state.
Definition: tenseur.h:710
Tenseur a_car
Total conformal factor .
Definition: etoile.h:518
bool relativistic
Indicator of relativity: true for a relativistic star, false for a Newtonian one. ...
Definition: etoile.h:440
Tenseur ener
Total energy density in the fluid frame.
Definition: etoile.h:463
Tenseur loggam
Logarithm of the Lorentz factor between the fluid and the co-orbiting observer.
Definition: etoile.h:852
Tenseur ent
Log-enthalpy (relativistic case) or specific enthalpy (Newtonian case)
Definition: etoile.h:460
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: tenseur.C:652
Tenseur ener_euler
Total energy density in the Eulerian frame.
Definition: etoile.h:468
void set_etat_zero()
Sets the logical state to ETATZERO (zero state).
Definition: tenseur.C:661
virtual Tenseur sprod(const Tenseur &t1, const Tenseur &t2) const
Performs the scalar product of two tensors by contracting the last index of t1 with the first index o...
Definition: etoile_bin.C:751
Tensor handling *** DEPRECATED : use class Tensor instead ***.
Definition: tenseur.h:304
Tenseur d_psi
Gradient of (in the irrotational case) (Cartesian components with respect to ref_triad ) ...
Definition: etoile.h:841
virtual void hydro_euler()
Computes the hydrodynamical quantities relative to the Eulerian observer from those in the fluid fram...
Definition: et_bin_hydro.C:109