3912
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997, 2002 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
4066
|
23 #if defined (__GNUG__) && ! defined (NO_PRAGMA_INTERFACE_IMPLEMENTATION) |
3912
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
|
31 #include <cfloat> |
|
32 #include <cmath> |
|
33 |
|
34 #include "DASPK.h" |
|
35 #include "f77-fcn.h" |
|
36 #include "lo-error.h" |
4051
|
37 #include "lo-sstream.h" |
3912
|
38 |
|
39 typedef int (*daspk_fcn_ptr) (const double&, const double*, |
|
40 const double*, const double&, |
|
41 double*, int&, double*, int*); |
|
42 |
|
43 typedef int (*daspk_jac_ptr) (const double&, const double*, |
|
44 const double*, double*, |
|
45 const double&, double*, int*); |
|
46 |
|
47 typedef int (*daspk_psol_ptr) (const int&, const double&, |
|
48 const double*, const double*, |
|
49 const double*, const double&, |
|
50 const double*, double*, int*, |
|
51 double*, const double&, int&, |
|
52 double*, int*); |
|
53 |
|
54 extern "C" |
|
55 int F77_FUNC (ddaspk, DDASPK) (daspk_fcn_ptr, const int&, double&, |
|
56 double*, double*, double&, const int*, |
3998
|
57 const double*, const double*, int&, |
3912
|
58 double*, const int&, int*, const int&, |
|
59 const double*, const int*, |
|
60 daspk_jac_ptr, daspk_psol_ptr); |
|
61 |
|
62 static DAEFunc::DAERHSFunc user_fun; |
|
63 static DAEFunc::DAEJacFunc user_jac; |
|
64 static int nn; |
|
65 |
4049
|
66 static int |
3912
|
67 ddaspk_f (const double& time, const double *state, const double *deriv, |
|
68 const double&, double *delta, int& ires, double *, int *) |
|
69 { |
|
70 ColumnVector tmp_deriv (nn); |
|
71 ColumnVector tmp_state (nn); |
|
72 ColumnVector tmp_delta (nn); |
|
73 |
|
74 for (int i = 0; i < nn; i++) |
|
75 { |
|
76 tmp_deriv.elem (i) = deriv [i]; |
|
77 tmp_state.elem (i) = state [i]; |
|
78 } |
|
79 |
|
80 tmp_delta = user_fun (tmp_state, tmp_deriv, time, ires); |
|
81 |
|
82 if (ires >= 0) |
|
83 { |
|
84 if (tmp_delta.length () == 0) |
|
85 ires = -2; |
|
86 else |
|
87 { |
|
88 for (int i = 0; i < nn; i++) |
|
89 delta [i] = tmp_delta.elem (i); |
|
90 } |
|
91 } |
|
92 |
|
93 return 0; |
|
94 } |
|
95 |
|
96 //NEQ, T, Y, YPRIME, SAVR, WK, CJ, WGHT, |
|
97 //C WP, IWP, B, EPLIN, IER, RPAR, IPAR) |
|
98 |
4049
|
99 static int |
3912
|
100 ddaspk_psol (const int& neq, const double& time, const double *state, |
|
101 const double *deriv, const double *savr, |
|
102 const double& cj, const double *wght, double *wp, |
|
103 int *iwp, double *b, const double& eplin, int& ier, |
|
104 double *, int*) |
|
105 { |
|
106 abort (); |
3946
|
107 return 0; |
3912
|
108 } |
|
109 |
3991
|
110 |
4049
|
111 static int |
3991
|
112 ddaspk_j (const double& time, const double *state, const double *deriv, |
|
113 double *pd, const double& cj, double *, int *) |
3912
|
114 { |
3991
|
115 // XXX FIXME XXX -- would be nice to avoid copying the data. |
|
116 |
3912
|
117 ColumnVector tmp_state (nn); |
|
118 ColumnVector tmp_deriv (nn); |
|
119 |
3991
|
120 for (int i = 0; i < nn; i++) |
|
121 { |
|
122 tmp_deriv.elem (i) = deriv [i]; |
|
123 tmp_state.elem (i) = state [i]; |
|
124 } |
3912
|
125 |
3991
|
126 Matrix tmp_pd = user_jac (tmp_state, tmp_deriv, time, cj); |
3912
|
127 |
|
128 for (int j = 0; j < nn; j++) |
|
129 for (int i = 0; i < nn; i++) |
3991
|
130 pd [nn * j + i] = tmp_pd.elem (i, j); |
3912
|
131 |
|
132 return 0; |
|
133 } |
|
134 |
|
135 ColumnVector |
|
136 DASPK::do_integrate (double tout) |
|
137 { |
4047
|
138 // XXX FIXME XXX -- should handle all this option stuff just once |
|
139 // for each new problem. |
|
140 |
3912
|
141 ColumnVector retval; |
|
142 |
4049
|
143 if (! initialized || restart || DAEFunc::reset|| DASPK_options::reset) |
3912
|
144 { |
4049
|
145 integration_error = false; |
|
146 |
|
147 initialized = true; |
|
148 |
|
149 info.resize (20); |
3912
|
150 |
4049
|
151 for (int i = 0; i < 20; i++) |
|
152 info(i) = 0; |
|
153 |
|
154 pinfo = info.fortran_vec (); |
3912
|
155 |
4049
|
156 int n = size (); |
3912
|
157 |
4049
|
158 nn = n; |
|
159 |
|
160 info(0) = 0; |
3912
|
161 |
4049
|
162 if (stop_time_set) |
|
163 { |
|
164 rwork(0) = stop_time; |
|
165 info(3) = 1; |
|
166 } |
|
167 else |
|
168 info(3) = 0; |
3912
|
169 |
4049
|
170 px = x.fortran_vec (); |
|
171 pxdot = xdot.fortran_vec (); |
|
172 |
|
173 // DAEFunc |
|
174 |
|
175 user_fun = DAEFunc::function (); |
|
176 user_jac = DAEFunc::jacobian_function (); |
3912
|
177 |
4049
|
178 if (user_fun) |
|
179 { |
|
180 int ires = 0; |
3912
|
181 |
4049
|
182 ColumnVector res = (*user_fun) (x, xdot, t, ires); |
3912
|
183 |
4049
|
184 if (res.length () != x.length ()) |
|
185 { |
|
186 (*current_liboctave_error_handler) |
|
187 ("daspk: inconsistent sizes for state and residual vectors"); |
3912
|
188 |
4049
|
189 integration_error = true; |
|
190 return retval; |
|
191 } |
|
192 } |
|
193 else |
3912
|
194 { |
|
195 (*current_liboctave_error_handler) |
4049
|
196 ("daspk: no user supplied RHS subroutine!"); |
|
197 |
|
198 integration_error = true; |
|
199 return retval; |
|
200 } |
|
201 |
|
202 info(4) = user_jac ? 1 : 0; |
|
203 |
|
204 DAEFunc::reset = false; |
|
205 |
4144
|
206 int eiq = enforce_inequality_constraints (); |
|
207 int ccic = compute_consistent_initial_condition (); |
|
208 int eavfet = exclude_algebraic_variables_from_error_test (); |
|
209 |
|
210 liw = 40 + n; |
|
211 if (eiq == 1 || eiq == 3) |
|
212 liw += n; |
|
213 if (ccic == 1 || eavfet == 1) |
|
214 liw += n; |
|
215 |
|
216 lrw = 50 + 9*n; |
|
217 if (! user_jac) |
|
218 lrw += n*n; |
|
219 if (eavfet == 1) |
|
220 lrw += n; |
|
221 |
|
222 iwork.resize (liw); |
|
223 rwork.resize (lrw); |
|
224 |
|
225 piwork = iwork.fortran_vec (); |
|
226 prwork = rwork.fortran_vec (); |
|
227 |
4049
|
228 // DASPK_options |
|
229 |
4144
|
230 abs_tol = absolute_tolerance (); |
|
231 rel_tol = relative_tolerance (); |
4049
|
232 |
|
233 int abs_tol_len = abs_tol.length (); |
|
234 int rel_tol_len = rel_tol.length (); |
|
235 |
|
236 if (abs_tol_len == 1 && rel_tol_len == 1) |
|
237 { |
|
238 info(1) = 0; |
|
239 } |
|
240 else if (abs_tol_len == n && rel_tol_len == n) |
|
241 { |
|
242 info(1) = 1; |
|
243 } |
|
244 else |
|
245 { |
|
246 (*current_liboctave_error_handler) |
|
247 ("daspk: inconsistent sizes for tolerance arrays"); |
3912
|
248 |
3995
|
249 integration_error = true; |
3912
|
250 return retval; |
|
251 } |
|
252 |
4144
|
253 pabs_tol = abs_tol.fortran_vec (); |
|
254 prel_tol = rel_tol.fortran_vec (); |
|
255 |
4049
|
256 double hmax = maximum_step_size (); |
|
257 if (hmax >= 0.0) |
|
258 { |
|
259 rwork(1) = hmax; |
|
260 info(6) = 1; |
|
261 } |
|
262 else |
|
263 info(6) = 0; |
3998
|
264 |
4049
|
265 double h0 = initial_step_size (); |
|
266 if (h0 >= 0.0) |
4047
|
267 { |
4049
|
268 rwork(2) = h0; |
|
269 info(7) = 1; |
4047
|
270 } |
|
271 else |
4049
|
272 info(7) = 0; |
|
273 |
|
274 int maxord = maximum_order (); |
|
275 if (maxord >= 0) |
4047
|
276 { |
4049
|
277 if (maxord > 0 && maxord < 6) |
|
278 { |
|
279 info(8) = 1; |
|
280 iwork(2) = maxord; |
|
281 } |
|
282 else |
|
283 { |
|
284 (*current_liboctave_error_handler) |
|
285 ("daspk: invalid value for maximum order"); |
|
286 integration_error = true; |
|
287 return retval; |
|
288 } |
|
289 } |
|
290 |
|
291 switch (eiq) |
|
292 { |
|
293 case 1: |
|
294 case 3: |
|
295 { |
|
296 Array<int> ict = inequality_constraint_types (); |
|
297 |
|
298 if (ict.length () == n) |
|
299 { |
|
300 for (int i = 0; i < n; i++) |
|
301 { |
|
302 int val = ict(i); |
|
303 if (val < -2 || val > 2) |
|
304 { |
|
305 (*current_liboctave_error_handler) |
|
306 ("daspk: invalid value for inequality constraint type"); |
|
307 integration_error = true; |
|
308 return retval; |
|
309 } |
|
310 iwork(40+i) = val; |
|
311 } |
|
312 } |
|
313 else |
|
314 { |
|
315 (*current_liboctave_error_handler) |
|
316 ("daspk: inequality constraint types size mismatch"); |
|
317 integration_error = true; |
|
318 return retval; |
|
319 } |
|
320 } |
|
321 // Fall through... |
|
322 |
4144
|
323 case 0: |
4049
|
324 case 2: |
|
325 info(9) = eiq; |
|
326 break; |
|
327 |
|
328 default: |
4047
|
329 (*current_liboctave_error_handler) |
4049
|
330 ("daspk: invalid value for enforce inequality constraints option"); |
4047
|
331 integration_error = true; |
|
332 return retval; |
|
333 } |
4049
|
334 |
|
335 if (ccic) |
|
336 { |
|
337 if (ccic == 1) |
|
338 { |
|
339 // XXX FIXME XXX -- this code is duplicated below. |
|
340 |
|
341 Array<int> av = algebraic_variables (); |
4047
|
342 |
4049
|
343 if (av.length () == n) |
|
344 { |
|
345 int lid; |
|
346 if (eiq == 0 || eiq == 2) |
|
347 lid = 40; |
|
348 else if (eiq == 1 || eiq == 3) |
|
349 lid = 40 + n; |
|
350 else |
|
351 abort (); |
4047
|
352 |
4049
|
353 for (int i = 0; i < n; i++) |
|
354 iwork(lid+i) = av(i) ? -1 : 1; |
|
355 } |
|
356 else |
|
357 { |
|
358 (*current_liboctave_error_handler) |
|
359 ("daspk: algebraic variables size mismatch"); |
|
360 integration_error = true; |
|
361 return retval; |
|
362 } |
|
363 } |
|
364 else if (ccic != 2) |
|
365 { |
|
366 (*current_liboctave_error_handler) |
|
367 ("daspk: invalid value for compute consistent initial condition option"); |
|
368 integration_error = true; |
|
369 return retval; |
|
370 } |
4047
|
371 |
4049
|
372 info(10) = ccic; |
|
373 } |
4047
|
374 |
4049
|
375 if (eavfet) |
|
376 { |
|
377 info(15) = 1; |
4047
|
378 |
4049
|
379 // XXX FIXME XXX -- this code is duplicated above. |
4047
|
380 |
|
381 Array<int> av = algebraic_variables (); |
|
382 |
|
383 if (av.length () == n) |
|
384 { |
|
385 int lid; |
|
386 if (eiq == 0 || eiq == 2) |
|
387 lid = 40; |
|
388 else if (eiq == 1 || eiq == 3) |
|
389 lid = 40 + n; |
|
390 else |
|
391 abort (); |
|
392 |
|
393 for (int i = 0; i < n; i++) |
|
394 iwork(lid+i) = av(i) ? -1 : 1; |
|
395 } |
4049
|
396 } |
|
397 |
|
398 if (use_initial_condition_heuristics ()) |
|
399 { |
|
400 Array<double> ich = initial_condition_heuristics (); |
|
401 |
|
402 if (ich.length () == 6) |
|
403 { |
|
404 iwork(31) = NINT (ich(0)); |
|
405 iwork(32) = NINT (ich(1)); |
|
406 iwork(33) = NINT (ich(2)); |
|
407 iwork(34) = NINT (ich(3)); |
|
408 |
|
409 rwork(13) = ich(4); |
|
410 rwork(14) = ich(5); |
|
411 } |
4047
|
412 else |
|
413 { |
|
414 (*current_liboctave_error_handler) |
4049
|
415 ("daspk: invalid initial condition heuristics option"); |
4047
|
416 integration_error = true; |
|
417 return retval; |
|
418 } |
4049
|
419 |
|
420 info(16) = 1; |
4047
|
421 } |
4049
|
422 |
|
423 int pici = print_initial_condition_info (); |
|
424 switch (pici) |
4047
|
425 { |
4049
|
426 case 0: |
|
427 case 1: |
|
428 case 2: |
|
429 info(17) = pici; |
|
430 break; |
|
431 |
|
432 default: |
4047
|
433 (*current_liboctave_error_handler) |
4049
|
434 ("daspk: invalid value for print initial condition info option"); |
4047
|
435 integration_error = true; |
|
436 return retval; |
4049
|
437 break; |
4047
|
438 } |
|
439 |
4049
|
440 DASPK_options::reset = false; |
4047
|
441 |
4049
|
442 restart = false; |
4047
|
443 } |
|
444 |
4049
|
445 static double *dummy = 0; |
|
446 static int *idummy = 0; |
4047
|
447 |
4049
|
448 F77_XFCN (ddaspk, DDASPK, (ddaspk_f, nn, t, px, pxdot, tout, pinfo, |
3998
|
449 prel_tol, pabs_tol, istate, prwork, lrw, |
3912
|
450 piwork, liw, dummy, idummy, ddaspk_j, |
|
451 ddaspk_psol)); |
|
452 |
|
453 if (f77_exception_encountered) |
|
454 { |
3995
|
455 integration_error = true; |
3912
|
456 (*current_liboctave_error_handler) ("unrecoverable error in daspk"); |
|
457 } |
|
458 else |
|
459 { |
3997
|
460 switch (istate) |
3912
|
461 { |
|
462 case 1: // A step was successfully taken in intermediate-output |
|
463 // mode. The code has not yet reached TOUT. |
|
464 case 2: // The integration to TSTOP was successfully completed |
|
465 // (T=TSTOP) by stepping exactly to TSTOP. |
|
466 case 3: // The integration to TOUT was successfully completed |
|
467 // (T=TOUT) by stepping past TOUT. Y(*) is obtained by |
|
468 // interpolation. YPRIME(*) is obtained by interpolation. |
3996
|
469 case 4: // The initial condition calculation, with |
|
470 // INFO(11) > 0, was successful, and INFO(14) = 1. |
|
471 // No integration steps were taken, and the solution |
|
472 // is not considered to have been started. |
3912
|
473 retval = x; |
|
474 t = tout; |
|
475 break; |
|
476 |
|
477 case -1: // A large amount of work has been expended. (~500 steps). |
|
478 case -2: // The error tolerances are too stringent. |
|
479 case -3: // The local error test cannot be satisfied because you |
|
480 // specified a zero component in ATOL and the |
|
481 // corresponding computed solution component is zero. |
|
482 // Thus, a pure relative error test is impossible for |
|
483 // this component. |
|
484 case -6: // DDASPK had repeated error test failures on the last |
|
485 // attempted step. |
|
486 case -7: // The corrector could not converge. |
|
487 case -8: // The matrix of partial derivatives is singular. |
|
488 case -9: // The corrector could not converge. There were repeated |
|
489 // error test failures in this step. |
|
490 case -10: // The corrector could not converge because IRES was |
|
491 // equal to minus one. |
|
492 case -11: // IRES equal to -2 was encountered and control is being |
|
493 // returned to the calling program. |
|
494 case -12: // DDASPK failed to compute the initial YPRIME. |
3996
|
495 case -13: // Unrecoverable error encountered inside user's |
|
496 // PSOL routine, and control is being returned to |
|
497 // the calling program. |
|
498 case -14: // The Krylov linear system solver could not |
|
499 // achieve convergence. |
3912
|
500 case -33: // The code has encountered trouble from which it cannot |
|
501 // recover. A message is printed explaining the trouble |
|
502 // and control is returned to the calling program. For |
|
503 // example, this occurs when invalid input is detected. |
3996
|
504 integration_error = true; |
|
505 break; |
|
506 |
3912
|
507 default: |
3995
|
508 integration_error = true; |
3996
|
509 (*current_liboctave_error_handler) |
3997
|
510 ("unrecognized value of istate (= %d) returned from ddaspk", |
|
511 istate); |
3912
|
512 break; |
|
513 } |
|
514 } |
|
515 |
|
516 return retval; |
|
517 } |
|
518 |
|
519 Matrix |
|
520 DASPK::do_integrate (const ColumnVector& tout) |
|
521 { |
|
522 Matrix dummy; |
|
523 return integrate (tout, dummy); |
|
524 } |
|
525 |
|
526 Matrix |
|
527 DASPK::integrate (const ColumnVector& tout, Matrix& xdot_out) |
|
528 { |
|
529 Matrix retval; |
4049
|
530 |
3912
|
531 int n_out = tout.capacity (); |
4049
|
532 int n = size (); |
3912
|
533 |
|
534 if (n_out > 0 && n > 0) |
|
535 { |
|
536 retval.resize (n_out, n); |
|
537 xdot_out.resize (n_out, n); |
|
538 |
|
539 for (int i = 0; i < n; i++) |
|
540 { |
|
541 retval.elem (0, i) = x.elem (i); |
|
542 xdot_out.elem (0, i) = xdot.elem (i); |
|
543 } |
|
544 |
|
545 for (int j = 1; j < n_out; j++) |
|
546 { |
|
547 ColumnVector x_next = do_integrate (tout.elem (j)); |
|
548 |
|
549 if (integration_error) |
|
550 return retval; |
|
551 |
|
552 for (int i = 0; i < n; i++) |
|
553 { |
|
554 retval.elem (j, i) = x_next.elem (i); |
|
555 xdot_out.elem (j, i) = xdot.elem (i); |
|
556 } |
|
557 } |
|
558 } |
|
559 |
|
560 return retval; |
|
561 } |
|
562 |
|
563 Matrix |
|
564 DASPK::do_integrate (const ColumnVector& tout, const ColumnVector& tcrit) |
|
565 { |
|
566 Matrix dummy; |
|
567 return integrate (tout, dummy, tcrit); |
|
568 } |
|
569 |
|
570 Matrix |
|
571 DASPK::integrate (const ColumnVector& tout, Matrix& xdot_out, |
|
572 const ColumnVector& tcrit) |
|
573 { |
|
574 Matrix retval; |
4049
|
575 |
3912
|
576 int n_out = tout.capacity (); |
4049
|
577 int n = size (); |
3912
|
578 |
|
579 if (n_out > 0 && n > 0) |
|
580 { |
|
581 retval.resize (n_out, n); |
|
582 xdot_out.resize (n_out, n); |
|
583 |
|
584 for (int i = 0; i < n; i++) |
|
585 { |
|
586 retval.elem (0, i) = x.elem (i); |
|
587 xdot_out.elem (0, i) = xdot.elem (i); |
|
588 } |
|
589 |
|
590 int n_crit = tcrit.capacity (); |
|
591 |
|
592 if (n_crit > 0) |
|
593 { |
|
594 int i_crit = 0; |
|
595 int i_out = 1; |
|
596 double next_crit = tcrit.elem (0); |
|
597 double next_out; |
|
598 while (i_out < n_out) |
|
599 { |
|
600 bool do_restart = false; |
|
601 |
|
602 next_out = tout.elem (i_out); |
|
603 if (i_crit < n_crit) |
|
604 next_crit = tcrit.elem (i_crit); |
|
605 |
|
606 bool save_output; |
|
607 double t_out; |
|
608 |
|
609 if (next_crit == next_out) |
|
610 { |
|
611 set_stop_time (next_crit); |
|
612 t_out = next_out; |
|
613 save_output = true; |
|
614 i_out++; |
|
615 i_crit++; |
|
616 do_restart = true; |
|
617 } |
|
618 else if (next_crit < next_out) |
|
619 { |
|
620 if (i_crit < n_crit) |
|
621 { |
|
622 set_stop_time (next_crit); |
|
623 t_out = next_crit; |
|
624 save_output = false; |
|
625 i_crit++; |
|
626 do_restart = true; |
|
627 } |
|
628 else |
|
629 { |
|
630 clear_stop_time (); |
|
631 t_out = next_out; |
|
632 save_output = true; |
|
633 i_out++; |
|
634 } |
|
635 } |
|
636 else |
|
637 { |
|
638 set_stop_time (next_crit); |
|
639 t_out = next_out; |
|
640 save_output = true; |
|
641 i_out++; |
|
642 } |
|
643 |
|
644 ColumnVector x_next = do_integrate (t_out); |
|
645 |
|
646 if (integration_error) |
|
647 return retval; |
|
648 |
|
649 if (save_output) |
|
650 { |
|
651 for (int i = 0; i < n; i++) |
|
652 { |
|
653 retval.elem (i_out-1, i) = x_next.elem (i); |
|
654 xdot_out.elem (i_out-1, i) = xdot.elem (i); |
|
655 } |
|
656 } |
|
657 |
|
658 if (do_restart) |
|
659 force_restart (); |
|
660 } |
|
661 } |
|
662 else |
|
663 { |
|
664 retval = integrate (tout, xdot_out); |
|
665 |
|
666 if (integration_error) |
|
667 return retval; |
|
668 } |
|
669 } |
|
670 |
|
671 return retval; |
|
672 } |
|
673 |
3995
|
674 std::string |
|
675 DASPK::error_message (void) const |
|
676 { |
|
677 std::string retval; |
|
678 |
4051
|
679 OSSTREAM buf; |
|
680 buf << t << OSSTREAM_ENDS; |
|
681 std::string t_curr = OSSTREAM_STR (buf); |
|
682 OSSTREAM_FREEZE (buf); |
4043
|
683 |
3997
|
684 switch (istate) |
3995
|
685 { |
3996
|
686 case 1: |
|
687 retval = "a step was successfully taken in intermediate-output mode."; |
|
688 break; |
|
689 |
|
690 case 2: |
|
691 retval = "integration completed by stepping exactly to TOUT"; |
|
692 break; |
|
693 |
|
694 case 3: |
|
695 retval = "integration to tout completed by stepping past TOUT"; |
|
696 break; |
|
697 |
|
698 case 4: |
|
699 retval = "initial condition calculation completed successfully"; |
|
700 break; |
|
701 |
|
702 case -1: |
4043
|
703 retval = std::string ("a large amount of work has been expended (t =") |
|
704 + t_curr + ")"; |
3996
|
705 break; |
|
706 |
|
707 case -2: |
|
708 retval = "the error tolerances are too stringent"; |
|
709 break; |
|
710 |
|
711 case -3: |
4043
|
712 retval = std::string ("error weight became zero during problem. (t = ") |
|
713 + t_curr |
|
714 + "; solution component i vanished, and atol or atol(i) == 0)"; |
3996
|
715 break; |
|
716 |
|
717 case -6: |
4043
|
718 retval = std::string ("repeated error test failures on the last attempted step (t = ") |
|
719 + t_curr + ")"; |
3996
|
720 break; |
|
721 |
|
722 case -7: |
4043
|
723 retval = std::string ("the corrector could not converge (t = ") |
|
724 + t_curr + ")"; |
3996
|
725 break; |
|
726 |
|
727 case -8: |
4043
|
728 retval = std::string ("the matrix of partial derivatives is singular (t = ") |
|
729 + t_curr + ")"; |
3996
|
730 break; |
|
731 |
|
732 case -9: |
4043
|
733 retval = std::string ("the corrector could not converge (t = ") |
|
734 + t_curr + "; repeated test failures)"; |
3996
|
735 break; |
|
736 |
|
737 case -10: |
4043
|
738 retval = std::string ("corrector could not converge because IRES was -1 (t = ") |
|
739 + t_curr + ")"; |
3996
|
740 break; |
|
741 |
|
742 case -11: |
4043
|
743 retval = std::string ("return requested in user-supplied function (t = ") |
|
744 + t_curr + ")"; |
3996
|
745 break; |
|
746 |
|
747 case -12: |
|
748 retval = "failed to compute consistent initial conditions"; |
|
749 break; |
|
750 |
|
751 case -13: |
4043
|
752 retval = std::string ("unrecoverable error encountered inside user's PSOL function (t = ") |
|
753 + t_curr + ")"; |
3996
|
754 break; |
|
755 |
|
756 case -14: |
4043
|
757 retval = std::string ("the Krylov linear system solver failed to converge (t = ") |
|
758 + t_curr + ")"; |
3996
|
759 break; |
|
760 |
|
761 case -33: |
|
762 retval = "unrecoverable error (see printed message)"; |
|
763 break; |
|
764 |
3995
|
765 default: |
|
766 retval = "unknown error state"; |
|
767 break; |
|
768 } |
|
769 |
|
770 return retval; |
|
771 } |
|
772 |
3912
|
773 /* |
|
774 ;;; Local Variables: *** |
|
775 ;;; mode: C++ *** |
|
776 ;;; End: *** |
|
777 */ |