-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtillcalcbulkmodulus.c
73 lines (62 loc) · 1.53 KB
/
tillcalcbulkmodulus.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
/*
* Calculate the isentropic bulk modulus
*
* Ks=rho*dP/drho (s=const.)
*
* along different isentropes for a material.
*
* Author: Christian Reinhardt
* Date: 19.11.2018
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "tillotson.h"
#define INDEX(i, j) ((i*tillmat->nTableV) + (j))
void 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;
double K, cs2, P;
int nRho, nU;
int iMat;
int i, j;
nRho = 100;
nU = 10;
if (argc != 2)
{
fprintf(stderr, "tillcalcbulkmodulus <iMat>\n");
exit(1);
}
iMat = atoi(argv[1]);
assert(iMat >= 0);
/* Initalize the material and calculate the isentropes. */
tillmat = tillInitMaterial(iMat, dKpcUnit, dMsolUnit);
tillInitLookup(tillmat, nTableRho, nTableV, rhomin, rhomax, vmax);
/*
* Calculate the bulk modulus 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;
P = tillPressureSound(tillmat, rho, u, &cs2);
K = rho*cs2;
printf("%15.7E", K);
}
printf("\n");
}
tillFinalizeMaterial(tillmat);
}