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 |
4842
|
232 lrw = 50 + 9*n + n*n; |
4144
|
233 if (eavfet == 1) |
|
234 lrw += n; |
|
235 |
|
236 iwork.resize (liw); |
|
237 rwork.resize (lrw); |
|
238 |
|
239 piwork = iwork.fortran_vec (); |
|
240 prwork = rwork.fortran_vec (); |
|
241 |
4049
|
242 // DASPK_options |
|
243 |
4144
|
244 abs_tol = absolute_tolerance (); |
|
245 rel_tol = relative_tolerance (); |
4049
|
246 |
|
247 int abs_tol_len = abs_tol.length (); |
|
248 int rel_tol_len = rel_tol.length (); |
|
249 |
|
250 if (abs_tol_len == 1 && rel_tol_len == 1) |
|
251 { |
|
252 info(1) = 0; |
|
253 } |
|
254 else if (abs_tol_len == n && rel_tol_len == n) |
|
255 { |
|
256 info(1) = 1; |
|
257 } |
|
258 else |
|
259 { |
|
260 (*current_liboctave_error_handler) |
|
261 ("daspk: inconsistent sizes for tolerance arrays"); |
3912
|
262 |
3995
|
263 integration_error = true; |
3912
|
264 return retval; |
|
265 } |
|
266 |
4144
|
267 pabs_tol = abs_tol.fortran_vec (); |
|
268 prel_tol = rel_tol.fortran_vec (); |
|
269 |
4049
|
270 double hmax = maximum_step_size (); |
|
271 if (hmax >= 0.0) |
|
272 { |
|
273 rwork(1) = hmax; |
|
274 info(6) = 1; |
|
275 } |
|
276 else |
|
277 info(6) = 0; |
3998
|
278 |
4049
|
279 double h0 = initial_step_size (); |
|
280 if (h0 >= 0.0) |
4047
|
281 { |
4049
|
282 rwork(2) = h0; |
|
283 info(7) = 1; |
4047
|
284 } |
|
285 else |
4049
|
286 info(7) = 0; |
|
287 |
|
288 int maxord = maximum_order (); |
|
289 if (maxord >= 0) |
4047
|
290 { |
4049
|
291 if (maxord > 0 && maxord < 6) |
|
292 { |
|
293 info(8) = 1; |
|
294 iwork(2) = maxord; |
|
295 } |
|
296 else |
|
297 { |
|
298 (*current_liboctave_error_handler) |
|
299 ("daspk: invalid value for maximum order"); |
|
300 integration_error = true; |
|
301 return retval; |
|
302 } |
|
303 } |
|
304 |
|
305 switch (eiq) |
|
306 { |
|
307 case 1: |
|
308 case 3: |
|
309 { |
|
310 Array<int> ict = inequality_constraint_types (); |
|
311 |
|
312 if (ict.length () == n) |
|
313 { |
|
314 for (int i = 0; i < n; i++) |
|
315 { |
|
316 int val = ict(i); |
|
317 if (val < -2 || val > 2) |
|
318 { |
|
319 (*current_liboctave_error_handler) |
|
320 ("daspk: invalid value for inequality constraint type"); |
|
321 integration_error = true; |
|
322 return retval; |
|
323 } |
|
324 iwork(40+i) = val; |
|
325 } |
|
326 } |
|
327 else |
|
328 { |
|
329 (*current_liboctave_error_handler) |
|
330 ("daspk: inequality constraint types size mismatch"); |
|
331 integration_error = true; |
|
332 return retval; |
|
333 } |
|
334 } |
|
335 // Fall through... |
|
336 |
4144
|
337 case 0: |
4049
|
338 case 2: |
|
339 info(9) = eiq; |
|
340 break; |
|
341 |
|
342 default: |
4047
|
343 (*current_liboctave_error_handler) |
4049
|
344 ("daspk: invalid value for enforce inequality constraints option"); |
4047
|
345 integration_error = true; |
|
346 return retval; |
|
347 } |
4049
|
348 |
|
349 if (ccic) |
|
350 { |
|
351 if (ccic == 1) |
|
352 { |
|
353 // XXX FIXME XXX -- this code is duplicated below. |
|
354 |
|
355 Array<int> av = algebraic_variables (); |
4047
|
356 |
4049
|
357 if (av.length () == n) |
|
358 { |
|
359 int lid; |
|
360 if (eiq == 0 || eiq == 2) |
|
361 lid = 40; |
|
362 else if (eiq == 1 || eiq == 3) |
|
363 lid = 40 + n; |
|
364 else |
|
365 abort (); |
4047
|
366 |
4049
|
367 for (int i = 0; i < n; i++) |
|
368 iwork(lid+i) = av(i) ? -1 : 1; |
|
369 } |
|
370 else |
|
371 { |
|
372 (*current_liboctave_error_handler) |
|
373 ("daspk: algebraic variables size mismatch"); |
|
374 integration_error = true; |
|
375 return retval; |
|
376 } |
|
377 } |
|
378 else if (ccic != 2) |
|
379 { |
|
380 (*current_liboctave_error_handler) |
|
381 ("daspk: invalid value for compute consistent initial condition option"); |
|
382 integration_error = true; |
|
383 return retval; |
|
384 } |
4047
|
385 |
4049
|
386 info(10) = ccic; |
|
387 } |
4047
|
388 |
4049
|
389 if (eavfet) |
|
390 { |
|
391 info(15) = 1; |
4047
|
392 |
4049
|
393 // XXX FIXME XXX -- this code is duplicated above. |
4047
|
394 |
|
395 Array<int> av = algebraic_variables (); |
|
396 |
|
397 if (av.length () == n) |
|
398 { |
|
399 int lid; |
|
400 if (eiq == 0 || eiq == 2) |
|
401 lid = 40; |
|
402 else if (eiq == 1 || eiq == 3) |
|
403 lid = 40 + n; |
|
404 else |
|
405 abort (); |
|
406 |
|
407 for (int i = 0; i < n; i++) |
|
408 iwork(lid+i) = av(i) ? -1 : 1; |
|
409 } |
4049
|
410 } |
|
411 |
|
412 if (use_initial_condition_heuristics ()) |
|
413 { |
|
414 Array<double> ich = initial_condition_heuristics (); |
|
415 |
|
416 if (ich.length () == 6) |
|
417 { |
|
418 iwork(31) = NINT (ich(0)); |
|
419 iwork(32) = NINT (ich(1)); |
|
420 iwork(33) = NINT (ich(2)); |
|
421 iwork(34) = NINT (ich(3)); |
|
422 |
|
423 rwork(13) = ich(4); |
|
424 rwork(14) = ich(5); |
|
425 } |
4047
|
426 else |
|
427 { |
|
428 (*current_liboctave_error_handler) |
4049
|
429 ("daspk: invalid initial condition heuristics option"); |
4047
|
430 integration_error = true; |
|
431 return retval; |
|
432 } |
4049
|
433 |
|
434 info(16) = 1; |
4047
|
435 } |
4049
|
436 |
|
437 int pici = print_initial_condition_info (); |
|
438 switch (pici) |
4047
|
439 { |
4049
|
440 case 0: |
|
441 case 1: |
|
442 case 2: |
|
443 info(17) = pici; |
|
444 break; |
|
445 |
|
446 default: |
4047
|
447 (*current_liboctave_error_handler) |
4049
|
448 ("daspk: invalid value for print initial condition info option"); |
4047
|
449 integration_error = true; |
|
450 return retval; |
4049
|
451 break; |
4047
|
452 } |
|
453 |
4049
|
454 DASPK_options::reset = false; |
4047
|
455 |
4049
|
456 restart = false; |
4047
|
457 } |
|
458 |
4049
|
459 static double *dummy = 0; |
|
460 static int *idummy = 0; |
4047
|
461 |
4049
|
462 F77_XFCN (ddaspk, DDASPK, (ddaspk_f, nn, t, px, pxdot, tout, pinfo, |
3998
|
463 prel_tol, pabs_tol, istate, prwork, lrw, |
3912
|
464 piwork, liw, dummy, idummy, ddaspk_j, |
|
465 ddaspk_psol)); |
|
466 |
|
467 if (f77_exception_encountered) |
|
468 { |
3995
|
469 integration_error = true; |
3912
|
470 (*current_liboctave_error_handler) ("unrecoverable error in daspk"); |
|
471 } |
|
472 else |
|
473 { |
3997
|
474 switch (istate) |
3912
|
475 { |
|
476 case 1: // A step was successfully taken in intermediate-output |
|
477 // mode. The code has not yet reached TOUT. |
|
478 case 2: // The integration to TSTOP was successfully completed |
|
479 // (T=TSTOP) by stepping exactly to TSTOP. |
|
480 case 3: // The integration to TOUT was successfully completed |
|
481 // (T=TOUT) by stepping past TOUT. Y(*) is obtained by |
|
482 // interpolation. YPRIME(*) is obtained by interpolation. |
3996
|
483 case 4: // The initial condition calculation, with |
|
484 // INFO(11) > 0, was successful, and INFO(14) = 1. |
|
485 // No integration steps were taken, and the solution |
|
486 // is not considered to have been started. |
3912
|
487 retval = x; |
|
488 t = tout; |
|
489 break; |
|
490 |
|
491 case -1: // A large amount of work has been expended. (~500 steps). |
|
492 case -2: // The error tolerances are too stringent. |
|
493 case -3: // The local error test cannot be satisfied because you |
|
494 // specified a zero component in ATOL and the |
|
495 // corresponding computed solution component is zero. |
|
496 // Thus, a pure relative error test is impossible for |
|
497 // this component. |
|
498 case -6: // DDASPK had repeated error test failures on the last |
|
499 // attempted step. |
|
500 case -7: // The corrector could not converge. |
|
501 case -8: // The matrix of partial derivatives is singular. |
|
502 case -9: // The corrector could not converge. There were repeated |
|
503 // error test failures in this step. |
|
504 case -10: // The corrector could not converge because IRES was |
|
505 // equal to minus one. |
|
506 case -11: // IRES equal to -2 was encountered and control is being |
|
507 // returned to the calling program. |
|
508 case -12: // DDASPK failed to compute the initial YPRIME. |
3996
|
509 case -13: // Unrecoverable error encountered inside user's |
|
510 // PSOL routine, and control is being returned to |
|
511 // the calling program. |
|
512 case -14: // The Krylov linear system solver could not |
|
513 // achieve convergence. |
3912
|
514 case -33: // The code has encountered trouble from which it cannot |
|
515 // recover. A message is printed explaining the trouble |
|
516 // and control is returned to the calling program. For |
|
517 // example, this occurs when invalid input is detected. |
3996
|
518 integration_error = true; |
|
519 break; |
|
520 |
3912
|
521 default: |
3995
|
522 integration_error = true; |
3996
|
523 (*current_liboctave_error_handler) |
3997
|
524 ("unrecognized value of istate (= %d) returned from ddaspk", |
|
525 istate); |
3912
|
526 break; |
|
527 } |
|
528 } |
|
529 |
|
530 return retval; |
|
531 } |
|
532 |
|
533 Matrix |
|
534 DASPK::do_integrate (const ColumnVector& tout) |
|
535 { |
|
536 Matrix dummy; |
|
537 return integrate (tout, dummy); |
|
538 } |
|
539 |
|
540 Matrix |
|
541 DASPK::integrate (const ColumnVector& tout, Matrix& xdot_out) |
|
542 { |
|
543 Matrix retval; |
4049
|
544 |
3912
|
545 int n_out = tout.capacity (); |
4049
|
546 int n = size (); |
3912
|
547 |
|
548 if (n_out > 0 && n > 0) |
|
549 { |
|
550 retval.resize (n_out, n); |
|
551 xdot_out.resize (n_out, n); |
|
552 |
|
553 for (int i = 0; i < n; i++) |
|
554 { |
|
555 retval.elem (0, i) = x.elem (i); |
|
556 xdot_out.elem (0, i) = xdot.elem (i); |
|
557 } |
|
558 |
|
559 for (int j = 1; j < n_out; j++) |
|
560 { |
|
561 ColumnVector x_next = do_integrate (tout.elem (j)); |
|
562 |
|
563 if (integration_error) |
|
564 return retval; |
|
565 |
|
566 for (int i = 0; i < n; i++) |
|
567 { |
|
568 retval.elem (j, i) = x_next.elem (i); |
|
569 xdot_out.elem (j, i) = xdot.elem (i); |
|
570 } |
|
571 } |
|
572 } |
|
573 |
|
574 return retval; |
|
575 } |
|
576 |
|
577 Matrix |
|
578 DASPK::do_integrate (const ColumnVector& tout, const ColumnVector& tcrit) |
|
579 { |
|
580 Matrix dummy; |
|
581 return integrate (tout, dummy, tcrit); |
|
582 } |
|
583 |
|
584 Matrix |
|
585 DASPK::integrate (const ColumnVector& tout, Matrix& xdot_out, |
|
586 const ColumnVector& tcrit) |
|
587 { |
|
588 Matrix retval; |
4049
|
589 |
3912
|
590 int n_out = tout.capacity (); |
4049
|
591 int n = size (); |
3912
|
592 |
|
593 if (n_out > 0 && n > 0) |
|
594 { |
|
595 retval.resize (n_out, n); |
|
596 xdot_out.resize (n_out, n); |
|
597 |
|
598 for (int i = 0; i < n; i++) |
|
599 { |
|
600 retval.elem (0, i) = x.elem (i); |
|
601 xdot_out.elem (0, i) = xdot.elem (i); |
|
602 } |
|
603 |
|
604 int n_crit = tcrit.capacity (); |
|
605 |
|
606 if (n_crit > 0) |
|
607 { |
|
608 int i_crit = 0; |
|
609 int i_out = 1; |
|
610 double next_crit = tcrit.elem (0); |
|
611 double next_out; |
|
612 while (i_out < n_out) |
|
613 { |
|
614 bool do_restart = false; |
|
615 |
|
616 next_out = tout.elem (i_out); |
|
617 if (i_crit < n_crit) |
|
618 next_crit = tcrit.elem (i_crit); |
|
619 |
|
620 bool save_output; |
|
621 double t_out; |
|
622 |
|
623 if (next_crit == next_out) |
|
624 { |
|
625 set_stop_time (next_crit); |
|
626 t_out = next_out; |
|
627 save_output = true; |
|
628 i_out++; |
|
629 i_crit++; |
|
630 do_restart = true; |
|
631 } |
|
632 else if (next_crit < next_out) |
|
633 { |
|
634 if (i_crit < n_crit) |
|
635 { |
|
636 set_stop_time (next_crit); |
|
637 t_out = next_crit; |
|
638 save_output = false; |
|
639 i_crit++; |
|
640 do_restart = true; |
|
641 } |
|
642 else |
|
643 { |
|
644 clear_stop_time (); |
|
645 t_out = next_out; |
|
646 save_output = true; |
|
647 i_out++; |
|
648 } |
|
649 } |
|
650 else |
|
651 { |
|
652 set_stop_time (next_crit); |
|
653 t_out = next_out; |
|
654 save_output = true; |
|
655 i_out++; |
|
656 } |
|
657 |
|
658 ColumnVector x_next = do_integrate (t_out); |
|
659 |
|
660 if (integration_error) |
|
661 return retval; |
|
662 |
|
663 if (save_output) |
|
664 { |
|
665 for (int i = 0; i < n; i++) |
|
666 { |
|
667 retval.elem (i_out-1, i) = x_next.elem (i); |
|
668 xdot_out.elem (i_out-1, i) = xdot.elem (i); |
|
669 } |
|
670 } |
|
671 |
|
672 if (do_restart) |
|
673 force_restart (); |
|
674 } |
|
675 } |
|
676 else |
|
677 { |
|
678 retval = integrate (tout, xdot_out); |
|
679 |
|
680 if (integration_error) |
|
681 return retval; |
|
682 } |
|
683 } |
|
684 |
|
685 return retval; |
|
686 } |
|
687 |
3995
|
688 std::string |
|
689 DASPK::error_message (void) const |
|
690 { |
|
691 std::string retval; |
|
692 |
4051
|
693 OSSTREAM buf; |
|
694 buf << t << OSSTREAM_ENDS; |
|
695 std::string t_curr = OSSTREAM_STR (buf); |
|
696 OSSTREAM_FREEZE (buf); |
4043
|
697 |
3997
|
698 switch (istate) |
3995
|
699 { |
3996
|
700 case 1: |
|
701 retval = "a step was successfully taken in intermediate-output mode."; |
|
702 break; |
|
703 |
|
704 case 2: |
|
705 retval = "integration completed by stepping exactly to TOUT"; |
|
706 break; |
|
707 |
|
708 case 3: |
|
709 retval = "integration to tout completed by stepping past TOUT"; |
|
710 break; |
|
711 |
|
712 case 4: |
|
713 retval = "initial condition calculation completed successfully"; |
|
714 break; |
|
715 |
|
716 case -1: |
4043
|
717 retval = std::string ("a large amount of work has been expended (t =") |
|
718 + t_curr + ")"; |
3996
|
719 break; |
|
720 |
|
721 case -2: |
|
722 retval = "the error tolerances are too stringent"; |
|
723 break; |
|
724 |
|
725 case -3: |
4043
|
726 retval = std::string ("error weight became zero during problem. (t = ") |
|
727 + t_curr |
|
728 + "; solution component i vanished, and atol or atol(i) == 0)"; |
3996
|
729 break; |
|
730 |
|
731 case -6: |
4043
|
732 retval = std::string ("repeated error test failures on the last attempted step (t = ") |
|
733 + t_curr + ")"; |
3996
|
734 break; |
|
735 |
|
736 case -7: |
4043
|
737 retval = std::string ("the corrector could not converge (t = ") |
|
738 + t_curr + ")"; |
3996
|
739 break; |
|
740 |
|
741 case -8: |
4043
|
742 retval = std::string ("the matrix of partial derivatives is singular (t = ") |
|
743 + t_curr + ")"; |
3996
|
744 break; |
|
745 |
|
746 case -9: |
4043
|
747 retval = std::string ("the corrector could not converge (t = ") |
|
748 + t_curr + "; repeated test failures)"; |
3996
|
749 break; |
|
750 |
|
751 case -10: |
4043
|
752 retval = std::string ("corrector could not converge because IRES was -1 (t = ") |
|
753 + t_curr + ")"; |
3996
|
754 break; |
|
755 |
|
756 case -11: |
4043
|
757 retval = std::string ("return requested in user-supplied function (t = ") |
|
758 + t_curr + ")"; |
3996
|
759 break; |
|
760 |
|
761 case -12: |
|
762 retval = "failed to compute consistent initial conditions"; |
|
763 break; |
|
764 |
|
765 case -13: |
4043
|
766 retval = std::string ("unrecoverable error encountered inside user's PSOL function (t = ") |
|
767 + t_curr + ")"; |
3996
|
768 break; |
|
769 |
|
770 case -14: |
4043
|
771 retval = std::string ("the Krylov linear system solver failed to converge (t = ") |
|
772 + t_curr + ")"; |
3996
|
773 break; |
|
774 |
|
775 case -33: |
|
776 retval = "unrecoverable error (see printed message)"; |
|
777 break; |
|
778 |
3995
|
779 default: |
|
780 retval = "unknown error state"; |
|
781 break; |
|
782 } |
|
783 |
|
784 return retval; |
|
785 } |
|
786 |
3912
|
787 /* |
|
788 ;;; Local Variables: *** |
|
789 ;;; mode: C++ *** |
|
790 ;;; End: *** |
|
791 */ |