LORENE
et_equil_spher_regu.C
1/*
2 * Method of class Etoile to compute a static spherical configuration
3 * by regularizing source.
4 *
5 * (see file etoile.h for documentation).
6 *
7 */
8
9/*
10 * Copyright (c) 2000-2001 Eric Gourgoulhon
11 * Copyright (c) 2000-2001 Keisuke Taniguchi
12 *
13 * This file is part of LORENE.
14 *
15 * LORENE is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * LORENE is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with LORENE; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 */
30
31
32
33
34/*
35 * $Id: et_equil_spher_regu.C,v 1.5 2016/12/05 16:17:53 j_novak Exp $
36 * $Log: et_equil_spher_regu.C,v $
37 * Revision 1.5 2016/12/05 16:17:53 j_novak
38 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
39 *
40 * Revision 1.4 2014/10/13 08:52:56 j_novak
41 * Lorene classes and functions now belong to the namespace Lorene.
42 *
43 * Revision 1.3 2014/10/06 15:13:08 j_novak
44 * Modified #include directives to use c++ syntax.
45 *
46 * Revision 1.2 2004/03/25 10:29:04 j_novak
47 * All LORENE's units are now defined in the namespace Unites (in file unites.h).
48 *
49 * Revision 1.1.1.1 2001/11/20 15:19:28 e_gourgoulhon
50 * LORENE
51 *
52 * Revision 2.14 2001/03/06 16:34:04 keisuke
53 * Change the regularization degree k_div=1 to the arbitrary one.
54 *
55 * Revision 2.13 2001/02/07 09:46:11 eric
56 * unsgam1 est desormais donne par Eos::der_nbar_ent (cas newtonien)
57 * ou Eos::der_ener_ent (cas relativiste).
58 *
59 * Revision 2.12 2000/09/26 15:42:35 keisuke
60 * Correction erreur: la triade de duu_div doit etre celle de mp et non celle
61 * de l'objet temporaire mpaff.
62 *
63 * Revision 2.11 2000/09/26 06:56:04 keisuke
64 * Suppress "int" from the declaration of k_div.
65 *
66 * Revision 2.10 2000/09/22 15:53:36 keisuke
67 * d_logn_auto_div est desormais un membre de la classe Etoile.
68 *
69 * Revision 2.9 2000/09/08 12:23:17 keisuke
70 * Correct a typological error in the equation.
71 *
72 * Revision 2.8 2000/09/07 15:37:23 keisuke
73 * Add a new argument in poisson_regular
74 * and suppress logn_auto_total.
75 *
76 * Revision 2.7 2000/09/06 12:47:35 keisuke
77 * Suppress #include "graphique.h".
78 *
79 * Revision 2.6 2000/09/06 12:39:59 keisuke
80 * Save the map in the every iterative step after operating "homothetie".
81 *
82 * Revision 2.5 2000/09/04 16:15:05 keisuke
83 * Change the argument of Map_af::poisson_regular.
84 *
85 * Revision 2.4 2000/08/31 16:05:26 keisuke
86 * Modify the arguments of Map_af::poisson_regular.
87 *
88 * Revision 2.3 2000/08/29 11:38:25 eric
89 * Ajout des membres k_div et logn_auto_div a la classe Etoile.
90 *
91 * Revision 2.2 2000/08/28 16:10:39 keisuke
92 * Add "nzet" in the argumant of poisson_regular.
93 *
94 * Revision 2.1 2000/08/25 14:58:15 keisuke
95 * Modif (Virial theorem).
96 *
97 * Revision 2.0 2000/08/25 09:01:33 keisuke
98 * *** empty log message ***
99 *
100 *
101 * $Header: /cvsroot/Lorene/C++/Source/Etoile/et_equil_spher_regu.C,v 1.5 2016/12/05 16:17:53 j_novak Exp $
102 *
103 */
104
105// Headers C
106#include <cmath>
107
108// Headers Lorene
109#include "etoile.h"
110#include "eos.h"
111#include "param.h"
112#include "unites.h"
113
114//********************************************************************
115
116namespace Lorene {
117
118void Etoile::equil_spher_regular(double ent_c, double precis){
119
120 // Fundamental constants and units
121 // -------------------------------
122 using namespace Unites ;
123
124 // Initializations
125 // ---------------
126
127 // k_div = 1 ; // Regularization index
128
129 cout << "Input the regularization degree (k_div) : " ;
130 cin >> k_div ; // Regularization index
131
132 const Mg3d* mg = mp.get_mg() ;
133 int nz = mg->get_nzone() ; // total number of domains
134
135 // Index of the point at phi=0, theta=pi/2 at the surface of the star:
136 int l_b = nzet - 1 ;
137 int i_b = mg->get_nr(l_b) - 1 ;
138 int j_b = mg->get_nt(l_b) - 1 ;
139 int k_b = 0 ;
140
141 // Value of the enthalpy defining the surface of the star
142 double ent_b = 0 ;
143
144 // Initialization of the enthalpy field to the constant value ent_c :
145
146 ent = ent_c ;
147 ent.annule(nzet, nz-1) ;
148
149 // Corresponding profiles of baryon density, energy density and pressure
150
152
153 // Initial metric
154 a_car = 1 ; // this value will remain unchanged in the Newtonian case
155 beta_auto = 0 ; // this value will remain unchanged in the Newtonian case
156
157 // Auxiliary quantities
158 // --------------------
159
160 // Affine mapping for solving the Poisson equations
161 Map_af mpaff(mp) ;
162
163 Param par_nul ; // Param (null) for Map_af::poisson.
164
165 Tenseur ent_jm1(mp) ; // Enthalpy at previous step
166 ent_jm1 = 0 ;
167
168 Tenseur source(mp) ;
169 Tenseur logn(mp) ;
170 Tenseur logn_quad(mp) ;
171 logn = 0 ;
172 logn_quad = 0 ;
173
174 Tenseur dlogn_auto_regu(mp, 1, COV, mp.get_bvect_spher()) ;
175
176 Cmp source_regu(mp) ;
177 Cmp source_div(mp) ;
178
179 Cmp dlogn(mp) ;
180 dlogn = 0 ;
181 Cmp dbeta(mp) ;
182
183 Tenseur dlogn_auto(mp, 1, COV, mp.get_bvect_spher()) ;
184 Tenseur dlogn_quad(mp) ;
185 dlogn_quad = 0 ;
186
187 double diff_ent = 1 ;
188 int mermax = 200 ; // Max number of iterations
189
190 double alpha_r = 1 ;
191
192 //=========================================================================
193 // Start of iteration
194 //=========================================================================
195
196 for(int mer=0 ; (diff_ent > precis) && (mer<mermax) ; mer++ ) {
197
198 cout << "-----------------------------------------------" << endl ;
199 cout << "step: " << mer << endl ;
200 cout << "alpha_r: " << alpha_r << endl ;
201 cout << "diff_ent = " << diff_ent << endl ;
202
203 //-----------------------------------------------------
204 // Resolution of Poisson equation for ln(N)
205 //-----------------------------------------------------
206
207 // Matter part of ln(N)
208 // --------------------
209
210 double unsgam1 ; // effective power of H in the source
211 // close to the surface
212
213 if (relativistic) {
214
215 source = a_car * (ener + 3*press) ;
216
217 // 1/(gam-1) = dln(e)/dln(H) close to the surface :
218 unsgam1 = eos.der_ener_ent_p(ent_b + 1e-10*(ent_c-ent_b)) ;
219 }
220 else {
221
222 source = nbar ;
223
224 // 1/(gam-1) = dln(n)/dln(H) close to the surface :
225 unsgam1 = eos.der_nbar_ent_p(ent_b + 1e-10*(ent_c-ent_b)) ;
226 }
227
228 (source.set()).set_dzpuis(4) ;
229
230 source.set_std_base() ; // Sets the standard spectral bases.
231
232 logn_auto.set_etat_qcq() ;
233 logn_auto_regu.set_etat_qcq() ;
234 logn_auto_div.set_etat_qcq() ;
235
236 source_regu.std_base_scal() ;
237 source_div.std_base_scal() ;
238
239 mpaff.poisson_regular(source(), k_div, nzet, unsgam1, par_nul,
240 logn_auto.set(), logn_auto_regu.set(),
241 logn_auto_div.set(),
242 d_logn_auto_div, source_regu, source_div) ;
243
244 dlogn_auto_regu = logn_auto_regu.gradient_spher() ;
245
246 dlogn_auto = dlogn_auto_regu + d_logn_auto_div ;
247
248 // NB: at this stage logn_auto is in machine units, not in c^2
249
250 // Quadratic part of ln(N)
251 // -----------------------
252
253 if (relativistic) {
254
255 mpaff.dsdr(beta_auto(), dbeta) ;
256
257 source = - dlogn * dbeta ;
258
259 logn_quad.set_etat_qcq() ;
260
261 mpaff.poisson(source(), par_nul, logn_quad.set()) ;
262
263 dlogn_quad.set_etat_qcq() ;
264
265 mpaff.dsdr(logn_quad(), dlogn_quad.set()) ;
266
267 }
268
269 //-----------------------------------------------------
270 // Computation of the new radial scale
271 //-----------------------------------------------------
272
273 // alpha_r (r = alpha_r r') is determined so that the enthalpy
274 // takes the requested value ent_b at the stellar surface
275
276 double nu_mat0_b = logn_auto()(l_b, k_b, j_b, i_b) ;
277 double nu_mat0_c = logn_auto()(0, 0, 0, 0) ;
278
279 double nu_quad0_b = logn_quad()(l_b, k_b, j_b, i_b) ;
280 double nu_quad0_c = logn_quad()(0, 0, 0, 0) ;
281
282 double alpha_r2 = ( ent_c - ent_b - nu_quad0_b + nu_quad0_c )
283 / ( qpig*(nu_mat0_b - nu_mat0_c) ) ;
284
285 alpha_r = sqrt(alpha_r2) ;
286
287 // New radial scale
288 // -----------------
289 mpaff.homothetie( alpha_r ) ;
290
291 // The mapping is transfered to that of the star:
292 // ----------------------------------------------
293 mp = mpaff ;
294
295 d_logn_auto_div.set_triad( mp.get_bvect_spher() ) ; // Absolutely necessary !!!
296
297 //--------------------
298 // First integral
299 //--------------------
300
301 // Gravitation potential in units c^2 :
302 logn_auto = alpha_r2*qpig * logn_auto ;
303 logn = logn_auto + logn_quad ;
304
305 // Enthalpy in all space
306 double logn_c = logn()(0, 0, 0, 0) ;
307 ent = ent_c - logn() + logn_c ;
308
309 //---------------------
310 // Equation of state
311 //---------------------
312
314
315 // derivative of gravitation potential in units c^2 :
316 dlogn_auto = alpha_r*qpig * dlogn_auto ;
317 dlogn = dlogn_auto(0) + dlogn_quad() ;
318
319 if (relativistic) {
320
321 //----------------------------
322 // Equation for beta = ln(AN)
323 //----------------------------
324
325 mpaff.dsdr(beta_auto(), dbeta) ;
326
327 source = 3 * qpig * a_car * press ;
328
329 source = source()
330 - 0.5 * ( dlogn * dlogn + dbeta * dbeta ) ;
331
332 source.set_std_base() ; // Sets the standard spectral bases.
333
334 beta_auto.set_etat_qcq() ;
335
336 mpaff.poisson(source(), par_nul, beta_auto.set()) ;
337
338 // Metric coefficient A^2 update
339
340 a_car = exp(2*(beta_auto - logn)) ;
341
342 }
343
344 // Relative difference with enthalpy at the previous step
345 // ------------------------------------------------------
346
347 diff_ent = norme( diffrel(ent(), ent_jm1()) ) / nzet ;
348
349 // Next step
350 // ---------
351
352 ent_jm1 = ent ;
353
354
355 } // End of iteration loop
356
357 //=========================================================================
358 // End of iteration
359 //=========================================================================
360
361
362 // Sets value to all the Tenseur's of the star
363 // -------------------------------------------
364
365 // ... hydro
366 ent.annule(nzet, nz-1) ; // enthalpy set to zero at the exterior of
367 // the star
368 ener_euler = ener ;
369 s_euler = 3 * press ;
370 gam_euler = 1 ;
371 u_euler = 0 ;
372
373 // ... metric
374 nnn = exp( unsurc2 * logn ) ;
375 shift = 0 ;
376
377 // Info printing
378 // -------------
379
380 cout << endl
381 << "Characteristics of the star obtained by Etoile::equil_spher_regular : "
382 << endl
383 << "-----------------------------------------------------------------"
384 << endl ;
385
386 double ray = mp.val_r(l_b, 1., M_PI/2., 0) ;
387 cout << "Coordinate radius : " << ray / km << " km" << endl ;
388
389 double rcirc = ray * sqrt( a_car()(l_b, k_b, j_b, i_b) ) ;
390
391 double compact = qpig/(4.*M_PI) * mass_g() / rcirc ;
392
393 cout << "Circumferential radius R : " << rcirc/km << " km" << endl ;
394 cout << "Baryon mass : " << mass_b()/msol << " Mo" << endl ;
395 cout << "Gravitational mass M : " << mass_g()/msol << " Mo" << endl ;
396 cout << "Compacity parameter GM/(c^2 R) : " << compact << endl ;
397
398
399 //-----------------
400 // Virial theorem
401 //-----------------
402
403 //... Pressure term
404
405 source = qpig * a_car * sqrt(a_car) * s_euler ;
406 source.set_std_base() ;
407 double vir_mat = source().integrale() ;
408
409 //... Gravitational term
410
411 Cmp tmp = beta_auto().dsdr() - dlogn ;
412
413 source = - ( dlogn * dlogn - 0.5 * tmp * tmp ) * sqrt(a_car()) ;
414
415 source.set_std_base() ;
416 double vir_grav = source().integrale() ;
417
418 //... Relative error on the virial identity GRV3
419
420 double grv3 = ( vir_mat + vir_grav ) / vir_mat ;
421
422 cout << "Virial theorem GRV3 : " << endl ;
423 cout << " 3P term : " << vir_mat << endl ;
424 cout << " grav. term : " << vir_grav << endl ;
425 cout << " relative error : " << grv3 << endl ;
426
427
428}
429
430}
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition cmp.h:446
void std_base_scal()
Sets the spectral bases of the Valeur va to the standard ones for a scalar.
Definition cmp.C:647
Tenseur logn_auto_div
Divergent part (if k_div!=0 ) of the logarithm of the part of the lapse N generated principaly by t...
Definition etoile.h:500
int nzet
Number of domains of *mp occupied by the star.
Definition etoile.h:435
Tenseur logn_auto_regu
Regular part of the logarithm of the part of the lapse N generated principaly by the star.
Definition etoile.h:494
int k_div
Index of regularity of the gravitational potential logn_auto .
Definition etoile.h:452
Tenseur nnn
Total lapse function.
Definition etoile.h:512
Tenseur logn_auto
Total of the logarithm of the part of the lapse N generated principaly by the star.
Definition etoile.h:487
Tenseur nbar
Baryon density in the fluid frame.
Definition etoile.h:462
const Eos & eos
Equation of state of the stellar matter.
Definition etoile.h:454
virtual void equation_of_state()
Computes the proper baryon and energy density, as well as pressure from the enthalpy.
Definition etoile.C:569
Tenseur u_euler
Fluid 3-velocity with respect to the Eulerian observer.
Definition etoile.h:477
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
virtual double mass_b() const
Baryon mass.
Tenseur ener
Total energy density in the fluid frame.
Definition etoile.h:463
void equil_spher_regular(double ent_c, double precis=1.e-14)
Computes a spherical static configuration.
Tenseur d_logn_auto_div
Gradient of logn_auto_div (if k_div!=0 ).
Definition etoile.h:504
Tenseur press
Fluid pressure.
Definition etoile.h:464
virtual double mass_g() const
Gravitational mass.
bool relativistic
Indicator of relativity: true for a relativistic star, false for a Newtonian one.
Definition etoile.h:440
Tenseur ener_euler
Total energy density in the Eulerian frame.
Definition etoile.h:468
Tenseur shift
Total shift vector.
Definition etoile.h:515
Tenseur s_euler
Trace of the stress tensor in the Eulerian frame.
Definition etoile.h:471
Tenseur ent
Log-enthalpy (relativistic case) or specific enthalpy (Newtonian case).
Definition etoile.h:460
Tenseur beta_auto
Logarithm of the part of the product AN generated principaly by by the star.
Definition etoile.h:509
Tenseur a_car
Total conformal factor .
Definition etoile.h:518
double unsurc2
: unsurc2=1 for a relativistic star, 0 for a Newtonian one.
Definition etoile.h:445
Affine radial mapping.
Definition map.h:2042
virtual void poisson_regular(const Cmp &source, int k_div, int nzet, double unsgam1, Param &par, Cmp &uu, Cmp &uu_regu, Cmp &uu_div, Tenseur &duu_div, Cmp &source_regu, Cmp &source_div) const
Computes the solution of a scalar Poisson equation.
virtual void homothetie(double lambda)
Sets a new radial scale.
Definition map_af.C:664
virtual void poisson(const Cmp &source, Param &par, Cmp &uu) const
Computes the solution of a scalar Poisson equation.
virtual void dsdr(const Cmp &ci, Cmp &resu) const
Computes of a Cmp.
Multi-domain grid.
Definition grilles.h:279
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition grilles.h:474
int get_nzone() const
Returns the number of domains.
Definition grilles.h:465
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition grilles.h:469
Parameter storage.
Definition param.h:125
Tensor handling *** DEPRECATED : use class Tensor instead ***.
Definition tenseur.h:304
Cmp & set()
Read/write for a scalar (see also operator=(const Cmp&) ).
Definition tenseur.C:830
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition tenseur.C:642
void set_std_base()
Set the standard spectal basis of decomposition for each component.
Definition tenseur.C:1176
Cmp sqrt(const Cmp &)
Square root.
Definition cmp_math.C:223
Cmp exp(const Cmp &)
Exponential.
Definition cmp_math.C:273
Tbl diffrel(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (norme version).
Definition cmp_math.C:507
Tbl norme(const Cmp &)
Sums of the absolute values of all the values of the Cmp in each domain.
Definition cmp_math.C:484
Lorene prototypes.
Definition app_hor.h:67
Standard units of space, time and mass.