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\
586 When called with no arguments, the names of all available options and\n\
587 their current values are displayed.\n\
588 Given one argument, return the value of the corresponding option.\n\
589 When called with two arguments, @code{daspk_options} set the option\n\
590 @var{opt} to value @var{val}.\n\
595 @item @qcode{\"absolute tolerance\"}\n\
596 Absolute tolerance. May be either vector or scalar. If a vector, it\n\
597 must match the dimension of the state vector, and the relative\n\
598 tolerance must also be a vector of the same length.\n\
600 @item @qcode{\"relative tolerance\"}\n\
601 Relative tolerance. May be either vector or scalar. If a vector, it\n\
602 must match the dimension of the state vector, and the absolute\n\
603 tolerance must also be a vector of the same length.\n\
605 The local error test applied at each integration step is\n\
609 abs (local error in x(i))\n\
610 <= rtol(i) * abs (Y(i)) + atol(i)\n\
614 @item @qcode{\"compute consistent initial condition\"}\n\
615 Denoting the differential variables in the state vector by @samp{Y_d}\n\
616 and the algebraic variables by @samp{Y_a}, @code{ddaspk} can solve\n\
617 one of two initialization problems:\n\
620 @item Given Y_d, calculate Y_a and Y'_d\n\
622 @item Given Y', calculate Y.\n\
625 In either case, initial values for the given components are input, and\n\
626 initial guesses for the unknown components must also be provided as\n\
627 input. Set this option to 1 to solve the first problem, or 2 to solve\n\
628 the second (the default is 0, so you must provide a set of\n\
629 initial conditions that are consistent).\n\
631 If this option is set to a nonzero value, you must also set the\n\
632 @qcode{\"algebraic variables\"} option to declare which variables in the\n\
633 problem are algebraic.\n\
635 @item @qcode{\"use initial condition heuristics\"}\n\
636 Set to a nonzero value to use the initial condition heuristics options\n\
639 @item @qcode{\"initial condition heuristics\"}\n\
640 A vector of the following parameters that can be used to control the\n\
641 initial condition calculation.\n\
645 Maximum number of Newton iterations (default is 5).\n\
648 Maximum number of Jacobian evaluations (default is 6).\n\
651 Maximum number of values of the artificial stepsize parameter to be\n\
652 tried if the @qcode{\"compute consistent initial condition\"} option has\n\
653 been set to 1 (default is 5).\n\
655 Note that the maximum total number of Newton iterations allowed is\n\
656 @code{MXNIT*MXNJ*MXNH} if the @qcode{\"compute consistent initial\n\
657 condition\"} option has been set to 1 and @code{MXNIT*MXNJ} if it is\n\
661 Set to a nonzero value to disable the linesearch algorithm (default is\n\
665 Minimum scaled step in linesearch algorithm (default is eps^(2/3)).\n\
668 Swing factor in the Newton iteration convergence test. The test is\n\
669 applied to the residual vector, premultiplied by the approximate\n\
670 Jacobian. For convergence, the weighted RMS norm of this vector\n\
671 (scaled by the error weights) must be less than @code{EPINIT*EPCON},\n\
672 where @code{EPCON} = 0.33 is the analogous test constant used in the\n\
673 time steps. The default is @code{EPINIT} = 0.01.\n\
676 @item @qcode{\"print initial condition info\"}\n\
677 Set this option to a nonzero value to display detailed information\n\
678 about the initial condition calculation (default is 0).\n\
680 @item @qcode{\"exclude algebraic variables from error test\"}\n\
681 Set to a nonzero value to exclude algebraic variables from the error\n\
682 test. You must also set the @qcode{\"algebraic variables\"} option to\n\
683 declare which variables in the problem are algebraic (default is 0).\n\
685 @item @qcode{\"algebraic variables\"}\n\
686 A vector of the same length as the state vector. A nonzero element\n\
687 indicates that the corresponding element of the state vector is an\n\
688 algebraic variable (i.e., its derivative does not appear explicitly\n\
689 in the equation set.\n\
691 This option is required by the\n\
692 @qcode{compute consistent initial condition\"} and\n\
693 @qcode{\"exclude algebraic variables from error test\"} options.\n\
695 @item @qcode{\"enforce inequality constraints\"}\n\
696 Set to one of the following values to enforce the inequality\n\
697 constraints specified by the @qcode{\"inequality constraint types\"}\n\
698 option (default is 0).\n\
701 @item To have constraint checking only in the initial condition calculation.\n\
703 @item To enforce constraint checking during the integration.\n\
705 @item To enforce both options 1 and 2.\n\
708 @item @qcode{\"inequality constraint types\"}\n\
709 A vector of the same length as the state specifying the type of\n\
710 inequality constraint. Each element of the vector corresponds to an\n\
711 element of the state and should be assigned one of the following\n\
719 Less than or equal to zero.\n\
725 Greater than or equal to zero.\n\
728 Greater than zero.\n\
731 This option only has an effect if the\n\
732 @qcode{\"enforce inequality constraints\"} option is nonzero.\n\
734 @item @qcode{\"initial step size\"}\n\
735 Differential-algebraic problems may occasionally suffer from severe\n\
736 scaling difficulties on the first step. If you know a great deal\n\
737 about the scaling of your problem, you can help to alleviate this\n\
738 problem by specifying an initial stepsize (default is computed\n\
741 @item @qcode{\"maximum order\"}\n\
742 Restrict the maximum order of the solution method. This option must\n\
743 be between 1 and 5, inclusive (default is 5).\n\
745 @item @qcode{\"maximum step size\"}\n\
746 Setting the maximum stepsize will avoid passing over very large\n\
747 regions (default is not specified).\n\
753 int nargin = args.
length ();
759 else if (nargin == 1 || nargin == 2)
761 std::string keyword = args(0).string_value ();
771 error (
"daspk_options: expecting keyword as first argument");