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