% function file dfdv

function df = dfdv(V,U)
global n kr EA R A1 A2 HR cp Feed ni
% U(1) = FSO2
% U(2) = FO2
% U(3) = FSO3
% U(4) = FN2
% U(5) = T
% dF(i)/dV = ni(i)*k(y(1)*sqrt(y(2))-y(3)/K)
% n = number of compounds
y = U(1:n)/sum(U(1:n)); % molar fractions
T = U(n+1);

k = kr .* exp (-EA./(R*T));
K = exp(A1 + A2./T);
rv = k .*(y(1).*sqrt(y(2)) - y(3) ./ K);

df(1:n) = ni(1:n) .* rv ; 
df(n+1) = rv .*(-HR)./(cp.*Feed);

df = df'; % transformation to column vector