49 #ifndef PV_TEMPERATURE_TABLE_NX
50 #define PV_TEMPERATURE_TABLE_NX 768
52 #ifndef PV_TEMPERATURE_TABLE_NY
53 #define PV_TEMPERATURE_TABLE_NY 768
60 static double TFunc(
double T,
void *par);
83 double prs, rho,
T1, Tlo, Thi,
T, logK = log10(
KELVIN);
87 print1 (
"> MakePV_TemperatureTable: Generating table...\n");
104 GetMu(1.0, 1.0, &mu_lo);
105 GetMu(1.e12, 1.0, &mu_hi);
107 for (j = 0; j < Ttab.
ny; j++){
108 for (i = 0; i < Ttab.
nx; i++){
122 status =
Brent(
TFunc, &par, Tlo, Thi, -1, 1.0e-12, &T);
124 print1 (
"! MakePV_TemperatureTable: ");
125 print1 (
"root could not be found [%d]\n",status);
137 double T, p, mu = 1.2;
142 for (j = 0; j < rhotab.
ny; j++){
143 for (i = 0; i < rhotab.
nx; i++){
147 mu = 1.2 + 0.0/cosh(mu*mu);
157 for (j = 0; j < Ttab.
ny; j++){
158 for (i = 0; i < Ttab.
nx; i++){
163 printf (
"! Error in inverting table\n");
171 printf (
"KELVIN = %12.6e\n",
KELVIN);
192 #if PV_TEMPERATURE_TABLE == YES
200 print (
"! Pressure: table interpolation failure [rho = %12.6e]\n", rho);
246 #if NIONS == 0 && PV_TEMPERATURE_TABLE == YES
250 if (v[PRS] < 0.0)
return 1;
257 print (
"! GetPV_Temperature: table interpolation failure ");
258 print (
"[T1 = %8.3e, rho = %8.3e]\n",T1,rho);
260 if (status == -1)
return 1;
267 #elif NIONS == 0 && PV_TEMPERATURE_TABLE == NO
270 double Tmin, Tmax, lnx, lny, rho, prs;
273 if (v[PRS] < 0.0)
return 1;
282 lnx = log10(prs/rho);
293 Tmin =
MIN(Ttab.
f[j][i], Ttab.
f[j+1][i+1]);
294 Tmax =
MAX(Ttab.
f[j][i], Ttab.
f[j+1][i+1]);
297 status =
Brent(
TFunc, &par, Tmin, Tmax, -1, 1.0e-7, T);
299 print (
"! PrimitiveTemperature: could not find root, ");
300 print (
"! [Tmin, Tmax] = [%12.6e, %12.6e]\n",Tmin, Tmax);
void GetMu(double T, double rho, double *mu)
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.
#define PV_TEMPERATURE_TABLE_NY
void print1(const char *fmt,...)
int nx
Number of columns or points in the x direction.
#define PV_TEMPERATURE_TABLE_NX
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 ny
Number of rows or points in the y direction.
int Table2DInterpolate(Table2D *tab, double x, double y, double *f)
void print(const char *fmt,...)
static double TFunc(double T, void *par)
void InitializeTable2D(Table2D *tab, double xmin, double xmax, int nx, double ymin, double ymax, int ny)
double MeanMolecularWeight(double *V)
double Pressure(double *v, double T)
static Table2D Ttab
A 2D table containing pre-computed values of temperature stored at equally spaced node values of Log...
double lnxmin
lower limit (in log10) in the x-direction
void FinalizeTable2D(Table2D *tab)
double lnymin
lower limit (in log10) in the y-direction
int GetPV_Temperature(double *v, double *T)
void MakePV_TemperatureTable()
#define QUIT_PLUTO(e_code)
double * x
array of x-values (not uniform)