LORENE
strot_diff_cfc_equil.C
1 /*
2  * Function Star_rot_diff_CFC::equilibrium
3  *
4  * (see file star_rot_diff_cfc.h for documentation).
5  *
6  */
7 
8 /*
9  * Copyright (c) 2025 Santiago Jaraba
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 // C headers
29 #include <cmath>
30 
31 // Lorene headers
32 #include "star_rot_diff_cfc.h"
33 #include "param.h"
34 #include "graphique.h"
35 #include "utilitaires.h"
36 #include "unites.h"
37 
38 
39 namespace Lorene{
40 void Star_rot_diff_CFC::equilibrium(double ent_c, double omega_c0, double fact_omega,
41  int , const Tbl& ent_limit,
42  const Itbl& icontrol,
43  const Tbl& control, double mbar_wanted,
44  double aexp_mass, Tbl& diff, Param*){
45 
46  // Fundamental constants and units
47  // --------------------------------
48  using namespace Unites ;
49 
50  // For the display
51  // ---------------
52  char display_bold[]="x[1m" ; display_bold[0] = 27 ;
53  char display_normal[] = "x[0m" ; display_normal[0] = 27 ;
54 
55 
56  // Grid parameters
57  // ----------------
58 
59  const Mg3d* mg = mp.get_mg() ;
60  int nz = mg->get_nzone() ; // total number of domains
61  int nzm1 = nz - 1 ;
62 
63  // Index of the point at phi=0, theta=pi/2 at the surface of the star:
64  int type_t = mg->get_type_t() ;
65  assert( ( type_t == SYM) || (type_t == NONSYM) ) ;
66  int l_b = nzet - 1 ;
67  int i_b = mg->get_nr(l_b) - 1 ;
68  int j_b = (type_t == SYM ? mg->get_nt(l_b) - 1 : mg->get_nt(l_b)/2 ) ;
69  int k_b = 0 ;
70 
71  // Value of the enthalpy defining the surface of the star
72  double ent_b = ent_limit(nzet-1) ;
73 
74  // Parameters to control the iteration
75  // -----------------------------------
76 
77  int mer_max = icontrol(0) ;
78  int mer_rot = icontrol(1) ;
79  int mer_change_omega = icontrol(2) ;
80  int mer_fix_omega = icontrol(3) ;
81  int mer_mass = icontrol(4) ;
82  int mer_triax = icontrol(5) ;
83  int delta_mer_kep = icontrol(6) ;
84 
85  // Protections:
86  if (mer_change_omega < mer_rot) {
87  cout << "Star_rot_diff_CFC::equilibrium: mer_change_omega < mer_rot !" << endl ;
88  cout << " mer_change_omega = " << mer_change_omega << endl ;
89  cout << " mer_rot = " << mer_rot << endl ;
90  abort() ;
91  }
92  if (mer_fix_omega < mer_change_omega) {
93  cout << "Star_rot_diff_CFC::equilibrium: mer_fix_omega < mer_change_omega !"
94  << endl ;
95  cout << " mer_fix_omega = " << mer_fix_omega << endl ;
96  cout << " mer_change_omega = " << mer_change_omega << endl ;
97  abort() ;
98  }
99 
100  // In order to converge to a given baryon mass, shall the central
101  // enthalpy be varied or Omega ?
102  bool change_ent = true ;
103  if (mer_mass < 0) {
104  change_ent = false ;
105  mer_mass = abs(mer_mass) ;
106  }
107 
108  double precis = control(0) ;
109  double omega_ini = control(1) ;
110  double relax = control(2) ;
111  double relax_prev = double(1) - relax ;
112  double ampli_triax = control(3) ;
113 
114 
115  // Error indicators
116  // ----------------
117 
118  diff.annule_hard() ;
119  double& diff_ent = diff.set(0) ;
120  double& vit_triax = diff.set(7) ;
121 
122  double alpha_r = 1 ;
123 
124  // Initializations
125  // ---------------
126 
127  // Initial central angular velocity
128  double omega_c = 0 ;
129 
130  double accrois_omega = (omega_c0 - omega_ini) /
131  double(mer_fix_omega - mer_change_omega) ;
132 
133 
134  update_metric() ; //update of the metric quantities
135 
136  equation_of_state() ; // update of the density, pressure,...etc
137 
138  hydro_euler() ; //update of the hydro quantities relative to the
139  // Eulerian observer
140 
141  // Quantities at the previous step :
142  Scalar ent_prev = ent ;
143  Scalar logn_prev = logn ;
144  Scalar psi_prev = psi ;
145  // Vector beta_prev = beta ;
146 
147  // Output files
148  // -------------
149 
150  ofstream fichconv("convergence.d") ; // Output file for diff_ent
151  fichconv << "# diff_ent GRV2 max_triax vit_triax" << endl ;
152 
153  ofstream fichfreq("frequency.d") ; // Output file for omega_c
154  fichfreq << "# f [Hz]" << endl ;
155 
156  ofstream fichevol("evolution.d") ; // Output file for various quantities
157  fichevol <<
158  "# |dH/dr_eq/dH/dr_pole| r_pole/r_eq ent_c"
159  << endl ;
160 
161  diff_ent = 1 ;
162  double err_grv2 = 1 ;
163  double max_triax_prev = 0 ; // Triaxial amplitude at previous step
164 
165 
166  //=========================================================================
167  // Start of iteration
168  //=========================================================================
169 
170  for(int mer=0 ; (diff_ent > precis) && (mer<mer_max) ; mer++ ) {
171 
172  cout << "-----------------------------------------------" << endl ;
173  cout << "step: " << mer << endl ;
174  cout << "diff_ent = " << display_bold << diff_ent << display_normal
175  << endl ;
176  cout << "err_grv2 = " << err_grv2 << endl ;
177  fichconv << mer ;
178  fichfreq << mer ;
179  fichevol << mer ;
180 
181  // Switch on rotation
182  if (mer >= mer_rot) {
183 
184  if (mer < mer_change_omega) {
185  omega_c = omega_ini ;
186  }
187  else {
188  if (mer <= mer_fix_omega) {
189  omega_c = omega_ini + accrois_omega *
190  (mer - mer_change_omega) ;
191  }
192  }
193 
194 
195  }
196 
197  //---------------------------------------------//
198  // Resolution of the Poisson equation for psi //
199  //---------------------------------------------//
200 
201  Scalar psi_new(mp) ;
202 
203  solve_psi( psi_new ) ;
204 
205  psi_new.std_spectral_base() ;
206 
207 
208  //---------------------------------------------------//
209  // Resolution of the Poisson equation for logn //
210  // Note: ln_f is due to the fluid part //
211  // ln_q is due to the quadratic metric part //
212  //---------------------------------------------------//
213 
214  Scalar ln_f_new(mp) ;
215  Scalar ln_q_new(mp) ;
216 
217  solve_logn_f( ln_f_new ) ;
218  solve_logn_q( ln_q_new ) ;
219 
220  ln_f_new.std_spectral_base() ;
221  ln_q_new.std_spectral_base() ;
222 
223  //---------------------------------------
224  // Triaxial perturbation of ln_ff
225  //---------------------------------------
226 
227  if (mer == mer_triax) {
228 
229  if ( mg->get_np(0) == 1 ) {
230  cout <<
231  "Star_rot_diff::equilibrium: np must be stricly greater than 1"
232  << endl << " to set a triaxial perturbation !" << endl ;
233  abort() ;
234  }
235 
236  const Coord& phi = mp.phi ;
237  const Coord& sint = mp.sint ;
238  Scalar perturb(mp) ;
239  perturb = 1 + ampli_triax * sint*sint * cos(2*phi) ;
240  ln_f_new = ln_f_new * perturb ;
241 
242  ln_f_new.std_spectral_base() ; // set the bases for spectral expansions
243  // to be the standard ones for a
244  // scalar field
245 
246  }
247 
248  // Monitoring of the triaxial perturbation
249  // ---------------------------------------
250 
251  const Valeur& va_nuf = ln_f_new.get_spectral_va() ;
252  va_nuf.coef() ; // Computes the spectral coefficients
253  double max_triax = 0 ;
254 
255  if ( mg->get_np(0) > 1 ) {
256 
257  for (int l=0; l<nz; l++) { // loop on the domains
258  for (int j=0; j<mg->get_nt(l); j++) {
259  for (int i=0; i<mg->get_nr(l); i++) {
260 
261  // Coefficient of cos(2 phi) :
262  double xcos2p = (*(va_nuf.c_cf))(l, 2, j, i) ;
263 
264  // Coefficient of sin(2 phi) :
265  double xsin2p = (*(va_nuf.c_cf))(l, 3, j, i) ;
266 
267  double xx = sqrt( xcos2p*xcos2p + xsin2p*xsin2p ) ;
268 
269  max_triax = ( xx > max_triax ) ? xx : max_triax ;
270  }
271  }
272  }
273 
274  }
275 
276  cout << "Triaxial part of nuf : " << max_triax << endl ;
277 
278 
279  //--------------------------------------------------//
280  // Resolution of the Poisson equation for shift //
281  //--------------------------------------------------//
282 
283  Vector beta_new(mp, CON, mp.get_bvect_spher()) ;
284 
285  solve_shift( beta_new ) ;
286 
287  //-----------------------------------------
288  // Determination of the fluid velociy U
289  //-----------------------------------------
290 
291  if (mer > mer_fix_omega + delta_mer_kep) {
292 
293  omega_c *= fact_omega ; // Increase of the angular velocity if
294  } // fact_omega != 1
295 
296 
297  bool omega_trop_grand = false ;
298  bool kepler = true ;
299 
300  while ( kepler ) {
301 
302  // Possible decrease of Omega to ensure a velocity < c
303 
304  bool superlum = true ;
305 
306  while ( superlum ) {
307 
308  // Computation of Omega(r,theta)
309 
310  if (omega_c == 0.) {
311  omega_field = 0 ;
312  }
313  else if (par_frot.get_taille() == 5) { // Uryu rotation profile
314  if (par_frot(1) == 1. && par_frot(2) == 1.) { // Rigid rotation limit in Uryu profile
315  omega_field = omega_c ;
316  for (int l=nzet+1; l<nz; l++) { // omega_field set to 0 far from the star
317  omega_field.set_domain(l) = 0 ;
318  }
319  prim_field = 0 ;
320  omega_min = omega_c ;
321  omega_max = omega_c ;
322  }
323  else { // Usual case
324  double lambda1 = par_frot(1) ;
325  double lambda2 = par_frot(2) ;
326  int p = 1 ;
327  int q = 3 ;
328 
329  // First, compute F_e and F_max
330  Scalar p4rst2 = psi4 ;
331  p4rst2.annule_domain(nzm1) ;
332  p4rst2.std_spectral_base() ;
333  p4rst2.mult_rsint() ; p4rst2.mult_rsint() ; // Multiplication by r^2 sin^2(theta)
334  Scalar nnn2 = nn * nn ;
335 
336  double omnp = omega_field.val_grid_point(l_b, k_b, j_b, i_b) + beta(3).val_grid_point(l_b, k_b, j_b, i_b) ;
337  double F_e = p4rst2.val_grid_point(l_b, k_b, j_b, i_b) * omnp /
338  ( nnn2.val_grid_point(l_b, k_b, j_b, i_b) -
339  p4rst2.val_grid_point(l_b, k_b, j_b, i_b) * omnp * omnp ) ;
340 
341  if (F_e != double(0)) { // Not the first iteration
342  int l, k, j, i ;
343  double om_max = 0 ;
344  double om_lkji = 0 ;
345  double F_max = 0 ;
346  for (l=0; l<nzet+1; l++) {
347  for (k=0; k<mg->get_np(l); k++) {
348  for (j=0; j<mg->get_nt(l); j++) {
349  for (i=0; i<mg->get_nr(l); i++) {
350  om_lkji = omega_field.val_grid_point(l, k, j, i) ;
351  if (om_lkji > om_max) {
352  om_max = om_lkji ;
353  omnp = om_max + beta(3).val_grid_point(l, k, j, i) ;
354  F_max = p4rst2.val_grid_point(l, k, j, i) * omnp /
355  ( nnn2.val_grid_point(l, k, j, i) -
356  p4rst2.val_grid_point(l, k, j, i) * omnp * omnp ) ;
357  }
358  }
359  }
360  }
361  }
362 
363  // Now A^2 and B^2, parameters for omega_frot, can be computed
364 
365  if (lambda2 == -1.) { // Special flag to keep A^2 and B^2 constant
366  // Computing lambda1 from A^2 and B^2
367  double A2 = par_frot(3) ;
368  double B2 = par_frot(4) ;
369  lambda1 = (1 + pow(F_max/(B2*omega_c), p))/(1 + pow(F_max/(A2*omega_c), q+p)) ;
370  }
371  else if (F_e < 0) { // Work in progress: fixing issues with A^2 and B^2 parameters
372  cout << "Warning: F_e=" << F_e << " < 0. Aborting." << endl ;
373  abort() ;
374  //F_e = 1.001*pow(lambda1/lambda2, 1./q)*F_max ;
375  //cout << F_e << endl ;
376  par_frot.set(3) = 10000. ;
377  par_frot.set(4) = 10000. ;
378  }
379  /*else if (F_e < F_max) {
380  cout << "Warning: F_e=" << F_e << " < F_max=" << F_max << ". Impossible to fix by changing lambda1 and lambda2." << endl ;
381  cout << "Trying with the parameters of the previous iteration" << endl ;
382  }*/
383  else {
384  /*while (F_e < pow(lambda1/lambda2, 1./q)*F_max) {
385  // This would lead to unphysical A^2 and B^2. Relaxing lambda1 and lambda2 only in this iteration
386  lambda1 *= .9 ;
387  lambda2 *= 1.1 ;
388  // lambda2 = 1.1*lambda1*pow(F_max/F_e, q) ;
389  cout << "Warning: unphysical A^2 and B^2. Relaxing lambda1=" << par_frot(1)
390  << "->" << lambda1 << ", lambda2=" << par_frot(2) << "->" << lambda2 << endl ;
391 
392  }*/
393  //cout << lambda2*pow(F_e, q)-lambda1*pow(F_max, q) << endl ;
394  par_frot.set(3) = pow(pow(F_e*F_max,p)/pow(omega_c, p+q) * (lambda2*pow(F_e, q)-lambda1*pow(F_max, q) )
395  / ((lambda1-1)*pow(F_e, p) - (lambda2-1)*pow(F_max, p)), 1./(p+q) ) ;
396  par_frot.set(4) = F_e*F_max/omega_c * pow((lambda2*pow(F_e, q)-lambda1*pow(F_max, q))
397  / (lambda2*(lambda1-1)*pow(F_e, p+q) - lambda1*(lambda2-1)*pow(F_max, p+q)), 1./p) ;
398 
399  cout << F_e << " " << F_max << endl ;
400  }
401 
402  }
403 
404  par_frot.set(0) = omega_c ;
405 
406  cout << "Parameters of Omega(F) : " << par_frot << endl ;
407 
408  double omeg_min = 0 ;
409  double omeg_max = lambda1 * omega_c ;
410  double precis1 = 1.e-14 ;
411  int nitermax1 = 200 ;
412 
413  fait_omega_field(omeg_min, omeg_max, precis1, nitermax1) ;
414  }
415  }
416  else { // Usual rotation profile
417  par_frot.set(0) = omega_c ;
418  if (par_frot(2) != double(0)) { // fixed a = R_eq / R_0
419  par_frot.set(1) = ray_eq() / par_frot(2) ;
420  }
421  double omeg_min = 0 ;
422  double omeg_max = omega_c ;
423  double precis1 = 1.e-14 ;
424  int nitermax1 = 100 ;
425 
426  fait_omega_field(omeg_min, omeg_max, precis1, nitermax1) ;
427  }
428 
429  // New fluid velocity :
430  //
431 
432  u_euler.set(1).set_etat_zero() ;
433  u_euler.set(2).set_etat_zero() ;
434 
435  u_euler.set(3) = omega_field ;
436  u_euler.set(3).annule(nzet,nzm1) ; // nzet is defined in class Star
438  u_euler.set(3).mult_rsint() ;
439  u_euler.set(3) += beta(3) ;
440  u_euler.set(3).annule(nzet,nzm1) ;
441 
442  u_euler = u_euler / nn ;
443 
444 
445  // v2 (square of norm of u_euler)
446  // -------------------------------
447 
448  v2 = contract(contract(gamma.cov(), 0, u_euler, 0), 0, u_euler, 0) ;
449 
450  // Is the new velocity larger than c in the equatorial plane ?
451 
452  superlum = false ;
453 
454  for (int l=0; l<nzet; l++) {
455  for (int i=0; i<mg->get_nr(l); i++) {
456 
457  double u2 = v2.val_grid_point(l, 0, j_b, i) ;
458  if (u2 >= 1.) { // superluminal velocity
459  superlum = true ;
460  cout << "U > c for l, i : " << l << " " << i
461  << " U = " << sqrt(u2) << endl ;
462  }
463  }
464  }
465  if ( superlum ) {
466  cout << "**** VELOCITY OF LIGHT REACHED ****" << endl ;
467  omega_c /= fact_omega ; // Decrease of Omega_c
468  cout << "New central rotation frequency : "
469  << omega/(2.*M_PI) * f_unit << " Hz" << endl ;
470  omega_trop_grand = true ;
471  }
472  } // end of while ( superlum )
473 
474 
475  // New computation of U (which this time is not superluminal)
476  // as well as of gam_euler, ener_euler, etc...
477  // -----------------------------------
478 
479  hydro_euler() ;
480 
481 
482  //------------------------------------------------------
483  // First integral of motion
484  //------------------------------------------------------
485 
486  Scalar mlngamma(mp) ; // -log( gam_euler )
487 
488  mlngamma = - log( gam_euler ) ;
489 
490  // Equatorial values of various potentials :
491  double ln_f_b = ln_f_new.val_grid_point(l_b, k_b, j_b, i_b) ;
492  double ln_q_b = ln_q_new.val_grid_point(l_b, k_b, j_b, i_b) ;
493  double mlngamma_b = mlngamma.val_grid_point(l_b, k_b, j_b, i_b) ;
494  double primf_b = prim_field.val_grid_point(l_b, k_b, j_b, i_b) ;
495 
496 
497  // Central values of various potentials :
498  double ln_f_c = ln_f_new.val_grid_point(0,0,0,0) ;
499  double ln_q_c = ln_q_new.val_grid_point(0,0,0,0) ;
500  double mlngamma_c = 0 ;
501  double primf_c = prim_field.val_grid_point(0,0,0,0) ;
502 
503  // Scale factor to ensure that the (log of) enthalpy is equal to
504  // ent_b at the equator
505  double alpha_r2 = ( ent_c - ent_b + mlngamma_c - mlngamma_b
506  + ln_q_c - ln_q_b + primf_c - primf_b)
507  / ( ln_f_b - ln_f_c ) ;
508  alpha_r = sqrt(alpha_r2) ;
509 
510  cout << "alpha_r = " << alpha_r << endl ;
511 
512  // Rescaling of the grid (no adaptation!)
513  //---------------------------------------
514  mp.homothetie(alpha_r) ;
515 
516  // Readjustment of logn :
517  // -----------------------
518 
519  logn = alpha_r2 * ln_f_new + ln_q_new ;
520 
521  double logn_c = logn.val_grid_point(0,0,0,0) ;
522 
523  // First integral of motion -> (log of) enthalpy in all space
524  // ----------------------------------------------------------
525 
526  ent = (ent_c + logn_c + mlngamma_c) - logn - mlngamma - prim_field ;
527 
528  // Test: is the enthalpy negative somewhere in the equatorial plane
529  // inside the star?
530  // --------------------------------------------------------
531 
532  kepler = false ;
533  for (int l=0; l<nzet; l++) {
534  int imax = mg->get_nr(l) - 1 ;
535  if (l == l_b) imax-- ; // The surface point is skipped
536  for (int i=0; i<imax; i++) {
537  if ( ent.val_grid_point(l, 0, j_b, i) < 0. ) {
538  kepler = true ;
539  cout << "ent < 0 for l, i : " << l << " " << i
540  << " ent = " << ent.val_grid_point(l, 0, j_b, i) << endl ;
541  }
542  }
543  }
544 
545  if ( kepler ) {
546  cout << "**** KEPLERIAN VELOCITY REACHED ****" << endl ;
547  omega_c /= fact_omega ; // Omega is decreased
548  cout << "New central rotation frequency : "
549  << omega_c/(2.*M_PI) * f_unit << " Hz" << endl ;
550  omega_trop_grand = true ;
551  }
552 
553  } // End of while ( kepler )
554 
555  if ( omega_trop_grand ) { // fact_omega is decreased for the
556  // next step
557  fact_omega = sqrt( fact_omega ) ;
558  cout << "**** New fact_omega : " << fact_omega << endl ;
559  }
560 
561 
562  //----------------------------------------------------
563  // Equation of state
564  //----------------------------------------------------
565 
566  equation_of_state() ; // computes new values for nbar (n), ener (e)
567  // and press (p) from the new ent (H)
568 
569  hydro_euler() ;
570 
571  beta = beta_new ;
572 
573  //---------------------------------------
574  // Calculate error of the GRV2 identity
575  //---------------------------------------
576 
577  err_grv2 = grv2() ;
578 
579 
580  //--------------------------------------
581  // Relaxations on some quantities....?
582  //
583  //--------------------------------------
584 
585  if (mer >= 10) {
586  logn = relax * logn + relax_prev * logn_prev ;
587 
588  psi = relax * psi_new + relax_prev * psi_prev ;
589 
590  }
591 
592  // Update of the metric quantities :
593 
594  update_metric() ;
595 
596  //-----------------------
597  // Informations display
598  // More to come later......
599  //-----------------------
600 
601  partial_display(cout) ;
602  fichfreq << " " << omega_c / (2*M_PI) * f_unit ;
603  fichevol << " " << ray_pole() / ray_eq() ;
604  fichevol << " " << ent_c ;
605 
606  //-----------------------------------------
607  // Convergence towards a given baryon mass
608  //-----------------------------------------
609 
610  if (mer > mer_mass) {
611 
612  double xx ;
613  if (mbar_wanted > 0.) {
614  xx = mass_b() / mbar_wanted - 1. ;
615  cout << "Discrep. baryon mass <-> wanted bar. mass : " << xx
616  << endl ;
617  }
618  else{
619  xx = mass_g() / fabs(mbar_wanted) - 1. ;
620  cout << "Discrep. grav. mass <-> wanted grav. mass : " << xx
621  << endl ;
622  }
623  double xprog = ( mer > 2*mer_mass) ? 1. :
624  double(mer-mer_mass)/double(mer_mass) ;
625  xx *= xprog ;
626  double ax = .5 * ( 2. + xx ) / (1. + xx ) ;
627  double fact = pow(ax, aexp_mass) ;
628  cout << " xprog, xx, ax, fact : " << xprog << " " <<
629  xx << " " << ax << " " << fact << endl ;
630 
631  if ( change_ent ) {
632  ent_c *= fact ;
633  }
634  else {
635  if (mer%4 == 0) omega_c *= fact ;
636  }
637  }
638 
639 
640  //------------------------------------------------------------
641  // Relative change in enthalpy with respect to previous step
642  // ** Check: Is diffrel(ent, ent_prev) ok?
643  //------------------------------------------------------------
644 
645  Tbl diff_ent_tbl = diffrel( ent, ent_prev ) ;
646  diff_ent = diff_ent_tbl(0) ;
647  for (int l=1; l<nzet; l++) {
648  diff_ent += diff_ent_tbl(l) ;
649  }
650  diff_ent /= nzet ;
651 
652  fichconv << " " << log10( fabs(diff_ent) + 1.e-16 ) ;
653  fichconv << " " << log10( fabs(err_grv2) + 1.e-16 ) ;
654  fichconv << " " << log10( fabs(max_triax) + 1.e-16 ) ;
655 
656  vit_triax = 0 ;
657  if ( (mer > mer_triax+1) && (max_triax_prev > 1e-13) ) {
658  vit_triax = (max_triax - max_triax_prev) / max_triax_prev ;
659  }
660 
661  fichconv << " " << vit_triax ;
662 
663  //------------------------------
664  // Recycling for the next step
665  //------------------------------
666 
667  ent_prev = ent ;
668  logn_prev = logn ;
669  psi_prev = psi ;
670  max_triax_prev = max_triax ;
671 
672  fichconv << endl ;
673  fichfreq << endl ;
674  fichevol << endl ;
675  fichconv.flush() ;
676  fichfreq.flush() ;
677  fichevol.flush() ;
678 
679 
680  } // End of main loop
681 
682  //=========================================================================
683  // End of iteration
684  //=========================================================================
685 
686  fichconv.close() ;
687  fichfreq.close() ;
688  fichevol.close() ;
689 
690 }
691 }
void annule_domain(int l)
Sets the Tensor to zero in a given domain.
Definition: tensor.C:676
Cmp log(const Cmp &)
Neperian logarithm.
Definition: cmp_math.C:299
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
Definition: valeur.h:312
Map & mp
Mapping associated with the star.
Definition: star.h:180
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition: grilles.h:481
void coef() const
Computes the coeffcients of *this.
Definition: valeur_coef.C:151
Cmp sqrt(const Cmp &)
Square root.
Definition: cmp_math.C:223
void solve_logn_q(Scalar &ln_q_new) const
Solution of the quadratic part of the Poisson equation for the lapse for rotating stars in CFC...
virtual void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Definition: scalar.C:330
double omega_min
Minimum value of .
virtual void annule(int l_min, int l_max)
Sets the Scalar to zero in several domains.
Definition: scalar.C:397
Metric gamma
3-metric
Definition: star.h:235
Scalar psi
Conformal factor .
Definition: star_rot_cfc.h:65
const Base_vect_spher & get_bvect_spher() const
Returns the orthonormal vectorial basis associated with the coordinates of the mapping.
Definition: map.h:810
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:792
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:399
int get_type_t() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the equatorial pl...
Definition: grilles.h:504
Basic integer array class.
Definition: itbl.h:122
Scalar psi4
Conformal factor .
Definition: star_rot_cfc.h:81
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
Values and coefficients of a (real-value) function.
Definition: valeur.h:297
virtual void hydro_euler()
Computes the hydrodynamical quantities relative to the Eulerian observer from those in the fluid fram...
Scalar ent
Log-enthalpy.
Definition: star.h:190
Vector beta
Shift vector.
Definition: star.h:228
Tensor field of valence 1.
Definition: vector.h:188
Cmp cos(const Cmp &)
Cosine.
Definition: cmp_math.C:97
Tbl & set_domain(int l)
Read/write of the value in a given domain.
Definition: scalar.h:627
Tbl diffrel(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (norme version).
Definition: cmp_math.C:507
double val_grid_point(int l, int k, int j, int i) const
Returns the value of the field at a specified grid point.
Definition: scalar.h:649
Coord phi
coordinate centered on the grid
Definition: map.h:747
int nzet
Number of domains of *mp occupied by the star.
Definition: star.h:183
Coord sint
Definition: map.h:748
virtual void equilibrium(double ent_c, double omega0, double fact_omega, int nzadapt, const Tbl &ent_limit, const Itbl &icontrol, const Tbl &control, double mbar_wanted, double aexp_mass, Tbl &diff, Param *=0x0)
Computes an equilibrium configuration.
Scalar gam_euler
Lorentz factor between the fluid and Eulerian observers.
Definition: star.h:204
double omega
Rotation angular velocity ([f_unit] )
Definition: star_rot_cfc.h:60
virtual void homothetie(double lambda)=0
Sets a new radial scale.
void solve_shift(Vector &shift_new) const
Solution of the shift equation for rotating stars in CFC.
void fait_omega_field(double omeg_min, double omeg_max, double precis, int nitermax)
Computes (member omega_field ).
Parameter storage.
Definition: param.h:125
Tbl par_frot
Parameters of the function .
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:467
virtual double mass_b() const
Baryonic mass.
Vector u_euler
Fluid 3-velocity with respect to the Eulerian observer.
Definition: star.h:207
void mult_rsint()
Multiplication by everywhere; dzpuis is not changed.
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 .
Scalar logn
Logarithm of the lapse N .
Definition: star.h:222
Active physical coordinates and mapping derivatives.
Definition: coord.h:90
void solve_logn_f(Scalar &ln_f_new) const
Solution of the `‘matter’&#39; part of the Poisson equation for the lapse for rotating stars in CFC...
double ray_pole() const
Coordinate radius at [r_unit].
Definition: star_global.C:281
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition: grilles.h:471
void solve_psi(Scalar &psi_new)
Solution of the equations for the conformal factor for rotating stars in CFC.
virtual const Sym_tensor & cov() const
Read-only access to the covariant representation.
Definition: metric.C:283
virtual void partial_display(ostream &) const
Printing of some informations, excluding all global quantities.
Multi-domain grid.
Definition: grilles.h:276
Scalar nn
Lapse function N .
Definition: star.h:225
double omega_max
Maximum value of .
Cmp log10(const Cmp &)
Basis 10 logarithm.
Definition: cmp_math.C:325
Cmp abs(const Cmp &)
Absolute value.
Definition: cmp_math.C:413
int get_taille() const
Gives the total size (ie dim.taille)
Definition: tbl.h:417
double ray_eq() const
Coordinate radius at , [r_unit].
Definition: star_global.C:111
Basic array class.
Definition: tbl.h:164
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition: grilles.h:476
Scalar & set(int)
Read/write access to a component.
Definition: vector.C:302
void equation_of_state()
Computes the proper baryon and energy density, as well as pressure from the enthalpy.
Definition: star.C:465
void update_metric()
Computes metric quantities from known potentials.
virtual double grv2() const
Error on the virial identity GRV2.
void annule_hard()
Sets the Tbl to zero in a hard way.
Definition: tbl.C:375
const Valeur & get_spectral_va() const
Returns va (read only version)
Definition: scalar.h:613
virtual double mass_g() const
Gravitational mass.