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

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