nstar_cold.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2006-2020, 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 nstar_cold.h
24  \brief File defining \ref o2scl::nstar_cold
25 */
26 #ifndef O2SCL_COLD_NSTAR_H
27 #define O2SCL_COLD_NSTAR_H
28 
29 #include <o2scl/eos_had_base.h>
30 #include <o2scl/tov_solve.h>
31 #include <o2scl/tov_solve.h>
32 #include <o2scl/table.h>
33 #include <o2scl/fermion.h>
34 #include <o2scl/root_cern.h>
35 #include <o2scl/mroot_cern.h>
36 #include <o2scl/mroot_hybrids.h>
37 #include <o2scl/eos_tov.h>
38 
39 #ifndef DOXYGEN_NO_O2NS
40 namespace o2scl {
41 #endif
42 
43  /** \brief Naive static cold neutron star
44 
45  This uses eos_had_base::calc_e() to compute the equation of
46  state of zero-temperature beta-equilibrated neutron star
47  matter and tov_solve::mvsr() to compute the mass versus
48  radius curve. By default the crust EOS is given by
49  that in \ref o2scl::eos_tov_interp::default_low_dens_eos() .
50 
51  The neutron, proton, electron and muon are given masses
52  according to their values in \ref o2scl_mks
53  after a conversion to units of \f$ 1/\mathrm{fm} \f$.
54 
55  There is an example for the usage of this class given
56  in the \ref ex_nstar_cold_sect.
57 
58  If \ref err_nonconv is true and the solver fails,
59  the error handler is called.
60 
61  \hline
62  \b EOS \b Output
63 
64  The function calc_eos() generates an object of type
65  \ref table_units, which contains the following columns
66  - \c ed in units of \f$ 1/\mathrm{fm}^4 \f$, the total energy
67  density of neutron star matter, \f$ \varepsilon \f$
68  - \c pr in units of \f$ 1/\mathrm{fm}^4 \f$, the total pressure
69  of neutron star matter, \f$ P \f$
70  - \c nb in units of \f$ 1/\mathrm{fm}^3 \f$, the baryon
71  number density, \f$ n_B \f$
72  - \c mun in units of \f$ 1/\mathrm{fm} \f$, the neutron
73  chemical potential, \f$ \mu_n \f$
74  - \c mup in units of \f$ 1/\mathrm{fm} \f$, the proton chemical
75  potential, \f$ \mu_p \f$
76  - \c mue in units of \f$ 1/\mathrm{fm} \f$, the electron
77  chemical potential, \f$ \mu_e \f$
78  - \c nn in units of \f$ 1/\mathrm{fm}^3 \f$, the neutron number
79  density, \f$ n_n \f$
80  - \c np in units of \f$ 1/\mathrm{fm}^3 \f$, the proton number
81  density, \f$ n_p \f$
82  - \c ne in units of \f$ 1/\mathrm{fm}^3 \f$, the electron
83  number density, \f$ n_e \f$
84  - \c kfn in units of \f$ 1/\mathrm{fm} \f$, the neutron Fermi
85  momentum, \f$ k_{F,n} \f$
86  - \c kfp in units of \f$ 1/\mathrm{fm} \f$, the proton Fermi
87  momentum, \f$ k_{F,p} \f$
88  - \c kfe in units of \f$ 1/\mathrm{fm} \f$, the electron
89  Fermi momentum, \f$ k_{F,e} \f$
90  - \c dednb_Ye in units of \f$ 1/\mathrm{fm} \f$,
91  \f$ ( d \varepsilon / d n_B )_{Y_e} \f$ where
92  \f$ Y_e = n_e / n_B \f$ is the electron fraction
93  (computed using \ref eos_had_base::const_pf_derivs() )
94  - \c dPdnb_Ye in units of \f$ 1/\mathrm{fm} \f$,
95  \f$ ( d P / d n_B )_{Y_e} \f$ .
96  - \c fcs2, the squared speed of sound at fixed electron
97  fraction, the ratio of the previous two quantities
98 
99  If \ref include_muons is true, the table has
100  additional columns
101  - \c mumu in units of \f$ 1/\mathrm{fm} \f$, the muon chemical
102  potential, \f$ \mu_{\mu} \f$
103  - \c nmu in units of \f$ 1/\mathrm{fm}^3 \f$, the muon number
104  density, \f$ n_{\mu} \f$
105  - \c kfmu in units of \f$ 1/\mathrm{fm} \f$, the muon Fermi
106  momentum, \f$ k_{F,\mu} \f$
107 
108  If the energy density is always positive and increasing, and the
109  pressure is always positive and increasing, then the EOS is
110  well-formed and \ref well_formed is \c true. The variable \ref
111  pressure_dec records the lowest baryon density where the
112  pressure decreases with increasing density.
113  If \ref err_nonconv is true and the EOS is not well
114  formed, the error handler is called, and the remaining
115  columns below are not computed.
116 
117  After computing the equation of state, \ref calc_eos()
118  also adds the following columns
119  - \c cs2 (unitless), the squared speed of sound divided by \f$ c^2 \f$
120  - \c logp, the natural logarithm of the pressure stored in \c pr
121  - \c loge, the natural logarithm of the energy density
122  stored in \c ed
123  - \c s in units of \f$ 1/\mathrm{fm} \f$,
124  the semi-perimeter of the Urca triangle
125  - \c urca in units of \f$ 1/\mathrm{fm}^4 \f$,
126  the squared area of the Urca triangle
127  - \c ad_index, the adiabatic index, \f$ \Gamma \f$
128  If the eos is not well-formed and \ref well_formed is <tt>false</tt>,
129  then the columns <tt>cs2</tt>, <tt>logp</tt>, and <tt>loge</tt>
130  are set to zero. The columns \c cs2 and \c ad_indes are computing
131  from derivatives using the current table interpolation type.
132 
133  The condition for the direct Urca process is the area of the
134  triangle formed by the neutron, proton, and electron Fermi
135  momenta. Using the definition of the semi-perimeter,
136  \f[
137  s \equiv \left( k_{F,n}+k_{F,p}+k_{F,e} \right)/2
138  \f]
139  Heron's formula gives the triangle area as
140  \f[
141  a=\sqrt{s(s-k_{F,n})(s-k_{F,p})(s-k_{F,e})} \, .
142  \f]
143  The column in the eos \ref table labeled \c urca is \f$ a^2 \f$
144  . If this quantity is positive, then direct Urca is allowed. The
145  variable \ref allow_urca is the smallest density for which the
146  direct Urca process turns on, and \ref deny_urca is the smallest
147  density for which the direct Urca process turns off.
148 
149  The squared speed of sound (in units of \f$ c \f$ )
150  is calculated by
151  \f[
152  c_s^2 = \frac{ d P }{d \varepsilon}
153  \f]
154  and this is placed in the column labeled \c cs2. If the
155  EOS is not well-formed, then this column is set to zero. If
156  \c cs2 is larger than 1, the EOS is said to be "acausal". The
157  variables \ref acausal, \ref acausal_ed, and \ref acausal_pr
158  record the baryon density, energy density, and pressure where
159  the EOS becomes acausal. The adabatic index is calculated by
160  \f[
161  \Gamma = \frac{ d \ln P} { d \ln \varepsilon}
162  \f]
163  Note that \f$ \Gamma \f$ must be greater than \f$ 4/3 \f$
164  at the center of the neutron star for stability. (This
165  is a necessary, but not sufficient condition.) If
166  the EOS is not well-formed then this column is set to zero.
167 
168  \hline
169  \b TOV \b Output
170 
171  The TOV table contains all the columns typically
172  generated for mass versus radius tables in \ref tov_solve,
173  as well as columns containing the central values of
174  al the densities and chemical potentials, and all the
175  other columns computed for the EOS above.
176 
177  \hline
178 
179  \future Warn if the EOS becomes pure neutron matter.
180  \future Some of the auxillary quantities can be computed
181  directly without using the table methods and the
182  EOS calculation would be a bit faster.
183  */
184 
185  class nstar_cold {
186 
187  public:
188 
189  nstar_cold();
190 
191  /// \name Basic operation
192  //@{
193  /** \brief Set the equation of state
194 
195  This should be set before calling calc_eos().
196  */
197  void set_eos(eos_had_base &he) {
198  hep=&he;
199  eos_set=true;
200  return;
201  }
202 
203  /** \brief Calculate the given equation of state
204  */
205  int calc_eos(double np_0=0.0);
206 
207  /** \brief Compute the density at which the direct Urca process is allowe
208 
209  This is faster than using calc_eos() since it does nothing
210  other than computes the critical density. It does not store
211  the equation of state.
212  */
213  double calc_urca(double np_0=0.0);
214 
215  /** \brief Calculate the M vs. R curve
216  */
217  int calc_nstar();
218 
219  /** \brief Calculate the profile for a fixed gravitational mass
220  */
221  int fixed(double target_mass);
222  //@}
223 
224  /// \name Output
225  //@{
226  /** \brief If true, the energy density and pressure
227  of the EOS is monotonically
228  increasing and the pressure is always positive
229  */
231 
232  /** \brief The smallest baryon density where the pressure starts
233  to decrease
234 
235  If this is zero after calling calc_eos(), then
236  the pressure does not decrease in the specified range
237  of baryon density
238  */
239  double pressure_dec;
240 
241  /** \brief The smallest density where Urca becomes allowed
242 
243  If this is zero after calling calc_eos(), then direct
244  Urca is never allowed.
245  */
246  double allow_urca;
247 
248  /** \brief The smallest density where Urca becomes disallowed
249 
250  If this is zero after calling calc_eos(), then direct
251  Urca is not disallowed at a higher density than
252  it becomes allowed.
253  */
254  double deny_urca;
255 
256  /** \brief The density at which the EOS becomes acausal
257 
258  If this is zero, then the EOS is causal at all baryon densities
259  in the specified range
260  */
261  double acausal;
262 
263  /** \brief The pressure at which the EOS becomes acausal
264 
265  If this is zero, then the EOS is causal at all baryon densities
266  in the specified range
267  */
268  double acausal_pr;
269 
270  /** \brief The energy density at which the EOS becomes acausal
271 
272  If this is zero, then the EOS is causal at all baryon densities
273  in the specified range
274  */
275  double acausal_ed;
276 
277  /** \brief Solver tolerance (default \f$ 10^{-4} \f$)
278  */
279  double solver_tol;
280 
281  /// Verbosity parameter (default 0)
282  int verbose;
283 
284  /** \brief Return the results data table
285 
286  This function immediately adds four constants to the table,
287  <tt>schwarz, Msun, pi</tt> and <tt>mproton</tt>.
288  */
289  void set_eos_table(std::shared_ptr<table_units<> > t) {
290  eost=t;
291  return;
292  }
293 
294  /** \brief Get the eos table (after having called calc_eos())
295  */
296  std::shared_ptr<table_units<> > get_eos_results() {
297  return eost;
298  }
299 
300  /** \brief Get the results from the TOV (after having called calc_nstar())
301  */
302  std::shared_ptr<table_units<> > get_tov_results() {
303  return tp->get_results();
304  }
305  //@}
306 
307  /** \name Configuration
308  */
309  //@{
310  /** \brief The starting baryon density (default 0.05)
311  */
312  double nb_start;
313 
314  /** \brief The final baryon density (default 2.0)
315  */
316  double nb_end;
317 
318  /** \brief The baryon density stepsize (default 0.01)
319  */
320  double dnb;
321 
322  /** \brief If true, include muons (default false)
323  */
325 
326  /** \brief If true, throw an exception if the solver fails
327  or if the EOS is not well-formed (default true)
328  */
330 
331  /** \brief Set the equation solver for the EOS
332  */
333  int set_root(root<> &rf) {
334  rp=&rf;
335  return 0;
336  }
337 
338  /** \brief Specify the object for solving the TOV equations
339 
340  The default uses the low-density equation of state with
341  tov::verbose=0. In calc_nstar(), the units are set by calling
342  tov_solve::set_units().
343  */
344  int set_tov(tov_solve &ts) {
345  tp=&ts;
346  return 0;
347  }
348  //@}
349 
350  /** \name Default objects */
351  //@{
352  /// The default neutron
353  fermion np;
354 
355  /// The default proton
356  fermion pp;
357 
358  /// Zero-temperature fermion thermodynamics
360 
361  /** \brief The default TOV equation solver
362  */
364 
365  /** \brief The default equation solver for the EOS
366  */
368 
369  /// Default EOS object for the TOV solver
371  //@}
372 
373 #ifndef DOXYGEN_INTERNAL
374 
375  protected:
376 
377  /// Solve to ensure zero charge in \f$ \beta \f$-equilibrium
378  double solve_fun(double x, thermo &hb);
379 
380  /// True if equation of state has been set
381  bool eos_set;
382 
383  /// The electron
384  fermion e;
385 
386  /// The muon
387  fermion mu;
388 
389  /// A pointer to the equation of state
391 
392  /// A pointer to the TOV object
394 
395  /// A pointer to the solver
397 
398  /// Storage for the EOS table
399  std::shared_ptr<table_units<> > eost;
400 
401  /// The baryon density
402  double barn;
403 
404 #endif
405 
406  };
407 
408 
409 #ifndef DOXYGEN_NO_O2NS
410 }
411 #endif
412 
413 #endif
o2scl::nstar_cold::acausal_pr
double acausal_pr
The pressure at which the EOS becomes acausal.
Definition: nstar_cold.h:268
o2scl::nstar_cold::eost
std::shared_ptr< table_units<> > eost
Storage for the EOS table.
Definition: nstar_cold.h:399
o2scl::nstar_cold::nb_start
double nb_start
The starting baryon density (default 0.05)
Definition: nstar_cold.h:312
o2scl::nstar_cold
Naive static cold neutron star.
Definition: nstar_cold.h:185
o2scl::nstar_cold::get_eos_results
std::shared_ptr< table_units<> > get_eos_results()
Get the eos table (after having called calc_eos())
Definition: nstar_cold.h:296
o2scl::nstar_cold::set_eos_table
void set_eos_table(std::shared_ptr< table_units<> > t)
Return the results data table.
Definition: nstar_cold.h:289
o2scl::nstar_cold::set_eos
void set_eos(eos_had_base &he)
Set the equation of state.
Definition: nstar_cold.h:197
o2scl::nstar_cold::calc_eos
int calc_eos(double np_0=0.0)
Calculate the given equation of state.
o2scl::nstar_cold::rp
root * rp
A pointer to the solver.
Definition: nstar_cold.h:396
thermo_tl< double >
o2scl::nstar_cold::acausal
double acausal
The density at which the EOS becomes acausal.
Definition: nstar_cold.h:261
o2scl::nstar_cold::allow_urca
double allow_urca
The smallest density where Urca becomes allowed.
Definition: nstar_cold.h:246
o2scl::nstar_cold::err_nonconv
bool err_nonconv
If true, throw an exception if the solver fails or if the EOS is not well-formed (default true)
Definition: nstar_cold.h:329
o2scl::root
o2scl::nstar_cold::pressure_dec
double pressure_dec
The smallest baryon density where the pressure starts to decrease.
Definition: nstar_cold.h:239
o2scl::nstar_cold::include_muons
bool include_muons
If true, include muons (default false)
Definition: nstar_cold.h:324
o2scl::nstar_cold::solve_fun
double solve_fun(double x, thermo &hb)
Solve to ensure zero charge in -equilibrium.
o2scl::table_units
o2scl::fermion_zerot_tl< double >
o2scl::nstar_cold::def_eos_tov
eos_tov_interp def_eos_tov
Default EOS object for the TOV solver.
Definition: nstar_cold.h:370
o2scl::nstar_cold::calc_nstar
int calc_nstar()
Calculate the M vs. R curve.
o2scl::nstar_cold::def_root
root_cern def_root
The default equation solver for the EOS.
Definition: nstar_cold.h:367
o2scl::nstar_cold::well_formed
bool well_formed
If true, the energy density and pressure of the EOS is monotonically increasing and the pressure is a...
Definition: nstar_cold.h:230
o2scl::nstar_cold::acausal_ed
double acausal_ed
The energy density at which the EOS becomes acausal.
Definition: nstar_cold.h:275
o2scl::nstar_cold::nb_end
double nb_end
The final baryon density (default 2.0)
Definition: nstar_cold.h:316
o2scl::nstar_cold::e
fermion e
The electron.
Definition: nstar_cold.h:384
o2scl::nstar_cold::pp
fermion pp
The default proton.
Definition: nstar_cold.h:356
o2scl::tov_solve
Class to solve the Tolman-Oppenheimer-Volkov equations.
Definition: tov_solve.h:350
o2scl::root_cern
o2scl::nstar_cold::eos_set
bool eos_set
True if equation of state has been set.
Definition: nstar_cold.h:381
o2scl::nstar_cold::set_tov
int set_tov(tov_solve &ts)
Specify the object for solving the TOV equations.
Definition: nstar_cold.h:344
o2scl::nstar_cold::get_tov_results
std::shared_ptr< table_units<> > get_tov_results()
Get the results from the TOV (after having called calc_nstar())
Definition: nstar_cold.h:302
o2scl::nstar_cold::set_root
int set_root(root<> &rf)
Set the equation solver for the EOS.
Definition: nstar_cold.h:333
o2scl::eos_tov_interp
An EOS for the TOV solver using simple linear interpolation and an optional crust EOS.
Definition: eos_tov.h:741
o2scl::nstar_cold::verbose
int verbose
Verbosity parameter (default 0)
Definition: nstar_cold.h:282
o2scl::tov_solve::get_results
std::shared_ptr< table_units<> > get_results()
Return the results data table.
Definition: tov_solve.h:716
o2scl::nstar_cold::solver_tol
double solver_tol
Solver tolerance (default )
Definition: nstar_cold.h:279
o2scl::nstar_cold::mu
fermion mu
The muon.
Definition: nstar_cold.h:387
o2scl::eos_had_base
Hadronic equation of state [abstract base].
Definition: eos_had_base.h:324
o2scl::nstar_cold::barn
double barn
The baryon density.
Definition: nstar_cold.h:402
o2scl::nstar_cold::dnb
double dnb
The baryon density stepsize (default 0.01)
Definition: nstar_cold.h:320
o2scl::nstar_cold::np
fermion np
The default neutron.
Definition: nstar_cold.h:353
o2scl::nstar_cold::fixed
int fixed(double target_mass)
Calculate the profile for a fixed gravitational mass.
o2scl::nstar_cold::tp
tov_solve * tp
A pointer to the TOV object.
Definition: nstar_cold.h:393
o2scl::nstar_cold::calc_urca
double calc_urca(double np_0=0.0)
Compute the density at which the direct Urca process is allowe.
o2scl::nstar_cold::fzt
fermion_zerot fzt
Zero-temperature fermion thermodynamics.
Definition: nstar_cold.h:359
o2scl::nstar_cold::hep
eos_had_base * hep
A pointer to the equation of state.
Definition: nstar_cold.h:390
o2scl::nstar_cold::deny_urca
double deny_urca
The smallest density where Urca becomes disallowed.
Definition: nstar_cold.h:254
o2scl::nstar_cold::def_tov
tov_solve def_tov
The default TOV equation solver.
Definition: nstar_cold.h:363

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