-
Notifications
You must be signed in to change notification settings - Fork 1
/
keq.m
26 lines (26 loc) · 1.32 KB
/
keq.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
% ________ ___ __ _____ ______
% |\ ____\|\ \|\ \ |\ _ \ _ \
% \ \ \___|\ \ \/ /|_ \ \ \\\__\ \ \
% \ \ \ \ \ ___ \ \ \ \\|__| \ \
% \ \ \____\ \ \\ \ \ __\ \ \ \ \ \
% \ \_______\ \__\\ \__\\__\ \__\ \ \__\
% \|_______|\|__| \|__\|__|\|__| \|__|
%
% Author: Andrea Somma;
% Politecnico of Milan
%
% keq calculated the equilibrium constant of a wanted reaction for ideal
% gas approximation
%
% - Keq=keq(T,species,coeff,data): where T is the temperature [K], species
% is the string vector of the species in the reaction, coeff is the
% vector of the corresponding stochiometric coefficients and data is
% the converted thermo matrix (see thConv or thRed).
%
function Keq=keq(T,species,coeff,data)
ckm = CKM;
R=8.314;
G=ckm.thProp(species,"G",T,data)';
DGR=coeff*G';
Keq=exp(-DGR/R/T);
end