-
Notifications
You must be signed in to change notification settings - Fork 0
/
testscvheospressure.c
83 lines (68 loc) · 2.09 KB
/
testscvheospressure.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
/*
* A simple program to test the SCVH EOS library.
*
* Author: Christian Reinhardt
* Created: 06.04.2020
* Modified: 15.05.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 logrho, logT;
double rho, T;
FILE *fp;
int i, j;
dKpcUnit = 0.0;
dMsolUnit = 0.0;
printf("SCVH EOS: Initializing material %i\n", iMat);
Mat = scvheosInitMaterial(iMat, dKpcUnit, dMsolUnit);
printf("Done.\n");
/* Interpolate in rho for different isotherms. */
fp = fopen("testscvheospressure.txt", "w");
for (j=1; j<Mat->nRho-1; j++) {
logrho = 0.5*(Mat->dLogRhoAxis[j+1] + Mat->dLogRhoAxis[j]);
fprintf(fp, "%15.7E", logrho);
for (i=0; i<Mat->nT-1; i++) {
//logT = Mat->dLogTAxis[i];
logT = 0.5*(Mat->dLogTAxis[i+1]+Mat->dLogTAxis[i]);
fprintf(fp, "%15.7E", scvheosLogPofRhoT(Mat, logrho, logT));
}
fprintf(fp, "\n");
}
fclose(fp);
/* Write the (rho, T) within the range of REOS3 to file. */
fp = fopen("testscvheospressure_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 the pressure at the grid points that are within the range of REOS3. */
fp = fopen("testscvheospressure_P.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");
}
fclose(fp);
printf("Free memory\n");
scvheosFinalizeMaterial(Mat);
printf("Done.\n");
return 0;
}