REQUIRE "atoms.a4l";
(* => atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *)
PROVIDE "phaseq.a4c";
(*
* This file is part of the ASCEND Modeling Library and is released
* under the GNU Public License as described at the end of this file.
*
* Use of this module is demonstrated by the associated script file
* phaseq.a4s.
*)
(*
Ascend model of the phase Equilibrium example presented by Zaher
-- Conditional Modeling. Ph.D. Thesis, Carnegie Mellon University,
Pittsburgh, PA, 15213. 1995 --. The problem consists of a phase equilibrium
calculation of a multicomponent mixture. For each of the phases (3 phases
are possible: organic-liquid, inorganic-liquid, and vapor) there is a
disjunctive statement which represents whether the phase exists or not.
It represent a problem which we can represent as a conditional model and
solve with the ascend conditional solver CMSlv.
This model requires:
"system.a4l"
"atoms.a4l"
*)
(* ************************************************* *)
MODEL phaseq;
phases IS_A set OF symbol_constant;
components IS_A set OF symbol_constant;
k_terms IS_A set OF integer_constant;
z[components] IS_A fraction;
y[phases][components] IS_A fraction;
phi[phases] IS_A fraction;
exist[phases] IS_A boolean_var;
P IS_A pressure;
T IS_A temperature;
Pcr[components] IS_A critical_pressure;
Tcr[components] IS_A critical_temperature;
B[components][k_terms] IS_A factor_constant;
C[k_terms] IS_A factor_constant;
A[components][components] IS_A temperature_constant;
(* Definition os sets *)
components :== ['B','E','W'];
phases :== ['A','O','V'];
k_terms :== [1..4];
(* Boundaries *)
CONDITIONAL
FOR i IN phases CREATE
cond[i]: SUM[y[i][j] | j IN components ]+ phi[i] >= 1.0;
END FOR;
END CONDITIONAL;
FOR i IN phases CREATE
(* Variant Equations *)
sum[i]: SUM[y[i][j] | j IN components ] = 1.0;
frac[i]: phi[i] = 0.0;
exist[i] == SATISFIED(cond[i],1e-08);
(* Disjunctive statement *)
WHEN (exist[i])
CASE TRUE:
USE sum[i];
CASE FALSE:
USE frac[i];
END WHEN;
END FOR;
(* Invariant Equations *)
FOR i IN components CREATE
y['V'][i] = y['A'][i] * (Pcr[i]/P) * exp(
((1/T) *
SUM[ ( A[i][j] - (0.5*
SUM[ A[j][k] * y['A'][k] | k IN components]
) ) * y['A'][j]
| j IN components ]) +
((Tcr[i]/T) *
SUM[ B[i][k] * ( (1 - (T/Tcr[i]))^C[k] ) | k IN k_terms] ) );
y['V'][i] = y['O'][i] * (Pcr[i]/P) * exp(
((1/T) *
SUM[ ( A[i][j] - (0.5*
SUM[ A[j][k] * y['O'][k] | k IN components]
) ) * y['O'][j]
| j IN components ]) +
((Tcr[i]/T) *
SUM[ B[i][k] * ( (1 - (T/Tcr[i]))^C[k] ) | k IN k_terms] ) );
END FOR;
FOR i IN components CREATE
SUM[phi[j]*y[j][i] | j IN phases] = z[i];
END FOR;
(* Constants *)
Tcr['B'] :== 562.2 {K};
Tcr['E'] :== 516.2 {K};
Tcr['W'] :== 647.4 {K};
Pcr['B'] :== 48.3 {atm};
Pcr['E'] :== 63.0 {atm};
Pcr['W'] :== 217.6 {atm};
C[1] :== 1.0;
C[2] :== 1.5;
C[3] :== 3.0;
C[4] :== 6.0;
A['B']['B'] :== 0.0{K};
A['B']['E'] :== 576.3 {K};
A['B']['W'] :== 1074.5 {K};
A['E']['B'] :== 576.3 {K};
A['E']['E'] :== 0.0 {K};
A['E']['W'] :== 351.8 {K};
A['W']['B'] :== 1074.5 {K};
A['W']['E'] :== 351.8 {K};
A['W']['W'] :== 0.0 {K};
B['B'][1] :== -6.98273;
B['B'][2] :== 1.33213;
B['B'][3] :== -2.62863;
B['B'][4] :== -3.33399;
B['E'][1] :== -8.51838;
B['E'][2] :== 0.34163;
B['E'][3] :== -5.73683;
B['E'][4] :== 8.32581;
B['W'][1] :== -7.76451;
B['W'][2] :== 1.45838;
B['W'][3] :== -2.77580;
B['W'][4] :== -1.23303;
METHODS
METHOD default_self;
END default_self;
METHOD specify;
FIX P;
FIX T;
FOR i IN components DO
FIX z[i];
END FOR;
END specify;
METHOD values;
(* fixed *)
T := 340.0 {K};
P := 1.0 {atm};
z['B'] := 0.50;
z['E'] := 0.15;
z['W'] := 0.35;
(* initial values for reals *)
y['A']['B'] := 0.02;
y['A']['E'] := 0.03;
y['A']['W'] := 0.95;
y['O']['B'] := 0.95;
y['O']['E'] := 0.03;
y['O']['W'] := 0.02;
y['V']['B'] := 0.50;
y['V']['E'] := 0.15;
y['V']['W'] := 0.35;
phi['A'] := 0.0;
phi['O'] := 0.0;
phi['V'] := 0.0;
(* initial values for booleans *)
FOR i IN phases DO
exist[i] := SATISFIED(cond[i],1e-08);
END FOR;
END values;
END phaseq;
(*
* phaseq.a4c
* by Vicente Rico-Ramirez
* April 10, 1998
* Part of the ASCEND Library
* $Date: 1998/06/17 19:13:16 $
* $Revision: 1.3 $
* $Author: mthomas $
* $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/phaseq.a4c,v $
*
* This file is part of the ASCEND Modeling Library.
*
* Copyright (C) 1998 Carnegie Mellon University
*
* The ASCEND Modeling Library is free software; you can redistribute
* it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* The ASCEND Modeling Library is distributed in hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check
* the file named COPYING.
*)