TomSym Chemical Equilibrium Problem
From TomWiki
Jump to navigationJump to search
This page is part of the TomSym Manual. See TomSym Manual. |
TomSym implementation of GAMS Example (CHEM,SEQ=21)
The problem is to find the equilibrium composition of a mixture of different atoms.
Bracken, J, and McCormick, G P, Chapter 5. In Selected Applications of Nonlinear Programming. John Wiley and Sons, New York, 1968, pp. 48-49.
c: compounds (H, H2, H2O, N, N2, NH, NO, O, O2, OH)
i: atoms (H hydrogen, N nitrogen, O oxygen)
% Parameters
% Atoms per compound
a = [1 2 2 0 0 1 0 0 0 1;
0 0 0 1 2 1 1 0 0 0;
0 0 1 0 0 0 1 1 2 1];
% Number of elements in mixture
h=2; n=1; o=1;
mix = [h n o]';
% Gibbs free energy at 3500 k and 750 psi
gibbs = [-10.021; -21.096; -37.986; -9.846; -28.653; ...
-18.918; -28.032; -14.640; -30.594; -26.11];
% Gibbs energy plus pressure
gplusp = gibbs + log(750*0.07031);
% Variables
% Number of mols in mixture
toms 10x1 x
% Component definition
eq1 = {};
for i=1:length(mix)
eq1 = {eq1; sum(a(i,:)*x) == mix(i)};
end
% Energy definition (xb = total number of mols in mixture)
xb = sum(x);
% Total free energy in mixture
energy = sum(x.*(gplusp + log((x)/xb)));
% Bounds on x and xb
cbnd = {0.001 <= x; 0.01 <= xb};
solution = ezsolve(energy,{eq1, cbnd});
Problem type appears to be: con Time for symbolic processing: 0.074995 seconds Starting numeric solver ===== * * * =================================================================== * * * TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31 ===================================================================================== Problem: --- 1: Problem 1 f_k -47.706514830836568000 sum(|constr|) 0.000000000000000666 f(x_k) + sum(|constr|) -47.706514830836568000 f(x_0) -0.209269531292347570 Solver: snopt. EXIT=0. INFORM=1. SNOPT 7.2-5 NLP code Optimality conditions satisfied FuncEv 26 GradEv 24 Iter 15 MinorIter 37 CPU time: 0.015600 sec. Elapsed time: 0.014000 sec.