Equation of State Sub-Library: Version 0.910
cold_nstar.h
00001 /*
00002   -------------------------------------------------------------------
00003   
00004   Copyright (C) 2006-2012, 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_COLD_NSTAR_H
00024 #define O2SCL_COLD_NSTAR_H
00025 
00026 #include <o2scl/hadronic_eos.h>
00027 #include <o2scl/tov_solve.h>
00028 #include <o2scl/table.h>
00029 #include <o2scl/fermion.h>
00030 #include <o2scl/cern_mroot_root.h>
00031 #include <o2scl/cern_mroot.h>
00032 #include <o2scl/gsl_mroot_hybrids.h>
00033 #include <o2scl/tov_eos.h>
00034 
00035 #ifndef DOXYGENP
00036 namespace o2scl {
00037 #endif
00038 
00039   /** \brief Naive static cold neutron star
00040 
00041       This uses hadronic_eos::calc_e() to compute the equation of 
00042       state of zero-temperature beta-equilibrated neutron star
00043       matter and tov_solve::mvsr() to compute the mass versus
00044       radius curve.
00045 
00046       The electron and muon are given masses \ref
00047       o2scl_fm::mass_electron and \ref o2scl_fm::mass_muon,
00048       respectively.
00049 
00050       There is an example for the usage of this class given
00051       in <tt>examples/ex_cold_nstar.cpp</tt>.
00052 
00053       \hline
00054       \b EOS Output
00055 
00056       The function calc_eos() generates an object of type
00057       \ref table_units, which contains the following columns
00058       - \c ed in units of \f$ 1/\mathrm{fm}^4 \f$, the total energy 
00059       density of neutron star matter
00060       - \c pr in units of \f$ 1/\mathrm{fm}^4 \f$, the total pressure
00061       of neutron star matter
00062       - \c nb in units of \f$ 1/\mathrm{fm}^3 \f$, the baryon 
00063       number density
00064       - \c mun in units of \f$ 1/\mathrm{fm} \f$, the neutron 
00065       chemical potential
00066       - \c mup in units of \f$ 1/\mathrm{fm} \f$, the proton chemical
00067       potential
00068       - \c mue in units of \f$ 1/\mathrm{fm} \f$, the electron 
00069       chemical potential
00070       - \c nn in units of \f$ 1/\mathrm{fm}^3 \f$, the neutron number
00071       density
00072       - \c np in units of \f$ 1/\mathrm{fm}^3 \f$, the proton number
00073       density
00074       - \c ne in units of \f$ 1/\mathrm{fm}^3 \f$, the electron 
00075       number density
00076       - \c kfn in units of \f$ 1/\mathrm{fm} \f$, the neutron Fermi
00077       momentum
00078       - \c kfp in units of \f$ 1/\mathrm{fm} \f$, the proton Fermi
00079       momentum
00080       - \c kfe in units of \f$ 1/\mathrm{fm} \f$, the electron 
00081       Fermi momentum.
00082 
00083       If \ref include_muons is true, the table has 
00084       additional columns
00085       - \c mumu in units of \f$ 1/\mathrm{fm} \f$, the muon chemical
00086       potential
00087       - \c nmu in units of \f$ 1/\mathrm{fm}^3 \f$, the muon number
00088       density
00089       - \c kfmu in units of \f$ 1/\mathrm{fm} \f$, the muon Fermi 
00090       momentum
00091 
00092       If the energy density is always positive and increasing, and the
00093       pressure is always positive and increasing, then the EOS is
00094       well-formed and \ref well_formed is \c true. The variable \ref
00095       pressure_flat records the lowest baryon density where the
00096       pressure decreases with increasing density.
00097       
00098       After computing the equation of state, \ref calc_eos()
00099       also adds the following columns
00100       - \c cs2 (unitless), the squared speed of sound
00101       - \c logp, the logarithm of the pressure stored in \c pr
00102       - \c loge, the logarithm of the energy density 
00103       stored in \c ed
00104       - \c s in units of \f$ 1/\mathrm{fm} \f$, 
00105       the semi-perimeter of the Urca triangle 
00106       - \c urca in units of \f$ 1/\mathrm{fm}^4 \f$, 
00107       the squared area of the Urca triangle
00108       - \c ad_index, the adiabatic index
00109 
00110       The condition for the direct Urca process is the area of the
00111       triangle formed by the neutron, proton, and electron Fermi
00112       momenta. Using the definition of the semi-perimeter, 
00113       \f[
00114       s \equiv \left( k_{F,n}+k_{F,p}+k_{F,e} \right)/2
00115       \f]
00116       Heron's formula gives the triangle area as
00117       \f[
00118       a=\sqrt{s(s-k_{F,n})(s-k_{F,p})(s-k_{F,e})} \, .
00119       \f]
00120       The column in the eos \ref table labeled \c urca is \f$ a^2 \f$
00121       . If this quantity is positive, then direct Urca is allowed. The
00122       variable \ref allow_urca is the smallest density for which the
00123       direct Urca process turns on, and \ref deny_urca is the smallest
00124       density for which the direct Urca process turns off.
00125       
00126       The squared speed of sound (in units of  \f$ c \f$ )
00127       is calculated by 
00128       \f[
00129       c_s^2 = \frac{ d P }{d \varepsilon}
00130       \f]
00131       and this is placed in the column labeled \c cs2. If the
00132       EOS is not well-formed, then this column is set to zero. If 
00133       \c cs2 is larger than 1, the EOS is said to be "acausal". The
00134       variables \ref acausal, \ref acausal_ed, and \ref acausal_pr
00135       record the baryon density, energy density, and pressure where
00136       the EOS becomes acausal. The adabatic index is calculated by
00137       \f[
00138       \Gamma = \frac{ d \ln P} { d \ln \varepsilon}
00139       \f]
00140       Note that \f$ \Gamma \f$ must be greater than \f$ 4/3 \f$ 
00141       at the center of the neutron star for stability. (This
00142       is a necessary, but not sufficient condition.)  If
00143       the EOS is not well-formed then this column is set to zero.
00144 
00145       \hline
00146       \b TOV Output
00147 
00148       The TOV table contains all the columns typically 
00149       generated for mass versus radius tables in \ref tov_solve,
00150       as well as columns containing the central values of 
00151       al the densities and chemical potentials, and all the 
00152       other columns computed for the EOS above. 
00153 
00154       \hline
00155 
00156       \future Warn if the EOS becomes pure neutron matter.
00157   */
00158 
00159   class cold_nstar {
00160 
00161   public:
00162 
00163     cold_nstar();
00164 
00165     /// \name Basic operation
00166     //@{
00167     /** \brief Set the equation of state
00168         
00169         This should be set before calling calc_eos().
00170     */
00171     int set_eos(hadronic_eos &he) {
00172       hep=&he;
00173       eos_set=true;
00174       return 0;
00175     }
00176 
00177     /** \brief Calculate the given equation of state
00178      */
00179     int calc_eos(double np_0=0.0);
00180 
00181     /** \brief Compute the density at which the direct Urca process is allowe
00182 
00183         This is faster than using calc_eos() since it does nothing
00184         other than computes the critical density. It does not store
00185         the equation of state.
00186      */
00187     double calc_urca(double np_0=0.0);
00188 
00189     /** \brief Calculate the M vs. R curve
00190      */
00191     int calc_nstar();
00192     //@}
00193 
00194     /// \name Output 
00195     //@{
00196     /// If true, the last call of calc_eos() succeeded.
00197     bool solver_success;
00198     
00199     /** \brief If true, the energy density of the EOS is monotonically 
00200         increasing and the pressure is always positive
00201     */
00202     bool well_formed;
00203 
00204     /** \brief The smallest baryon density where the pressure starts 
00205         to decrease
00206 
00207         If this is zero after calling calc_eos(), then 
00208         the pressure does not decrease in the specified range
00209         of baryon density
00210      */
00211     double pressure_flat;
00212 
00213     /** \brief The smallest density where Urca becomes allowed
00214 
00215         If this is zero after calling calc_eos(), then direct
00216         Urca is never allowed.
00217      */
00218     double allow_urca;
00219 
00220     /** \brief The smallest density where Urca becomes disallowed
00221         
00222         If this is zero after calling calc_eos(), then direct
00223         Urca is not disallowed at a higher density than 
00224         it becomes allowed.
00225      */
00226     double deny_urca;
00227 
00228     /** \brief The density at which the EOS becomes acausal
00229 
00230         If this is zero, then the EOS is causal at all baryon densities
00231         in the specified range
00232      */
00233     double acausal;
00234 
00235     /** \brief The pressure at which the EOS becomes acausal
00236 
00237         If this is zero, then the EOS is causal at all baryon densities
00238         in the specified range
00239      */
00240     double acausal_pr;
00241 
00242     /** \brief The energy density at which the EOS becomes acausal
00243 
00244         If this is zero, then the EOS is causal at all baryon densities
00245         in the specified range
00246      */
00247     double acausal_ed;
00248 
00249     /** \brief Solver tolerance (default \f$ 10^{-4} \f$)
00250     */
00251     double solver_tol;
00252 
00253     /// Verbosity parameter (default 0)
00254     int verbose;
00255 
00256     /** \brief Get the eos table (after having called calc_eos())
00257      */
00258     o2_shared_ptr<table_units>::type get_eos_results() {
00259       return eost;
00260     }
00261     
00262     /** \brief Get the results from the TOV (after having called calc_nstar())
00263      */
00264     o2_shared_ptr<table_units>::type get_tov_results() {
00265       return tp->get_results();
00266     }
00267     //@}
00268 
00269     /** \name Configuration
00270      */
00271     //@{
00272     /** \brief The starting baryon density (default 0.05)
00273      */
00274     double nb_start;
00275 
00276     /** \brief The final baryon density (default 2.0)
00277      */
00278     double nb_end;
00279 
00280     /** \brief The baryon density stepsize (default 0.01)
00281      */
00282     double dnb;
00283 
00284     /** \brief If true, include muons (default false)
00285      */
00286     bool include_muons;
00287 
00288     /// If true, throw an exception if the calculation fails (default true)
00289     bool err_nonconv;
00290 
00291     /** \brief Set the neutron and proton 
00292         
00293         The default objects are of type \ref fermion, with mass \ref
00294         o2scl_fm::mass_neutron and \ref o2scl_fm::mass_proton. These
00295         defaults will give incorrect results for non-relativistic
00296         equations of state.
00297      */
00298     int set_n_and_p(fermion &n, fermion &p) {
00299       np=&n;
00300       pp=&p;
00301       return 0;
00302     }
00303 
00304     /** \brief Set the equation solver for the EOS
00305      */
00306     int set_root(root<funct> &rf) {
00307       rp=&rf;
00308       return 0;
00309     }
00310 
00311     /** \brief Specify the object for solving the TOV equations
00312         
00313         The default uses the low-density equation of state with
00314         tov::verbose=0. In calc_nstar(), the units are set by calling
00315         tov_solve::set_units().
00316     */
00317     int set_tov(tov_solve &ts) {
00318       tp=&ts;
00319       return 0;
00320     }
00321     //@}
00322 
00323     /** \name Default objects */
00324     //@{
00325     /// The default neutron
00326     fermion def_n;
00327 
00328     /// The default proton
00329     fermion def_p;
00330 
00331     /// Desc
00332     fermion_zerot fzt;
00333 
00334     /** \brief The default TOV equation solver
00335      */
00336     tov_solve def_tov;
00337 
00338     /** \brief The default equation solver for the EOS
00339     */
00340     cern_mroot_root<funct> def_root;
00341 
00342     /// Default EOS object for the TOV solver
00343     tov_interp_eos def_tov_eos;
00344     //@}
00345 
00346 #ifndef DOXYGEN_INTERNAL
00347 
00348   protected:
00349 
00350     /// \name The thermodynamic information
00351     //@{
00352     thermo hb, h, l;
00353     //@}
00354 
00355     /// Solve to ensure zero charge in \f$ \beta \f$-equilibrium
00356     double solve_fun(double x);
00357 
00358     /// True if equation of state has been set
00359     bool eos_set;
00360 
00361     /// The electron
00362     fermion e;
00363 
00364     /// The muon
00365     fermion mu;
00366 
00367     /// A pointer to the equation of state
00368     hadronic_eos *hep;
00369 
00370     /// A pointer to the neutron
00371     fermion *np;
00372 
00373     /// A pointer to the proton
00374     fermion *pp;
00375 
00376     /// A pointer to the TOV object
00377     tov_solve *tp;
00378     
00379     /// A pointer to the solver
00380     root<funct> *rp;
00381 
00382     /// Storage for the EOS table
00383     o2_shared_ptr<table_units>::type eost;
00384 
00385     /// The baryon density
00386     double barn;
00387 
00388 #endif
00389 
00390   };
00391 
00392 
00393 #ifndef DOXYGENP
00394 }
00395 #endif
00396 
00397 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Friends

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

Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads.