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