et_rot_diff.C

00001 /*
00002  * Methods for class Et_rot_diff.
00003  *
00004  * (see file et_rot_diff.h for documentation).
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2001 Eric Gourgoulhon
00010  *
00011  *   This file is part of LORENE.
00012  *
00013  *   LORENE is free software; you can redistribute it and/or modify
00014  *   it under the terms of the GNU General Public License as published by
00015  *   the Free Software Foundation; either version 2 of the License, or
00016  *   (at your option) any later version.
00017  *
00018  *   LORENE is distributed in the hope that it will be useful,
00019  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *   GNU General Public License for more details.
00022  *
00023  *   You should have received a copy of the GNU General Public License
00024  *   along with LORENE; if not, write to the Free Software
00025  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  *
00027  */
00028 
00029 
00030 char et_rot_diff_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/et_rot_diff.C,v 1.3 2004/03/25 10:29:05 j_novak Exp $" ;
00031 
00032 /*
00033  * $Id: et_rot_diff.C,v 1.3 2004/03/25 10:29:05 j_novak Exp $
00034  * $Log: et_rot_diff.C,v $
00035  * Revision 1.3  2004/03/25 10:29:05  j_novak
00036  * All LORENE's units are now defined in the namespace Unites (in file unites.h).
00037  *
00038  * Revision 1.2  2001/12/04 21:27:53  e_gourgoulhon
00039  *
00040  * All writing/reading to a binary file are now performed according to
00041  * the big endian convention, whatever the system is big endian or
00042  * small endian, thanks to the functions fwrite_be and fread_be
00043  *
00044  * Revision 1.1.1.1  2001/11/20 15:19:28  e_gourgoulhon
00045  * LORENE
00046  *
00047  * Revision 1.3  2001/10/25  09:20:54  eric
00048  * Ajout de la fonction virtuelle display_poly.
00049  * Affichage de Max nbar, ener et press.
00050  *
00051  * Revision 1.2  2001/10/24  16:23:01  eric
00052  * *** empty log message ***
00053  *
00054  * Revision 1.1  2001/10/19  08:18:10  eric
00055  * Initial revision
00056  *
00057  *
00058  * $Header: /cvsroot/Lorene/C++/Source/Etoile/et_rot_diff.C,v 1.3 2004/03/25 10:29:05 j_novak Exp $
00059  *
00060  */
00061 
00062 // Headers C
00063 #include "math.h"
00064 
00065 // Headers Lorene
00066 #include "et_rot_diff.h"
00067 #include "eos.h"
00068 #include "nbr_spx.h"
00069 #include "utilitaires.h"
00070 #include "unites.h"     
00071 
00072                 //--------------//
00073                 // Constructors //
00074                 //--------------//
00075 
00076 // Standard constructor
00077 // --------------------
00078 Et_rot_diff::Et_rot_diff(Map& mp_i, int nzet_i, bool relat, const Eos& eos_i, 
00079              double (*frot_i)(double, const Tbl&), 
00080              double (*primfrot_i)(double, const Tbl&), 
00081              const Tbl& par_frot_i)
00082                : Etoile_rot(mp_i, nzet_i, relat, eos_i),
00083              frot(frot_i), 
00084              primfrot(primfrot_i), 
00085              par_frot(par_frot_i), 
00086              omega_field(mp_i), 
00087              prim_field(mp_i)
00088              {
00089 
00090     // To make sure that omega is not used
00091     omega = __infinity ; 
00092     
00093     // Initialization to a static state : 
00094     omega_field = 0 ; 
00095     prim_field = 0 ; 
00096     omega_min = 0 ;
00097     omega_max = 0 ; 
00098     
00099 } 
00100 
00101 // Copy constructor
00102 // ----------------
00103 Et_rot_diff::Et_rot_diff(const Et_rot_diff& et)
00104                : Etoile_rot(et), 
00105                  frot(et.frot), 
00106                  primfrot(et.primfrot), 
00107              par_frot(et.par_frot), 
00108              omega_field(et.omega_field), 
00109              omega_min(et.omega_min), 
00110              omega_max(et.omega_max),  
00111              prim_field(et.prim_field)
00112              {}
00113              
00114 
00115 // Constructor from a file
00116 // -----------------------
00117 Et_rot_diff::Et_rot_diff(Map& mp_i, const Eos& eos_i, FILE* fich,
00118              double (*frot_i)(double, const Tbl&), 
00119              double (*primfrot_i)(double, const Tbl&) )
00120             : Etoile_rot(mp_i, eos_i, fich),
00121               frot(frot_i), 
00122               primfrot(primfrot_i), 
00123               par_frot(fich), 
00124               omega_field(mp_i), 
00125               prim_field(mp_i)
00126              {
00127 
00128     Tenseur omega_field_file(mp, fich) ; 
00129     omega_field = omega_field_file ; 
00130     fait_prim_field() ; 
00131              
00132     // omega_min and omega_max are read in the file:     
00133     fread_be(&omega_min, sizeof(double), 1, fich) ;     
00134     fread_be(&omega_max, sizeof(double), 1, fich) ;     
00135 
00136 }
00137 
00138 
00139                 //------------//
00140                 // Destructor //
00141                 //------------//
00142 
00143 Et_rot_diff::~Et_rot_diff(){} 
00144 
00145 
00146                 //--------------//
00147                 //  Assignment  //
00148                 //--------------//
00149 
00150 // Assignment to another Et_rot_diff
00151 // ---------------------------------
00152 void Et_rot_diff::operator=(const Et_rot_diff& et) {
00153 
00154     // Assignment of quantities common to all the derived classes of Etoile_rot
00155     Etoile_rot::operator=(et) ;     
00156     
00157     // Assignment of proper quantities of class Etoile_rot
00158     frot = et.frot ; 
00159     primfrot = et.primfrot ; 
00160     par_frot = et.par_frot ; 
00161     omega_field = et.omega_field ; 
00162     prim_field = et.prim_field ; 
00163     omega_min = et.omega_min ; 
00164     omega_max = et.omega_max ; 
00165 
00166 }
00167 
00168                 //--------------//
00169                 //    Outputs   //
00170                 //--------------//
00171 
00172 // Save in a file
00173 // --------------
00174 
00175 void Et_rot_diff::sauve(FILE* fich) const {
00176     
00177     Etoile_rot::sauve(fich) ; 
00178     
00179     par_frot.sauve(fich) ; 
00180     
00181     omega_field.sauve(fich) ; 
00182     
00183     fwrite_be(&omega_min, sizeof(double), 1, fich) ;        
00184     fwrite_be(&omega_max, sizeof(double), 1, fich) ;        
00185 
00186 }
00187 
00188 
00189 // Printing
00190 // --------
00191 
00192 ostream& Et_rot_diff::operator>>(ostream& ost) const {
00193     
00194   using namespace Unites ;
00195 
00196     Etoile_rot::operator>>(ost) ; 
00197     
00198     ost << endl ; 
00199     ost << "Differentially rotating  star" << endl ; 
00200     ost << "-----------------------------" << endl ; 
00201     
00202     ost << endl << "Parameters of F(Omega) : " << endl ; 
00203     ost << par_frot << endl ; 
00204     
00205     ost << "Min, Max of Omega/(2pi) : " << omega_min / (2*M_PI) * f_unit 
00206         << " Hz,  " << omega_max / (2*M_PI) * f_unit << " Hz" << endl ; 
00207     int lsurf = nzet - 1; 
00208     int nt = mp.get_mg()->get_nt(lsurf) ; 
00209     int nr = mp.get_mg()->get_nr(lsurf) ; 
00210     ost << "Central, equatorial value of Omega:        "
00211     << omega_field()(0, 0, 0, 0) * f_unit << " rad/s,   " 
00212     << omega_field()(nzet-1, 0, nt-1, nr-1) * f_unit << " rad/s" << endl ; 
00213     
00214     ost << "Central, equatorial value of Omega/(2 Pi): "
00215     << omega_field()(0, 0, 0, 0) * f_unit / (2*M_PI) << " Hz,      " 
00216     << omega_field()(nzet-1, 0, nt-1, nr-1) * f_unit / (2*M_PI) 
00217     << " Hz" << endl ; 
00218     
00219     double nbar_max = max( max( nbar() ) ) ; 
00220     double ener_max = max( max( ener() ) ) ; 
00221     double press_max = max( max( press() ) ) ; 
00222     ost << "Max prop. bar. dens. :          " << nbar_max 
00223     << " x 0.1 fm^-3 = " << nbar_max / nbar()(0, 0, 0, 0) << " central"
00224     << endl ; 
00225     ost << "Max prop. ener. dens. (e_max) : " << ener_max
00226     << " rho_nuc c^2 = " << ener_max / ener()(0, 0, 0, 0) << " central"
00227     << endl ; 
00228     ost << "Max pressure :                  " << press_max
00229     << " rho_nuc c^2 = " << press_max / press()(0, 0, 0, 0) << " central"
00230     << endl ; 
00231    
00232     // Length scale set by the maximum energy density:
00233     double len_rho = 1. / sqrt( ggrav * ener_max ) ;
00234     ost << endl << "Value of A = par_frot(1) in units of e_max^{1/2} : " << 
00235         par_frot(1) / len_rho << endl ; 
00236     
00237     ost << "Value of A / r_eq : " << 
00238         par_frot(1) / ray_eq() << endl ; 
00239     
00240     ost << "r_p/r_eq : " << aplat() << endl ; 
00241     ost << "KEH l^2 = (c/G^2)^{2/3} J^2 e_max^{1/3} M_B^{-10/3} : " <<
00242     angu_mom() * angu_mom() / pow(len_rho, 0.6666666666666666)
00243     / pow(mass_b(), 3.3333333333333333) 
00244     / pow(ggrav, 1.3333333333333333) << endl ;
00245      
00246     ost << "M e_max^{1/2} : " << ggrav * mass_g() / len_rho << endl ; 
00247     
00248     ost << "r_eq e_max^{1/2} : " << ray_eq() / len_rho << endl ; 
00249     
00250     ost << "T/W : " << tsw() << endl ; 
00251     
00252     ost << "Omega_c / e_max^{1/2} : " << get_omega_c() * len_rho << endl ; 
00253      
00254     display_poly(ost) ; 
00255 
00256     return ost ;
00257     
00258     
00259 }
00260 
00261 // display_poly
00262 // ------------
00263 
00264 void Et_rot_diff::display_poly(ostream& ost) const {
00265 
00266   using namespace Unites ;
00267 
00268     Etoile_rot::display_poly( ost ) ; 
00269     
00270     const Eos_poly* p_eos_poly = dynamic_cast<const Eos_poly*>( &eos ) ;      
00271 
00272     if (p_eos_poly != 0x0) {
00273 
00274     double kappa = p_eos_poly->get_kap() ; 
00275     double gamma = p_eos_poly->get_gam() ;  ; 
00276 
00277     // kappa^{n/2}
00278     double kap_ns2 = pow( kappa,  0.5 /(gamma-1) ) ; 
00279     
00280     // Polytropic unit of length in terms of r_unit : 
00281     double r_poly = kap_ns2 / sqrt(ggrav) ; 
00282     
00283     // Polytropic unit of time in terms of t_unit :
00284     double t_poly = r_poly ; 
00285 
00286     // Polytropic unit of density in terms of rho_unit :
00287     double rho_poly = 1. / (ggrav * r_poly * r_poly) ;  
00288 
00289     ost.precision(10) ; 
00290     ost << "  n_max     : " << max( max( nbar() ) ) / rho_poly << endl ; 
00291     ost << "  e_max     : " << max( max( ener() ) ) / rho_poly << endl ; 
00292     ost << "  P_min     : " << 2.*M_PI / omega_max / t_poly << endl ; 
00293     ost << "  P_max     : " << 2.*M_PI / omega_min / t_poly << endl ; 
00294     
00295     int lsurf = nzet - 1; 
00296     int nt = mp.get_mg()->get_nt(lsurf) ; 
00297     int nr = mp.get_mg()->get_nr(lsurf) ; 
00298     ost << "  P_eq      : " << 2.*M_PI / 
00299         omega_field()(nzet-1, 0, nt-1, nr-1) / t_poly << endl ; 
00300         
00301     }
00302 
00303 }
00304 
00305 
00306 
00307         //-----------------------//
00308         //  Miscellaneous    //
00309         //-----------------------//
00310 
00311 double Et_rot_diff::funct_omega(double omeg) const {
00312 
00313     return frot(omeg, par_frot) ;
00314     
00315 }
00316 
00317 double Et_rot_diff::prim_funct_omega(double omeg) const {
00318 
00319     return primfrot(omeg, par_frot) ;
00320     
00321 }
00322 
00323 double Et_rot_diff::get_omega_c() const {
00324     
00325     return omega_field()(0, 0, 0, 0) ; 
00326     
00327 }
00328 
00329 
00330         

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