binaire_global.C

00001 /*
00002  * Methods of class Binaire to compute global quantities
00003  *
00004  * (see file binaire.h for documentation)
00005  */
00006 
00007 /*
00008  *   Copyright (c) 2000-2001 Eric Gourgoulhon
00009  *   Copyright (c) 2000-2001 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 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 binaire_global_C[] = "$Header: /cvsroot/Lorene/C++/Source/Binaire/binaire_global.C,v 1.6 2004/03/25 10:28:59 j_novak Exp $" ;
00031 
00032 /*
00033  * $Id: binaire_global.C,v 1.6 2004/03/25 10:28:59 j_novak Exp $
00034  * $Log: binaire_global.C,v $
00035  * Revision 1.6  2004/03/25 10:28:59  j_novak
00036  * All LORENE's units are now defined in the namespace Unites (in file unites.h).
00037  *
00038  * Revision 1.5  2003/09/08 09:32:40  e_gourgoulhon
00039  * Corrected a problem of spectral basis initialisation in virial_gb() and
00040  * virial_fus(): introduced the new variable a1.
00041  *
00042  * Revision 1.4  2001/12/20 14:18:40  k_taniguchi
00043  * Addition of the Komar mass, the virial error by Gourgoulhon and Bonazzola, and the virial error by Friedman, Uryu, and Shibata.
00044  *
00045  * Revision 1.3  2001/12/16 16:21:38  e_gourgoulhon
00046  * #include "unites.h" is now local to Binaire::mass_adm(), in order
00047  * not to make Lorene's units global variables.
00048  *
00049  * Revision 1.2  2001/12/14 09:45:14  k_taniguchi
00050  * Correction of missing 16 pi G factor in the ADM mass
00051  *
00052  * Revision 1.1.1.1  2001/11/20 15:19:30  e_gourgoulhon
00053  * LORENE
00054  *
00055  * Revision 2.3  2000/03/08  12:26:33  eric
00056  * Ajout de l'appel a std_base_scal() sur le Cmp source dans le cas
00057  * relativiste (masse ADM).
00058  *
00059  * Revision 2.2  2000/02/23  11:26:00  keisuke
00060  * Changement de "virial relation".
00061  *
00062  * Revision 2.1  2000/02/18  15:48:55  eric
00063  * *** empty log message ***
00064  *
00065  * Revision 2.0  2000/02/18  14:53:09  eric
00066  * *** empty log message ***
00067  *
00068  *
00069  * $Header: /cvsroot/Lorene/C++/Source/Binaire/binaire_global.C,v 1.6 2004/03/25 10:28:59 j_novak Exp $
00070  *
00071  */
00072 
00073 // Headers C
00074 #include "math.h"
00075 
00076 // Headers Lorene
00077 #include "binaire.h"
00078 #include "unites.h"
00079 
00080             //---------------------------------//
00081             //      ADM mass           //
00082             //---------------------------------//
00083 
00084 double Binaire::mass_adm() const {
00085   using namespace Unites ;
00086     
00087     if (p_mass_adm == 0x0) {        // a new computation is requireed
00088     
00089     p_mass_adm = new double ; 
00090         
00091     if (star1.is_relativistic()) {  // Relativistic case
00092                     // -----------------
00093         assert( star2.is_relativistic() ) ;
00094         
00095         *p_mass_adm = 0 ; 
00096         
00097         for (int i=0; i<=1; i++) {      // loop on the stars
00098         
00099         const Cmp& a2 = (et[i]->get_a_car())() ; 
00100         const Cmp& ee = (et[i]->get_ener_euler())() ; 
00101         const Cmp& ak2_auto = (et[i]->get_akcar_auto())() ;
00102         const Cmp& ak2_comp = (et[i]->get_akcar_comp())() ;
00103         
00104         Cmp source = pow(a2, 1.25) * ee 
00105           + pow(a2, 0.25) * (ak2_auto + ak2_comp) / (4.*qpig) ; 
00106                
00107         source.std_base_scal() ; 
00108                
00109         *p_mass_adm += source.integrale() ; 
00110         
00111         }    
00112     
00113     }
00114     else {      // Newtonian case 
00115             // --------------
00116             
00117         *p_mass_adm = star1.mass_b() + star2.mass_b() ; 
00118         
00119     }
00120         
00121     }   // End of the case where a new computation was necessary
00122     
00123     return *p_mass_adm ; 
00124     
00125 }
00126 
00127 
00128             //---------------------------------//
00129             //      Komar mass         //
00130             //---------------------------------//
00131 
00132 double Binaire::mass_kom() const {
00133     
00134   using namespace Unites ;
00135 
00136     if (p_mass_kom == 0x0) {        // a new computation is requireed
00137     
00138     p_mass_kom = new double ; 
00139         
00140     if (star1.is_relativistic()) {  // Relativistic case
00141                     // -----------------
00142         assert( star2.is_relativistic() ) ; 
00143         
00144         *p_mass_kom = 0 ; 
00145         
00146         for (int i=0; i<=1; i++) {      // loop on the stars
00147         
00148             const Cmp& lapse = (et[i]->get_nnn())() ;
00149             const Cmp& a2 = (et[i]->get_a_car())() ; 
00150         const Cmp& ee = (et[i]->get_ener_euler())() ; 
00151         const Cmp& se = (et[i]->get_s_euler())() ; 
00152         const Cmp& ak2_auto = (et[i]->get_akcar_auto())() ;
00153         const Cmp& ak2_comp = (et[i]->get_akcar_comp())() ;
00154 
00155         const Tenseur& dnu_auto = et[i]->get_d_logn_auto() ;
00156         const Tenseur& dnu_comp = et[i]->get_d_logn_comp() ;
00157         const Tenseur& dbe_auto = et[i]->get_d_beta_auto() ;
00158         const Tenseur& dbe_comp = et[i]->get_d_beta_comp() ;
00159 
00160         Tenseur dndb = flat_scalar_prod(dnu_auto,
00161                         dbe_auto + dbe_comp) ;
00162         Tenseur dndn = flat_scalar_prod(dnu_auto,
00163                         dnu_auto + dnu_comp) ;
00164 
00165         Cmp source = lapse * ( a2 * (ee + se)
00166                        + (ak2_auto + ak2_comp)/qpig
00167                        - dndb()/qpig + dndn()/qpig ) ;
00168                
00169         source.std_base_scal() ; 
00170                
00171         *p_mass_kom += source.integrale() ; 
00172         
00173         }    
00174     
00175     }
00176     else {      // Newtonian case 
00177             // --------------
00178             
00179         *p_mass_kom = star1.mass_b() + star2.mass_b() ; 
00180         
00181     }
00182         
00183     }   // End of the case where a new computation was necessary
00184     
00185     return *p_mass_kom ; 
00186     
00187 }
00188 
00189 
00190             //---------------------------------//
00191             //   Total angular momentum        //
00192             //---------------------------------//
00193 
00194 const Tbl& Binaire::angu_mom() const {
00195     
00196     if (p_angu_mom == 0x0) {        // a new computation is requireed
00197     
00198     p_angu_mom = new Tbl(3) ; 
00199     
00200     p_angu_mom->annule_hard() ; // fills the double array with zeros
00201         
00202     for (int i=0; i<=1; i++) {      // loop on the stars
00203         
00204         const Map& mp = et[i]->get_mp() ; 
00205         
00206         Cmp xx(mp) ; 
00207         Cmp yy(mp) ; 
00208         Cmp zz(mp) ; 
00209         
00210         xx = mp.xa ;
00211         yy = mp.ya ;
00212         zz = mp.za ;
00213         
00214         const Cmp& vx = (et[i]->get_u_euler())(0) ; 
00215         const Cmp& vy = (et[i]->get_u_euler())(1) ; 
00216         const Cmp& vz = (et[i]->get_u_euler())(2) ; 
00217 
00218         Cmp rho(mp) ; 
00219         
00220         if ( et[i]->is_relativistic() ) {
00221         const Cmp& a2 = (et[i]->get_a_car())() ; 
00222         const Cmp& ee = (et[i]->get_ener_euler())() ; 
00223         const Cmp& pp = (et[i]->get_press())() ; 
00224         rho = pow(a2, 2.5) * (ee + pp) ; 
00225         }
00226         else {
00227         rho = (et[i]->get_nbar())() ;
00228         }
00229         
00230 
00231         Base_val** base = (et[i]->get_mp()).get_mg()->std_base_vect_cart() ;
00232 
00233         // X component
00234         // -----------
00235         
00236         Cmp source = rho * ( yy * vz  -  zz * vy ) ;
00237          
00238         (source.va).set_base( *(base[2]) ) ;    // same basis as V^z
00239         
00240 //##        p_angu_mom->set(0) += source.integrale() ; 
00241 
00242         p_angu_mom->set(0) += 0 ; 
00243         
00244         // y component
00245         // -----------
00246         
00247         source = rho * ( zz * vx  -  xx * vz ) ;
00248         
00249         (source.va).set_base( *(base[2]) ) ;    // same basis as V^z
00250         
00251 //##        p_angu_mom->set(1) += source.integrale() ; 
00252         p_angu_mom->set(1) += 0 ; 
00253     
00254         
00255         // Z component
00256         // -----------
00257         
00258         source = rho * ( xx * vy - yy * vx ) ;
00259         
00260         source.std_base_scal() ;    // same basis as V^x (standard scalar
00261                     //    field)
00262          
00263         p_angu_mom->set(2) += source.integrale() ; 
00264         
00265         delete base[0] ; 
00266         delete base[1] ; 
00267         delete base[2] ; 
00268         delete [] base ; 
00269         
00270     }  // End of the loop on the stars
00271 
00272     }   // End of the case where a new computation was necessary
00273     
00274     return *p_angu_mom ; 
00275     
00276 }
00277 
00278 
00279 
00280 
00281             //---------------------------------//
00282             //      Total energy           //
00283             //---------------------------------//
00284 
00285 double Binaire::total_ener() const {
00286     
00287     if (p_total_ener == 0x0) {      // a new computation is requireed
00288     
00289     p_total_ener = new double ; 
00290         
00291     if (star1.is_relativistic()) {  // Relativistic case
00292                     // -----------------
00293     
00294         assert( star2.is_relativistic() ) ; 
00295         
00296         *p_total_ener = mass_adm() - star1.mass_b() - star2.mass_b() ; 
00297         
00298     }
00299     else {      // Newtonian case 
00300             // --------------
00301             
00302         *p_total_ener = 0 ; 
00303         
00304         for (int i=0; i<=1; i++) {      // loop on the stars
00305         
00306         const Cmp e_int = (et[i]->get_ener())()
00307                     - (et[i]->get_nbar())()  ; 
00308 
00309         const Cmp& rho = (et[i]->get_nbar())() ;
00310 
00311         // Fluid velocity with respect to the inertial frame
00312         const Tenseur& vit = et[i]->get_u_euler() ; 
00313         
00314         Cmp vit2 = flat_scalar_prod(vit, vit)() ; 
00315         
00316         // Gravitational potential 
00317         const Cmp nu = (et[i]->get_logn_auto())() 
00318                    + (et[i]->get_logn_comp())() ;
00319         
00320         Cmp source = e_int + .5 * rho * vit2 + .5 * rho * nu ; 
00321                
00322         *p_total_ener += source.integrale() ; 
00323         
00324         
00325         }   // End of the loop on the stars
00326     
00327     }   // End of Newtonian case    
00328     
00329     }   // End of the case where a new computation was necessary
00330     
00331     
00332     return *p_total_ener ; 
00333     
00334 }
00335 
00336 
00337             //---------------------------------//
00338             //   Error on the virial theorem   //
00339             //---------------------------------//
00340 
00341 double Binaire::virial() const {
00342     
00343     if (p_virial == 0x0) {      // a new computation is requireed
00344     
00345     p_virial = new double ; 
00346         
00347     if (star1.is_relativistic()) {  // Relativistic case
00348                     // -----------------
00349     
00350         assert( star2.is_relativistic() ) ; 
00351         
00352         *p_virial = 1. - mass_kom() / mass_adm() ; 
00353         
00354     }
00355     else {      // Newtonian case 
00356             // --------------
00357             
00358         *p_virial = 0 ; 
00359         
00360         
00361         double vir_mat = 0 ; 
00362         double vir_grav = 0 ; 
00363         
00364         for (int i=0; i<=1; i++) {      // loop on the stars
00365         
00366         const Cmp& pp = (et[i]->get_press())()  ; 
00367 
00368         const Cmp& rho = (et[i]->get_nbar())() ;
00369 
00370         // Fluid velocity with respect to the inertial frame
00371         const Tenseur& vit = et[i]->get_u_euler() ; 
00372         
00373         Cmp vit2 = flat_scalar_prod(vit, vit)() ; 
00374         
00375         // Gravitational potential 
00376         const Cmp nu = (et[i]->get_logn_auto())() 
00377                    + (et[i]->get_logn_comp())() ;
00378         
00379         Cmp source = 3*pp + rho * vit2 ;
00380         
00381         vir_mat +=  source.integrale() ;
00382          
00383         source =  .5 * rho * nu ; 
00384 
00385         vir_grav +=  source.integrale() ;
00386         
00387         }  // End of the loop on the stars
00388     
00389         *p_virial = ( vir_mat + vir_grav ) / fabs(vir_grav) ;
00390         
00391     }   // End of the Newtonian case 
00392 
00393     }   // End of the case where a new computation was necessary
00394     
00395     return *p_virial ; 
00396     
00397 }
00398 
00399 
00400          //----------------------------------------------//
00401          //  Virial error by Gourgoulhon and Bonazzola   //
00402          //----------------------------------------------//
00403 
00404 double Binaire::virial_gb() const {
00405     
00406   using namespace Unites ;
00407 
00408     if (p_virial_gb == 0x0) {       // a new computation is requireed
00409     
00410     p_virial_gb = new double ; 
00411         
00412     if (star1.is_relativistic()) {  // Relativistic case
00413                     // -----------------    
00414 
00415         assert( star2.is_relativistic() ) ; 
00416         
00417         *p_virial_gb = 0 ;
00418 
00419         double vir_pres = 0. ;
00420         double vir_extr = 0. ;
00421         double vir_grav = 0. ;
00422 
00423         for (int i=0; i<=1; i++) {  // loop on the stars
00424 
00425           const Cmp& a2 = (et[i]->get_a_car())() ;
00426           const Cmp& se = (et[i]->get_s_euler())() ;
00427           const Cmp& ak2_auto = (et[i]->get_akcar_auto())() ;
00428           const Cmp& ak2_comp = (et[i]->get_akcar_comp())() ;
00429 
00430           const Tenseur& dnu_auto = et[i]->get_d_logn_auto() ;
00431           const Tenseur& dnu_comp = et[i]->get_d_logn_comp() ;
00432           const Tenseur& dbe_auto = et[i]->get_d_beta_auto() ;
00433           const Tenseur& dbe_comp = et[i]->get_d_beta_comp() ;
00434 
00435         Cmp a1 = sqrt(a2) ; 
00436         a1.std_base_scal() ;
00437 
00438           Cmp source = 2. * a2 * a1 * se ;
00439           vir_pres += source.integrale() ;
00440 
00441           source = 1.5 * a1 * (ak2_auto + ak2_comp) / qpig ;
00442           source.std_base_scal() ;
00443           vir_extr += source.integrale() ;
00444 
00445           Tenseur sprod1 = flat_scalar_prod(dbe_auto, dbe_auto+dbe_comp) ;
00446           Tenseur sprod2 = flat_scalar_prod(dnu_auto, dnu_auto+dnu_comp) ;
00447           Tenseur sprod3 = flat_scalar_prod(dbe_auto, dnu_auto+dnu_comp) ;
00448 
00449           source = a1 * ( sprod1() - sprod2() - 2.*sprod3() )/qpig ;
00450           vir_grav += source.integrale() ;
00451 
00452         }  // End of the loop on the stars
00453 
00454 
00455         *p_virial_gb = (vir_pres + vir_extr + vir_grav) / mass_adm() ;
00456         
00457     }
00458     else {      // Newtonian case 
00459             // --------------
00460             
00461         *p_virial_gb = virial() ; 
00462         
00463         
00464     }   // End of the Newtonian case 
00465 
00466     }   // End of the case where a new computation was necessary
00467     
00468     return *p_virial_gb ; 
00469     
00470 }
00471 
00472 
00473          //------------------------------------------------//
00474          //  Virial error by Friedman, Uryu, and Shibata   //
00475          //------------------------------------------------//
00476 
00477 double Binaire::virial_fus() const {
00478     
00479   using namespace Unites ;
00480 
00481     if (p_virial_fus == 0x0) {      // a new computation is requireed
00482     
00483     p_virial_fus = new double ; 
00484         
00485     if (star1.is_relativistic()) {  // Relativistic case
00486                     // -----------------
00487 
00488         assert( star2.is_relativistic() ) ; 
00489         
00490         *p_virial_fus = 0 ;
00491 
00492         double vir_pres = 0. ;
00493         double vir_extr = 0. ;
00494         double vir_grav = 0. ;
00495 
00496         for (int i=0; i<=1; i++) {  // loop on the stars
00497 
00498           const Cmp& lapse = (et[i]->get_nnn())() ;
00499           const Cmp& a2 = (et[i]->get_a_car())() ;
00500           const Cmp& se = (et[i]->get_s_euler())() ;
00501           const Cmp& ak2_auto = (et[i]->get_akcar_auto())() ;
00502           const Cmp& ak2_comp = (et[i]->get_akcar_comp())() ;
00503 
00504           const Tenseur& dnu_auto = et[i]->get_d_logn_auto() ;
00505           const Tenseur& dnu_comp = et[i]->get_d_logn_comp() ;
00506           const Tenseur& dbe_auto = et[i]->get_d_beta_auto() ;
00507           const Tenseur& dbe_comp = et[i]->get_d_beta_comp() ;
00508 
00509         Cmp a1 = sqrt(a2) ; 
00510         a1.std_base_scal() ;
00511 
00512           Cmp source = 2. * lapse * a2 * a1 * se ;
00513           vir_pres += source.integrale() ;
00514 
00515           source = 1.5 * lapse * a1 * (ak2_auto + ak2_comp) / qpig ;
00516           vir_extr += source.integrale() ;
00517 
00518           Tenseur sprod = flat_scalar_prod( dbe_auto, dbe_auto+dbe_comp )
00519         - flat_scalar_prod( dnu_auto, dnu_auto+dnu_comp ) ;
00520 
00521           source = lapse * a1 * sprod() / qpig ;
00522           vir_grav += source.integrale() ;
00523 
00524         }  // End of the loop on the stars
00525 
00526 
00527         *p_virial_fus = (vir_pres + vir_extr + vir_grav) / mass_adm() ;
00528         
00529     }
00530     else {      // Newtonian case 
00531             // --------------
00532             
00533         *p_virial_fus = virial() ; 
00534         
00535         
00536     }   // End of the Newtonian case 
00537 
00538     }   // End of the case where a new computation was necessary
00539     
00540     return *p_virial_fus ; 
00541     
00542 }
00543 

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