-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwritePressureTable.c
70 lines (59 loc) · 1.94 KB
/
writePressureTable.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
/* This file is part of ANEOSmaterial.
* Copyright (c) 2020-2021 Thomas Meier & Christian Reinhardt
*
* ANEOSmaterial is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ANEOSmaterial is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ANEOSmaterial. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* ANEOS material library
* Writes the phase data on a grid for the ANEOS material model
*
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "ANEOSmaterial.h"
int main(int argc, char *argv[])
{
ANEOSMATERIAL *Mat;
// Use cgs units.
double dKpcUnit = 0.0;
double dMsolUnit = 0.0;
FILE *fp;
if (argc != 2) {
fprintf(stderr,"Usage: writePressureTable <iMat>\n");
exit(1);
}
int iMat = atoi(argv[1]);
Mat = ANEOSinitMaterial(iMat, dKpcUnit, dMsolUnit);
assert(Mat != NULL);
fprintf(stderr, "iMat = %i: %s (%s)\n", Mat->iMat, Mat->matName, Mat->matstring);
fprintf(stderr, "nRho = %i nT = %i\n", Mat->nRho, Mat->nT);
fp = fopen("pressure.txt", "w");
assert(fp != NULL);
fprintf(fp, "# %s\n", Mat->matstring);
fprintf(fp, "# iMat = %i nRho = %i nT = %i\n", iMat, Mat->nRho, Mat->nT);
for (int i=0; i<Mat->nT; i++)
{
if ( (i%50)==0){
fprintf(stderr, "Iterating over T for %d of %d\n", i, Mat->nT);
}
for (int j=0; j<Mat->nRho; j++)
{
fprintf(fp,"%.15e %.15e %.15e\n", Mat->rhoAxis[j], Mat->TAxis[i], Mat->pArray[i][j]);
}
}
fclose(fp);
return 0;
}