| 1 |
REQUIRE "system.a4l"; |
| 2 |
(* => system.a4l, basemodel.a4l *) |
| 3 |
PROVIDE "phases.a4l"; |
| 4 |
|
| 5 |
(* |
| 6 |
* phases.a4l |
| 7 |
* by Arthur W. Westerberg |
| 8 |
* Part of the ASCEND Library |
| 9 |
* $Date: 1998/06/17 19:16:57 $ |
| 10 |
* $Revision: 1.3 $ |
| 11 |
* $Author: mthomas $ |
| 12 |
* $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/phases.a4l,v $ |
| 13 |
* |
| 14 |
* This file is part of the ASCEND Modeling Library. |
| 15 |
* |
| 16 |
* Copyright (C) 1998 Arthur W Westerberg |
| 17 |
* |
| 18 |
* The ASCEND Modeling Library is free software; you can redistribute |
| 19 |
* it and/or modify it under the terms of the GNU General Public |
| 20 |
* License as published by the Free Software Foundation; either |
| 21 |
* version 2 of the License, or (at your option) any later version. |
| 22 |
* |
| 23 |
* The ASCEND Modeling Library is distributed in hope that it will be |
| 24 |
* useful, but WITHOUT ANY WARRANTY; without even the implied |
| 25 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 26 |
* See the GNU General Public License for more details. |
| 27 |
* |
| 28 |
* You should have received a copy of the GNU General Public License |
| 29 |
* along with the program; if not, write to the Free Software |
| 30 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check |
| 31 |
* the file named COPYING. |
| 32 |
*) |
| 33 |
|
| 34 |
(* |
| 35 |
* This model establishes the symbolic information needed by streams |
| 36 |
* and holdups for the phases they contain, based on the information |
| 37 |
* with which the user parameterizes this model. |
| 38 |
*) |
| 39 |
|
| 40 |
MODEL phases_data( |
| 41 |
phase_indicator IS_A symbol_constant; |
| 42 |
vapor_option IS_A symbol_constant; |
| 43 |
liquid1_option IS_A symbol_constant; |
| 44 |
liquid2_option IS_A symbol_constant; |
| 45 |
) WHERE( |
| 46 |
(* The next 3 conditions limit to models supported in thermo.a4l. |
| 47 |
* as models for new correlations, solid phases, and so forth |
| 48 |
* are added to thermo.a4l, this should be expanded. |
| 49 |
*) |
| 50 |
(phase_indicator IN ['M','V','L','VL','LL','VLL']) == TRUE; |
| 51 |
(vapor_option IN |
| 52 |
['Pitzer_vapor_mixture','ideal_vapor_mixture','none']) == TRUE; |
| 53 |
(liquid1_option IN |
| 54 |
['Wilson_liquid_mixture', 'UNIFAC_liquid_mixture', 'none']) == TRUE; |
| 55 |
|
| 56 |
(* Note: The Wilson method cannot predict a second liquid phase *) |
| 57 |
((liquid1_option IN ['Wilson_liquid_mixture']) AND |
| 58 |
(phase_indicator IN ['LL','VLL'])) == FALSE; |
| 59 |
(liquid2_option IN ['UNIFAC_liquid_mixture', 'none']) == TRUE; |
| 60 |
|
| 61 |
(* not all combinations involving 'none' are legal. *) |
| 62 |
((phase_indicator == 'M') AND |
| 63 |
(vapor_option == 'none') AND |
| 64 |
(liquid1_option == 'none') AND (liquid2_option == 'none')) |
| 65 |
OR |
| 66 |
((phase_indicator == 'V') AND |
| 67 |
(liquid1_option == 'none') AND |
| 68 |
(liquid2_option == 'none')) |
| 69 |
OR |
| 70 |
((phase_indicator == 'L') AND |
| 71 |
(vapor_option == 'none') AND (liquid2_option == 'none')) |
| 72 |
OR |
| 73 |
((phase_indicator == 'VL') AND (liquid2_option == 'none')) |
| 74 |
OR |
| 75 |
((phase_indicator == 'LL') AND (vapor_option == 'none')) |
| 76 |
OR |
| 77 |
((phase_indicator == 'VLL') AND ( |
| 78 |
('none' IN [vapor_option,liquid1_option,liquid2_option]) == FALSE)) |
| 79 |
; |
| 80 |
(* |
| 81 |
*) |
| 82 |
|
| 83 |
(* Note: at present the thermodynamics models do not have |
| 84 |
* correlations that will support a complete LLE calculation, |
| 85 |
* so VLL is diabled until we get models that do. |
| 86 |
* If you create such models, remove the next condition. |
| 87 |
*) |
| 88 |
(phase_indicator IN ['LL','VLL']) == FALSE; |
| 89 |
); |
| 90 |
|
| 91 |
(* |
| 92 |
* typical examples of use -- |
| 93 |
* pd IS_A phases_data('M', 'none', 'none', 'none'); |
| 94 |
* pd IS_A phases_data('V', 'Pitzer_vapor_mixture', 'none', 'none'); |
| 95 |
* pd IS_A phases_data('VL', 'Pitzer_vapor_mixture', |
| 96 |
* 'Wilson_liquid_mixture','none'); |
| 97 |
* pd IS_A phases_data('VLL', 'Pitzer', 'UNIFAC_liquid_mixture', |
| 98 |
* 'UNIFAC_liquid_mixture'); |
| 99 |
*) |
| 100 |
|
| 101 |
phases IS_A set OF symbol_constant; |
| 102 |
reference_phase IS_A symbol_constant; |
| 103 |
|
| 104 |
SELECT (phase_indicator) |
| 105 |
CASE 'M': |
| 106 |
phases :== ['material']; |
| 107 |
reference_phase :== 'material'; |
| 108 |
CASE 'V': |
| 109 |
phases :== ['vapor']; |
| 110 |
reference_phase :== 'vapor'; |
| 111 |
CASE 'L': |
| 112 |
phases :== ['liquid1']; |
| 113 |
reference_phase :== 'liquid1'; |
| 114 |
CASE 'VL': |
| 115 |
phases :== ['vapor','liquid1']; |
| 116 |
reference_phase :== 'liquid1'; |
| 117 |
CASE 'LL': |
| 118 |
phases :== ['liquid1','liquid2']; |
| 119 |
reference_phase :== 'liquid1'; |
| 120 |
CASE 'VLL': |
| 121 |
phases :== ['vapor','liquid1','liquid2']; |
| 122 |
reference_phase :== 'liquid1'; |
| 123 |
END SELECT; |
| 124 |
|
| 125 |
phase_type[phases] IS_A symbol_constant; |
| 126 |
|
| 127 |
SELECT (phase_indicator) |
| 128 |
CASE 'M': |
| 129 |
phase_type['material'] :== vapor_option; |
| 130 |
CASE 'V': |
| 131 |
phase_type['vapor'] :== vapor_option; |
| 132 |
CASE 'L': |
| 133 |
phase_type['liquid1'] :== liquid1_option; |
| 134 |
CASE 'VL': |
| 135 |
phase_type['vapor'] :== vapor_option; |
| 136 |
phase_type['liquid1'] :== liquid1_option; |
| 137 |
CASE 'LL': |
| 138 |
phase_type['liquid1'] :== liquid1_option; |
| 139 |
phase_type['liquid2'] :== liquid2_option; |
| 140 |
CASE 'VLL': |
| 141 |
phase_type['vapor'] :== vapor_option; |
| 142 |
phase_type['liquid1'] :== liquid1_option; |
| 143 |
phase_type['liquid2'] :== liquid2_option; |
| 144 |
END SELECT; |
| 145 |
|
| 146 |
other_phases IS_A set OF symbol_constant; |
| 147 |
other_phases :== [phases - [reference_phase]]; |
| 148 |
|
| 149 |
METHODS |
| 150 |
(* No clear, specify, reset methods are needed here |
| 151 |
* as all items are constants. But we are setting a |
| 152 |
* rigorous example of how to MODEL, so here they are. |
| 153 |
*) |
| 154 |
|
| 155 |
METHOD check_self; |
| 156 |
END check_self; |
| 157 |
METHOD check_all; |
| 158 |
END check_all; |
| 159 |
METHOD default_self; |
| 160 |
END default_self; |
| 161 |
METHOD default_all; |
| 162 |
END default_all; |
| 163 |
METHOD specify; |
| 164 |
END specify; |
| 165 |
METHOD scale_self; |
| 166 |
END scale_self; |
| 167 |
METHOD scale_all; |
| 168 |
END scale_all; |
| 169 |
METHOD bound_self; |
| 170 |
END bound_self; |
| 171 |
METHOD bound_all; |
| 172 |
END bound_all; |
| 173 |
|
| 174 |
END phases_data; |
| 175 |
|
| 176 |
MODEL test_phases_data REFINES testcmumodel; |
| 177 |
(* the following 3 models should all build properly. *) |
| 178 |
pass1 IS_A phases_data('M', 'none', 'none', 'none'); |
| 179 |
pass2 IS_A phases_data('V', 'Pitzer_vapor_mixture', 'none', 'none'); |
| 180 |
pass3 IS_A phases_data('VL', 'Pitzer_vapor_mixture', |
| 181 |
'Wilson_liquid_mixture','none'); |
| 182 |
|
| 183 |
(* and the rest should fail *) |
| 184 |
fail4 IS_A phases_data('VLL', 'Pitzer_vapor_mixture', |
| 185 |
'UNIFAC_liquid_mixture', |
| 186 |
'UNIFAC_liquid_mixture'); |
| 187 |
fail5 IS_A phases_data('M', 'Pitzer_vapor_mixture', |
| 188 |
'UNIFAC_liquid_mixture', |
| 189 |
'UNIFAC_liquid_mixture'); |
| 190 |
fail6 IS_A phases_data('VL', 'Pitzer_vapor_mixture', |
| 191 |
'none', 'UNIFAC_liquid_mixture'); |
| 192 |
(* we really should put in all 20 or so other failures, but |
| 193 |
* it's tedious and pointless. |
| 194 |
*) |
| 195 |
|
| 196 |
METHODS |
| 197 |
(* for completeness *) |
| 198 |
METHOD values; |
| 199 |
(* everything is currently a constant, so nothing to do. *) |
| 200 |
END values; |
| 201 |
END test_phases_data; |