star_bin_vel_pot.C

00001 /*
00002  * Method of class Star_bin to compute the velocity scalar potential $\psi$
00003  * by solving the continuity equation.
00004  *
00005  * (see file star.h for documentation).
00006  *
00007  */
00008 
00009 /*
00010  *   Copyright (c) 2004      Francois Limousin
00011  *                 2000-2001 Eric Gourgoulhon  (for precedent version)
00012  *
00013  *   This file is part of LORENE.
00014  *
00015  *   LORENE is free software; you can redistribute it and/or modify
00016  *   it under the terms of the GNU General Public License as published by
00017  *   the Free Software Foundation; either version 2 of the License, or
00018  *   (at your option) any later version.
00019  *
00020  *   LORENE is distributed in the hope that it will be useful,
00021  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *   GNU General Public License for more details.
00024  *
00025  *   You should have received a copy of the GNU General Public License
00026  *   along with LORENE; if not, write to the Free Software
00027  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028  *
00029  */
00030 
00031 char star_bin_vel_pot_C[] = "$Header: /cvsroot/Lorene/C++/Source/Star/star_bin_vel_pot.C,v 1.6 2005/09/13 19:38:31 f_limousin Exp $" ;
00032 
00033 /*
00034  * $Id: star_bin_vel_pot.C,v 1.6 2005/09/13 19:38:31 f_limousin Exp $
00035  * $Log: star_bin_vel_pot.C,v $
00036  * Revision 1.6  2005/09/13 19:38:31  f_limousin
00037  * Reintroduction of the resolution of the equations in cartesian coordinates.
00038  *
00039  * Revision 1.5  2005/02/24 16:07:57  f_limousin
00040  * Change the name of some variables (for instance dcov_logn --> dlogn).
00041  *
00042  * Revision 1.4  2005/02/17 17:33:11  f_limousin
00043  * Change the name of some quantities to be consistent with other classes
00044  * (for instance nnn is changed to nn, shift to beta, beta to lnq...)
00045  *
00046  * Revision 1.3  2004/06/22 12:53:09  f_limousin
00047  * Change qq, qq_auto and qq_comp to beta, beta_auto and beta_comp.
00048  *
00049  * Revision 1.2  2004/06/07 16:26:01  f_limousin
00050  * Many modif...
00051  *
00052  * Revision 1.1  2004/04/08 16:34:08  f_limousin
00053  * First version
00054  *
00055  *
00056  * $Header: /cvsroot/Lorene/C++/Source/Star/star_bin_vel_pot.C,v 1.6 2005/09/13 19:38:31 f_limousin Exp $
00057  *
00058  */
00059 
00060 // Headers Lorene
00061 #include "star.h"
00062 #include "eos.h"
00063 #include "param.h"
00064 #include "cmp.h"
00065 #include "tenseur.h"
00066 #include "graphique.h"
00067 #include "utilitaires.h"
00068 
00069 // Local prototype
00070 Cmp raccord_c1(const Cmp& uu, int l1) ; 
00071 
00072 double Star_bin::velocity_potential(int mermax, double precis, double relax) {
00073   
00074     int nzm1 = mp.get_mg()->get_nzone() - 1 ;
00075 
00076      //----------------------------------
00077     // Specific relativistic enthalpy           ---> hhh
00078     //----------------------------------
00079     
00080     Scalar hhh = exp(ent) ;  // = 1 at the Newtonian limit
00081     hhh.std_spectral_base() ;
00082 
00083     //----------------------------------------------
00084     //  Computation of W^i = - A^2 h Gamma_n B^i/N
00085     // See Eq (62) from Gourgoulhon et al. (2001)
00086     //----------------------------------------------
00087 
00088     Vector www = hhh * gam_euler * bsn * psi4 ;
00089     
00090     www.change_triad( mp.get_bvect_cart() ) ;   // components on the mapping
00091                         // Cartesian basis
00092     
00093     //-------------------------------------------------
00094     // Constant value of W^i at the center of the star
00095     //-------------------------------------------------
00096     
00097     Vector v_orb(mp, CON, mp.get_bvect_cart()) ; 
00098     
00099     v_orb.set_etat_qcq() ;
00100     for (int i=1; i<=3; i++) {
00101     v_orb.set(i) = www(i).val_grid_point(0, 0, 0, 0) ;
00102     }
00103 
00104     v_orb.set_triad( *(www.get_triad()) ) ;  
00105     v_orb.std_spectral_base() ;
00106    
00107     //-------------------------------------------------
00108     // Source and coefficients a,b for poisson_compact (independent from psi0)
00109     //-------------------------------------------------
00110     
00111     Scalar dndh_log = eos.der_nbar_ent(ent, nzet) ; 
00112 
00113     // In order to avoid any division by zero in the computation of zeta_h
00114     //  the value of dndh_log is set to 1 in the external domains:
00115     for (int l=nzet; l <= nzm1; l++) {
00116     dndh_log.set_domain(l) = 1 ; 
00117     }
00118     
00119     Scalar zeta_h( ent / dndh_log ) ;
00120     zeta_h.std_spectral_base() ;
00121 
00122     Metric_flat flat_spher (mp.flat_met_spher()) ;
00123     Vector bb = (1 - zeta_h) * ent.derive_con(flat_spher) + 
00124     zeta_h * lnq.derive_con(flat_spher) ;
00125 
00126     Scalar entmb = ent - lnq ;  
00127 
00128     www.change_triad(mp.get_bvect_cart()) ;
00129     v_orb.change_triad(mp.get_bvect_cart()) ;
00130 
00131     Tensor dcovdcov_psi0 = psi0.derive_cov(flat).derive_cov(flat) ;
00132     dcovdcov_psi0.inc_dzpuis() ;
00133 
00134     // See Eq (63) from Gourgoulhon et al. (2001)
00135     Scalar source = contract(www - v_orb, 0, ent.derive_cov(flat), 0)
00136     + zeta_h * ( contract(v_orb, 0, entmb.derive_cov(flat), 0) +
00137              contract(www/gam_euler, 0, gam_euler.derive_cov(flat), 0)
00138              + contract(hij, 0, 1, (psi0.derive_cov(flat)  
00139                 + v_orb.down(0, flat))*entmb.derive_cov(flat),
00140                 0, 1) 
00141              - contract(hij, 0, 1, dcovdcov_psi0, 0, 1))
00142     - contract(hij, 0, 1, ent.derive_cov(flat) * (psi0.derive_cov(flat) 
00143                               + v_orb.down(0, flat)), 
00144                               0, 1) ;
00145   
00146 /*
00147     des_meridian(zeta_h,0., 4., "zeta_h", 10) ; 
00148     arrete() ; 
00149     des_meridian(bb(1),0., 4., "bb(1)", 10) ; 
00150     arrete() ; 
00151     des_meridian(bb(2),0., 4., "bb(2)", 10) ; 
00152     arrete() ; 
00153     des_meridian(bb(3),0., 4., "bb(3)", 10) ; 
00154     arrete() ; 
00155     des_meridian(psi0,0., 4., "psi0", 10) ; 
00156     arrete() ; 
00157     des_meridian(source,0., 4., "source", 10) ; 
00158     arrete() ; 
00159 */  
00160 
00161 
00162     www.change_triad(mp.get_bvect_cart()) ;
00163     v_orb.change_triad(mp.get_bvect_cart()) ;
00164                  
00165     source.annule(nzet, nzm1) ; 
00166                 
00167     //---------------------------------------------------
00168     // Resolution by means of Map_radial::poisson_compact 
00169     //---------------------------------------------------
00170 
00171     Param par ; 
00172     int niter ; 
00173     par.add_int(mermax) ; 
00174     par.add_double(precis, 0) ; 
00175     par.add_double(relax, 1) ; 
00176     par.add_int_mod(niter) ; 
00177     
00178     
00179     if (psi0.get_etat() == ETATZERO) {
00180     psi0 = 0 ; 
00181     }
00182 
00183     Cmp source_cmp (source) ;
00184     Cmp zeta_h_cmp (zeta_h) ;
00185     Cmp psi0_cmp (psi0) ;
00186     
00187     Tenseur bb_cmp(mp, 1, CON, mp.get_bvect_spher()) ;
00188     bb_cmp.set_etat_qcq() ;
00189     Cmp bb_cmp1 (bb(1)) ;
00190     Cmp bb_cmp2 (bb(2)) ;
00191     Cmp bb_cmp3 (bb(3)) ;
00192     bb_cmp.set(0) = bb_cmp1 ;
00193     bb_cmp.set(1) = bb_cmp2 ;
00194     bb_cmp.set(2) = bb_cmp3 ;
00195  
00196     source_cmp.va.ylm() ;
00197 
00198     cout << "source" << endl << norme(source_cmp)<< endl ;
00199     cout << "zeta_h " << endl << norme(zeta_h_cmp) << endl ;
00200     cout << "bb(1)" << endl << norme(bb_cmp(0)) << endl ;
00201     cout << "bb(2)" << endl << norme(bb_cmp(1)) << endl ;
00202     cout << "bb(3)" << endl << norme(bb_cmp(2)) << endl ;
00203     cout << "psiO" << endl << norme(psi0_cmp) << endl ;
00204 
00205     mp.poisson_compact(source_cmp, zeta_h_cmp, bb_cmp, par, psi0_cmp ) ;
00206     
00207     psi0 = psi0_cmp ;
00208 
00209     cout << "psiO apres" << endl << norme(psi0) << endl ;
00210 
00211     //---------------------------------------------------
00212     // Check of the solution  
00213     //---------------------------------------------------
00214     
00215     Scalar bb_dpsi0 = contract(bb, 0, psi0.derive_cov(flat_spher), 0) ;
00216     
00217     Scalar oper = zeta_h * psi0.laplacian() + bb_dpsi0 ; 
00218     
00219     source.set_spectral_va().ylm_i() ;
00220 
00221     double erreur = diffrel(oper, source)(0) ; 
00222 
00223     cout << "Check of the resolution of the continuity equation : " 
00224      << endl ; 
00225     cout << "            norme(source) : " << norme(source)(0) 
00226          << "    diff oper/source : " << erreur << endl ; 
00227     
00228     
00229     //--------------------------------
00230     // Computation of grad(psi)
00231     //--------------------------------
00232     
00233     v_orb.change_triad(mp.get_bvect_cart()) ;
00234     d_psi.change_triad(mp.get_bvect_cart()) ;
00235 
00236     for (int i=1; i<=3; i++) 
00237     d_psi.set(i) = (psi0.derive_cov(flat))(i) + v_orb(i) ; 
00238 
00239     v_orb.change_triad(mp.get_bvect_cart()) ;    
00240     d_psi.change_triad(mp.get_bvect_cart()) ; 
00241    
00242     // C^1 continuation of d_psi outside the star
00243     //  (to ensure a smooth enthalpy field accross the stellar surface)
00244     // ----------------------------------------------------------------
00245     
00246     d_psi.annule(nzet, nzm1) ;    
00247  
00248     for (int i=1; i<=3; i++) {
00249     Cmp d_psi_i (d_psi(i)) ;
00250     d_psi_i = raccord_c1(d_psi_i, nzet) ; 
00251     d_psi.set(i) = d_psi_i ; 
00252     }
00253     
00254     return erreur ; 
00255 
00256 }

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