function R = nitr_rate_rev (a, time, c)

%NITR_RATE Function defining the change in 15R (the ratio of 15N to 14N) over time used to 
%calculate the nitrification rate in uM per hour given a time
%series of 15R in NO2 or NO3

%asantoro@whoi
%29 dec 2010

%UNKNOWNS (outputs)
%   a(1) = k, the rate constant in per hour
%   a(2) = Fin = nitrification rate in uM per hour

%DATA
%   time = time in hours

%KNOWNS (coefficients = inputs)
%   c(1) = AP15 = starting atom fraction 15NH4 (or 15NO2)
%   c(2) = No_15 = the starting 15N-NO3 in uM (or any receiving pool)
%   c(3) = No_14 = the starting 14N-NO3 in uM (or any receiving pool)


% modified 19 nov 2012 to include AP15 term in the denominator, aes
R = (c(2).*exp(-a(1).*time./1.005)+((a(2).*c(1))./(a(1)./1.005)).*(1-exp(-a(1).*time./1.005)))./((c(3).*exp(-a(1).*time)+((a(2).*(1-c(1)))./a(1)).*(1-exp(-a(1).*time))));

end


% Reference

% Santoro, A.E., Casciotti, K.L., and C.A. Francis (2010) Activity,
% abundance,and diversity of nitrifying archaea and bacteria in the central
% California Current.  Environmental Microbiology 12: 1989-2006.