/[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 2654 - (show annotations) (download) (as text)
Wed Jan 16 02:04:07 2013 UTC (9 years, 8 months ago) by jpye
File MIME type: text/x-chdr
File size: 5409 byte(s)
Merged (copied) fprops2 branch to trunk. This copy overwrites the trunk version of fprops,
and history is preserved via the fprops2 sequence. I hope that's OK...
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, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
18 *//** @file
19 This file contains declarations of the data structures passed to
20 functions that EVALUATE fluid properties. We allow from some preprocessing of
21 data loaded from input files, if deisred/needed.
22
23 Data declarations as provided in input files are given in filedata.h
24 */
25
26 #ifndef FPROPS_RUNDATA_H
27 #define FPROPS_RUNDATA_H
28
29 #include "common.h"
30
31 /* TODO remove this dependency eventually (some helmholtz data objects are not yet being copied into new structures*/
32 #include "filedata.h"
33
34
35 /** Power terms for phi0 (including polynomial) */
36 typedef struct Cp0RunPowTerm_struct{
37 double a;
38 double p;
39 } Phi0RunPowTerm;
40
41 /** Planck-Einstein aka 'exponential' terms for phi0 */
42 typedef struct Cp0RunExpTerm_struct{
43 double n;
44 double gamma;
45 } Phi0RunExpTerm;
46
47 /**
48 Zero-pressure specific heat capacity data for a fluid
49
50 There is no 'R' or 'cp0star' in this structure. If cp0star != R in the filedata, that
51 difference will be corrected for when this structure is created.
52 */
53 typedef struct Phi0RunData_struct{
54 double c; /**< second integration constant in phi0, value determined by reference point for entropy */
55 double m; /**< first integration constant in phi0, value determined by reference point for enthalpy */
56
57 unsigned np; /**< number of power terms */
58 Phi0RunPowTerm *pt; /**< power term data, may be NULL if np == 0 */
59 unsigned ne; /**< number of Planck-Einstein aka 'exponential' terms */
60 Phi0RunExpTerm *et; /**< exponential term data, maybe NULL if ne == 0 */
61 } Phi0RunData;
62
63 typedef struct HelmholtzRunData_struct{
64 double rho_star;/**< normalisation density, kg/m3 */
65 double T_star; /**< normalisation temperature, K */
66
67 //REMOVED: double p_t; /**< triple-point pressure */
68
69 unsigned np; /**< number of power terms in residual equation */
70 const HelmholtzPowTerm *pt; /**< power term data for residual eqn, maybe NULL if np == 0 */
71 unsigned ng; /**< number of critical terms of the first kind */
72 const HelmholtzGausTerm *gt; /**< critical terms of the first kind */
73 unsigned nc; /**< number of critical terms of the second kind */
74 const HelmholtzCritTerm *ct; /**< critical terms of the second kind */
75 } HelmholtzRunData;
76
77 typedef struct PengrobRunData_struct{
78 double aTc; /**< value of 'a' when evaluated at T = T_c */
79 double b; /**< coeficient 'b' in PR EOS */
80 double kappa; /** parameter used in a(T) */
81 } PengrobRunData;
82
83 typedef union CorrelationUnion_union{
84 HelmholtzRunData *helm;
85 PengrobRunData *pengrob;
86 /* maybe more later */
87 } CorrelationUnion;
88
89 /* TODO Regarding Cp0Data: some source publications present Cp0 data eg in the
90 form of polynomials etc, and others present phi0 data (nondimensionalised ideal
91 helmholtz energy). There is a straightforward conversion between the two, see
92 precalc.c (although that is still incomplete). What is not clear is whether it
93 is better to keep phi0 or cp0 values in the runtime data here. */
94
95 /** All runtime 'core' data for all possible correlations, with exception of correlation-type-ID, function pointers and metadata */
96 typedef struct FluidData_struct{
97 /* common data across all correlations */
98 double R; /**< specific gas constant */
99 double M; /**< molar mass, kg/kmol */
100 double T_t; /**< triple-point temperature */
101 double T_c; /**< critical temperature */
102 double p_c; /**< critical pressure */
103 double rho_c; /**< critical density */
104 double omega; /**< acentric factor (possibly calculated from correlation data)*/
105 Phi0RunData *cp0; /* data for ideal component of Helmholtz energy */
106
107 /* correlation-specific stuff here */
108 CorrelationUnion corr;
109 } FluidData;
110
111
112 /* Definition of a fluid property function pointer */
113 typedef double PropEvalFn(double,double,const FluidData *data, FpropsError *err);
114
115 /** @return psat */
116 typedef double SatEvalFn(double T,double *rhof, double *rhog, const FluidData *data, FpropsError *err);
117
118 /**
119 Structure containing all the necessary data and metadata for run-time
120 calculation of fluid properties.
121 */
122 typedef struct PureFluid_struct{
123 const char *name;
124 EosType type;
125 FluidData *data; // everything we need at runtime in the following functions should be inside this
126 //Pointers to departure functions
127 PropEvalFn *p_fn;
128 PropEvalFn *u_fn;
129 PropEvalFn *h_fn;
130 PropEvalFn *s_fn;
131 PropEvalFn *a_fn;
132 PropEvalFn *cv_fn;
133 PropEvalFn *cp_fn;
134 PropEvalFn *w_fn;
135 PropEvalFn *g_fn;
136 PropEvalFn *alphap_fn;
137 PropEvalFn *betap_fn;
138 PropEvalFn *dpdrho_T_fn; // this derivative is required for saturation properties by Akasaka method
139 SatEvalFn *sat_fn; // function to return {psat,rhof,rhog}(T) for this pure fluid
140 } PureFluid;
141
142 #endif

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