1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
|
/*
* Method of class Star_bhns to compute a sensitve indicator of
* the mass-shedding and quantities related to the indicator
*
* (see file star_bhns.h for documentation).
*
*/
/*
* Copyright (c) 2006 Keisuke Taniguchi
*
* This file is part of LORENE.
*
* LORENE is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* LORENE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LORENE; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
char star_bhns_chi_C[] = "$Header: /cvsroot/Lorene/C++/Source/Star_bhns/star_bhns_chi.C,v 1.3 2014/10/13 08:53:40 j_novak Exp $" ;
/*
* $Id: star_bhns_chi.C,v 1.3 2014/10/13 08:53:40 j_novak Exp $
* $Log: star_bhns_chi.C,v $
* Revision 1.3 2014/10/13 08:53:40 j_novak
* Lorene classes and functions now belong to the namespace Lorene.
*
* Revision 1.2 2014/10/06 15:13:16 j_novak
* Modified #include directives to use c++ syntax.
*
* Revision 1.1 2007/06/22 01:30:27 k_taniguchi
* *** empty log message ***
*
*
* $Header: /cvsroot/Lorene/C++/Source/Star_bhns/star_bhns_chi.C,v 1.3 2014/10/13 08:53:40 j_novak Exp $
*
*/
// C++ headers
//#include <>
// C headers
#include <cmath>
// Lorene headers
#include "star_bhns.h"
#include "param.h"
#include "tbl.h"
#include "utilitaires.h"
namespace Lorene {
double Star_bhns::chi_rp(double radius, double phi) {
const Scalar& dent = ent.dsdr() ;
double dent_pole = dent.val_point(ray_pole(), 0., 0.) ;
double dent_eq = dent.val_point(radius, M_PI/2., phi) ;
double chi = fabs( dent_eq / dent_pole ) ;
return chi ;
}
double Star_bhns::radius_p(double phi) {
double rad = mp.val_r(nzet-1, 1., M_PI/2., phi) ;
// We assume that the stellar surface is fitted to the domain (nzet-1)
return rad ;
}
double Star_bhns::phi_min() {
const Mg3d* mg = mp.get_mg() ;
int np = mg->get_np(0) ;
int nps2 = np/2 ;
Tbl phi(nps2+1) ;
phi.set_etat_qcq() ;
for (int i=0; i<=nps2; i++) {
phi.set(i) = 2.*M_PI*i/np + 0.5*M_PI ;
}
Tbl chi(nps2+1) ;
chi.set_etat_qcq() ;
for (int i=0; i<=nps2; i++) {
double phi_i = phi_local_min( phi(i) ) ;
double rad_i = radius_p( phi_i ) ;
chi.set(i) = chi_rp(rad_i, phi_i) ;
}
for (int i=0; i<=nps2; i++) {
cout.precision(16) ;
cout << "chi(" << i << ") = " << chi(i)
<< " phi = " << phi_local_min( phi(i) ) / M_PI
<< " [M_PI]" << endl ;
cout.precision(4) ;
}
double chi_ini = chi(0) ; // Initialization
double delta_chi ;
int jj = 0 ; // Initialization
for (int i=0; i<nps2; i++) {
if ( chi(i+1) < 1.e-12 )
chi.set(i+1) = 1. ;
delta_chi = chi_ini - chi(i+1) ;
if ( delta_chi > 0. ) {
chi_ini = chi(i+1) ;
jj = i+1 ;
}
}
double phi_glob_min = phi_local_min( phi(jj) ) ;
return phi_glob_min ;
}
double Star_bhns::phi_local_min(double phi_ini) {
int mm ; // Number of steps to the phi direction
double ppp = phi_ini ; // Initial position of the phi coordinate
double diff ; // Difference between two succesive chi
double dp = M_PI/2. ; // Step interval to the phi direction
double ptmp ;
double rad1, rad2 ;
double init_check = chi_rp(radius_p(phi_ini), phi_ini)
- chi_rp(radius_p(phi_ini+1.e-10*dp), phi_ini+1.e-10*dp) ;
if ( init_check >= 0. ) {
while ( dp > 1.e-15 ) {
diff = 1. ;
mm = 0 ;
dp = 0.1 * dp ;
while ( diff > 0. && (ppp+mm*dp) < 2.*M_PI ) {
mm++ ;
ptmp = ppp + mm * dp ;
rad1 = radius_p(ptmp-dp) ;
rad2 = radius_p(ptmp) ;
diff = chi_rp(rad1, ptmp-dp) - chi_rp(rad2, ptmp) ;
}
ppp += (mm - 2) * dp ;
}
if ( (ppp+2.*dp) >= 2.*M_PI ) {
cout << "No minimum for phi > " << phi_ini / M_PI
<< " [M_PI]" << endl ;
}
}
else {
while ( dp > 1.e-15 ) {
diff = 1. ;
mm = 0 ;
dp = 0.1 * dp ;
while ( diff > 0. && (ppp-mm*dp) > 0. ) {
mm++ ;
ptmp = ppp - mm * dp ;
rad1 = radius_p(ptmp+dp) ;
rad2 = radius_p(ptmp) ;
diff = chi_rp(rad1, ptmp+dp) - chi_rp(rad2, ptmp) ;
}
ppp -= (mm - 2) * dp ;
}
if ( (ppp-2.*dp) < 0. ) {
cout << "No minimum for phi < " << phi_ini / M_PI
<< " [M_PI]" << endl ;
}
}
return ppp ;
}
}
|