LORENE
star_bin_equilibrium_xcts.C
1 /*
2  * Method of class Star_bin to compute an equilibrium configuration
3  * (see file star.h for documentation).
4  */
5 
6 /*
7  * Copyright (c) 2010 Michal Bejger
8  *
9  * This file is part of LORENE.
10  *
11  * LORENE is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2
13  * as published by the Free Software Foundation.
14  *
15  * LORENE is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with LORENE; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */
25 
26 
27 
28 /*
29  * $Id: star_bin_equilibrium_xcts.C,v 1.14 2016/12/05 16:18:14 j_novak Exp $
30  * $Log: star_bin_equilibrium_xcts.C,v $
31  * Revision 1.14 2016/12/05 16:18:14 j_novak
32  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
33  *
34  * Revision 1.13 2014/10/13 08:53:38 j_novak
35  * Lorene classes and functions now belong to the namespace Lorene.
36  *
37  * Revision 1.12 2014/10/06 15:13:16 j_novak
38  * Modified #include directives to use c++ syntax.
39  *
40  * Revision 1.11 2011/03/25 16:28:12 e_gourgoulhon
41  * Still in progress
42  *
43  * Revision 1.10 2010/12/20 15:42:10 m_bejger
44  * Various rearrangements of fields in Poissson equations
45  *
46  * Revision 1.9 2010/12/14 17:34:42 m_bejger
47  * Improved iteration for beta_auto poisson_vect()
48  *
49  * Revision 1.8 2010/12/09 10:48:06 m_bejger
50  * Testing the main equations
51  *
52  * Revision 1.7 2010/10/26 18:46:28 m_bejger
53  * Added table fact_resize for domain resizing
54  *
55  * Revision 1.6 2010/10/18 19:08:14 m_bejger
56  * Changed to allow for calculations with more than one domain in the star
57  *
58  * Revision 1.5 2010/06/23 20:40:56 m_bejger
59  * Corrections in equations for Psi_auto, chi_auto and beta_auto
60  *
61  * Revision 1.4 2010/06/18 13:28:59 m_bejger
62  * Adjusted the computation of the first integral, radial scale
63  *
64  * Revision 1.3 2010/06/17 17:05:06 m_bejger
65  * Testing version
66  *
67  * Revision 1.2 2010/06/15 08:21:21 m_bejger
68  * Minor changes; still not working properly
69  *
70  * Revision 1.1 2010/05/04 07:51:05 m_bejger
71  * Initial version
72  *
73  * $Header: /cvsroot/Lorene/C++/Source/Star/star_bin_equilibrium_xcts.C,v 1.14 2016/12/05 16:18:14 j_novak Exp $
74  *
75  */
76 
77 // C headers
78 #include <cmath>
79 
80 // Lorene headers
81 #include "cmp.h"
82 #include "tenseur.h"
83 #include "metrique.h"
84 #include "star.h"
85 #include "param.h"
86 #include "graphique.h"
87 #include "utilitaires.h"
88 #include "tensor.h"
89 #include "nbr_spx.h"
90 #include "unites.h"
91 
92 
93 namespace Lorene {
94 void Star_bin_xcts::equilibrium(double ent_c,
95  int mermax,
96  int mermax_potvit,
97  int mermax_poisson,
98  double relax_poisson,
99  double relax_potvit,
100  double thres_adapt,
101  const Tbl& fact_resize,
102  const Tbl* pent_limit,
103  Tbl& diff) {
104 
105  // Fundamental constants and units
106  // -------------------------------
107 
108  using namespace Unites ;
109 
110  // Initializations
111  // ---------------
112 
113  const Mg3d* mg = mp.get_mg() ;
114  int nz = mg->get_nzone() ; // total number of domains
115 
116  // The following is required to initialize mp_prev as a Map_et:
117  Map_et& mp_et = dynamic_cast<Map_et&>(mp) ;
118 
119  // Domain and radial indices of points at the surface of the star:
120  int l_b = nzet - 1 ;
121  int i_b = mg->get_nr(l_b) - 1 ;
122  int k_b ;
123  int j_b ;
124 
125  // Value of the enthalpy defining the surface of the star
126  double ent_b = 0 ;
127 
128  // Error indicators
129  // ----------------
130 
131  double& diff_ent = diff.set(0) ;
132  double& diff_vel_pot = diff.set(1) ;
133  double& diff_psi = diff.set(2) ;
134  double& diff_chi = diff.set(3) ;
135  double& diff_beta_x = diff.set(4) ;
136  double& diff_beta_y = diff.set(5) ;
137  double& diff_beta_z = diff.set(6) ;
138 
139  // Parameters for the function Map_et::adapt
140  // -----------------------------------------
141 
142  Param par_adapt ;
143  int nitermax = 100 ;
144  int niter ;
145  int adapt_flag = 1 ; // 1 = performs the full computation,
146  // 0 = performs only the rescaling by
147  // the factor alpha_r
148  //## int nz_search = nzet + 1 ; // Number of domains for searching the
149  // enthalpy
150 
151  int nz_search = nzet ; // Number of domains
152  // for searching
153  // the enthalpy isosurfaces
154 
155  double precis_secant = 1.e-14 ;
156  double alpha_r ;
157  double reg_map = 1. ; // 1 = regular mapping,
158  // 0 = contracting mapping
159 
160  par_adapt.add_int(nitermax, 0) ; // maximum number of iterations to
161  // locate zeros by the secant method
162 
163  par_adapt.add_int(nzet, 1) ; // number of domains where the adjustment
164  // to the isosurfaces of ent is to be performed
165 
166  par_adapt.add_int(nz_search, 2) ; // number of domains to search
167  // the enthalpy isosurface
168 
169  par_adapt.add_int(adapt_flag, 3) ; // 1 = performs the full computation,
170  // 0 = performs only the rescaling by
171  // the factor alpha_r
172 
173  par_adapt.add_int(j_b, 4) ; // theta index of the collocation point
174  // (theta_*, phi_*)
175 
176  par_adapt.add_int(k_b, 5) ; // theta index of the collocation point
177  // (theta_*, phi_*)
178 
179  par_adapt.add_int_mod(niter, 0) ; // number of iterations actually used in
180  // the secant method
181 
182  par_adapt.add_double(precis_secant, 0) ;// required absolute precision in
183  // the determination of zeros by
184  // the secant method
185  par_adapt.add_double(reg_map, 1) ; // 1. = regular mapping, 0 = contracting mapping
186 
187  par_adapt.add_double(alpha_r, 2) ; // factor by which all the radial
188  // distances will be multiplied
189 
190  // Enthalpy values for the adaptation
191  Tbl ent_limit(nzet) ;
192  if (pent_limit != 0x0) ent_limit = *pent_limit ;
193 
194  par_adapt.add_tbl(ent_limit, 0) ; // array of values of the field ent
195  // to define the isosurfaces.
196 
197  double precis_poisson = 1.e-16 ;
198 
199  Cmp ssjm1psi (ssjm1_psi) ;
200  Cmp ssjm1chi (ssjm1_chi) ;
201 
202  // Parameters for the function Scalar::poisson for Psi_auto
203  // ---------------------------------------------------------------
204 
205  Param par_psi ;
206 
207  par_psi.add_int(mermax_poisson, 0) ; // maximum number of iterations
208  par_psi.add_double(relax_poisson, 0) ; // relaxation parameter
209  par_psi.add_double(precis_poisson, 1) ; // required precision
210  par_psi.add_int_mod(niter, 0) ; // number of iterations actually used
211  par_psi.add_cmp_mod( ssjm1psi ) ;
212 
213  // Parameters for the function Scalar::poisson for chi_auto
214  // ---------------------------------------------------------------
215 
216  Param par_chi ;
217 
218  par_chi.add_int(mermax_poisson, 0) ; // maximum number of iterations
219  par_chi.add_double(relax_poisson, 0) ; // relaxation parameter
220  par_chi.add_double(precis_poisson, 1) ; // required precision
221  par_chi.add_int_mod(niter, 0) ; // number of iterations actually used
222  par_chi.add_cmp_mod( ssjm1chi ) ;
223 
224  // Parameters for the function Vector::poisson for beta
225  // ----------------------------------------------------
226 
227  Param par_beta ;
228 
229  par_beta.add_int(mermax_poisson, 0) ; // maximum number of
230  // iterations
231  par_beta.add_double(relax_poisson, 0) ; // relaxation parameter
232  par_beta.add_double(precis_poisson, 1) ; // required precision
233  par_beta.add_int_mod(niter, 0) ; // number of iterations
234  // actually used
235 
236  // Sources at the previous step, for a poisson_vect() solver
237  Cmp ssjm1khi (ssjm1_khi) ;
238 
239  Tenseur ssjm1wbeta(mp, 1, CON, mp.get_bvect_cart()) ;
240  ssjm1wbeta.set_etat_qcq() ;
241  for (int i=0; i<3; i++) ssjm1wbeta.set(i) = Cmp(ssjm1_wbeta(i+1)) ;
242 
243  par_beta.add_cmp_mod(ssjm1khi) ;
244  par_beta.add_tenseur_mod(ssjm1wbeta) ;
245 
246  // Redefinition of external potential
247  // See Eq (99) from Gourgoulhon et al. (2001)
248  // logN = logN_auto + logn_ac_rest = log(chi_auto + 1.)
249  // - log(Psi_auto + 1.) + logn_ac_rest
250  //------------------------------------
251 
252  Scalar Psi_auto_p1 = Psi_auto + 1. ;
253  Scalar chi_auto_p1 = chi_auto + 1. ;
254 
255  Scalar logn_auto = log(chi_auto_p1) - log(Psi_auto_p1) ;
256  logn_auto.std_spectral_base() ;
257 
258  Scalar logn_ac_rest = log(1. + chi_comp/chi_auto_p1)
259  - log(1. + Psi_comp/Psi_auto_p1) ;
260 
261  logn_ac_rest.std_spectral_base() ;
262 
263  //cout << "logn_auto" << norme(logn_auto) << endl ;
264  //cout << "logn_ac_rest" << norme(logn_ac_rest) << endl ;
265  //cout << "pot_centri" << norme(pot_centri) << endl ;
266  //cout << "loggam" << norme(loggam) << endl ;
267 
268  Scalar pot_ext = logn_ac_rest + pot_centri + loggam ;
269  //cout << "pot_ext" << norme(pot_ext) << endl ;
270 
271  Scalar ent_jm1 = ent ; // Enthalpy at previous step
272 
273  Scalar source_tot(mp) ; // source term in equations Psi_auto
274  // and chi_auto
275 
276  Vector source_beta(mp, CON, mp.get_bvect_cart()) ; // source term
277  // in the equation
278  // for beta_auto
279 
280  //==================================================================
281  // Start of iteration
282  //==================================================================
283 
284  for(int mer=0 ; mer<mermax ; mer++ ) {
285 
286  cout << "-----------------------------------------------" << endl ;
287  cout << "step: " << mer << endl ;
288  cout << "diff_ent = " << diff_ent << endl ;
289 
290  //-----------------------------------------------------
291  // Resolution of the elliptic equation for the velocity
292  // scalar potential
293  //-----------------------------------------------------
294 
295  if (irrotational) {
296 
297  diff_vel_pot = velocity_potential(mermax_potvit, precis_poisson,
298  relax_potvit) ;
299  }
300 
301  diff_vel_pot = 0. ; // to avoid the warning
302 
303  //-----------------------------------------------------
304  // Computation of the new radial scale
305  //--------------------------------------------------
306 
307  // alpha_r (r = alpha_r r') is determined so that the enthalpy
308  // takes the requested value ent_b at the stellar surface
309 
310  // Values at the center of the star:
311  double logn_auto_c = logn_auto.val_grid_point(0, 0, 0, 0) ;
312  double pot_ext_c = pot_ext.val_grid_point(0, 0, 0, 0) ;
313 
314  // Search for the reference point (theta_*, phi_*) [notation of
315  // Bonazzola, Gourgoulhon & Marck PRD 58, 104020 (1998)]
316  // at the surface of the star
317  // ------------------------------------------------------------
318  double alpha_r2 = 0 ;
319  for (int k=0; k<mg->get_np(l_b); k++) {
320  for (int j=0; j<mg->get_nt(l_b); j++) {
321 
322  double pot_ext_b = pot_ext.val_grid_point(l_b, k, j, i_b) ;
323  double logn_auto_b = logn_auto.val_grid_point(l_b, k, j, i_b) ;
324  // See Eq (100) from Gourgoulhon et al. (2001)
325  double alpha_r2_jk = ( ent_c - ent_b + pot_ext_c - pot_ext_b) /
326  ( logn_auto_b - logn_auto_c ) ;
327 
328  // cout << "k, j, alpha_r2_jk : " << k << " " << j << " " << alpha_r2_jk << endl ;
329 
330  if (alpha_r2_jk > alpha_r2) {
331  alpha_r2 = alpha_r2_jk ;
332  k_b = k ;
333  j_b = j ;
334  }
335 
336  }
337  }
338 
339  alpha_r = sqrt(alpha_r2) ;
340 
341  cout << "k_b, j_b, alpha_r: " << k_b << " " << j_b << " "
342  << alpha_r << endl ;
343 
344  // New value of logn_auto
345  // ----------------------
346 
347  Psi_auto = pow(Psi_auto +1.,alpha_r2) - 1. ;
348  chi_auto = pow(chi_auto +1.,alpha_r2) - 1. ;
351 
352  //------------------------------------------------------------
353  // Change the values of the inner points of the domain adjascent
354  // to the surface of the star by those of the outer points of
355  // the domain under the surface
356  //------------------------------------------------------------
357 
360 
361  logn_auto = log(chi_auto + 1.) - log(Psi_auto + 1.) ;
362  logn_auto.std_spectral_base() ;
363 
364  logn_auto_c = logn_auto.val_grid_point(0, 0, 0, 0) ;
365 
366  //------------------------------------------
367  // First integral --> enthalpy in all space
368  // See Eq (98) from Gourgoulhon et al. (2001)
369  //-------------------------------------------
370 
371  ent = (ent_c + logn_auto_c + pot_ext_c) - logn_auto - pot_ext ;
372  cout.precision(8) ;
373  cout << "pot" << norme(pot_ext) << endl ;
374 
375  (ent.set_spectral_va()).smooth(nzet, ent.set_spectral_va()) ;
376 
377  //----------------------------------------------------
378  // Adaptation of the mapping to the new enthalpy field
379  //----------------------------------------------------
380 
381  // Shall the adaptation be performed (cusp) ?
382  // ------------------------------------------
383 
384  double dent_eq = ent.dsdr().val_point(ray_eq(),M_PI/2.,0.) ;
385  double dent_pole = ent.dsdr().val_point(ray_pole(),0.,0.) ;
386  double rap_dent = fabs( dent_eq / dent_pole ) ;
387  cout << "| dH/dr_eq / dH/dr_pole | = " << rap_dent << endl ;
388 
389  if ( rap_dent < thres_adapt ) {
390  adapt_flag = 0 ; // No adaptation of the mapping
391  cout << "******* FROZEN MAPPING *********" << endl ;
392  }
393  else{
394  adapt_flag = 1 ; // The adaptation of the mapping is to be
395  // performed
396  }
397 
398  ent_limit.set_etat_qcq() ;
399  for (int l=0; l<nzet; l++) { // loop on domains inside the star
400  ent_limit.set(l) = ent.val_grid_point(l, k_b, j_b, i_b) ;
401 
402  } ent_limit.set(nzet-1) = ent_b ;
403 
404  Map_et mp_prev = mp_et ;
405 
406  Cmp ent_cmp(ent) ;
407  mp.adapt(ent_cmp, par_adapt) ;
408  ent = ent_cmp ;
409 
410  // Readjustment of the external boundary of domain l=nzet
411  // to keep a fixed ratio with respect to star's surface
412 
413  double rr_in_1 = mp.val_r(nzet, -1., M_PI/2., 0.) ;
414 
415  // Resizes the outer boundary of the shell including the comp. NS
416  double rr_out_nm2 = mp.val_r(nz-2, 1., M_PI/2., 0.) ;
417 
418  mp.resize(nz-2, rr_in_1/rr_out_nm2 * fact_resize(1)) ;
419 
420  // Resizes the inner boundary of the shell including the comp. NS
421  double rr_out_nm3 = mp.val_r(nz-3, 1., M_PI/2., 0.) ;
422 
423  mp.resize(nz-3, rr_in_1/rr_out_nm3 * fact_resize(0)) ;
424 
425  if (nz > nzet+3) {
426 
427  // Resize of the domain from 1(nzet) to N-4
428  double rr_out_nm3_new = mp.val_r(nz-3, 1., M_PI/2., 0.) ;
429 
430  for (int i=nzet-1; i<nz-4; i++) {
431 
432  double rr_out_i = mp.val_r(i, 1., M_PI/2., 0.) ;
433 
434  double rr_mid = rr_out_i
435  + (rr_out_nm3_new - rr_out_i) / double(nz - 3 - i) ;
436 
437  double rr_2timesi = 2. * rr_out_i ;
438 
439  if (rr_2timesi < rr_mid) {
440 
441  double rr_out_ip1 = mp.val_r(i+1, 1., M_PI/2., 0.) ;
442 
443  mp.resize(i+1, rr_2timesi / rr_out_ip1) ;
444 
445  } else {
446 
447  double rr_out_ip1 = mp.val_r(i+1, 1., M_PI/2., 0.) ;
448 
449  mp.resize(i+1, rr_mid / rr_out_ip1) ;
450 
451  } // End of else
452 
453  } // End of i loop
454 
455  } // End of (nz > nzet+3) loop
456 
457 // if (nz>= 5) {
458 //
459 // double separation = 2. * fabs(mp.get_ori_x()) ;
460 // double ray_eqq = ray_eq() ;
461 // double ray_eqq_pi = ray_eq_pi() ;
462 // double new_rr_out_2 = (separation - ray_eqq) * 0.95 ;
463 // double new_rr_out_3 = (separation + ray_eqq_pi) * 1.05 ;
464 //
465 // double rr_in_1 = mp.val_r(1,-1., M_PI/2, 0.) ;
466 // double rr_out_1 = mp.val_r(1, 1., M_PI/2, 0.) ;
467 // double rr_out_2 = mp.val_r(2, 1., M_PI/2, 0.) ;
468 // double rr_out_3 = mp.val_r(3, 1., M_PI/2, 0.) ;
469 //
470 // mp.resize(1, 0.5*(new_rr_out_2 + rr_in_1) / rr_out_1) ;
471 // mp.resize(2, new_rr_out_2 / rr_out_2) ;
472 // mp.resize(3, new_rr_out_3 / rr_out_3) ;
473 //
474 // for (int dd=4; dd<=nz-2; dd++) {
475 // mp.resize(dd, new_rr_out_3 * pow(4., dd-3) /
476 // mp.val_r(dd, 1., M_PI/2, 0.)) ;
477 // }
478 //
479 // }
480 
481  //else cout << "too small number of domains" << endl ;
482 
483 
484  //------------------------------------------------------------------
485  // Computation of the enthalpy at the new grid points
486  //------------------------------------------------------------------
487 
488  mp_prev.homothetie(alpha_r) ;
489 
490  //Cmp ent_cmp2 (ent) ;
491  //mp.reevaluate_symy(&mp_prev, nzet+1, ent_cmp2) ;
492  //ent = ent_cmp2 ;
493 
494  mp.reevaluate_symy(&mp_prev, nzet+1, ent) ;
495 
496  double ent_s_max = -1 ;
497  int k_s_max = -1 ;
498  int j_s_max = -1 ;
499  for (int k=0; k<mg->get_np(l_b); k++) {
500  for (int j=0; j<mg->get_nt(l_b); j++) {
501  double xx = fabs( ent.val_grid_point(l_b, k, j, i_b) ) ;
502  if (xx > ent_s_max) {
503  ent_s_max = xx ;
504  k_s_max = k ;
505  j_s_max = j ;
506  }
507  }
508  }
509  cout << "Max. abs(enthalpy) at the boundary between domains nzet-1"
510  << " and nzet : " << endl ;
511  cout << " " << ent_s_max << " reached for k = " << k_s_max <<
512  " and j = " << j_s_max << endl ;
513 
514  //------------------------------------------------------------------
515  // Equation of state
516  //------------------------------------------------------------------
517 
518  equation_of_state() ; // computes new values for nbar (n), ener (e)
519  // and press (p) from the new ent (H)
520 
521  //------------------------------------------------------------------
522  // Matter source terms in the gravitational field equations
523  //------------------------------------------------------------------
524 
525  hydro_euler() ; // computes new values for ener_euler (E),
526  // s_euler (S) and u_euler (U^i)
527 
528  // -------------------------------
529  // AUXILIARY QUANTITIES
530  // -------------------------------
531 
532  int nr = mp.get_mg()->get_nr(0) ;
533  int nt = mp.get_mg()->get_nt(0) ;
534  int np = mp.get_mg()->get_np(0) ;
535 
536  Scalar Psi3 = psi4 / Psi ;
537  Psi3.std_spectral_base() ;
538 
539  Scalar sPsi7 = Psi * pow(psi4, -2.) ;
540  sPsi7.std_spectral_base() ;
541 
542  //------------------------------------------------------------------
543  // Poisson equation for Psi_auto (Eq. 8.127 of arXiv:gr-qc/0703035)
544  //------------------------------------------------------------------
545 
546  // Source
547  //--------
548 
549  source_tot = - 0.5 * qpig * psi4 % Psi % ener_euler
550  - 0.125 * sPsi7 * (hacar_auto + hacar_comp) ;
551  source_tot.std_spectral_base() ;
552 
553  // Resolution of the Poisson equation
554  // ----------------------------------
555 
556  cout << "Resolution of the Poisson equation for Psi_auto:" << endl ;
557  source_tot.poisson(par_psi, Psi_auto) ;
558  ssjm1_psi = ssjm1psi ;
559 
560  cout << "Psi_auto: " << endl << norme(Psi_auto/(nr*nt*np)) << endl ;
561 
562  // Check: has the Poisson equation been correctly solved ?
563  // -----------------------------------------------------
564 
565  Tbl tdiff_psi = diffrel(Psi_auto.laplacian(), source_tot) ;
566  cout <<
567  "Relative error in the resolution of the equation for Psi_auto : "
568  << endl ;
569  for (int l=0; l<nz; l++) {
570  cout << tdiff_psi(l) << " " ;
571  }
572  cout << endl
573  << "==========================================================="
574  << endl ;
575 
576  diff_psi = max(abs(tdiff_psi)) ;
577 
578  //------------------------------------------------------------------
579  // Poisson equation for chi_auto (Eq. 8.129 of arXiv:gr-qc/0703035)
580  //------------------------------------------------------------------
581 
582  // Source
583  //--------
584 
585  source_tot = chi * 0.5 * qpig * psi4 % (ener_euler + 2.*s_euler)
586  + 0.875 * nn % sPsi7 * (hacar_auto + hacar_comp) ;
587  source_tot.std_spectral_base() ;
588 
589  // Resolution of the Poisson equation
590  // ----------------------------------
591 
592  cout << "Resolution of the Poisson equation for chi_auto:" << endl ;
593  source_tot.poisson(par_chi, chi_auto) ;
594  ssjm1_chi = ssjm1chi ;
595 
596  cout << "chi_auto: " << endl << norme(chi_auto/(nr*nt*np)) << endl ;
597 
598  // Check: has the Poisson equation been correctly solved ?
599  // -----------------------------------------------------
600 
601  Tbl tdiff_chi = diffrel(chi_auto.laplacian(), source_tot) ;
602  cout <<
603  "Relative error in the resolution of the equation for chi_auto : "
604  << endl ;
605 
606  for (int l=0; l<nz; l++) {
607  cout << tdiff_chi(l) << " " ;
608  }
609  cout << endl
610  << "==========================================================="
611  << endl ;
612 
613  diff_chi = max(abs(tdiff_chi)) ;
614 
615  //------------------------------------------------------------------
616  // Vector Poisson equation for beta_auto
617  // (Eq. 8.128 of arXiv:gr-qc/0703035)
618  //------------------------------------------------------------------
619 
620  // Source
621  //--------
622 
623  source_beta = 4.* qpig * chi % Psi3 * (ener_euler + press) * u_euler
624  + 2. * sPsi7 * contract(haij_auto, 1, dcov_chi, 0)
625  -14. * nn % sPsi7 * contract(haij_auto, 1, dcov_Psi, 0) ;
626  source_beta.std_spectral_base() ;
627 
628  // Resolution of the Poisson equation
629  // ----------------------------------
630 
631  Tenseur source_p(mp, 1, CON, mp.get_bvect_cart() ) ;
632  source_p.set_etat_qcq() ;
633  for (int i=0; i<3; i++) {
634 
635  source_p.set(i) = Cmp(source_beta(i+1)) ;
636  //source_p.set(i).filtre(4) ;
637 
638  }
639 
640  Tenseur vect_auxi (mp, 1, CON, mp.get_bvect_cart()) ;
641  vect_auxi.set_etat_qcq() ;
642  for (int i=0; i<3 ;i++) vect_auxi.set(i) = Cmp(w_beta(i+1)) ;
643  vect_auxi.set_std_base() ;
644 
645 
646  Tenseur scal_auxi (mp) ;
647  scal_auxi.set_etat_qcq() ;
648  scal_auxi.set() = Cmp(khi) ;
649  scal_auxi.set_std_base() ;
650 
651  Tenseur resu_p(mp, 1, CON, mp.get_bvect_cart()) ;
652  resu_p.set_etat_qcq() ;
653  for (int i=0; i<3 ;i++) resu_p.set(i) = Cmp(beta_auto.set(i+1));
654  resu_p.set_std_base() ;
655 
656  // Resolution of the vector Poisson equation
657  // -----------------------------------------
658 
659  double lambda = double(1) / double(3) ;
660  source_p.poisson_vect(lambda, par_beta, resu_p, vect_auxi, scal_auxi) ;
661  //source_p.poisson_vect_oohara(lambda, par_beta, resu_p, scal_auxi) ;
662 
663  for (int i=1; i<=3; i++) {
664  beta_auto.set(i) = resu_p(i-1) ;
665  w_beta.set(i) = vect_auxi(i-1) ;
666  }
667  khi = scal_auxi() ;
668 
669  // Values of sources from the previous step
670  ssjm1_khi = ssjm1khi ;
671  for (int i=0; i<3; i++) ssjm1_wbeta.set(i+1) = ssjm1wbeta(i) ;
672 
673  cout << "beta_auto_x" << endl << norme(beta_auto(1)/(nr*nt*np))
674  << endl ;
675  cout << "beta_auto_y" << endl << norme(beta_auto(2)/(nr*nt*np))
676  << endl ;
677  cout << "beta_auto_z" << endl << norme(beta_auto(3)/(nr*nt*np))
678  << endl ;
679 
680  // Check: has the equation for beta_auto been correctly solved ?
681  // --------------------------------------------------------------
682 
683  Vector lap_beta = (beta_auto.derive_con(flat)).divergence(flat)
684  + lambda* beta_auto.divergence(flat).derive_con(flat) ;
685 
686  source_beta.dec_dzpuis() ;
687  Tbl tdiff_beta_x = diffrel(lap_beta(1), source_beta(1)) ;
688  Tbl tdiff_beta_y = diffrel(lap_beta(2), source_beta(2)) ;
689  Tbl tdiff_beta_z = diffrel(lap_beta(3), source_beta(3)) ;
690 
691  cout <<
692  "Relative error in the resolution of the equation for beta_auto : "
693  << endl ;
694  cout << "x component : " ;
695  for (int l=0; l<nz; l++) {
696  cout << tdiff_beta_x(l) << " " ;
697  }
698  cout << endl ;
699  cout << "y component : " ;
700  for (int l=0; l<nz; l++) {
701  cout << tdiff_beta_y(l) << " " ;
702  }
703  cout << endl ;
704  cout << "z component : " ;
705  for (int l=0; l<nz; l++) {
706  cout << tdiff_beta_z(l) << " " ;
707  }
708  cout << endl ;
709 
710  diff_beta_x = max(abs(tdiff_beta_x)) ;
711  diff_beta_y = max(abs(tdiff_beta_y)) ;
712  diff_beta_z = max(abs(tdiff_beta_z)) ;
713 
714  // End of relativistic equations
715 
716  //-------------------------------------------------
717  // Relative change in enthalpy
718  //-------------------------------------------------
719 
720  Tbl diff_ent_tbl = diffrel( ent, ent_jm1 ) ;
721  diff_ent = diff_ent_tbl(0) ;
722  for (int l=1; l<nzet; l++) diff_ent += diff_ent_tbl(l) ;
723 
724  diff_ent /= nzet ;
725 
726 
727  ent_jm1 = ent ;
728 
729 
730  } // End of main loop
731 
732  //==================================================================
733  // End of iteration
734  //==================================================================
735 
736 }
737 
738 
739 
740 
741 
742 
743 
744 }
Scalar chi
Total function .
Definition: star.h:1155
Cmp log(const Cmp &)
Neperian logarithm.
Definition: cmp_math.C:299
void add_tenseur_mod(Tenseur &ti, int position=0)
Adds the address of a new modifiable Tenseur to the list.
Definition: param.C:1145
Vector dcov_chi
Covariant derivative of the function .
Definition: star.h:1174
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition: cmp.h:446
Radial mapping of rather general form.
Definition: map.h:2783
void add_int(const int &n, int position=0)
Adds the address of a new int to the list.
Definition: param.C:249
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:479
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
Standard units of space, time and mass.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition: map.h:783
const Scalar & laplacian(int ced_mult_r=4) const
Returns the Laplacian of *this.
Definition: scalar_deriv.C:436
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:393
Scalar poisson() const
Solves the scalar Poisson equation with *this as a source.
Definition: scalar_pde.C:139
bool irrotational
true for an irrotational star, false for a corotating one
Definition: star.h:1099
virtual void adapt(const Cmp &ent, const Param &par, int nbr=0)=0
Adaptation of the mapping to a given scalar field.
Vector dcov_Psi
Covariant derivative of the conformal factor .
Definition: star.h:1171
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 ent
Log-enthalpy.
Definition: star.h:190
void equilibrium(double ent_c, int mermax, int mermax_potvit, int mermax_poisson, double relax_poisson, double relax_potvit, double thres_adapt, const Tbl &fact, const Tbl *pent_limit, Tbl &diff)
Computes an equilibrium configuration.
Scalar s_euler
Trace of the stress scalar in the Eulerian frame.
Definition: star.h:201
const Vector & derive_con(const Metric &gam) const
Returns the "contravariant" derivative of *this with respect to some metric , by raising the index of...
Definition: scalar_deriv.C:402
Tensor field of valence 1.
Definition: vector.h:188
Sym_tensor haij_auto
Part of the extrinsic curvature tensor generated by beta_auto.
Definition: star.h:1193
void smooth(int nzet, Valeur &uuva) const
Changes the function *this as a smooth one when there exists a discontinuity between the nucleus and ...
Definition: valeur_smooth.C:80
Tbl diffrel(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (norme version).
Definition: cmp_math.C:507
Scalar ssjm1_chi
Effective source at the previous step for the resolution of the Poisson equation for ...
Definition: star.h:1216
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:643
virtual void dec_dzpuis(int dec=1)
Decreases by dec units the value of dzpuis and changes accordingly the values in the compactified ext...
Definition: tensor.C:817
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: tbl.C:364
int nzet
Number of domains of *mp occupied by the star.
Definition: star.h:183
virtual double val_r(int l, double xi, double theta, double pphi) const =0
Returns the value of the radial coordinate r for a given in a given domain.
Scalar loggam
Logarithm of the Lorentz factor between the fluid and the co-orbiting observer.
Definition: star.h:1120
Cmp & set()
Read/write for a scalar (see also operator=(const Cmp&) ).
Definition: tenseur.C:840
Scalar pot_centri
Centrifugal potential.
Definition: star.h:1129
Tbl norme(const Cmp &)
Sums of the absolute values of all the values of the Cmp in each domain.
Definition: cmp_math.C:484
Scalar Psi_auto
Scalar field generated principally by the star.
Definition: star.h:1144
Vector ssjm1_wbeta
Effective source at the previous step for wbeta of the vector Poisson equation for wbeta (needed for ...
Definition: star.h:1234
Scalar press
Fluid pressure.
Definition: star.h:194
Vector w_beta
Solution for the vector part of the vector Poisson equation for .
Definition: star.h:1163
Scalar chi_comp
Scalar field generated principally by the companion star.
Definition: star.h:1139
Parameter storage.
Definition: param.h:125
void add_tbl(const Tbl &ti, int position=0)
Adds the address of a new Tbl to the list.
Definition: param.C:525
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:465
virtual void homothetie(double lambda)
Sets a new radial scale.
Definition: map_et.C:928
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
Definition: cmp_math.C:438
const Scalar & divergence(const Metric &) const
The divergence of this with respect to a Metric .
Definition: vector.C:387
Vector u_euler
Fluid 3-velocity with respect to the Eulerian observer.
Definition: star.h:207
Cmp pow(const Cmp &, int)
Power .
Definition: cmp_math.C:351
Scalar chi_auto
Scalar field generated principally by the star.
Definition: star.h:1134
Tenseur contract(const Tenseur &, int id1, int id2)
Self contraction of two indices of a Tenseur .
virtual void resize(int l, double lambda)=0
Rescales the outer boundary of one domain.
Scalar ssjm1_khi
Effective source at the previous step for the resolution of the Poisson equation for khi...
Definition: star.h:1227
double val_point(double r, double theta, double phi) const
Computes the value of the field at an arbitrary point , by means of the spectral expansion.
Definition: scalar.C:896
Scalar psi4
Conformal factor .
Definition: star.h:1158
double ray_pole() const
Coordinate radius at [r_unit].
Definition: star_global.C:281
Metric_flat flat
Flat metric defined on the mapping (Spherical components with respect to the mapping of the star) ...
Definition: star.h:1177
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition: grilles.h:469
Scalar Psi
Total conformal factor .
Definition: star.h:1152
const Tensor & derive_con(const Metric &gam) const
Returns the "contravariant" derivative of this with respect to some metric , by raising the last inde...
Definition: tensor.C:1023
Multi-domain grid.
Definition: grilles.h:279
Scalar hacar_auto
Part of the scalar generated by beta_auto, i.e.
Definition: star.h:1205
virtual void hydro_euler()
Computes the hydrodynamical quantities relative to the Eulerian observer from those in the fluid fram...
virtual void reevaluate_symy(const Map *mp_prev, int nzet, Cmp &uu) const =0
Recomputes the values of a Cmp at the collocation points after a change in the mapping.
const Base_vect_cart & get_bvect_cart() const
Returns the Cartesian basis associated with the coordinates (x,y,z) of the mapping, i.e.
Definition: map.h:809
Scalar nn
Lapse function N .
Definition: star.h:225
Vector beta_auto
Part of the shift vector generated principally by the star (Spherical components with respect to the ...
Definition: star.h:1182
Cmp abs(const Cmp &)
Absolute value.
Definition: cmp_math.C:413
void add_double(const double &x, int position=0)
Adds the the address of a new double to the list.
Definition: param.C:318
double ray_eq() const
Coordinate radius at , [r_unit].
Definition: star_global.C:111
const Scalar & dsdr() const
Returns of *this .
Definition: scalar_deriv.C:113
Scalar Psi_comp
Scalar field generated principally by the companion star.
Definition: star.h:1149
Scalar hacar_comp
Part of the scalar generated by beta_auto and beta_comp, i.e.
Definition: star.h:1211
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:474
Valeur & set_spectral_va()
Returns va (read/write version)
Definition: scalar.h:610
Scalar & set(int)
Read/write access to a component.
Definition: vector.C:302
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: tenseur.C:652
void add_cmp_mod(Cmp &ti, int position=0)
Adds the address of a new modifiable Cmp to the list.
Definition: param.C:1007
void equation_of_state()
Computes the proper baryon and energy density, as well as pressure from the enthalpy.
Definition: star.C:465
double velocity_potential(int mermax, double precis, double relax)
Computes the non-translational part of the velocity scalar potential by solving the continuity equat...
Scalar khi
Solution for the scalar part of the vector Poisson equation for .
Definition: star.h:1168
Scalar ssjm1_psi
Effective source at the previous step for the resolution of the Poisson equation for ...
Definition: star.h:1221
Scalar ener_euler
Total energy density in the Eulerian frame.
Definition: star.h:198
Tensor handling *** DEPRECATED : use class Tensor instead ***.
Definition: tenseur.h:304
void add_int_mod(int &n, int position=0)
Adds the address of a new modifiable int to the list.
Definition: param.C:388