26 #if defined (HAVE_CONFIG_H)
40 const double&,
double *,
F77_INT&,
double *,
44 double *,
const double&,
double *,
F77_INT *);
47 const double *,
const double *,
48 const double *,
const double&,
49 const double *,
double *,
F77_INT *,
50 double *,
const double&,
F77_INT&,
69 ddaspk_f (
const double&
time,
const double *state,
const double *deriv,
76 for (
F77_INT i = 0; i < nn; i++)
78 tmp_deriv.
elem (i) = deriv[i];
79 tmp_state.
elem (i) = state[i];
84 tmp_delta = user_fcn (tmp_state, tmp_deriv,
time, tmp_ires);
86 ires = octave::to_f77_int (tmp_ires);
94 for (
F77_INT i = 0; i < nn; i++)
95 delta[i] = tmp_delta.
elem (i);
106 ddaspk_psol (
const F77_INT&,
const double&,
const double *,
107 const double *,
const double *,
const double&,
108 const double *,
double *,
F77_INT *,
double *,
111 (*current_liboctave_error_handler) (
"daspk: PSOL is not implemented");
117 ddaspk_j (
const double&
time,
const double *state,
const double *deriv,
118 double *pd,
const double& cj,
double *,
F77_INT *)
125 for (
F77_INT i = 0; i < nn; i++)
127 tmp_deriv.
elem (i) = deriv[i];
128 tmp_state.
elem (i) = state[i];
131 Matrix tmp_pd = user_jac (tmp_state, tmp_deriv,
time, cj);
133 for (
F77_INT j = 0; j < nn; j++)
134 for (
F77_INT i = 0; i < nn; i++)
135 pd[nn * j + i] = tmp_pd.
elem (i, j);
152 m_initialized =
true;
156 for (
F77_INT i = 0; i < 20; i++)
187 (*current_liboctave_error_handler)
188 (
"daspk: inconsistent sizes for state and residual vectors");
197 (*current_liboctave_error_handler)
198 (
"daspk: no user supplied RHS subroutine!");
204 m_info(4) = (user_jac ? 1 : 0);
213 if (eiq == 1 || eiq == 3)
215 if (ccic == 1 || eavfet == 1)
218 m_lrw = 50 + 9*
n +
n*
n;
230 F77_INT abs_tol_len = octave::to_f77_int (m_abs_tol.
numel ());
231 F77_INT rel_tol_len = octave::to_f77_int (m_rel_tol.
numel ());
233 if (abs_tol_len == 1 && rel_tol_len == 1)
237 else if (abs_tol_len ==
n && rel_tol_len ==
n)
244 (*current_liboctave_error_handler)
245 (
"daspk: inconsistent sizes for tolerance arrays");
272 if (maxord > 0 && maxord < 6)
275 m_iwork(2) = octave::to_f77_int (maxord);
280 (*current_liboctave_error_handler)
281 (
"daspk: invalid value for maximum order");
300 F77_INT val = octave::to_f77_int (ict(i));
301 if (val < -2 || val > 2)
304 (*current_liboctave_error_handler)
305 (
"daspk: invalid value for inequality constraint type");
315 (*current_liboctave_error_handler)
316 (
"daspk: inequality constraint types size mismatch");
325 m_info(9) = octave::to_f77_int (eiq);
330 (*current_liboctave_error_handler)
331 (
"daspk: invalid value for enforce inequality constraints option");
349 if (eiq == 0 || eiq == 2)
351 else if (eiq == 1 || eiq == 3)
355 (
"daspk: invalid value for eiq: "
356 "%" OCTAVE_IDX_TYPE_FORMAT, eiq);
359 m_iwork(lid+i) = (av(i) ? -1 : 1);
364 (*current_liboctave_error_handler)
365 (
"daspk: algebraic variables size mismatch");
373 (*current_liboctave_error_handler)
374 (
"daspk: invalid value for compute consistent initial condition option");
379 m_info(10) = octave::to_f77_int (ccic);
395 if (eiq == 0 || eiq == 2)
397 else if (eiq == 1 || eiq == 3)
401 (
"daspk: invalid value for eiq: %" OCTAVE_IDX_TYPE_FORMAT,
405 m_iwork(lid+i) = (av(i) ? -1 : 1);
413 if (ich.
numel () == 6)
420 m_rwork(13) = ich(4);
421 m_rwork(14) = ich(5);
426 (*current_liboctave_error_handler)
427 (
"daspk: invalid initial condition heuristics option");
441 m_info(17) = octave::to_f77_int (pici);
446 (*current_liboctave_error_handler)
447 (
"daspk: invalid value for print initial condition info option");
469 double *dummy =
nullptr;
475 prel_tol, pabs_tol, tmp_istate, prwork, m_lrw,
476 piwork, m_liw, dummy, idummy, ddaspk_j,
530 (*current_liboctave_error_handler)
531 (
"unrecognized value of m_istate (= %" OCTAVE_IDX_TYPE_FORMAT
") "
554 if (n_out > 0 &&
n > 0)
574 retval.
elem (j, i) = x_next.
elem (i);
599 if (n_out > 0 &&
n > 0)
616 double next_crit = tcrit.
elem (0);
618 while (i_out < n_out)
620 bool do_restart =
false;
622 next_out = tout.
elem (i_out);
624 next_crit = tcrit.
elem (i_crit);
629 if (next_crit == next_out)
638 else if (next_crit < next_out)
673 retval.
elem (i_out-1, i) = x_next.
elem (i);
699 std::ostringstream buf;
701 std::string t_curr = buf.str ();
706 retval =
"a step was successfully taken in intermediate-output mode.";
710 retval =
"integration completed by stepping exactly to TOUT";
714 retval =
"integration to tout completed by stepping past TOUT";
718 retval =
"initial condition calculation completed successfully";
722 retval =
"a large amount of work has been expended (t =" + t_curr +
')';
726 retval =
"the error tolerances are too stringent";
730 retval =
"error weight became zero during problem. (t = " + t_curr +
731 "; solution component i vanished, and atol or atol(i) == 0)";
735 retval =
"repeated error test failures on the last attempted step (t = "
740 retval =
"the corrector could not converge (t = " + t_curr +
')';
744 retval =
"the matrix of partial derivatives is singular (t = " + t_curr +
749 retval =
"the corrector could not converge (t = " + t_curr +
750 "; repeated test failures)";
754 retval =
"corrector could not converge because IRES was -1 (t = "
759 retval =
"return requested in user-supplied function (t = " + t_curr +
764 retval =
"failed to compute consistent initial conditions";
768 retval =
"unrecoverable error encountered inside user's PSOL function (t = "
773 retval =
"the Krylov linear system solver failed to converge (t = "
778 retval =
"unrecoverable error (see printed message)";
782 retval =
"unknown error state";
F77_INT(* daspk_fcn_ptr)(const double &, const double *, const double *, const double &, double *, F77_INT &, double *, F77_INT *)
F77_RET_T F77_FUNC(ddaspk, DDASPK)(daspk_fcn_ptr
F77_INT(* daspk_psol_ptr)(const F77_INT &, const double &, const double *, const double *, const double *, const double &, const double *, double *, F77_INT *, double *, const double &, F77_INT &, double *, F77_INT *)
F77_INT(* daspk_jac_ptr)(const double &, const double *, const double *, double *, const double &, double *, F77_INT *)
T & elem(octave_idx_type n)
Size of the specified dimension.
T * fortran_vec()
Size of the specified dimension.
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
bool isempty() const
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
DAEJacFunc jacobian_function() const
Matrix(* DAEJacFunc)(const ColumnVector &x, const ColumnVector &xdot, double t, double cj)
DAERHSFunc function() const
ColumnVector(* DAERHSFunc)(const ColumnVector &x, const ColumnVector &xdot, double t, octave_idx_type &ires)
octave_idx_type enforce_inequality_constraints() const
double initial_step_size() const
octave_idx_type maximum_order() const
Array< double > absolute_tolerance() const
Array< octave_idx_type > inequality_constraint_types() const
octave_idx_type use_initial_condition_heuristics() const
octave_idx_type compute_consistent_initial_condition() const
double maximum_step_size() const
Array< octave_idx_type > algebraic_variables() const
Array< double > relative_tolerance() const
Array< double > initial_condition_heuristics() const
octave_idx_type exclude_algebraic_variables_from_error_test() const
octave_idx_type print_initial_condition_info() const
std::string error_message() const
Matrix integrate(const ColumnVector &tout, Matrix &xdot_out)
ColumnVector do_integrate(double t)
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
virtual void force_restart()
octave_idx_type size() const
void set_stop_time(double tt)
Vector representing the dimensions (size) of an Array.
subroutine ddaspk(RES, NEQ, T, Y, YPRIME, TOUT, INFO, RTOL, ATOL, IDID, RWORK, LRW, IWORK, LIW, RPAR, IPAR, JAC, PSOL)
#define F77_XFCN(f, F, args)
octave_f77_int_type F77_INT
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
F77_RET_T(F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, const F77_INT &, const F77_INT &, const F77_INT &, F77_INT &, F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, F77_DBLE *, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, F77_INT *, F77_INT &F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL)
octave_idx_type nint_big(double x)