1 |
jpye |
2654 |
/* ASCEND modelling environment |
2 |
|
|
Copyright (C) 2011 Carnegie Mellon University |
3 |
|
|
|
4 |
|
|
This program is free software; you can redistribute it and/or modify |
5 |
|
|
it under the terms of the GNU General Public License as published by |
6 |
|
|
the Free Software Foundation; either version 2, or (at your option) |
7 |
|
|
any later version. |
8 |
|
|
|
9 |
|
|
This program is distributed in the hope that it will be useful, |
10 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
|
|
GNU General Public License for more details. |
13 |
|
|
|
14 |
|
|
You should have received a copy of the GNU General Public License |
15 |
jpye |
2661 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 |
jpye |
2654 |
*//** @file |
17 |
|
|
This file contains declarations of the data structures passed to |
18 |
|
|
functions that EVALUATE fluid properties. We allow from some preprocessing of |
19 |
|
|
data loaded from input files, if deisred/needed. |
20 |
|
|
|
21 |
|
|
Data declarations as provided in input files are given in filedata.h |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
#ifndef FPROPS_RUNDATA_H |
25 |
|
|
#define FPROPS_RUNDATA_H |
26 |
|
|
|
27 |
|
|
#include "common.h" |
28 |
|
|
|
29 |
|
|
/* TODO remove this dependency eventually (some helmholtz data objects are not yet being copied into new structures*/ |
30 |
|
|
#include "filedata.h" |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/** Power terms for phi0 (including polynomial) */ |
34 |
|
|
typedef struct Cp0RunPowTerm_struct{ |
35 |
|
|
double a; |
36 |
|
|
double p; |
37 |
|
|
} Phi0RunPowTerm; |
38 |
|
|
|
39 |
|
|
/** Planck-Einstein aka 'exponential' terms for phi0 */ |
40 |
|
|
typedef struct Cp0RunExpTerm_struct{ |
41 |
|
|
double n; |
42 |
|
|
double gamma; |
43 |
|
|
} Phi0RunExpTerm; |
44 |
|
|
|
45 |
|
|
/** |
46 |
|
|
Zero-pressure specific heat capacity data for a fluid |
47 |
|
|
|
48 |
|
|
There is no 'R' or 'cp0star' in this structure. If cp0star != R in the filedata, that |
49 |
|
|
difference will be corrected for when this structure is created. |
50 |
|
|
*/ |
51 |
|
|
typedef struct Phi0RunData_struct{ |
52 |
|
|
double c; /**< second integration constant in phi0, value determined by reference point for entropy */ |
53 |
|
|
double m; /**< first integration constant in phi0, value determined by reference point for enthalpy */ |
54 |
|
|
|
55 |
|
|
unsigned np; /**< number of power terms */ |
56 |
|
|
Phi0RunPowTerm *pt; /**< power term data, may be NULL if np == 0 */ |
57 |
|
|
unsigned ne; /**< number of Planck-Einstein aka 'exponential' terms */ |
58 |
|
|
Phi0RunExpTerm *et; /**< exponential term data, maybe NULL if ne == 0 */ |
59 |
|
|
} Phi0RunData; |
60 |
|
|
|
61 |
|
|
typedef struct HelmholtzRunData_struct{ |
62 |
|
|
double rho_star;/**< normalisation density, kg/m3 */ |
63 |
|
|
double T_star; /**< normalisation temperature, K */ |
64 |
|
|
|
65 |
|
|
//REMOVED: double p_t; /**< triple-point pressure */ |
66 |
|
|
|
67 |
|
|
unsigned np; /**< number of power terms in residual equation */ |
68 |
|
|
const HelmholtzPowTerm *pt; /**< power term data for residual eqn, maybe NULL if np == 0 */ |
69 |
|
|
unsigned ng; /**< number of critical terms of the first kind */ |
70 |
|
|
const HelmholtzGausTerm *gt; /**< critical terms of the first kind */ |
71 |
|
|
unsigned nc; /**< number of critical terms of the second kind */ |
72 |
|
|
const HelmholtzCritTerm *ct; /**< critical terms of the second kind */ |
73 |
|
|
} HelmholtzRunData; |
74 |
|
|
|
75 |
|
|
typedef struct PengrobRunData_struct{ |
76 |
|
|
double aTc; /**< value of 'a' when evaluated at T = T_c */ |
77 |
|
|
double b; /**< coeficient 'b' in PR EOS */ |
78 |
|
|
double kappa; /** parameter used in a(T) */ |
79 |
|
|
} PengrobRunData; |
80 |
|
|
|
81 |
|
|
typedef union CorrelationUnion_union{ |
82 |
|
|
HelmholtzRunData *helm; |
83 |
|
|
PengrobRunData *pengrob; |
84 |
|
|
/* maybe more later */ |
85 |
|
|
} CorrelationUnion; |
86 |
|
|
|
87 |
|
|
/* TODO Regarding Cp0Data: some source publications present Cp0 data eg in the |
88 |
|
|
form of polynomials etc, and others present phi0 data (nondimensionalised ideal |
89 |
|
|
helmholtz energy). There is a straightforward conversion between the two, see |
90 |
|
|
precalc.c (although that is still incomplete). What is not clear is whether it |
91 |
|
|
is better to keep phi0 or cp0 values in the runtime data here. */ |
92 |
|
|
|
93 |
|
|
/** All runtime 'core' data for all possible correlations, with exception of correlation-type-ID, function pointers and metadata */ |
94 |
|
|
typedef struct FluidData_struct{ |
95 |
|
|
/* common data across all correlations */ |
96 |
|
|
double R; /**< specific gas constant */ |
97 |
|
|
double M; /**< molar mass, kg/kmol */ |
98 |
|
|
double T_t; /**< triple-point temperature */ |
99 |
|
|
double T_c; /**< critical temperature */ |
100 |
|
|
double p_c; /**< critical pressure */ |
101 |
|
|
double rho_c; /**< critical density */ |
102 |
|
|
double omega; /**< acentric factor (possibly calculated from correlation data)*/ |
103 |
|
|
Phi0RunData *cp0; /* data for ideal component of Helmholtz energy */ |
104 |
|
|
|
105 |
|
|
/* correlation-specific stuff here */ |
106 |
|
|
CorrelationUnion corr; |
107 |
|
|
} FluidData; |
108 |
|
|
|
109 |
|
|
|
110 |
|
|
/* Definition of a fluid property function pointer */ |
111 |
|
|
typedef double PropEvalFn(double,double,const FluidData *data, FpropsError *err); |
112 |
|
|
|
113 |
|
|
/** @return psat */ |
114 |
|
|
typedef double SatEvalFn(double T,double *rhof, double *rhog, const FluidData *data, FpropsError *err); |
115 |
|
|
|
116 |
|
|
/** |
117 |
|
|
Structure containing all the necessary data and metadata for run-time |
118 |
|
|
calculation of fluid properties. |
119 |
|
|
*/ |
120 |
|
|
typedef struct PureFluid_struct{ |
121 |
|
|
const char *name; |
122 |
jpye |
2662 |
const char *source; |
123 |
jpye |
2654 |
EosType type; |
124 |
jpye |
2662 |
FluidData *data; // everything we need at runtime in the following functions should be in here |
125 |
jpye |
2654 |
//Pointers to departure functions |
126 |
|
|
PropEvalFn *p_fn; |
127 |
|
|
PropEvalFn *u_fn; |
128 |
|
|
PropEvalFn *h_fn; |
129 |
|
|
PropEvalFn *s_fn; |
130 |
|
|
PropEvalFn *a_fn; |
131 |
|
|
PropEvalFn *cv_fn; |
132 |
|
|
PropEvalFn *cp_fn; |
133 |
|
|
PropEvalFn *w_fn; |
134 |
|
|
PropEvalFn *g_fn; |
135 |
|
|
PropEvalFn *alphap_fn; |
136 |
|
|
PropEvalFn *betap_fn; |
137 |
|
|
PropEvalFn *dpdrho_T_fn; // this derivative is required for saturation properties by Akasaka method |
138 |
|
|
SatEvalFn *sat_fn; // function to return {psat,rhof,rhog}(T) for this pure fluid |
139 |
|
|
} PureFluid; |
140 |
|
|
|
141 |
|
|
#endif |