% script to generate data over range of parameter values
% D = linspace(Dmin,Dmax,Dstep)
% K = linspace(Kmin,Kmax,Kstep)

Dmin = 1;
Dmax = 100;
Dstep = 20;
Kmin = 0.005;
Kmax = 0.1;
Kstep = 20;

D = linspace(Dmin,Dmax,Dstep);   % build range of D values
K = linspace(Kmin,Kmax,Kstep);   % build range of K values

for i = 1:Dstep
   for j = 1:Kstep
      [x,t,TM] = model2d(D(i),K(j)) % run model with prescribed parameter
      sTM = sum(TM,2);              % sum ALL methane (Head+Soil) in system 
      rr =  polyfit(t,log(sTM),1);  % exponential growth rate
      r(i,j) = rr(1);               % grab exp rate (r from e^(rt)) 
      mm =  polyfit(t,sTM,1);       % linear approx 
      m(i,j) = mm(1);               % slope from least squares fit
      save data1                    % store each iteration, in case of crash 
   end
   fprintf('Dstep = %i \n',i);
end 

