function out = objective_Ne_closure(t,ppmU,ppmTh)

% This returns Ne-21 concentration in quartz as a function of input 
% closure age, U, and Th. Syntax:
%
% out = objective_Ne_closure(t,ppmU,ppmTh);
% 
% Used for implicit solve for Ne closure age. 
% 
% Greg Balco, Berkeley Geochronology Center, 2018

% convert ppm to atoms

gUperg = ppmU*1e-6;
molUperg = gUperg./238.03;
mol235perg = molUperg./137.88;
mol238perg = molUperg - mol235perg;

gThperg = ppmTh*1e-6;
molThperg = gThperg./232;

% Alpha production. Note assumes Ft = 1 for etched quartz. 

l232 = -log(0.5)./1.405e10;
l235 = -log(0.5)./7.038e8;
l238 = -log(0.5)./4.468e9;

mola232perg = 6.*molThperg.*(exp(l232.*t) - 1);
mola235perg = 7.*mol235perg.*(exp(l235.*t) - 1);
mola238perg = 8.*mol238perg.*(exp(l238.*t) - 1);

% Convert alpha production to Ne-21 production
% Factors for Ne-21 per alpha from Cox and Farley, Table 6

molNe21 = mola232perg.*6.08e-8 + mola235perg.*5.62e-8 + mola238perg.*4.04e-8;

out = molNe21.*6.022e23;

