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