star_bhns_chi.C

00001 /*
00002  *  Method of class Star_bhns to compute a sensitve indicator of
00003  *   the mass-shedding and quantities related to the indicator
00004  *
00005  *    (see file star_bhns.h for documentation).
00006  *
00007  */
00008 
00009 /*
00010  *   Copyright (c) 2006 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_chi_C[] = "$Header: /cvsroot/Lorene/C++/Source/Star_bhns/star_bhns_chi.C,v 1.1 2007/06/22 01:30:27 k_taniguchi Exp $" ;
00030 
00031 /*
00032  * $Id: star_bhns_chi.C,v 1.1 2007/06/22 01:30:27 k_taniguchi Exp $
00033  * $Log: star_bhns_chi.C,v $
00034  * Revision 1.1  2007/06/22 01:30:27  k_taniguchi
00035  * *** empty log message ***
00036  *
00037  *
00038  * $Header: /cvsroot/Lorene/C++/Source/Star_bhns/star_bhns_chi.C,v 1.1 2007/06/22 01:30:27 k_taniguchi Exp $
00039  *
00040  */
00041 
00042 // C++ headers
00043 //#include <>
00044 
00045 // C headers
00046 #include <math.h>
00047 
00048 // Lorene headers
00049 #include "star_bhns.h"
00050 #include "param.h"
00051 #include "tbl.h"
00052 #include "utilitaires.h"
00053 
00054 double Star_bhns::chi_rp(double radius, double phi) {
00055 
00056     const Scalar& dent = ent.dsdr() ;
00057 
00058     double dent_pole = dent.val_point(ray_pole(), 0., 0.) ;
00059     double dent_eq = dent.val_point(radius, M_PI/2., phi) ;
00060 
00061     double chi = fabs( dent_eq / dent_pole ) ;
00062 
00063     return chi ;
00064 
00065 }
00066 
00067 double Star_bhns::radius_p(double phi) {
00068 
00069     double rad = mp.val_r(nzet-1, 1., M_PI/2., phi) ;
00070     // We assume that the stellar surface is fitted to the domain (nzet-1)
00071 
00072     return rad ;
00073 
00074 }
00075 
00076 double Star_bhns::phi_min() {
00077 
00078     const Mg3d* mg = mp.get_mg() ;
00079     int np = mg->get_np(0) ;
00080     int nps2 = np/2 ;
00081 
00082     Tbl phi(nps2+1) ;
00083     phi.set_etat_qcq() ;
00084 
00085     for (int i=0; i<=nps2; i++) {
00086         phi.set(i) = 2.*M_PI*i/np + 0.5*M_PI ;
00087     }
00088 
00089     Tbl chi(nps2+1) ;
00090     chi.set_etat_qcq() ;
00091 
00092     for (int i=0; i<=nps2; i++) {
00093 
00094         double phi_i = phi_local_min( phi(i) ) ;
00095     double rad_i = radius_p( phi_i ) ;
00096 
00097     chi.set(i) = chi_rp(rad_i, phi_i) ;
00098 
00099     }
00100 
00101     for (int i=0; i<=nps2; i++) {
00102 
00103         cout.precision(16) ;
00104     cout << "chi(" << i << ") = " << chi(i)
00105          << "  phi = " << phi_local_min( phi(i) ) / M_PI
00106          << " [M_PI]" << endl ;
00107     cout.precision(4) ;
00108 
00109     }
00110 
00111     double chi_ini = chi(0) ; // Initialization
00112     double delta_chi ;
00113     int jj = 0 ; // Initialization
00114 
00115     for (int i=0; i<nps2; i++) {
00116 
00117         if ( chi(i+1) < 1.e-12 )
00118         chi.set(i+1) = 1. ;
00119 
00120     delta_chi = chi_ini - chi(i+1) ;
00121 
00122     if ( delta_chi > 0. ) {
00123 
00124         chi_ini = chi(i+1) ;
00125         jj = i+1 ;
00126 
00127     }
00128 
00129     }
00130 
00131     double phi_glob_min = phi_local_min( phi(jj) ) ;
00132 
00133     return phi_glob_min ;
00134 
00135 }
00136 
00137 
00138 double Star_bhns::phi_local_min(double phi_ini) {
00139 
00140     int mm ;                // Number of steps to the phi direction
00141     double ppp = phi_ini ;  // Initial position of the phi coordinate
00142     double diff ;           // Difference between two succesive chi
00143     double dp = M_PI/2. ;   // Step interval to the phi direction
00144     double ptmp ;
00145 
00146     double rad1, rad2 ;
00147 
00148     double init_check = chi_rp(radius_p(phi_ini), phi_ini)
00149       - chi_rp(radius_p(phi_ini+1.e-10*dp), phi_ini+1.e-10*dp) ;
00150 
00151     if ( init_check >= 0. ) {
00152 
00153         while ( dp > 1.e-15 ) {
00154 
00155         diff = 1. ;
00156         mm = 0 ;
00157         dp = 0.1 * dp ;
00158 
00159         while ( diff > 0. && (ppp+mm*dp) < 2.*M_PI ) {
00160 
00161             mm++ ;
00162         ptmp = ppp + mm * dp ;
00163 
00164         rad1 = radius_p(ptmp-dp) ;
00165         rad2 = radius_p(ptmp) ;
00166 
00167         diff = chi_rp(rad1, ptmp-dp) - chi_rp(rad2, ptmp) ;
00168 
00169         }
00170 
00171         ppp += (mm - 2) * dp ;
00172 
00173     }
00174 
00175     if ( (ppp+2.*dp) >= 2.*M_PI ) {
00176 
00177         cout << "No minimum for phi > " << phi_ini / M_PI
00178          << " [M_PI]" << endl ;
00179 
00180     }
00181 
00182     }
00183     else {
00184 
00185         while ( dp > 1.e-15 ) {
00186 
00187         diff = 1. ;
00188         mm = 0 ;
00189         dp = 0.1 * dp ;
00190 
00191         while ( diff > 0. && (ppp-mm*dp) > 0. ) {
00192 
00193             mm++ ;
00194         ptmp = ppp - mm * dp ;
00195 
00196         rad1 = radius_p(ptmp+dp) ;
00197         rad2 = radius_p(ptmp) ;
00198 
00199         diff = chi_rp(rad1, ptmp+dp) - chi_rp(rad2, ptmp) ;
00200 
00201         }
00202 
00203         ppp -= (mm - 2) * dp ;
00204 
00205     }
00206 
00207     if ( (ppp-2.*dp) < 0. ) {
00208 
00209         cout << "No minimum for phi < " << phi_ini / M_PI
00210          << " [M_PI]" << endl ;
00211 
00212     }
00213 
00214     }
00215 
00216     return ppp ;
00217 
00218 }

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