Parent Directory | Revision Log

Revision **2738** -
(**show annotations**)
(**download**)
(**as text**)

*Thu Dec 12 08:21:07 2013 UTC*
(5 years, 5 months ago)
by *jpye*

File MIME type: text/x-chdr

File size: 6041 byte(s)

File MIME type: text/x-chdr

File size: 6041 byte(s)

more debugging of cp0 and ideal_cp, pengrob_cp (both seem incorrect)

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 | Runtime data for ideal gas properties, which are stored in the |

46 | form of reduced ideal-gas compnent of helmholtz energy (see http://fprops.org) |

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 | /** All runtime 'core' data for all possible correlations, with exception of |

88 | correlation-type-ID, function pointers and metadata (URLs, publications etc) |

89 | |

90 | TODO FluidData (or PureFluid?) could/should be extended to include the following |

91 | frequently-calculated items: |

92 | - fluid properties at triple point (rhoft, rhogt, pt...) |

93 | - fluid properties at critical point (hc, ...) |

94 | - accurate saturation curve data (interpolation/spline/something like that) |

95 | - solutions of iterative solver results, eg (p,h) pairs. |

96 | |

97 | This data would be held at this level unless it is correlation-specific in |

98 | nature, in which case it would belong in lower-level rundata structures. |

99 | |

100 | For fluids without phase change (incompressible, ideal), we |

101 | - set T_c to zero, |

102 | - use a value of 1 K for Tstar |

103 | - provide a _sat SatEvalFn that always returns an error. |

104 | ...but maybe there's a better way. It's up to the particular PropEvalFn to |

105 | make use of Tstar or T_c as desired, but this data is stored here |

106 | */ |

107 | typedef struct FluidData_struct{ |

108 | /* common data across all correlations */ |

109 | double R; /**< specific gas constant */ |

110 | double M; /**< molar mass, kg/kmol */ |

111 | double T_t; /**< triple-point temperature */ |

112 | double T_c; /**< critical temperature */ |

113 | double p_c; /**< critical pressure */ |

114 | double rho_c; /**< critical density */ |

115 | double omega; /**< acentric factor (possibly calculated from correlation data)*/ |

116 | double Tstar; /**< reference for reduced temperature */ |

117 | double rhostar; /**< reference for reduced density */ |

118 | Phi0RunData *cp0; /* data for ideal component of Helmholtz energy */ |

119 | ReferenceState ref0; |

120 | /* correlation-specific stuff here */ |

121 | CorrelationUnion corr; |

122 | } FluidData; |

123 | |

124 | |

125 | /* Definition of a fluid property function pointer */ |

126 | typedef double PropEvalFn(double,double,const FluidData *data, FpropsError *err); |

127 | |

128 | /** @return psat */ |

129 | typedef double SatEvalFn(double T,double *rhof, double *rhog, const FluidData *data, FpropsError *err); |

130 | |

131 | /** |

132 | Structure containing all the necessary data and metadata for run-time |

133 | calculation of fluid properties. |

134 | */ |

135 | typedef struct PureFluid_struct{ |

136 | const char *name; |

137 | const char *source; |

138 | EosType type; |

139 | FluidData *data; // everything we need at runtime in the following functions should be in here |

140 | //Pointers to departure functions |

141 | PropEvalFn *p_fn; |

142 | PropEvalFn *u_fn; |

143 | PropEvalFn *h_fn; |

144 | PropEvalFn *s_fn; |

145 | PropEvalFn *a_fn; |

146 | PropEvalFn *cv_fn; |

147 | PropEvalFn *cp_fn; |

148 | PropEvalFn *w_fn; |

149 | PropEvalFn *g_fn; |

150 | PropEvalFn *alphap_fn; |

151 | PropEvalFn *betap_fn; |

152 | PropEvalFn *dpdrho_T_fn; // this derivative is required for saturation properties by Akasaka method |

153 | SatEvalFn *sat_fn; // function to return {psat,rhof,rhog}(T) for this pure fluid |

154 | } PureFluid; |

155 | |

156 | #endif |

john.pye@anu.edu.au | ViewVC Help |

Powered by ViewVC 1.1.22 |