star_global.C

00001 /*
00002  * Methods of class Star to compute global quantities
00003  */
00004 
00005 /*
00006  *   Copyright (c) 2004 francois Limousin
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 star_global_C[] = "$Header: /cvsroot/Lorene/C++/Source/Star/star_global.C,v 1.4 2009/10/26 10:54:33 j_novak Exp $" ;
00028 
00029 /*
00030  * $Id: star_global.C,v 1.4 2009/10/26 10:54:33 j_novak Exp $
00031  * $Log: star_global.C,v $
00032  * Revision 1.4  2009/10/26 10:54:33  j_novak
00033  * Added the case of a NONSYM base in theta.
00034  *
00035  * Revision 1.3  2007/06/21 19:55:09  k_taniguchi
00036  * Introduction of a method to compute ray_eq_3pis2().
00037  *
00038  * Revision 1.2  2004/01/20 15:20:48  f_limousin
00039  * First version
00040  *
00041  *
00042  * $Header: /cvsroot/Lorene/C++/Source/Star/star_global.C,v 1.4 2009/10/26 10:54:33 j_novak Exp $
00043  *
00044  */
00045 
00046 // Headers C
00047 #include "math.h"
00048 
00049 // Headers Lorene
00050 #include "star.h"
00051 
00052             //--------------------------//
00053             //  Stellar surface     //
00054             //--------------------------//
00055 
00056 const Itbl& Star::l_surf() const {
00057 
00058     if (p_l_surf == 0x0) {    // a new computation is required
00059     
00060     assert(p_xi_surf == 0x0) ;  // consistency check
00061     
00062     int np = mp.get_mg()->get_np(0) ;   
00063     int nt = mp.get_mg()->get_nt(0) ;   
00064     
00065     p_l_surf = new Itbl(np, nt) ;
00066     p_xi_surf = new Tbl(np, nt) ;
00067     
00068     double ent0 = 0 ;   // definition of the surface
00069     double precis = 1.e-15 ; 
00070     int nitermax = 100 ; 
00071     int niter ; 
00072     
00073     (ent.get_spectral_va()).equipot(ent0, nzet, precis, nitermax, niter, *p_l_surf, 
00074             *p_xi_surf) ; 
00075     
00076     }
00077    
00078     return *p_l_surf ; 
00079     
00080 }
00081 
00082 const Tbl& Star::xi_surf() const {
00083 
00084     if (p_xi_surf == 0x0) {    // a new computation is required
00085     
00086     assert(p_l_surf == 0x0) ;  // consistency check
00087     
00088     l_surf() ;  // the computation is done by l_surf()
00089     
00090     }
00091    
00092     return *p_xi_surf ; 
00093     
00094 }
00095 
00096 
00097             //--------------------------//
00098             //  Coordinate radii    //
00099             //--------------------------//
00100 
00101 double Star::ray_eq() const {
00102 
00103     if (p_ray_eq == 0x0) {    // a new computation is required
00104     
00105     const Mg3d& mg = *(mp.get_mg()) ;
00106     
00107     int type_t = mg.get_type_t() ; 
00108 #ifndef NDEBUG
00109     int type_p = mg.get_type_p() ; 
00110 #endif
00111     int nt = mg.get_nt(0) ;     
00112     
00113     assert( (type_t == SYM) || (type_t == NONSYM) ) ; 
00114     assert( (type_p == SYM) || (type_p == NONSYM) ) ; 
00115     int k = 0 ; 
00116     int j = (type_t == SYM ? nt-1 : nt / 2); 
00117     int l = l_surf()(k, j) ; 
00118     double xi = xi_surf()(k, j) ; 
00119     double theta = M_PI / 2 ; 
00120     double phi = 0 ; 
00121         
00122     p_ray_eq = new double( mp.val_r(l, xi, theta, phi) ) ;
00123 
00124     }
00125     
00126     return *p_ray_eq ; 
00127 
00128 } 
00129 
00130 
00131 double Star::ray_eq_pis2() const {
00132 
00133     if (p_ray_eq_pis2 == 0x0) {    // a new computation is required
00134     
00135     const Mg3d& mg = *(mp.get_mg()) ;
00136     
00137     int type_t = mg.get_type_t() ; 
00138     int type_p = mg.get_type_p() ; 
00139     int nt = mg.get_nt(0) ;     
00140     int np = mg.get_np(0) ;     
00141     
00142     int j = (type_t == SYM ? nt-1 : nt / 2); 
00143     double theta = M_PI / 2 ; 
00144     double phi = M_PI / 2 ;
00145         
00146     switch (type_p) {
00147         
00148         case SYM : {
00149         int k = np / 2  ; 
00150         int l = l_surf()(k, j) ; 
00151         double xi = xi_surf()(k, j) ; 
00152         p_ray_eq_pis2 = new double( mp.val_r(l, xi, theta, phi) ) ;
00153         break ; 
00154         }
00155         
00156         case NONSYM : {
00157         assert( np % 4 == 0 ) ; 
00158         int k = np / 4  ; 
00159         int l = l_surf()(k, j) ; 
00160         double xi = xi_surf()(k, j) ; 
00161         p_ray_eq_pis2 = new double( mp.val_r(l, xi, theta, phi) ) ;
00162         break ; 
00163         }
00164         
00165         default : {
00166         cout << "Star::ray_eq_pis2 : the case type_p = " 
00167              << type_p << " is not contemplated yet !" << endl ;
00168         abort() ; 
00169         }
00170     } 
00171 
00172     }
00173     
00174     return *p_ray_eq_pis2 ; 
00175 
00176 } 
00177 
00178 
00179 double Star::ray_eq_pi() const {
00180 
00181     if (p_ray_eq_pi == 0x0) {    // a new computation is required
00182     
00183     const Mg3d& mg = *(mp.get_mg()) ;
00184     
00185     int type_t = mg.get_type_t() ; 
00186     int type_p = mg.get_type_p() ; 
00187     int nt = mg.get_nt(0) ;     
00188     int np = mg.get_np(0) ;     
00189     
00190     assert ( ( type_t == SYM ) || ( type_t == NONSYM ) ) ;
00191     
00192     switch (type_p) {
00193         
00194         case SYM : {
00195         p_ray_eq_pi = new double( ray_eq() ) ;
00196         break ; 
00197         }       
00198         
00199         case NONSYM : {
00200         int k = np / 2  ; 
00201         int j = (type_t == SYM ? nt-1 : nt/2 ) ; 
00202         int l = l_surf()(k, j) ; 
00203         double xi = xi_surf()(k, j) ; 
00204         double theta = M_PI / 2 ; 
00205         double phi = M_PI ; 
00206         
00207         p_ray_eq_pi = new double( mp.val_r(l, xi, theta, phi) ) ;
00208         break ;
00209         }
00210         
00211         default : {
00212 
00213         cout << "Star::ray_eq_pi : the case type_p = " << type_p << endl ; 
00214         cout << " is not contemplated yet !" << endl ;
00215         abort() ; 
00216         break ; 
00217         }
00218     }
00219 
00220     }
00221     
00222     return *p_ray_eq_pi ; 
00223 
00224 } 
00225 
00226 double Star::ray_eq_3pis2() const {
00227 
00228     if (p_ray_eq_3pis2 == 0x0) {    // a new computation is required
00229     
00230     const Mg3d& mg = *(mp.get_mg()) ;
00231     
00232     int type_t = mg.get_type_t() ; 
00233     int type_p = mg.get_type_p() ; 
00234     int nt = mg.get_nt(0) ;     
00235     int np = mg.get_np(0) ;     
00236     
00237     assert( ( type_t == SYM ) || ( type_t == NONSYM ) ) ;
00238     
00239     int j = (type_t == SYM ? nt-1 : nt/2 ); 
00240     double theta = M_PI / 2 ; 
00241     double phi = 3. * M_PI / 2 ;
00242         
00243     switch (type_p) {
00244         
00245         case SYM : {
00246         p_ray_eq_3pis2 = new double( ray_eq_pis2() ) ;
00247         break ; 
00248         }
00249         
00250         case NONSYM : {
00251         assert( np % 4 == 0 ) ; 
00252         int k = 3 * np / 4  ; 
00253         int l = l_surf()(k, j) ; 
00254         double xi = xi_surf()(k, j) ; 
00255         p_ray_eq_3pis2 = new double( mp.val_r(l, xi, theta, phi) ) ;
00256         break ; 
00257         }
00258         
00259         default : {
00260         cout << "Star::ray_eq_3pis2 : the case type_p = " 
00261              << type_p << " is not implemented yet !" << endl ;
00262         abort() ; 
00263         }
00264     } 
00265     }
00266     
00267     return *p_ray_eq_3pis2 ; 
00268 
00269 } 
00270 
00271 double Star::ray_pole() const {
00272 
00273     if (p_ray_pole == 0x0) {    // a new computation is required
00274     
00275 #ifndef NDEBUG
00276     const Mg3d& mg = *(mp.get_mg()) ;
00277     int type_t = mg.get_type_t() ; 
00278 #endif  
00279     assert( (type_t == SYM) || (type_t == NONSYM) ) ;  
00280     
00281     int k = 0 ; 
00282     int j = 0 ; 
00283     int l = l_surf()(k, j) ; 
00284     double xi = xi_surf()(k, j) ; 
00285     double theta = 0 ; 
00286     double phi = 0 ; 
00287         
00288     p_ray_pole = new double( mp.val_r(l, xi, theta, phi) ) ;
00289 
00290     }
00291     
00292     return *p_ray_pole ; 
00293 
00294 } 
00295 
00296             //--------------------------//
00297             //  Baryon mass     //
00298             //--------------------------//
00299 
00300 double Star::mass_b() const {
00301 
00302     if (p_mass_b == 0x0) {    // a new computation is required
00303     
00304     cout << 
00305         "Star::mass_b : in the relativistic case, the baryon mass"
00306          << endl << 
00307         "computation cannot be performed by the base class Star !" 
00308          << endl ; 
00309     abort() ; 
00310     }
00311     
00312     return *p_mass_b ; 
00313 
00314 } 
00315         
00316             //----------------------------//
00317             //  Gravitational mass    //
00318             //----------------------------//
00319 
00320 double Star::mass_g() const {
00321 
00322     if (p_mass_g == 0x0) {    // a new computation is required
00323     
00324     cout << 
00325         "Star::mass_g : in the relativistic case, the gravitational mass"
00326          << endl << 
00327         "computation cannot be performed by the base class Star !" 
00328          << endl ; 
00329     abort() ; 
00330     }
00331     
00332     return *p_mass_g ; 
00333 
00334 } 
00335         

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