26 #ifndef O2SCL_TOV_EOS_H
27 #define O2SCL_TOV_EOS_H
33 #include <boost/numeric/ublas/vector.hpp>
35 #include <o2scl/constants.h>
36 #include <o2scl/lib_settings.h>
37 #include <o2scl/interp.h>
38 #include <o2scl/table_units.h>
39 #include <o2scl/vector_derint.h>
41 #ifndef DOXYGEN_NO_O2NS
78 virtual void get_eden(
double P,
double &e,
double &nb)=0;
85 virtual void get_aux(
double P,
size_t &np, std::vector<double> &auxp) {
94 std::vector<std::string> &pnames,
95 std::vector<std::string> &punits) {
103 void check_nb(
double &avg_abs_dev,
double &max_abs_dev) {
105 O2SCL_ERR2(
"Variable 'baryon_column' false in",
108 std::vector<double> edv, prv, nbv, dedn;
109 for (
double pres=0.1;pres<3.0;pres*=1.001) {
116 dedn.resize(edv.size());
120 for(
size_t i=0;i<edv.size();i++) {
121 double abs_dev=(fabs(edv[i]+prv[i]-dedn[i]*nbv[i])/
122 fabs(dedn[i]*nbv[i]));
123 if (abs_dev>max_abs_dev) max_abs_dev=abs_dev;
124 avg_abs_dev+=abs_dev;
126 avg_abs_dev/=((double)edv.size());
210 if (nb<0.0 || ed<0.0) {
211 O2SCL_ERR2(
"Negative densities not supported in ",
212 "eos_tov_polytrope::set_coeff_index().",
exc_einval);
218 O2SCL_ERR2(
"Values of 'Pstar' and 'ed' incommensurate in ",
219 "eos_tov_buchdahl::set_baryon_density().",
exc_einval);
231 virtual void get_eden(
double P,
double &e,
double &nb) {
232 e=12.0*sqrt(
Pstar*P)-5.0*P;
237 double t1=sqrt(P/
Pstar);
239 double mu=mu1*pow((-
pr1+9.0*
Pstar)*(3.0+t1)*(3.0-t2)/
240 (-P+9.0*
Pstar)/(3.0-t1)/(3.0+t2),0.25);
249 virtual void get_aux(
double P,
size_t &np, std::vector<double> &auxp) {
257 virtual void get_names(
size_t &np, std::vector<std::string> &pnames) {
287 std::vector<double> &by) {
338 if (coeff<0.0 || index<0.0) {
339 O2SCL_ERR2(
"Negative coefficients and indices not supported in ",
340 "eos_tov_polytrope::set_coeff_index().",
exc_einval);
352 if (nb<0.0 || ed<0.0) {
353 O2SCL_ERR2(
"Negative densities not supported in ",
354 "eos_tov_polytrope::set_coeff_index().",
exc_einval);
365 virtual void get_eden(
double P,
double &e,
double &nb) {
366 e=pow(P/
K,
n/(1.0+
n));
424 if (nb<0.0 || ed<0.0) {
425 O2SCL_ERR2(
"Negative densities not supported in ",
426 "eos_tov_polytrope::set_coeff_index().",
exc_einval);
437 virtual void get_eden(
double P,
double &e,
double &nb) {
449 virtual void get_aux(
double P,
size_t &np, std::vector<double> &auxp) {
457 virtual void get_names(
size_t &np, std::vector<std::string> &pnames) {
538 static const int smooth_trans=0;
539 static const int match_line=1;
546 std::string s_colp, std::string s_colnb=
"");
551 void read_vectors(
size_t n_core, std::vector<double> &core_ed,
552 std::vector<double> &core_pr,
553 std::vector<double> &core_nb);
558 void read_vectors(
size_t n_core, std::vector<double> &core_ed,
559 std::vector<double> &core_pr);
576 bool external=
false);
583 bool external=
false);
592 bool external=
false);
606 std::string fname=
"");
626 virtual void get_eden(
double pres,
double &ed,
double &nb);
633 virtual void get_aux(
double P,
size_t &nv, std::vector<double> &auxp);
639 std::vector<std::string> &pnames,
640 std::vector<std::string> &punits);
648 virtual void get_eden_user(
double pres,
double &ed,
double &nb);
679 #ifndef DOXYGEN_INTERNAL
683 void internal_read();
748 #ifndef DOXYGEN_NO_O2NS
std::vector< double > full_vecnb
Baryon densities from full EOS.
void set_baryon_density(double nb, double ed)
Set the baryon density.
double pr1
The pressure at ed1.
virtual void get_eden(double P, double &e, double &nb)=0
Given the pressure, produce the energy and number densities.
void ngl13_low_dens_eos2(double S, double L, double nt, std::string fname="")
Crust EOS from Newton13 given S and L in MeV and a transition density.
virtual void get_eden(double P, double &e, double &nb)
Given the pressure, produce the energy and number densities.
void default_low_dens_eos()
Default crust EOS from Negele73 and Baym71.
std::vector< double > crust_vecnb
Baryon densities.
void set_baryon_density(double nb, double ed)
Set the baryon density.
std::vector< double > crust_vecp
Pressures.
void sho11_low_dens_eos()
Crust EOS from Shen11b.
size_t crust_nlines
Number of EOS entries.
void vector_deriv_interp(size_t n, ovec_t &v, vec2_t &dv, size_t interp_type=itp_cspline)
size_t full_nlines
Number of lines in full EOS.
std::vector< double > full_vecp
Pressures from full EOS.
double eps0
Index (default 0.0)
void ngl13_low_dens_eos(double L, std::string model="PNM", bool external=false)
Crust EOS from Newton13 given L in MeV.
virtual void get_names_units(size_t &np, std::vector< std::string > &pnames, std::vector< std::string > &punits)
Fill a list with strings for the names of the remaining quanities.
double ed1
The energy density for which the baryon density is known.
double pr1
The pressure at ed1.
double trans_pres
Transition pressure (in )
virtual void get_names_units(size_t &np, std::vector< std::string > &pnames, std::vector< std::string > &punits)
Fill a list with strings for the names of the remaining quanities.
bool eos_read
True if an EOS has been specified.
double K
Coefficient (default 1.0)
double ed1
The energy density for which the baryon density is known.
virtual void get_eden_user(double pres, double &ed, double &nb)
Get the energy density from the pressure in the user-specified unit system.
virtual void get_names(size_t &np, std::vector< std::string > &pnames)
Fill a list with strings for the names of the remaining quanities.
void read_table(table_units<> &eosat, std::string s_cole, std::string s_colp, std::string s_colnb="")
Specify the EOS through a table.
double pfactor
Unit conversion factor for pressure (default 1.0)
void set_baryon_density(double nb, double ed)
Set the baryon density.
double Pstar
The parameter with units of pressure in units of solar masses per km cubed (default value ) ...
void gcp10_low_dens_eos(std::string model="BSk20", bool external=false)
Crust EOS from Goriely, Chamel, and Pearson.
std::vector< double > crust_vece
Energy densities.
bool core_set
True if core table has been specified.
double nb1
The baryon density at ed1.
virtual void get_aux(double P, size_t &nv, std::vector< double > &auxp)
Given the pressure, produce all the remaining quantities.
double n
Index (default 3.0)
double ed1
The energy density for which the baryon density is known.
An EOS for the TOV solver using simple linear interpolation and an optional crust EOS...
#define O2SCL_ERR2(d, d2, n)
table_units * core_table
Full user EOS table.
A EOS base class for the TOV solver.
virtual void get_eden(double pres, double &ed, double &nb)
Given the pressure, produce the energy and number densities.
size_t core_auxp
Number of additional columns in the core EOS.
virtual void get_eden(double P, double &e, double &nb)
Given the pressure, produce the energy and number densities.
Class to solve the Tolman-Oppenheimer-Volkov equations.
int solve_u_rp_fun(size_t bv, const std::vector< double > &bx, std::vector< double > &by)
Solve to compute profiles.
size_t cole
Column for energy density in EOS file.
void set_coeff_index(double coeff, double index)
Desc.
void no_low_dens_eos()
Compute with no crust EOS.
Standard polytropic EOS .
virtual void get_aux(double P, size_t &np, std::vector< double > &auxp)
Given the pressure, produce all the remaining quantities.
void s12_low_dens_eos(std::string model="SLy4", bool external=false)
Crust EOS from Steiner12.
void set_cs2_eps0(double cs2_, double eps0_)
Desc.
double cs2
Coefficient (default 1.0)
double pr1
The pressure at ed1.
virtual void get_names(size_t &np, std::vector< std::string > &pnames)
Fill a list with strings for the names of the remaining quanities.
void get_transition(double &ptrans, double &pwidth)
Get the transition pressure (in the user-specified unit system) and width.
void check_nb(double &avg_abs_dev, double &max_abs_dev)
Check that the baryon density is consistent with the EOS.
double nb1
The baryon density at ed1.
void read_vectors(size_t n_core, std::vector< double > &core_ed, std::vector< double > &core_pr, std::vector< double > &core_nb)
Read the EOS from a set of equal length vectors for energy density, pressure, and baryon density...
double efactor
Unit conversion factor for energy density (default 1.0)
double nfactor
Unit conversion factor for baryon density (default 1.0)
void set_transition(double ptrans, double pw)
Set the transition pressure and "width".
size_t colnb
Column for baryon density in EOS file.
bool use_crust
Set to true if we are using a crust EOS (default false)
int verbose
Control for output (default 1)
bool baryon_column
Set to true if the baryon density is provided in the EOS (default false)
std::vector< double > full_vece
Energy densities from full EOS.
virtual void get_eden(double P, double &e, double &nb)
Given the pressure, produce the energy and number densities.
virtual void get_aux(double P, size_t &np, std::vector< double > &auxp)
Given the pressure, produce all the remaining quantities.
double nb1
The baryon density at ed1.
double trans_width
Transition width (unitless)
The Buchdahl EOS for the TOV solver.
size_t colp
Column for pressure in EOS file.
virtual void get_aux(double P, size_t &np, std::vector< double > &auxp)
Given the pressure, produce all the remaining quantities.