et_bin_nsbh_equilibrium.C

00001 /*
00002  *  Method of class Etoile to compute a static spherical configuration
00003  *   of a neutron star in a NS-BH binary system.
00004  *
00005  *    (see file etoile.h for documentation).
00006  *
00007  */
00008 
00009 /*
00010  *   Copyright (c) 2003 Keisuke Taniguchi
00011  *
00012  *   This file is part of LORENE.
00013  *
00014  *   LORENE is free software; you can redistribute it and/or modify
00015  *   it under the terms of the GNU General Public License version 2
00016  *   as published by the Free Software Foundation.
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 char et_bin_nsbh_equilibrium_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/et_bin_nsbh_equilibrium.C,v 1.11 2008/09/26 08:38:45 p_grandclement Exp $" ;
00030 
00031 /*
00032  * $Id: et_bin_nsbh_equilibrium.C,v 1.11 2008/09/26 08:38:45 p_grandclement Exp $
00033  * $Log: et_bin_nsbh_equilibrium.C,v $
00034  * Revision 1.11  2008/09/26 08:38:45  p_grandclement
00035  * get rid of desaliasing
00036  *
00037  * Revision 1.10  2006/09/05 13:39:45  p_grandclement
00038  * update of the bin_ns_bh project
00039  *
00040  * Revision 1.9  2006/06/01 12:47:53  p_grandclement
00041  * update of the Bin_ns_bh project
00042  *
00043  * Revision 1.8  2006/04/25 07:21:58  p_grandclement
00044  * Various changes for the NS_BH project
00045  *
00046  * Revision 1.7  2006/03/30 07:33:47  p_grandclement
00047  * *** empty log message ***
00048  *
00049  * Revision 1.6  2005/10/18 13:12:33  p_grandclement
00050  * update of the mixted binary codes
00051  *
00052  * Revision 1.5  2005/08/29 15:10:17  p_grandclement
00053  * Addition of things needed :
00054  *   1) For BBH with different masses
00055  *   2) Provisory files for the mixted binaries (Bh and NS) : THIS IS NOT
00056  *   WORKING YET !!!
00057  *
00058  * Revision 1.4  2004/03/25 10:29:04  j_novak
00059  * All LORENE's units are now defined in the namespace Unites (in file unites.h).
00060  *
00061  * Revision 1.3  2003/10/24 12:34:06  k_taniguchi
00062  * Change the notation as it should be
00063  *
00064  * Revision 1.2  2003/10/21 11:49:33  k_taniguchi
00065  * Change the class from Etoile_bin to sub-class Et_bin_nsbh.
00066  *
00067  * Revision 1.1  2003/10/20 15:01:55  k_taniguchi
00068  * Computation of an equilibrium configuration of a neutron star
00069  * in a NS-BH binary system.
00070  *
00071  *
00072  * $Header: /cvsroot/Lorene/C++/Source/Etoile/et_bin_nsbh_equilibrium.C,v 1.11 2008/09/26 08:38:45 p_grandclement Exp $
00073  *
00074  */
00075 
00076 // Headers C
00077 #include <math.h>
00078 
00079 // Headers Lorene
00080 #include "etoile.h"
00081 #include "map.h"
00082 #include "nbr_spx.h"
00083 #include "et_bin_nsbh.h"
00084 #include "param.h"
00085 
00086 #include "graphique.h"
00087 #include "utilitaires.h"
00088 #include "unites.h"
00089 
00090 void Et_bin_nsbh::equilibrium_nsbh(bool adapt, double ent_c, int& niter, int mermax,
00091                    int mermax_poisson, double relax_poisson,
00092                    int mermax_potvit, double relax_potvit,
00093                    Tbl& diff) {
00094                    
00095     // Fundamental constants and units
00096     // -------------------------------
00097   using namespace Unites ;
00098 
00099     // Initializations
00100     // --------------
00101    
00102     const Mg3d* mg = mp.get_mg() ;
00103     int nz = mg->get_nzone() ;      // total number of domains
00104 
00105     // The following is required to initialize mp_prev as a Map_et:
00106     Map_et& mp_et = dynamic_cast<Map_et&>(mp) ;
00107 
00108     // Error indicators
00109     // ----------------
00110     double& diff_ent = diff.set(0) ;
00111     double& diff_vel_pot = diff.set(1) ;
00112     double& diff_lapse = diff.set(2) ;
00113     double& diff_confpsi = diff.set(3) ;
00114     double& diff_shift_x = diff.set(4) ;
00115     double& diff_shift_y = diff.set(5) ;
00116     double& diff_shift_z = diff.set(6) ;
00117 
00118    
00119     // Parameters for the function Map_et::poisson for n_auto
00120     // ------------------------------------------------------
00121     double precis_poisson = 1.e-16 ;
00122 
00123     Param par_poisson1 ;
00124     par_poisson1.add_int(mermax_poisson,  0) ;  // maximum number of iterations
00125     par_poisson1.add_double(relax_poisson,  0) ; // relaxation parameter
00126     par_poisson1.add_double(precis_poisson, 1) ; // required precision
00127     par_poisson1.add_int_mod(niter, 0) ; // number of iterations actually used
00128     par_poisson1.add_cmp_mod( ssjm1_lapse ) ;
00129 
00130     // Parameters for the function Map_et::poisson for confpsi_auto
00131     // ------------------------------------------------------------
00132 
00133     Param par_poisson2 ;
00134     par_poisson2.add_int(mermax_poisson,  0) ;  // maximum number of iterations
00135     par_poisson2.add_double(relax_poisson,  0) ; // relaxation parameter
00136     par_poisson2.add_double(precis_poisson, 1) ; // required precision
00137     par_poisson2.add_int_mod(niter, 0) ; // number of iterations actually used
00138     par_poisson2.add_cmp_mod( ssjm1_confpsi ) ;
00139 
00140     // Parameters for the function Tenseur::poisson_vect
00141     // -------------------------------------------------
00142 
00143     Param par_poisson_vect ;
00144     par_poisson_vect.add_int(mermax_poisson, 0) ; 
00145                                             // maximum number of iterations
00146     par_poisson_vect.add_double(relax_poisson, 0) ; // relaxation parameter
00147     par_poisson_vect.add_double(precis_poisson, 1) ; // required precision
00148     par_poisson_vect.add_cmp_mod( ssjm1_khi ) ;
00149     par_poisson_vect.add_tenseur_mod( ssjm1_wshift ) ;
00150     par_poisson_vect.add_int_mod(niter, 0) ;
00151     
00152     // Parameters for the adaptation
00153     Param par_adapt ; 
00154     int nitermax = 100 ;  
00155     int niter_adapt ; 
00156     int adapt_flag = (adapt) ? 1 : 0 ;  
00157     int nz_search = nzet + 1 ;
00158     double precis_secant = 1.e-14 ; 
00159     double alpha_r ; 
00160     double reg_map = 1. ;   
00161     int k_b ;
00162     int j_b ; 
00163     Tbl ent_limit(nzet) ; 
00164     
00165     par_adapt.add_int(nitermax, 0) ; 
00166     par_adapt.add_int(nzet, 1) ;
00167     par_adapt.add_int(nz_search, 2) ;   
00168     par_adapt.add_int(adapt_flag, 3) ;
00169     par_adapt.add_int(j_b, 4) ;
00170     par_adapt.add_int(k_b, 5) ; 
00171     par_adapt.add_int_mod(niter_adapt, 0) ; 
00172     par_adapt.add_double(precis_secant, 0) ; 
00173     par_adapt.add_double(reg_map, 1)    ; 
00174     par_adapt.add_double(alpha_r, 2) ;
00175     par_adapt.add_tbl(ent_limit, 0) ;
00176     
00177     // External potential
00178     // See Eq (99) from Gourgoulhon et al. (2001)
00179     // -----------------------------------------
00180    
00181 
00182     Tenseur ent_jm1 = ent ; // Enthalpy at previous step
00183     Tenseur source(mp) ;    // source term in the equation for logn_auto
00184                 // and beta_auto
00185     Tenseur source_shift(mp, 1, CON, ref_triad) ;  // source term in the
00186                            //  equation for shift_auto
00187 
00188     //=========================================================================
00189     //          Start of iteration
00190     //=========================================================================
00191 
00192     for(int mer=0 ; mer<mermax ; mer++ ) {
00193 
00194     cout << "-----------------------------------------------" << endl ;
00195     cout << "step: " << mer << endl ;
00196     cout << "diff_ent = " << diff_ent << endl ;
00197     //-----------------------------------------------------
00198     // Resolution of the elliptic equation for the velocity
00199     // scalar potential
00200     //-----------------------------------------------------
00201 
00202     if (irrotational) {
00203         diff_vel_pot = velocity_potential(mermax_potvit, precis_poisson, 
00204                           relax_potvit) ; 
00205     }
00206 
00207     // Equation de la surface
00208     //if (adapt) {
00209     
00210        // Rescaling of the radius : (Be carefull !)
00211        int nt = mg->get_nt(nzet-1) ;
00212        int np = mg->get_np(nzet-1) ;
00213        int nr = mg->get_nr(nzet-1) ;
00214       
00215        // valeurs au centre
00216        double hc = exp(ent_c) ;
00217        double gamma_c = exp(loggam())(0,0,0,0) ;
00218        double gamma_0_c = exp(-pot_centri())(0,0,0,0) ;
00219        double n_auto_c = n_auto()(0,0,0,0) ;
00220        double n_comp_c = n_comp()(0,0,0,0) ;   
00221      
00222        double alpha_square = 0 ;
00223        double constante = 0;
00224        for (int k=0; k<np; k++) {
00225         for (int j=0; j<nt; j++) {
00226         
00227           // valeurs au bord
00228               double gamma_b = exp(loggam())(nzet-1,k,j,nr-1) ;
00229               double gamma_0_b = exp(-pot_centri())(nzet-1,k,j,nr-1) ;
00230               double n_auto_b = n_auto()(nzet-1,k,j,nr-1) ;
00231               double n_comp_b = n_comp()(nzet-1,k,j,nr-1) ;
00232   
00233        // Les solutions :
00234        double alpha_square_courant = (gamma_0_c*gamma_b*n_comp_b - hc*gamma_c*gamma_0_b*n_comp_c) /
00235                              (hc*gamma_c*gamma_0_b*n_auto_c-gamma_0_c*gamma_b*n_auto_b) ;
00236        double constante_courant = gamma_b*(n_comp_b+alpha_square_courant*n_auto_b)/gamma_0_b ;
00237 
00238         if (alpha_square_courant > alpha_square) {
00239             alpha_square = alpha_square_courant ; 
00240             k_b = k ; 
00241             j_b = j ;
00242             constante = constante_courant ; 
00243         }
00244         }
00245     }
00246 
00247        alpha_r = sqrt(alpha_square) ;
00248        cout << "Adaptation : " << k_b << " " << j_b << " " << alpha_r << endl ;
00249         
00250        // Le potentiel : 
00251        Tenseur potentiel (constante*exp(-loggam-pot_centri)/(n_auto*alpha_square+n_comp)) ;
00252        potentiel.set_std_base() ;
00253        for (int l=nzet+1 ; l<nz ; l++)
00254             potentiel.set().va.set(l) = 1 ;
00255 
00256        Map_et mp_prev = mp_et ; 
00257        ent = log(potentiel) ;
00258        ent.set_std_base() ;
00259            ent().va.smooth(nzet, (ent.set().va)) ;
00260     
00261        ent_limit.set_etat_qcq() ; 
00262        for (int l=0; l<nzet; l++) { // loop on domains inside the star
00263            ent_limit.set(l) = ent()(l, k_b, j_b, nr-1) ; 
00264        } 
00265        
00266        // On adapte :  
00267        mp.adapt(ent(), par_adapt, 4) ;
00268        mp_prev.homothetie(alpha_r) ;
00269 
00270        for (int l=nzet ; l<nz-1 ; l++)
00271          mp.resize(l, 1./alpha_r) ;
00272        mp.reevaluate_symy (&mp_prev, nzet, ent.set()) ;
00273        
00274 
00275 
00276     // Equation of state
00277     //----------------------------------------------------
00278     equation_of_state() ;   // computes new values for nbar (n), ener (e)
00279                 // and press (p) from the new ent (H)
00280 
00281     //---------------------------------------------------------
00282     // Matter source terms in the gravitational field equations
00283     //---------------------------------------------------------
00284     hydro_euler() ; // computes new values for ener_euler (E),
00285                 // s_euler (S) and u_euler (U^i)
00286                 
00287                 
00288     //-------------------------------------------------
00289     //  Relative change in enthalpy
00290     //-------------------------------------------------
00291 
00292     Tbl diff_ent_tbl = diffrel( ent(), ent_jm1() ) ;
00293     diff_ent = diff_ent_tbl(0) ;
00294     for (int l=1; l<nzet; l++) {
00295         diff_ent += diff_ent_tbl(l) ;
00296     }
00297     diff_ent /= nzet ;
00298 
00299     ent_jm1 = ent ;
00300     
00301     
00302     //--------------------------------------------------------
00303     // Poisson equation for n_auto
00304     //--------------------------------------------------------
00305 
00306     // Source 
00307     // See Eq (50) from Gourgoulhon et al. (2001)
00308     // ------------------------------------------
00309 
00310     Tenseur confpsi_q = pow(confpsi, 4.) ;
00311     Tenseur confpsi_c = pow(confpsi, 5.) ;
00312     
00313     if (relativistic) {
00314         Tenseur tmp = flat_scalar_prod(tkij_tot, tkij_auto) ;
00315         Tenseur kk (mp) ;
00316         kk = 0 ;
00317         Tenseur tmp2(mp) ;
00318         tmp2.set_etat_qcq() ;
00319         for (int i=0 ; i<3 ; i++) {
00320         tmp2.set() = tmp(i, i) ;
00321         kk = kk + tmp2 ;
00322         }
00323         
00324         source = qpig * nnn * confpsi_q * (ener_euler + s_euler)
00325         + nnn * confpsi_q * kk
00326         - 2.*flat_scalar_prod(d_confpsi_auto+d_confpsi_comp, d_n_auto) /
00327         confpsi ;
00328     }
00329     else {
00330         cout <<
00331         "WARNING : Et_bin_nsbh is for the relativistic calculation"
00332          << endl ;
00333         abort() ;
00334     }
00335 
00336     source.set_std_base() ; 
00337 
00338     // Resolution of the Poisson equation
00339     // ----------------------------------
00340     Cmp n_auto_old (n_auto()) ;
00341     source().poisson(par_poisson1, n_auto.set()) ;
00342     n_auto.set() = n_auto() + 0.5 ; 
00343     
00344     // Difference pas précédent
00345     // -----------------------------------------------------
00346     
00347     Tbl tdiff_lapse = diffrel(n_auto(), n_auto_old) ;
00348     cout <<
00349     "Relative difference on n_auto : "
00350     << endl ;
00351     for (int l=0; l<nz; l++) {
00352         cout << tdiff_lapse(l) << "  " ;
00353     }
00354     cout << endl ;
00355     diff_lapse = max(abs(tdiff_lapse)) ; 
00356         
00357     if (relativistic) {
00358          
00359     
00360         //--------------------------------------------------------
00361         // Poisson equation for confpsi_auto 
00362         //--------------------------------------------------------
00363 
00364         // Source
00365         // See Eq (51) from Gourgoulhon et al. (2001)
00366         // ------------------------------------------
00367 
00368         Tenseur tmp = flat_scalar_prod(tkij_tot, tkij_auto) ;
00369         Tenseur kk (mp) ;
00370         kk = 0 ;
00371         Tenseur tmp2(mp) ;
00372         tmp2.set_etat_qcq() ;
00373         for (int i=0 ; i<3 ; i++) {
00374         tmp2.set() = tmp(i, i) ;
00375         kk = kk + tmp2 ;
00376         }
00377 
00378         source = -0.5 * qpig * confpsi_c * ener_euler
00379         - 0.125 * confpsi_c * kk ;
00380 
00381         source.set_std_base() ;     
00382         
00383         // Resolution of the Poisson equation 
00384         // ----------------------------------
00385         Cmp psi_old (confpsi_auto()) ;
00386         source().poisson(par_poisson2, confpsi_auto.set()) ;
00387         confpsi_auto.set() = confpsi_auto() + 0.5 ; 
00388         
00389         
00390         // Check: has the Poisson equation been correctly solved ?
00391         // -----------------------------------------------------
00392 
00393         Tbl tdiff_confpsi = diffrel(confpsi_auto(), psi_old) ;
00394         cout << 
00395         "Relative difference on confpsi_auto : "
00396          << endl ;
00397         for (int l=0; l<nz; l++) {
00398         cout << tdiff_confpsi(l) << "  " ;
00399         }
00400         cout << endl ;
00401         diff_confpsi = max(abs(tdiff_confpsi)) ;
00402         
00403         //--------------------------------------------------------
00404         // Vector Poisson equation for shift_auto 
00405         //--------------------------------------------------------
00406 
00407         // Source
00408         // See Eq (52) from Gourgoulhon et al. (2001)
00409         // ------
00410      Tenseur vtmp = d_n_auto -6. * nnn * d_confpsi_auto / confpsi ;
00411         source_shift = 4.*qpig * nnn *confpsi_q *(ener_euler + press)
00412            * u_euler ;
00413         if (tkij_tot.get_etat() != ETATZERO)        
00414     source_shift = source_shift + 2.* flat_scalar_prod(tkij_tot, vtmp) ;
00415         source_shift.set_std_base() ;
00416         // Resolution of the Poisson equation 
00417         // ----------------------------------
00418         // Filter for the source of shift vector 
00419     for (int i=0 ; i<3 ; i++)
00420          if (source_shift(i).get_etat() !=  ETATZERO)
00421            source_shift.set(i).va.coef_i() ;       
00422 
00423 for (int i=0; i<3; i++)
00424           if ((source_shift(i).get_etat() != ETATZERO) && (source_shift(i).va.c->t[nz-1]->get_etat() != ETATZERO)) 
00425         source_shift.set(i).filtre(4) ;
00426         for (int i=0; i<3; i++) {
00427         if(source_shift(i).dz_nonzero()) {
00428             assert( source_shift(i).get_dzpuis() == 4 ) ;
00429         }
00430         else{
00431             (source_shift.set(i)).set_dzpuis(4) ;
00432         }
00433         }
00434         //##
00435         // source_shift.dec2_dzpuis() ;    // dzpuis 4 -> 2
00436 
00437         double lambda_shift = double(1) / double(3) ;
00438         // ON DOIT CHANGER DE TRIADE
00439         source_shift.change_triad(mp.get_bvect_cart()) ;
00440         Tenseur shift_old (shift_auto) ;  
00441         source_shift.poisson_vect_oohara(lambda_shift, par_poisson_vect,
00442                       shift_auto, khi_shift) ;
00443        shift_auto.change_triad(ref_triad) ;
00444 
00445         // Check: has the equation for shift_auto been correctly solved ?
00446         // --------------------------------------------------------------
00447 
00448        
00449 
00450         Tbl tdiff_shift_x = diffrel(shift_auto(0), shift_old(0)) ;
00451         Tbl tdiff_shift_y = diffrel(shift_auto(1), shift_old(1)) ;
00452         Tbl tdiff_shift_z = diffrel(shift_auto(2), shift_old(2)) ;
00453 
00454         cout <<
00455         "Relative difference on shift_auto : "
00456          << endl ; 
00457         cout << "x component : " ;
00458         for (int l=0; l<nz; l++) {
00459         cout << tdiff_shift_x(l) << "  " ;
00460         }
00461         cout << endl ;
00462         cout << "y component : " ;
00463         for (int l=0; l<nz; l++) {
00464         cout << tdiff_shift_y(l) << "  " ;
00465         }
00466         cout << endl ;
00467         cout << "z component : " ;
00468         for (int l=0; l<nz; l++) {
00469         cout << tdiff_shift_z(l) << "  " ;
00470         }
00471         cout << endl ;
00472 
00473         diff_shift_x = max(abs(tdiff_shift_x)) ;
00474         diff_shift_y = max(abs(tdiff_shift_y)) ;
00475         diff_shift_z = max(abs(tdiff_shift_z)) ;
00476         } // End of relativistic equations
00477 
00478     
00479     } // End of main loop
00480 
00481     //=========================================================================
00482     //          End of iteration
00483     //=========================================================================
00484 }
00485 
00486 // Truc pourri
00487 void Et_bin_nsbh::equilibrium_nsbh (double, int, int, double,
00488                   int, double, double, const Tbl&, Tbl&) {
00489                   
00490         cout << "Not implemented !" << endl ;
00491         abort() ;
00492 }

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