32 #define NUM_OPTIONS 13
36 {
"absolute tolerance",
37 {
"absolute",
"tolerance", 0, 0, 0, 0, 0, },
38 { 2, 0, 0, 0, 0, 0, 0, }, 1, },
40 {
"relative tolerance",
41 {
"relative",
"tolerance", 0, 0, 0, 0, 0, },
42 { 1, 0, 0, 0, 0, 0, 0, }, 1, },
44 {
"compute consistent initial condition",
45 {
"compute",
"consistent",
"initial",
"condition", 0, 0, 0, },
46 { 1, 0, 0, 0, 0, 0, 0, }, 1, },
48 {
"use initial condition heuristics",
49 {
"use",
"initial",
"condition",
"heuristics", 0, 0, 0, },
50 { 1, 0, 0, 0, 0, 0, 0, }, 1, },
52 {
"initial condition heuristics",
53 {
"initial",
"condition",
"heuristics", 0, 0, 0, 0, },
54 { 3, 1, 0, 0, 0, 0, 0, }, 2, },
56 {
"print initial condition info",
57 {
"print",
"initial",
"condition",
"info", 0, 0, 0, },
58 { 1, 0, 0, 0, 0, 0, 0, }, 1, },
60 {
"exclude algebraic variables from error test",
61 {
"exclude",
"algebraic",
"variables",
"from",
"error",
"test", 0, },
62 { 2, 0, 0, 0, 0, 0, 0, }, 1, },
64 {
"algebraic variables",
65 {
"algebraic",
"variables", 0, 0, 0, 0, 0, },
66 { 2, 0, 0, 0, 0, 0, 0, }, 1, },
68 {
"enforce inequality constraints",
69 {
"enforce",
"inequality",
"constraints", 0, 0, 0, 0, },
70 { 2, 0, 0, 0, 0, 0, 0, }, 1, },
72 {
"inequality constraint types",
73 {
"inequality",
"constraint",
"types", 0, 0, 0, 0, },
74 { 3, 0, 0, 0, 0, 0, 0, }, 1, },
76 {
"initial step size",
77 {
"initial",
"step",
"size", 0, 0, 0, 0, },
78 { 3, 1, 0, 0, 0, 0, 0, }, 2, },
81 {
"maximum",
"order", 0, 0, 0, 0, 0, },
82 { 1, 1, 0, 0, 0, 0, 0, }, 2, },
84 {
"maximum step size",
85 {
"maximum",
"step",
"size", 0, 0, 0, 0, },
86 { 1, 1, 0, 0, 0, 0, 0, }, 2, },
92 std::ostringstream buf;
95 <<
"Options for DASPK include:\n\n"
97 <<
" ------- -----\n";
112 os << val(0) <<
"\n";
134 os << val(0) <<
"\n";
180 os << val(0) <<
"\n";
226 os << val(0) <<
"\n";
263 os << val(0) <<
"\n";
322 keyword, list[0].min_toks_to_match,
MAX_TOKENS))
330 keyword, list[1].min_toks_to_match,
MAX_TOKENS))
338 keyword, list[2].min_toks_to_match,
MAX_TOKENS))
346 keyword, list[3].min_toks_to_match,
MAX_TOKENS))
354 keyword, list[4].min_toks_to_match,
MAX_TOKENS))
362 keyword, list[5].min_toks_to_match,
MAX_TOKENS))
370 keyword, list[6].min_toks_to_match,
MAX_TOKENS))
378 keyword, list[7].min_toks_to_match,
MAX_TOKENS))
386 keyword, list[8].min_toks_to_match,
MAX_TOKENS))
394 keyword, list[9].min_toks_to_match,
MAX_TOKENS))
402 keyword, list[10].min_toks_to_match,
MAX_TOKENS))
410 keyword, list[11].min_toks_to_match,
MAX_TOKENS))
418 keyword, list[12].min_toks_to_match,
MAX_TOKENS))
427 warning (
"daspk_options: no match for `%s'", keyword.c_str ());
439 keyword, list[0].min_toks_to_match,
MAX_TOKENS))
453 keyword, list[1].min_toks_to_match,
MAX_TOKENS))
467 keyword, list[2].min_toks_to_match,
MAX_TOKENS))
471 retval =
static_cast<double> (val);
474 keyword, list[3].min_toks_to_match,
MAX_TOKENS))
478 retval =
static_cast<double> (val);
481 keyword, list[4].min_toks_to_match,
MAX_TOKENS))
495 keyword, list[5].min_toks_to_match,
MAX_TOKENS))
499 retval =
static_cast<double> (val);
502 keyword, list[6].min_toks_to_match,
MAX_TOKENS))
506 retval =
static_cast<double> (val);
509 keyword, list[7].min_toks_to_match,
MAX_TOKENS))
515 retval =
static_cast<double> (val(0));
527 keyword, list[8].min_toks_to_match,
MAX_TOKENS))
531 retval =
static_cast<double> (val);
534 keyword, list[9].min_toks_to_match,
MAX_TOKENS))
540 retval =
static_cast<double> (val(0));
552 keyword, list[10].min_toks_to_match,
MAX_TOKENS))
559 keyword, list[11].min_toks_to_match,
MAX_TOKENS))
563 retval =
static_cast<double> (val);
566 keyword, list[12].min_toks_to_match,
MAX_TOKENS))
574 warning (
"daspk_options: no match for `%s'", keyword.c_str ());
580 DEFUN (daspk_options, args, ,
582 @deftypefn {Built-in Function} {} daspk_options ()\n\
583 @deftypefnx {Built-in Function} {val =} daspk_options (@var{opt})\n\
584 @deftypefnx {Built-in Function} {} daspk_options (@var{opt}, @var{val})\n\
585 Query or set options for the function @code{daspk}.\n\
587 When called with no arguments, the names of all available options and\n\
588 their current values are displayed.\n\
590 Given one argument, return the value of the option @var{opt}.\n\
592 When called with two arguments, @code{daspk_options} sets the option\n\
593 @var{opt} to value @var{val}.\n\
598 @item @qcode{\"absolute tolerance\"}\n\
599 Absolute tolerance. May be either vector or scalar. If a vector, it\n\
600 must match the dimension of the state vector, and the relative\n\
601 tolerance must also be a vector of the same length.\n\
603 @item @qcode{\"relative tolerance\"}\n\
604 Relative tolerance. May be either vector or scalar. If a vector, it\n\
605 must match the dimension of the state vector, and the absolute\n\
606 tolerance must also be a vector of the same length.\n\
608 The local error test applied at each integration step is\n\
612 abs (local error in x(i))\n\
613 <= rtol(i) * abs (Y(i)) + atol(i)\n\
617 @item @qcode{\"compute consistent initial condition\"}\n\
618 Denoting the differential variables in the state vector by @samp{Y_d}\n\
619 and the algebraic variables by @samp{Y_a}, @code{ddaspk} can solve\n\
620 one of two initialization problems:\n\
623 @item Given Y_d, calculate Y_a and Y'_d\n\
625 @item Given Y', calculate Y.\n\
628 In either case, initial values for the given components are input, and\n\
629 initial guesses for the unknown components must also be provided as\n\
630 input. Set this option to 1 to solve the first problem, or 2 to solve\n\
631 the second (the default is 0, so you must provide a set of\n\
632 initial conditions that are consistent).\n\
634 If this option is set to a nonzero value, you must also set the\n\
635 @qcode{\"algebraic variables\"} option to declare which variables in the\n\
636 problem are algebraic.\n\
638 @item @qcode{\"use initial condition heuristics\"}\n\
639 Set to a nonzero value to use the initial condition heuristics options\n\
642 @item @qcode{\"initial condition heuristics\"}\n\
643 A vector of the following parameters that can be used to control the\n\
644 initial condition calculation.\n\
648 Maximum number of Newton iterations (default is 5).\n\
651 Maximum number of Jacobian evaluations (default is 6).\n\
654 Maximum number of values of the artificial stepsize parameter to be\n\
655 tried if the @qcode{\"compute consistent initial condition\"} option has\n\
656 been set to 1 (default is 5).\n\
658 Note that the maximum total number of Newton iterations allowed is\n\
659 @code{MXNIT*MXNJ*MXNH} if the @qcode{\"compute consistent initial\n\
660 condition\"} option has been set to 1 and @code{MXNIT*MXNJ} if it is\n\
664 Set to a nonzero value to disable the linesearch algorithm (default is\n\
668 Minimum scaled step in linesearch algorithm (default is eps^(2/3)).\n\
671 Swing factor in the Newton iteration convergence test. The test is\n\
672 applied to the residual vector, premultiplied by the approximate\n\
673 Jacobian. For convergence, the weighted RMS norm of this vector\n\
674 (scaled by the error weights) must be less than @code{EPINIT*EPCON},\n\
675 where @code{EPCON} = 0.33 is the analogous test constant used in the\n\
676 time steps. The default is @code{EPINIT} = 0.01.\n\
679 @item @qcode{\"print initial condition info\"}\n\
680 Set this option to a nonzero value to display detailed information\n\
681 about the initial condition calculation (default is 0).\n\
683 @item @qcode{\"exclude algebraic variables from error test\"}\n\
684 Set to a nonzero value to exclude algebraic variables from the error\n\
685 test. You must also set the @qcode{\"algebraic variables\"} option to\n\
686 declare which variables in the problem are algebraic (default is 0).\n\
688 @item @qcode{\"algebraic variables\"}\n\
689 A vector of the same length as the state vector. A nonzero element\n\
690 indicates that the corresponding element of the state vector is an\n\
691 algebraic variable (i.e., its derivative does not appear explicitly\n\
692 in the equation set).\n\
694 This option is required by the\n\
695 @qcode{\"compute consistent initial condition\"} and\n\
696 @qcode{\"exclude algebraic variables from error test\"} options.\n\
698 @item @qcode{\"enforce inequality constraints\"}\n\
699 Set to one of the following values to enforce the inequality\n\
700 constraints specified by the @qcode{\"inequality constraint types\"}\n\
701 option (default is 0).\n\
704 @item To have constraint checking only in the initial condition calculation.\n\
706 @item To enforce constraint checking during the integration.\n\
708 @item To enforce both options 1 and 2.\n\
711 @item @qcode{\"inequality constraint types\"}\n\
712 A vector of the same length as the state specifying the type of\n\
713 inequality constraint. Each element of the vector corresponds to an\n\
714 element of the state and should be assigned one of the following\n\
722 Less than or equal to zero.\n\
728 Greater than or equal to zero.\n\
731 Greater than zero.\n\
734 This option only has an effect if the\n\
735 @qcode{\"enforce inequality constraints\"} option is nonzero.\n\
737 @item @qcode{\"initial step size\"}\n\
738 Differential-algebraic problems may occasionally suffer from severe\n\
739 scaling difficulties on the first step. If you know a great deal\n\
740 about the scaling of your problem, you can help to alleviate this\n\
741 problem by specifying an initial stepsize (default is computed\n\
744 @item @qcode{\"maximum order\"}\n\
745 Restrict the maximum order of the solution method. This option must\n\
746 be between 1 and 5, inclusive (default is 5).\n\
748 @item @qcode{\"maximum step size\"}\n\
749 Setting the maximum stepsize will avoid passing over very large\n\
750 regions (default is not specified).\n\
756 int nargin = args.
length ();
762 else if (nargin == 1 || nargin == 2)
764 std::string keyword = args(0).string_value ();
774 error (
"daspk_options: expecting keyword as first argument");
Array< double > absolute_tolerance(void) const
OCTINTERP_API void print_usage(void)
void set_inequality_constraint_types(octave_idx_type val)
octave_idx_type length(void) const
int int_value(bool req_int=false, bool frc_str_conv=false) const
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
void set_print_initial_condition_info(octave_idx_type val)
octave_idx_type print_initial_condition_info(void) const
octave_idx_type use_initial_condition_heuristics(void) const
void set_algebraic_variables(int val)
static void set_DASPK_options(const std::string &keyword, const octave_value &val)
double maximum_step_size(void) const
void set_initial_step_size(double val)
void set_maximum_step_size(double val)
void set_absolute_tolerance(double val)
double initial_step_size(void) const
octave_idx_type maximum_order(void) const
void set_use_initial_condition_heuristics(octave_idx_type val)
Array< octave_idx_type > algebraic_variables(void) const
octave_idx_type compute_consistent_initial_condition(void) const
octave_idx_type enforce_inequality_constraints(void) const
int keyword_almost_match(const char *const *std, int *min_len, const std::string &s, int min_toks_to_match, int max_toks)
octave_idx_type exclude_algebraic_variables_from_error_test(void) const
Array< octave_idx_type > inequality_constraint_types(void) const
static DASPK_options_struct DASPK_options_table[]
static octave_value_list show_DASPK_options(const std::string &keyword)
void warning(const char *fmt,...)
Handles the reference counting for all the derived classes.
octave_idx_type length(void) const
Number of elements in the array.
void set_maximum_order(octave_idx_type val)
void set_enforce_inequality_constraints(octave_idx_type val)
Array< double > relative_tolerance(void) const
void octave_print_internal(std::ostream &, char, bool)
static void print_DASPK_options(std::ostream &os)
Array< double > vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
void set_relative_tolerance(double val)
Array< int > int_vector_value(bool req_int=false, bool frc_str_conv=false, bool frc_vec_conv=false) const
double double_value(bool frc_str_conv=false) const
static DASPK_options daspk_opts
void set_exclude_algebraic_variables_from_error_test(octave_idx_type val)
void set_initial_condition_heuristics(const Array< double > &val)
void set_compute_consistent_initial_condition(octave_idx_type val)
Array< double > initial_condition_heuristics(void) const