bin_ns_bh.C

00001 /*
00002  *  Basic methods for class Bin_ns_bh
00003  *
00004  */
00005 
00006 /*
00007  *   Copyright (c) 2002  Philippe Grandclement, Keisuke Taniguchi,
00008  *              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 version 2
00014  *   as published by the Free Software Foundation.
00015  *
00016  *   LORENE is distributed in the hope that it will be useful,
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *   GNU General Public License for more details.
00020  *
00021  *   You should have received a copy of the GNU General Public License
00022  *   along with LORENE; if not, write to the Free Software
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  *
00025  */
00026 
00027 char bin_ns_bh_C[] = "$Header: /cvsroot/Lorene/C++/Source/Bin_ns_bh/bin_ns_bh.C,v 1.13 2007/04/26 14:14:59 f_limousin Exp $" ;
00028 
00029 /*
00030  * $Id: bin_ns_bh.C,v 1.13 2007/04/26 14:14:59 f_limousin Exp $
00031  * $Log: bin_ns_bh.C,v $
00032  * Revision 1.13  2007/04/26 14:14:59  f_limousin
00033  * The function fait_tkij now have default values for bound_nn and lim_nn
00034  *
00035  * Revision 1.12  2007/04/24 20:13:53  f_limousin
00036  * Implementation of Dirichlet and Neumann BC for the lapse
00037  *
00038  * Revision 1.11  2006/09/25 10:01:49  p_grandclement
00039  * Addition of N-dimensional Tbl
00040  *
00041  * Revision 1.10  2006/03/30 07:33:45  p_grandclement
00042  * *** empty log message ***
00043  *
00044  * Revision 1.9  2005/12/06 07:01:58  p_grandclement
00045  * addition of Bhole::mp scaling in affecte()
00046  *
00047  * Revision 1.8  2005/12/01 12:59:10  p_grandclement
00048  * Files for bin_ns_bh project
00049  *
00050  * Revision 1.6  2005/08/29 15:10:15  p_grandclement
00051  * Addition of things needed :
00052  *   1) For BBH with different masses
00053  *   2) Provisory files for the mixted binaries (Bh and NS) : THIS IS NOT
00054  *   WORKING YET !!!
00055  *
00056  * Revision 1.5  2004/03/25 10:28:58  j_novak
00057  * All LORENE's units are now defined in the namespace Unites (in file unites.h).
00058  *
00059  * Revision 1.4  2003/02/13 16:40:25  p_grandclement
00060  * Addition of various things for the Bin_ns_bh project, non of them being
00061  * completely tested
00062  *
00063  * Revision 1.3  2002/12/19 14:51:19  e_gourgoulhon
00064  * Added the new functions set_omega and set_x_axe
00065  *
00066  * Revision 1.2  2002/12/18 10:31:15  e_gourgoulhon
00067  * irrot : int -> bool
00068  *
00069  * Revision 1.1  2002/12/17 13:10:11  e_gourgoulhon
00070  * Methods for class Bin_ns_bh
00071  *
00072  *
00073  *
00074  *
00075  * $Header: /cvsroot/Lorene/C++/Source/Bin_ns_bh/bin_ns_bh.C,v 1.13 2007/04/26 14:14:59 f_limousin Exp $
00076  *
00077  */
00078 
00079 // C++ headers
00080 #include "headcpp.h"
00081 
00082 // C headers
00083 #include <math.h>
00084 
00085 // Lorene headers
00086 #include "map.h"
00087 #include "bhole.h"
00088 #include "bin_ns_bh.h"
00089 #include "utilitaires.h"
00090 #include "unites.h"
00091 #include "graphique.h"
00092 #include "param.h"
00093 
00094                 //--------------//
00095                 // Constructors //
00096                 //--------------//
00097 
00098 // Standard constructor
00099 // --------------------
00100 Bin_ns_bh::Bin_ns_bh(Map& mp_ns, int nzet, const Eos& eos, bool irrot_ns,
00101             Map_af& mp_bh)
00102         : ref_triad(0., "Absolute frame Cartesian basis"),
00103           star(mp_ns, nzet, true, eos, irrot_ns, ref_triad),
00104           hole(mp_bh),
00105           omega(0),
00106           x_axe(0) {
00107 
00108      // Pointers of derived quantities initialized to zero :
00109     set_der_0x0() ;
00110 }
00111 
00112 // Copy constructor
00113 // ----------------
00114 Bin_ns_bh::Bin_ns_bh(const Bin_ns_bh& bibi)
00115                 : ref_triad(0., "Absolute frame Cartesian basis"),
00116          star(bibi.star),
00117          hole(bibi.hole),
00118          omega(bibi.omega),
00119          x_axe(bibi.x_axe) {
00120 
00121      // Pointers of derived quantities initialized to zero :
00122     set_der_0x0() ;
00123 }
00124 
00125 // Constructor from a file
00126 // -----------------------
00127 Bin_ns_bh::Bin_ns_bh(Map& mp_ns, const Eos& eos, Map_af& mp_bh, FILE* fich, bool old)
00128         : ref_triad(0., "Absolute frame Cartesian basis"),
00129           star(mp_ns, eos, ref_triad, fich, old),
00130           hole(mp_bh, fich, old) {
00131 
00132     // omega and x_axe are read in the file:
00133     fread_be(&omega, sizeof(double), 1, fich) ;
00134     fread_be(&x_axe, sizeof(double), 1, fich) ;
00135 
00136     assert(hole.get_omega() == omega) ;
00137 
00138     // Pointers of derived quantities initialized to zero :
00139     set_der_0x0() ;
00140 }
00141 
00142                 //------------//
00143                 // Destructor //
00144                 //------------//
00145 
00146 Bin_ns_bh::~Bin_ns_bh(){
00147 
00148     del_deriv() ;
00149 
00150 }
00151 
00152             //----------------------------------//
00153             // Management of derived quantities //
00154             //----------------------------------//
00155 
00156 void Bin_ns_bh::del_deriv() const {
00157 
00158     if (p_mass_adm != 0x0) delete p_mass_adm ;
00159     if (p_mass_kom != 0x0) delete p_mass_kom ;
00160     if (p_angu_mom != 0x0) delete p_angu_mom ;
00161     if (p_total_ener != 0x0) delete p_total_ener ;
00162     if (p_virial != 0x0) delete p_virial ;
00163     if (p_virial_gb != 0x0) delete p_virial_gb ;
00164     if (p_virial_fus != 0x0) delete p_virial_fus ;
00165     if (p_ham_constr != 0x0) delete p_ham_constr ;
00166     if (p_mom_constr != 0x0) delete p_mom_constr ;
00167 
00168     set_der_0x0() ;
00169 }
00170 
00171 
00172 
00173 
00174 void Bin_ns_bh::set_der_0x0() const {
00175 
00176     p_mass_adm = 0x0 ;
00177     p_mass_kom = 0x0 ;
00178     p_angu_mom = 0x0 ;
00179     p_total_ener = 0x0 ;
00180     p_virial = 0x0 ;
00181     p_virial_gb = 0x0 ;
00182     p_virial_fus = 0x0 ;
00183     p_ham_constr = 0x0 ;
00184     p_mom_constr = 0x0 ;
00185 
00186 }
00187 
00188                 //--------------//
00189                 //  Assignment  //
00190                 //--------------//
00191 
00192 // Assignment to another Binaire
00193 // -----------------------------
00194 
00195 void Bin_ns_bh::operator=(const Bin_ns_bh& bibi) {
00196 
00197     assert( bibi.ref_triad == ref_triad ) ;
00198 
00199     star = bibi.star ;
00200     hole = bibi.hole ;
00201 
00202     omega = bibi.omega ;
00203     x_axe = bibi.x_axe ;
00204 
00205     // ref_triad remains unchanged
00206 
00207     del_deriv() ;  // Deletes all derived quantities
00208 
00209 }
00210 
00211 void Bin_ns_bh::set_omega(double omega_i) {
00212 
00213         omega = omega_i ;
00214     hole.set_omega(omega) ;
00215 
00216     del_deriv() ;
00217 
00218 }
00219 
00220 void Bin_ns_bh::set_x_axe(double x_axe_i) {
00221 
00222         x_axe = x_axe_i ;
00223 
00224     del_deriv() ;
00225 
00226 }
00227 
00228 double Bin_ns_bh::separation() const {
00229     return star.mp.get_ori_x() - hole.mp.get_ori_x() ;
00230 }
00231 
00232 
00233                 //--------------//
00234                 //    Outputs   //
00235                 //--------------//
00236 
00237 // Save in a file
00238 // --------------
00239 void Bin_ns_bh::sauve(FILE* fich) const {
00240 
00241     star.sauve(fich) ;
00242     hole.sauve(fich) ;
00243 
00244     fwrite_be(&omega, sizeof(double), 1, fich) ;
00245     fwrite_be(&x_axe, sizeof(double), 1, fich) ;
00246 
00247 }
00248 
00249 
00250 void Bin_ns_bh::init_auto () {
00251     
00252     // On doit faire fonction pour assurer que tout va bien sur les trucs limites
00253     Cmp filtre_ns(star.get_mp()) ;
00254     Cmp radius_ns (star.get_mp()) ;
00255     radius_ns = star.get_mp().r ;
00256     double rlim_ns = star.get_mp().val_r (0, 1, 0, 0) ;
00257     filtre_ns = 0.5 * (1 + exp(-radius_ns*radius_ns/rlim_ns/rlim_ns)) ;
00258     filtre_ns.std_base_scal() ;
00259     
00260     Cmp filtre_bh(hole.get_mp()) ;
00261     Cmp radius_bh (hole.get_mp()) ;
00262     radius_bh = hole.get_mp().r ;
00263     double rlim_bh = hole.get_mp().val_r (0, 1, 0, 0) ;
00264     filtre_bh = 0.5 * (1 + exp(-radius_bh*radius_bh/rlim_bh/rlim_bh)) ;
00265     filtre_bh.std_base_scal() ;
00266     
00267     // Facteur conforme : pas de soucis
00268     star.set_confpsi_auto() = sqrt(exp(star.get_beta_auto()()-star.get_logn_auto()()))*filtre_ns ;
00269     star.set_confpsi_auto().set_std_base() ;
00270     hole.set_psi_auto() = hole.get_psi_auto()() * filtre_bh ;
00271     hole.set_psi_auto().std_base_scal() ;
00272     
00273     // Le lapse
00274     star.set_n_auto() = sqrt(exp(star.get_beta_auto()()-star.get_logn_auto()()))*filtre_ns ;
00275     star.set_n_auto().set_std_base() ;
00276         
00277     hole.set_n_auto() = hole.get_n_auto()() * filtre_bh ;
00278     hole.set_n_auto().std_base_scal() ;
00279     
00280     // On doit assurer que le lapse tot est bien zero sur l'horizon...
00281     Cmp soustrait ((filtre_bh-0.5)*2*exp(1.)) ;
00282     int nz = hole.get_mp().get_mg()->get_nzone() ;
00283     Mtbl xa_hole (hole.get_mp().get_mg()) ;
00284     xa_hole = hole.get_mp().xa ;
00285     Mtbl ya_hole (hole.get_mp().get_mg()) ;
00286     ya_hole = hole.get_mp().ya ;
00287     Mtbl za_hole (hole.get_mp().get_mg()) ;
00288     za_hole = hole.get_mp().za ;
00289     double xa_abs, ya_abs, za_abs ;
00290     double air, tet, phi ;
00291 
00292     int np = hole.get_mp().get_mg()->get_np(0) ;
00293     int nt = hole.get_mp().get_mg()->get_nt(0) ;
00294     for (int k=0 ; k<np ; k++)
00295          for (int j=0 ; j<nt ; j++) {
00296               double val_hole = hole.n_auto()(1, k,j,0) ;
00297           xa_abs = xa_hole(1,k,j,0) ; 
00298           ya_abs = ya_hole(1,k,j,0) ;
00299           za_abs = za_hole(1,k,j,0) ;
00300           star.get_mp().convert_absolute (xa_abs, ya_abs, za_abs, air, tet, phi) ;
00301           double val_star  = star.get_n_auto()().val_point (air, tet, phi) ;
00302               for (int l=1 ; l<nz ; l++)
00303               for (int i=0 ; i<hole.get_mp().get_mg()->get_nr(l) ; i++)
00304                hole.set_n_auto().set(l,k,j,i) -= (val_star+val_hole)*soustrait(l,k,j,i) ;
00305     }
00306     hole.set_n_auto().std_base_scal() ;
00307     hole.set_n_auto().raccord(1) ;
00308 }
00309 
00310     // *********************************
00311     // Affectation to another Bin_ns_bh
00312     //**********************************
00313 
00314 void Bin_ns_bh::affecte(const Bin_ns_bh& so) {
00315         
00316     // Kinematic quantities :
00317     star.nzet = so.star.nzet ;
00318     set_omega(so.omega) ;
00319     x_axe = so.x_axe ;
00320     star.set_mp().set_ori (so.star.mp.get_ori_x(), 0., 0.) ;
00321         hole.set_mp().set_ori (so.hole.mp.get_ori_x(), 0., 0.) ;
00322     star.set_mp().set_rot_phi (so.star.mp.get_rot_phi()) ;
00323     hole.set_mp().set_rot_phi (so.hole.mp.get_rot_phi()) ;
00324     
00325     hole.set_mp().homothetie_interne (so.hole.get_rayon()/hole.rayon) ;
00326     hole.set_rayon(so.hole.get_rayon()) ;
00327     
00328     // Faut gêrer le map_et :
00329     Map_et* map_et = dynamic_cast<Map_et*>(&star.mp) ;
00330     Map_et* map_et_so = dynamic_cast<Map_et*>(&so.star.mp) ;
00331 
00332         int kmax = -1 ;
00333     int jmax = -1 ;
00334     int np = map_et->get_mg()->get_np(star.nzet-1) ;
00335     int nt = map_et->get_mg()->get_nt(star.nzet-1) ;
00336     Mtbl phi (map_et->get_mg()) ;
00337     phi = map_et->phi ;
00338     Mtbl tet (map_et->get_mg()) ;
00339     tet = map_et->tet ;
00340     double rmax = 0 ;
00341     for (int k=0 ; k<np ; k++)
00342         for (int j=0 ; j<nt ; j++) {
00343             double rcourant = map_et_so->val_r(star.nzet-1, 1, tet(0,k,j,0), phi(0,k,j,0)) ;
00344         if (rcourant > rmax) {
00345             rmax = rcourant ;
00346             kmax = k ;
00347             jmax = j ;
00348            }
00349     }
00350     
00351     double old_r = map_et->val_r(star.nzet-1, 1, tet(0,kmax,jmax,0), phi(0,kmax,jmax,0)) ;
00352     map_et->homothetie (rmax/old_r) ;
00353     
00354     star.ent.allocate_all() ;
00355     star.ent.set().import(star.nzet, so.star.ent()) ;
00356     star.ent.set_std_base() ;
00357     
00358     Param par_adapt ; 
00359     int nitermax = 100 ;  
00360     int niter_adapt ; 
00361     int adapt_flag = 1 ;  
00362     int nz_search = star.nzet + 1 ;
00363     double precis_secant = 1.e-14 ; 
00364     double alpha_r = 1. ; 
00365     double reg_map = 1. ;   
00366     Tbl ent_limit(star.nzet) ; 
00367     
00368     par_adapt.add_int(nitermax, 0) ; 
00369     par_adapt.add_int(star.nzet, 1) ;
00370     par_adapt.add_int(nz_search, 2) ;   
00371     par_adapt.add_int(adapt_flag, 3) ;
00372     par_adapt.add_int(jmax, 4) ;
00373     par_adapt.add_int(kmax, 5) ; 
00374     par_adapt.add_int_mod(niter_adapt, 0) ; 
00375     par_adapt.add_double(precis_secant, 0) ; 
00376     par_adapt.add_double(reg_map, 1)    ; 
00377     par_adapt.add_double(alpha_r, 2) ;
00378     par_adapt.add_tbl(ent_limit, 0) ;
00379         
00380     Map_et mp_prev = *map_et ;
00381     ent_limit.set_etat_qcq() ; 
00382     for (int l=0; l<star.nzet-1; l++) {
00383         int nr = map_et->get_mg()->get_nr(l) ;
00384     ent_limit.set(l) = star.ent()(l, kmax, jmax, nr-1) ; 
00385     }
00386     ent_limit.set(star.nzet-1) = 0  ; 
00387        
00388     // On adapte :
00389     map_et->adapt(star.ent(), par_adapt) ;
00390     mp_prev.homothetie(alpha_r) ;
00391     map_et->reevaluate_symy (&mp_prev, star.nzet, star.ent.set()) ;
00392         
00393     star.ent.set().import(star.nzet, so.star.ent()) ;
00394     
00395      // The BH part :
00396     // Lapse :
00397     hole.n_auto.allocate_all() ;
00398     Cmp auxi_n (so.hole.n_auto()) ;
00399     auxi_n.raccord(1) ;
00400     hole.n_auto.set().import(auxi_n) ;
00401     hole.n_auto.set().std_base_scal() ;
00402     hole.n_auto.set().raccord(1) ;
00403     
00404     // Psi :
00405     hole.psi_auto.allocate_all() ;
00406     Cmp auxi_psi (so.hole.psi_auto()) ;
00407     auxi_psi.raccord(1) ;
00408     hole.psi_auto.set().import(auxi_psi) ;
00409     hole.psi_auto.set().std_base_scal() ;
00410     hole.psi_auto.set().raccord(1) ;
00411     
00412     // Shift :
00413     hole.shift_auto.allocate_all() ;
00414     Tenseur auxi_shift (so.hole.shift_auto) ;
00415     for (int i=0 ; i<3 ; i++)
00416         auxi_shift.set(i).raccord(1) ;
00417     hole.shift_auto.set(0).import(auxi_shift(0)) ;
00418     hole.shift_auto.set(1).import(auxi_shift(1)) ;
00419     hole.shift_auto.set(2).import(auxi_shift(2)) ;
00420     hole.shift_auto.set_std_base() ;
00421     
00422     // The NS part :
00423     star.n_auto.allocate_all() ;
00424     star.n_auto.set().import(so.star.n_auto()) ;
00425     star.n_auto.set().std_base_scal() ;
00426     
00427     // Psi :
00428     star.confpsi_auto.allocate_all() ;
00429     star.confpsi_auto.set().import(so.star.confpsi_auto()) ;
00430     star.confpsi_auto.set().std_base_scal() ;
00431     // Shift :
00432     star.w_shift.allocate_all() ;
00433     star.w_shift.set(0).import(so.star.w_shift(0)) ;
00434     star.w_shift.set(1).import(so.star.w_shift(1)) ;
00435     star.w_shift.set(2).import(so.star.w_shift(2)) ;
00436     star.w_shift.set_std_base() ;
00437     star.khi_shift.allocate_all() ;
00438     star.khi_shift.set().import(so.star.khi_shift()) ;
00439     star.khi_shift.set().std_base_scal() ;
00440     star.fait_shift_auto() ;
00441     
00442     Tenseur copie_dpsi (so.star.d_psi) ;
00443     copie_dpsi.set(2).dec2_dzpuis() ;
00444     if (so.star.is_irrotational()) {
00445         star.d_psi.allocate_all() ;
00446             star.d_psi.set(0).import(star.nzet, copie_dpsi(0)) ;
00447         star.d_psi.set(1).import(star.nzet, copie_dpsi(1)) ;
00448         star.d_psi.set(2).import(star.nzet, copie_dpsi(2)) ;
00449         star.d_psi.set_std_base() ;
00450     }
00451     
00452     
00453     
00454     // Reconstruction of the fields :
00455     hole.update_metric(star) ;    
00456         star.update_metric(hole) ;
00457     star.update_metric_der_comp(hole) ;
00458     fait_tkij() ;
00459     
00460     star.kinematics(omega, x_axe) ;
00461     star.equation_of_state() ;
00462         star.hydro_euler() ;
00463 }
00464     
00465 
00466 // Printing
00467 // --------
00468 ostream& operator<<(ostream& ost, const Bin_ns_bh& bibi)  {
00469     bibi >> ost ;
00470     return ost ;
00471 }
00472 
00473 
00474 ostream& Bin_ns_bh::operator>>(ostream& ost) const {
00475 
00476   using namespace Unites ;
00477 
00478     ost << endl ;
00479     ost << "Neutron star - black hole binary system" << endl ;
00480     ost << "=======================================" << endl ;
00481     ost << endl <<
00482     "Orbital angular velocity : " << omega * f_unit << " rad/s" << endl ;
00483     ost <<
00484     "Absolute coordinate X of the rotation axis : " << x_axe / km
00485         << " km" << endl ;
00486     ost << endl << "Neutron star : " << endl ;
00487     ost <<         "============   " << endl ;
00488     ost << star << endl ;
00489 
00490     ost << "Black hole : " << endl ;
00491     ost << "==========   " << endl ;
00492     ost << "Coordinate radius of the throat : " << hole.get_rayon() / km << " km" << endl ;
00493     ost << "Absolute abscidia of the throat center : " << (hole.get_mp()).get_ori_x() / km
00494         << " km" << endl ;
00495     return ost ;
00496 }

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