% calcT0.m : The function CalcT0 takes the values given to it, applies them to
% the required equation and returns what the 'z' value is at this point
% with these values.
%
%
% Based on the function calc.m written by k.bryan this funtion uses a
% different formula and therefore returns different data. The time variable
% and DeltaGCat are unused in this function and therefore their respective
% values passed to this function will not influence the out come. Are left
% in the call for simplicity -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';
    DeltaHEq=ones(m1,1)*DeltaHEq';
    TEq=ones(m1,1)*TEq';
elseif m2>1
    DeltaGCat=ones(m1,1)*DeltaGCat';
    DeltaHEq=ones(m1,1)*DeltaHEq';
    TEq=ones(m1,1)*TEq';
    Temp=Temp*ones(1,m2);
end


% This is some calculation of values that are repeated in the main equation
A = exp(-1.*(DeltaGCat./(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)./D;

end

