star_rot_dirac.C

00001 /*
00002  *  Methods of class Star_rot_Dirac
00003  *
00004  *    (see file star_rot_dirac.h for documentation).
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2005  Lap-Ming Lin & Jerome Novak
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 version 2
00015  *   as published by the Free Software Foundation.
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 char star_rot_dirac_C[] = "$Header: /cvsroot/Lorene/C++/Source/Star/star_rot_dirac.C,v 1.7 2008/05/30 08:27:38 j_novak Exp $" ;
00029 
00030 /*
00031  * $Id: star_rot_dirac.C,v 1.7 2008/05/30 08:27:38 j_novak Exp $
00032  * $Log: star_rot_dirac.C,v $
00033  * Revision 1.7  2008/05/30 08:27:38  j_novak
00034  * New global quantities rp_circ and ellipt (circumferential polar coordinate and
00035  * ellipticity).
00036  *
00037  * Revision 1.6  2007/11/06 16:23:59  j_novak
00038  * Added the flag spectral_filter giving the order of possible spectral filtering
00039  * of the hydro sources of metric equations (some members *_euler). The filtering
00040  * is done in strot_dirac_hydro, if this flag is non-zero.
00041  *
00042  * Revision 1.5  2007/11/06 10:15:19  j_novak
00043  * Change the order of updates in the constructor from a file, to avoid
00044  * inconsistencies.
00045  *
00046  * Revision 1.4  2007/10/30 16:55:23  j_novak
00047  * Completed the input/ouput to a file
00048  *
00049  * Revision 1.3  2005/02/09 13:37:37  lm_lin
00050  *
00051  * Add pointers p_tsw, p_aplat, and p_r_circ; add more screen output
00052  * information.
00053  *
00054  * Revision 1.2  2005/02/02 09:22:29  lm_lin
00055  *
00056  * Add the GRV3 error to screen output
00057  *
00058  * Revision 1.1  2005/01/31 08:51:48  j_novak
00059  * New files for rotating stars in Dirac gauge (still under developement).
00060  *
00061  *
00062  * $Header: /cvsroot/Lorene/C++/Source/Star/star_rot_dirac.C,v 1.7 2008/05/30 08:27:38 j_novak Exp $
00063  *
00064  */
00065 
00066 
00067 // C headers
00068 #include <math.h>
00069 #include <assert.h>
00070 
00071 // Lorene headers
00072 #include "star_rot_dirac.h"
00073 #include "unites.h" 
00074 #include "utilitaires.h"
00075 
00076 
00077                    //--------------//
00078                    // Constructors //
00079                    //--------------//
00080 
00081 // Standard constructor
00082 //-------------------------
00083 Star_rot_Dirac::Star_rot_Dirac(Map& mpi, int nzet_i, const Eos& eos_i, int filter)
00084                    : Star(mpi, nzet_i, eos_i),
00085              spectral_filter(filter),
00086              psi4(mpi),
00087              psi2(mpi),
00088              qqq(mpi),
00089              ln_psi(mpi),
00090              j_euler(mpi, CON, mpi.get_bvect_spher()),
00091              v2(mpi),
00092              flat(mpi.flat_met_spher()),
00093              tgamma(flat),
00094              aa(mpi, CON, mpi.get_bvect_spher()),
00095              taa(mpi, COV, mpi.get_bvect_spher()),
00096              aa_quad(mpi),
00097              hh(mpi, mpi.get_bvect_spher(), flat) 
00098 {
00099     assert (spectral_filter>=0) ;
00100     assert (spectral_filter<1000) ;
00101 
00102   // Initialization to a static state
00103   omega = 0 ;
00104   v2 = 0 ;
00105 
00106   // All the matter quantities are initialized to zero
00107   j_euler.set_etat_zero() ;
00108 
00109   // Initialization to a flat case
00110   psi4 = 1 ;
00111   psi2 = 1 ;
00112   qqq = 1 ;
00113   ln_psi = 0 ;
00114   aa.set_etat_zero() ;
00115   taa.set_etat_zero() ;
00116   aa_quad = 0 ;
00117   hh.set_etat_zero() ;
00118 
00119   // Pointers of derived quantities initialized to zero : 
00120   set_der_0x0() ;
00121 
00122 } 
00123              
00124 
00125 // Copy constructor
00126 //-----------------
00127 Star_rot_Dirac::Star_rot_Dirac(const Star_rot_Dirac& star)
00128                    : Star(star),
00129              spectral_filter(star.spectral_filter),
00130              psi4(star.psi4),
00131              psi2(star.psi2),
00132              qqq(star.qqq),
00133              ln_psi(star.ln_psi),
00134              j_euler(star.j_euler),
00135              v2(star.v2),
00136              flat(star.flat),
00137              tgamma(star.tgamma),
00138              aa(star.aa),
00139              taa(star.taa),
00140              aa_quad(star.aa_quad),
00141              hh(star.hh)
00142 {
00143 
00144   omega = star.omega ;
00145 
00146   // Pointers of derived quantities initialized to zero : 
00147   set_der_0x0() ;
00148 
00149 }
00150 
00151 
00152 //Constructor from a file 
00153 //------------------------
00154 Star_rot_Dirac::Star_rot_Dirac(Map& mpi, const Eos& eos_i, FILE* fich)
00155                   : Star(mpi, eos_i, fich),
00156             psi4(mpi),
00157             psi2(mpi),
00158             qqq(mpi, *(mpi.get_mg()), fich),
00159             ln_psi(mpi),
00160             j_euler(mpi, CON, mpi.get_bvect_spher()),
00161             v2(mpi),
00162             flat(mpi.flat_met_spher()),
00163             tgamma(flat),
00164             aa(mpi, CON, mpi.get_bvect_spher()),
00165             taa(mpi, COV, mpi.get_bvect_spher()),
00166             aa_quad(mpi),
00167             hh(mpi, mpi.get_bvect_spher(), flat, fich)
00168 {
00169 
00170   // Pointers of derived quantities initialized to zero 
00171   //----------------------------------------------------
00172   set_der_0x0() ;
00173 
00174   fread_be(&spectral_filter, sizeof(int), 1, fich) ;
00175 
00176   // Metric fields are read in the file:
00177   fread_be(&omega, sizeof(double), 1, fich) ;
00178   Vector shift_tmp(mpi, mpi.get_bvect_spher(), fich) ;
00179   beta = shift_tmp ;
00180 
00181   update_metric() ;
00182 
00183   equation_of_state() ;
00184 
00185   hydro_euler() ;
00186 
00187 
00188 
00189 
00190 }
00191 
00192 
00193                       //------------// 
00194                       // Destructor //
00195                       //------------//
00196 
00197 Star_rot_Dirac::~Star_rot_Dirac(){
00198 
00199   Star_rot_Dirac::del_deriv() ;
00200   
00201 }
00202 
00203 
00204                //----------------------------------//
00205                // Management of derived quantities //
00206                //----------------------------------//
00207 
00208 void Star_rot_Dirac::del_deriv() const {
00209 
00210        if (p_angu_mom != 0x0) delete p_angu_mom ;
00211        if (p_grv2 != 0x0) delete p_grv2 ;
00212        if (p_grv3 != 0x0) delete p_grv3 ;
00213        if (p_tsw != 0x0) delete p_tsw ;
00214        if (p_r_circ != 0x0) delete p_r_circ ;
00215        if (p_rp_circ != 0x0) delete p_rp_circ ;
00216 
00217        set_der_0x0() ;
00218 
00219        Star::del_deriv() ;
00220 
00221 }
00222 
00223 
00224 void Star_rot_Dirac::set_der_0x0() const {
00225 
00226        p_angu_mom = 0x0 ;
00227        p_grv2 = 0x0 ;
00228        p_grv3 = 0x0 ;
00229        p_tsw = 0x0 ;
00230        p_r_circ = 0x0 ;
00231        p_rp_circ = 0x0 ;
00232 
00233 }
00234 
00235 
00236 void Star_rot_Dirac::del_hydro_euler() {
00237 
00238     j_euler.set_etat_nondef() ;
00239     v2.set_etat_nondef() ;
00240 
00241     del_deriv() ;
00242     
00243     Star::del_hydro_euler() ;
00244 
00245 }
00246 
00247 
00248 
00249                     //---------------//
00250                     //  Assignment   //
00251                     //---------------//   
00252 
00253 // Assignment to another Star_rot_Dirac
00254 // ------------------------------------
00255 
00256 void Star_rot_Dirac::operator=(const Star_rot_Dirac& star) {
00257 
00258      // Assignment of quantities common to all the derived classes of Star
00259      Star::operator=(star) ;
00260 
00261      // Assignment of proper quantities of class Star_rot_Dirac
00262      spectral_filter = star.spectral_filter ;
00263      omega = star.omega ;
00264      psi4 = star.psi4 ;
00265      psi2 = star.psi2 ;
00266      qqq = star.qqq ;
00267      ln_psi = star.ln_psi ;
00268      j_euler = star.j_euler ;
00269      v2 = star.v2 ;
00270      tgamma = star.tgamma ;
00271      aa = star.aa ;
00272      aa_quad = star.aa_quad ;
00273      hh = star.hh ;
00274 
00275      assert(&flat == &star.flat) ;
00276 
00277      del_deriv() ;    // Deletes all derived quantities
00278 
00279 }
00280      
00281 
00282                       //-----------//
00283                       //  Outputs  //
00284                       //-----------//
00285 
00286 // Save in a file
00287 // --------------
00288 
00289 void Star_rot_Dirac::sauve(FILE* fich) const {
00290 
00291       Star::sauve(fich) ;
00292 
00293       qqq.sauve(fich) ;
00294       hh.sauve(fich) ;
00295       fwrite_be(&spectral_filter, sizeof(int), 1, fich) ;
00296       fwrite_be(&omega, sizeof(double), 1, fich) ;
00297       beta.sauve(fich) ;
00298 
00299 }
00300 
00301 
00302 // Printing
00303 // ---------
00304 
00305 ostream& Star_rot_Dirac::operator>>(ostream& ost) const {
00306 
00307   using namespace Unites ;
00308 
00309      Star::operator>>(ost) ;
00310 
00311      ost << "Rotating star in Dirac gauge" << endl ;
00312 
00313      // Only uniformly rotating star for the moment....
00314      ost << endl ;
00315      ost << "Uniformly rotating star" << endl ;
00316      ost << "-----------------------" << endl ;
00317      if (spectral_filter > 0)
00318      ost << "hydro sources of equations are filtered\n"
00319          << "with " << spectral_filter << "-order exponential filter" << endl ;
00320 
00321      double freq = omega/ (2.*M_PI) ;
00322      ost << "Omega : " << omega * f_unit
00323          << " rad/s    f : " << freq * f_unit << " Hz" << endl ;
00324      ost << "Rotation period : " << 1000. / (freq * f_unit) << " ms"
00325          << endl ;
00326 
00327      ost << "Error on the virial identity GRV2 : " << endl ;
00328      ost << "GRV2 = " << grv2() << endl ;
00329      ost << "Error on the virial identity GRV3 : " << endl ;
00330      ost << "GRV3 = " << grv3() << endl ;
00331 
00332      ost << "Angular momentum J :    "
00333          << angu_mom()/( qpig / (4*M_PI) *msol*msol) << " G M_sol^2 / c"
00334          << endl ;
00335      ost << "c J / (G M^2) :         "
00336          << angu_mom()/( qpig / (4*M_PI) * pow(mass_g(), 2.) ) << endl ;
00337 
00338      if (omega != 0.) {
00339        double mom_iner = angu_mom() / omega ; 
00340        double mom_iner_38si = mom_iner * rho_unit * (pow(r_unit, double(5.)) 
00341          / double(1.e38) ) ; 
00342        ost << "Moment of inertia:       " << mom_iner_38si << " 10^38 kg m^2"
00343        << endl ; 
00344      }
00345 
00346      ost << "Ratio T/W :              " << tsw() << endl ;
00347      ost << "Circumferential equatorial radius R_circ :     "
00348      << r_circ()/km << " km" << endl ;
00349      ost << "Circumferential polar radius Rp_circ :     "
00350      << rp_circ()/km << " km" << endl ;
00351      ost << "Coordinate equatorial radius r_eq : " << ray_eq()/km << " km"
00352      << endl ;
00353      ost << "Flattening r_pole/r_eq :  " << aplat() << endl ;
00354      ost << "Ellipticity sqrt(1-(Rp_circ/R_circ)^2) :  " << ellipt() << endl ;
00355 
00356      double compact = qpig/(4.*M_PI) * mass_g() / r_circ() ;
00357      ost << "Compaction parameter M_g / R_circ : " << compact << endl ; 
00358      
00359 
00360      // More to come here.....
00361 
00362      return ost ;
00363 
00364 }

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