-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestscvheosderivs_old.c
113 lines (87 loc) · 3 KB
/
testscvheosderivs_old.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* A simple program to test the SCVH EOS library.
*
* Author: Christian Reinhardt
* Created: 08.06.2020
* Modified: 09.06.2020
*/
#include <math.h>
#include <stdio.h>
#include <assert.h>
#include "scvheos.h"
int main(int argc, char **argv) {
SCVHEOSMAT *Mat;
int iMat = SCVHEOS_H;
double dKpcUnit = 2.06701e-13;
double dMsolUnit = 4.80438e-08;
double rho, T;
FILE *fp;
int i, j;
/* Use the original units. */
dKpcUnit = 0.0;
dMsolUnit = 0.0;
printf("SCVH EOS: Initializing material %i\n", iMat);
Mat = scvheosInitMaterial(iMat, dKpcUnit, dMsolUnit);
printf("Done.\n");
/* Write the (rho, T) within the range of REOS3 to file. */
fp = fopen("testscvheosderivs_rhoT_grid.txt", "w");
for (j=10; j<Mat->nRho-1; j++) {
rho = pow(Mat->dLogBase, Mat->dLogRhoAxis[j]);
fprintf(fp, "%15.7E", rho);
fprintf(fp, "\n");
}
fprintf(fp, "\n");
for (i=15; i<Mat->nT-1; i++) {
T = pow(Mat->dLogBase, Mat->dLogTAxis[i]);
fprintf(fp, "%15.7E", T);
fprintf(fp, "\n");
}
fclose(fp);
/* Calculate dP/drho(rho, T) on the grid points of the EOS table. */
fp = fopen("testscvheosderivs_dpdrhoofrhot.txt", "w");
for (j=0; j<Mat->nRho-1; j++) {
rho = pow(Mat->dLogBase, Mat->dLogRhoAxis[j]);
for (i=0; i<Mat->nT-1; i++) {
T = pow(Mat->dLogBase, Mat->dLogTAxis[i]);
//fprintf(stderr, "rho= %g T= %g dPdRho= %g\n", rho, T, scvheosdPdRhoofRhoT(Mat, rho, T));
fprintf(fp, "%15.7E", scvheosdPdRhoofRhoT(Mat, rho, T));
}
fprintf(fp, "\n");
}
fclose(fp);
/* Do the same but only for the grid points that are within the range of REOS3. */
fp = fopen("testscvheosderivs_dpdrhoofrhot_reos3.txt", "w");
for (j=10; j<Mat->nRho-1; j++) {
rho = pow(Mat->dLogBase, Mat->dLogRhoAxis[j]);
for (i=15; i<Mat->nT-1; i++) {
T = pow(Mat->dLogBase, Mat->dLogTAxis[i]);
fprintf(fp, "%15.7E", scvheosPofRhoT(Mat, rho, T));
}
fprintf(fp, "\n");
}
/* Calculate dP/dT(rho, T) on the grid points of the EOS table. */
fp = fopen("testscvheosderivs_dpdtofrhot.txt", "w");
for (j=0; j<Mat->nRho-1; j++) {
rho = pow(Mat->dLogBase, Mat->dLogRhoAxis[j]);
for (i=0; i<Mat->nT-1; i++) {
T = pow(Mat->dLogBase, Mat->dLogTAxis[i]);
fprintf(fp, "%15.7E", scvheosdPdTofRhoT(Mat, rho, T));
}
fprintf(fp, "\n");
}
fclose(fp);
/* Do the same but only for the grid points that are within the range of REOS3. */
fp = fopen("testscvheosderivs_dpdtofrhot_reos3.txt", "w");
for (j=10; j<Mat->nRho-1; j++) {
rho = pow(Mat->dLogBase, Mat->dLogRhoAxis[j]);
for (i=15; i<Mat->nT-1; i++) {
T = pow(Mat->dLogBase, Mat->dLogTAxis[i]);
fprintf(fp, "%15.7E", scvheosdPdTofRhoT(Mat, rho, T));
}
fprintf(fp, "\n");
}
printf("Free memory\n");
scvheosFinalizeMaterial(Mat);
printf("Done.\n");
return 0;
}