strot_dirac_lambda_grv2.C

00001 /*
00002  * Method Star_rot_Dirac::lambda_grv2.
00003  *
00004  * (see file star_rot_dirac.h for documentation)
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2005 Lap-Ming Lin & Jerome Novak
00010  *   Copyright (c) 2000-2001 Eric Gourgoulhon for the previous Etoile version
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 as published by
00016  *   the Free Software Foundation; either version 2 of the License, or
00017  *   (at your option) any later version.
00018  *
00019  *   LORENE is distributed in the hope that it will be useful,
00020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  *   GNU General Public License for more details.
00023  *
00024  *   You should have received a copy of the GNU General Public License
00025  *   along with LORENE; if not, write to the Free Software
00026  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  *
00028  */
00029 
00030 
00031 char strot_dirac_lambda_grv2_C[] = "$Header: /cvsroot/Lorene/C++/Source/Star/strot_dirac_lambda_grv2.C,v 1.1 2005/01/31 14:08:08 j_novak Exp $" ;
00032 
00033 /*
00034  * $Id: strot_dirac_lambda_grv2.C,v 1.1 2005/01/31 14:08:08 j_novak Exp $
00035  * $Log: strot_dirac_lambda_grv2.C,v $
00036  * Revision 1.1  2005/01/31 14:08:08  j_novak
00037  * Methods to calculate the virial identity error.
00038  *
00039  *
00040  * $Header: /cvsroot/Lorene/C++/Source/Star/strot_dirac_lambda_grv2.C,v 1.1 2005/01/31 14:08:08 j_novak Exp $
00041  *
00042  */
00043 
00044 // Headers C
00045 #include <math.h>
00046 
00047 // Headers Lorene
00048 #include "star_rot_dirac.h"
00049 #include "proto_f77.h"
00050 
00051 double Star_rot_Dirac::lambda_grv2(const Scalar& sou_m, const Scalar& sou_q) {
00052 
00053   const Map_radial* mprad = dynamic_cast<const Map_radial*>( &sou_m.get_mp() ) ;
00054     
00055     if (mprad == 0x0) {
00056         cout << "Star_rot_Dirac::lambda_grv2: the mapping of sou_m does not"
00057              << endl << " belong to the class Map_radial !" << endl ;
00058         abort() ;
00059     }   
00060     
00061 
00062     assert( &sou_q.get_mp() == mprad ) ;
00063     
00064     sou_q.check_dzpuis(4) ;
00065     
00066     const Mg3d* mg = mprad->get_mg() ;
00067     int nz = mg->get_nzone() ;
00068         
00069     // Construction of a Map_af which coincides with *mp on the equator
00070     // ----------------------------------------------------------------
00071 
00072     double theta0 = M_PI / 2 ;      // Equator
00073     double phi0 = 0 ;
00074 
00075     Map_af mpaff(*mprad) ;
00076 
00077     for (int l=0 ; l<nz ; l++) {
00078         double rmax = mprad->val_r(l, double(1), theta0, phi0) ;
00079         switch ( mg->get_type_r(l) ) {
00080             case RARE:  {
00081                 double rmin = mprad->val_r(l, double(0), theta0, phi0) ;
00082                 mpaff.set_alpha(rmax - rmin, l) ;
00083                 mpaff.set_beta(rmin, l) ;
00084                 break ;
00085             }
00086     
00087             case FIN:   {
00088                 double rmin = mprad->val_r(l, double(-1), theta0, phi0) ;
00089                 mpaff.set_alpha( double(.5) * (rmax - rmin), l ) ;
00090                 mpaff.set_beta( double(.5) * (rmax + rmin), l) ;
00091                 break ;
00092             }
00093     
00094             case UNSURR: {
00095                 double rmin = mprad->val_r(l, double(-1), theta0, phi0) ;
00096                 double umax = double(1) / rmin ;
00097                 double umin = double(1) / rmax ;
00098                 mpaff.set_alpha( double(.5) * (umin - umax),  l) ;
00099                 mpaff.set_beta( double(.5) * (umin + umax), l) ;
00100                 break ;
00101             }
00102     
00103             default: {
00104                 cout << "Star_rot_Dirac::lambda_grv2: unknown type_r ! " << endl ;
00105                 abort () ;
00106                 break ;
00107             }
00108     
00109         }
00110     }
00111 
00112 
00113     // Reduced Jacobian of
00114     // the transformation  (r,theta,phi) <-> (dzeta,theta',phi')
00115     // ------------------------------------------------------------
00116     
00117     Mtbl jac = 1 / ( (mprad->xsr) * (mprad->dxdr) ) ;   
00118                                 // R/x dR/dx in the nucleus
00119                                 // R dR/dx   in the shells
00120                                 // - U/(x-1) dU/dx in the ZEC                       
00121     for (int l=0; l<nz; l++) {
00122         switch ( mg->get_type_r(l) ) {
00123             case RARE:  {
00124                 double a1 = mpaff.get_alpha()[l] ;
00125                 *(jac.t[l]) =  *(jac.t[l]) / (a1*a1) ;
00126                 break ;
00127             }
00128     
00129             case FIN:   {
00130                 double a1 = mpaff.get_alpha()[l] ;
00131                 double b1 = mpaff.get_beta()[l] ;
00132                 assert( jac.t[l]->get_etat() == ETATQCQ ) ;
00133                 double* tjac = jac.t[l]->t ;
00134                 double* const xi = mg->get_grille3d(l)->x ;
00135                 for (int k=0; k<mg->get_np(l); k++) {
00136                     for (int j=0; j<mg->get_nt(l); j++) {
00137                         for (int i=0; i<mg->get_nr(l); i++) {
00138                             *tjac = *tjac /
00139                                     (a1 * (a1 * xi[i] + b1) ) ;
00140                             tjac++ ;    
00141                         }
00142                     }
00143                 }               
00144                 
00145                 break ;
00146             }
00147     
00148             case UNSURR: {
00149                 double a1 = mpaff.get_alpha()[l] ;
00150                 *(jac.t[l]) = - *(jac.t[l]) / (a1*a1) ;
00151                 break ;
00152             }
00153     
00154             default: {
00155                 cout << "Star_rot_Dirac::lambda_grv2: unknown type_r ! " << endl ;
00156                 abort () ;
00157                 break ;
00158             }
00159     
00160         }
00161     
00162     }
00163 
00164 
00165     // Multiplication of the sources by the reduced Jacobian:
00166     // -----------------------------------------------------
00167         
00168     Mtbl s_m(mg) ;
00169     if ( sou_m.get_etat() == ETATZERO ) {
00170         s_m = 0 ;
00171     }
00172     else{
00173         assert(sou_m.get_spectral_va().get_etat() == ETATQCQ) ; 
00174         sou_m.get_spectral_va().coef_i() ;  
00175         s_m = *(sou_m.get_spectral_va().c) ;
00176     }
00177         
00178     Mtbl s_q(mg) ;
00179     if ( sou_q.get_etat() == ETATZERO ) {
00180         s_q = 0 ;
00181     }
00182     else{
00183         assert(sou_q.get_spectral_va().get_etat() == ETATQCQ) ; 
00184         sou_q.get_spectral_va().coef_i() ;  
00185         s_q = *(sou_q.get_spectral_va().c) ;
00186     }
00187             
00188     s_m *= jac ;
00189     s_q *= jac ;
00190         
00191     
00192     // Preparations for the call to the Fortran subroutine
00193     // ---------------------------------------------------                              
00194     
00195     int np1 = 1 ;       // Axisymmetry enforced
00196     int nt = mg->get_nt(0) ;
00197     int nt2 = 2*nt - 1 ;    // Number of points for the theta sampling
00198                             //  in [0,Pi], instead of [0,Pi/2]
00199 
00200     // Array NDL
00201     // ---------
00202     int* ndl = new int[nz+4] ;
00203     ndl[0] = nz ;
00204     for (int l=0; l<nz; l++) {
00205         ndl[1+l] = mg->get_nr(l) ;
00206     }
00207     ndl[1+nz] = nt2 ;
00208     ndl[2+nz] = np1 ;
00209     ndl[3+nz] = nz ;
00210 
00211     // Parameters NDR, NDT, NDP
00212     // ------------------------
00213     int nrmax = 0 ;
00214     for (int l=0; l<nz ; l++) {
00215         nrmax = ( ndl[1+l] > nrmax ) ? ndl[1+l] : nrmax ;
00216     }
00217     int ndr = nrmax + 5 ;
00218     int ndt = nt2 + 2 ;
00219     int ndp = np1 + 2 ;
00220 
00221     // Array ERRE
00222     // ----------
00223 
00224     double* erre = new double [nz*ndr] ;
00225 
00226     for (int l=0; l<nz; l++) {
00227         double a1 = mpaff.get_alpha()[l] ;
00228         double b1 = mpaff.get_beta()[l] ;
00229         for (int i=0; i<ndl[1+l]; i++) {
00230             double xi = mg->get_grille3d(l)->x[i] ;
00231             erre[ ndr*l + i ] = a1 * xi + b1 ;
00232         }
00233     }
00234 
00235     // Arrays containing the data
00236     // --------------------------
00237 
00238     int ndrt = ndr*ndt ;
00239     int ndrtp = ndr*ndt*ndp ;
00240     int taille = ndrtp*nz ;
00241 
00242     double* tsou_m = new double[ taille ] ;
00243     double* tsou_q = new double[ taille ] ;
00244 
00245     // Initialisation to zero :
00246     for (int i=0; i<taille; i++) {
00247         tsou_m[i] = 0 ;
00248         tsou_q[i] = 0 ;
00249     }
00250 
00251     // Copy of s_m into tsou_m
00252     // -----------------------
00253 
00254     for (int l=0; l<nz; l++) {
00255        for (int k=0; k<np1; k++) {
00256             for (int j=0; j<nt; j++) {
00257                 for (int i=0; i<mg->get_nr(l); i++) {
00258                     double xx = s_m(l, k, j, i) ;
00259                     tsou_m[ndrtp*l + ndrt*k + ndr*j + i] = xx ;
00260                     // point symetrique par rapport au plan theta = pi/2 :
00261                     tsou_m[ndrtp*l + ndrt*k + ndr*(nt2-1-j) + i] = xx ;         
00262                 }
00263             }
00264         }
00265     }
00266 
00267     // Copy of s_q into tsou_q
00268     // -----------------------
00269 
00270     for (int l=0; l<nz; l++) {
00271        for (int k=0; k<np1; k++) {
00272             for (int j=0; j<nt; j++) {
00273                 for (int i=0; i<mg->get_nr(l); i++) {
00274                     double xx = s_q(l, k, j, i) ;
00275                     tsou_q[ndrtp*l + ndrt*k + ndr*j + i] = xx ;
00276                     // point symetrique par rapport au plan theta = pi/2 :
00277                     tsou_q[ndrtp*l + ndrt*k + ndr*(nt2-1-j) + i] = xx ;         
00278                 }
00279             }
00280         }
00281     }
00282 
00283     
00284     // Computation of the integrals
00285     // ----------------------------
00286 
00287     double int_m, int_q ;
00288     F77_integrale2d(ndl, &ndr, &ndt, &ndp, erre, tsou_m, &int_m) ;
00289     F77_integrale2d(ndl, &ndr, &ndt, &ndp, erre, tsou_q, &int_q) ;
00290 
00291     // Cleaning
00292     // --------
00293 
00294     delete [] ndl ;
00295     delete [] erre ;
00296     delete [] tsou_m ;
00297     delete [] tsou_q ;
00298 
00299     // Computation of lambda
00300     // ---------------------
00301 
00302     double lambda ;
00303     if ( int_q != double(0) ) {
00304         lambda = - int_m / int_q ;
00305     }
00306     else{
00307         lambda = 0 ;
00308     }
00309     
00310     return lambda ;
00311     
00312 }

Generated on Thu Oct 21 01:35:18 2010 for LORENE by  doxygen 1.4.6