-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtillcalcgamma.c
124 lines (101 loc) · 2.76 KB
/
tillcalcgamma.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
114
115
116
117
118
119
120
121
122
123
124
/*
* Calculate the generalized Gruneisen parameter
*
* Gamma(rho, u) = a + b/omega0
*
* along different isentropes for a material.
*
* Author: Christian Reinhardt
* Date: 01.02.2020
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "tillotson.h"
#define INDEX(i, j) ((i*tillMat->nTableV) + (j))
double Gamma(TILLMATERIAL *tillMat, double rho, double u) {
double eta;
double omega0;
assert(rho >= tillMat->rho0);
eta = rho/tillMat->rho0;
omega0 = u/(tillMat->u0*eta*eta)+1.0;
return(tillMat->a + tillMat->b/omega0);
}
int main(int argc, char **argv) {
TILLMATERIAL *tillMat;
/* Unit convertion factors */
double dKpcUnit = 2.06701e-13;
double dMsolUnit = 4.80438e-08;
/* Lookup table */
double rhomax = 100.0;
double rhomin = 1e-4;
double vmax = 1200.0;
int nTableRho = 1000;
int nTableV = 1000;
double rho, u;
//int nSteps;
int iMat;
int i, j;
#if 0
if (argc != 5)
{
fprintf(stderr, "tillcalcgamma <iMat> <rho_max> <u_start> <nSteps>\n");
exit(1);
}
iMat = atoi(argv[1]);
rho_max = atof(argv[2]);
u_inital = atof(argv[3]);
nSteps = atoi(argv[4]);
assert(iMat >= 0);
#endif
iMat = 1;
/* Initalize the material and calculate the isentropes. */
tillMat = tillInitMaterial(iMat, dKpcUnit, dMsolUnit);
rhomin = 0.99*tillMat->rho0;
rhomax = 10000.0*tillMat->rho0;
vmax = 25.0;
//assert(rhomax > rhomin);
tillInitLookup(tillMat, nTableRho, nTableV, rhomin, rhomax, vmax);
rho = tillMat->rho0;
u = 0.0;
fprintf(stderr, "Gamma(rho=%15.7E, u=%15.7E)=%15.7E\n", rho, u, Gamma(tillMat, rho, u));
i = 999;
j = 999;
rho = tillLookupRho(tillMat, i);
u = tillMat->Lookup[INDEX(i, j)].u;
fprintf(stderr, "Gamma(rho=%15.7E, u=%15.7E)=%15.7E\n", rho, u, Gamma(tillMat, rho, u));
exit(1);
fprintf(stderr, "i=%i\n", tillMat->n);
/*
* Calculate Gamma(rho, u) for the cold curve.
*/
for (i=tillMat->n+1; i<tillMat->nTableRho; i+=10)
{
fprintf(stderr, "i=%i\n", i);
rho = tillLookupRho(tillMat, i);
printf("%15.7E", rho/tillMat->rho0);
j = 0;
u = tillMat->Lookup[INDEX(i, j)].u;
printf("%15.7E", Gamma(tillMat, rho, u));
printf("\n");
}
#if 0
/*
* Calculate Gamma(rho, u) for different isentropes.
*/
for (i=0; i<tillMat->nTableRho; i+=10)
{
rho = tillLookupRho(tillMat, i);
printf("%15.7E", rho);
for (j=0; j<tillMat->nTableV; j+= 10)
{
u = tillMat->Lookup[INDEX(i, j)].u;
printf("%15.7E", Gamma(tillMat, rho, u));
}
printf("\n");
}
#endif
tillFinalizeMaterial(tillMat);
return 0;
}