46 #ifndef TV_ENERGY_TABLE_NX
47 #define TV_ENERGY_TABLE_NX 1024
49 #ifndef TV_ENERGY_TABLE_NY
50 #define TV_ENERGY_TABLE_NY 512
53 static double rhoeFunc(
double,
void *);
56 #if TV_ENERGY_TABLE == YES
74 double T, rho, v[
NVAR];
76 print1 (
"> MakeInternalEnergyTable(): Generating table (%d x %d points)\n",
81 for (j = 0; j < rhoe_tab.
ny; j++){
82 for (i = 0; i < rhoe_tab.
nx; i++){
99 for (j = 0; j < rhoe_tab.
ny; j++){
101 for (i = 0; i < rhoe_tab.
nx; i++){
107 rhoe_tab.
a[j], rhoe_tab.
b[j], rhoe_tab.
c[j],
111 dfdx[0], dfdx[rhoe_tab.
nx-1], rhoe_tab.
nx,
112 rhoe_tab.
a[j], rhoe_tab.
b[j], rhoe_tab.
c[j], rhoe_tab.
d[j]);
120 double G, lnT, rhoe, rhoe_ex;
127 fp = fopen(
"rhoe.dat",
"w");
128 v[
RHO] = rho = rhoe_tab.
y[
j];
129 for (i = 10; i < rhoe_tab.
nx-11; i++){
130 for (ii = 0; ii < 20; ii++){
131 T = rhoe_tab.
x[
i] + ii*rhoe_tab.
dx[
i]/20.0;
135 fprintf (fp,
"%12.6e %12.6e %12.6e %12.6e\n",T,rhoe_ex, rhoe, G);
154 double Epp, Emm, Ep, Em, dEdT;
155 double dT = 1.e-3, v[256];
163 dEdT = (-Epp + 8.0*Ep - 8.0*Em + Emm)/(12.0*T*dT);
170 #if NIONS == 0 && TV_ENERGY_TABLE == NO
201 double rhoe, rho, Tlo, Thi,
T;
204 print1 (
"> MakeEV_TemperatureTable(): Generating table...\n");
210 for (j = 0; j < Trhoe_tab.
ny; j++){
211 for (i = 0; i < Trhoe_tab.
nx; i++){
213 par.
rhoe = rhoe = Trhoe_tab.
x[
i];
214 par.
v[
RHO] = rho = Trhoe_tab.
y[
j];
219 if (status != 0) T = -1.0;
221 Trhoe_tab.
f[
j][
i] =
T;
228 double G, lnT,
v[256];
232 fp = fopen(
"rhoe.dat",
"w");
233 v[
RHO] = rho = 1.245197084735e+00;
234 for (lnT = 2.0; lnT < 4.5; lnT += 1.e-3){
238 fprintf (fp,
"%12.6e %12.6e %12.6e\n",T,rhoe,G);
269 #if TV_ENERGY_TABLE == YES
277 print (
"! InternalEnergy(): table interpolation failure (bound exceeded)\n");
313 #if TV_ENERGY_TABLE == YES
317 if (rhoe < 0.0)
return 1;
323 print (
"! GetEV_Temperature(): table interpolation failure");
324 print (
" [rho = %12.6e, rhoe = %12.6e]\n",rho,rhoe);
333 int nv, status,
i,
j;
334 double Tmin, Tmax,rho, lnx, lny;
337 if (rhoe < 0.0)
return 1;
345 v[nv] =
MAX(v[nv],0.0);
346 v[nv] =
MIN(v[nv],1.0);
348 #if COOLING == H2_COOL
372 Tmin = Trhoe_tab.
f[j+1][
i];
373 Tmax = Trhoe_tab.
f[
j][i+1];
376 InternalEnergyBracket(rhoe, v, &Tmin, &Tmax);
379 if (Tmin < 0.0 || Tmax < 0.0)
return 1;
405 printf (
"! rhoeFunc: T = %12.6e\n",T);
409 func = rhoe - p->
rhoe;
414 void SoundSpeed2 (
double **
v,
double *cs2,
double *h,
int beg,
int end,
433 for (i = beg; i <= end; i++){
double * y
array of y-values (not uniform)
#define T_CUT_RHOE
Sets the lowest cut-off temperature used in the PVTE_LAW equation of state.
double InternalEnergy(double *v, double T)
double FundamentalDerivative(double *v, double T)
void print1(const char *fmt,...)
int nx
Number of columns or points in the x direction.
#define TV_ENERGY_TABLE_NX
double ** a
Spline coefficient (x^3)
double ** c
Spline coefficient (x)
double ** b
Spline coefficient (x^2)
void SplineCoeffs(double *x, double *f, double dfL, double dfR, int n, double *a, double *b, double *c, double *d)
void WriteBinaryTable2D(char *fname, Table2D *tab)
int Brent(double(*Func)(double, void *), void *param, double x1, double x2, double abs_acc, double rel_acc, double *xroot)
int InverseLookupTable2D(Table2D *tab, double y, double f, double *x)
int GetEV_Temperature(double rhoe, double *v, double *T)
void MonotoneSplineCoeffs(double *x, double *y, double *dydx, int n, double *a, double *b, double *c, double *d)
static Table2D Trhoe_tab
A 2D table containing pre-computed values of temperature by inverting e=e(T,rho) at equally spaced no...
static Table2D rhoe_tab
A 2D table containing pre-computed values of internal energy stored at equally spaced node values of ...
int ny
Number of rows or points in the y direction.
int Table2DInterpolate(Table2D *tab, double x, double y, double *f)
static double rhoeFunc(double, void *)
void print(const char *fmt,...)
static double InternalEnergyDeriv(double rho, double T)
void MakeEV_TemperatureTable()
int interpolation
LINEAR/SPLINE1.
#define ARRAY_1D(nx, type)
void InitializeTable2D(Table2D *tab, double xmin, double xmax, int nx, double ymin, double ymax, int ny)
void MakeInternalEnergyTable()
void SoundSpeed2(double **v, double *cs2, double *h, int beg, int end, int pos, Grid *grid)
double lnxmin
lower limit (in log10) in the x-direction
void FinalizeTable2D(Table2D *tab)
double lnymin
lower limit (in log10) in the y-direction
double ** d
Spline coefficiten (1)
double * dx
grid spacing array in the x direction (not uniform)
#define TV_ENERGY_TABLE_NY
#define QUIT_PLUTO(e_code)
double * x
array of x-values (not uniform)
double InternalEnergyFunc(double *v, double T)