00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 2008, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 #ifndef O2SCL_TOV_SOLVE_H 00024 #define O2SCL_TOV_SOLVE_H 00025 00026 #include <o2scl/tov_eos.h> 00027 #include <o2scl/smart_interp.h> 00028 00029 #ifndef DOXYGENP 00030 namespace o2scl { 00031 #endif 00032 00033 /** 00034 \brief Class to solve the Tolman-Oppenheimer-Volkov equations 00035 00036 Integrate Tolman-Oppenheimer-Volkov (TOV) equations 00037 00038 The present code, as demonstrated in the tests, gives the 00039 correct central pressure and energy density of the analytical 00040 solution by Buchdahl to within less than 1 part in \f$ 10^5 \f$. 00041 00042 The TOV equations (i.e. Einstein's equations for a 00043 static spherically symmetric object) are 00044 \f[ 00045 \frac{d m}{d r} = 4 \pi r^2 \varepsilon 00046 \f] 00047 \f[ 00048 \frac{d P}{d r} = - \frac{G \varepsilon m}{r^2} 00049 \left( 1+\frac{P}{\varepsilon}\right) 00050 \left( 1+\frac{4 \pi P r^3}{m} \right) 00051 \left( 1-\frac{2 G m}{r}\right)^{-1} 00052 \f] 00053 where \f$r\f$ is the radial coordinate, \f$m(r)\f$ is the mass 00054 enclosed within a radius \f$r\f$, and \f$\varepsilon(r)\f$ and 00055 \f$P(r)\f$ are the energy density and pressure at \f$r\f$, and 00056 \f$G\f$ is the gravitational constant. The boundary conditions 00057 are \f$m(r=0)=0\f$ the condition \f$P(r=R)=0\f$ for some fixed 00058 radius \f$R\f$. These boundary conditions give a series of 00059 solutions to the TOV equations as a function of the radius, 00060 although they do not necessarily have a solution for all radii. 00061 00062 The gravitational mass is given by 00063 \f[ 00064 M_G = \int_0^R 4 \pi r^2 \varepsilon d r 00065 \f] 00066 while the baryonic mass is given by 00067 \f[ 00068 M_B = \int_0^R 4 \pi r^2 n_B m_B 00069 \left(1-\frac{G m}{r}\right)^{-1/2} d r 00070 \f] 00071 where \f$n_B(r)\f$ is the baryon number density at radius 00072 \f$r\f$ and \f$m_B\f$ is the mass of one baryon. 00073 00074 The gravitational potential, \f$\Phi(r)\f$ can be determined from 00075 \f[ 00076 \frac{d \Phi}{d r} = - \frac{1}{\varepsilon} 00077 \frac{ d P}{d r} \left(1+\frac{P}{\varepsilon}\right)^{-1} 00078 \f] 00079 00080 The proper boundary condition for the gravitational potential 00081 is 00082 \f[ 00083 \Phi(r=R) = \frac{1}{2} \ln \left(1-\frac{2 G M}{R} \right) 00084 \f] 00085 00086 The equation of state may be changed at any time. 00087 00088 Note that the pressure in the low-density eos is not 00089 strictly increasing! (see at P=4.3e-10) 00090 00091 <b>Screen output</b> 00092 - \c verbose=0 - Nothing (even if an error occurs). 00093 - \c verbose=1 - Some basic information and any errors or 00094 warnings. 00095 - \c verbose=2 - For each profile computation, information 00096 at every kilometer. 00097 - \c verbose=3 - Profile information every 20 grid points. A 00098 keypress is required after each profile. 00099 00100 \todo 00101 - The error handler is called in tov_solve()::derivs for 00102 pressures less than the minimum even in normal circumstances. 00103 This should be fixed, so that errors are more rare 00104 - baryon mass doesn't work for fixed() (This may be fixed. We should 00105 make sure it's tested.) 00106 - Combine maxoutsize and kmax? 00107 - Document column naming issues 00108 00109 \future 00110 - Turn numbers in max() function into variables 00111 00112 */ 00113 class tov_solve { 00114 public: 00115 00116 /// \name Basic properties 00117 //@{ 00118 /// mass 00119 double mass; 00120 /// radius 00121 double rad; 00122 /// baryonic mass 00123 double bmass; 00124 /// gravitational potential 00125 double gpot; 00126 //@} 00127 00128 /// \name Solution parameters 00129 /** 00130 These parameters can be changed at any time. 00131 */ 00132 //@{ 00133 /// Use general relativistic version (default true) 00134 bool generel; 00135 /** \brief calculate the gravitational potential and the enclosed 00136 baryon mass (default false) 00137 */ 00138 bool calcgpot; 00139 /// smallest allowed radial stepsize (default 1.0e-4) 00140 double hmin; 00141 /// largest allowed radial stepsize (default 0.05) 00142 double hmax; 00143 /// initial radial stepsize (default 4.0e-3) 00144 double hstart; 00145 /// control for output (default 1) 00146 int verbose; 00147 /// maximum radius for integration in km (default 60) 00148 double maxradius; 00149 //@} 00150 00151 /// \name Mass versus radius parameters 00152 00153 //@{ 00154 /// Beginning pressure (default 7.0e-7) 00155 double prbegin; 00156 /// Ending pressure (default 8.0e-3) 00157 double prend; 00158 /// Increment for pressure (default 1.1) 00159 double princ; 00160 /// Use 'princ' as a multiplier, not an additive increment (default true) 00161 bool logmode; 00162 /** \brief Guess for central pressure in solar masses per km3 00163 (default \f$ 5.2 \times 10^{-5} \f$) 00164 00165 This guess is used in the function fixed(). 00166 */ 00167 double prguess; 00168 //@} 00169 00170 /// \name Fixed mass parameters 00171 00172 //@{ 00173 /** 00174 \brief Target mass 00175 00176 Use negative values to indicate a mass measured relative to the 00177 maximum mass. For example, if the EOS has a maximum mass of 2.0, then 00178 -0.15 will give the profile of a 1.85 solar mass star. 00179 */ 00180 double tmass; 00181 //@} 00182 00183 /// \name Results 00184 00185 //@{ 00186 /** \brief Return the results data table 00187 */ 00188 table &get_results() {return out_table;} 00189 //@} 00190 00191 //-------------------------------------------- 00192 // Function prototypes 00193 00194 tov_solve(); 00195 00196 ~tov_solve(); 00197 00198 /// \name Actual solution of equations 00199 //@{ 00200 /// Calculate the mass vs. radius curve 00201 int mvsr(); 00202 /// Calculate the profile of a star with fixed mass 00203 int fixed(double d_tmass); 00204 /// Calculate the profile of the maximum mass star 00205 int max(); 00206 //@} 00207 00208 /** 00209 \brief Check the solution (unfinished) 00210 */ 00211 int solution_check(); 00212 00213 /// Set units 00214 int set_units(double s_efactor=1.0, double s_pfactor=1.0, 00215 double s_nbfactor=1.0); 00216 00217 /** 00218 \brief Set units 00219 00220 Valid entries for the units of energy density and pressure are: 00221 - "g/cm^3" 00222 - "erg/cm^3" 00223 - "MeV/fm^3" 00224 - "fm^-4" 00225 - "Msun/km^3" (i.e. solar masses per cubic kilometer) 00226 00227 Valid entries for the units of baryon density are: 00228 - "m^-3" 00229 - "cm^-3" 00230 - "fm^-3" 00231 */ 00232 int set_units(std::string eunits="", std::string punits="", 00233 std::string nunits=""); 00234 00235 /** 00236 \brief Set maximum storage for integration 00237 00238 The variable \c s_kmax is the maximum number of radial 00239 integration stepsk while \c s_maxoutsize is the maximum number 00240 of points that will be output for any profile. 00241 00242 If \c s_kmax is less than zero, there is no limit on 00243 the number of radial steps. 00244 */ 00245 int set_kmax(int s_maxoutsize=400, int s_kmax=40000); 00246 00247 /// Set the EOS to use 00248 int set_eos(tov_eos &ter) { 00249 te=&ter; 00250 eos_set=true; 00251 return 0; 00252 } 00253 00254 /** 00255 \brief Set solver 00256 */ 00257 int set_mroot(mroot<void *,mm_funct<void *> > &s_mrp) 00258 {mroot_ptr=&s_mrp; return 0;}; 00259 00260 /** 00261 \brief Set minimizer 00262 */ 00263 int set_minimize(minimize<void *,funct<void *> > &s_mp) 00264 {min_ptr=&s_mp; return 0;}; 00265 00266 /** 00267 \brief Set the adaptive stepper 00268 */ 00269 int set_stepper(adapt_step<void *,ode_funct<void *> > &sap) 00270 {as_ptr=&sap; return 0;}; 00271 00272 /// The default minimizer 00273 gsl_min_brent<void *,funct<void *> > def_min; 00274 00275 /// The default solver 00276 gsl_mroot_hybrids<void *,mm_funct<void *> > def_solver; 00277 00278 /// The default adaptive stepper 00279 gsl_astep<void *,ode_funct<void *> > def_stepper; 00280 00281 /// If true, compute the angular velocity (default false) 00282 bool compute_ang_vel; 00283 00284 /// The angular velocity 00285 double cap_omega; 00286 00287 /// The schwarzchild radius in km 00288 double schwarz_km; 00289 00290 #ifndef DOXYGEN_INTERNAL 00291 00292 friend class io_tlate<tov_solve>; 00293 00294 protected: 00295 00296 /** 00297 \brief Ensure \c col does not match strings in \c cnames 00298 */ 00299 int make_unique_name(std::string &col, 00300 std::vector<std::string> &cnames); 00301 00302 /// The EOS 00303 tov_eos *te; 00304 00305 /// True if the EOS has been set 00306 bool eos_set; 00307 00308 /// Define some necessary I/O objects 00309 base_ioc bio; 00310 00311 /// \name User EOS 00312 //@{ 00313 /// Units for energy density 00314 std::string eunits; 00315 /// Units for pressure 00316 std::string punits; 00317 /// Units for baryon density 00318 std::string nunits; 00319 /// unit conversion factor for energy density (default 1.0) 00320 double efactor; 00321 /// unit conversion factor for pressure (default 1.0) 00322 double pfactor; 00323 /// unit conversion factor for baryon density (default 1.0) 00324 double nfactor; 00325 //@} 00326 00327 /// maximum storage size (default 40000) 00328 int kmax; 00329 /// maximum size of output file (default 400) 00330 int maxoutsize; 00331 00332 /** 00333 \brief Smallest allowed pressure for integration (default: -100) 00334 00335 This can't be much 00336 smaller since we need to compute numbers near exp(-presmin) 00337 */ 00338 double presmin; 00339 00340 /// \name Integration storage 00341 //@{ 00342 ovector rky[6], rkx, rkdydx[6]; 00343 //@} 00344 00345 /// The output table 00346 table out_table; 00347 00348 /// The solver 00349 mroot<void *,mm_funct<void *> > *mroot_ptr; 00350 00351 /// The minimizer 00352 minimize<void *,funct<void *> > *min_ptr; 00353 00354 /// The default adaptive stepper 00355 adapt_step<void *,ode_funct<void *> > *as_ptr; 00356 00357 /// The ODE step function 00358 int derivs(double x, size_t nv, const ovector_view &y, 00359 ovector_view &dydx, void *&pa); 00360 00361 /// The ODE step function for the angular velocity 00362 int derivs_ang_vel(double x, size_t nv, const ovector_view &y, 00363 ovector_view &dydx, void *&pa); 00364 00365 /// Output a stellar profile 00366 int profile_out(double xx); 00367 00368 /// The minimizer function to compute the maximum mass 00369 double maxfun(double maxx, void *&pa); 00370 00371 /** 00372 \brief The solver function to compute the stellar profile 00373 00374 */ 00375 int starfun(size_t ndvar, const ovector_view &ndx, ovector_view &ndy, 00376 void *&pa); 00377 00378 /// Compute the angular velocity 00379 int ang_vel(); 00380 00381 /// Interpolation object for derivs_ang_vel() 00382 smart_interp<> smi; 00383 00384 #endif 00385 00386 }; 00387 00388 #ifndef DOXYGENP 00389 } 00390 #endif 00391 00392 #endif 00393 00394
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page