function diffusivity_1d_xk_test ( )

%*****************************************************************************80
%
%% diffusivity_1d_xk_test() tests diffusivity_1d_xk().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 March 2019
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Dongbin Xiu, George Karniadakis,
%    Modeling uncertainty in steady state diffusion problems via
%    generalized polynomial chaos,
%    Computer Methods in Applied Mechanics and Engineering,
%    Volume 191, 2002, pages 4927-4948.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'diffusivity_1d_xk_test\n' );
  fprintf ( 1, '  Test diffusivity_1d_xk.\n' );
%
%  Set the spatial grid.
%
  n = 51;
  x_min = -1.0;
  x_max = +1.0;
  x = linspace ( x_min, x_max, n );
%
%  Sample the OMEGA values.
%  Use a seed of 0 for the MATLAB random number generator.
%
  m = 5;
  omega = randn ( m, 1 );
%
%  Compute the diffusivity field.
%
  dc0 = 10.0;
  dc = diffusivity_1d_xk ( dc0, m, omega, n, x );
%
%  Plot the diffusivity field.
%
  figure ( )
  plot ( x, dc, 'LineWidth', 2 );
  grid on
  xlabel ( '<--- X --->', 'fontsize', 12 )
  ylabel ( '<--- \rho(X) --->', 'fontsize', 12 )
  title ( 'XK stochastic diffusivity function', 'Fontsize', 18 )

  dc_max = max ( dc );
  axis ( [ -1.0, +1.0, 0.0, dc_max ] )

  filename = 'diffusivity_1d_xk.png';
  print ( '-dpng', filename )
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Plot file stored as "%s".\n', filename );

  pause ( 5 );

  close ( );

  return
end
