function spring_sweep_ode_test ( )

%*****************************************************************************80
%
%% spring_sweep_ode_test: Parameter Sweep of an ODE
%
%  Discussion:
%
%    This is a parameter sweep study of a 2nd order ODE system.
%
%      m*x'' + b*x' + k*x = 0
%
%    We solve the ODE for a time span of 0 to 25 seconds, with initial
%    conditions X(0) = 0 and X'(0) = 1. We sweep the parameters "b" and "k"
%    and record the peak values of X for each condition. At the end, we plot a
%    surface of the results.
%
%    The results can be displayed by calling sweep_ode_display.m.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 February 2019
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../spring_sweep_ode' );

  timestamp ( )
  fprintf ( 1, '\n' );
  fprintf ( 1, 'spring_sweep_ode_test()\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Sweep through sets of values of parameters B and K,\n' );
  fprintf ( 1, '  computing the solution of the ODE corresponding to each set.\n' );
  fprintf ( 1, '  For each solution X(T), determine the maximum value over time.\n' );
  fprintf ( 1, '  Construct a contour plot of XMAX(B,K).\n' );
%
%  Initialization:
%
  bVals = 0.1 : 0.05 : 5;
  kVals = 1.5 : 0.05 : 5;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of K values = %d\n', length ( kVals ) );
  fprintf ( 1, '  Number of B values = %d\n', length ( bVals ) );
  fprintf ( 1, '  Number of times the ODE must be solved = %d\n', ...
    length ( kVals ) * length ( bVals ) );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Begin computation\n' );
%
%  Solve the ODE for every pair of K and B values and return the maximum
%  value over the time interval.
%
  peakVals = spring_sweep ( bVals, kVals );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Computation completed\n' );

  spring_peak_display ( bVals, kVals, peakVals );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'spring_sweep_ode_test\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( )

  rmpath ( '../spring_sweep_ode' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

