tov_solve.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2006-2017, Andrew W. Steiner
5 
6  This file is part of O2scl.
7 
8  O2scl is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  O2scl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with O2scl. If not, see <http://www.gnu.org/licenses/>.
20 
21  -------------------------------------------------------------------
22 */
23 /** \file tov_solve.h
24  \brief File defining \ref o2scl::tov_solve
25 */
26 #ifndef O2SCL_TOV_SOLVE_H
27 #define O2SCL_TOV_SOLVE_H
28 
29 #include <o2scl/eos_tov.h>
30 #include <o2scl/interp.h>
31 #include <o2scl/table_units.h>
32 #include <o2scl/ode_iv_solve.h>
33 #include <o2scl/mroot_hybrids.h>
34 #include <o2scl/min_brent_gsl.h>
35 
36 #ifndef DOXYGEN_NO_O2NS
37 namespace o2scl {
38 #endif
39 
40  /** \brief Class to solve the Tolman-Oppenheimer-Volkov equations
41 
42  See the \ref tovtoc section of the User's Guide for
43  the mathematical background.
44 
45  This class uses adaptive integration to compute the
46  gravitational mass, the radius, the baryonic mass (if the EOS
47  supplies the baryon density), and the gravitational potential
48  (if requested). The equation of state may be changed at any
49  time, by specifying the appropriate \ref eos_tov object
50 
51  <b>Basic Usage</b>
52 
53  After specifying the EOS through \ref tov_solve::set_eos(), one
54  calls either \ref tov_solve::mvsr(), \ref tov_solve::fixed(), or
55  \ref tov_solve::max() to compute the mass versus radius curve,
56  the profile of a star of a given fixed mass, or the profile of
57  the maximum mass star. These functions all generate results
58  in the form of a \ref table_units object, which can be
59  obtained from \ref tov_solve::get_results().
60 
61  Screen output:
62  - \c verbose=0 - Nothing
63  - \c verbose=1 - Basic information
64  - \c verbose=2 - For each profile computation, report solution
65  information at every kilometer.
66  - \c verbose=3 - Report profile information at every 20 grid
67  points and output the final interpolation to zero pressure. A
68  keypress is required after each profile.
69 
70  <b>Profiles of fixed mass</b>
71 
72  Profiles for a fixed gravitational mass are computed by solving
73  for the correct central pressure. In order to ensure that the
74  solver does not accidentally select a central pressure beyond
75  the maximum mass neutron star, the profile with the maximum mass
76  is computed beforehand automatically. The intial guess to the
77  solver is always the value of \ref fixed_pr_guess, which defaults to
78  \f$ 5.2 \times 10^{-5}~\mathrm{Msun}/\mathrm{km}^3 \f$ .
79  Alternatively, the user can specify the central pressure of
80  the maximum mass star so that it does not have to be computed.
81 
82  <b>Mass versus radius curve</b>
83 
84  The neutron star mass versus radius curve is constructed by
85  computing profiles of all neutron stars with a range of central
86  pressures. This range is from \ref prbegin to \ref prend, and
87  the ratio between successive central pressures is specified in
88  \ref princ (making a logarithmic central pressure grid).
89 
90  <b>Output tables</b>
91 
92  The functions \ref tov_solve::fixed() and \ref tov_solve::max()
93  produce output tables which represent the profile of the neutron
94  star of the requested mass. The columns are
95  - \c gm, the enclosed gravitational mass in \f$ \mathrm{M}_{\odot} \f$
96  - \c r, the radial coordinate in \f$ \mathrm{km} \f$
97  - \c gp, the gravitational potential (unitless) when
98  \ref calc_gpot is true
99  - \c bm, the baryonic mass in \f$ \mathrm{M}_{\odot} \f$ (when
100  \ref eos_tov::baryon_column is true).
101  - \c pr, the pressure in user-specified units
102  - \c ed, the energy density in user-specified units
103  - \c nb, the baryon density in user-specified units
104  (if \ref eos_tov::baryon_column is true)
105  - \c sg, the local surface gravity
106  (in \f$ \mathrm{g}/\mathrm{cm}^{2} \f$ )
107  - \c rs, the local redshift (unitless),
108  - \c dmdr, the derivative of the enclosed gravitational mass
109  in \f$ \mathrm{M}_{\odot}/\mathrm{km} \f$
110  - \c dlogpdr, the derivative of the natural logarithm of the
111  pressure
112  - \c dgpdr, the derivative of the gravitational potential
113  in \f$ 1/\mathrm{km} \f$ (if \ref calc_gpot is true)
114  - \c dbmdr, the derivative of the enclosed baryonic mass
115  (if \ref eos_tov::baryon_column is true). \n
116 
117  The function \ref tov_solve::mvsr() produces a different kind of
118  output table corresponding to the mass versus radius curve. Some
119  points on the curve may correspond to unstable branches.
120  - \c gm, the total gravitational mass in \f$ \mathrm{M}_{\odot} \f$
121  - \c r, the radius in \f$ \mathrm{km} \f$
122  - \c gp, the gravitational potential in the center (unitless) when
123  \ref calc_gpot is true
124  - \c bm, total the baryonic mass in \f$ \mathrm{M}_{\odot} \f$ (when
125  \ref eos_tov::baryon_column is true).
126  - \c pr, the central pressure in user-specified units
127  - \c ed, the central energy density in user-specified units
128  - \c nb, the central baryon density in user-specified units
129  (if \ref eos_tov::baryon_column is true)
130  - \c sg, the surface gravity
131  (in \f$ \mathrm{g}/\mathrm{cm}^{2} \f$ )
132  - \c rs, the redshift at the surface,
133  - \c dmdr, the derivative of the gravitational mass
134  - \c dlogpdr, the derivative of the natural logarithm of the
135  pressure
136  - \c dgpdr, the derivative of the gravitational potential
137  in \f$ 1/\mathrm{km} \f$ (if \ref calc_gpot is true)
138  - \c dbmdr, the derivative of the enclosed baryonic mass
139  (if \ref eos_tov::baryon_column is true). \n
140 
141  <b>Unit systems</b>
142 
143  By default, this class operates with energy density and
144  pressure in units of \f$ \mathrm{M}_{\odot}/\mathrm{km}^3 \f$
145  and baryon density in units of \f$ \mathrm{fm}^{-3} \f$.
146 
147  The function \ref set_units(std::string,std::string,std::string)
148  allows one to use different unit systems for energy density,
149  pressure, and baryon density. The following list of units of
150  energy density and pressure are hard-coded into the library and
151  always work:
152  - <tt>"g/cm^3"</tt>,
153  - <tt>"erg/cm^3"</tt>,
154  - <tt>"MeV/fm^3"</tt>,
155  - <tt>"1/fm^4"</tt>, and
156  - <tt>"Msun/km^3"</tt> (i.e. \f$ \mathrm{M}_{\odot}/\mathrm{km}^3 \f$ )
157 
158  The list of hard-coded units for baryon density are:
159  - <tt>"1/m^3"</tt>,
160  - <tt>"1/cm^3"</tt>, and
161  - <tt>"1/fm^3"</tt>.
162 
163  Other units choices will work if the conversion is either
164  already added to the global unit conversion object (from
165  <tt>o2scl_settings.get_convert_units()</tt> ) or the global unit
166  conversion object is able to compute them by a system call to
167  GNU <tt>units</tt> (see documentation in \ref convert_units).
168  Note that the choice of what units the tables are produced in
169  is independent of the unit system specified in the associated
170  \ref eos_tov object, i.e. the input EOS and output EOS units
171  need not be the same.
172 
173  Alternatively, using \ref set_units(double,double,double)
174  allows one to specify the conversion factors directly without
175  using the global unit conversion object.
176 
177  <b>Accuracy</b>
178 
179  The present code, as demonstrated in the tests, gives the
180  correct central pressure and energy density of the analytical
181  solution by Buchdahl to within less than 1 \part in \f$ 10^8 \f$.
182 
183  <b>Rotation</b>
184 
185  Rotation is considered if \ref tov_solve::ang_vel is set to
186  <tt>true</tt>. This adds two more differential equations to
187  solve for each central pressure.
188 
189  The differential equation for \f$ \bar{\omega} \f$ (see the
190  section in the User's Guide called \ref tovtoc ) is
191  independent of the relative scale for \f$ \bar{\omega} \f$ and
192  \f$ j \f$ . First, one rescales \f$ \bar{\omega} \f$ and
193  rewrites everything in terms of \f$ f\equiv \bar{\omega}/\Omega
194  \f$ and \f$ g \equiv r^4 j~df/dr \f$ . Then, pick a central
195  pressure, \f$ m(r=0)=g(r=0)=0 \f$, arbitrary values for \f$
196  \Phi(r=0) \f$ and \f$ f(r=0) \f$, and integrate
197  \f{eqnarray*}
198  \frac{d P}{d r} &=& - \frac{G \varepsilon m}{r^2}
199  \left( 1+\frac{P}{\varepsilon}\right)
200  \left( 1+\frac{4 \pi P r^3}{m} \right)
201  \left( 1-\frac{2 G m}{r}\right)^{-1}
202  \nonumber \\
203  \frac{d m}{d r} &=& 4 \pi r^2 \varepsilon
204  \nonumber \\
205  \frac{d \Phi}{d r} &=& - \frac{1}{\varepsilon}
206  \frac{ d P}{d r} \left(1+\frac{P}{\varepsilon}\right)^{-1}
207  \nonumber \\
208  \frac{d g}{dr} &=& -4 r^3 \frac{d j}{dr} f
209  \nonumber \\
210  \frac{d f}{dr} &=& \frac{g}{r^4 j}
211  \f}
212  Afterwards, shift \f$ \Phi \f$ by a constant to ensure
213  the correct value at \f$ r=R \f$, and multiply \f$ g \f$
214  by a constant to ensure that \f$ g=r^4 j (df/dr) \f$ holds
215  for the new potential \f$ \Phi \f$. Then, multiply
216  \f$ f \f$ by a constant to ensure that
217  \f[
218  f(r=R) + \frac{R}{3} \left(\frac{df}{dr}\right)_{r=R} = 1
219  \f]
220 
221  The functions \f$ f \f$ and \f$ g \f$ are stored in columns
222  called <tt>"omega_rat"</tt> and <tt>"rjw"</tt>, respectively.
223  One can compute the baryonic mass by integration or by adding
224  one additional differential equation, bringing the total to six.
225 
226  The moment of inertia is (see \ref tovtoc),
227  \f[
228  I = \frac{R^4}{6 G} \left.\frac{df}{dr}\right|_{r=R}
229  \f]
230  where the last fraction is stored in \ref domega_rat .
231 
232  <b>Convergence details</b>
233 
234  By default, if the TOV solver fails to converge, the error
235  handler is called and an exception is thrown. If \ref
236  o2scl::tov_solve::err_nonconv is false, then \ref
237  o2scl::tov_solve::mvsr(), \ref o2scl::tov_solve::fixed(), and
238  \ref o2scl::tov_solve::max(), return an integer which gives some
239  information about why the solver failed to converge.
240 
241  <b>Other details</b>
242 
243  The ODE solution is stored in a buffer which can be directly
244  accessed using \ref o2scl::tov_solve::get_rkx(), \ref
245  o2scl::tov_solve::get_rky(), and \ref
246  o2scl::tov_solve::get_rkdydx(). In the case that the ODE steps
247  are small enough that there isn't enough space in the buffers,
248  the ODE solution data is thinned by a factor of two to allow for
249  the remaining ODE steps to be stored. The size of the buffers
250  can be controlled in \ref buffer_size .
251 
252  If \ref o2scl::tov_solve::reformat_results is true (the
253  default), then the results are placed in a shared pointer to the
254  \ref table_units object which can be accessed using \ref
255  o2scl::tov_solve::get_results(). The maximum size of the output
256  table can be controlled with \ref max_table_size. The output
257  table may be smaller than this, as it cannot be larger than the
258  number of steps stored in the buffer.
259 
260  \note The function \ref o2scl::tov_solve::integ_star() returns
261  <tt>gsl_efailed</tt> without calling the error handler in the
262  case that the solver can recover gracefully from, for example, a
263  negative pressure.
264  */
265  class tov_solve {
266 
267  public:
268 
271  typedef boost::numeric::ublas::matrix_column<ubmatrix> ubmatrix_column;
272  typedef boost::numeric::ublas::matrix_row<ubmatrix> ubmatrix_row;
273 
274 #ifndef DOXYGEN_INTERNAL
275 
276  protected:
277 
278  /// ODE function object
280 
281  /// Interpolation object for listed radii in \ref mvsr()
283 
284  /** \brief Set up column names and units
285 
286  When this function is used by \ref mvsr(), \c mvsr_mode is set
287  to true.
288  */
289  void column_setup(bool mvsr_mode=false);
290 
291  /** \brief If true, \ref integ_star() computes all the profile info,
292  otherwise it only computes the gravitational mass
293  */
295 
296  /// The last row index in \ref rky
297  size_t ix_last;
298 
299  /// The schwarzchild radius in km
300  double schwarz_km;
301 
302  /** \brief Target mass for integ_star()
303 
304  Has a value of zero, unless set to a non-zero value by \ref fixed().
305  */
306  double tmass;
307 
308  /** \brief Ensure \c col does not match strings in \c cnames
309 
310  Underscores are added to \c col until it matches none of
311  the strings in \c cnames.
312  */
313  void make_unique_name(std::string &col,
314  std::vector<std::string> &cnames);
315 
316  /// \name User EOS
317  //@{
318  /// The EOS
320 
321  /// True if the EOS has been set
322  bool eos_set;
323  //@}
324 
325  /// \name Units for output table
326  //@{
327  /// Units for energy density
328  std::string eunits;
329  /// Units for pressure
330  std::string punits;
331  /// Units for baryon density
332  std::string nunits;
333  /// unit conversion factor for energy density (default 1.0)
334  double efactor;
335  /// unit conversion factor for pressure (default 1.0)
336  double pfactor;
337  /// unit conversion factor for baryon density (default 1.0)
338  double nfactor;
339  //@}
340 
341  /** \brief Smallest allowed pressure for integration (default: -100)
342 
343  This quantity can't be much smaller than -100 since we need to
344  compute numbers near \f$ e^{-\mathrm{min\_log\_pres}} \f$
345 
346  \future Replace this with the proper value from std::limits?
347  */
348  double min_log_pres;
349 
350  /// \name Integration storage
351  //@{
352  /// Radial coordinate (in kilometers)
353  ubvector rkx;
354  /** \brief ODE functions
355 
356  If \c rky is viewed as a matrix, then the first column of each
357  row is the gravitational mass in solar masses, and the second
358  column is the natural logarithm of the pressure in \f$
359  \mathrm{M}_{\odot}/km^3 \f$ . When \ref calc_gpot is true, the
360  next column is the gravitational potential (which is
361  unitless), and when \ref eos_tov::baryon_column is true, the
362  next column is the baryonic mass in \f$ \mathrm{M}_{\odot}
363  \f$.
364  */
365  std::vector<ubvector> rky;
366  /// The derivatives of the ODE functions
367  std::vector<ubvector> rkdydx;
368  //@}
369 
370  /// The output table
371  std::shared_ptr<table_units<> > out_table;
372 
373  /// \name Numerical methods
374  //@{
375  /// The solver
377 
378  /// The minimizer
380 
381  /// The adaptive stepper
383  //@}
384 
385  /// The ODE step function
386  virtual int derivs(double x, size_t nv, const ubvector &y,
387  ubvector &dydx);
388 
389  /// The minimizer function to compute the maximum mass
390  virtual double max_fun(double maxx);
391 
392  /** \brief The solver function to compute the stellar profile
393  */
394  virtual int integ_star(size_t ndvar, const ubvector &ndx,
395  ubvector &ndy);
396 
397 #endif
398 
399  public:
400 
401  tov_solve();
402 
403  virtual ~tov_solve();
404 
405  /// Size of the ODE solution buffer (default \f$ 10^5 \f$)
406  size_t buffer_size;
407 
408  /// Maximum number of lines in the output table (default 400)
410 
411  /// \name Basic properties
412  //@{
413  /// Gravitational mass
414  double mass;
415  /// Radius
416  double rad;
417  /// Baryonic mass (when computed)
418  double bmass;
419  /// Gravitational potential (when computed)
420  double gpot;
421  /// The value of \f$ r^4 j df / dr \f$
422  double last_rjw;
423  /// The value of \f$ \bar{\omega} / \Omega \f$
424  double last_f;
425  /** \brief The value of \f$ d (\bar{\omega}/\Omega)/dr \f$
426  at the surface (when computed)
427  */
428  double domega_rat;
429  /** \brief Maximum value for central pressure in
430  \f$ \mathrm{M}_{\odot}/\mathrm{km}^3 \f$ (default \f$ 10^{20} \f$ )
431 
432  This variable is set by the <tt>mvsr()</tt> and <tt>max()</tt>
433  functions and used in \ref integ_star() .
434  */
435  double pcent_max;
436  //@}
437 
438  /** \name Solution parameters
439 
440  These parameters can be changed at any time.
441  */
442  //@{
443  /** \brief If true, then fixed() and max() reformat results into
444  a \ref o2scl::table_units object
445 
446  Note that \ref mvsr() always places its results in the
447  output table independent of the value of this variable.
448  */
450  /** \brief The mass of one baryon
451 
452  The mass of one baryon in kg for the total baryon mass
453  calculation (defaults to the proton mass).
454  */
455  double baryon_mass;
456  /// If true, solve for the angular velocity (default false)
457  bool ang_vel;
458  /// Apply general relativistic corrections (default true)
459  bool gen_rel;
460  /** \brief calculate the gravitational potential and the enclosed
461  baryon mass (default false)
462  */
463  bool calc_gpot;
464  /// smallest allowed radial stepsize in km (default 1.0e-4)
465  double step_min;
466  /// largest allowed radial stepsize in km (default 0.05)
467  double step_max;
468  /// initial radial stepsize in km (default 4.0e-3)
469  double step_start;
470  /// control for output (default 1)
471  int verbose;
472  /// Maximum number of integration steps (default 100000)
474  /** \brief If true, call the error handler if the solution does
475  not converge (default true)
476  */
478  //@}
479 
480  /** \brief Default value of maximum pressure for maximum mass star
481  in \f$ \mathrm{M}_{\odot}/\mathrm{km}^3 \f$
482  */
483  double pmax_default;
484 
485  /// \name Mass versus radius parameters
486  //@{
487  /** \brief Beginning pressure in
488  \f$ \mathrm{M}_{\odot}/\mathrm{km}^3 \f$ (default 7.0e-7)
489  */
490  double prbegin;
491  /** \brief Ending pressure in
492  \f$ \mathrm{M}_{\odot}/\mathrm{km}^3 \f$ (default 8.0e-3)
493  */
494  double prend;
495  /// Increment factor for pressure (default 1.1)
496  double princ;
497  /** \brief List of pressures at which more information should be
498  recorded
499 
500  If pressures (in the user-specified units) are added to this
501  vector, then in mvsr(), the radial location, enclosed
502  gravitational mass, and (if \ref o2scl::eos_tov::baryon_column
503  is true) enclosed baryon mass are stored in the table for each
504  central pressure. The associated columns are named
505  <tt>r0, gm0, bm0, r1, gm1, bm1,</tt> etc.
506  */
507  std::vector<double> pr_list;
508  //@}
509 
510  /// \name Fixed mass parameter
511  //@{
512  /** \brief Guess for central pressure in
513  \f$ \mathrm{M}_{\odot}/\mathrm{km}^3 \f$
514  (default \f$ 5.2 \times 10^{-5} \f$)
515 
516  This guess is used in the functions fixed().
517  */
519  //@}
520 
521  /// \name Maximum mass profile parameters
522  //@{
523  /// Beginning pressure for maximum mass guess (default 7.0e-5)
524  double max_begin;
525  /// Ending pressure for maximum mass guess (default 5.0e-3)
526  double max_end;
527  /// Increment for pressure for maximum mass guess (default 1.3)
528  double max_inc;
529  //@}
530 
531  /// \name Basic operation
532  //@{
533  /// Set the EOS to use
534  void set_eos(eos_tov &ter) {
535  te=&ter;
536  eos_set=true;
537  return;
538  }
539 
540  /** \brief Set output units for the table
541  */
542  void set_units(double s_efactor=1.0, double s_pfactor=1.0,
543  double s_nbfactor=1.0);
544 
545  /** \brief Set output units for the table
546  */
547  void set_units(std::string eunits="", std::string punits="",
548  std::string nunits="");
549 
550  /// Calculate the mass vs. radius curve
551  virtual int mvsr();
552 
553  /** \brief Calculate the profile of a star with fixed mass
554 
555  If the target mass is negative, it is interpreted as
556  subtracting from the maximum mass configuration. For a 2.15
557  solar mass neutron star, <tt>target_mass=-0.2</tt> corresponds
558  to 1.95 solar mass configuration.
559 
560  The variable \c pmax is the maximum allowable central pressure
561  in \f$ \mathrm{M}_{\odot}/\mathrm{km}^3 \f$, i.e. the central
562  pressure of the maximum mass star. This ensures that the
563  function does not unintentionally select a configuration on an
564  unstable branch. If \c pmax is greater than or equal to the
565  default value (\ref pmax_default), then the maximum mass star
566  will be explicitly computed first.
567  */
568  virtual int fixed(double target_mass, double pmax=1.0e20);
569 
570  virtual int fixed_pr(double pcent, double pmax=1.0e20);
571 
572  /** \brief Calculate the profile of the maximum mass star
573  */
574  virtual int max();
575 
576  /** \brief Construct a table from the results
577 
578  This function constructs a \ref table_units object from the
579  information in \ref rkx, \ref rky, and \ref rkdydx . Note that
580  the table is always constructed by default so this function
581  need not be called unless \ref tov_solve::reformat_results is
582  <tt>false</tt>.
583  */
584  virtual void make_table();
585 
586  /** \brief Return the results data table
587  */
588  std::shared_ptr<table_units<> > get_results() {
589  return out_table;
590  }
591 
592  /** \brief Return the results data table
593 
594  This function immediately adds four constants to the table,
595  <tt>schwarz, Msun, pi</tt> and <tt>mproton</tt>.
596  */
597  void set_table(std::shared_ptr<table_units<> > t) {
598  out_table=t;
599  // Add native constants
600  out_table->add_constant("schwarz",schwarz_km);
601  out_table->add_constant("Msun",o2scl_mks::solar_mass);
602  out_table->add_constant("pi",o2scl_const::pi);
603  out_table->add_constant("mproton",o2scl_mks::mass_proton);
604  return;
605  }
606  //@}
607 
608  /// \name Convergence information flags
609  //@{
610  static const int fixed_solver_failed=128;
611  static const int fixed_integ_star_failed=256;
612  static const int fixed_wrong_mass=512;
613  static const int max_minimizer_failed=1024;
614  static const int max_integ_star_failed=2048;
615  static const int mvsr_integ_star_failed=4096;
616  static const int ang_vel_failed=8192;
617  static const int cent_press_large=16384;
618  static const int cent_press_neg=32768;
619  static const int over_max_steps=65536;
620  static const int last_step_large=131072;
621  //@}
622 
623  /// \name Get internally formatted results (in internal unit system)
624  //@{
625  /// Get the vector for the radial grid
626  const ubvector &get_rkx() const {
627  return rkx;
628  }
629  /// Get a list of vectors for the ODEs
630  const std::vector<ubvector> &get_rky() const {
631  return rky;
632  }
633  /// Get a list of vectors for the corresponding derivatives
634  const std::vector<ubvector> &get_rkdydx() const {
635  return rkdydx;
636  }
637  //@}
638 
639  /// \name Control numerical methods
640  //@{
641  /** \brief Set solver
642  */
644  mroot_ptr=&s_mrp;
645  return;
646  };
647 
648  /** \brief Set minimizer
649  */
650  void set_min(min_base<> &s_mp) {
651  min_ptr=&s_mp;
652  return;
653  };
654 
655  /** \brief Set the adaptive stepper
656  */
658  as_ptr=&sap;
659  return;
660  };
661  //@}
662 
663  /// \name Default numerical classes
664  //@{
665  /// The default minimizer
667 
668  /// The default solver
670 
671  /// The default adaptive stepper
673  //@}
674 
675  };
676 
677 #ifndef DOXYGEN_NO_O2NS
678 }
679 #endif
680 
681 #endif
682 
683 
void set_eos(eos_tov &ter)
Set the EOS to use.
Definition: tov_solve.h:534
virtual int mvsr()
Calculate the mass vs. radius curve.
const std::vector< ubvector > & get_rky() const
Get a list of vectors for the ODEs.
Definition: tov_solve.h:630
double pcent_max
Maximum value for central pressure in (default )
Definition: tov_solve.h:435
std::string punits
Units for pressure.
Definition: tov_solve.h:330
double rad
Radius.
Definition: tov_solve.h:416
const double solar_mass
double schwarz_km
The schwarzchild radius in km.
Definition: tov_solve.h:300
mroot< mm_funct11, ubvector, jac_funct11 > * mroot_ptr
The solver.
Definition: tov_solve.h:376
const double mass_proton
bool calc_gpot
calculate the gravitational potential and the enclosed baryon mass (default false) ...
Definition: tov_solve.h:463
virtual int fixed(double target_mass, double pmax=1.0e20)
Calculate the profile of a star with fixed mass.
bool err_nonconv
If true, call the error handler if the solution does not converge (default true)
Definition: tov_solve.h:477
const double pi
std::shared_ptr< table_units<> > get_results()
Return the results data table.
Definition: tov_solve.h:588
double domega_rat
The value of at the surface (when computed)
Definition: tov_solve.h:428
std::string nunits
Units for baryon density.
Definition: tov_solve.h:332
double max_begin
Beginning pressure for maximum mass guess (default 7.0e-5)
Definition: tov_solve.h:524
double pmax_default
Default value of maximum pressure for maximum mass star in .
Definition: tov_solve.h:483
size_t max_integ_steps
Maximum number of integration steps (default 100000)
Definition: tov_solve.h:473
int verbose
control for output (default 1)
Definition: tov_solve.h:471
void set_mroot(mroot< mm_funct11, ubvector, jac_funct11 > &s_mrp)
Set solver.
Definition: tov_solve.h:643
size_t ix_last
The last row index in rky.
Definition: tov_solve.h:297
bool gen_rel
Apply general relativistic corrections (default true)
Definition: tov_solve.h:459
void set_stepper(astep_base< ubvector, ubvector, ubvector, ode_funct11 > &sap)
Set the adaptive stepper.
Definition: tov_solve.h:657
double max_end
Ending pressure for maximum mass guess (default 5.0e-3)
Definition: tov_solve.h:526
double prbegin
Beginning pressure in (default 7.0e-7)
Definition: tov_solve.h:490
void set_units(double s_efactor=1.0, double s_pfactor=1.0, double s_nbfactor=1.0)
Set output units for the table.
double pfactor
unit conversion factor for pressure (default 1.0)
Definition: tov_solve.h:336
std::vector< ubvector > rky
ODE functions.
Definition: tov_solve.h:365
virtual int integ_star(size_t ndvar, const ubvector &ndx, ubvector &ndy)
The solver function to compute the stellar profile.
double min_log_pres
Smallest allowed pressure for integration (default: -100)
Definition: tov_solve.h:348
double prend
Ending pressure in (default 8.0e-3)
Definition: tov_solve.h:494
bool integ_star_final
If true, integ_star() computes all the profile info, otherwise it only computes the gravitational mas...
Definition: tov_solve.h:294
const std::vector< ubvector > & get_rkdydx() const
Get a list of vectors for the corresponding derivatives.
Definition: tov_solve.h:634
double bmass
Baryonic mass (when computed)
Definition: tov_solve.h:418
bool ang_vel
If true, solve for the angular velocity (default false)
Definition: tov_solve.h:457
bool eos_set
True if the EOS has been set.
Definition: tov_solve.h:322
virtual void make_table()
Construct a table from the results.
min_brent_gsl def_min
The default minimizer.
Definition: tov_solve.h:666
virtual int derivs(double x, size_t nv, const ubvector &y, ubvector &dydx)
The ODE step function.
eos_tov * te
The EOS.
Definition: tov_solve.h:319
virtual double max_fun(double maxx)
The minimizer function to compute the maximum mass.
size_t buffer_size
Size of the ODE solution buffer (default )
Definition: tov_solve.h:406
bool reformat_results
If true, then fixed() and max() reformat results into a o2scl::table_units object.
Definition: tov_solve.h:449
std::string eunits
Units for energy density.
Definition: tov_solve.h:328
std::shared_ptr< table_units<> > out_table
The output table.
Definition: tov_solve.h:371
A EOS base class for the TOV solver.
Definition: eos_tov.h:47
double mass
Gravitational mass.
Definition: tov_solve.h:414
const ubvector & get_rkx() const
Get the vector for the radial grid.
Definition: tov_solve.h:626
mroot_hybrids< mm_funct11, ubvector, ubmatrix, jac_funct11 > def_solver
The default solver.
Definition: tov_solve.h:669
double baryon_mass
The mass of one baryon.
Definition: tov_solve.h:455
double step_max
largest allowed radial stepsize in km (default 0.05)
Definition: tov_solve.h:467
ubvector rkx
Radial coordinate (in kilometers)
Definition: tov_solve.h:353
void column_setup(bool mvsr_mode=false)
Set up column names and units.
double last_rjw
The value of .
Definition: tov_solve.h:422
std::vector< ubvector > rkdydx
The derivatives of the ODE functions.
Definition: tov_solve.h:367
Class to solve the Tolman-Oppenheimer-Volkov equations.
Definition: tov_solve.h:265
astep_base< ubvector, ubvector, ubvector, ode_funct11 > * as_ptr
The adaptive stepper.
Definition: tov_solve.h:382
interp< ubvector > iop
Interpolation object for listed radii in mvsr()
Definition: tov_solve.h:282
ode_funct11 ofm
ODE function object.
Definition: tov_solve.h:279
double max_inc
Increment for pressure for maximum mass guess (default 1.3)
Definition: tov_solve.h:528
double nfactor
unit conversion factor for baryon density (default 1.0)
Definition: tov_solve.h:338
double fixed_pr_guess
Guess for central pressure in (default )
Definition: tov_solve.h:518
double princ
Increment factor for pressure (default 1.1)
Definition: tov_solve.h:496
void set_table(std::shared_ptr< table_units<> > t)
Return the results data table.
Definition: tov_solve.h:597
double step_start
initial radial stepsize in km (default 4.0e-3)
Definition: tov_solve.h:469
astep_gsl< ubvector, ubvector, ubvector, ode_funct11 > def_stepper
The default adaptive stepper.
Definition: tov_solve.h:672
min_base * min_ptr
The minimizer.
Definition: tov_solve.h:379
double tmass
Target mass for integ_star()
Definition: tov_solve.h:306
void make_unique_name(std::string &col, std::vector< std::string > &cnames)
Ensure col does not match strings in cnames.
double step_min
smallest allowed radial stepsize in km (default 1.0e-4)
Definition: tov_solve.h:465
virtual int max()
Calculate the profile of the maximum mass star.
std::vector< double > pr_list
List of pressures at which more information should be recorded.
Definition: tov_solve.h:507
size_t max_table_size
Maximum number of lines in the output table (default 400)
Definition: tov_solve.h:409
double last_f
The value of .
Definition: tov_solve.h:424
double gpot
Gravitational potential (when computed)
Definition: tov_solve.h:420
std::function< int(double, size_t, const boost::numeric::ublas::vector< double > &, boost::numeric::ublas::vector< double > &)> ode_funct11
void set_min(min_base<> &s_mp)
Set minimizer.
Definition: tov_solve.h:650
double efactor
unit conversion factor for energy density (default 1.0)
Definition: tov_solve.h:334

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).