-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesteosdpdu.c
99 lines (83 loc) · 2.1 KB
/
testeosdpdu.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
91
92
93
94
95
96
97
98
99
/*
* 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))
void main(int argc, char **argv) {
/*
* Check, if dPdu agrees for eosdPdu and tilldPdu for
* Tillotson materials and if eosdPdu agrees with
* the analytic expression for an ideal gas.
*/
double dKpcUnit = 2.06701e-13;
double dMsolUnit = 4.80438e-08;
double rhomax = 100.0;
double vmax = 100.0;
double rho, u;
int nTableRho = 100;
int nTableV = 100;
TILLMATERIAL *tillmat;
FILE *fp = 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");
/*
* Print P on a rho x u grid.
*/
fp = fopen("testeosdpdu1.txt","w");
assert(fp != NULL);
fprintf(stderr, "Printing grid using tilldPu()...\n");
/* Print a rho x u grid. */
for (i=0;i<tillmat->nTableRho;i+=1)
{
rho = i*tillmat->drho;
for (j=0;j<tillmat->nTableV;j+=1)
{
// v = j*tillmat->dv
u = j*tillmat->dv;
fprintf(fp," %15.7E", tilldPdu(tillmat, rho, u));
}
fprintf(fp,"\n");
}
fclose(fp);
fp = fopen("testeosdpdu2.txt","w");
assert(fp != NULL);
fprintf(stderr, "Printing grid using eosdPu()...\n");
/* Print a rho x u grid. */
for (i=0;i<tillmat->nTableRho;i+=1)
{
rho = i*tillmat->drho;
for (j=0;j<tillmat->nTableV;j+=1)
{
u = j*tillmat->dv;
fprintf(fp," %15.7E", eosdPdu(tillmat, rho, u));
}
fprintf(fp,"\n");
}
fclose(fp);
fp = fopen("testeosdpdu3.txt","w");
assert(fp != NULL);
fprintf(stderr, "Printing grid for the ideal gas EOS...\n");
/* Print a rho x u grid. */
for (i=0;i<tillmat->nTableRho;i+=1)
{
rho = i*tillmat->drho;
for (j=0;j<tillmat->nTableV;j+=1)
{
u = j*tillmat->dv;
fprintf(fp," %15.7E", eosdPdu(NULL, rho, u)-(5.0/3.0-1.0)*rho);
}
fprintf(fp,"\n");
}
fclose(fp);
tillFinalizeMaterial(tillmat);
}