eos_sn.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 eos_sn.h
24  \brief File defining \ref o2scl::eos_sn_base
25 */
26 #ifndef GEN_SN_EOS_H
27 #define GEN_SN_EOS_H
28 
29 #include <cmath>
30 #include <iostream>
31 #include <fstream>
32 #include <o2scl/constants.h>
33 #include <o2scl/tensor_grid.h>
34 #include <o2scl/table.h>
35 #include <o2scl/boson_eff.h>
36 #include <o2scl/fermion_rel.h>
37 #include <o2scl/fermion_eff.h>
38 #include <o2scl/test_mgr.h>
39 #include <o2scl/convert_units.h>
40 #include <o2scl/interp2_direct.h>
41 
42 #ifndef DOXYGEN_NO_O2NS
43 namespace o2scl {
44 #endif
45 
46  /** \brief A base class for the supernova EOSs [abstract]
47 
48  This class is experimental.
49 
50  See also the general description in the \ref sneos_section
51  section of the User's guide.
52 
53  \comment
54  \todo Allow logarithmic grids for any of nb, Ye, or T.
55  12/10/13: The member variables are in the parent class, but no
56  code is written to use them yet. What really are these for?
57  1/3/14: In fact, the linear vs. logarithmic distinction isn't
58  necessarily useful, because some of the grids (e.g. T for sht)
59  aren't either purely linear or purely logarithmic.
60  \endcomment
61 
62  \future Add option to rescale energies and chemical
63  potentials to different masses.
64  \future Create a \ref o2scl::table object, possibly using
65  tensor_grid::vector_slice.
66  \future Show how matrix_slice and vector_slice can be used
67  with this object.
68  \future Add option to load and store a separate lepton/photon
69  EOS
70  \future Add pions?
71  \future Create a standard output format? Output to
72  stellarcollapse.org HDF5 format?
73 
74  \comment
75  \future Could this be a child of eos_had_temp_base and
76  then directly used in nstar_cold()? Actually no, this doesn't
77  work because of the nuclei.
78  \endcomment
79 
80  */
81  class eos_sn_base {
82 
83  public:
84 
87 
88  eos_sn_base();
89 
90  virtual ~eos_sn_base();
91 
92  /// \name Grid and data sizes
93  //@{
94  /// Size of baryon density grid
95  size_t n_nB;
96  /// Size of electron fraction grid
97  size_t n_Ye;
98  /// Size of temperature grid
99  size_t n_T;
100  /// Baryon density grid (in \f$ \mathrm{fm}^{-3} \f$)
101  std::vector<double> nB_grid;
102  /// Electron fraction grid
103  std::vector<double> Ye_grid;
104  /// Temperature grid (in \f$ \mathrm{MeV} \f$)
105  std::vector<double> T_grid;
106  /// Number of additional data sets
107  size_t n_oth;
108  /// Number of base data sets
109  static const size_t n_base=16;
110  //@}
111 
112  /// \name Data
113  //@{
114  /** \brief Total free energy per baryon in MeV (without
115  baryon rest masses but including electron rest mass)
116 
117  By default, this energy is relative to
118  \f[
119  m_n (1-Y_e) + m_p Y_e
120  \f]
121  where \f$ m_n \f$ is stored in \ref m_neut and \f$ m_p \f$
122  is stored in \ref m_prot .
123  */
125  /** \brief Free energy per baryon without lepton and photon
126  contributions in MeV
127 
128  By default, this energy is relative to
129  \f[
130  m_n (1-Y_e) + m_p Y_e
131  \f]
132  where \f$ m_n \f$ is stored in \ref m_neut and \f$ m_p \f$
133  is stored in \ref m_prot .
134  */
136  /** \brief Total internal energy per baryon in MeV (without
137  baryon rest masses but including electron rest mass)
138 
139  By default, this energy is relative to
140  \f[
141  m_n (1-Y_e) + m_p Y_e
142  \f]
143  where \f$ m_n \f$ is stored in \ref m_neut and \f$ m_p \f$
144  is stored in \ref m_prot .
145  */
147  /** \brief Internal energy per baryon without lepton and photon
148  contributions in MeV
149 
150  By default, this energy is relative to
151  \f[
152  m_n (1-Y_e) + m_p Y_e
153  \f]
154  where \f$ m_n \f$ is stored in \ref m_neut and \f$ m_p \f$
155  is stored in \ref m_prot .
156  */
158  /// Total pressure in \f$ \mathrm{MeV}/\mathrm{fm}^3 \f$
160  /** \brief Pressure without lepton and photon contributions
161  in \f$ \mathrm{MeV}/\mathrm{fm}^3 \f$
162  */
164  /// Total entropy per baryon
166  /// Entry per baryon without lepton and photon contributions
168  /** \brief Neutron chemical potential in MeV
169 
170  By default this is relative to the neutron mass in
171  \ref m_neut .
172  */
174  /** \brief Proton chemical potential in MeV
175 
176  By default this is relative to the proton mass in
177  \ref m_prot .
178  */
180  /// Proton number
182  /// Mass number
184  /// Neutron baryon fraction
186  /// Proton baryon fraction
188  /// Alpha particle baryon fraction
190  /// Heavy nuclei baryon fraction
192  /// Other data sets
194  /// List of pointers to data
195  tensor_grid3<> *arr[n_base+30];
196  //@}
197 
198  /** \brief Check the table composition entries
199  */
200  void check_composition(double &max1, double &max2);
201 
202  /// \name Interpolation
203  //@{
204  /** \brief Set the interpolation type of all the
205  \ref o2scl::tensor_grid3 objects to type \c interp_type .
206 
207  \note This is used by the constructor to set all tensors
208  to linear interpolation.
209  */
210  void set_interp_type(size_t interp_type);
211  //@}
212 
213  /// \name Nucleon masses
214  //@{
215  /** \brief Neutron mass in \f$ \mathrm{MeV} \f$
216  (defaults to o2scl_mks::mass_neutron times o2scl_const::hc_mev_fm)
217  */
218  double m_neut;
219 
220  /** \brief Proton mass in \f$ \mathrm{MeV} \f$
221  (defaults to o2scl_mks::mass_proton times o2scl_const::hc_mev_fm)
222  */
223  double m_prot;
224  //@}
225 
226  /// \name Electron and photon contribution
227  //@{
228  /// Photon
230  /// Electron
232  /// Muon
234  /// If true, include muons
236  /// Relativistic fermion thermodynamics
238  /** \brief Compute the electron and photon contribution for the full
239  grid
240 
241  If \ref baryons_only_loaded is true, this function computes
242  the data for <tt>E, P, S,</tt> and <tt>F</tt> by adding
243  electrons and photons to the baryon contributions stored in
244  <tt>Eint, Pint, Sint,</tt> and <tt>Fint</tt>. Otherwise,
245  this function computes <tt>Eint, Pint, Sint,</tt> and
246  <tt>Fint</tt> by subtracting electron and photon
247  contributions from <tt>E, P, S,</tt> and <tt>F</tt>.
248 
249  The electron contribution to the internal energy and free
250  energy computed by this function includes the electron rest
251  mass.
252  */
253  virtual void compute_eg();
254 
255  /** \brief Compute lepton contribution at one point
256  */
257  virtual void compute_eg_point(double nB, double Ye, double T,
258  thermo &th);
259 
260  /** \brief Check electrons and photons
261 
262  This checks that the electron and photon thermodynamics
263  generated by \o2 is consistent with the data in
264  \c E, \c Eint, \c F, \c Fint, \c P, \c Pint, \c S,
265  and \c Sint.
266  */
267  virtual double check_eg();
268  //@}
269 
270  /** \brief Test the free energy and store results in \c tm
271 
272  This checks that the data in \c Fint is consistent with that
273  in \c Eint and \c Sint (if \ref baryons_only_loaded is true)
274  and that \c F is consistent with that in \c E and \c S (if
275  \ref with_leptons_loaded is true).
276  */
277  void check_free_energy(double &avg);
278 
279  /** \brief Verbosity parameter (default 1)
280  */
281  int verbose;
282 
283  /** \brief Compute properties of matter in beta equilibrium
284  at fixed entropy per baryon
285 
286  This function just does a simple hard-coded linear
287  interpolation.
288  */
289  virtual void beta_eq_sfixed
290  (double nB, double entr, double &Ye, double &T);
291 
292  /** \brief Compute the electron fraction for beta-equilibrium
293  at fixed density and temperature temperature
294 
295  This function just uses linear interpolation to
296  interpolate in baryon density and temperature and
297  the uses a quadratic to determine the minimum of the
298  free energy.
299 
300  If \ref data_with_leptons() is <tt>false</tt>, then
301  \ref compute_eg() is used to compute the leptons.
302  */
303  virtual void beta_eq_Tfixed(double nB, double T, double &Ye);
304 
305  /// Return true if data has been loaded
306  bool is_loaded() {
307  return loaded;
308  }
309 
310  /// Free allocated memory
311  void free();
312 
313  /// Return true if data with lepton information has been loaded
315  return with_leptons_loaded;
316  }
317 
318  /// Return true if data with only baryon information has been loaded
320  return baryons_only_loaded;
321  }
322 
323  /* \brief Load EOS from file named \c file_name
324 
325  \comment
326  The native EOS type overriddes this generic function,
327  but this function is for loading other EOSs in the
328  base class format
329  \endcomment
330  */
331  virtual void load(std::string fname);
332 
333  /* \brief Output EOS to file named \c file_name
334 
335  \comment
336  The native EOS type overriddes this generic function,
337  but this function is for writing other EOSs in the
338  base class format
339  \endcomment
340  */
341  virtual void output(std::string fname);
342 
343  /// Labels for the extra data sets included in current EOS
344  std::vector<std::string> oth_names;
345 
346  /// Units for the extra data sets included in current EOS
347  std::vector<std::string> oth_units;
348 
349  /** \brief A slice of data from \ref eos_sn_base for one index fixed
350 
351  This class allows one to easily construct a \ref
352  o2scl::interp2_direct object automatically by fixing one index
353  from one of the \ref o2scl::tensor_grid3 objects in a child of
354  \ref o2scl::eos_sn_base .
355  */
356  class slice {
357 
358  public:
359 
360  /// Typedef for the matrix type
361  typedef std::function<double &(size_t,size_t)> data_t;
362 
363  /// Data object in the form of a matrix
364  data_t data;
365 
366  /// \name Grid vectors
367  //@{
368  ubvector grid_x, grid_y;
369  //@}
370 
371  /** \brief The interpolation object
372  */
375 
376  /** \brief Set the slice to correspond to a matrix
377  in the form \f$ (n_B,T) \f$
378  */
379  void set_nB_T(tensor_grid3<> &tg3, size_t iYe) {
380  /*
381  data=std::bind(std::mem_fn<double &(size_t,size_t,size_t)>
382  (&tensor_grid3<>::get),tg3,std::placeholders::_1,iYe,
383  std::placeholders::_2);
384  size_t nx=tg3.get_size(0);
385  grid_x.resize(nx);
386  for(size_t i=0;i<nx;i++) grid_x[i]=tg3.get_grid(0,i);
387  size_t ny=tg3.get_size(2);
388  grid_y.resize(ny);
389  for(size_t i=0;i<ny;i++) grid_y[i]=tg3.get_grid(2,i);
390  it.set_data(nx,ny,grid_x,grid_y,data);
391  */
392  return;
393  }
394 
395  /** \brief Set the slice to correspond to a matrix
396  in the form \f$ (n_B,Y_e) \f$
397  */
398  void set_nB_Ye(tensor_grid3<> &tg3, size_t iT) {
399  /*
400  data=std::bind(std::mem_fn<double &(size_t,size_t,size_t)>
401  (&tensor_grid3<>::get),tg3,std::placeholders::_1,
402  std::placeholders::_2,iT);
403  size_t nx=tg3.get_size(0);
404  grid_x.resize(nx);
405  for(size_t i=0;i<nx;i++) grid_x[i]=tg3.get_grid(0,i);
406  size_t ny=tg3.get_size(1);
407  grid_y.resize(ny);
408  for(size_t i=0;i<ny;i++) grid_y[i]=tg3.get_grid(1,i);
409  it.set_data(nx,ny,grid_x,grid_y,data);
410  */
411  return;
412  }
413 
414  /** \brief Set the slice to correspond to a matrix
415  in the form \f$ (T,Y_e) \f$
416  */
417  void set_T_Ye(tensor_grid3<> &tg3, size_t inB) {
418  /*
419  data=std::bind(std::mem_fn<double &(size_t,size_t,size_t)>
420  (&tensor_grid3<>::get),tg3,inB,std::placeholders::_2,
421  std::placeholders::_1);
422  size_t nx=tg3.get_size(2);
423  grid_x.resize(nx);
424  for(size_t i=0;i<nx;i++) grid_x[i]=tg3.get_grid(2,i);
425  size_t ny=tg3.get_size(1);
426  grid_y.resize(ny);
427  for(size_t i=0;i<ny;i++) grid_y[i]=tg3.get_grid(1,i);
428  it.set_data(nx,ny,grid_x,grid_y,data);
429  */
430  return;
431  }
432 
433  };
434 
435  protected:
436 
437  /** \brief Unit conversion object (set automatically in constructor)
438  */
440  /// If true, a EOS table was successfully loaded (default false)
441  bool loaded;
442  /// True if thermodynamics with leptons has been loaded
444  /// True if baryon-only thermodynamics has been loaded
446 
447  /// \name Memory allocation
448  //@{
449  /// Allocate memory
450  void alloc();
451  //@}
452 
453 
454  };
455 
456  /** \brief The Lattimer-Swesty supernova EOS
457 
458  This class is experimental.
459 
460  \note \o2 Does not contain the Lattimer-Swesty EOS, only
461  provides some code to manipulate it. This class is designed
462  to be used with the files <tt>ls.dat, sk1.dat, ska.dat</tt>
463  and <tt>skm.dat</tt> as provided on Jim Lattimer's website,
464  http://www.astro.sunysb.edu/lattimer/EOS/main.html .
465 
466  Note that the tables on this website are different
467  than what is generated from the LS Fortran code. See
468  \ref eos_sn_oo to read O'Connor and Ott's tables
469  generated from the LS Fortran code.
470 
471  The four models are
472  - LS (K=370, Sv=31)
473  - SKI' (K=371, Sv=30.4)
474  - SKa (K=263, Sv=34.5)
475  - SKM* (K=217, Sv=31.4)
476 
477  \note In the original table, the full internal energy per baryon
478  (data section 4 of 26) is apparently based on a rest mass of
479  \f$ Y_e m_p + (1-Y_e) m_n \f$, while the baryon part of the
480  internal energy per baryon (data section 13 of 26) is based
481  on a rest mass of \f$ m_n \f$. This means that
482  \f[
483  E - E_{\mathrm{int}} = E_{\mathrm{eg}} - Y_e (m_n - m_p)
484  \f]
485  where \f$ E_{\mathrm{eg}} \f$ is the energy per baryon of
486  electrons and photons. In order to keep things consistent with
487  the other EOS tables, when the EOS table is loaded, \ref
488  eos_sn_base::Eint is rescaled to a rest mass of \f$ Y_e m_p +
489  (1-Y_e) m_n \f$ .
490 
491  See also the documentation at \ref eos_sn_base and the
492  \ref sneos_section section of the User's guide.
493 
494  See \ref Lattimer91 and \ref Lattimer85.
495 
496  \todo There are still a few points for which the electron/photon
497  EOS seems to be off, but this may be the result of small
498  inaccuracies from finite-differencing the LS table.
499  */
500  class eos_sn_ls : public eos_sn_base {
501 
502  public:
503 
504  /// \name Additional data included in this EOS
505  //@{
506  /// Filling factor for nuclei
508  /// Baryon number density inside nuclei in \f$ \mathrm{fm}^{-3} \f$
510  /// Derivative of pressure with respect to baryon density
512  /// Derivative of pressure with respect to temperature
514  /// Derivative of pressure with respect to electron fraction
516  /// Derivative of entropy with respect to temperature
518  /// Derivative of entropy with respect to electron fraction
520  /// Number of neutrons in skin
522  /// Baryon density outside nuclei in \f$ \mathrm{fm}^{-3} \f$
524  /// Proton fraction outside nuclei
526  /** \brief Out of whackness parameter,
527  \f$ \mu_n-\mu_p-\mu_e+1.293~\mathrm{MeV} \f$, in MeV
528  */
530  //@}
531 
532  eos_sn_ls() :
533  fill(other[0]),
534  nb_in(other[1]),
535  dPdn(other[2]),
536  dPdT(other[3]),
537  dPdY(other[4]),
538  dsdT(other[5]),
539  dsdY(other[6]),
540  Nskin(other[7]),
541  nb_out(other[8]),
542  x_out(other[9]),
543  mu(other[10]) {
544  }
545 
546  /// Load table from filename \c fname
547  virtual void load(std::string fname);
548 
549  /** \brief Check electrons and photons
550 
551  This checks that the electron and photon thermodynamics
552  generated by \o2 is consistent with the data in
553  \c E, \c Eint, \c F, \c Fint, \c P, \c Pint, \c S,
554  and \c Sint.
555  */
556  virtual double check_eg();
557  };
558 
559  /** \brief The EOS tables from O'Connor and Ott
560 
561  This class reads the HDF5 EOS tables generated by E. O'Connor
562  and C. Ott in \ref OConnor10. The tables are available from
563 
564  http://stellarcollapse.org/equationofstate
565 
566  and are available under a creative commons
567  attribution-noncommercial-share alike license. This \o2 code to
568  read those tables is licensed (along with all \o2 code) under
569  the GPLv3 license (with permission from Evan O'Connor).
570 
571  The original README file from O'Connor and Ott's EOSdriver
572  code is available in the \o2
573  distribution in <tt>doc/o2scl/eos/extras/scollapse_README</tt>
574  and is reproduced below
575 
576  \verbinclude scollapse_README
577 
578  See also the documentation at \ref eos_sn_base and the
579  \ref sneos_section section of the User's guide.
580 
581  \future Loading an EOS currently requires loading the HDF5 file
582  and then copying it. This wouldn't be necessary if the \o2
583  tensor had the same ordering as the indices in the original
584  HDF5 file.
585  */
586  class eos_sn_oo : public eos_sn_base {
587 
588  public:
589 
590  eos_sn_oo() :
591  cs2(other[0]),
592  dedt(other[1]),
593  dpderho(other[2]),
594  dpdrhoe(other[3]),
595  gamma(other[4]),
596  mu_e(other[5]),
597  muhat(other[6]),
598  munu(other[7]),
599  XHe3(other[8]),
600  XLi4(other[9]),
601  Xt(other[10]),
602  Xd(other[11]) {
603  }
604 
605  /// \name Additional data included in this EOS
606  //@{
607  /// Speed of sound in cm^2/s^2
609  /// C_V in erg/g/K
611  /// dpderho in dyn*g/cm^2/erg
613  /// dpdrhoe in dyn cm^3/cm^2/g
615  /// Gamma
617  /// Electron chemical potential per baryon including rest mass
619  /// mun - mup
621  /// mue - mun + mup
623  /// Helion fraction
625  /// Lithium-4 fraction
627  /// Triton fraction
629  /// Deuteron fraction
631  /// The original mass density grid from the table in g/cm^3
632  std::vector<double> rho;
633  /// Energy shift for table storage in erg/g
634  double energy_shift;
635  //@}
636 
637  /// \name Table modes
638  //@{
639  /// Use the J. Lattimer et al. method for handling the chemical potentials
640  static const size_t ls_mode=0;
641  /// Use the H. Shen et al. method for handling the chemical potentials
642  static const size_t stos_mode=1;
643  /// Set for a Hempel et al. table with light nuclei
644  static const size_t hfsl_mode=2;
645  /// Set for a G. Shen et al. table
646  static const size_t sht_mode=3;
647  //@}
648 
649  /// Load table from filename \c fname with mode \c mode
650  virtual void load(std::string fname, size_t mode);
651 
652  };
653 
654  /** \brief The H. Shen et al. supernova EOS
655 
656  This class is experimental.
657 
658  \note \o2 Does not contain the EOS, only provides some code to
659  manipulate it. This class is designed to be used with the file
660  which was originally called <tt>eos.tab</tt> and now referred to
661  as <tt>eos1.tab</tt> and stored e.g. at
662  http://user.numazu-ct.ac.jp/~sumi/eos/.
663 
664  In order to force the EOS to a uniform grid, linear
665  interpolation is used to recast the variation in baryon density,
666  choosing the grid in baryon density to be the same as the
667  section in the table with T=0.1 MeV and \f$ Y_p = 0.1 \f$ for
668  all temperature and proton fraction points.
669 
670  The data for \ref eos_sn_base::E, \ref eos_sn_base::F, \ref
671  eos_sn_base::S, and \ref eos_sn_base::P is not stored in the table
672  but can be computed with \ref eos_sn_base::compute_eg().
673 
674  See also the documentation at \ref eos_sn_base and the
675  \ref sneos_section section of the User's guide.
676 
677  See \ref Shen98 and \ref Shen98b .
678 
679  \note Thanks to Matthias Hempel for providing the correct
680  temperature grid.
681 
682  \todo Add the T=0 and Ye=0 data to this class. Separate
683  tables for these cases have been released, but I don't think
684  this class can read them yet.
685  */
686  class eos_sn_stos : public eos_sn_base {
687 
688  public:
689 
690  /// \name Additional data included in this EOS
691  //@{
692  /** \brief Logarithm of baryon number density in
693  \f$ \mathrm{g}/\mathrm{cm}^3 \f$
694  */
696  /// Baryon number density in \f$ \mathrm{fm}^{-3} \f$
698  /// Logarithm of proton fraction
700  /// Proton fraction
702  /// Nucleon effective mass in MeV
704  /// Fraction of quark matter
706  //@}
707 
708  eos_sn_stos() :
709  log_rho(other[0]),
710  nB(other[1]),
711  log_Y(other[2]),
712  Yp(other[3]),
713  M_star(other[4]),
714  quark_frac(other[5]) {
715  check_grid=true;
716  m_neut=938.0;
717  m_prot=938.0;
718  }
719 
720  static const size_t orig_mode=0;
721  static const size_t quark_mode=1;
722 
723  /// If true, check the grid after load() (default true)
725 
726  /// Load table from filename \c fname with mode \c mode
727  virtual void load(std::string fname, size_t mode);
728 
729  };
730 
731  /** \brief A class to manipulate the G. Shen et al. EOS
732 
733  This class is experimental.
734 
735  \note \o2 Does not contain the EOS, only provides some code to
736  manipulate it. This class was designed to be used with the FSU
737  models given at
738  http://cecelia.physics.indiana.edu/gang_shen_eos/FSU/fsu.html .
739  The full list of files and the associated modes for the
740  \ref load() function are:
741  - <tt>"FSU1.7eos1.01.dat"</tt> (\ref mode_17)
742  - <tt>"FSU2.1eos1.01.dat"</tt> (\ref mode_21)
743  - <tt>"FSU1.7eosb1.01.dat"</tt> (\ref mode_17b)
744  - <tt>"FSU2.1eosb1.01.dat"</tt> (\ref mode_21b)
745  - <tt>"NL3eos1.03.dat"</tt> (\ref mode_NL3)
746  - <tt>"NL3eosb1.03.dat"</tt> (\ref mode_NL3b)
747 
748  See also the documentation at \ref eos_sn_base and the
749  \ref sneos_section section of the User's guide.
750 
751  The free energy per baryon neutron and proton chemical
752  potentials are relative to a nucleon mass of 939 MeV. The values
753  of \ref o2scl::eos_sn_base::m_neut and \ref
754  o2scl::eos_sn_base::m_prot are set to 939 MeV accordingly. The
755  electron chemical potential still includes its rest mass. All
756  quantites are stored as in the original table, except that
757  the values in \ref o2scl::eos_sn_base::E or \ref
758  o2scl::eos_sn_base::Eint are computed directly from the
759  thermodynamic identity.
760 
761  See \ref Shen11.
762 
763  \warning The NL3 model is probably ruled out by nuclear mass
764  data, neutron matter calculations, and neutron star mass and
765  radius observations.
766  */
767  class eos_sn_sht : public eos_sn_base {
768 
769  public:
770 
771  /// \name Table modes
772  //@{
773  /// 1.7 solar masses with leptons and photons
774  static const size_t mode_17=0;
775  /// 2.1 solar masses with leptons and photons
776  static const size_t mode_21=1;
777  /// 1.7 solar masses without leptons and photons
778  static const size_t mode_17b=2;
779  /// 2.1 solar masses without leptons and photons
780  static const size_t mode_21b=3;
781  /// NL3 model with leptons and photons
782  static const size_t mode_NL3=4;
783  /// NL3 model with leptons and photons
784  static const size_t mode_NL3b=5;
785  //@}
786 
787  /// \name Additional data included in this EOS
788  //@{
789  /// Temperature in MeV
791  /// Proton fraction
793  /// Baryon number density in \f$ 1/\mathrm{fm}^3 \f$
795  /// Electron chemical potential in MeV
797  /// Nucleon effective mass (Dirac) in MeV
799  //@}
800 
801  eos_sn_sht() :
802  T(other[0]),
803  Yp(other[1]),
804  nB(other[2]),
805  mue(other[3]),
806  M_star(other[4]) {
807  check_grid=true;
808  m_neut=939.0;
809  m_prot=939.0;
810  }
811 
812  /// If true, check the grid after load() (default true)
814 
815  /// Load table from filename \c fname with mode \c mode
816  virtual void load(std::string fname, size_t mode);
817 
818  };
819 
820  /** \brief The Hempel et al. supernova EOSs
821 
822  This class is experimental.
823 
824  \note \o2 Does not contain the EOS, only provides some code to
825  manipulate it. This class was designed to be used with the files
826  <tt>dd2_frdm_eos_shen98format_v1.02.tab</tt>,
827  <tt>fsg_roca_eos_shen98format_v1.0.tab</tt>, and
828  <tt>nl3_lala_eos_shen98format_v1.0.tab</tt> as obtained from
829  http://phys-merger.physik.unibas.ch/~hempel/eos.html.
830 
831  The free energy is stored with respect to the proton mass
832  of 938 MeV, so \ref eos_sn_base::Fint is shifted by
833  \f[
834  938~\mathrm{MeV}-Y_e m_p-(1-Y_e) m_n
835  \f]
836  and the internal energy is stored with respect to an
837  atomic mass unit so \ref eos_sn_base::Eint is shifted
838  by
839  \f[
840  931~\mathrm{MeV}-Y_e m_p-(1-Y_e) m_n
841  \f]
842  the rest of the file data is copied over directly from
843  the file.
844 
845  See also the documentation at \ref eos_sn_base and the
846  \ref sneos_section section of the User's guide.
847 
848  See \ref Hempel10 and \ref Hempel12.
849  */
850  class eos_sn_hfsl : public eos_sn_base {
851 
852  public:
853 
854  /// The atomic mass unit
855  double m_amu;
856 
857  /// \name Additional data included in this EOS
858  //@{
859  /** \brief Logarithm of baryon number density in
860  \f$ \mathrm{g}/\mathrm{cm}^3 \f$
861  */
863  /// Baryon number density in \f$ 1/\mathrm{fm}^3 \f$
865  /// Logarithm of proton fraction
867  /// Proton fraction
869  /// Nucleon effective mass in MeV
871  /// Mass number of light fragments
873  /// Proton number of light fragments
875  //@}
876 
877  /// If true, check the grid after load() (default true)
879 
880  eos_sn_hfsl() :
881  log_rho(other[0]),
882  nB(other[1]),
883  log_Y(other[2]),
884  Yp(other[3]),
885  M_star(other[4]),
886  A_light(other[5]),
887  Z_light(other[6]) {
888  check_grid=true;
889  m_neut=939.565346;
890  m_prot=938.272013;
891  m_amu=931.49432;
892  }
893 
894  /// Load table from filename \c fname
895  virtual void load(std::string fname);
896 
897  };
898 
899 #ifndef DOXYGEN_NO_O2NS
900 }
901 #endif
902 
903 #endif
tensor_grid3 & munu
mue - mun + mup
Definition: eos_sn.h:622
tensor_grid3 & XHe3
Helion fraction.
Definition: eos_sn.h:624
tensor_grid3 & fill
Filling factor for nuclei.
Definition: eos_sn.h:507
tensor_grid3 & cs2
Speed of sound in cm^2/s^2.
Definition: eos_sn.h:608
data_t data
Data object in the form of a matrix.
Definition: eos_sn.h:364
virtual void beta_eq_sfixed(double nB, double entr, double &Ye, double &T)
Compute properties of matter in beta equilibrium at fixed entropy per baryon.
tensor_grid3 & nB
Baryon number density in .
Definition: eos_sn.h:697
size_t n_oth
Number of additional data sets.
Definition: eos_sn.h:107
tensor_grid3 & dpderho
dpderho in dyn*g/cm^2/erg
Definition: eos_sn.h:612
void alloc()
Allocate memory.
tensor_grid3 & Yp
Proton fraction.
Definition: eos_sn.h:792
tensor_grid3 & T
Temperature in MeV.
Definition: eos_sn.h:790
bool baryons_only_loaded
True if baryon-only thermodynamics has been loaded.
Definition: eos_sn.h:445
std::vector< std::string > oth_units
Units for the extra data sets included in current EOS.
Definition: eos_sn.h:347
interp2_direct< ubvector, data_t, matrix_row_gen< data_t >, matrix_column_gen< data_t > > it
The interpolation object.
Definition: eos_sn.h:374
virtual void compute_eg_point(double nB, double Ye, double T, thermo &th)
Compute lepton contribution at one point.
tensor_grid3 Z
Proton number.
Definition: eos_sn.h:181
A slice of data from eos_sn_base for one index fixed.
Definition: eos_sn.h:356
tensor_grid3 mup
Proton chemical potential in MeV.
Definition: eos_sn.h:179
void set_nB_Ye(tensor_grid3<> &tg3, size_t iT)
Set the slice to correspond to a matrix in the form .
Definition: eos_sn.h:398
double m_neut
Neutron mass in (defaults to o2scl_mks::mass_neutron times o2scl_const::hc_mev_fm) ...
Definition: eos_sn.h:218
tensor_grid3 Eint
Internal energy per baryon without lepton and photon contributions in MeV.
Definition: eos_sn.h:157
std::vector< std::string > oth_names
Labels for the extra data sets included in current EOS.
Definition: eos_sn.h:344
bool loaded
If true, a EOS table was successfully loaded (default false)
Definition: eos_sn.h:441
tensor_grid3 Pint
Pressure without lepton and photon contributions in .
Definition: eos_sn.h:163
tensor_grid3 Fint
Free energy per baryon without lepton and photon contributions in MeV.
Definition: eos_sn.h:135
tensor_grid3 & XLi4
Lithium-4 fraction.
Definition: eos_sn.h:626
std::vector< double > nB_grid
Baryon density grid (in )
Definition: eos_sn.h:101
tensor_grid3 & Xd
Deuteron fraction.
Definition: eos_sn.h:630
tensor_grid3 Xalpha
Alpha particle baryon fraction.
Definition: eos_sn.h:189
A base class for the supernova EOSs [abstract].
Definition: eos_sn.h:81
virtual double check_eg()
Check electrons and photons.
fermion electron
Electron.
Definition: eos_sn.h:231
bool include_muons
If true, include muons.
Definition: eos_sn.h:235
tensor_grid3 & A_light
Mass number of light fragments.
Definition: eos_sn.h:872
The H. Shen et al. supernova EOS.
Definition: eos_sn.h:686
tensor_grid3 & x_out
Proton fraction outside nuclei.
Definition: eos_sn.h:525
tensor_grid3 & mue
Electron chemical potential in MeV.
Definition: eos_sn.h:796
tensor_grid3 & Yp
Proton fraction.
Definition: eos_sn.h:701
tensor_grid3 P
Total pressure in .
Definition: eos_sn.h:159
tensor_grid3 E
Total internal energy per baryon in MeV (without baryon rest masses but including electron rest mass)...
Definition: eos_sn.h:146
convert_units & cu
Unit conversion object (set automatically in constructor)
Definition: eos_sn.h:439
tensor_grid3 Sint
Entry per baryon without lepton and photon contributions.
Definition: eos_sn.h:167
The Lattimer-Swesty supernova EOS.
Definition: eos_sn.h:500
virtual void beta_eq_Tfixed(double nB, double T, double &Ye)
Compute the electron fraction for beta-equilibrium at fixed density and temperature temperature...
tensor_grid3 & Nskin
Number of neutrons in skin.
Definition: eos_sn.h:521
std::vector< double > T_grid
Temperature grid (in )
Definition: eos_sn.h:105
tensor_grid3 & muhat
mun - mup
Definition: eos_sn.h:620
tensor_grid3 & Yp
Proton fraction.
Definition: eos_sn.h:868
tensor_grid3 Xp
Proton baryon fraction.
Definition: eos_sn.h:187
tensor_grid3 & dsdT
Derivative of entropy with respect to temperature.
Definition: eos_sn.h:517
tensor_grid3 S
Total entropy per baryon.
Definition: eos_sn.h:165
tensor_grid3 & mu
Out of whackness parameter, , in MeV.
Definition: eos_sn.h:529
std::function< double &(size_t, size_t)> data_t
Typedef for the matrix type.
Definition: eos_sn.h:361
tensor_grid3 Xnuclei
Heavy nuclei baryon fraction.
Definition: eos_sn.h:191
static const size_t n_base
Number of base data sets.
Definition: eos_sn.h:109
A class to manipulate the G. Shen et al. EOS.
Definition: eos_sn.h:767
tensor_grid3 & gamma
Gamma.
Definition: eos_sn.h:616
double m_prot
Proton mass in (defaults to o2scl_mks::mass_proton times o2scl_const::hc_mev_fm) ...
Definition: eos_sn.h:223
boson photon
Photon.
Definition: eos_sn.h:229
tensor_grid3 & log_Y
Logarithm of proton fraction.
Definition: eos_sn.h:699
void free()
Free allocated memory.
tensor_grid3 & nb_in
Baryon number density inside nuclei in .
Definition: eos_sn.h:509
fermion muon
Muon.
Definition: eos_sn.h:233
tensor_grid3 & nB
Baryon number density in .
Definition: eos_sn.h:864
bool is_loaded()
Return true if data has been loaded.
Definition: eos_sn.h:306
tensor_grid3 other[30]
Other data sets.
Definition: eos_sn.h:193
void set_interp_type(size_t interp_type)
Set the interpolation type of all the o2scl::tensor_grid3 objects to type interp_type ...
double m_amu
The atomic mass unit.
Definition: eos_sn.h:855
tensor_grid3 & dpdrhoe
dpdrhoe in dyn cm^3/cm^2/g
Definition: eos_sn.h:614
size_t n_T
Size of temperature grid.
Definition: eos_sn.h:99
The EOS tables from O&#39;Connor and Ott.
Definition: eos_sn.h:586
tensor_grid3 & log_Y
Logarithm of proton fraction.
Definition: eos_sn.h:866
size_t n_Ye
Size of electron fraction grid.
Definition: eos_sn.h:97
size_t n_nB
Size of baryon density grid.
Definition: eos_sn.h:95
bool check_grid
If true, check the grid after load() (default true)
Definition: eos_sn.h:878
bool with_leptons_loaded
True if thermodynamics with leptons has been loaded.
Definition: eos_sn.h:443
tensor_grid3 & nB
Baryon number density in .
Definition: eos_sn.h:794
tensor_grid3 & dsdY
Derivative of entropy with respect to electron fraction.
Definition: eos_sn.h:519
void set_T_Ye(tensor_grid3<> &tg3, size_t inB)
Set the slice to correspond to a matrix in the form .
Definition: eos_sn.h:417
tensor_grid3 & Xt
Triton fraction.
Definition: eos_sn.h:628
The Hempel et al. supernova EOSs.
Definition: eos_sn.h:850
bool data_baryons_only()
Return true if data with only baryon information has been loaded.
Definition: eos_sn.h:319
tensor_grid3 mun
Neutron chemical potential in MeV.
Definition: eos_sn.h:173
tensor_grid3 & M_star
Nucleon effective mass (Dirac) in MeV.
Definition: eos_sn.h:798
tensor_grid3 & log_rho
Logarithm of baryon number density in .
Definition: eos_sn.h:862
void set_nB_T(tensor_grid3<> &tg3, size_t iYe)
Set the slice to correspond to a matrix in the form .
Definition: eos_sn.h:379
std::vector< double > Ye_grid
Electron fraction grid.
Definition: eos_sn.h:103
bool check_grid
If true, check the grid after load() (default true)
Definition: eos_sn.h:724
tensor_grid3 F
Total free energy per baryon in MeV (without baryon rest masses but including electron rest mass) ...
Definition: eos_sn.h:124
double energy_shift
Energy shift for table storage in erg/g.
Definition: eos_sn.h:634
tensor_grid3 & M_star
Nucleon effective mass in MeV.
Definition: eos_sn.h:870
tensor_grid3 * arr[n_base+30]
List of pointers to data.
Definition: eos_sn.h:195
bool data_with_leptons()
Return true if data with lepton information has been loaded.
Definition: eos_sn.h:314
tensor_grid3 A
Mass number.
Definition: eos_sn.h:183
tensor_grid3 & Z_light
Proton number of light fragments.
Definition: eos_sn.h:874
void check_free_energy(double &avg)
Test the free energy and store results in tm.
tensor_grid3 & dPdT
Derivative of pressure with respect to temperature.
Definition: eos_sn.h:513
fermion_rel relf
Relativistic fermion thermodynamics.
Definition: eos_sn.h:237
tensor_grid3 & log_rho
Logarithm of baryon number density in .
Definition: eos_sn.h:695
tensor_grid3 & nb_out
Baryon density outside nuclei in .
Definition: eos_sn.h:523
std::vector< double > rho
The original mass density grid from the table in g/cm^3.
Definition: eos_sn.h:632
void check_composition(double &max1, double &max2)
Check the table composition entries.
tensor_grid3 & M_star
Nucleon effective mass in MeV.
Definition: eos_sn.h:703
int verbose
Verbosity parameter (default 1)
Definition: eos_sn.h:281
bool check_grid
If true, check the grid after load() (default true)
Definition: eos_sn.h:813
tensor_grid3 & mu_e
Electron chemical potential per baryon including rest mass.
Definition: eos_sn.h:618
tensor_grid3 Xn
Neutron baryon fraction.
Definition: eos_sn.h:185
tensor_grid3 & dedt
C_V in erg/g/K.
Definition: eos_sn.h:610
virtual void compute_eg()
Compute the electron and photon contribution for the full grid.
tensor_grid3 & quark_frac
Fraction of quark matter.
Definition: eos_sn.h:705
tensor_grid3 & dPdn
Derivative of pressure with respect to baryon density.
Definition: eos_sn.h:511
tensor_grid3 & dPdY
Derivative of pressure with respect to electron fraction.
Definition: eos_sn.h:515

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