nstar_cold.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2006-2018, 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  \todo Maybe calc_eos() doesn't really need a thermo object since
180  it can use the default EOS thermo object and we can get
181  rid of the class variables h, hb, and l
182 
183  \future Warn if the EOS becomes pure neutron matter.
184  \future Some of the auxillary quantities can be computed
185  directly without using the table methods and the
186  EOS calculation would be a bit faster.
187  */
188 
189  class nstar_cold {
190 
191  public:
192 
193  nstar_cold();
194 
195  /// \name Basic operation
196  //@{
197  /** \brief Set the equation of state
198 
199  This should be set before calling calc_eos().
200  */
201  void set_eos(eos_had_base &he) {
202  hep=&he;
203  eos_set=true;
204  return;
205  }
206 
207  /** \brief Calculate the given equation of state
208  */
209  int calc_eos(double np_0=0.0);
210 
211  /** \brief Compute the density at which the direct Urca process is allowe
212 
213  This is faster than using calc_eos() since it does nothing
214  other than computes the critical density. It does not store
215  the equation of state.
216  */
217  double calc_urca(double np_0=0.0);
218 
219  /** \brief Calculate the M vs. R curve
220  */
221  int calc_nstar();
222 
223  /** \brief Calculate the profile for a fixed gravitational mass
224  */
225  int fixed(double target_mass);
226  //@}
227 
228  /// \name Output
229  //@{
230  /** \brief If true, the energy density and pressure
231  of the EOS is monotonically
232  increasing and the pressure is always positive
233  */
235 
236  /** \brief The smallest baryon density where the pressure starts
237  to decrease
238 
239  If this is zero after calling calc_eos(), then
240  the pressure does not decrease in the specified range
241  of baryon density
242  */
243  double pressure_dec;
244 
245  /** \brief The smallest density where Urca becomes allowed
246 
247  If this is zero after calling calc_eos(), then direct
248  Urca is never allowed.
249  */
250  double allow_urca;
251 
252  /** \brief The smallest density where Urca becomes disallowed
253 
254  If this is zero after calling calc_eos(), then direct
255  Urca is not disallowed at a higher density than
256  it becomes allowed.
257  */
258  double deny_urca;
259 
260  /** \brief The density at which the EOS becomes acausal
261 
262  If this is zero, then the EOS is causal at all baryon densities
263  in the specified range
264  */
265  double acausal;
266 
267  /** \brief The pressure at which the EOS becomes acausal
268 
269  If this is zero, then the EOS is causal at all baryon densities
270  in the specified range
271  */
272  double acausal_pr;
273 
274  /** \brief The energy density at which the EOS becomes acausal
275 
276  If this is zero, then the EOS is causal at all baryon densities
277  in the specified range
278  */
279  double acausal_ed;
280 
281  /** \brief Solver tolerance (default \f$ 10^{-4} \f$)
282  */
283  double solver_tol;
284 
285  /// Verbosity parameter (default 0)
286  int verbose;
287 
288  /** \brief Return the results data table
289 
290  This function immediately adds four constants to the table,
291  <tt>schwarz, Msun, pi</tt> and <tt>mproton</tt>.
292  */
293  void set_eos_table(std::shared_ptr<table_units<> > t) {
294  eost=t;
295  return;
296  }
297 
298  /** \brief Get the eos table (after having called calc_eos())
299  */
300  std::shared_ptr<table_units<> > get_eos_results() {
301  return eost;
302  }
303 
304  /** \brief Get the results from the TOV (after having called calc_nstar())
305  */
306  std::shared_ptr<table_units<> > get_tov_results() {
307  return tp->get_results();
308  }
309  //@}
310 
311  /** \name Configuration
312  */
313  //@{
314  /** \brief The starting baryon density (default 0.05)
315  */
316  double nb_start;
317 
318  /** \brief The final baryon density (default 2.0)
319  */
320  double nb_end;
321 
322  /** \brief The baryon density stepsize (default 0.01)
323  */
324  double dnb;
325 
326  /** \brief If true, include muons (default false)
327  */
329 
330  /** \brief If true, throw an exception if the solver fails
331  or if the EOS is not well-formed (default true)
332  */
334 
335  /** \brief Set the equation solver for the EOS
336  */
337  int set_root(root<> &rf) {
338  rp=&rf;
339  return 0;
340  }
341 
342  /** \brief Specify the object for solving the TOV equations
343 
344  The default uses the low-density equation of state with
345  tov::verbose=0. In calc_nstar(), the units are set by calling
346  tov_solve::set_units().
347  */
348  int set_tov(tov_solve &ts) {
349  tp=&ts;
350  return 0;
351  }
352  //@}
353 
354  /** \name Default objects */
355  //@{
356  /// The default neutron
358 
359  /// The default proton
361 
362  /// Zero-temperature fermion thermodynamics
364 
365  /** \brief The default TOV equation solver
366  */
368 
369  /** \brief The default equation solver for the EOS
370  */
372 
373  /// Default EOS object for the TOV solver
375  //@}
376 
377 #ifndef DOXYGEN_INTERNAL
378 
379  protected:
380 
381  /// \name The thermodynamic information
382  //@{
383  thermo hb, h, l;
384  //@}
385 
386  /// Solve to ensure zero charge in \f$ \beta \f$-equilibrium
387  double solve_fun(double x);
388 
389  /// True if equation of state has been set
390  bool eos_set;
391 
392  /// The electron
394 
395  /// The muon
397 
398  /// A pointer to the equation of state
400 
401  /// A pointer to the TOV object
403 
404  /// A pointer to the solver
406 
407  /// Storage for the EOS table
408  std::shared_ptr<table_units<> > eost;
409 
410  /// The baryon density
411  double barn;
412 
413 #endif
414 
415  };
416 
417 
418 #ifndef DOXYGEN_NO_O2NS
419 }
420 #endif
421 
422 #endif
eos_tov_interp def_eos_tov
Default EOS object for the TOV solver.
Definition: nstar_cold.h:374
eos_had_base * hep
A pointer to the equation of state.
Definition: nstar_cold.h:399
fermion pp
The default proton.
Definition: nstar_cold.h:360
std::shared_ptr< table_units<> > get_tov_results()
Get the results from the TOV (after having called calc_nstar())
Definition: nstar_cold.h:306
Naive static cold neutron star.
Definition: nstar_cold.h:189
std::shared_ptr< table_units<> > get_results()
Return the results data table.
Definition: tov_solve.h:716
int set_root(root<> &rf)
Set the equation solver for the EOS.
Definition: nstar_cold.h:337
int verbose
Verbosity parameter (default 0)
Definition: nstar_cold.h:286
tov_solve * tp
A pointer to the TOV object.
Definition: nstar_cold.h:402
double deny_urca
The smallest density where Urca becomes disallowed.
Definition: nstar_cold.h:258
double acausal_ed
The energy density at which the EOS becomes acausal.
Definition: nstar_cold.h:279
std::shared_ptr< table_units<> > eost
Storage for the EOS table.
Definition: nstar_cold.h:408
root_cern def_root
The default equation solver for the EOS.
Definition: nstar_cold.h:371
double pressure_dec
The smallest baryon density where the pressure starts to decrease.
Definition: nstar_cold.h:243
int set_tov(tov_solve &ts)
Specify the object for solving the TOV equations.
Definition: nstar_cold.h:348
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:234
double solver_tol
Solver tolerance (default )
Definition: nstar_cold.h:283
bool eos_set
True if equation of state has been set.
Definition: nstar_cold.h:390
fermion e
The electron.
Definition: nstar_cold.h:393
double solve_fun(double x)
Solve to ensure zero charge in -equilibrium.
An EOS for the TOV solver using simple linear interpolation and an optional crust EOS...
Definition: eos_tov.h:695
fermion np
The default neutron.
Definition: nstar_cold.h:357
fermion_zerot fzt
Zero-temperature fermion thermodynamics.
Definition: nstar_cold.h:363
Hadronic equation of state [abstract base].
Definition: eos_had_base.h:324
void set_eos_table(std::shared_ptr< table_units<> > t)
Return the results data table.
Definition: nstar_cold.h:293
int fixed(double target_mass)
Calculate the profile for a fixed gravitational mass.
tov_solve def_tov
The default TOV equation solver.
Definition: nstar_cold.h:367
Class to solve the Tolman-Oppenheimer-Volkov equations.
Definition: tov_solve.h:350
double nb_end
The final baryon density (default 2.0)
Definition: nstar_cold.h:320
double calc_urca(double np_0=0.0)
Compute the density at which the direct Urca process is allowe.
double barn
The baryon density.
Definition: nstar_cold.h:411
void set_eos(eos_had_base &he)
Set the equation of state.
Definition: nstar_cold.h:201
fermion mu
The muon.
Definition: nstar_cold.h:396
double acausal_pr
The pressure at which the EOS becomes acausal.
Definition: nstar_cold.h:272
std::shared_ptr< table_units<> > get_eos_results()
Get the eos table (after having called calc_eos())
Definition: nstar_cold.h:300
double acausal
The density at which the EOS becomes acausal.
Definition: nstar_cold.h:265
double dnb
The baryon density stepsize (default 0.01)
Definition: nstar_cold.h:324
double nb_start
The starting baryon density (default 0.05)
Definition: nstar_cold.h:316
int calc_nstar()
Calculate the M vs. R curve.
double allow_urca
The smallest density where Urca becomes allowed.
Definition: nstar_cold.h:250
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:333
bool include_muons
If true, include muons (default false)
Definition: nstar_cold.h:328
int calc_eos(double np_0=0.0)
Calculate the given equation of state.
root * rp
A pointer to the solver.
Definition: nstar_cold.h:405

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