eos_sn.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 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 Check electrons and photons
256 
257  This checks that the electron and photon thermodynamics
258  generated by \o2 is consistent with the data in
259  \c E, \c Eint, \c F, \c Fint, \c P, \c Pint, \c S,
260  and \c Sint.
261  */
262  virtual double check_eg();
263  //@}
264 
265  /** \brief Test the free energy and store results in \c tm
266 
267  This checks that the data in \c Fint is consistent with that
268  in \c Eint and \c Sint (if \ref baryons_only_loaded is true)
269  and that \c F is consistent with that in \c E and \c S (if
270  \ref with_leptons_loaded is true).
271  */
272  void check_free_energy(double &avg);
273 
274  /** \brief Verbosity parameter (default 1)
275  */
276  int verbose;
277 
278  /** \brief Compute properties of matter in beta equilibrium
279  at fixed entropy per baryon
280 
281  This function just does a simple hard-coded linear
282  interpolation.
283  */
284  virtual void beta_eq_sfixed
285  (double nB, double entr, double &Ye, double &T);
286 
287  /** \brief Compute the electron fraction for beta-equilibrium
288  at fixed density and temperature temperature
289 
290  This function just uses linear interpolation to
291  interpolate in baryon density and temperature and
292  the uses a quadratic to determine the minimum of the
293  free energy.
294 
295  If \ref data_with_leptons() is <tt>false</tt>, then
296  \ref compute_eg() is used to compute the leptons.
297  */
298  virtual void beta_eq_Tfixed(double nB, double T, double &Ye);
299 
300  /// Return true if data has been loaded
301  bool is_loaded() {
302  return loaded;
303  }
304 
305  /// Free allocated memory
306  void free();
307 
308  /// Return true if data with lepton information has been loaded
310  return with_leptons_loaded;
311  }
312 
313  /// Return true if data with only baryon information has been loaded
315  return baryons_only_loaded;
316  }
317 
318  /* \brief Load EOS from file named \c file_name
319 
320  \comment
321  The native EOS type overriddes this generic function,
322  but this function is for loading other EOSs in the
323  base class format
324  \endcomment
325  */
326  virtual void load(std::string fname);
327 
328  /* \brief Output EOS to file named \c file_name
329 
330  \comment
331  The native EOS type overriddes this generic function,
332  but this function is for writing other EOSs in the
333  base class format
334  \endcomment
335  */
336  virtual void output(std::string fname);
337 
338  /// Labels for the extra data sets included in current EOS
339  std::vector<std::string> oth_names;
340 
341  /// Units for the extra data sets included in current EOS
342  std::vector<std::string> oth_units;
343 
344  /** \brief A slice of data from \ref eos_sn_base for one index fixed
345 
346  This class allows one to easily construct a \ref
347  o2scl::interp2_direct object automatically by fixing one index
348  from one of the \ref o2scl::tensor_grid3 objects in a child of
349  \ref o2scl::eos_sn_base .
350  */
351  class slice {
352 
353  public:
354 
355  /// Typedef for the matrix type
356  typedef std::function<double &(size_t,size_t)> data_t;
357 
358  /// Data object in the form of a matrix
359  data_t data;
360 
361  /// \name Grid vectors
362  //@{
363  ubvector grid_x, grid_y;
364  //@}
365 
366  /** \brief The interpolation object
367  */
370 
371  /** \brief Set the slice to correspond to a matrix
372  in the form \f$ (n_B,T) \f$
373  */
374  void set_nB_T(tensor_grid3<> &tg3, size_t iYe) {
375  data=std::bind(std::mem_fn<double &(size_t,size_t,size_t)>
376  (&tensor_grid3<>::get),tg3,std::placeholders::_1,iYe,
377  std::placeholders::_2);
378  size_t nx=tg3.get_size(0);
379  grid_x.resize(nx);
380  for(size_t i=0;i<nx;i++) grid_x[i]=tg3.get_grid(0,i);
381  size_t ny=tg3.get_size(2);
382  grid_y.resize(ny);
383  for(size_t i=0;i<ny;i++) grid_y[i]=tg3.get_grid(2,i);
384  it.set_data(nx,ny,grid_x,grid_y,data);
385  return;
386  }
387 
388  /** \brief Set the slice to correspond to a matrix
389  in the form \f$ (n_B,Y_e) \f$
390  */
391  void set_nB_Ye(tensor_grid3<> &tg3, size_t iT) {
392  data=std::bind(std::mem_fn<double &(size_t,size_t,size_t)>
393  (&tensor_grid3<>::get),tg3,std::placeholders::_1,
394  std::placeholders::_2,iT);
395  size_t nx=tg3.get_size(0);
396  grid_x.resize(nx);
397  for(size_t i=0;i<nx;i++) grid_x[i]=tg3.get_grid(0,i);
398  size_t ny=tg3.get_size(1);
399  grid_y.resize(ny);
400  for(size_t i=0;i<ny;i++) grid_y[i]=tg3.get_grid(1,i);
401  it.set_data(nx,ny,grid_x,grid_y,data);
402  return;
403  }
404 
405  /** \brief Set the slice to correspond to a matrix
406  in the form \f$ (T,Y_e) \f$
407  */
408  void set_T_Ye(tensor_grid3<> &tg3, size_t inB) {
409  data=std::bind(std::mem_fn<double &(size_t,size_t,size_t)>
410  (&tensor_grid3<>::get),tg3,inB,std::placeholders::_2,
411  std::placeholders::_1);
412  size_t nx=tg3.get_size(2);
413  grid_x.resize(nx);
414  for(size_t i=0;i<nx;i++) grid_x[i]=tg3.get_grid(2,i);
415  size_t ny=tg3.get_size(1);
416  grid_y.resize(ny);
417  for(size_t i=0;i<ny;i++) grid_y[i]=tg3.get_grid(1,i);
418  it.set_data(nx,ny,grid_x,grid_y,data);
419  return;
420  }
421 
422  };
423 
424  protected:
425 
426  /** \brief Unit conversion object (set automatically in constructor)
427  */
429  /// If true, a EOS table was successfully loaded (default false)
430  bool loaded;
431  /// True if thermodynamics with leptons has been loaded
433  /// True if baryon-only thermodynamics has been loaded
435 
436  /// \name Memory allocation
437  //@{
438  /// Allocate memory
439  void alloc();
440  //@}
441 
442 
443  };
444 
445  /** \brief The Lattimer-Swesty supernova EOS
446 
447  This class is experimental.
448 
449  \note \o2 Does not contain the Lattimer-Swesty EOS, only
450  provides some code to manipulate it. This class is designed
451  to be used with the files <tt>ls.dat, sk1.dat, ska.dat</tt>
452  and <tt>skm.dat</tt> as provided on Jim Lattimer's website,
453  http://www.astro.sunysb.edu/lattimer/EOS/main.html .
454 
455  Note that the tables on this website are different
456  than what is generated from the LS Fortran code. See
457  \ref eos_sn_oo to read O'Connor and Ott's tables
458  generated from the LS Fortran code.
459 
460  The four models are
461  - LS (K=370, Sv=31)
462  - SKI' (K=371, Sv=30.4)
463  - SKa (K=263, Sv=34.5)
464  - SKM* (K=217, Sv=31.4)
465 
466  \note In the original table, the full internal energy per baryon
467  (data section 4 of 26) is apparently based on a rest mass of
468  \f$ Y_e m_p + (1-Y_e) m_n \f$, while the baryon part of the
469  internal energy per baryon (data section 13 of 26) is based
470  on a rest mass of \f$ m_n \f$. This means that
471  \f[
472  E - E_{\mathrm{int}} = E_{\mathrm{eg}} - Y_e (m_n - m_p)
473  \f]
474  where \f$ E_{\mathrm{eg}} \f$ is the energy per baryon of
475  electrons and photons. In order to keep things consistent with
476  the other EOS tables, when the EOS table is loaded, \ref
477  eos_sn_base::Eint is rescaled to a rest mass of \f$ Y_e m_p +
478  (1-Y_e) m_n \f$ .
479 
480  See also the documentation at \ref eos_sn_base and the
481  \ref sneos_section section of the User's guide.
482 
483  See \ref Lattimer91 and \ref Lattimer85.
484 
485  \todo There are still a few points for which the electron/photon
486  EOS seems to be off, but this may be the result of small
487  inaccuracies from finite-differencing the LS table.
488  */
489  class eos_sn_ls : public eos_sn_base {
490 
491  public:
492 
493  /// \name Additional data included in this EOS
494  //@{
495  /// Filling factor for nuclei
497  /// Baryon number density inside nuclei in \f$ \mathrm{fm}^{-3} \f$
499  /// Derivative of pressure with respect to baryon density
501  /// Derivative of pressure with respect to temperature
503  /// Derivative of pressure with respect to electron fraction
505  /// Derivative of entropy with respect to temperature
507  /// Derivative of entropy with respect to electron fraction
509  /// Number of neutrons in skin
511  /// Baryon density outside nuclei in \f$ \mathrm{fm}^{-3} \f$
513  /// Proton fraction outside nuclei
515  /** \brief Out of whackness parameter,
516  \f$ \mu_n-\mu_p-\mu_e+1.293~\mathrm{MeV} \f$, in MeV
517  */
519  //@}
520 
521  eos_sn_ls() :
522  fill(other[0]),
523  nb_in(other[1]),
524  dPdn(other[2]),
525  dPdT(other[3]),
526  dPdY(other[4]),
527  dsdT(other[5]),
528  dsdY(other[6]),
529  Nskin(other[7]),
530  nb_out(other[8]),
531  x_out(other[9]),
532  mu(other[10]) {
533  }
534 
535  /// Load table from filename \c fname
536  virtual void load(std::string fname);
537 
538  /** \brief Check electrons and photons
539 
540  This checks that the electron and photon thermodynamics
541  generated by \o2 is consistent with the data in
542  \c E, \c Eint, \c F, \c Fint, \c P, \c Pint, \c S,
543  and \c Sint.
544  */
545  virtual double check_eg();
546  };
547 
548  /** \brief The EOS tables from O'Connor and Ott
549 
550  This class reads the HDF5 EOS tables generated by E. O'Connor
551  and C. Ott in \ref OConnor10. The tables are available from
552 
553  http://stellarcollapse.org/equationofstate
554 
555  and are available under a creative commons
556  attribution-noncommercial-share alike license. This \o2 code to
557  read those tables is licensed (along with all \o2 code) under
558  the GPLv3 license (with permission from Evan O'Connor).
559 
560  The original README file from O'Connor and Ott's EOSdriver
561  code is available in the \o2
562  distribution in <tt>doc/o2scl/eos/extras/scollapse_README</tt>
563  and is reproduced below
564 
565  \verbinclude scollapse_README
566 
567  See also the documentation at \ref eos_sn_base and the
568  \ref sneos_section section of the User's guide.
569 
570  \future Loading an EOS currently requires loading the HDF5 file
571  and then copying it. This wouldn't be necessary if the \o2
572  tensor had the same ordering as the indices in the original
573  HDF5 file.
574  */
575  class eos_sn_oo : public eos_sn_base {
576 
577  public:
578 
579  eos_sn_oo() :
580  cs2(other[0]),
581  dedt(other[1]),
582  dpderho(other[2]),
583  dpdrhoe(other[3]),
584  gamma(other[4]),
585  mu_e(other[5]),
586  muhat(other[6]),
587  munu(other[7]),
588  XHe3(other[8]),
589  XLi4(other[9]),
590  Xt(other[10]),
591  Xd(other[11]) {
592  }
593 
594  /// \name Additional data included in this EOS
595  //@{
596  /// Speed of sound in cm^2/s^2
598  /// C_V in erg/g/K
600  /// dpderho in dyn*g/cm^2/erg
602  /// dpdrhoe in dyn cm^3/cm^2/g
604  /// Gamma
606  /// Electron chemical potential per baryon including rest mass
608  /// mun - mup
610  /// mue - mun + mup
612  /// Helion fraction
614  /// Lithium-4 fraction
616  /// Triton fraction
618  /// Deuteron fraction
620  /// The original mass density grid from the table in g/cm^3
621  std::vector<double> rho;
622  /// Energy shift for table storage in erg/g
623  double energy_shift;
624  //@}
625 
626  /// \name Table modes
627  //@{
628  /// Use the J. Lattimer et al. method for handling the chemical potentials
629  static const size_t ls_mode=0;
630  /// Use the H. Shen et al. method for handling the chemical potentials
631  static const size_t stos_mode=1;
632  /// Set for a Hempel et al. table with light nuclei
633  static const size_t hfsl_mode=2;
634  /// Set for a G. Shen et al. table
635  static const size_t sht_mode=3;
636  //@}
637 
638  /// Load table from filename \c fname with mode \c mode
639  virtual void load(std::string fname, size_t mode);
640 
641  };
642 
643  /** \brief The H. Shen et al. supernova EOS
644 
645  This class is experimental.
646 
647  \note \o2 Does not contain the EOS, only provides some code to
648  manipulate it. This class is designed to be used with the file
649  which was originally called <tt>eos.tab</tt> and now referred to
650  as <tt>eos1.tab</tt> and stored e.g. at
651  http://user.numazu-ct.ac.jp/~sumi/eos/.
652 
653  In order to force the EOS to a uniform grid, linear
654  interpolation is used to recast the variation in baryon density,
655  choosing the grid in baryon density to be the same as the
656  section in the table with T=0.1 MeV and \f$ Y_p = 0.1 \f$ for
657  all temperature and proton fraction points.
658 
659  The data for \ref eos_sn_base::E, \ref eos_sn_base::F, \ref
660  eos_sn_base::S, and \ref eos_sn_base::P is not stored in the table
661  but can be computed with \ref eos_sn_base::compute_eg().
662 
663  See also the documentation at \ref eos_sn_base and the
664  \ref sneos_section section of the User's guide.
665 
666  See \ref Shen98 and \ref Shen98b .
667 
668  \note Thanks to Matthias Hempel for providing the correct
669  temperature grid.
670 
671  \todo Add the T=0 and Ye=0 data to this class. Separate
672  tables for these cases have been released, but I don't think
673  this class can read them yet.
674  */
675  class eos_sn_stos : public eos_sn_base {
676 
677  public:
678 
679  /// \name Additional data included in this EOS
680  //@{
681  /** \brief Logarithm of baryon number density in
682  \f$ \mathrm{g}/\mathrm{cm}^3 \f$
683  */
685  /// Baryon number density in \f$ \mathrm{fm}^{-3} \f$
687  /// Logarithm of proton fraction
689  /// Proton fraction
691  /// Nucleon effective mass in MeV
693  /// Fraction of quark matter
695  //@}
696 
697  eos_sn_stos() :
698  log_rho(other[0]),
699  nB(other[1]),
700  log_Y(other[2]),
701  Yp(other[3]),
702  M_star(other[4]),
703  quark_frac(other[5]) {
704  check_grid=true;
705  m_neut=938.0;
706  m_prot=938.0;
707  }
708 
709  static const size_t orig_mode=0;
710  static const size_t quark_mode=1;
711 
712  /// If true, check the grid after load() (default true)
714 
715  /// Load table from filename \c fname with mode \c mode
716  virtual void load(std::string fname, size_t mode);
717 
718  };
719 
720  /** \brief A class to manipulate the G. Shen et al. EOS
721 
722  This class is experimental.
723 
724  \note \o2 Does not contain the EOS, only provides some code to
725  manipulate it. This class was designed to be used with the FSU
726  models given at
727  http://cecelia.physics.indiana.edu/gang_shen_eos/FSU/fsu.html .
728  The full list of files and the associated modes for the
729  \ref load() function are:
730  - <tt>"FSU1.7eos1.01.dat"</tt> (\ref mode_17)
731  - <tt>"FSU2.1eos1.01.dat"</tt> (\ref mode_21)
732  - <tt>"FSU1.7eosb1.01.dat"</tt> (\ref mode_17b)
733  - <tt>"FSU2.1eosb1.01.dat"</tt> (\ref mode_21b)
734  - <tt>"NL3eos1.03.dat"</tt> (\ref mode_NL3)
735  - <tt>"NL3eosb1.03.dat"</tt> (\ref mode_NL3b)
736 
737  See also the documentation at \ref eos_sn_base and the
738  \ref sneos_section section of the User's guide.
739 
740  The free energy per baryon neutron and proton chemical
741  potentials are relative to a nucleon mass of 939 MeV. The values
742  of \ref o2scl::eos_sn_base::m_neut and \ref
743  o2scl::eos_sn_base::m_prot are set to 939 MeV accordingly. The
744  electron chemical potential still includes its rest mass. All
745  quantites are stored as in the original table, except that
746  the values in \ref o2scl::eos_sn_base::E or \ref
747  o2scl::eos_sn_base::Eint are computed directly from the
748  thermodynamic identity.
749 
750  See \ref Shen11.
751 
752  \warning The NL3 model is probably ruled out by nuclear mass
753  data, neutron matter calculations, and neutron star mass and
754  radius observations.
755  */
756  class eos_sn_sht : public eos_sn_base {
757 
758  public:
759 
760  /// \name Table modes
761  //@{
762  /// 1.7 solar masses with leptons and photons
763  static const size_t mode_17=0;
764  /// 2.1 solar masses with leptons and photons
765  static const size_t mode_21=1;
766  /// 1.7 solar masses without leptons and photons
767  static const size_t mode_17b=2;
768  /// 2.1 solar masses without leptons and photons
769  static const size_t mode_21b=3;
770  /// NL3 model with leptons and photons
771  static const size_t mode_NL3=4;
772  /// NL3 model with leptons and photons
773  static const size_t mode_NL3b=5;
774  //@}
775 
776  /// \name Additional data included in this EOS
777  //@{
778  /// Temperature in MeV
780  /// Proton fraction
782  /// Baryon number density in \f$ 1/\mathrm{fm}^3 \f$
784  /// Electron chemical potential in MeV
786  /// Nucleon effective mass (Dirac) in MeV
788  //@}
789 
790  eos_sn_sht() :
791  T(other[0]),
792  Yp(other[1]),
793  nB(other[2]),
794  mue(other[3]),
795  M_star(other[4]) {
796  check_grid=true;
797  m_neut=939.0;
798  m_prot=939.0;
799  }
800 
801  /// If true, check the grid after load() (default true)
803 
804  /// Load table from filename \c fname with mode \c mode
805  virtual void load(std::string fname, size_t mode);
806 
807  };
808 
809  /** \brief The Hempel et al. supernova EOSs
810 
811  This class is experimental.
812 
813  \note \o2 Does not contain the EOS, only provides some code to
814  manipulate it. This class was designed to be used with the files
815  <tt>dd2_frdm_eos_shen98format_v1.02.tab</tt>,
816  <tt>fsg_roca_eos_shen98format_v1.0.tab</tt>, and
817  <tt>nl3_lala_eos_shen98format_v1.0.tab</tt> as obtained from
818  http://phys-merger.physik.unibas.ch/~hempel/eos.html.
819 
820  The free energy is stored with respect to the proton mass
821  of 938 MeV, so \ref eos_sn_base::Fint is shifted by
822  \f[
823  938~\mathrm{MeV}-Y_e m_p-(1-Y_e) m_n
824  \f]
825  and the internal energy is stored with respect to an
826  atomic mass unit so \ref eos_sn_base::Eint is shifted
827  by
828  \f[
829  931~\mathrm{MeV}-Y_e m_p-(1-Y_e) m_n
830  \f]
831  the rest of the file data is copied over directly from
832  the file.
833 
834  See also the documentation at \ref eos_sn_base and the
835  \ref sneos_section section of the User's guide.
836 
837  See \ref Hempel10 and \ref Hempel12.
838  */
839  class eos_sn_hfsl : public eos_sn_base {
840 
841  public:
842 
843  /// The atomic mass unit
844  double m_amu;
845 
846  /// \name Additional data included in this EOS
847  //@{
848  /** \brief Logarithm of baryon number density in
849  \f$ \mathrm{g}/\mathrm{cm}^3 \f$
850  */
852  /// Baryon number density in \f$ 1/\mathrm{fm}^3 \f$
854  /// Logarithm of proton fraction
856  /// Proton fraction
858  /// Nucleon effective mass in MeV
860  /// Mass number of light fragments
862  /// Proton number of light fragments
864  //@}
865 
866  /// If true, check the grid after load() (default true)
868 
869  eos_sn_hfsl() :
870  log_rho(other[0]),
871  nB(other[1]),
872  log_Y(other[2]),
873  Yp(other[3]),
874  M_star(other[4]),
875  A_light(other[5]),
876  Z_light(other[6]) {
877  check_grid=true;
878  m_neut=939.565346;
879  m_prot=938.272013;
880  m_amu=931.49432;
881  }
882 
883  /// Load table from filename \c fname
884  virtual void load(std::string fname);
885 
886  };
887 
888 #ifndef DOXYGEN_NO_O2NS
889 }
890 #endif
891 
892 #endif
tensor_grid3 & munu
mue - mun + mup
Definition: eos_sn.h:611
tensor_grid3 & XHe3
Helion fraction.
Definition: eos_sn.h:613
tensor_grid3 & fill
Filling factor for nuclei.
Definition: eos_sn.h:496
tensor_grid3 & cs2
Speed of sound in cm^2/s^2.
Definition: eos_sn.h:597
data_t data
Data object in the form of a matrix.
Definition: eos_sn.h:359
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:686
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:601
void alloc()
Allocate memory.
tensor_grid3 & Yp
Proton fraction.
Definition: eos_sn.h:781
tensor_grid3 & T
Temperature in MeV.
Definition: eos_sn.h:779
bool baryons_only_loaded
True if baryon-only thermodynamics has been loaded.
Definition: eos_sn.h:434
std::vector< std::string > oth_units
Units for the extra data sets included in current EOS.
Definition: eos_sn.h:342
interp2_direct< ubvector, data_t, matrix_row_gen< data_t >, matrix_column_gen< data_t > > it
The interpolation object.
Definition: eos_sn.h:369
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:351
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:391
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:339
bool loaded
If true, a EOS table was successfully loaded (default false)
Definition: eos_sn.h:430
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:615
std::vector< double > nB_grid
Baryon density grid (in )
Definition: eos_sn.h:101
tensor_grid3 & Xd
Deuteron fraction.
Definition: eos_sn.h:619
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
size_t get_size(size_t i) const
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:861
The H. Shen et al. supernova EOS.
Definition: eos_sn.h:675
tensor_grid3 & x_out
Proton fraction outside nuclei.
Definition: eos_sn.h:514
tensor_grid3 & mue
Electron chemical potential in MeV.
Definition: eos_sn.h:785
tensor_grid3 & Yp
Proton fraction.
Definition: eos_sn.h:690
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:428
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:489
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:510
std::vector< double > T_grid
Temperature grid (in )
Definition: eos_sn.h:105
tensor_grid3 & muhat
mun - mup
Definition: eos_sn.h:609
tensor_grid3 & Yp
Proton fraction.
Definition: eos_sn.h:857
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:506
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:518
std::function< double &(size_t, size_t)> data_t
Typedef for the matrix type.
Definition: eos_sn.h:356
tensor_grid3 Xnuclei
Heavy nuclei baryon fraction.
Definition: eos_sn.h:191
double get_grid(size_t i, size_t j) const
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:756
tensor_grid3 & gamma
Gamma.
Definition: eos_sn.h:605
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:688
void free()
Free allocated memory.
tensor_grid3 & nb_in
Baryon number density inside nuclei in .
Definition: eos_sn.h:498
fermion muon
Muon.
Definition: eos_sn.h:233
tensor_grid3 & nB
Baryon number density in .
Definition: eos_sn.h:853
bool is_loaded()
Return true if data has been loaded.
Definition: eos_sn.h:301
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:844
tensor_grid3 & dpdrhoe
dpdrhoe in dyn cm^3/cm^2/g
Definition: eos_sn.h:603
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:575
tensor_grid3 & log_Y
Logarithm of proton fraction.
Definition: eos_sn.h:855
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:867
bool with_leptons_loaded
True if thermodynamics with leptons has been loaded.
Definition: eos_sn.h:432
tensor_grid3 & nB
Baryon number density in .
Definition: eos_sn.h:783
tensor_grid3 & dsdY
Derivative of entropy with respect to electron fraction.
Definition: eos_sn.h:508
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:408
tensor_grid3 & Xt
Triton fraction.
Definition: eos_sn.h:617
The Hempel et al. supernova EOSs.
Definition: eos_sn.h:839
bool data_baryons_only()
Return true if data with only baryon information has been loaded.
Definition: eos_sn.h:314
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:787
tensor_grid3 & log_rho
Logarithm of baryon number density in .
Definition: eos_sn.h:851
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:374
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:713
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:623
tensor_grid3 & M_star
Nucleon effective mass in MeV.
Definition: eos_sn.h:859
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:309
tensor_grid3 A
Mass number.
Definition: eos_sn.h:183
tensor_grid3 & Z_light
Proton number of light fragments.
Definition: eos_sn.h:863
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:502
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:684
tensor_grid3 & nb_out
Baryon density outside nuclei in .
Definition: eos_sn.h:512
std::vector< double > rho
The original mass density grid from the table in g/cm^3.
Definition: eos_sn.h:621
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:692
int verbose
Verbosity parameter (default 1)
Definition: eos_sn.h:276
bool check_grid
If true, check the grid after load() (default true)
Definition: eos_sn.h:802
tensor_grid3 & mu_e
Electron chemical potential per baryon including rest mass.
Definition: eos_sn.h:607
tensor_grid3 Xn
Neutron baryon fraction.
Definition: eos_sn.h:185
tensor_grid3 & dedt
C_V in erg/g/K.
Definition: eos_sn.h:599
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:694
tensor_grid3 & dPdn
Derivative of pressure with respect to baryon density.
Definition: eos_sn.h:500
tensor_grid3 & dPdY
Derivative of pressure with respect to electron fraction.
Definition: eos_sn.h:504

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