(* ASCEND modelling environment Copyright (C) 1998, 2007 Carnegie Mellon University This program 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, or (at your option) any later version. This program is distributed in the 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 this program. If not, see . *) REQUIRE "atoms.a4l"; (* The following the conditional model is discussed in the PhD thesis of Vicente Rico-Ramirez, https://pse.cheme.cmu.edu/ascend/ftp/pdfThesis/victhesis.pdf Ascend model of the Rachford-Rice equation described by King, Separation Process. Chemical Engineering series. 2nd. Edition, McGraw-Hill, 77-79, 1980 The problem consists in a simple flash calculation performed by solving the Rachford-Rice equation. There is a disjunctive statement which extends the use of that equation for cases in which the system has only one phase (liquid or vapor). That is, this model not only copes with the liquid-vapor equilibrium case. The resulting system of equations can be solved with the ascend conditional solver CMSlv. by Vicente Rico-Ramirez, April 10, 1998 *) (* Components *) MODEL component_constants; Tc IS_A critical_temperature; Pc IS_A critical_pressure; vpa, vpb, vpc, vpd IS_A vapor_pressure_constant; END component_constants; MODEL n_butane REFINES component_constants; (*Constants *) Tc :== 425.2 {K}; Pc :== 38.0 {bar}; vpa :== -6.88709; vpb :== 1.15157; vpc :== -1.99873; vpd :== -3.13003; END n_butane; MODEL n_pentane REFINES component_constants; (*Constants *) Tc :== 469.7 {K}; Pc :== 33.7 {bar}; vpa :== -7.28936; vpb :== 1.53679; vpc :== -3.08367; vpd :== -1.02456; END n_pentane; MODEL n_hexane REFINES component_constants; (*Constants *) Tc :== 507.5 {K}; Pc :== 30.1 {bar}; vpa :== -7.46765; vpb :== 1.44211; vpc :== -3.28222; vpd :== -2.50941; END n_hexane; (* ************************************************* *) (* Flash calculation *) (* Rachford Rice calculation when P and T are specified *) MODEL rachford; components IS_A set OF integer_constant; comp[components] IS_A component_constants; VP[components] IS_A pressure; K[components] IS_A factor; z[components], x[components], y[components] IS_A fraction; V,F IS_A molar_rate; V_F IS_A factor; T IS_A temperature; P IS_A pressure; G IS_A factor; bol1,bol2 IS_A boolean_var; (* Component Data *) components :== [1..3]; comp[1] IS_REFINED_TO n_butane; comp[2] IS_REFINED_TO n_pentane; comp[3] IS_REFINED_TO n_hexane; (* Boundaries *) CONDITIONAL cond1: G <= 0.0; cond2: G <= 1.0; END CONDITIONAL; bol1 == SATISFIED(cond1,1e-08); bol2 == SATISFIED(cond2,1e-08); (* Variant Equations*) eq1: V_F = 0.0; eq2: V_F = G; eq3: V_F = 1.0; (* Disjunctive Statement*) WHEN (bol1,bol2) CASE TRUE,TRUE: USE eq1; CASE FALSE,TRUE: USE eq2; CASE FALSE,FALSE: USE eq3; OTHERWISE: END WHEN; (* Invariant Equations *) FOR i IN components CREATE (* Vapor pressure *) ln(VP[i]/comp[i].Pc)*T/comp[i].Tc*abs(comp[i].Tc - T) = (comp[i].vpa*abs(1.0 - T/comp[i].Tc) + (comp[i].vpb*abs(1.0 - T/comp[i].Tc)^1.5) + (comp[i].vpc*abs(1.0 - T/comp[i].Tc)^3.0) + (comp[i].vpd*abs(1.0 - T/comp[i].Tc)^6.0))*(comp[i].Tc - T); (* Equilibrium constant *) K[i] = VP[i] / P; END FOR; (* Rachford-Rice *) SUM[ ( z[i] * ( K[i] - 1 ) ) / ( ((K[i]-1)* V_F) + 1 ) | i IN components ] = G - V_F; FOR i IN components CREATE (* Liquid compositions *) x[i] = z[i] / ( ((K[i]-1)* V_F) + 1 ); (* Vapor compositions *) y[i] = ( K[i] * z[i] ) / ( ((K[i]-1)* V_F) + 1 ); END FOR; (* V/F *) V_F = V/F; METHODS METHOD default_self; END default_self; METHOD specify; FOR i IN components DO FIX z[i]; END FOR; FIX F; FIX P; FIX T; END specify; METHOD values; (* fixed values *) z[1] := 0.2; z[2] := 0.5; z[3] := 0.3; P := 10 {atm}; T := 405 {K}; (* It obtains results in the complete range 150 - 830 *) F:= 200 {lb_mole/hour}; (* initial guesses *) K[1] := 2; K[2] := 1; K[3] := 0.5; V := 100 {lb_mole/hour}; V_F:= 0.5; G := 0.5; END values; METHOD on_load; RUN default_self; RUN reset; RUN values; END on_load; METHOD self_test; (* no tests yet *) END self_test; END rachford;