26 #ifndef O2SCL_TABULATED_EOS_H
27 #define O2SCL_TABULATED_EOS_H
30 #include <o2scl/constants.h>
31 #include <o2scl/eos_had_base.h>
32 #include <o2scl/fermion.h>
33 #include <o2scl/eos_had_apr.h>
35 #ifndef DOXYGEN_NO_O2NS
73 std::string srho_nuc, srho_neut, snuc, sneut;
93 virtual ~eos_had_tabulated() {
105 O2SCL_ERR(
"No EOS specified in eos_had_tabulated::calc_e().",
108 double barn=ne.n+pr.n;
110 double delta=(1.0-2.0*xp);
116 double edsym=(tneut->
interp(srho_neut,barn,sneut)-
117 tnuc->
interp(srho_nuc,barn,snuc))/
120 th.
ed=ednuc+delta*delta*edsym;
123 double dednucdn=tnuc->
deriv(srho_nuc,barn,snuc)/
125 double dedsymdn=barn*(tneut->
deriv(srho_neut,barn,sneut)-
126 tnuc->
deriv(srho_nuc,barn,snuc))/
130 ne.mu=(dednucdn+delta*delta*dedsymdn)+4.0*delta*edsym*xp/barn;
131 pr.mu=(dednucdn+delta*delta*dedsymdn)+4.0*delta*edsym*(xp-1.0)/barn;
134 th.
pr=-th.
ed+ne.n*ne.mu+pr.n*pr.mu;
142 template <
class vec_t>
143 int set_eos(
size_t n, vec_t &rho, vec_t &Enuc, vec_t &Eneut) {
153 for(
size_t i=0;i<n;i++) {
154 double line[3]={rho[i],Enuc[i],Eneut[i]};
167 template<
class vec_t>
168 int set_eos(
size_t n_nuc, vec_t &rho_nuc, vec_t &E_nuc,
169 size_t n_neut, vec_t &rho_neut, vec_t &E_neut) {
181 for(
size_t i=0;i<n_nuc;i++) {
182 double line[2]={rho_nuc[i],E_nuc[i]};
185 for(
size_t i=0;i<n_neut;i++) {
186 double line[2]={rho_neut[i],E_neut[i]};
205 #ifndef DOXYGEN_NO_O2NS
void deriv(std::string x, std::string y, std::string yp)
bool table_alloc
True if the table has been allocated.
void free_table()
Free the table memory.
int set_eos(size_t n, vec_t &rho, vec_t &Enuc, vec_t &Eneut)
Set the EOS through vectors specifying the densities and energies.
Zero-temperature EOS from a table.
int set_eos(size_t n_nuc, vec_t &rho_nuc, vec_t &E_nuc, size_t n_neut, vec_t &rho_neut, vec_t &E_neut)
Set the EOS through vectors specifying the densities and energies.
double interp(std::string sx, double x0, std::string sy)
void line_of_names(std::string newheads)
A hadronic EOS based on a function of the densities [abstract base].
virtual int calc_e(fermion &ne, fermion &pr, thermo &th)
Equation of state as a function of density.
table & get_neut_table()
Return the internal table.
void line_of_data(size_t nv, const vec2_t &v)
bool one_table
If true, then tnuc and tneut point to the same table.
table & get_nuc_table()
Return the internal table.