etoile_eqsph_falloff.C

00001 /*
00002  * Method of class Etoile to compute a static spherical configuration
00003  *  with the outer boundary condition at a finite radius
00004  *
00005  * (see file etoile.h for documentation).
00006  *
00007  */
00008 
00009 /*
00010  *   Copyright (c) 2004 Keisuke Taniguchi
00011  *
00012  *   This file is part of LORENE.
00013  *
00014  *   LORENE is free software; you can redistribute it and/or modify
00015  *   it under the terms of the GNU General Public License as published by
00016  *   the Free Software Foundation; either version 2 of the License, or
00017  *   (at your option) any later version.
00018  *
00019  *   LORENE is distributed in the hope that it will be useful,
00020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  *   GNU General Public License for more details.
00023  *
00024  *   You should have received a copy of the GNU General Public License
00025  *   along with LORENE; if not, write to the Free Software
00026  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  *
00028  */
00029 
00030 
00031 char etoile_eqsph_falloff_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/etoile_eqsph_falloff.C,v 1.1 2004/11/30 20:52:24 k_taniguchi Exp $" ;
00032 
00033 /*
00034  * $Id: etoile_eqsph_falloff.C,v 1.1 2004/11/30 20:52:24 k_taniguchi Exp $
00035  * $Log: etoile_eqsph_falloff.C,v $
00036  * Revision 1.1  2004/11/30 20:52:24  k_taniguchi
00037  * *** empty log message ***
00038  *
00039  *
00040  *
00041  * $Header: /cvsroot/Lorene/C++/Source/Etoile/etoile_eqsph_falloff.C,v 1.1 2004/11/30 20:52:24 k_taniguchi Exp $
00042  *
00043  */
00044 
00045 // Headers C
00046 #include "math.h"
00047 
00048 // Headers Lorene
00049 #include "etoile.h"
00050 #include "param.h"
00051 #include "unites.h"     
00052 
00053 void Etoile::equil_spher_falloff(double ent_c, double precis) {
00054     
00055     // Fundamental constants and units
00056     // -------------------------------
00057   using namespace Unites ;
00058     
00059     // Initializations
00060     // ---------------
00061     
00062     const Mg3d* mg = mp.get_mg() ; 
00063     int nz = mg->get_nzone() ;      // total number of domains
00064     
00065     // Index of the point at phi=0, theta=pi/2 at the surface of the star:
00066     int l_b = nzet - 1 ; 
00067     int i_b = mg->get_nr(l_b) - 1 ; 
00068     int j_b = mg->get_nt(l_b) - 1 ; 
00069     int k_b = 0 ; 
00070     
00071     // Value of the enthalpy defining the surface of the star
00072     double ent_b = 0 ; 
00073     
00074     // Initialization of the enthalpy field to the constant value ent_c :
00075     
00076     ent = ent_c ; 
00077     ent.annule(nzet, nz-1) ; 
00078     
00079     
00080     // Corresponding profiles of baryon density, energy density and pressure
00081     
00082     equation_of_state() ; 
00083     
00084     // Initial metric 
00085     a_car = 1 ;      // this value will remain unchanged in the Newtonian case
00086     beta_auto = 0 ;  // this value will remain unchanged in the Newtonian case
00087     
00088 
00089     // Auxiliary quantities
00090     // --------------------
00091     
00092     // Affine mapping for solving the Poisson equations
00093     Map_af mpaff(mp);   
00094         
00095     Param par_nul   ;    // Param (null) for Map_af::poisson.
00096 
00097     Tenseur ent_jm1(mp) ;   // Enthalpy at previous step
00098     ent_jm1 = 0 ; 
00099     
00100     Tenseur source(mp) ; 
00101     Tenseur logn(mp) ; 
00102     Tenseur logn_quad(mp) ; 
00103     logn = 0 ; 
00104     logn_quad = 0 ; 
00105 
00106     Cmp dlogn(mp) ; 
00107     Cmp dbeta(mp) ; 
00108     
00109     double diff_ent = 1 ;     
00110     int mermax = 200 ;      // Max number of iterations
00111     
00112     double alpha_r = 1 ; 
00113     int k_falloff = 1 ;
00114 
00115     //=========================================================================
00116     //          Start of iteration
00117     //=========================================================================
00118 
00119     for(int mer=0 ; (diff_ent > precis) && (mer<mermax) ; mer++ ) {
00120 
00121     cout << "-----------------------------------------------" << endl ;
00122     cout << "step: " << mer << endl ;
00123     cout << "alpha_r: " << alpha_r << endl ;
00124     cout << "diff_ent = " << diff_ent << endl ;    
00125 
00126     //-----------------------------------------------------
00127     // Resolution of Poisson equation for ln(N)
00128     //-----------------------------------------------------
00129 
00130     // Matter part of ln(N)
00131     // --------------------
00132     if (relativistic) {
00133         source = a_car * (ener + 3*press) ;
00134     }
00135     else {
00136         source = nbar ; 
00137     }
00138     
00139     (source.set()).set_dzpuis(4) ; 
00140     
00141     source.set_std_base() ;     // Sets the standard spectral bases. 
00142     
00143     logn_auto.set_etat_qcq() ; 
00144 
00145     mpaff.poisson_falloff(source(), par_nul, logn_auto.set(), k_falloff) ; 
00146 
00147     // NB: at this stage logn_auto is in machine units, not in c^2
00148 
00149     // Quadratic part of ln(N)
00150     // -----------------------
00151 
00152     if (relativistic) {
00153         
00154         mpaff.dsdr(logn(), dlogn) ; 
00155         mpaff.dsdr(beta_auto(), dbeta) ; 
00156         
00157         source = - dlogn * dbeta ; 
00158               
00159         logn_quad.set_etat_qcq() ; 
00160         
00161         mpaff.poisson_falloff(source(), par_nul, logn_quad.set(),
00162                   k_falloff) ; 
00163                 
00164     }
00165 
00166     //-----------------------------------------------------
00167     // Computation of the new radial scale
00168     //-----------------------------------------------------
00169 
00170     // alpha_r (r = alpha_r r') is determined so that the enthalpy
00171     // takes the requested value ent_b at the stellar surface
00172     
00173     double nu_mat0_b  = logn_auto()(l_b, k_b, j_b, i_b) ; 
00174     double nu_mat0_c  = logn_auto()(0, 0, 0, 0) ; 
00175 
00176     double nu_quad0_b  = logn_quad()(l_b, k_b, j_b, i_b) ; 
00177     double nu_quad0_c  = logn_quad()(0, 0, 0, 0) ; 
00178 
00179     double alpha_r2 = ( ent_c - ent_b - nu_quad0_b + nu_quad0_c )
00180                 / ( qpig*(nu_mat0_b - nu_mat0_c) ) ;
00181 
00182     alpha_r = sqrt(alpha_r2) ;
00183     
00184     // New radial scale
00185     mpaff.homothetie( alpha_r ) ; 
00186 
00187     //--------------------
00188     // First integral
00189     //--------------------
00190 
00191     // Gravitation potential in units c^2 :
00192     logn_auto = alpha_r2*qpig * logn_auto ;
00193     logn = logn_auto + logn_quad ;
00194 
00195     // Enthalpy in all space
00196     double logn_c = logn()(0, 0, 0, 0) ;
00197     ent = ent_c - logn() + logn_c ;
00198 
00199     //---------------------
00200     // Equation of state
00201     //---------------------
00202     
00203     equation_of_state() ; 
00204     
00205     if (relativistic) {
00206         
00207         //----------------------------
00208         // Equation for beta = ln(AN)
00209         //----------------------------
00210         
00211         mpaff.dsdr(logn(), dlogn) ; 
00212         mpaff.dsdr(beta_auto(), dbeta) ; 
00213         
00214         source = 3 * qpig * a_car * press ;
00215         
00216         source = source() 
00217              - 0.5 * (  dlogn * dlogn + dbeta * dbeta ) ;
00218     
00219         source.set_std_base() ;   // Sets the standard spectral bases. 
00220 
00221         beta_auto.set_etat_qcq() ; 
00222              
00223         mpaff.poisson_falloff(source(), par_nul, beta_auto.set(),
00224                   k_falloff) ; 
00225         
00226 
00227         // Metric coefficient A^2 update
00228         
00229         a_car = exp(2*(beta_auto - logn)) ;
00230         
00231     }
00232     
00233     // Relative difference with enthalpy at the previous step
00234     // ------------------------------------------------------
00235     
00236     diff_ent = norme( diffrel(ent(), ent_jm1()) ) / nzet ; 
00237 
00238     // Next step
00239     // ---------
00240     
00241     ent_jm1 = ent ; 
00242 
00243 
00244     }  // End of iteration loop 
00245     
00246     //=========================================================================
00247     //          End of iteration
00248     //=========================================================================
00249 
00250 
00251     // The mapping is transfered to that of the star:
00252     // ----------------------------------------------
00253     mp = mpaff ; 
00254     
00255     
00256     // Sets value to all the Tenseur's of the star
00257     // -------------------------------------------
00258     
00259     // ... hydro 
00260     ent.annule(nzet, nz-1) ;    // enthalpy set to zero at the exterior of 
00261                 // the star
00262     ener_euler = ener ; 
00263     s_euler = 3 * press ;
00264     gam_euler = 1 ;  
00265     u_euler = 0 ; 
00266     
00267     // ... metric
00268     nnn = exp( unsurc2 * logn ) ; 
00269     nnn.set_std_base() ;
00270     shift = 0 ; 
00271     a_car.set_std_base() ;
00272 
00273     // Info printing
00274     // -------------
00275     
00276     cout << endl 
00277      << "Characteristics of the star obtained by Etoile::equil_spher_falloff : " 
00278      << endl 
00279      << "-------------------------------------------------------------------" 
00280      << endl ; 
00281 
00282     double ray = mp.val_r(l_b, 1., M_PI/2., 0) ; 
00283     cout << "Coordinate radius  :       " << ray / km << " km" << endl ; 
00284 
00285     double rcirc = ray * sqrt( a_car()(l_b, k_b, j_b, i_b) ) ; 
00286     
00287     double compact = qpig/(4.*M_PI) * mass_g() / rcirc ; 
00288 
00289     cout << "Circumferential radius R : " << rcirc/km  << " km" << endl ;
00290     cout << "Baryon mass :       " << mass_b()/msol << " Mo" << endl ;
00291     cout << "Gravitational mass M :  " << mass_g()/msol << " Mo" << endl ;
00292     cout << "Compacity parameter GM/(c^2 R) : " << compact << endl ;
00293 
00294 
00295     //-----------------
00296     // Virial theorem
00297     //-----------------
00298     
00299     //... Pressure term
00300 
00301     source = qpig * a_car * sqrt(a_car) * s_euler ; 
00302     source.set_std_base() ;     
00303     double vir_mat = source().integrale() ; 
00304     
00305     //... Gravitational term
00306 
00307     Cmp tmp = beta_auto() - logn() ; 
00308 
00309     source =  - ( logn().dsdr() * logn().dsdr() 
00310               - 0.5 * tmp.dsdr() * tmp.dsdr() ) 
00311             * sqrt(a_car())  ; 
00312 
00313     source.set_std_base() ;
00314 
00315     double vir_grav = source().integrale() ;
00316 
00317     //... Relative error on the virial identity GRV3
00318     
00319     double grv3 = ( vir_mat + vir_grav ) / vir_mat ;
00320 
00321     cout << "Virial theorem GRV3 : " << endl ; 
00322     cout << "     3P term    : " << vir_mat << endl ; 
00323     cout << "     grav. term : " << vir_grav << endl ; 
00324     cout << "     relative error : " << grv3 << endl ; 
00325     
00326 }

Generated on Tue Feb 7 01:35:17 2012 for LORENE by  doxygen 1.4.6