function dydt = ozone2_deriv ( t, y )

%*****************************************************************************80
%
%% ozone2_deriv() evaluates the derivative of the ozone2 ODE.
%
%  Discussion:
%
%    u1 = O
%    u2 = NO
%    u3 = NO2
%    u4 = O3
%    sigma = NO2 source term
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 January 2021
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Willem Hundsdorfer, Jan Verwer,
%    Numerical solution of time dependent advection-diffusion-reaction equations,
%    Springer, 2003,
%    ISBN13: 978-3-662-09017-6.
%
%  Input:
%
%    real T, Y(4): the arguments of the derivative.
%
%  Output:
%
%    real DYDT(4): the value of the derivative.
%
  k1 = ozone2_k1 ( t );
  [ k2, k3, sigma2, t0, y0, tstop ] = ozone2_parameters ( );

  y1 = y(1);
  y2 = y(2);
  y3 = y(3);
  y4 = y(4);

  dy1dt = + k1 * y3 - k2 * y1;
  dy2dt = + k1 * y3           - k3 * y2 * y4 + sigma2;
  dy3dt = - k1 * y3           + k3 * y2 * y4;
  dy4dt =           + k2 * y1 - k3 * y2 * y4;

  dydt = [ dy1dt; dy2dt; dy3dt; dy4dt ];

  return
end
