/[ascend]/branches/sid/models/johnpye/fprops/rundata.h
ViewVC logotype

Contents of /branches/sid/models/johnpye/fprops/rundata.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3024 - (show annotations) (download) (as text)
Thu Jul 23 04:16:35 2015 UTC (3 years, 3 months ago) by sid
File MIME type: text/x-chdr
File size: 7792 byte(s)
first attempt at two phase

1 /* 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 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *//** @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 <stdio.h>
28 #include "common.h"
29
30 /* TODO remove this dependency eventually (some helmholtz data objects are not yet being copied into new structures*/
31 #include "filedata.h"
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 Runtime data for ideal gas properties, which are stored in the
47 form of reduced ideal-gas compnent of helmholtz energy (see http://fprops.org)
48
49 There is no 'R' or 'cp0star' in this structure. If cp0star != R in the filedata, that
50 difference will be corrected for when this structure is created.
51 */
52 typedef struct Phi0RunData_struct{
53 double c; /**< second integration constant in phi0, value determined by reference point for entropy */
54 double m; /**< first integration constant in phi0, value determined by reference point for enthalpy */
55
56 unsigned np; /**< number of power terms */
57 Phi0RunPowTerm *pt; /**< power term data, may be NULL if np == 0 */
58 unsigned ne; /**< number of Planck-Einstein aka 'exponential' terms */
59 Phi0RunExpTerm *et; /**< exponential term data, maybe NULL if ne == 0 */
60 } Phi0RunData;
61
62 typedef struct HelmholtzRunData_struct{
63 double rho_star;/**< normalisation density, kg/m3 */
64 double T_star; /**< normalisation temperature, K */
65
66 //REMOVED: double p_t; /**< triple-point pressure */
67
68 unsigned np; /**< number of power terms in residual equation */
69 const HelmholtzPowTerm *pt; /**< power term data for residual eqn, maybe NULL if np == 0 */
70 unsigned ng; /**< number of critical terms of the first kind */
71 const HelmholtzGausTerm *gt; /**< critical terms of the first kind */
72 unsigned nc; /**< number of critical terms of the second kind */
73 const HelmholtzCritTerm *ct; /**< critical terms of the second kind */
74 } HelmholtzRunData;
75
76 typedef struct PengrobRunData_struct{
77 double aTc; /**< value of 'a' when evaluated at T = T_c */
78 double b; /**< coeficient 'b' in PR EOS */
79 double kappa; /** parameter used in a(T) */
80 } PengrobRunData;
81
82 typedef union CorrelationUnion_union{
83 HelmholtzRunData *helm;
84 PengrobRunData *pengrob;
85 /* maybe more later */
86 } CorrelationUnion;
87
88 /** All runtime 'core' data for all possible correlations, with exception of
89 correlation-type-ID, function pointers and metadata (URLs, publications etc)
90
91 TODO FluidData (or PureFluid?) could/should be extended to include the following
92 frequently-calculated items:
93 - fluid properties at triple point (rhoft, rhogt, pt...)
94 - fluid properties at critical point (hc, ...)
95 - accurate saturation curve data (interpolation/spline/something like that)
96 - solutions of iterative solver results, eg (p,h) pairs.
97
98 This data would be held at this level unless it is correlation-specific in
99 nature, in which case it would belong in lower-level rundata structures.
100
101 For fluids without phase change (incompressible, ideal), we
102 - set T_c to zero,
103 - use a value of 1 K for Tstar
104 - provide a _sat SatEvalFn that always returns an error.
105 ...but maybe there's a better way. It's up to the particular PropEvalFn to
106 make use of Tstar or T_c as desired, but this data is stored here
107 */
108 typedef struct FluidData_struct{
109 /* common data across all correlations */
110 double R; /**< specific gas constant */
111 double M; /**< molar mass, kg/kmol */
112 double T_t; /**< triple-point temperature */
113 double T_c; /**< critical temperature */
114 double p_c; /**< critical pressure */
115 double rho_c; /**< critical density */
116 double omega; /**< acentric factor (possibly calculated from correlation data)*/
117 double Tstar; /**< reference for reduced temperature */
118 double rhostar; /**< reference for reduced density */
119 Phi0RunData *cp0; /* data for ideal component of Helmholtz energy */
120 ReferenceState ref0;
121 /* correlation-specific stuff here */
122 CorrelationUnion corr;
123 } FluidData;
124
125
126 /* Definition of a fluid property function pointer */
127 typedef double PropEvalFn(double T,double rho,const FluidData *data, FpropsError *err);
128
129 /** @return psat */
130 typedef double SatEvalFn(double T,double *rhof, double *rhog, const FluidData *data, FpropsError *err);
131
132
133
134 /*structure for tables*/
135 #define NTP 200
136 #define NRHOP 200
137 #define NSAT 1000
138 typedef double (*TtseMatrix) [NRHOP];
139 typedef double* TtseLine;
140
141 typedef struct ttse_struct{
142
143 int istablebuilt;
144 int doesfileexist;
145 int usettse;
146
147 double tmin,tmax,rhomin,rhomax;
148
149 TtseMatrix s, dsdt, d2sdt2, dsdrho, d2sdrho2, d2sdtdrho;
150 TtseMatrix p, dpdt, d2pdt2, dpdrho, d2pdrho2, d2pdtdrho;
151 TtseMatrix u, dudt, d2udt2, dudrho, d2udrho2, d2udtdrho;
152 TtseMatrix g, dgdt, d2gdt2, dgdrho, d2gdrho2, d2gdtdrho;
153 TtseMatrix h, dhdt, d2hdt2, dhdrho, d2hdrho2, d2hdtdrho;
154
155 TtseLine satFRho,satFdRhodt,satFd2RhodT2;
156 TtseLine satGRho,satGdRhodt,satGd2RhodT2;
157
158 //double ** dsdT,** d2sdT2,** dsdRho,** d2sdRho2,** d2sdTdRho;
159 //double ** dPdT,** d2PdT2,** dPdRho,** d2PdRho2,** d2PdTdRho;
160 //double ** dudT,** d2udT2,** dudRho,** d2udRho2,** d2udTdRho;
161 //double ** dgdT,** d2gdT2,** dgdRho,** d2gdRho2,** d2gdTdRho;
162 //double ** dhdT,** d2hdT2,** dhdRho,** d2hdRho2,** d2hdTdRho;
163 }Ttse;
164
165 /**
166 Structure containing all the necessary data and metadata for run-time
167 calculation of fluid properties.
168 */
169 typedef struct PureFluid_struct{
170 const char *name;
171 const char *source;
172 EosType type;
173 FluidData *data; // everything we need at runtime in the following functions should be in here
174 //Pointers to departure functions
175 PropEvalFn *p_fn;
176 PropEvalFn *u_fn;
177 PropEvalFn *h_fn;
178 PropEvalFn *s_fn;
179 PropEvalFn *a_fn;
180 PropEvalFn *cv_fn;
181 PropEvalFn *cp_fn;
182 PropEvalFn *w_fn;
183 PropEvalFn *g_fn;
184 PropEvalFn *alphap_fn;
185 PropEvalFn *betap_fn;
186 PropEvalFn *dpdrho_T_fn, *d2pdrho2_T_fn, *dpdT_rho_fn, *d2pdT2_rho_fn, *d2pdTdrho_fn;// dpdrho_T_fn this derivative is required for saturation properties by Akasaka method
187 PropEvalFn *dhdrho_T_fn, *d2hdrho2_T_fn, *dhdT_rho_fn, *d2hdT2_rho_fn, *d2hdTdrho_fn;
188 PropEvalFn *dsdrho_T_fn, *d2sdrho2_T_fn, *dsdT_rho_fn, *d2sdT2_rho_fn, *d2sdTdrho_fn;
189 PropEvalFn *dudrho_T_fn, *d2udrho2_T_fn, *dudT_rho_fn, *d2udT2_rho_fn, *d2udTdrho_fn;
190 PropEvalFn *dgdrho_T_fn, *d2gdrho2_T_fn, *dgdT_rho_fn, *d2gdT2_rho_fn, *d2gdTdrho_fn;
191 SatEvalFn *sat_fn; // function to return {psat,rhof,rhog}(T) for this pure fluid
192
193 const ViscosityData *visc; // TODO should it be here? or inside FluidData?? probably yes, but needs review.
194 const ThermalConductivityData *thcond; // TODO should it be here? probably yes, but needs review.
195 Ttse * table;
196 FILE * file_table; //file pointer to open the binary files for TTSE tables.
197 } PureFluid;
198
199
200
201
202 #endif
203

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22