star_bhns_equilibrium.C

00001 /*
00002  *  Method of class Star_bhns to compute an equilibrium configuration
00003  *   of a neutron star in a black hole-neutron star binary
00004  *
00005  *    (see file star_bhns.h for documentation).
00006  *
00007  */
00008 
00009 /*
00010  *   Copyright (c) 2005-2007 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 star_bhns_equilibrium_C[] = "$Header: /cvsroot/Lorene/C++/Source/Star_bhns/star_bhns_equilibrium.C,v 1.2 2008/05/15 19:13:45 k_taniguchi Exp $" ;
00030 
00031 /*
00032  * $Id: star_bhns_equilibrium.C,v 1.2 2008/05/15 19:13:45 k_taniguchi Exp $
00033  * $Log: star_bhns_equilibrium.C,v $
00034  * Revision 1.2  2008/05/15 19:13:45  k_taniguchi
00035  * Change of some parameters.
00036  *
00037  * Revision 1.1  2007/06/22 01:30:45  k_taniguchi
00038  * *** empty log message ***
00039  *
00040  *
00041  * $Header: /cvsroot/Lorene/C++/Source/Star_bhns/star_bhns_equilibrium.C,v 1.2 2008/05/15 19:13:45 k_taniguchi Exp $
00042  *
00043  */
00044 
00045 // C++ headers
00046 //#include <>
00047 
00048 // C headers
00049 #include <math.h>
00050 
00051 // Lorene headers
00052 #include "star_bhns.h"
00053 #include "param.h"
00054 #include "cmp.h"
00055 #include "tenseur.h"
00056 #include "utilitaires.h"
00057 #include "unites.h"
00058 //#include "graphique.h"
00059 
00060 void Star_bhns::equilibrium_bhns(double ent_c, const double& mass_bh,
00061                  const double& sepa, bool kerrschild,
00062                  int mer, int mermax_ns, int mermax_potvit,
00063                  int mermax_poisson, int filter_r,
00064                  int filter_r_s, int filter_p_s,
00065                  double relax_poisson, double relax_potvit,
00066                  double thres_adapt, double resize_ns,
00067                  const Tbl& fact_resize, Tbl& diff) {
00068 
00069     // Fundamental constants and units
00070     // -------------------------------
00071     using namespace Unites ;
00072 
00073     // Initializations
00074     // ---------------
00075 
00076     const Mg3d* mg = mp.get_mg() ;
00077     int nz = mg->get_nzone() ;    // Total number of domain
00078     //    int nt = mg->get_nt(0) ;
00079 
00080     // The following is required to initialize mp_prev as a Map_et:
00081     Map_et& mp_et = dynamic_cast<Map_et&>(mp) ;
00082 
00083     // Domain and radial indices of points at the surface of the star:
00084     int l_b = nzet - 1 ;
00085     int i_b = mg->get_nr(l_b) - 1 ;
00086     int k_b ;
00087     int j_b ;
00088 
00089     // Value of the enthalpy defining the surface of the star
00090     double ent_b = 0 ;
00091 
00092     // Error indicators
00093     // ----------------
00094 
00095     double& diff_ent = diff.set(0) ;
00096     double& diff_vel_pot = diff.set(1) ;
00097     double& diff_lapconf = diff.set(2) ;
00098     double& diff_confo = diff.set(3) ;
00099     double& diff_shift_x = diff.set(4) ;
00100     double& diff_shift_y = diff.set(5) ;
00101     double& diff_shift_z = diff.set(6) ;
00102     double& diff_dHdr = diff.set(7) ;
00103     double& diff_dHdr_min = diff.set(8) ;
00104     double& diff_phi_min = diff.set(9) ;
00105     double& diff_radius = diff.set(10) ;
00106 
00107     // Parameters for the function Map_et::adapt
00108     // -----------------------------------------
00109 
00110     Param par_adapt ;
00111     int nitermax = 100 ;
00112     int niter ;
00113     int adapt_flag = 1 ;   //  1 = performs the full computation,
00114                            //  0 = performs only the rescaling by
00115                            //      the factor alpha_r
00116 
00117     // Number of domains for searching the enthalpy isosurfaces
00118     int nz_search = nzet + 1 ;
00119     //    int nz_search = nzet ;
00120 
00121     double precis_secant = 1.e-14 ;
00122     double alpha_r ;
00123     double reg_map = 1. ; // 1 = regular mapping, 0 = contracting mapping
00124 
00125     Tbl ent_limit(nz) ;
00126 
00127     par_adapt.add_int(nitermax, 0) ;   // maximum number of iterations to
00128                                        // locate zeros by the secant method
00129     par_adapt.add_int(nzet, 1) ;       // number of domains where the
00130                                        // adjustment to the isosurfaces of
00131                                        // ent is to be performed
00132     par_adapt.add_int(nz_search, 2) ;  // number of domains to search for
00133                                        // the enthalpy isosurface
00134     par_adapt.add_int(adapt_flag, 3) ; // 1 = performs the full computation,
00135                                        // 0 = performs only the rescaling by
00136                                        //     the factor alpha_r
00137     par_adapt.add_int(j_b, 4) ;        // theta index of the collocation point
00138                                        // (theta_*, phi_*)
00139     par_adapt.add_int(k_b, 5) ;        // theta index of the collocation point
00140                                        // (theta_*, phi_*)
00141     par_adapt.add_int_mod(niter, 0) ;  // number of iterations actually used
00142                                        // in the secant method
00143     par_adapt.add_double(precis_secant, 0) ; // required absolute precision in
00144                                              // the determination of zeros by
00145                                              // the secant method
00146     par_adapt.add_double(reg_map, 1) ; // 1. = regular mapping,
00147                                        // 0 = contracting mapping
00148     par_adapt.add_double(alpha_r, 2) ; // factor by which all the radial
00149                                        // distances will be multiplied
00150     par_adapt.add_tbl(ent_limit, 0) ;  // array of values of the field ent
00151                                        // to define the isosurfaces
00152 
00153     Cmp ssjm1lapconf(ssjm1_lapconf) ;
00154     Cmp ssjm1confo(ssjm1_confo) ;
00155 
00156     ssjm1lapconf.set_etat_qcq() ;
00157     ssjm1confo.set_etat_qcq() ;
00158 
00159     double precis_poisson = 1.e-14 ;
00160 
00161     // Parameters for the function Scalar::poisson for lapconf_auto
00162     // ------------------------------------------------------------
00163 
00164     Param par_lapconf ;
00165 
00166     par_lapconf.add_int(mermax_poisson, 0) ;    // maximum number of iterations
00167     par_lapconf.add_double(relax_poisson, 0) ;  // relaxation parameter
00168     par_lapconf.add_double(precis_poisson, 1) ; // required precision
00169     par_lapconf.add_int_mod(niter, 0) ;  // number of iterations actually used
00170     par_lapconf.add_cmp_mod( ssjm1lapconf ) ;
00171 
00172     // Parameters for the function Scalar::poisson for confo_auto
00173     // ----------------------------------------------------------
00174 
00175     Param par_confo ;
00176 
00177     par_confo.add_int(mermax_poisson, 0) ;    // maximum number of iterations
00178     par_confo.add_double(relax_poisson, 0) ;  // relaxation parameter
00179     par_confo.add_double(precis_poisson, 1) ; // required precision
00180     par_confo.add_int_mod(niter, 0) ;  // number of iterations actually used
00181     par_confo.add_cmp_mod( ssjm1confo ) ;
00182 
00183     // Parameters for the function Vector::poisson for shift method 2
00184     // --------------------------------------------------------------
00185 
00186     Param par_shift2 ;
00187 
00188     par_shift2.add_int(mermax_poisson, 0) ;    // maximum number of iterations
00189     par_shift2.add_double(relax_poisson, 0) ;  // relaxation parameter
00190     par_shift2.add_double(precis_poisson, 1) ; // required precision
00191     par_shift2.add_int_mod(niter, 0) ; // number of iterations actually used
00192 
00193     Cmp ssjm1khi(ssjm1_khi) ;
00194     ssjm1khi.set_etat_qcq() ;
00195 
00196     Tenseur ssjm1wshift(mp, 1, CON, mp.get_bvect_cart()) ;
00197     ssjm1wshift.set_etat_qcq() ;
00198     for (int i=0; i<3; i++) {
00199         ssjm1wshift.set(i) = Cmp(ssjm1_wshift(i+1)) ;
00200     }
00201 
00202     par_shift2.add_cmp_mod(ssjm1khi) ;
00203     par_shift2.add_tenseur_mod(ssjm1wshift) ;
00204 
00205     Scalar ent_jm1 = ent ;  // Enthalpy at previous step
00206 
00207     Scalar lapconf_m1(mp) ;  // = lapconf_auto - 0.5
00208     Scalar confo_m1(mp) ;  // = confo_auto - 0.5
00209 
00210     Scalar source_lapconf(mp) ; // Source term in the equation for lapconf_auto
00211     source_lapconf.set_etat_qcq() ;
00212     Scalar source_confo(mp) ; // Source term in the equation for confo_auto
00213     source_confo.set_etat_qcq() ;
00214     Vector source_shift(mp, CON, mp.get_bvect_cart()) ; // Source term 
00215                             // in the equation for shift_auto
00216     source_shift.set_etat_qcq() ;
00217 
00218     //===========================================================
00219     //                    Start of iteration
00220     //===========================================================
00221 
00222     for (int mer_ns=0; mer_ns<mermax_ns; mer_ns++) {
00223 
00224         cout << "-----------------------------------------------" << endl ;
00225     cout << "step: " << mer_ns << endl ;
00226     cout << "diff_ent = " << diff_ent << endl ;
00227 
00228     //------------------------------------------------------
00229     // Resolution of the elliptic equation for the velocity
00230     // scalar potential
00231     //------------------------------------------------------
00232 
00233     if (irrotational) {
00234         diff_vel_pot = velo_pot_bhns(mass_bh, sepa, kerrschild,
00235                      mermax_potvit, precis_poisson,
00236                      relax_potvit) ;
00237     }
00238     else {
00239         diff_vel_pot = 0. ; // to avoid the warning
00240     }
00241 
00242     //-------------------------------------
00243     // Computation of the new radial scale
00244     //-------------------------------------
00245 
00246     // alpha_r (r = alpha_r r') is determined so that the enthalpy
00247     // takes the requested value ent_b at the stellar surface
00248 
00249     // Values at the center of the star:
00250     // lapconf_auto = lapconf_auto=0(r->infty) + 0.5
00251     // The term lapconf_auto=0(r->infty) should be rescaled.
00252     double lapconf_auto_c = lapconf_auto.val_grid_point(0,0,0,0) - 0.5 ;
00253     double lapconf_comp_c = lapconf_comp.val_grid_point(0,0,0,0) ;
00254 
00255     double confo_c = confo_tot.val_grid_point(0,0,0,0) ;
00256 
00257     double gam_c = gam.val_grid_point(0,0,0,0) ;
00258     double gam0_c = gam0.val_grid_point(0,0,0,0) ;
00259 
00260     double hhh_c = exp(ent_c) ;
00261     double hhh_b = exp(ent_b) ;
00262 
00263     // Search for the reference point (theta_*, phi_*) [notation of
00264     //  Bonazzola, Gourgoulhon & Marck PRD 58, 104020 (1998)]
00265     //  at the surface of the star
00266     // ------------------------------------------------------------
00267     double alpha_r2 = 0. ;
00268 
00269     for (int k=0; k<mg->get_np(l_b); k++) {
00270         for (int j=0; j<mg->get_nt(l_b); j++) {
00271 
00272         double lapconf_auto_b =
00273           lapconf_auto.val_grid_point(l_b,k,j,i_b) - 0.5 ;
00274         double lapconf_comp_b =
00275           lapconf_comp.val_grid_point(l_b,k,j,i_b) ;
00276 
00277         double confo_b = confo_tot.val_grid_point(l_b,k,j,i_b) ;
00278 
00279         double gam_b = gam.val_grid_point(l_b,k,j,i_b) ;
00280         double gam0_b = gam0.val_grid_point(l_b,k,j,i_b) ;
00281 
00282         double aaa = (gam0_c*gam_b*hhh_b*confo_c)
00283           / (gam0_b*gam_c*hhh_c*confo_b) ;
00284 
00285         // See Eq (100) from Gourgoulhon et al. (2001)
00286         double alpha_r2_jk = (aaa * lapconf_comp_b - lapconf_comp_c
00287                       + 0.5 * (aaa - 1.))
00288           / (lapconf_auto_c - aaa * lapconf_auto_b ) ;
00289 
00290         if (alpha_r2_jk > alpha_r2) {
00291             alpha_r2 = alpha_r2_jk ;
00292             k_b = k ;
00293             j_b = j ;
00294         }
00295         }
00296     }
00297 
00298     alpha_r = sqrt(alpha_r2) ;
00299 
00300     cout << "k_b, j_b, alpha_r: " << k_b << "  " << j_b << "  "
00301          << alpha_r << endl ;
00302 
00303     // New value of lapconf_auto
00304     // -------------------------
00305 
00306     lapconf_auto = alpha_r2 * (lapconf_auto - 0.5) + 0.5 ;
00307     Scalar lapconf_tot_tmp = lapconf_auto + lapconf_comp ;
00308     lapconf_tot_tmp.std_spectral_base() ;
00309 
00310     /*
00311     confo_auto = alpha_r2 * (confo_auto - 0.5) + 0.5 ;
00312     Scalar confo_tot_tmp = confo_auto + confo_comp ;
00313     confo_tot_tmp.std_spectral_base() ;
00314     */
00315     //------------------------------------------------------------
00316     // Change the values of the inner points of the second domain
00317     // by those of the outer points of the first domain
00318     //------------------------------------------------------------
00319 
00320     lapconf_auto.set_spectral_va().smooth(nzet,lapconf_auto.set_spectral_va()) ;
00321 
00322     //--------------------------------------------
00323     // First integral  -->  enthalpy in all space
00324     // See Eq (98) from Gourgoulhon et al. (2001)
00325     //--------------------------------------------
00326 
00327     double log_lapconf_c = log(lapconf_tot_tmp.val_grid_point(0,0,0,0)) ;
00328     double log_confo_c = log(confo_tot.val_grid_point(0,0,0,0)) ;
00329     double loggam_c = loggam.val_grid_point(0,0,0,0) ;
00330     double pot_centri_c = pot_centri.val_grid_point(0,0,0,0) ;
00331 
00332     ent = (ent_c + log_lapconf_c - log_confo_c + loggam_c + pot_centri_c)
00333       - log(lapconf_tot_tmp) + log(confo_tot) - loggam - pot_centri ;
00334     ent.std_spectral_base() ;
00335 
00336 
00337     //----------------------------------------------------------
00338     // Change the enthalpy field to be set its maximum position
00339     // at the coordinate center
00340     //----------------------------------------------------------
00341 
00342     double dentdx = ent.dsdx().val_grid_point(0,0,0,0) ;
00343     double dentdy = ent.dsdy().val_grid_point(0,0,0,0) ;
00344 
00345     cout << "dH/dx|_center = " << dentdx << endl ;
00346     cout << "dH/dy|_center = " << dentdy << endl ;
00347 
00348     double dec_fact_x = 1. ;
00349     double dec_fact_y = 1. ;
00350 
00351     Scalar func_in(mp) ;
00352     func_in = 1. - dec_fact_x * (dentdx/ent_c) * mp.x
00353       - dec_fact_y * (dentdy/ent_c) * mp.y ;
00354 
00355     func_in.annule(nzet, nz-1) ;
00356     func_in.std_spectral_base() ;
00357 
00358     Scalar func_ex(mp) ;
00359     func_ex = 1. ;
00360     func_ex.annule(0, nzet-1) ;
00361     func_ex.std_spectral_base() ;
00362 
00363     // New enthalpy field
00364     // ------------------
00365     ent = ent * (func_in + func_ex) ;
00366 
00367     (ent.set_spectral_va()).smooth(nzet, ent.set_spectral_va()) ;
00368 
00369     double dentdx_new = ent.dsdx().val_grid_point(0,0,0,0) ;
00370     double dentdy_new = ent.dsdy().val_grid_point(0,0,0,0) ;
00371     cout << "dH/dx|_new    = " << dentdx_new << endl ;
00372     cout << "dH/dy|_new    = " << dentdy_new << endl ;
00373 
00374     //-----------------------------------------------------
00375     // Adaptation of the mapping to the new enthalpy field
00376     //-----------------------------------------------------
00377 
00378     double dent_eq = ent.dsdr().val_point(ray_eq_pi(),M_PI/2.,M_PI) ;
00379     double dent_pole = ent.dsdr().val_point(ray_pole(),0.,0.) ;
00380     double rap_dent = fabs( dent_eq / dent_pole ) ;
00381     cout << "| dH/dr_eq / dH/dr_pole | = " << rap_dent << endl ;
00382     diff_dHdr = rap_dent ;
00383 
00384     if ( rap_dent < thres_adapt ) {
00385         adapt_flag = 0 ;    // No adaptation of the mapping
00386         cout << "******* FROZEN MAPPING  *********" << endl ;
00387     }
00388     else {
00389         adapt_flag = 1 ;    // The adaptation of the mapping is to be
00390                             //  performed
00391     }
00392 
00393     ent_limit.set_etat_qcq() ;
00394     for (int l=0; l<nzet; l++) {    // loop on domains inside the star
00395         ent_limit.set(l) = ent.val_grid_point(l, k_b, j_b, i_b) ;
00396     }
00397     ent_limit.set(nzet-1) = ent_b  ;
00398 
00399     Map_et mp_prev = mp_et ;
00400 
00401     Cmp ent_cmp(ent) ;
00402     mp.adapt(ent_cmp, par_adapt) ;
00403     ent = ent_cmp ;
00404 
00405     // Readjustment of the external boundary of domain l=nzet
00406     // to keep a fixed ratio with respect to star's surface
00407 
00408     double rr_in_1 = mp.val_r(1, -1., M_PI/2., 0.) ;
00409 
00410     // Resize of the outer boundary of the shell including the BH
00411     double rr_out_nm2 = mp.val_r(nz-2, 1., M_PI/2., 0.) ;
00412     mp.resize(nz-2, rr_in_1/rr_out_nm2 * fact_resize(1)) ;
00413 
00414     // Resize of the inner boundary of the shell including the BH
00415     double rr_out_nm3 = mp.val_r(nz-3, 1., M_PI/2., 0.) ;
00416     mp.resize(nz-3, rr_in_1/rr_out_nm3 * fact_resize(0)) ;
00417 
00418     //  if (mer % 2 == 0) {
00419 
00420     if (nz > 4) {
00421 
00422       // Resize of the domain 1
00423       double rr_out_1 = mp.val_r(1, 1., M_PI/2., 0.) ;
00424       mp.resize(1, rr_in_1/rr_out_1 * resize_ns) ;
00425 
00426       if (nz > 5) {
00427 
00428         // Resize of the domain from 2 to N-4
00429         double rr_out_nm3_new = mp.val_r(nz-3, 1., M_PI/2., 0.) ;
00430 
00431         for (int i=1; i<nz-4; i++) {
00432 
00433           double rr_out_i = mp.val_r(i, 1., M_PI/2., 0.) ;
00434 
00435           double rr_mid = rr_out_i
00436         + (rr_out_nm3_new - rr_out_i) / double(nz - 3 - i) ;
00437 
00438           double rr_2timesi = 2. * rr_out_i ;
00439 
00440           if (rr_2timesi < rr_mid) {
00441 
00442         double rr_out_ip1 = mp.val_r(i+1, 1., M_PI/2., 0.) ;
00443         mp.resize(i+1, rr_2timesi / rr_out_ip1) ;
00444 
00445           }
00446           else {
00447 
00448         double rr_out_ip1 = mp.val_r(i+1, 1., M_PI/2., 0.) ;
00449         mp.resize(i+1, rr_mid / rr_out_ip1) ;
00450 
00451           }  // End of else
00452 
00453         }  // End of i loop
00454 
00455       }  // End of (nz > 5) loop
00456 
00457     }  // End of (nz > 4) loop
00458 
00459     //  }  // End of (mer % 2) loop
00460 
00461     //----------------------------------------------------
00462     // Computation of the enthalpy at the new grid points
00463     //----------------------------------------------------
00464 
00465     mp_prev.homothetie(alpha_r) ;
00466 
00467     Cmp ent_cmp2 (ent) ;
00468     mp.reevaluate(&mp_prev, nzet+1, ent_cmp2) ;
00469     ent = ent_cmp2 ;
00470 
00471     double ent_s_max = -1 ;
00472     int k_s_max = -1 ;
00473     int j_s_max = -1 ;
00474     
00475     for (int k=0; k<mg->get_np(l_b); k++) {
00476         for (int j=0; j<mg->get_nt(l_b); j++) {
00477             double xx = fabs( ent.val_grid_point(l_b, k, j, i_b) ) ;
00478         if (xx > ent_s_max) {
00479             ent_s_max = xx ;
00480             k_s_max = k ;
00481             j_s_max = j ;
00482         }
00483         }
00484     }
00485     cout << "Max. abs(enthalpy) at the boundary between domains nzet-1"
00486          << " and nzet : " << endl ;
00487     cout << "   " << ent_s_max << " reached for k = " << k_s_max
00488          << " and j = " << j_s_max << endl ;
00489 
00490     //-------------------
00491     // Equation of state
00492     //-------------------
00493 
00494     equation_of_state() ;   // computes new values for nbar (n), ener (e)
00495                             // and press (p) from the new ent (H)
00496 
00497     //----------------------------------------------------------
00498     // Matter source terms in the gravitational field equations
00499     //----------------------------------------------------------
00500 
00501     hydro_euler_bhns(kerrschild, mass_bh, sepa) ;
00502                           // computes new values for ener_euler (E),
00503                           // s_euler (S) and u_euler (U^i)
00504 
00505 
00506     //-------------------------------------------------
00507     // Computation of the minimum of the indicator chi
00508     //-------------------------------------------------
00509     double azimu_min = phi_min() ;
00510     double rad_chi_min = radius_p(azimu_min) ;
00511     double chi_min = chi_rp(rad_chi_min, azimu_min) ;
00512 
00513     cout << "| dH/dr_eq / dH/dr_pole | (minimum) = " << chi_min << endl ;
00514     cout << "     phi =    " << azimu_min / M_PI << " [M_PI]" << endl ;
00515     cout << "     radius = " << rad_chi_min / km << " [km]" << endl ;
00516 
00517     diff_dHdr_min = chi_min ;
00518     diff_phi_min = azimu_min ;
00519     diff_radius = rad_chi_min ;
00520 
00521     //-----------------------------------
00522     // Poisson equation for lapconf_auto
00523     //-----------------------------------
00524 
00525     // Source
00526     //--------
00527 
00528     Scalar sou_lap1(mp) ;  // dzpuis = 0
00529     sou_lap1 = qpig * lapconf_tot_tmp * pow(confo_tot,4.)
00530       * (0.5*ener_euler + s_euler) ;
00531 
00532     sou_lap1.std_spectral_base() ;
00533     sou_lap1.annule(nzet,nz-1) ;
00534     sou_lap1.inc_dzpuis(4) ;  // dzpuis : 0 -> 4
00535 
00536     Scalar sou_lap2(mp) ;  // dzpuis = 4
00537     sou_lap2 =  0.875 * (lapconf_auto+0.5) * taij_quad_auto
00538       / pow(confo_auto+0.5,8.) ;
00539     sou_lap2.std_spectral_base() ;
00540 
00541     source_lapconf = sou_lap1 + sou_lap2 ;
00542 
00543     source_lapconf.std_spectral_base() ;
00544     //  source_lapse.annule(nzet,nz-1) ;
00545 
00546     if (filter_r != 0) {
00547         if (source_lapconf.get_etat() != ETATZERO) {
00548             source_lapconf.filtre(filter_r) ;
00549         //          source_lapse.filtre_r(filter_r,0) ;
00550         }
00551     }
00552 
00553     assert(source_lapconf.get_dzpuis() == 4) ;
00554 
00555     // Resolution of the Poisson equation (Outer BC : lapconf_m1 -> 0)
00556     // ----------------------------------
00557 
00558     lapconf_m1.set_etat_qcq() ;
00559     lapconf_m1 = lapconf_auto - 0.5 ;
00560     source_lapconf.poisson(par_lapconf, lapconf_m1) ;
00561     ssjm1_lapconf = ssjm1lapconf ;
00562 
00563     // Check: has the Poisson equation been correctly solved ?
00564     // -------------------------------------------------------
00565 
00566     Tbl tdiff_lapconf = diffrel(lapconf_m1.laplacian(), source_lapconf) ;
00567     cout <<
00568       "Relative error in the resolution of the equation for lapconf_auto : "
00569          << endl ;
00570     for (int l=0; l<nz; l++) {
00571         cout << tdiff_lapconf(l) << "  " ;
00572     }
00573     cout << endl ;
00574     diff_lapconf = max(abs(tdiff_lapconf)) ;
00575 
00576     // Re-construction of the lapconf function
00577     // ---------------------------------------
00578     lapconf_auto = lapconf_m1 + 0.5 ;
00579               // lapconf_tot = lapconf_auto + lapconf_comp
00580               // lapconf_auto, _comp -> 0.5 (r -> inf)
00581               // lapconf_tot -> 1 (r -> inf)
00582 
00583     //---------------------------------
00584     // Poisson equation for confo_auto
00585     //---------------------------------
00586 
00587     // Source
00588     //--------
00589 
00590     Scalar sou_con1(mp) ;  // dzpuis = 0
00591     sou_con1 = - 0.5 * qpig * pow(confo_tot,5.) * ener_euler ;
00592     sou_con1.std_spectral_base() ;
00593     sou_con1.annule(nzet,nz-1) ;
00594     sou_con1.inc_dzpuis(4) ;  // dzpuis : 0 -> 4
00595 
00596     Scalar sou_con2(mp) ;  // dzpuis = 4
00597     sou_con2 = - 0.125 * taij_quad_auto / pow(confo_auto+0.5,7.) ;
00598     sou_con2.std_spectral_base() ;
00599 
00600     source_confo = sou_con1 + sou_con2 ;
00601 
00602     source_confo.std_spectral_base() ;
00603     //  source_confo.annule(nzet,nz-1) ;
00604 
00605     if (filter_r != 0) {
00606         if (source_confo.get_etat() != ETATZERO) {
00607             source_confo.filtre(filter_r) ;
00608         //          source_confo.filtre_r(filter_r,0) ;
00609         }
00610     }
00611 
00612     assert(source_confo.get_dzpuis() == 4) ;
00613 
00614     // Resolution of the Poisson equation (Outer BC : confo_m1 -> 0)
00615     // ----------------------------------
00616 
00617     confo_m1.set_etat_qcq() ;
00618     confo_m1 = confo_auto - 0.5 ;
00619     source_confo.poisson(par_confo, confo_m1) ;
00620     ssjm1_confo = ssjm1confo ;
00621 
00622     // Check: has the Poisson equation been correctly solved ?
00623     // -------------------------------------------------------
00624 
00625     Tbl tdiff_confo = diffrel(confo_m1.laplacian(), source_confo) ;
00626     cout <<
00627       "Relative error in the resolution of the equation for confo_auto : "
00628          << endl ;
00629     for (int l=0; l<nz; l++) {
00630         cout << tdiff_confo(l) << "  " ;
00631     }
00632     cout << endl ;
00633     diff_confo = max(abs(tdiff_confo)) ;
00634 
00635     // Re-construction of the conformal factor
00636     // ---------------------------------------
00637     confo_auto = confo_m1 + 0.5 ; // confo_tot = confo_auto + confo_comp
00638                                       // confo_auto, _comp -> 0.5 (r -> inf)
00639                                   // confo_tot -> 1 (r -> inf)
00640 
00641     //----------------------------------------
00642     // Vector Poisson equation for shift_auto
00643     //----------------------------------------
00644 
00645     // Source
00646     // ------
00647 
00648     Vector sou_shif1(mp, CON, mp.get_bvect_cart()) ;  // dzpuis = 0
00649     sou_shif1.set_etat_qcq() ;
00650 
00651     for (int i=1; i<=3; i++) {
00652         sou_shif1.set(i) = 4.*qpig * lapconf_tot_tmp
00653           * pow(confo_tot, 3.)
00654           * (ener_euler + press) * u_euler(i) ;
00655     }
00656 
00657     sou_shif1.std_spectral_base() ;
00658     sou_shif1.annule(nzet, nz-1) ;
00659 
00660     for (int i=1; i<=3; i++) {
00661         (sou_shif1.set(i)).inc_dzpuis(4) ;  // dzpuis: 0 -> 4
00662     }
00663 
00664     Vector sou_shif2(mp, CON, mp.get_bvect_cart()) ;  // dzpuis = 4
00665     sou_shif2.set_etat_qcq() ;
00666     for (int i=1; i<=3; i++) {
00667         sou_shif2.set(i) = 2. *
00668           (taij_auto(i,1)*(d_lapconf_auto(1)
00669                    -7.*(lapconf_auto+0.5)*d_confo_auto(1)
00670                    /(confo_auto+0.5))
00671            +taij_auto(i,2)*(d_lapconf_auto(2)
00672                 -7.*(lapconf_auto+0.5)*d_confo_auto(2)
00673                 /(confo_auto+0.5))
00674            +taij_auto(i,3)*(d_lapconf_auto(3)
00675                 -7.*(lapconf_auto+0.5)*d_confo_auto(3)
00676                 /(confo_auto+0.5))
00677            ) / pow(confo_auto+0.5,7.) ;
00678     }
00679     sou_shif2.std_spectral_base() ;
00680 
00681     source_shift = sou_shif1 + sou_shif2 ;
00682 
00683     source_shift.std_spectral_base() ;
00684     //  source_shift.annule(nzet, nz-1) ;
00685 
00686     // Resolution of the Poisson equation
00687     // ----------------------------------
00688 
00689     // Filter for the source of shift vector
00690 
00691     if (filter_r_s != 0) {
00692         for (int i=1; i<=3; i++) {
00693             if (source_shift(i).get_etat() != ETATZERO) {
00694             source_shift.set(i).filtre(filter_r_s) ;
00695             //          source_shift.set(i).filtre_r(filter_r_s, 0) ;
00696         }
00697         }
00698     }
00699 
00700     if (filter_p_s != 0) {
00701         for (int i=1; i<=3; i++) {
00702             if (source_shift(i).get_etat() != ETATZERO) {
00703             (source_shift.set(i)).filtre_phi(filter_p_s, nz-1) ;
00704             //          (source_shift.set(i)).filtre_phi(filter_p_s, 0) ;
00705         }
00706         }
00707     }
00708 
00709     for (int i=1; i<=3; i++) {
00710         if(source_shift(i).dz_nonzero()) {
00711             assert( source_shift(i).get_dzpuis() == 4 ) ;
00712         }
00713         else {
00714             (source_shift.set(i)).set_dzpuis(4) ;
00715         }
00716     }
00717 
00718     double lambda = double(1) / double(3) ;
00719 
00720     Tenseur source_p(mp, 1, CON, mp.get_bvect_cart() ) ;
00721     source_p.set_etat_qcq() ;
00722     for (int i=0; i<3; i++) {
00723         source_p.set(i) = Cmp(source_shift(i+1)) ;
00724     }
00725 
00726     Tenseur vect_auxi(mp, 1, CON, mp.get_bvect_cart()) ;
00727     vect_auxi.set_etat_qcq() ;
00728     for (int i=0; i<3 ;i++) {
00729         vect_auxi.set(i) = 0. ;
00730     }
00731     Tenseur scal_auxi(mp) ;
00732     scal_auxi.set_etat_qcq() ;
00733     scal_auxi.set().annule_hard() ;
00734     scal_auxi.set_std_base() ;
00735 
00736     Tenseur resu_p(mp, 1, CON, mp.get_bvect_cart() ) ;
00737     resu_p.set_etat_qcq() ;
00738 
00739     source_p.poisson_vect(lambda, par_shift2, resu_p, vect_auxi,
00740                   scal_auxi) ;
00741 
00742     for (int i=1; i<=3; i++)
00743         shift_auto.set(i) = resu_p(i-1) ;
00744 
00745     ssjm1_khi = ssjm1khi ;
00746 
00747     for (int i=0; i<3; i++) {
00748         ssjm1_wshift.set(i+1) = ssjm1wshift(i) ;
00749     }
00750 
00751     // Check: has the equation for shift_auto been correctly solved ?
00752     // --------------------------------------------------------------
00753 
00754     Vector lap_shift = shift_auto.derive_con(flat).divergence(flat)
00755       + lambda * shift_auto.divergence(flat).derive_con(flat) ;
00756 
00757     source_shift.dec_dzpuis() ;
00758 
00759     Tbl tdiff_shift_x = diffrel(lap_shift(1), source_shift(1)) ;
00760     Tbl tdiff_shift_y = diffrel(lap_shift(2), source_shift(2)) ;
00761     Tbl tdiff_shift_z = diffrel(lap_shift(3), source_shift(3)) ;
00762 
00763     cout <<
00764       "Relative error in the resolution of the equation for shift_auto : "
00765          << endl ;
00766     cout << "x component : " ;
00767     for (int l=0; l<nz; l++) {
00768         cout << tdiff_shift_x(l) << "  " ;
00769     }
00770     cout << endl ;
00771     cout << "y component : " ;
00772     for (int l=0; l<nz; l++) {
00773         cout << tdiff_shift_y(l) << "  " ;
00774     }
00775     cout << endl ;
00776     cout << "z component : " ;
00777     for (int l=0; l<nz; l++) {
00778         cout << tdiff_shift_z(l) << "  " ;
00779     }
00780     cout << endl ;
00781 
00782     diff_shift_x = max(abs(tdiff_shift_x)) ;
00783     diff_shift_y = max(abs(tdiff_shift_y)) ;
00784     diff_shift_z = max(abs(tdiff_shift_z)) ;
00785 
00786 
00787     //-----------------------------
00788     // Relative change in enthalpy
00789     //-----------------------------
00790 
00791     Tbl diff_ent_tbl = diffrel( ent, ent_jm1 ) ;
00792     diff_ent = diff_ent_tbl(0) ;
00793     for (int l=0; l<nzet; l++) {
00794         diff_ent += diff_ent_tbl(l) ;
00795     }
00796     diff_ent /= nzet ;
00797 
00798     ent_jm1 = ent ;
00799 
00800     /*
00801     des_profile( lapconf_auto, 0., 10.,
00802              M_PI/2., M_PI, "Self lapconf function of NS",
00803              "Lapconf (theta=pi/2, phi=0)" ) ;
00804 
00805     des_profile( lapconf_tot, 0., 10.,
00806              M_PI/2., M_PI, "Total lapconf function seen by NS",
00807              "Lapconf (theta=pi/2, phi=0)" ) ;
00808 
00809     des_profile( confo_auto, 0., 10.,
00810              M_PI/2., M_PI, "Self conformal factor of NS",
00811              "Confo (theta=pi/2, phi=0)" ) ;
00812 
00813     des_profile( confo_tot, 0., 10.,
00814              M_PI/2., M_PI, "Total conformal factor seen by NS",
00815              "Confo (theta=pi/2, phi=0)" ) ;
00816 
00817     des_coupe_vect_z( shift_auto, 0., -3., 0.5, 3,
00818               "Self shift vector of NS") ;
00819 
00820     des_coupe_vect_z( shift_tot, 0., -3., 0.5, 3,
00821               "Total shift vector seen by NS") ;
00822     */
00823     } // End of main loop
00824 
00825     //=========================================================
00826     //                    End of iteration
00827     //=========================================================
00828 
00829 
00830 }

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