LORENE
hot_star_rot_cfc.C
1 /*
2  * Methods of class Hot_star_rot_CFC
3  *
4  * (see file star_rot_dirac.h for documentation).
5  *
6  */
7 
8 /*
9  * Copyright (c) 2024 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 // Lorene headers
32 #include "hot_star_rot_cfc.h"
33 #include "unites.h"
34 #include "utilitaires.h"
35 
36 
37  //--------------//
38  // Constructors //
39  //--------------//
40 
41 // Standard constructor
42 //-------------------------
43 namespace Lorene {
44  Hot_star_rot_CFC::Hot_star_rot_CFC(Map& mpi, int nzet_i, const Hot_eos& heos_i, int relat_i,
45  int e_type_i, double const_value_i, int filter)
46  : Hot_star(mpi, nzet_i, heos_i),
47  relat_type(relat_i),
48  e_type(e_type_i),
49  const_value(const_value_i),
50  spectral_filter(filter),
51  psi(mpi),
52  j_euler(mpi, CON, mpi.get_bvect_spher()),
53  v2(mpi),
54  psi4(mpi),
55  psi2(mpi),
56  flat(mpi.flat_met_spher()),
57  hatA(mpi, CON, mpi.get_bvect_spher()),
58  hatA_quad(mpi)
59 {
60  assert (relat_type == 3) ;
61  assert ((spectral_filter>=0) && (spectral_filter<100)) ;
62 
63  switch (e_type) {
64  case 0 :
65  break ;
66  case 1 :
67  cerr << "Hot_rns: the constant temperature profile"
68  << "is not implemented yet!" << endl ;
69  abort() ;
70  break ;
71  default:
72  cerr << "Hot_rns: the entropy type = " << e_type
73  << "is not known!" << endl ;
74  abort() ;
75  break ;
76  }
77 
78  // Initialization to a static state
79  omega = 0 ;
80  v2 = 0 ;
81 
82  // All the matter quantities are initialized to zero
84 
85  // Initialization to a flat case
86  psi = 1 ;
88  psi4 = 1 ;
89  psi2 = 1 ;
91  hatA_quad = 0 ;
92 
93  // Pointers of derived quantities initialized to zero :
94  set_der_0x0() ;
95 
96 }
97 
98 
99 // Copy constructor
100 //-----------------
102  : Hot_star(star),
103  relat_type(star.relat_type),
104  e_type(star.e_type),
105  const_value(star.const_value),
106  spectral_filter(star.spectral_filter),
107  psi(star.psi),
108  j_euler(star.j_euler),
109  v2(star.v2),
110  psi4(star.psi4),
111  psi2(star.psi2),
112  flat(star.flat),
113  hatA(star.hatA),
114  hatA_quad(star.hatA_quad)
115 {
116 
117  switch (e_type) {
118  case 0 :
119  break ;
120  case 1 :
121  cerr << "Hot_rns: the constant temperature profile"
122  << "is not implemented yet!" << endl ;
123  abort() ;
124  break ;
125  default:
126  cerr << "Hot_rns: the entropy type = " << e_type
127  << "is not known!" << endl ;
128  abort() ;
129  break ;
130  }
131 
132  omega = star.omega ;
133 
134  // Pointers of derived quantities initialized to zero :
135  set_der_0x0() ;
136 
137 }
138 
139 
140 //Constructor from a file
141 //------------------------
142 Hot_star_rot_CFC::Hot_star_rot_CFC(Map& mpi, const Hot_eos& heos_i, FILE* fich)
143  : Hot_star(mpi, heos_i, fich),
144  psi(mpi, *(mpi.get_mg()), fich),
145  j_euler(mpi, CON, mpi.get_bvect_spher()),
146  v2(mpi),
147  psi4(mpi),
148  psi2(mpi),
149  flat(mpi.flat_met_spher()),
150  hatA(mpi, CON, mpi.get_bvect_spher()),
151  hatA_quad(mpi)
152 {
153 
154  // Pointers of derived quantities initialized to zero
155  //----------------------------------------------------
156  set_der_0x0() ;
157 
158  fread_be(&relat_type, sizeof(int), 1, fich) ;
159  fread_be(&e_type, sizeof(int), 1, fich) ;
160  fread_be(&const_value, sizeof(double), 1, fich) ;
161  fread_be(&spectral_filter, sizeof(int), 1, fich) ;
162 
163  // Metric fields are read in the file:
164  fread_be(&omega, sizeof(double), 1, fich) ;
165  Vector shift_tmp(mpi, mpi.get_bvect_spher(), fich) ;
166  beta = shift_tmp ;
167 
168  update_metric() ;
169 
170  equation_of_state() ; // TODO: add the Param
171 
172  hydro_euler() ;
173 
174  // Computation of \hat{A}^{ij} and its norm
175  //------------------------------------------
176  Vector sou_Xi = 2*Unites::qpig*psi4*psi4*psi2*j_euler ;
177  double lambda = 1./3. ;
178  Vector Xi_new = sou_Xi.poisson(lambda) ;
179 
180  hatA = Xi_new.ope_killing_conf(flat) ;
181  hatA_quad = contract(hatA, 0, 1, hatA.up_down(flat), 0, 1) ;
182 
183 }
184 
185 
186  //------------//
187  // Destructor //
188  //------------//
189 
191 
193 
194 }
195 
196 
197  //----------------------------------//
198  // Management of derived quantities //
199  //----------------------------------//
200 
202 
203  if (p_angu_mom != 0x0) delete p_angu_mom ;
204  if (p_grv2 != 0x0) delete p_grv2 ;
205  if (p_grv3 != 0x0) delete p_grv3 ;
206  if (p_tsw != 0x0) delete p_tsw ;
207  if (p_r_circ != 0x0) delete p_r_circ ;
208  if (p_rp_circ != 0x0) delete p_rp_circ ;
209 
210  set_der_0x0() ;
211 
213 
214 }
215 
216 
218 
219  p_angu_mom = 0x0 ;
220  p_grv2 = 0x0 ;
221  p_grv3 = 0x0 ;
222  p_tsw = 0x0 ;
223  p_r_circ = 0x0 ;
224  p_rp_circ = 0x0 ;
225 
226 }
227 
228 
230 
232  v2.set_etat_nondef() ;
233 
234  del_deriv() ;
235 
237 
238 }
239 
240 
241 
242  //---------------//
243  // Assignment //
244  //---------------//
245 
246 // Assignment to another Hot_star_rot_CFC
247 // ------------------------------------
248 
250 
251  // Assignment of quantities common to all the derived classes of Hot_star
252  Hot_star::operator=(star) ;
253 
254  // Assignment of proper quantities of class Hot_star_rot_CFC
255  relat_type = star.relat_type ;
256  e_type = star.e_type ;
257  const_value = star.const_value ;
259  psi = star.psi ;
260  omega = star.omega ;
261  j_euler = star.j_euler ;
262  v2 = star.v2 ;
263  psi4 = star.psi4 ;
264  psi2 = star.psi2 ;
265  hatA = star.hatA ;
266  hatA_quad = star.hatA_quad ;
267 
268  assert(&flat == &star.flat) ;
269 
270  switch (e_type) {
271  case 0 :
272  break ;
273  case 1 :
274  cerr << "Hot_rns: the constant temperature profile"
275  << "is not implemented yet!" << endl ;
276  abort() ;
277  break ;
278  default:
279  cerr << "Hot_rns: the entropy type = " << e_type
280  << "is not known!" << endl ;
281  abort() ;
282  break ;
283  }
284 
285  del_deriv() ; // Deletes all derived quantities
286 
287 }
288 
289 // Update of the entropy from input
290 // ------------------------------------------------------------
292 
293  switch (e_type) {
294  case 0 : {
295  entropy = const_value ;
296  break ;
297  }
298  case 1 :
299  cerr << "Hot_rns: the constant temperature profile"
300  << "is not implemented yet!" << endl ;
301  abort() ;
302  break ;
303  default:
304  cerr << "Hot_rns: the entropy type = " << e_type
305  << "is not known!" << endl ;
306  abort() ;
307  break ;
308  }
309  entropy.annule(nzet, mp.get_mg()->get_nzone()-1) ; // TODO: is this necessary?
311 }
312 
313 
314 
315  //-----------//
316  // Outputs //
317  //-----------//
318 
319 // Save in a file
320 // --------------
321 
322 void Hot_star_rot_CFC::sauve(FILE* fich) const {
323 
324  Hot_star::sauve(fich) ;
325 
326  psi.sauve(fich) ;
327 
328  fwrite_be(&relat_type, sizeof(int), 1, fich) ;
329  fwrite_be(&e_type, sizeof(int), 1, fich) ;
330  fwrite_be(&const_value, sizeof(double), 1, fich) ;
331  fwrite_be(&spectral_filter, sizeof(int), 1, fich) ;
332  fwrite_be(&omega, sizeof(double), 1, fich) ;
333  beta.sauve(fich) ;
334 
335 }
336 
337 
338 // Printing
339 // ---------
340 
341 ostream& Hot_star_rot_CFC::operator>>(ostream& ost) const {
342 
343  using namespace Unites ;
344 
345  Hot_star::operator>>(ost) ;
346 
347  ost << "Rotating star " ;
348  switch (relat_type) {
349  case 0 : {
350  ost << "in Newtonian theory" << endl ;
351  break;
352  }
353  case 1 : {
354  ost << "in Dirac gauge" << endl ;
355  break ;
356  }
357  case 2 : {
358  ost << "in Conformal Flatness Condition (CFC)" << endl ;
359  break ;
360  }
361  case 3: {
362  ost << "in Conformal Flatness Condition (CFC), with hat{A}^{ij}_{TT} = 0\n"
363  << "(see Cordero-Carrion et al. (2009) for details" << endl ;
364  break ;
365  }
366  default: {
367  cerr << "Hot_star_rot_CFC::operator>> : unknown value for 'relat_type'" << endl ;
368  cerr << "relat_type = " << relat_type << endl ;
369  abort() ;
370  }
371  }
372 
373  // Only uniformly rotating star for the moment....
374  ost << endl ;
375  ost << "Uniformly rotating star" << endl ;
376  ost << "-----------------------" << endl ;
377  if (spectral_filter > 0)
378  ost << "hydro sources of equations are filtered\n"
379  << "with " << spectral_filter << "-order exponential filter" << endl ;
380 
381  double freq = omega/ (2.*M_PI) ;
382  ost << "Omega : " << omega * f_unit
383  << " rad/s f : " << freq * f_unit << " Hz" << endl ;
384  ost << "Rotation period : " << 1000. / (freq * f_unit) << " ms"
385  << endl ;
386 
387  ost << "Error on the virial identity GRV2 : " << endl ;
388  ost << "GRV2 = " << grv2() << endl ;
389  ost << "Error on the virial identity GRV3 : " << endl ;
390  ost << "GRV3 = " << grv3() << endl ;
391 
392  ost << "Angular momentum J : "
393  << angu_mom()/( qpig / (4*M_PI) *msol*msol) << " G M_sol^2 / c"
394  << endl ;
395  ost << "c J / (G M^2) : "
396  << angu_mom()/( qpig / (4*M_PI) * pow(mass_g(), 2.) ) << endl ;
397 
398  if (omega != 0.) {
399  double mom_iner = angu_mom() / omega ;
400  double mom_iner_38si = mom_iner * rho_unit * (pow(r_unit, double(5.))
401  / double(1.e38) ) ;
402  ost << "Moment of inertia: " << mom_iner_38si << " 10^38 kg m^2"
403  << endl ;
404  }
405 
406  ost << "Ratio T/W : " << tsw() << endl ;
407  ost << "Circumferential equatorial radius R_circ : "
408  << r_circ()/km << " km" << endl ;
409  if (mp.get_mg()->get_np(0) == 1)
410  ost << "Circumferential polar radius Rp_circ : "
411  << rp_circ()/km << " km" << endl ;
412  ost << "Coordinate equatorial radius r_eq : " << ray_eq()/km << " km"
413  << endl ;
414  ost << "Flattening r_pole/r_eq : " << aplat() << endl ;
415  if (mp.get_mg()->get_np(0) == 1)
416  ost << "Ellipticity sqrt(1-(Rp_circ/R_circ)^2) : " << ellipt() << endl ;
417 
418  double compact = qpig/(4.*M_PI) * mass_g() / r_circ() ;
419  ost << "Compaction parameter M_g / R_circ : " << compact << endl ;
420 
421 
422  // More to come here.....
423 
424  return ost ;
425 
426 }
427 }
int relat_type
Relativistic flag.
const Metric_flat & flat
flat metric (spherical components)
virtual void del_deriv() const
Deletes all the derived quantities.
Scalar psi
Conformal factor .
double * p_r_circ
Circumferential equatorial radius.
virtual void del_hydro_euler()
Sets to ETATNONDEF (undefined state) the hydrodynamical quantities relative to the Eulerian observer...
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition: grilles.h:481
virtual void annule(int l_min, int l_max)
Sets the Scalar to zero in several domains.
Definition: scalar.C:397
const Base_vect_spher & get_bvect_spher() const
Returns the orthonormal vectorial basis associated with the coordinates of the mapping.
Definition: map.h:809
Lorene prototypes.
Definition: app_hor.h:67
Standard units of space, time and mass.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition: map.h:791
Base class for hot stars.
Definition: hot_star.h:76
virtual double aplat() const
Flattening r_pole/r_eq.
virtual double grv2() const
Error on the virial identity GRV2.
virtual void set_etat_nondef()
Sets the logical state of all components to ETATNONDEF (undefined state).
Definition: tensor.C:499
Base class for coordinate mappings.
Definition: map.h:696
void equation_of_state()
Computes the proper baryon and energy density, as well as pressure from the enthalpy.
Definition: hot_star.C:489
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
Scalar entropy
Entropy per baryon field (in $k_B$)
Definition: hot_star.h:99
virtual void sauve(FILE *) const
Save in a binary file.
Definition: tensor.C:916
virtual ~Hot_star_rot_CFC()
Destructor.
int spectral_filter
Spectral exponential filtering order.
virtual void set_etat_nondef()
Sets the logical state to ETATNONDEF (undefined).
Definition: scalar.C:350
virtual double rp_circ() const
Circumferential polar radius.
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Tensor field of valence 1.
Definition: vector.h:188
Sym_tensor ope_killing_conf(const Metric &gam) const
Computes the conformal Killing operator associated with a given metric.
Definition: vector.C:468
int e_type
Integer defining the type of entropy profile.
double ray_eq() const
Coordinate radius at , [r_unit].
virtual void sauve(FILE *) const
Save in a file.
Definition: scalar.C:692
int nzet
Number of domains of *mp occupied by the star.
Definition: hot_star.h:84
virtual void sauve(FILE *) const
Save in a file.
Definition: hot_star.C:415
double * p_rp_circ
Circumferential polar radius.
virtual void hydro_euler()
Computes the hydrodynamical quantities relative to the Eulerian observer from those in the fluid fram...
Hot_star_rot_CFC(Map &mp_i, int nzet_i, const Hot_eos &heos_i, int relat_i, int e_type, double const_value_i, int filter=0)
Standard constructor.
double * p_tsw
Ratio T/W.
void set_der_0x0() const
Sets to 0x0 all the pointers on derived quantities.
double omega
Rotation angular velocity ([f_unit] )
double * p_angu_mom
Angular momentum.
void operator=(const Hot_star_rot_CFC &)
Assignment to another Hot_star_rot_CFC.
Vector poisson(double lambda, int method=6) const
Solves the vector Poisson equation with *this as a source.
virtual double r_circ() const
Circumferential equatorial radius.
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:467
virtual double mass_g() const
Gravitational mass.
Map & mp
Mapping associated with the star.
Definition: hot_star.h:81
double const_value
Constant value of entropy or temperature.
virtual double tsw() const
Ratio T/W.
Scalar psi4
Conformal factor .
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
Cmp pow(const Cmp &, int)
Power .
Definition: cmp_math.C:351
virtual double angu_mom() const
Angular momentum.
Tenseur contract(const Tenseur &, int id1, int id2)
Self contraction of two indices of a Tenseur .
virtual double grv3() const
Error on the virial identity GRV3.
void operator=(const Hot_star &)
Assignment to another Hot_star.
Definition: hot_star.C:367
virtual void del_hydro_euler()
Sets to ETATNONDEF (undefined state) the hydrodynamical quantities relative to the Eulerian observer...
Definition: hot_star.C:346
Class for relativistic rotating stars in Conformal Flatness Condition and maximal slicing...
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
Base class for 2-parameters equations of state (abstract class).
Definition: hoteos.h:85
double * p_grv2
Error on the virial identity GRV2.
virtual void sauve(FILE *) const
Save in a file.
void update_metric()
Computes metric quantities from known potentials.
virtual void set_etat_zero()
Sets the logical state of all components to ETATZERO (zero state).
Definition: tensor.C:507
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition: hot_star.C:436
void update_entropy()
Updates the part of the entropy from entropy_param.
Vector j_euler
Momentum density 3-vector with respect to the Eulerian observer.
Vector beta
Shift vector.
Definition: hot_star.h:133
virtual void del_deriv() const
Deletes all the derived quantities.
Definition: hot_star.C:314
virtual double ellipt() const
Ellipticity e.
double * p_grv3
Error on the virial identity GRV3.