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

Contents of /trunk/models/johnpye/fprops/rundata.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2730 - (show annotations) (download) (as text)
Mon Dec 9 08:32:08 2013 UTC (5 years ago) by jpye
File MIME type: text/x-chdr
File size: 5952 byte(s)
working on ideal gas EOS, and implementing enthalpy of formation/absolute entropy via reference state mechanism.
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 "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 /** All runtime 'core' data for all possible correlations, with exception of
87 correlation-type-ID, function pointers and metadata (URLs, publications etc)
88
89 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 For fluids without phase change (incompressible, ideal), we
100 - set T_c to zero,
101 - use a value of 1 K for Tstar
102 - provide a _sat SatEvalFn that always returns an error.
103 ...but maybe there's a better way. It's up to the particular PropEvalFn to
104 make use of Tstar or T_c as desired, but this data is stored here
105 */
106 typedef struct FluidData_struct{
107 /* common data across all correlations */
108 double R; /**< specific gas constant */
109 double M; /**< molar mass, kg/kmol */
110 double T_t; /**< triple-point temperature */
111 double T_c; /**< critical temperature */
112 double p_c; /**< critical pressure */
113 double rho_c; /**< critical density */
114 double omega; /**< acentric factor (possibly calculated from correlation data)*/
115 double Tstar; /**< reference for reduced temperature */
116 double rhostar; /**< reference for reduced density */
117 Phi0RunData *cp0; /* data for ideal component of Helmholtz energy */
118 ReferenceState ref0;
119 /* correlation-specific stuff here */
120 CorrelationUnion corr;
121 } FluidData;
122
123
124 /* Definition of a fluid property function pointer */
125 typedef double PropEvalFn(double,double,const FluidData *data, FpropsError *err);
126
127 /** @return psat */
128 typedef double SatEvalFn(double T,double *rhof, double *rhog, const FluidData *data, FpropsError *err);
129
130 /**
131 Structure containing all the necessary data and metadata for run-time
132 calculation of fluid properties.
133 */
134 typedef struct PureFluid_struct{
135 const char *name;
136 const char *source;
137 EosType type;
138 FluidData *data; // everything we need at runtime in the following functions should be in here
139 //Pointers to departure functions
140 PropEvalFn *p_fn;
141 PropEvalFn *u_fn;
142 PropEvalFn *h_fn;
143 PropEvalFn *s_fn;
144 PropEvalFn *a_fn;
145 PropEvalFn *cv_fn;
146 PropEvalFn *cp_fn;
147 PropEvalFn *w_fn;
148 PropEvalFn *g_fn;
149 PropEvalFn *alphap_fn;
150 PropEvalFn *betap_fn;
151 PropEvalFn *dpdrho_T_fn; // this derivative is required for saturation properties by Akasaka method
152 SatEvalFn *sat_fn; // function to return {psat,rhof,rhog}(T) for this pure fluid
153 } PureFluid;
154
155 #endif

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