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