-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheoslib.c
130 lines (120 loc) · 2.93 KB
/
eoslib.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
125
126
127
128
129
/*
* Copyright (c) 2018 Christian Reinhardt.
*
* This file provides a general interface that allows the use of different
* equations of state (EOS) in hydro-codes.
*
* Currently supported are:
*
* Ideal gas EOS
* Tillotson EOS (Tillotson 1962)
* Van der Waals EOS
* ANEOS (Thompson 1972)
* M-ANEOS (Melosh 2007)
*/
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <stdio.h>
#include "eoslib.h"
/*
* Basic functions:
*
* eosInitMat: initialise a material of a given EOS from its material ID.
*
* eosFinalizeMat: finalize a material, free memory if needed.
*
* eosPressureSound: calculate the pressure and soundspeed for a given EOS/material.
*
* eosPressure: calculate the pressure only (uses eosPressureSound).
*
* eosSoundSpeed: calculate the sound speed for a given rho and u (uses
* eosPressureSound).
*
* eosFinalize: free memory.
*/
void *eosInitMat(int iMat, double dKpcUnit, double dMsolUnit, void *param)
{
/*
* Initialize an EOS/material.
*
* Parameters:
*
* iMat: material ID
* params: a general array containing different parameters that depend
* on the EOS.
*/
if (iMat == IDEALGAS)
{
/*
* Classic ideal gas.
*/
return((igMat *) igInit((igParam *));
} else if (iMat == VDW_EOS) {
/*
* The Van der Waals EOS.
*/
return(vdwInit());
} else if (EOS_TILL_MIN <= iMat <= EOS_TILL_MAX) {
/*
* The Tillotson EOS (Tillotson 1962).
*/
return((TILLMATERIAL*) (tillInitMaterial(iMat, dKpcUnit, dMsolUnit, param->nTableRho, param->nTableV, param->rhomax, param->vmax, param->iExpV)));
} else {
fprintf(stderr, "iMat= %i undefined.\n", iMat);
assert(0);
}
}
void eosFinalizeMat(void *eosMat)
{
/*
* Free the memory.
*/
if (eosMat != NULL)
free(eosMat);
}
double eosPressureSound(void *eosMat, double rho, double u, double *pcSound)
{
/*
* Calculate the pressure and sound speed for a given EOS and material.
*
* Input:
* eosMat: structure that contains EOS/material specific data
* rho: density
* u: internal energy
* pcSound: sound speed (if NULL nothing is returned)
* Output:
* Pressure
*/
}
double eosPressure(void *eosMat, double rho, double u)
{
/*
* Calculate the pressure for a given EOS and material.
*/
return (eosPressureSound(eosMat, rho, u, NULL));
}
double eosdPdrho(void *eosMat, double rho, double u)
{
/*
* Calculate dP/drho (at constant u).
*/
}
double eosdPdu(void *eosMat, double rho, double u)
{
/*
* Calculate dP/du (at constant rho).
*/
}
double eosTempRhoU(void *eosMat, double rho, double u)
{
/*
* Calculate T(rho, u).
*/
}
double eosRhoPU(void *eosMat, double P, double u)
{
/*
* Calculate rho(P, u).
*/
}