LORENE
star_rot_dirac.C
1/*
2 * Methods of class Star_rot_Dirac
3 *
4 * (see file star_rot_dirac.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: star_rot_dirac.C,v 1.11 2016/12/05 16:18:15 j_novak Exp $
32 * $Log: star_rot_dirac.C,v $
33 * Revision 1.11 2016/12/05 16:18:15 j_novak
34 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
35 *
36 * Revision 1.10 2014/10/13 08:53:39 j_novak
37 * Lorene classes and functions now belong to the namespace Lorene.
38 *
39 * Revision 1.9 2014/10/06 15:13:17 j_novak
40 * Modified #include directives to use c++ syntax.
41 *
42 * Revision 1.8 2013/04/25 15:46:06 j_novak
43 * Added special treatment in the case np = 1, for type_p = NONSYM.
44 *
45 * Revision 1.7 2008/05/30 08:27:38 j_novak
46 * New global quantities rp_circ and ellipt (circumferential polar coordinate and
47 * ellipticity).
48 *
49 * Revision 1.6 2007/11/06 16:23:59 j_novak
50 * Added the flag spectral_filter giving the order of possible spectral filtering
51 * of the hydro sources of metric equations (some members *_euler). The filtering
52 * is done in strot_dirac_hydro, if this flag is non-zero.
53 *
54 * Revision 1.5 2007/11/06 10:15:19 j_novak
55 * Change the order of updates in the constructor from a file, to avoid
56 * inconsistencies.
57 *
58 * Revision 1.4 2007/10/30 16:55:23 j_novak
59 * Completed the input/ouput to a file
60 *
61 * Revision 1.3 2005/02/09 13:37:37 lm_lin
62 *
63 * Add pointers p_tsw, p_aplat, and p_r_circ; add more screen output
64 * information.
65 *
66 * Revision 1.2 2005/02/02 09:22:29 lm_lin
67 *
68 * Add the GRV3 error to screen output
69 *
70 * Revision 1.1 2005/01/31 08:51:48 j_novak
71 * New files for rotating stars in Dirac gauge (still under developement).
72 *
73 *
74 * $Header: /cvsroot/Lorene/C++/Source/Star/star_rot_dirac.C,v 1.11 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
88
89 //--------------//
90 // Constructors //
91 //--------------//
92
93// Standard constructor
94//-------------------------
95namespace Lorene {
96Star_rot_Dirac::Star_rot_Dirac(Map& mpi, int nzet_i, const Eos& eos_i, int filter)
97 : Star(mpi, nzet_i, eos_i),
98 spectral_filter(filter),
99 psi4(mpi),
100 psi2(mpi),
101 qqq(mpi),
102 ln_psi(mpi),
103 j_euler(mpi, CON, mpi.get_bvect_spher()),
104 v2(mpi),
105 flat(mpi.flat_met_spher()),
106 tgamma(flat),
107 aa(mpi, CON, mpi.get_bvect_spher()),
108 taa(mpi, COV, mpi.get_bvect_spher()),
109 aa_quad(mpi),
110 hh(mpi, mpi.get_bvect_spher(), flat)
111{
112 assert (spectral_filter>=0) ;
113 assert (spectral_filter<1000) ;
114
115 // Initialization to a static state
116 omega = 0 ;
117 v2 = 0 ;
118
119 // All the matter quantities are initialized to zero
120 j_euler.set_etat_zero() ;
121
122 // Initialization to a flat case
123 psi4 = 1 ;
124 psi2 = 1 ;
125 qqq = 1 ;
126 ln_psi = 0 ;
127 aa.set_etat_zero() ;
128 taa.set_etat_zero() ;
129 aa_quad = 0 ;
130 hh.set_etat_zero() ;
131
132 // Pointers of derived quantities initialized to zero :
133 set_der_0x0() ;
134
135}
136
137
138// Copy constructor
139//-----------------
141 : Star(star),
143 psi4(star.psi4),
144 psi2(star.psi2),
145 qqq(star.qqq),
146 ln_psi(star.ln_psi),
147 j_euler(star.j_euler),
148 v2(star.v2),
149 flat(star.flat),
150 tgamma(star.tgamma),
151 aa(star.aa),
152 taa(star.taa),
153 aa_quad(star.aa_quad),
154 hh(star.hh)
155{
156
157 omega = star.omega ;
158
159 // Pointers of derived quantities initialized to zero :
160 set_der_0x0() ;
161
162}
163
164
165//Constructor from a file
166//------------------------
167Star_rot_Dirac::Star_rot_Dirac(Map& mpi, const Eos& eos_i, FILE* fich)
168 : Star(mpi, eos_i, fich),
169 psi4(mpi),
170 psi2(mpi),
171 qqq(mpi, *(mpi.get_mg()), fich),
172 ln_psi(mpi),
173 j_euler(mpi, CON, mpi.get_bvect_spher()),
174 v2(mpi),
175 flat(mpi.flat_met_spher()),
176 tgamma(flat),
177 aa(mpi, CON, mpi.get_bvect_spher()),
178 taa(mpi, COV, mpi.get_bvect_spher()),
179 aa_quad(mpi),
180 hh(mpi, mpi.get_bvect_spher(), flat, fich)
181{
182
183 // Pointers of derived quantities initialized to zero
184 //----------------------------------------------------
185 set_der_0x0() ;
186
187 fread_be(&spectral_filter, sizeof(int), 1, fich) ;
188
189 // Metric fields are read in the file:
190 fread_be(&omega, sizeof(double), 1, fich) ;
191 Vector shift_tmp(mpi, mpi.get_bvect_spher(), fich) ;
192 beta = shift_tmp ;
193
194 update_metric() ;
195
197
198 hydro_euler() ;
199
200
201
202
203}
204
205
206 //------------//
207 // Destructor //
208 //------------//
209
215
216
217 //----------------------------------//
218 // Management of derived quantities //
219 //----------------------------------//
220
222
223 if (p_angu_mom != 0x0) delete p_angu_mom ;
224 if (p_grv2 != 0x0) delete p_grv2 ;
225 if (p_grv3 != 0x0) delete p_grv3 ;
226 if (p_tsw != 0x0) delete p_tsw ;
227 if (p_r_circ != 0x0) delete p_r_circ ;
228 if (p_rp_circ != 0x0) delete p_rp_circ ;
229
230 set_der_0x0() ;
231
233
234}
235
236
238
239 p_angu_mom = 0x0 ;
240 p_grv2 = 0x0 ;
241 p_grv3 = 0x0 ;
242 p_tsw = 0x0 ;
243 p_r_circ = 0x0 ;
244 p_rp_circ = 0x0 ;
245
246}
247
248
250
251 j_euler.set_etat_nondef() ;
252 v2.set_etat_nondef() ;
253
254 del_deriv() ;
255
257
258}
259
260
261
262 //---------------//
263 // Assignment //
264 //---------------//
265
266// Assignment to another Star_rot_Dirac
267// ------------------------------------
268
270
271 // Assignment of quantities common to all the derived classes of Star
272 Star::operator=(star) ;
273
274 // Assignment of proper quantities of class Star_rot_Dirac
276 omega = star.omega ;
277 psi4 = star.psi4 ;
278 psi2 = star.psi2 ;
279 qqq = star.qqq ;
280 ln_psi = star.ln_psi ;
281 j_euler = star.j_euler ;
282 v2 = star.v2 ;
283 tgamma = star.tgamma ;
284 aa = star.aa ;
285 aa_quad = star.aa_quad ;
286 hh = star.hh ;
287
288 assert(&flat == &star.flat) ;
289
290 del_deriv() ; // Deletes all derived quantities
291
292}
293
294
295 //-----------//
296 // Outputs //
297 //-----------//
298
299// Save in a file
300// --------------
301
302void Star_rot_Dirac::sauve(FILE* fich) const {
303
304 Star::sauve(fich) ;
305
306 qqq.sauve(fich) ;
307 hh.sauve(fich) ;
308 fwrite_be(&spectral_filter, sizeof(int), 1, fich) ;
309 fwrite_be(&omega, sizeof(double), 1, fich) ;
310 beta.sauve(fich) ;
311
312}
313
314
315// Printing
316// ---------
317
318ostream& Star_rot_Dirac::operator>>(ostream& ost) const {
319
320 using namespace Unites ;
321
322 Star::operator>>(ost) ;
323
324 ost << "Rotating star in Dirac gauge" << endl ;
325
326 // Only uniformly rotating star for the moment....
327 ost << endl ;
328 ost << "Uniformly rotating star" << endl ;
329 ost << "-----------------------" << endl ;
330 if (spectral_filter > 0)
331 ost << "hydro sources of equations are filtered\n"
332 << "with " << spectral_filter << "-order exponential filter" << endl ;
333
334 double freq = omega/ (2.*M_PI) ;
335 ost << "Omega : " << omega * f_unit
336 << " rad/s f : " << freq * f_unit << " Hz" << endl ;
337 ost << "Rotation period : " << 1000. / (freq * f_unit) << " ms"
338 << endl ;
339
340 ost << "Error on the virial identity GRV2 : " << endl ;
341 ost << "GRV2 = " << grv2() << endl ;
342 ost << "Error on the virial identity GRV3 : " << endl ;
343 ost << "GRV3 = " << grv3() << endl ;
344
345 ost << "Angular momentum J : "
346 << angu_mom()/( qpig / (4*M_PI) *msol*msol) << " G M_sol^2 / c"
347 << endl ;
348 ost << "c J / (G M^2) : "
349 << angu_mom()/( qpig / (4*M_PI) * pow(mass_g(), 2.) ) << endl ;
350
351 if (omega != 0.) {
352 double mom_iner = angu_mom() / omega ;
353 double mom_iner_38si = mom_iner * rho_unit * (pow(r_unit, double(5.))
354 / double(1.e38) ) ;
355 ost << "Moment of inertia: " << mom_iner_38si << " 10^38 kg m^2"
356 << endl ;
357 }
358
359 ost << "Ratio T/W : " << tsw() << endl ;
360 ost << "Circumferential equatorial radius R_circ : "
361 << r_circ()/km << " km" << endl ;
362 if (mp.get_mg()->get_np(0) == 1)
363 ost << "Circumferential polar radius Rp_circ : "
364 << rp_circ()/km << " km" << endl ;
365 ost << "Coordinate equatorial radius r_eq : " << ray_eq()/km << " km"
366 << endl ;
367 ost << "Flattening r_pole/r_eq : " << aplat() << endl ;
368 if (mp.get_mg()->get_np(0) == 1)
369 ost << "Ellipticity sqrt(1-(Rp_circ/R_circ)^2) : " << ellipt() << endl ;
370
371 double compact = qpig/(4.*M_PI) * mass_g() / r_circ() ;
372 ost << "Compaction parameter M_g / R_circ : " << compact << endl ;
373
374
375 // More to come here.....
376
377 return ost ;
378
379}
380}
Equation of state base class.
Definition eos.h:206
virtual double mass_g() const
Gravitational mass.
virtual double ellipt() const
Ellipticity e.
virtual double grv3() const
Error on the virial identity GRV3.
Star_rot_Dirac(Map &mp_i, int nzet_i, const Eos &eos_i, int filter=0)
Standard constructor.
Sym_tensor_trans hh
is defined by .
virtual double angu_mom() const
Angular momentum.
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
virtual void del_deriv() const
Deletes all the derived quantities.
double * p_grv3
Error on the virial identity GRV3.
virtual double r_circ() const
Circumferential equatorial radius.
int spectral_filter
Spectral exponential filtering order.
double omega
Rotation angular velocity ([f_unit] ).
double * p_tsw
Ratio T/W.
double * p_r_circ
Circumferential equatorial radius.
virtual double tsw() const
Ratio T/W.
Vector j_euler
Momentum density 3-vector with respect to the Eulerian observer.
const Metric_flat & flat
flat metric (spherical components)
virtual void del_hydro_euler()
Sets to ETATNONDEF (undefined state) the hydrodynamical quantities relative to the Eulerian observer.
virtual void sauve(FILE *) const
Save in a file.
void set_der_0x0() const
Sets to 0x0 all the pointers on derived quantities.
virtual double rp_circ() const
Circumferential polar radius.
void update_metric()
Computes metric quantities from known potentials.
Scalar psi4
Conformal factor .
virtual void hydro_euler()
Computes the hydrodynamical quantities relative to the Eulerian observer from those in the fluid fram...
double * p_grv2
Error on the virial identity GRV2.
virtual ~Star_rot_Dirac()
Destructor.
double * p_angu_mom
Angular momentum.
double * p_rp_circ
Circumferential polar radius.
virtual double aplat() const
Flattening r_pole/r_eq.
void operator=(const Star_rot_Dirac &)
Assignment to another Star_rot_Dirac.
virtual double grv2() const
Error on the virial identity GRV2.
Star(Map &mp_i, int nzet_i, const Eos &eos_i)
Standard constructor.
Definition star.C:127
virtual void del_hydro_euler()
Sets to ETATNONDEF (undefined state) the hydrodynamical quantities relative to the Eulerian observer.
Definition star.C:333
void equation_of_state()
Computes the proper baryon and energy density, as well as pressure from the enthalpy.
Definition star.C:465
virtual void del_deriv() const
Deletes all the derived quantities.
Definition star.C:301
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition star.C:420
double ray_eq() const
Coordinate radius at , [r_unit].
virtual void sauve(FILE *) const
Save in a file.
Definition star.C:400
Map & mp
Mapping associated with the star.
Definition star.h:180
void operator=(const Star &)
Assignment to another Star.
Definition star.C:354
Vector beta
Shift vector.
Definition star.h:228
Tensor field of valence 1.
Definition vector.h:188
Cmp pow(const Cmp &, int)
Power .
Definition cmp_math.C:351
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
Definition fread_be.C:72
int fwrite_be(const int *aa, int size, int nb, FILE *fich)
Writes integer(s) into a binary file according to the big endian convention.
Definition fwrite_be.C:73
Lorene prototypes.
Definition app_hor.h:67
const Base_vect_spher & get_bvect_spher() const
Returns the orthonormal vectorial basis associated with the coordinates of the mapping.
Definition map.h:795
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition map.h:777
Map(const Mg3d &)
Constructor from a multi-domain 3D grid.
Definition map.C:142
const Metric_flat & flat_met_spher() const
Returns the flat metric associated with the spherical coordinates and with components expressed in th...
Definition map.C:324
Standard units of space, time and mass.