eos_poly_newt.C

00001 /*
00002  * Methods of the class Eos_poly_newt.
00003  *
00004  * (see file eos.h for documentation).
00005  */
00006 
00007 /*
00008  *   Copyright (c) 2000-2001 Eric Gourgoulhon
00009  *
00010  *   This file is part of LORENE.
00011  *
00012  *   LORENE is free software; you can redistribute it and/or modify
00013  *   it under the terms of the GNU General Public License as published by
00014  *   the Free Software Foundation; either version 2 of the License, or
00015  *   (at your option) any later version.
00016  *
00017  *   LORENE is distributed in the hope that it will be useful,
00018  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *   GNU General Public License for more details.
00021  *
00022  *   You should have received a copy of the GNU General Public License
00023  *   along with LORENE; if not, write to the Free Software
00024  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  */
00027 
00028 
00029 char eos_poly_newt_C[] = "$Header: /cvsroot/Lorene/C++/Source/Eos/eos_poly_newt.C,v 1.3 2002/10/16 14:36:35 j_novak Exp $" ;
00030 
00031 /*
00032  * $Id: eos_poly_newt.C,v 1.3 2002/10/16 14:36:35 j_novak Exp $
00033  * $Log: eos_poly_newt.C,v $
00034  * Revision 1.3  2002/10/16 14:36:35  j_novak
00035  * Reorganization of #include instructions of standard C++, in order to
00036  * use experimental version 3 of gcc.
00037  *
00038  * Revision 1.2  2002/04/09 14:32:15  e_gourgoulhon
00039  * 1/ Added extra parameters in EOS computational functions (argument par)
00040  * 2/ New class MEos for multi-domain EOS
00041  *
00042  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00043  * LORENE
00044  *
00045  * Revision 2.5  2001/02/23  15:16:51  eric
00046  * Continuite en ent=0 des quantites derivees.
00047  *
00048  * Revision 2.4  2001/02/07  09:50:11  eric
00049  * Suppression de la fonction derent_ent_p.
00050  * Ajout des fonctions donnant les derivees de l'EOS:
00051  *      der_nbar_ent_p
00052  *      der_ener_ent_p
00053  *      der_press_ent_p
00054  *
00055  * Revision 2.3  2000/02/14  14:49:41  eric
00056  * Modif affichage.
00057  *
00058  * Revision 2.2  2000/02/14  14:33:33  eric
00059  * Ajout du constructeur par lecture de fichier formate.
00060  *
00061  * Revision 2.1  2000/01/21  15:18:56  eric
00062  * Ajout des operateurs de comparaison == et !=
00063  *
00064  * Revision 2.0  2000/01/18  15:14:12  eric
00065  * *** empty log message ***
00066  *
00067  *
00068  * $Header: /cvsroot/Lorene/C++/Source/Eos/eos_poly_newt.C,v 1.3 2002/10/16 14:36:35 j_novak Exp $
00069  *
00070  */
00071 
00072 // Headers C
00073 #include <stdlib.h>
00074 #include <string.h>
00075 #include <math.h>
00076 
00077 // Headers Lorene
00078 #include "eos.h"
00079 #include "cmp.h"
00080 
00081             //--------------//
00082             // Constructors //
00083             //--------------//
00084 
00085 // Standard constructor 
00086 // --------------------
00087 Eos_poly_newt::Eos_poly_newt(double gamma, double kappa) : 
00088            Eos_poly(gamma, kappa) {
00089 
00090     set_name("Newtonian polytropic EOS") ; 
00091 
00092 }  
00093 
00094   
00095 // Copy constructor
00096 // ----------------
00097 Eos_poly_newt::Eos_poly_newt(const Eos_poly_newt& eosi) : Eos_poly(eosi) {}
00098   
00099 
00100 // Constructor from a binary file
00101 // ------------------------------
00102 Eos_poly_newt::Eos_poly_newt(FILE* fich) : Eos_poly(fich) {}
00103            
00104 // Constructor from a formatted file
00105 // ---------------------------------
00106 Eos_poly_newt::Eos_poly_newt(ifstream& fich) : Eos_poly(fich) {}
00107            
00108 
00109             //--------------//
00110             //  Destructor  //
00111             //--------------//
00112 
00113 Eos_poly_newt::~Eos_poly_newt(){
00114     
00115     // does nothing
00116         
00117 }
00118             //--------------//
00119             //  Assignment  //
00120             //--------------//
00121 
00122 void Eos_poly_newt::operator=(const Eos_poly_newt& eosi) {
00123     
00124     set_name(eosi.name) ; 
00125     
00126     gam = eosi.gam ; 
00127     kap = eosi.kap ; 
00128     m_0 = eosi.m_0 ; 
00129     
00130     set_auxiliary() ; 
00131     
00132 }
00133             //------------------------//
00134             //  Comparison operators  //
00135             //------------------------//
00136 
00137 bool Eos_poly_newt::operator==(const Eos& eos_i) const {
00138     
00139     bool resu = true ; 
00140     
00141     if ( eos_i.identify() != identify() ) {
00142     cout << "The second EOS is not of type Eos_poly_newt !" << endl ; 
00143     resu = false ; 
00144     }
00145     else{
00146     
00147     const Eos_poly_newt& eos = dynamic_cast<const Eos_poly_newt&>( eos_i ) ; 
00148 
00149     if (eos.gam != gam) {
00150         cout 
00151         << "The two Eos_poly_newt have different gamma : " << gam << " <-> " 
00152         << eos.gam << endl ; 
00153         resu = false ; 
00154     }
00155 
00156     if (eos.kap != kap) {
00157         cout 
00158         << "The two Eos_poly_newt have different kappa : " << kap << " <-> " 
00159         << eos.kap << endl ; 
00160         resu = false ; 
00161     }
00162 
00163     if (eos.m_0 != m_0) {
00164         cout 
00165         << "The two Eos_poly_newt have different m_0 : " << m_0 << " <-> " 
00166         << eos.m_0 << endl ; 
00167         resu = false ; 
00168     }
00169     
00170     }
00171     
00172     return resu ; 
00173     
00174 }
00175 
00176 bool Eos_poly_newt::operator!=(const Eos& eos_i) const {
00177  
00178     return !(operator==(eos_i)) ; 
00179        
00180 }
00181 
00182 
00183             //------------//
00184             //  Outputs   //
00185             //------------//
00186 
00187 void Eos_poly_newt::sauve(FILE* fich) const {
00188 
00189     Eos_poly::sauve(fich) ; 
00190        
00191 }
00192 
00193 ostream& Eos_poly_newt::operator>>(ostream & ost) const {
00194     
00195     ost << "EOS of class Eos_poly_newt (Newtonian polytrope) : " << endl ; 
00196     ost << "   Adiabatic index gamma :      " << gam << endl ; 
00197     ost << "   Pressure coefficient kappa : " << kap << 
00198        " rho_nuc c^2 / n_nuc^gamma" << endl ; 
00199     
00200     return ost ;
00201 
00202 }
00203 
00204 
00205             //------------------------------//
00206             //    Computational routines    //
00207             //------------------------------//
00208 
00209 // Baryon density from enthalpy 
00210 //------------------------------
00211 
00212 double Eos_poly_newt::nbar_ent_p(double ent, const Param* ) const {
00213 
00214     if ( ent > double(0) ) {
00215 
00216     return pow( gam1sgamkap * ent, unsgam1 ) ;
00217     }
00218     else{
00219     return 0 ;
00220     }
00221 }
00222 
00223 // Energy density from enthalpy
00224 //------------------------------
00225 
00226 double Eos_poly_newt::ener_ent_p(double ent, const Param* ) const {
00227 
00228     if ( ent > double(0) ) {
00229 
00230     double nn = pow( gam1sgamkap * ent, unsgam1 ) ;
00231 
00232     double pp = kap * pow( nn, gam ) ;
00233 
00234     return  unsgam1 * pp + m_0 * nn ;
00235     }
00236     else{
00237     return 0 ;
00238     }
00239 }
00240 
00241 // Pressure from enthalpy
00242 //------------------------
00243 
00244 double Eos_poly_newt::press_ent_p(double ent, const Param* ) const {
00245 
00246     if ( ent > double(0) ) {
00247 
00248     double nn = pow( gam1sgamkap * ent, unsgam1 ) ;
00249 
00250     return kap * pow( nn, gam ) ;
00251 
00252     }
00253     else{
00254     return 0 ;
00255     }
00256 }
00257 
00258 // dln(n)/ln(h) from enthalpy
00259 //---------------------------
00260 
00261 double Eos_poly_newt::der_nbar_ent_p(double , const Param* ) const {
00262 
00263     return double(1) / gam1 ;
00264 
00265 }
00266 
00267 // dln(e)/ln(h) from enthalpy
00268 //---------------------------
00269 
00270 double Eos_poly_newt::der_ener_ent_p(double ent, const Param* ) const {
00271     
00272     if ( ent > double(0) ) {
00273 
00274 
00275     double nn = pow( gam1sgamkap * ( exp(ent) - double(1) ),  
00276                      unsgam1 ) ;
00277 
00278     double pp = kap * pow( nn, gam ) ;
00279 
00280     double ee =  unsgam1 * pp + m_0 * nn ; 
00281     
00282 
00283     return ( double(1) + pp / ee) / gam1 ;
00284 
00285     }
00286     else{
00287     return double(1) / gam1 ;   //  to ensure continuity at ent=0
00288     }
00289 }
00290 
00291 // dln(p)/ln(h) from enthalpy 
00292 //---------------------------
00293 
00294 double Eos_poly_newt::der_press_ent_p(double, const Param* ) const {
00295     
00296     return gam / gam1 ;
00297 
00298 }
00299 

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