% calcV.m Based on the function calc.m written by k.bryan this funtion uses a
% formula for calculation of rate at a given value of time and temperature
% -DH
function value = calc(Temp,Time,DeltaGCat,DeltaGInact,DeltaHEq,TEq,E0,h,Kb,R)

[m1,n1]=size(Temp);
[m2,n2]=size(DeltaGCat);

%make arrays out of the values
if n1==m2
    DeltaGCat=ones(m1,1)*DeltaGCat';
    DeltaGInact=ones(m1,1)*DeltaGInact';
    DeltaHEq=ones(m1,1)*DeltaHEq';
    TEq=ones(m1,1)*TEq';
elseif m2>1
    DeltaGCat=ones(m1,1)*DeltaGCat';
    DeltaGInact=ones(m1,1)*DeltaGInact';
    DeltaHEq=ones(m1,1)*DeltaHEq';
    TEq=ones(m1,1)*TEq';
    Time=Time*ones(1,m2);
    Temp=Temp*ones(1,m2);
end

    
% This is some calculation of values that are repeated in the main equation
A = exp(-(DeltaGCat./(R.*Temp)));
B = exp(-(DeltaGInact./(R.*Temp)));
C = exp((DeltaHEq.*(1./TEq - 1./Temp))./R);
D = h.*(1+C);

% Main equation to calculate the value at the given point.
value = (Kb.*Temp.*A.*E0.*exp(-(Kb.*Temp.*B.*C.*Time)./D))./D;

end
