star_bhns.C

00001 /*
00002  *  Methods of class Star_bhns
00003  *
00004  *    (see file star_bhns.h for documentation).
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2005-2007 Keisuke Taniguchi
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_bhns_C[] = "$Header: /cvsroot/Lorene/C++/Source/Star_bhns/star_bhns.C,v 1.2 2008/05/15 19:12:38 k_taniguchi Exp $" ;
00029 
00030 /*
00031  * $Id: star_bhns.C,v 1.2 2008/05/15 19:12:38 k_taniguchi Exp $
00032  * $Log: star_bhns.C,v $
00033  * Revision 1.2  2008/05/15 19:12:38  k_taniguchi
00034  * Change of some parameters.
00035  *
00036  * Revision 1.1  2007/06/22 01:30:10  k_taniguchi
00037  * *** empty log message ***
00038  *
00039  *
00040  * $Header: /cvsroot/Lorene/C++/Source/Star_bhns/star_bhns.C,v 1.2 2008/05/15 19:12:38 k_taniguchi Exp $
00041  *
00042  */
00043 
00044 // C++ headers
00045 //#include <>
00046 
00047 // C headers
00048 #include <math.h>
00049 
00050 // Lorene headers
00051 #include "etoile.h"
00052 #include "star.h"
00053 #include "star_bhns.h"
00054 #include "eos.h"
00055 #include "unites.h"
00056 
00057 // Local prototype
00058 Cmp raccord_c1(const Cmp& uu, int l1) ;
00059 
00060                     //---------------------//
00061                     //     Constructor     //
00062                     //---------------------//
00063 
00064 // Standard constructor
00065 // --------------------
00066 Star_bhns::Star_bhns(Map& mp_i, int nzet_i, const Eos& eos_i, bool irrot_i)
00067       : Star(mp_i, nzet_i, eos_i),
00068     mp_aff(mp_i),
00069     irrotational(irrot_i),
00070     psi0(mp_i),
00071     d_psi(mp_i, COV, mp_i.get_bvect_cart()),
00072     wit_w(mp_i, CON, mp_i.get_bvect_cart()),
00073     loggam(mp_i),
00074     bsn(mp_i, CON, mp_i.get_bvect_cart()),
00075     gam(mp_i),
00076     gam0(mp_i),
00077     pot_centri(mp_i),
00078         lapconf_auto(mp_i),
00079     lapconf_comp(mp_i),
00080     lapconf_tot(mp_i),
00081         lapse_auto(mp_i),
00082     lapse_tot(mp_i),
00083     d_lapconf_auto(mp_i, COV, mp_i.get_bvect_cart()),
00084     d_lapconf_comp(mp_i, COV, mp_i.get_bvect_cart()),
00085     shift_auto(mp_i, CON, mp_i.get_bvect_cart()),
00086     shift_comp(mp_i, CON, mp_i.get_bvect_cart()),
00087     shift_tot(mp_i, CON, mp_i.get_bvect_cart()),
00088     d_shift_auto(mp_i, 2, CON, mp_i.get_bvect_cart()),
00089     d_shift_comp(mp_i, 2, CON, mp_i.get_bvect_cart()),
00090     confo_auto(mp_i),
00091     confo_comp(mp_i),
00092     confo_tot(mp_i),
00093     d_confo_auto(mp_i, COV, mp_i.get_bvect_cart()),
00094     d_confo_comp(mp_i, COV, mp_i.get_bvect_cart()),
00095     psi4(mp_i),
00096     taij_auto(mp_i, CON, mp_i.get_bvect_cart()),
00097     taij_quad_auto(mp_i),
00098     flat(mp_i, mp_i.get_bvect_cart()),
00099     ssjm1_lapconf(mp_i),
00100     ssjm1_confo(mp_i),
00101     ssjm1_khi(mp_i),
00102     ssjm1_wshift(mp_i, CON, mp_i.get_bvect_cart())
00103 {
00104 
00105     // Pointers of derived quantities initialized to zero :
00106     set_der_0x0() ;
00107 
00108     // Quantities defined on a spherical triad in star.C are put on
00109     // a cartesian one
00110     u_euler.change_triad(mp_i.get_bvect_cart()) ;
00111 
00112     // All quantities are initialized to zero
00113     psi0 = 0. ;
00114     psi0.std_spectral_base() ;
00115     d_psi.set_etat_zero() ;
00116     wit_w.set_etat_zero() ;
00117     loggam = 0. ;
00118     loggam.std_spectral_base() ;
00119     bsn.set_etat_zero() ;
00120     gam = 0. ;
00121     gam.std_spectral_base() ;
00122     gam0 = 0. ;
00123     gam0.std_spectral_base() ;
00124     pot_centri = 0. ;
00125     pot_centri.std_spectral_base() ;
00126 
00127     lapconf_auto = 1. ;
00128     lapconf_auto.std_spectral_base() ;
00129     lapconf_comp = 0. ;
00130     lapconf_comp.std_spectral_base() ;
00131     lapconf_tot = 1. ;
00132     lapconf_tot.std_spectral_base() ;
00133     lapse_auto = 1. ;
00134     lapse_auto.std_spectral_base() ;
00135     lapse_tot = 1. ;
00136     lapse_tot.std_spectral_base() ;
00137     d_lapconf_auto.set_etat_zero() ;
00138     d_lapconf_comp.set_etat_zero() ;
00139     shift_auto.set_etat_zero() ;
00140     shift_comp.set_etat_zero() ;
00141     shift_tot.set_etat_zero() ;
00142     d_shift_auto.set_etat_zero() ;
00143     d_shift_comp.set_etat_zero() ;
00144     confo_auto = 1. ;
00145     confo_auto.std_spectral_base() ;
00146     confo_comp = 0. ;
00147     confo_comp.std_spectral_base() ;
00148     confo_tot = 1. ;
00149     confo_tot.std_spectral_base() ;
00150     d_confo_auto.set_etat_zero() ;
00151     d_confo_comp.set_etat_zero() ;
00152     psi4 = 1. ;
00153     psi4.std_spectral_base() ;
00154 
00155     taij_auto.set_etat_zero() ;
00156     taij_quad_auto = 0. ;
00157     taij_quad_auto.std_spectral_base() ;
00158 
00159     ssjm1_lapconf = 0. ;
00160     ssjm1_lapconf.std_spectral_base() ;
00161     ssjm1_confo = 0. ;
00162     ssjm1_confo.std_spectral_base() ;
00163     ssjm1_khi = 0. ;
00164     ssjm1_khi.std_spectral_base() ;
00165     ssjm1_wshift.set_etat_zero() ;
00166 
00167 }
00168 
00169 // Copy constructor
00170 // ----------------
00171 Star_bhns::Star_bhns(const Star_bhns& star)
00172       : Star(star),
00173     mp_aff(star.mp_aff),
00174     irrotational(star.irrotational),
00175     psi0(star.psi0),
00176     d_psi(star.d_psi),
00177     wit_w(star.wit_w),
00178     loggam(star.loggam),
00179     bsn(star.bsn),
00180     gam(star.gam),
00181     gam0(star.gam0),
00182     pot_centri(star.pot_centri),
00183     lapconf_auto(star.lapconf_auto),
00184     lapconf_comp(star.lapconf_comp),
00185     lapconf_tot(star.lapconf_tot),
00186     lapse_auto(star.lapse_auto),
00187     lapse_tot(star.lapse_tot),
00188     d_lapconf_auto(star.d_lapconf_auto),
00189     d_lapconf_comp(star.d_lapconf_comp),
00190     shift_auto(star.shift_auto),
00191     shift_comp(star.shift_comp),
00192     shift_tot(star.shift_tot),
00193     d_shift_auto(star.d_shift_auto),
00194     d_shift_comp(star.d_shift_comp),
00195     confo_auto(star.confo_auto),
00196     confo_comp(star.confo_comp),
00197     confo_tot(star.confo_tot),
00198     d_confo_auto(star.d_confo_auto),
00199     d_confo_comp(star.d_confo_comp),
00200     psi4(star.psi4),
00201     taij_auto(star.taij_auto),
00202     taij_quad_auto(star.taij_quad_auto),
00203     flat(star.flat),
00204     ssjm1_lapconf(star.ssjm1_lapconf),
00205     ssjm1_confo(star.ssjm1_confo),
00206     ssjm1_khi(star.ssjm1_khi),
00207     ssjm1_wshift(star.ssjm1_wshift)
00208 {
00209     set_der_0x0() ;
00210 }
00211 
00212 // Constructor from a file
00213 // -----------------------
00214 Star_bhns::Star_bhns(Map& mp_i, const Eos& eos_i, FILE* fich)
00215       : Star(mp_i, eos_i, fich),
00216     mp_aff(mp_i),
00217     psi0(mp_i),
00218     d_psi(mp_i, COV, mp_i.get_bvect_cart()),
00219     wit_w(mp_i, CON, mp_i.get_bvect_cart()),
00220     loggam(mp_i),
00221     bsn(mp_i, CON, mp_i.get_bvect_cart()),
00222     gam(mp_i),
00223     gam0(mp_i),
00224     pot_centri(mp_i),
00225     lapconf_auto(mp_i, *(mp_i.get_mg()), fich),
00226     lapconf_comp(mp_i),
00227     lapconf_tot(mp_i),
00228     lapse_auto(mp_i),
00229     lapse_tot(mp_i),
00230     d_lapconf_auto(mp_i, COV, mp_i.get_bvect_cart()),
00231     d_lapconf_comp(mp_i, COV, mp_i.get_bvect_cart()),
00232     shift_auto(mp_i, mp_i.get_bvect_cart(), fich),
00233     shift_comp(mp_i, CON, mp_i.get_bvect_cart()),
00234     shift_tot(mp_i, CON, mp_i.get_bvect_cart()),
00235     d_shift_auto(mp_i, 2, CON, mp_i.get_bvect_cart()),
00236     d_shift_comp(mp_i, 2, CON, mp_i.get_bvect_cart()),
00237     confo_auto(mp_i, *(mp_i.get_mg()), fich),
00238     confo_comp(mp_i),
00239     confo_tot(mp_i),
00240     d_confo_auto(mp_i, COV, mp_i.get_bvect_cart()),
00241     d_confo_comp(mp_i, COV, mp_i.get_bvect_cart()),
00242     psi4(mp_i),
00243     taij_auto(mp_i, CON, mp_i.get_bvect_cart()),
00244     taij_quad_auto(mp_i),
00245     flat(mp_i, mp_i.get_bvect_cart()),
00246     ssjm1_lapconf(mp_i, *(mp_i.get_mg()), fich),
00247     ssjm1_confo(mp_i, *(mp_i.get_mg()), fich),
00248     ssjm1_khi(mp_i, *(mp_i.get_mg()), fich),
00249     ssjm1_wshift(mp_i, mp_i.get_bvect_cart(), fich)
00250 {
00251 
00252     // Star parameter
00253     fread(&irrotational, sizeof(bool), 1, fich) ;
00254 
00255     // Read of the saved fields
00256     // ------------------------
00257 
00258     if (irrotational) {
00259         Scalar gam_euler_file(mp, *(mp.get_mg()), fich) ;
00260     gam_euler = gam_euler_file ;
00261 
00262     Scalar psi0_file(mp, *(mp.get_mg()), fich) ;
00263     psi0 = psi0_file ;
00264     }
00265 
00266     // Quantities defined on a spherical triad in star.C are put on
00267     // a cartesian one
00268     u_euler.change_triad(mp_i.get_bvect_cart()) ;
00269 
00270     // All other quantities are initialized to zero
00271     // --------------------------------------------
00272 
00273     d_psi.set_etat_zero() ;
00274     wit_w.set_etat_zero() ;
00275     loggam = 0. ;
00276     loggam.std_spectral_base() ;
00277     bsn.set_etat_zero() ;
00278     gam = 0. ;
00279     gam.std_spectral_base() ;
00280     gam0 = 0. ;
00281     gam0.std_spectral_base() ;
00282     pot_centri = 0. ;
00283     pot_centri.std_spectral_base() ;
00284 
00285     lapconf_comp = 0. ;
00286     lapconf_comp.std_spectral_base() ;
00287     lapconf_tot = 1. ;
00288     lapconf_tot.std_spectral_base() ;
00289     lapse_auto = 1. ;
00290     lapse_auto.std_spectral_base() ;
00291     lapse_tot = 1. ;
00292     lapse_tot.std_spectral_base() ;
00293     d_lapconf_auto.set_etat_zero() ;
00294     d_lapconf_comp.set_etat_zero() ;
00295     shift_comp.set_etat_zero() ;
00296     shift_tot.set_etat_zero() ;
00297     d_shift_auto.set_etat_zero() ;
00298     d_shift_comp.set_etat_zero() ;
00299     confo_comp = 0. ;
00300     confo_comp.std_spectral_base() ;
00301     confo_tot = 1. ;
00302     confo_tot.std_spectral_base() ;
00303     d_confo_auto.set_etat_zero() ;
00304     d_confo_comp.set_etat_zero() ;
00305     psi4 = 1. ;
00306     psi4.std_spectral_base() ;
00307     taij_auto.set_etat_zero() ;
00308     taij_quad_auto = 0. ;
00309     taij_quad_auto.std_spectral_base() ;
00310 
00311     // Pointers of derived quantities initialized to zero
00312     // --------------------------------------------------
00313     set_der_0x0() ;
00314 
00315 }
00316 
00317 
00318                     //--------------------//
00319                     //     Destructor     //
00320                     //--------------------//
00321 
00322 Star_bhns::~Star_bhns()
00323 {
00324 
00325     del_deriv() ;
00326 
00327 }
00328 
00329 
00330                     //------------------------------------------//
00331                     //     Management of derived quantities     //
00332                     //------------------------------------------//
00333 
00334 void Star_bhns::del_deriv() const {
00335 
00336     Star::del_deriv() ;
00337 
00338     if (p_mass_b_bhns != 0x0) delete p_mass_b_bhns ;
00339     if (p_mass_g_bhns != 0x0) delete p_mass_g_bhns ;
00340 
00341     set_der_0x0() ;
00342 
00343 }
00344 
00345 void Star_bhns::set_der_0x0() const {
00346 
00347     Star::set_der_0x0() ;
00348 
00349     p_mass_b_bhns = 0x0 ;
00350     p_mass_g_bhns = 0x0 ;
00351 
00352 }
00353 
00354 
00355                     //--------------------//
00356                     //     Assignment     //
00357                     //--------------------//
00358 
00359 // Assignment to another Star_bhns
00360 // -------------------------------
00361 void Star_bhns::operator=(const Star_bhns& star) {
00362 
00363     // Assignment of quantities common to the derived classes of Star
00364     Star::operator=(star) ;
00365 
00366     // Assignment of proper quantities of class Star_bhns
00367     mp_aff = star.mp_aff ;
00368     irrotational = star.irrotational ;
00369     psi0 = star.psi0 ;
00370     d_psi = star.d_psi ;
00371     wit_w = star.wit_w ;
00372     loggam = star.loggam ;
00373     bsn = star.bsn ;
00374     gam = star.gam ;
00375     gam0 = star.gam0 ;
00376     pot_centri = star.pot_centri ;
00377     lapconf_auto = star.lapconf_auto ;
00378     lapconf_comp = star.lapconf_comp ;
00379     lapconf_tot = star.lapconf_tot ;
00380     lapse_auto = star.lapse_auto ;
00381     lapse_tot = star.lapse_tot ;
00382     d_lapconf_auto = star.d_lapconf_auto ;
00383     d_lapconf_comp = star.d_lapconf_comp ;
00384     shift_auto = star.shift_auto ;
00385     shift_comp = star.shift_comp ;
00386     shift_tot = star.shift_tot ;
00387     d_shift_auto = star.d_shift_auto ;
00388     d_shift_comp = star.d_shift_comp ;
00389     confo_auto = star.confo_auto ;
00390     confo_comp = star.confo_comp ;
00391     confo_tot = star.confo_tot ;
00392     d_confo_auto = star.d_confo_auto ;
00393     d_confo_comp = star.d_confo_comp ;
00394     psi4 = star.psi4 ;
00395     taij_auto = star.taij_auto ;
00396     taij_quad_auto = star.taij_quad_auto ;
00397     flat = star.flat ;
00398     ssjm1_lapconf = star.ssjm1_lapconf ;
00399     ssjm1_confo = star.ssjm1_confo ;
00400     ssjm1_khi = star.ssjm1_khi ;
00401     ssjm1_wshift = star.ssjm1_wshift ;
00402 
00403     del_deriv() ;
00404 
00405 }
00406 
00407 Scalar& Star_bhns::set_pot_centri() {
00408 
00409     del_deriv() ;
00410     return pot_centri ;
00411 
00412 }
00413 
00414 Scalar& Star_bhns::set_lapconf_auto() {
00415 
00416     del_deriv() ;
00417     return lapconf_auto ;
00418 
00419 }
00420 
00421 Scalar& Star_bhns::set_lapconf_comp() {
00422 
00423     del_deriv() ;
00424     return lapconf_comp ;
00425 
00426 }
00427 
00428 Vector& Star_bhns::set_shift_auto() {
00429 
00430     del_deriv() ;
00431     return shift_auto ;
00432 
00433 }
00434 
00435 Vector& Star_bhns::set_shift_comp() {
00436 
00437     del_deriv() ;
00438     return shift_comp ;
00439 
00440 }
00441 
00442 Scalar& Star_bhns::set_confo_auto() {
00443 
00444     del_deriv() ;
00445     return confo_auto ;
00446 
00447 }
00448 
00449 Scalar& Star_bhns::set_confo_comp() {
00450 
00451     del_deriv() ;
00452     return confo_comp ;
00453 
00454 }
00455 
00456 
00457                     //-----------------//
00458                     //     Outputs     //
00459                     //-----------------//
00460 
00461 // Save in a file
00462 // --------------
00463 void Star_bhns::sauve(FILE* fich) const {
00464 
00465     Star::sauve(fich) ;
00466 
00467     lapconf_auto.sauve(fich) ;
00468     shift_auto.sauve(fich) ;
00469     confo_auto.sauve(fich) ;
00470 
00471     ssjm1_lapconf.sauve(fich) ;
00472     ssjm1_confo.sauve(fich) ;
00473     ssjm1_khi.sauve(fich) ;
00474     ssjm1_wshift.sauve(fich) ;
00475 
00476     fwrite(&irrotational, sizeof(bool), 1, fich) ;
00477 
00478     if (irrotational) {
00479         gam_euler.sauve(fich) ; // required to construct d_psi from psi0
00480     psi0.sauve(fich) ;
00481     }
00482 
00483 }
00484 
00485 // Printing
00486 // --------
00487 
00488 ostream& Star_bhns::operator>>(ostream& ost) const {
00489 
00490     using namespace Unites ;
00491 
00492     //    Star::operator>>(ost) ;
00493 
00494     ost << endl ;
00495     ost << "Neutron star in a BHNS binary" << endl ;
00496     ost << "-----------------------------" << endl ;
00497 
00498     ost << "Coordinate radius R_eq_tow :           "
00499     << ray_eq_pi() / km << " [km]" << endl ;
00500     ost << "Coordinate radius R_eq_opp :           "
00501     << ray_eq() / km << " [km]" << endl ;
00502     ost << "Coordinate radius R_eq_orb :           "
00503     << ray_eq_pis2() / km << " [km]" << endl ;
00504     ost << "Coordinate radius R_pole :             "
00505     << ray_pole() / km << " [km]" << endl ;
00506     ost << "Central enthalph H_ent :               "
00507     << ent.val_grid_point(0,0,0,0) << endl ;
00508     ost << "Lapse function at the center of NS :   "
00509     << lapse_tot.val_grid_point(0,0,0,0) << endl ;
00510     ost << "Conformal factor at the center of NS : "
00511     << confo_tot.val_grid_point(0,0,0,0) << endl ;
00512     ost << "shift(1) at the center of NS :         "
00513     << shift_tot(1).val_grid_point(0,0,0,0) << endl ;
00514     ost << "shift(2) at the center of NS :         "
00515     << shift_tot(2).val_grid_point(0,0,0,0) << endl ;
00516     ost << "shift(3) at the center of NS :         "
00517     << shift_tot(3).val_grid_point(0,0,0,0) << endl ;
00518 
00519     return ost ;
00520 
00521 }
00522 
00523 
00524                     //--------------------------------//
00525                     //     Computational routines     //
00526                     //--------------------------------//
00527 
00528 void Star_bhns::fait_d_psi_bhns() {
00529 
00530     if (!irrotational) {
00531         d_psi.set_etat_nondef() ;
00532     return ;
00533     }
00534 
00535     // Specific relativistic enthalpy          ---> hhh
00536     // ------------------------------
00537 
00538     Scalar hhh = exp(ent) ;  // = 1 at the Newtonian limit
00539 
00540     // Computation of W^i = h Gamma_n B^i / N
00541     // --------------------------------------
00542 
00543     Vector www = hhh * gam_euler * bsn * psi4 ;
00544 
00545     // Constant value of W^i at the center of the star
00546     // -----------------------------------------------
00547 
00548     Vector v_orb(mp, COV, mp.get_bvect_cart()) ;
00549 
00550     for (int i=1; i<=3; i++) {
00551         v_orb.set(i) = www(i).val_grid_point(0,0,0,0) ;
00552     }
00553 
00554     // Gradient of psi
00555     // ---------------
00556 
00557     Vector d_psi0(mp, COV, mp.get_bvect_cart()) ;
00558     d_psi0.set_etat_qcq() ;
00559     for (int i=1; i<=3; i++)
00560         d_psi0.set(i) = psi0.deriv(i) ;
00561 
00562     d_psi0.std_spectral_base() ;
00563 
00564     d_psi = d_psi0 + v_orb ;
00565 
00566     for (int i=1; i<=3; i++) {
00567         if (d_psi(i).get_etat() == ETATZERO)
00568         d_psi.set(i).annule_hard() ;
00569     }
00570 
00571     // C^1 continuation of d_psi outside the star
00572     // (to ensure a smooth enthalpy field accross the stellar surface)
00573     // ---------------------------------------------------------------
00574 
00575     int nzm1 = mp.get_mg()->get_nzone() - 1 ;
00576     d_psi.annule(nzet, nzm1) ;
00577     for (int i=1; i<=3; i++) {
00578         Cmp d_psi_i (d_psi(i)) ;
00579     d_psi_i.va.set_base( d_psi0(i).get_spectral_va().base ) ;
00580     d_psi_i = raccord_c1(d_psi_i, nzet) ;
00581     d_psi.set(i) = d_psi_i ;
00582     }
00583 
00584 }
00585 
00586 
00587 void Star_bhns::relax_bhns(const Star_bhns& star_prev, double relax_ent,
00588                double relax_met, int mer, int fmer_met) {
00589 
00590     double relax_ent_jm1 = 1. - relax_ent ;
00591     double relax_met_jm1 = 1. - relax_met ;
00592 
00593     ent = relax_ent * ent + relax_ent_jm1 * star_prev.ent ;
00594 
00595     if ( (mer != 0) && (mer % fmer_met == 0)) {
00596 
00597         lapconf_auto = relax_met * lapconf_auto
00598         + relax_met_jm1 * star_prev.lapconf_auto ;
00599 
00600     shift_auto = relax_met * shift_auto
00601         + relax_met_jm1 * star_prev.shift_auto ;
00602 
00603     confo_auto = relax_met * confo_auto
00604         + relax_met_jm1 * star_prev.confo_auto ;
00605 
00606     }
00607 
00608     del_deriv() ;
00609 
00610     equation_of_state() ;
00611 
00612 }

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