function [ kappa1, kappa2, kappas, ...
    k1, k2, k3, k4, kd, ki, km, ...
    n, nud, num, nus, ...
    v1, v2, v3, v4, ... 
    t0, u0, tstop ] = circadian_parameters ( ...
    kappa1_user, kappa2_user, kappas_user, ...
    k1_user, k2_user, k3_user, k4_user, kd_user, ki_user, km_user, ...
    n, nud_user, num_user, nus_user, ...
    v1_user, v2_user, v3_user, v4_user, ... 
    t0_user, u0_user, tstop_user )

%*****************************************************************************80
%
%% circadian_parameters() returns parameters for circadian_ode().
%
%  Discussion:
%
%    If input values are specified, this resets the default parameters.
%    Otherwise, the output will be the current defaults.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 July 2026
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Albert Goldbeter,
%    A model for circadian oscillation in the Drosophilia period protein (PER),
%    Proceedings of the Royal Society of London, B,
%    Volume 261, pages 319-324, 1995.
%
%  Input:
%
%    real kappa1_user, kappa2_user, kappas_user,
%    k1_user, k2_user, k3_user, k4_user, kd_user, ki_user, km_user,
%    n, nud_user, num_user, nus_user,
%    v1_user, v2_user, v3_user, v4_user:
%    user requested values for problem parameters.
%
%    real t0_user: user requested values for the initial time.
%
%    real u0_user(5): user requested values for the initial condition.
%
%    real tstop_user: user requested values for the final time.
%
%  Output:
%
%    real kappa1, kappa2, kappas,
%    k1, k2, k3, k4, kd, ki, km,
%    n, nud, num, nus,
%    v1, v2, v3, v4:
%    current problem parameters.
%
%    real t0: the current initial time.
%
%    real u0(5): the current initial condition.
%
%    real tstop: the current final time.
%
  persistent kappa1_default;
  persistent kappa2_default;
  persistent kappas_default;
  persistent k1_default;
  persistent k2_default;
  persistent k3_default;
  persistent k4_default;
  persistent kd_default;
  persistent ki_default;
  persistent km_default;
  persistent n_default;
  persistent nud_default;
  persistent num_default;
  persistent nus_default;
  persistent v1_default;
  persistent v2_default;
  persistent v3_default;
  persistent v4_default;
  persistent t0_default;
  persistent u0_default;
  persistent tstop_default;
%
%  Initialize defaults.
%
  if ( isempty ( kappa1_default ) )
    kappa1_default = 1.9;
  end

  if ( isempty ( kappa2_default ) )
    kappa2_default = 1.3;
  end

  if ( isempty ( kappas_default ) )
    kappas_default = 0.38;
  end

  if ( isempty ( k1_default ) )
    k1_default = 2.0;
  end

  if ( isempty ( k2_default ) )
    k2_default = 2.0;
  end

  if ( isempty ( k3_default ) )
    k3_default = 2.0;
  end

  if ( isempty ( k4_default ) )
    k4_default = 2.0;
  end

  if ( isempty ( kd_default ) )
    kd_default = 0.2;
  end

  if ( isempty ( ki_default ) )
    ki_default = 1.0;
  end

  if ( isempty ( km_default ) )
    km_default = 0.5;
  end

  if ( isempty ( n_default ) )
    n_default = 4;
  end

  if ( isempty ( nud_default ) )
    nud_default = 0.95;
  end

  if ( isempty ( num_default ) )
    num_default = 0.65;
  end

  if ( isempty ( nus_default ) )
    nus_default = 0.76;
  end

  if ( isempty ( v1_default ) )
    v1_default = 3.2;
  end

  if ( isempty ( v2_default ) )
    v2_default = 1.58;
  end

  if ( isempty ( v3_default ) )
    v3_default = 5.0;
  end

  if ( isempty ( v4_default ) )
    v4_default = 2.5;
  end

  if ( isempty ( t0_default ) )
    t0_default = 0.0;
  end

  if ( isempty ( u0_default ) )
    u0_default = [ 0.5; 0.25; 0.25; 0.25; 1.00 ];
%   u0_default = [ 0.1; 0.25; 0.25; 0.25; 0.25 ]; % M/PN spirals in
%   u0_default = [ 1.9; 0.8; 0.8; 0.8; 0.8 ]; % M/PN spirals out
  end

  if ( isempty ( tstop_default ) )
    tstop_default = 72.0;
  end
%
%  Update defaults if input was supplied.
%
  if ( 1 <= nargin )
    kappa1_default = kappa1_user;
  end

  if ( 2 <= nargin )
    kappa2_default = kappa2_user;
  end

  if ( 3 <= nargin )
    kappas_default = kappas_user;
  end

  if ( 4 <= nargin )
    k1_default = k1_user;
  end

  if ( 5 <= nargin )
    k2_default = k2_user;
  end

  if ( 6 <= nargin )
    k3_default = k3_user;
  end

  if ( 7 <= nargin )
    k4_default = k4_user;
  end

  if ( 8 <= nargin )
    kd_default = kd_user;
  end

  if ( 9 <= nargin )
    ki_default = ki_user;
  end

  if ( 10 <= nargin )
    km_default = km_user;
  end

  if ( 11 <= nargin )
    n_default = n_user;
  end

  if ( 12 <= nargin )
    nud_default = nud_user;
  end

  if ( 13 <= nargin )
    num_default = num_user;
  end

  if ( 14 <= nargin )
    nus_default = nus_user;
  end

  if ( 15 <= nargin )
    v1_default = v1_user;
  end

  if ( 16 <= nargin )
    v2_default = v2_user;
  end

  if ( 17 <= nargin )
    v3_default = v3_user;
  end

  if ( 18 <= nargin )
    v4_default = v4_user;
  end

  if ( 19 <= nargin )
    t0_default = t0_user;
  end

  if ( 20 <= nargin )
    u0_default = u0_user;
  end

  if ( 21 <= nargin )
    tstop_default = tstop_user;
  end
%
%  Return values.
%
  kappa1 = kappa1_default;
  kappa2 = kappa2_default;
  kappas = kappas_default;
  k1 = k1_default;
  k2 = k2_default;
  k3 = k3_default;
  k4 = k4_default;
  kd = kd_default;
  ki = ki_default;
  km = km_default;
  n = n_default;
  nud = nud_default;
  num = num_default;
  nus = nus_default;
  v1 = v1_default;
  v2 = v2_default;
  v3 = v3_default;
  v4 = v4_default;
  t0 = t0_default;
  u0 = u0_default;
  tstop = tstop_default;
  
  return
end

