38 const double*,
const double&,
43 const double*,
double*,
44 const double&,
double*,
48 const double&,
const double*,
49 const double*,
const double*,
50 const double&,
const double*,
52 double*,
const double&,
60 double&,
double*,
double*,
double&,
61 const octave_idx_type*,
const double*,
62 const double*, octave_idx_type&,
63 double*,
const octave_idx_type&,
64 octave_idx_type*,
const octave_idx_type&,
65 const double*,
const octave_idx_type*,
78 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
86 tmp_deriv.
elem (i) = deriv[i];
87 tmp_state.
elem (i) = state[i];
90 tmp_delta =
user_fun (tmp_state, tmp_deriv, time, ires);
94 if (tmp_delta.
length () == 0)
99 delta[i] = tmp_delta.
elem (i);
103 END_INTERRUPT_WITH_EXCEPTIONS;
113 const double *,
const double *,
const double&,
117 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
121 END_INTERRUPT_WITH_EXCEPTIONS;
131 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
140 tmp_deriv.
elem (i) = deriv[i];
141 tmp_state.
elem (i) = state[i];
148 pd[nn * j + i] = tmp_pd.
elem (i, j);
150 END_INTERRUPT_WITH_EXCEPTIONS;
199 if (res.
length () != x.length ())
201 (*current_liboctave_error_handler)
202 (
"daspk: inconsistent sizes for state and residual vectors");
210 (*current_liboctave_error_handler)
211 (
"daspk: no user supplied RHS subroutine!");
226 if (eiq == 1 || eiq == 3)
228 if (ccic == 1 || eavfet == 1)
231 lrw = 50 + 9*n + n*n;
246 if (abs_tol_len == 1 && rel_tol_len == 1)
250 else if (abs_tol_len == n && rel_tol_len == n)
256 (*current_liboctave_error_handler)
257 (
"daspk: inconsistent sizes for tolerance arrays");
284 if (maxord > 0 && maxord < 6)
291 (*current_liboctave_error_handler)
292 (
"daspk: invalid value for maximum order");
310 if (val < -2 || val > 2)
312 (*current_liboctave_error_handler)
313 (
"daspk: invalid value for inequality constraint type");
322 (*current_liboctave_error_handler)
323 (
"daspk: inequality constraint types size mismatch");
336 (*current_liboctave_error_handler)
337 (
"daspk: invalid value for enforce inequality constraints option");
353 if (eiq == 0 || eiq == 2)
355 else if (eiq == 1 || eiq == 3)
361 iwork(lid+i) = av(i) ? -1 : 1;
365 (*current_liboctave_error_handler)
366 (
"daspk: algebraic variables size mismatch");
373 (*current_liboctave_error_handler)
374 (
"daspk: invalid value for compute consistent initial condition option");
393 if (eiq == 0 || eiq == 2)
395 else if (eiq == 1 || eiq == 3)
401 iwork(lid+i) = av(i) ? -1 : 1;
421 (*current_liboctave_error_handler)
422 (
"daspk: invalid initial condition heuristics option");
440 (*current_liboctave_error_handler)
441 (
"daspk: invalid value for print initial condition info option");
520 (*current_liboctave_error_handler)
521 (
"unrecognized value of istate (= %d) returned from ddaspk",
544 if (n_out > 0 && n > 0)
547 xdot_out.
resize (n_out, n);
564 retval.
elem (j, i) = x_next.
elem (i);
589 if (n_out > 0 && n > 0)
592 xdot_out.
resize (n_out, n);
606 double next_crit = tcrit.
elem (0);
608 while (i_out < n_out)
610 bool do_restart =
false;
612 next_out = tout.
elem (i_out);
614 next_crit = tcrit.
elem (i_crit);
619 if (next_crit == next_out)
628 else if (next_crit < next_out)
663 retval.
elem (i_out-1, i) = x_next.
elem (i);
689 std::ostringstream buf;
691 std::string t_curr = buf.str ();
696 retval =
"a step was successfully taken in intermediate-output mode.";
700 retval =
"integration completed by stepping exactly to TOUT";
704 retval =
"integration to tout completed by stepping past TOUT";
708 retval =
"initial condition calculation completed successfully";
712 retval = std::string (
"a large amount of work has been expended (t =")
717 retval =
"the error tolerances are too stringent";
721 retval = std::string (
"error weight became zero during problem. (t = ")
723 +
"; solution component i vanished, and atol or atol(i) == 0)";
727 retval = std::string (
"repeated error test failures on the last attempted step (t = ")
732 retval = std::string (
"the corrector could not converge (t = ")
737 retval = std::string (
"the matrix of partial derivatives is singular (t = ")
742 retval = std::string (
"the corrector could not converge (t = ")
743 + t_curr +
"; repeated test failures)";
747 retval = std::string (
"corrector could not converge because IRES was -1 (t = ")
752 retval = std::string (
"return requested in user-supplied function (t = ")
757 retval =
"failed to compute consistent initial conditions";
761 retval = std::string (
"unrecoverable error encountered inside user's PSOL function (t = ")
766 retval = std::string (
"the Krylov linear system solver failed to converge (t = ")
771 retval =
"unrecoverable error (see printed message)";
775 retval =
"unknown error state";
Array< double > absolute_tolerance(void) const
static DAEFunc::DAERHSFunc user_fun
octave_idx_type size(void) const
static octave_idx_type ddaspk_f(const double &time, const double *state, const double *deriv, const double &, double *delta, octave_idx_type &ires, double *, octave_idx_type *)
ColumnVector do_integrate(double t)
Matrix integrate(const ColumnVector &tout, Matrix &xdot_out)
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
static uint32_t state[624]
static octave_idx_type nn
subroutine ddaspk(RES, NEQ, T, Y, YPRIME, TOUT, INFO, RTOL, ATOL, IDID, RWORK, LRW, IWORK, LIW, RPAR, IPAR, JAC, PSOL)
static DAEFunc::DAEJacFunc user_jac
DAERHSFunc function(void) const
octave_idx_type print_initial_condition_info(void) const
Matrix(* DAEJacFunc)(const ColumnVector &x, const ColumnVector &xdot, double t, double cj)
T & elem(octave_idx_type n)
static octave_idx_type ddaspk_psol(const octave_idx_type &, const double &, const double *, const double *, const double *, const double &, const double *, double *, octave_idx_type *, double *, const double &, octave_idx_type &, double *, octave_idx_type *)
octave_idx_type use_initial_condition_heuristics(void) const
#define F77_XFCN(f, F, args)
static octave_idx_type ddaspk_j(const double &time, const double *state, const double *deriv, double *pd, const double &cj, double *, octave_idx_type *)
DAEJacFunc jacobian_function(void) const
double maximum_step_size(void) const
Array< octave_idx_type > iwork
virtual void force_restart(void)
octave_idx_type(* daspk_fcn_ptr)(const double &, const double *, const double *, const double &, double *, octave_idx_type &, double *, octave_idx_type *)
void set_stop_time(double tt)
double initial_step_size(void) const
void resize(const dim_vector &dv, const T &rfv)
octave_idx_type maximum_order(void) const
Array< octave_idx_type > algebraic_variables(void) const
octave_idx_type capacity(void) const
Number of elements in the array.
octave_idx_type compute_consistent_initial_condition(void) const
octave_idx_type enforce_inequality_constraints(void) const
octave_idx_type exclude_algebraic_variables_from_error_test(void) const
Array< octave_idx_type > inequality_constraint_types(void) const
void clear_stop_time(void)
octave_idx_type length(void) const
Number of elements in the array.
std::string error_message(void) const
F77_RET_T F77_FUNC(ddaspk, DDASPK)(daspk_fcn_ptr
octave_idx_type(* daspk_jac_ptr)(const double &, const double *, const double *, double *, const double &, double *, octave_idx_type *)
Array< double > relative_tolerance(void) const
Array< octave_idx_type > info
ColumnVector(* DAERHSFunc)(const ColumnVector &x, const ColumnVector &xdot, double t, octave_idx_type &ires)
const T * fortran_vec(void) const
octave_idx_type NINTbig(double x)
Array< double > initial_condition_heuristics(void) const
octave_idx_type(* daspk_psol_ptr)(const octave_idx_type &, const double &, const double *, const double *, const double *, const double &, const double *, double *, octave_idx_type *, double *, const double &, octave_idx_type &, double *, octave_idx_type *)