-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesttillrhopu.c
90 lines (73 loc) · 1.94 KB
/
testtillrhopu.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* This is a simple program to test the Tillotson EOS library.
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <assert.h>
#include "tillotson.h"
#define MAX(A,B) ((A) > (B) ? (A) : (B))
#define MIN(A,B) ((A) > (B) ? (B) : (A))
#define INDEX(i, j) ((i*tillmat->nTableV) + (j))
//#define TILL_PRESS_NP
void main(int argc, char **argv)
{
/*
* Calculate rho(P,u) for a given pressure and then see how well the result matches.
*/
double dKpcUnit = 2.06701e-13;
double dMsolUnit = 4.80438e-08;
double rhomax = 100.0;
double vmax = 100.0;
double umax = 100.0;
double rho, rho_int, u, P;
int nTableRho = 100;
int nTableV = 100;
TILLMATERIAL *tillmat;
FILE *fp1 = NULL;
FILE *fp2 = NULL;
int i = 0;
int j = 0;
fprintf(stderr, "Initializing material...\n");
tillmat = tillInitMaterial(GRANITE, dKpcUnit, dMsolUnit, nTableRho, nTableV, rhomax, vmax, 1);
fprintf(stderr, "Done.\n");
/*
* Determine rho(P, u) on a rho x u grid.
*/
fp1 = fopen("testtillrhopu1.txt","w");
assert(fp1 != NULL);
fp2 = fopen("testtillrhopu2.txt","w");
assert(fp2 != NULL);
#if 0
/* Print a rho x u grid. */
for (i=0;i<tillmat->nTableRho;i+=1)
{
rho = i*tillmat->drho;
if (rho < tillmat->rho0) continue;
u = 0.0;
P = tillPressure(tillmat, rho, u);
rho_int = tillRhoPU(tillmat, P, u);
}
#endif
/* Print a rho x u grid. */
for (i=0;i<tillmat->nTableRho;i+=1)
{
rho = i*tillmat->drho;
if (rho < tillmat->rho0) continue;
for (j=0;j<tillmat->nTableV;j+=1)
{
// v = j*tillmat->dv
u = j*tillmat->dv;
P = tillPressure(tillmat, rho, u);
fprintf(fp1, " %15.7E", rho);
fprintf(fp2, " %15.7E", tillRhoPU(tillmat, P, u));
if (fabs(tillRhoPU(tillmat, P, u) - rho) > 1e-1) printf("%15.7E %15.7E %15.7E\n", rho, u, P);
}
fprintf(fp1, "\n");
fprintf(fp2, "\n");
}
fclose(fp1);
fclose(fp2);
tillFinalizeMaterial(tillmat);
}