etoile_global.C

00001 /*
00002  * Methods of class Etoile to compute global quantities
00003  */
00004 
00005 /*
00006  *   Copyright (c) 2000-2001 Eric Gourgoulhon
00007  *
00008  *   This file is part of LORENE.
00009  *
00010  *   LORENE is free software; you can redistribute it and/or modify
00011  *   it under the terms of the GNU General Public License as published by
00012  *   the Free Software Foundation; either version 2 of the License, or
00013  *   (at your option) any later version.
00014  *
00015  *   LORENE is distributed in the hope that it will be useful,
00016  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *   GNU General Public License for more details.
00019  *
00020  *   You should have received a copy of the GNU General Public License
00021  *   along with LORENE; if not, write to the Free Software
00022  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  */
00025 
00026 
00027 char etoile_global_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/etoile_global.C,v 1.5 2005/01/18 22:37:30 k_taniguchi Exp $" ;
00028 
00029 /*
00030  * $Id: etoile_global.C,v 1.5 2005/01/18 22:37:30 k_taniguchi Exp $
00031  * $Log: etoile_global.C,v $
00032  * Revision 1.5  2005/01/18 22:37:30  k_taniguchi
00033  * Modify the method of ray_eq(int kk).
00034  *
00035  * Revision 1.4  2005/01/18 20:35:46  k_taniguchi
00036  * Addition of ray_eq(int kk).
00037  *
00038  * Revision 1.3  2005/01/17 20:40:56  k_taniguchi
00039  * Addition of ray_eq_3pis2().
00040  *
00041  * Revision 1.2  2003/12/05 14:50:26  j_novak
00042  * To suppress some warnings...
00043  *
00044  * Revision 1.1.1.1  2001/11/20 15:19:28  e_gourgoulhon
00045  * LORENE
00046  *
00047  * Revision 1.2  2000/07/21  12:02:14  eric
00048  * Etoile::ray_eq_pi() : traitement du cas type_p = SYM.
00049  *
00050  * Revision 1.1  2000/01/28  17:18:45  eric
00051  * Initial revision
00052  *
00053  *
00054  * $Header: /cvsroot/Lorene/C++/Source/Etoile/etoile_global.C,v 1.5 2005/01/18 22:37:30 k_taniguchi Exp $
00055  *
00056  */
00057 
00058 // Headers C
00059 #include "math.h"
00060 
00061 // Headers Lorene
00062 #include "etoile.h"
00063 
00064             //--------------------------//
00065             //  Stellar surface     //
00066             //--------------------------//
00067 
00068 const Itbl& Etoile::l_surf() const {
00069 
00070     if (p_l_surf == 0x0) {    // a new computation is required
00071     
00072     assert(p_xi_surf == 0x0) ;  // consistency check
00073     
00074     int np = mp.get_mg()->get_np(0) ;   
00075     int nt = mp.get_mg()->get_nt(0) ;   
00076     
00077     p_l_surf = new Itbl(np, nt) ;
00078     p_xi_surf = new Tbl(np, nt) ;
00079     
00080     double ent0 = 0 ;   // definition of the surface
00081     double precis = 1.e-15 ; 
00082     int nitermax = 100 ; 
00083     int niter ; 
00084     
00085     (ent().va).equipot(ent0, nzet, precis, nitermax, niter, *p_l_surf, 
00086             *p_xi_surf) ; 
00087     
00088     }
00089    
00090     return *p_l_surf ; 
00091     
00092 }
00093 
00094 const Tbl& Etoile::xi_surf() const {
00095 
00096     if (p_xi_surf == 0x0) {    // a new computation is required
00097     
00098     assert(p_l_surf == 0x0) ;  // consistency check
00099     
00100     l_surf() ;  // the computation is done by l_surf()
00101     
00102     }
00103    
00104     return *p_xi_surf ; 
00105     
00106 }
00107 
00108 
00109             //--------------------------//
00110             //  Coordinate radii    //
00111             //--------------------------//
00112 
00113 double Etoile::ray_eq() const {
00114 
00115     if (p_ray_eq == 0x0) {    // a new computation is required
00116     
00117     const Mg3d& mg = *(mp.get_mg()) ;
00118     
00119     int type_t = mg.get_type_t() ; 
00120 #ifndef NDEBUG
00121     int type_p = mg.get_type_p() ; 
00122 #endif
00123     int nt = mg.get_nt(0) ;     
00124     
00125     if ( type_t == SYM ) {
00126         assert( (type_p == SYM) || (type_p == NONSYM) ) ; 
00127         int k = 0 ; 
00128         int j = nt-1 ; 
00129         int l = l_surf()(k, j) ; 
00130         double xi = xi_surf()(k, j) ; 
00131         double theta = M_PI / 2 ; 
00132         double phi = 0 ; 
00133         
00134         p_ray_eq = new double( mp.val_r(l, xi, theta, phi) ) ;
00135 
00136     }
00137     else {
00138         cout << "Etoile::ray_eq : the case type_t = " << type_t
00139          << " is not contemplated yet !" << endl ;
00140         abort() ; 
00141     }
00142 
00143     }
00144     
00145     return *p_ray_eq ; 
00146 
00147 } 
00148 
00149 
00150 double Etoile::ray_eq_pis2() const {
00151 
00152     if (p_ray_eq_pis2 == 0x0) {    // a new computation is required
00153     
00154     const Mg3d& mg = *(mp.get_mg()) ;
00155     
00156     int type_t = mg.get_type_t() ; 
00157     int type_p = mg.get_type_p() ; 
00158     int nt = mg.get_nt(0) ;     
00159     int np = mg.get_np(0) ;     
00160     
00161     if ( type_t == SYM ) {
00162     
00163         int j = nt-1 ; 
00164         double theta = M_PI / 2 ; 
00165         double phi = M_PI / 2 ;
00166         
00167         switch (type_p) {
00168         
00169         case SYM : {
00170             int k = np / 2  ; 
00171             int l = l_surf()(k, j) ; 
00172             double xi = xi_surf()(k, j) ; 
00173             p_ray_eq_pis2 = new double( mp.val_r(l, xi, theta, phi) ) ;
00174             break ; 
00175         }
00176         
00177         case NONSYM : {
00178             assert( np % 4 == 0 ) ; 
00179             int k = np / 4  ; 
00180             int l = l_surf()(k, j) ; 
00181             double xi = xi_surf()(k, j) ; 
00182             p_ray_eq_pis2 = new double( mp.val_r(l, xi, theta, phi) ) ;
00183             break ; 
00184         }
00185         
00186         default : {
00187             cout << "Etoile::ray_eq_pis2 : the case type_p = " 
00188             << type_p << " is not contemplated yet !" << endl ;
00189             abort() ; 
00190         }
00191         } 
00192 
00193     }
00194     else {
00195         cout << "Etoile::ray_eq_pis2 : the case type_t = " << type_t
00196              << " is not contemplated yet !" << endl ;
00197         abort() ; 
00198     }
00199 
00200     }
00201     
00202     return *p_ray_eq_pis2 ; 
00203 
00204 } 
00205 
00206 
00207 double Etoile::ray_eq_pi() const {
00208 
00209     if (p_ray_eq_pi == 0x0) {    // a new computation is required
00210     
00211     const Mg3d& mg = *(mp.get_mg()) ;
00212     
00213     int type_t = mg.get_type_t() ; 
00214     int type_p = mg.get_type_p() ; 
00215     int nt = mg.get_nt(0) ;     
00216     int np = mg.get_np(0) ;     
00217     
00218     if ( type_t == SYM ) {
00219 
00220         switch (type_p) {
00221         
00222         case SYM : {
00223             p_ray_eq_pi = new double( ray_eq() ) ;
00224             break ; 
00225         }       
00226         
00227         case NONSYM : {
00228             int k = np / 2  ; 
00229             int j = nt-1 ; 
00230             int l = l_surf()(k, j) ; 
00231             double xi = xi_surf()(k, j) ; 
00232             double theta = M_PI / 2 ; 
00233             double phi = M_PI ; 
00234         
00235             p_ray_eq_pi = new double( mp.val_r(l, xi, theta, phi) ) ;
00236             break ;
00237         }
00238         
00239         default : {
00240 
00241         cout << "Etoile::ray_eq_pi : the case type_t = " << type_t
00242          << " and type_p = " << type_p << endl ; 
00243         cout << " is not contemplated yet !" << endl ;
00244         abort() ; 
00245         break ; 
00246         }
00247         }
00248     }
00249 
00250     }
00251     
00252     return *p_ray_eq_pi ; 
00253 
00254 } 
00255 
00256 double Etoile::ray_eq_3pis2() const {
00257 
00258     if (p_ray_eq_3pis2 == 0x0) {    // a new computation is required
00259     
00260     const Mg3d& mg = *(mp.get_mg()) ;
00261     
00262     int type_t = mg.get_type_t() ; 
00263     int type_p = mg.get_type_p() ; 
00264     int nt = mg.get_nt(0) ;     
00265     int np = mg.get_np(0) ;     
00266     
00267     if ( type_t == SYM ) {
00268     
00269         int j = nt-1 ; 
00270         double theta = M_PI / 2 ; 
00271         double phi = 3. * M_PI / 2 ;
00272         
00273         switch (type_p) {
00274         
00275         case SYM : {
00276             p_ray_eq_3pis2 = new double( ray_eq_pis2() ) ;
00277             break ; 
00278         }
00279         
00280         case NONSYM : {
00281             assert( np % 4 == 0 ) ; 
00282             int k = 3 * np / 4  ; 
00283             int l = l_surf()(k, j) ; 
00284             double xi = xi_surf()(k, j) ; 
00285             p_ray_eq_3pis2 = new double( mp.val_r(l,xi,theta,phi) ) ;
00286             break ; 
00287         }
00288         
00289         default : {
00290             cout << "Etoile::ray_eq_3pis2 : the case type_p = " 
00291             << type_p << " is not contemplated yet !" << endl ;
00292             abort() ; 
00293         }
00294         } 
00295 
00296     }
00297     else {
00298         cout << "Etoile::ray_eq_3pis2 : the case type_t = " << type_t
00299              << " is not contemplated yet !" << endl ;
00300         abort() ; 
00301     }
00302 
00303     }
00304     
00305     return *p_ray_eq_3pis2 ; 
00306 
00307 } 
00308 
00309 double Etoile::ray_pole() const {
00310 
00311     if (p_ray_pole == 0x0) {    // a new computation is required
00312     
00313 #ifndef NDEBUG
00314     const Mg3d& mg = *(mp.get_mg()) ;
00315     int type_t = mg.get_type_t() ; 
00316 #endif  
00317     assert( (type_t == SYM) || (type_t == NONSYM) ) ;  
00318     
00319     int k = 0 ; 
00320     int j = 0 ; 
00321     int l = l_surf()(k, j) ; 
00322     double xi = xi_surf()(k, j) ; 
00323     double theta = 0 ; 
00324     double phi = 0 ; 
00325         
00326     p_ray_pole = new double( mp.val_r(l, xi, theta, phi) ) ;
00327 
00328     }
00329     
00330     return *p_ray_pole ; 
00331 
00332 } 
00333 
00334 double Etoile::ray_eq(int kk) const {
00335 
00336     const Mg3d& mg = *(mp.get_mg()) ;
00337     
00338     int type_t = mg.get_type_t() ; 
00339     int type_p = mg.get_type_p() ; 
00340     int nt = mg.get_nt(0) ;     
00341     int np = mg.get_np(0) ; 
00342 
00343     assert( kk >= 0 ) ;
00344     assert( kk < np ) ;
00345     
00346     double ray_eq_kk ;
00347     if ( type_t == SYM ) {
00348     
00349         int j = nt-1 ; 
00350     double theta = M_PI / 2 ; 
00351         
00352     switch (type_p) {
00353         
00354         case SYM : {
00355             cout << "Etoile::ray_eq(kk) : the case type_p = " 
00356              << type_p << " is not contemplated yet !" << endl ;
00357         abort() ; 
00358         }
00359         
00360         case NONSYM : {
00361             double phi = 2. * kk * M_PI / np ;
00362         int l = l_surf()(kk, j) ; 
00363         double xi = xi_surf()(kk, j) ; 
00364         ray_eq_kk = mp.val_r(l,xi,theta,phi) ;
00365         break ; 
00366         }
00367         
00368         default : {
00369             cout << "Etoile::ray_eq(kk) : the case type_p = " 
00370              << type_p << " is not contemplated yet !" << endl ;
00371         abort() ; 
00372         }
00373     } 
00374 
00375     }
00376     else {
00377         cout << "Etoile::ray_eq(kk) : the case type_t = " << type_t
00378          << " is not contemplated yet !" << endl ;
00379     abort() ; 
00380     }
00381 
00382     return ray_eq_kk ;
00383 }
00384 
00385 
00386             //--------------------------//
00387             //  Baryon mass     //
00388             //--------------------------//
00389 
00390 double Etoile::mass_b() const {
00391 
00392     if (p_mass_b == 0x0) {    // a new computation is required
00393     
00394     if (relativistic) {
00395         cout << 
00396         "Etoile::mass_b : in the relativistic case, the baryon mass"
00397         << endl << 
00398         "computation cannot be performed by the base class Etoile !" 
00399         << endl ; 
00400         abort() ; 
00401     }
00402     
00403     assert(nbar.get_etat() == ETATQCQ) ; 
00404     p_mass_b = new double( nbar().integrale() ) ;
00405 
00406     }
00407     
00408     return *p_mass_b ; 
00409 
00410 } 
00411         
00412             //----------------------------//
00413             //  Gravitational mass    //
00414             //----------------------------//
00415 
00416 double Etoile::mass_g() const {
00417 
00418     if (p_mass_g == 0x0) {    // a new computation is required
00419     
00420     if (relativistic) {
00421         cout << 
00422         "Etoile::mass_g : in the relativistic case, the gravitational mass"
00423         << endl << 
00424         "computation cannot be performed by the base class Etoile !" 
00425         << endl ; 
00426         abort() ; 
00427     }
00428     
00429     p_mass_g = new double( mass_b() ) ;   // in the Newtonian case
00430                           //  M_g = M_b
00431 
00432     }
00433     
00434     return *p_mass_g ; 
00435 
00436 } 
00437         

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