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 |
|
|
/** Power terms for phi0 (including polynomial) */ |
33 |
|
|
typedef struct Cp0RunPowTerm_struct{ |
34 |
|
|
double a; |
35 |
|
|
double p; |
36 |
|
|
} Phi0RunPowTerm; |
37 |
|
|
|
38 |
|
|
/** Planck-Einstein aka 'exponential' terms for phi0 */ |
39 |
|
|
typedef struct Cp0RunExpTerm_struct{ |
40 |
|
|
double n; |
41 |
|
|
double gamma; |
42 |
|
|
} Phi0RunExpTerm; |
43 |
|
|
|
44 |
|
|
/** |
45 |
|
|
Zero-pressure specific heat capacity data for a fluid |
46 |
|
|
|
47 |
|
|
There is no 'R' or 'cp0star' in this structure. If cp0star != R in the filedata, that |
48 |
|
|
difference will be corrected for when this structure is created. |
49 |
|
|
*/ |
50 |
|
|
typedef struct Phi0RunData_struct{ |
51 |
|
|
double c; /**< second integration constant in phi0, value determined by reference point for entropy */ |
52 |
|
|
double m; /**< first integration constant in phi0, value determined by reference point for enthalpy */ |
53 |
|
|
|
54 |
|
|
unsigned np; /**< number of power terms */ |
55 |
|
|
Phi0RunPowTerm *pt; /**< power term data, may be NULL if np == 0 */ |
56 |
|
|
unsigned ne; /**< number of Planck-Einstein aka 'exponential' terms */ |
57 |
|
|
Phi0RunExpTerm *et; /**< exponential term data, maybe NULL if ne == 0 */ |
58 |
|
|
} Phi0RunData; |
59 |
|
|
|
60 |
|
|
typedef struct HelmholtzRunData_struct{ |
61 |
|
|
double rho_star;/**< normalisation density, kg/m3 */ |
62 |
|
|
double T_star; /**< normalisation temperature, K */ |
63 |
|
|
|
64 |
|
|
//REMOVED: double p_t; /**< triple-point pressure */ |
65 |
|
|
|
66 |
|
|
unsigned np; /**< number of power terms in residual equation */ |
67 |
|
|
const HelmholtzPowTerm *pt; /**< power term data for residual eqn, maybe NULL if np == 0 */ |
68 |
|
|
unsigned ng; /**< number of critical terms of the first kind */ |
69 |
|
|
const HelmholtzGausTerm *gt; /**< critical terms of the first kind */ |
70 |
|
|
unsigned nc; /**< number of critical terms of the second kind */ |
71 |
|
|
const HelmholtzCritTerm *ct; /**< critical terms of the second kind */ |
72 |
|
|
} HelmholtzRunData; |
73 |
|
|
|
74 |
|
|
typedef struct PengrobRunData_struct{ |
75 |
|
|
double aTc; /**< value of 'a' when evaluated at T = T_c */ |
76 |
|
|
double b; /**< coeficient 'b' in PR EOS */ |
77 |
|
|
double kappa; /** parameter used in a(T) */ |
78 |
|
|
} PengrobRunData; |
79 |
|
|
|
80 |
|
|
typedef union CorrelationUnion_union{ |
81 |
|
|
HelmholtzRunData *helm; |
82 |
|
|
PengrobRunData *pengrob; |
83 |
|
|
/* maybe more later */ |
84 |
|
|
} CorrelationUnion; |
85 |
|
|
|
86 |
jpye |
2680 |
/** All runtime 'core' data for all possible correlations, with exception of |
87 |
|
|
correlation-type-ID, function pointers and metadata (URLs, publications etc) |
88 |
jpye |
2654 |
|
89 |
jpye |
2680 |
TODO FluidData (or PureFluid?) could/should be extended to include the following |
90 |
|
|
frequently-calculated items: |
91 |
|
|
- fluid properties at triple point (rhoft, rhogt, pt...) |
92 |
|
|
- fluid properties at critical point (hc, ...) |
93 |
|
|
- accurate saturation curve data (interpolation/spline/something like that) |
94 |
|
|
- solutions of iterative solver results, eg (p,h) pairs. |
95 |
|
|
|
96 |
|
|
This data would be held at this level unless it is correlation-specific in |
97 |
|
|
nature, in which case it would belong in lower-level rundata structures. |
98 |
|
|
*/ |
99 |
jpye |
2654 |
typedef struct FluidData_struct{ |
100 |
|
|
/* common data across all correlations */ |
101 |
|
|
double R; /**< specific gas constant */ |
102 |
|
|
double M; /**< molar mass, kg/kmol */ |
103 |
|
|
double T_t; /**< triple-point temperature */ |
104 |
|
|
double T_c; /**< critical temperature */ |
105 |
|
|
double p_c; /**< critical pressure */ |
106 |
|
|
double rho_c; /**< critical density */ |
107 |
|
|
double omega; /**< acentric factor (possibly calculated from correlation data)*/ |
108 |
|
|
Phi0RunData *cp0; /* data for ideal component of Helmholtz energy */ |
109 |
|
|
|
110 |
|
|
/* correlation-specific stuff here */ |
111 |
|
|
CorrelationUnion corr; |
112 |
|
|
} FluidData; |
113 |
|
|
|
114 |
|
|
|
115 |
|
|
/* Definition of a fluid property function pointer */ |
116 |
|
|
typedef double PropEvalFn(double,double,const FluidData *data, FpropsError *err); |
117 |
|
|
|
118 |
|
|
/** @return psat */ |
119 |
|
|
typedef double SatEvalFn(double T,double *rhof, double *rhog, const FluidData *data, FpropsError *err); |
120 |
|
|
|
121 |
|
|
/** |
122 |
|
|
Structure containing all the necessary data and metadata for run-time |
123 |
|
|
calculation of fluid properties. |
124 |
|
|
*/ |
125 |
|
|
typedef struct PureFluid_struct{ |
126 |
|
|
const char *name; |
127 |
jpye |
2662 |
const char *source; |
128 |
jpye |
2654 |
EosType type; |
129 |
jpye |
2662 |
FluidData *data; // everything we need at runtime in the following functions should be in here |
130 |
jpye |
2654 |
//Pointers to departure functions |
131 |
|
|
PropEvalFn *p_fn; |
132 |
|
|
PropEvalFn *u_fn; |
133 |
|
|
PropEvalFn *h_fn; |
134 |
|
|
PropEvalFn *s_fn; |
135 |
|
|
PropEvalFn *a_fn; |
136 |
|
|
PropEvalFn *cv_fn; |
137 |
|
|
PropEvalFn *cp_fn; |
138 |
|
|
PropEvalFn *w_fn; |
139 |
|
|
PropEvalFn *g_fn; |
140 |
|
|
PropEvalFn *alphap_fn; |
141 |
|
|
PropEvalFn *betap_fn; |
142 |
|
|
PropEvalFn *dpdrho_T_fn; // this derivative is required for saturation properties by Akasaka method |
143 |
|
|
SatEvalFn *sat_fn; // function to return {psat,rhof,rhog}(T) for this pure fluid |
144 |
|
|
} PureFluid; |
145 |
|
|
|
146 |
|
|
#endif |