diff-grok 1.0.10 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/.claude/settings.local.json +11 -0
  2. package/CLAUDE.md +98 -0
  3. package/README.MD +100 -24
  4. package/images/E5.png +0 -0
  5. package/images/HIRES.png +0 -0
  6. package/images/OREGO.png +0 -0
  7. package/images/POLL-full.png +0 -0
  8. package/images/ROBER.png +0 -0
  9. package/images/VDP0L.png +0 -0
  10. package/index.js +1 -1
  11. package/index.js.map +1 -1
  12. package/index.ts +2 -1
  13. package/jest.config.js +1 -0
  14. package/package.json +1 -1
  15. package/src/examples/bioreactor.js +125 -0
  16. package/src/examples/bioreactor.js.map +1 -0
  17. package/src/examples/bioreactor.ts +132 -0
  18. package/src/examples/cyclic-model.js +3 -1
  19. package/src/examples/cyclic-model.js.map +1 -1
  20. package/src/examples/cyclic-model.ts +3 -1
  21. package/src/solver-tools/ab4-method.js +332 -0
  22. package/src/solver-tools/ab4-method.js.map +1 -0
  23. package/src/solver-tools/ab4-method.ts +395 -0
  24. package/src/solver-tools/ab5-method.js +334 -0
  25. package/src/solver-tools/ab5-method.js.map +1 -0
  26. package/src/solver-tools/ab5-method.ts +397 -0
  27. package/src/solver-tools/index.js +6 -0
  28. package/src/solver-tools/index.js.map +1 -1
  29. package/src/solver-tools/index.ts +6 -0
  30. package/src/solver-tools/lsoda/blas.js +246 -0
  31. package/src/solver-tools/lsoda/blas.js.map +1 -0
  32. package/src/solver-tools/lsoda/blas.ts +267 -0
  33. package/src/solver-tools/lsoda/cfode.js +73 -0
  34. package/src/solver-tools/lsoda/cfode.js.map +1 -0
  35. package/src/solver-tools/lsoda/cfode.ts +83 -0
  36. package/src/solver-tools/lsoda/common.js +94 -0
  37. package/src/solver-tools/lsoda/common.js.map +1 -0
  38. package/src/solver-tools/lsoda/common.ts +135 -0
  39. package/src/solver-tools/lsoda/corfailure.js +25 -0
  40. package/src/solver-tools/lsoda/corfailure.js.map +1 -0
  41. package/src/solver-tools/lsoda/corfailure.ts +30 -0
  42. package/src/solver-tools/lsoda/correction.js +101 -0
  43. package/src/solver-tools/lsoda/correction.js.map +1 -0
  44. package/src/solver-tools/lsoda/correction.ts +119 -0
  45. package/src/solver-tools/lsoda/dense.js +110 -0
  46. package/src/solver-tools/lsoda/dense.js.map +1 -0
  47. package/src/solver-tools/lsoda/dense.ts +129 -0
  48. package/src/solver-tools/lsoda/index.js +4 -0
  49. package/src/solver-tools/lsoda/index.js.map +1 -0
  50. package/src/solver-tools/lsoda/index.ts +5 -0
  51. package/src/solver-tools/lsoda/intdy.js +43 -0
  52. package/src/solver-tools/lsoda/intdy.js.map +1 -0
  53. package/src/solver-tools/lsoda/intdy.ts +50 -0
  54. package/src/solver-tools/lsoda/lsoda.js +567 -0
  55. package/src/solver-tools/lsoda/lsoda.js.map +1 -0
  56. package/src/solver-tools/lsoda/lsoda.ts +632 -0
  57. package/src/solver-tools/lsoda/methodswitch.js +97 -0
  58. package/src/solver-tools/lsoda/methodswitch.js.map +1 -0
  59. package/src/solver-tools/lsoda/methodswitch.ts +107 -0
  60. package/src/solver-tools/lsoda/orderswitch.js +86 -0
  61. package/src/solver-tools/lsoda/orderswitch.js.map +1 -0
  62. package/src/solver-tools/lsoda/orderswitch.ts +95 -0
  63. package/src/solver-tools/lsoda/prja.js +43 -0
  64. package/src/solver-tools/lsoda/prja.js.map +1 -0
  65. package/src/solver-tools/lsoda/prja.ts +49 -0
  66. package/src/solver-tools/lsoda/scaleh.js +30 -0
  67. package/src/solver-tools/lsoda/scaleh.js.map +1 -0
  68. package/src/solver-tools/lsoda/scaleh.ts +33 -0
  69. package/src/solver-tools/lsoda/solsy.js +14 -0
  70. package/src/solver-tools/lsoda/solsy.js.map +1 -0
  71. package/src/solver-tools/lsoda/solsy.ts +18 -0
  72. package/src/solver-tools/lsoda/stoda.js +259 -0
  73. package/src/solver-tools/lsoda/stoda.js.map +1 -0
  74. package/src/solver-tools/lsoda/stoda.ts +286 -0
  75. package/src/solver-tools/lsoda-method.js +120 -0
  76. package/src/solver-tools/lsoda-method.js.map +1 -0
  77. package/src/solver-tools/lsoda-method.ts +136 -0
  78. package/src/solver-tools/mrt-method.js +81 -18
  79. package/src/solver-tools/mrt-method.js.map +1 -1
  80. package/src/solver-tools/mrt-method.ts +111 -21
  81. package/src/solver-tools/rk3-method.js +210 -0
  82. package/src/solver-tools/rk3-method.js.map +1 -0
  83. package/src/solver-tools/rk3-method.ts +257 -0
  84. package/src/solver-tools/rk4-method.js +236 -0
  85. package/src/solver-tools/rk4-method.js.map +1 -0
  86. package/src/solver-tools/rk4-method.ts +286 -0
  87. package/src/solver-tools/rkdp-method.js +247 -0
  88. package/src/solver-tools/rkdp-method.js.map +1 -0
  89. package/src/solver-tools/rkdp-method.ts +300 -0
  90. package/src/solver-tools/ros34prw-method.js +1 -1
  91. package/src/solver-tools/ros34prw-method.js.map +1 -1
  92. package/src/solver-tools/ros34prw-method.ts +1 -1
  93. package/src/solver-tools/ros3prw-method.js +1 -1
  94. package/src/solver-tools/ros3prw-method.js.map +1 -1
  95. package/src/solver-tools/ros3prw-method.ts +1 -1
  96. package/src/solver-tools/solver-defs.js +6 -0
  97. package/src/solver-tools/solver-defs.js.map +1 -1
  98. package/src/solver-tools/solver-defs.ts +6 -0
  99. package/src/tests/correctness.test.js +6 -4
  100. package/src/tests/correctness.test.js.map +1 -1
  101. package/src/tests/correctness.test.ts +6 -4
  102. package/src/tests/lsoda-lib-correctness.test.js +223 -0
  103. package/src/tests/lsoda-lib-correctness.test.js.map +1 -0
  104. package/src/tests/lsoda-lib-correctness.test.ts +283 -0
  105. package/src/tests/lsoda-lib-performance.test.js +95 -0
  106. package/src/tests/lsoda-lib-performance.test.js.map +1 -0
  107. package/src/tests/lsoda-lib-performance.test.ts +126 -0
  108. package/src/tests/performance.test.js +10 -8
  109. package/src/tests/performance.test.js.map +1 -1
  110. package/src/tests/performance.test.ts +10 -8
  111. package/src/tests/test-defs.js +14 -1
  112. package/src/tests/test-defs.js.map +1 -1
  113. package/src/tests/test-defs.ts +15 -1
  114. package/src/worker-tools/solving.js +13 -1
  115. package/src/worker-tools/solving.js.map +1 -1
  116. package/src/worker-tools/solving.ts +20 -1
  117. package/docs/.nojekyll +0 -1
  118. package/docs/assets/hierarchy.js +0 -1
  119. package/docs/assets/highlight.css +0 -99
  120. package/docs/assets/icons.js +0 -18
  121. package/docs/assets/icons.svg +0 -1
  122. package/docs/assets/main.js +0 -60
  123. package/docs/assets/navigation.js +0 -1
  124. package/docs/assets/search.js +0 -1
  125. package/docs/assets/style.css +0 -1633
  126. package/docs/classes/BasicModelPipelineCreator.html +0 -10
  127. package/docs/classes/Callback.html +0 -7
  128. package/docs/classes/CyclicModelPipelineCreator.html +0 -10
  129. package/docs/classes/IterCheckerCallback.html +0 -8
  130. package/docs/classes/PipelineCreator.html +0 -6
  131. package/docs/classes/TimeCheckerCallback.html +0 -8
  132. package/docs/classes/UpdatesModelPipelineCreator.html +0 -10
  133. package/docs/functions/applyPipeline.html +0 -9
  134. package/docs/functions/getCallback.html +0 -3
  135. package/docs/functions/getIVP.html +0 -6
  136. package/docs/functions/getInputVector.html +0 -2
  137. package/docs/functions/getIvp2WebWorker.html +0 -6
  138. package/docs/functions/getJScode.html +0 -6
  139. package/docs/functions/getOutputNames.html +0 -4
  140. package/docs/functions/getPipelineCreator.html +0 -7
  141. package/docs/functions/mrt.html +0 -11
  142. package/docs/functions/printE5.html +0 -76
  143. package/docs/functions/printHires.html +0 -76
  144. package/docs/functions/printOrego.html +0 -66
  145. package/docs/functions/printPollution.html +0 -163
  146. package/docs/functions/printRobertson.html +0 -60
  147. package/docs/functions/printVdpol.html +0 -66
  148. package/docs/functions/ros34prw.html +0 -8
  149. package/docs/functions/ros3prw.html +0 -8
  150. package/docs/functions/solveIvp.html +0 -5
  151. package/docs/hierarchy.html +0 -1
  152. package/docs/index.html +0 -683
  153. package/docs/media/CONTRIBUTING.md +0 -74
  154. package/docs/media/POLL.png +0 -0
  155. package/docs/media/VDPOL.png +0 -0
  156. package/docs/media/acid-prod.gif +0 -0
  157. package/docs/media/basic-use.js +0 -40
  158. package/docs/media/basic-use.js.map +0 -1
  159. package/docs/media/basic-use.ts +0 -44
  160. package/docs/media/check-methods.js +0 -59
  161. package/docs/media/check-methods.js.map +0 -1
  162. package/docs/media/check-methods.ts +0 -81
  163. package/docs/media/corr-probs.js +0 -132
  164. package/docs/media/corr-probs.js.map +0 -1
  165. package/docs/media/corr-probs.ts +0 -155
  166. package/docs/media/cyclic-model.js +0 -100
  167. package/docs/media/cyclic-model.js.map +0 -1
  168. package/docs/media/cyclic-model.ts +0 -110
  169. package/docs/media/e5.js +0 -36
  170. package/docs/media/e5.js.map +0 -1
  171. package/docs/media/e5.ts +0 -36
  172. package/docs/media/hires.js +0 -39
  173. package/docs/media/hires.js.map +0 -1
  174. package/docs/media/hires.ts +0 -40
  175. package/docs/media/model-updates.js +0 -112
  176. package/docs/media/model-updates.js.map +0 -1
  177. package/docs/media/model-updates.ts +0 -122
  178. package/docs/media/orego.js +0 -24
  179. package/docs/media/orego.js.map +0 -1
  180. package/docs/media/orego.ts +0 -25
  181. package/docs/media/pipeline-use.js +0 -87
  182. package/docs/media/pipeline-use.js.map +0 -1
  183. package/docs/media/pipeline-use.ts +0 -98
  184. package/docs/media/pollution.js +0 -132
  185. package/docs/media/pollution.js.map +0 -1
  186. package/docs/media/pollution.ts +0 -133
  187. package/docs/media/print-benchmark.js +0 -581
  188. package/docs/media/print-benchmark.js.map +0 -1
  189. package/docs/media/print-benchmark.ts +0 -594
  190. package/docs/media/robertson.js +0 -19
  191. package/docs/media/robertson.js.map +0 -1
  192. package/docs/media/robertson.ts +0 -19
  193. package/docs/media/scripting.js +0 -30
  194. package/docs/media/scripting.js.map +0 -1
  195. package/docs/media/scripting.ts +0 -35
  196. package/docs/media/vdpol.js +0 -17
  197. package/docs/media/vdpol.js.map +0 -1
  198. package/docs/media/vdpol.ts +0 -17
  199. package/docs/modules.html +0 -1
  200. package/docs/types/Arg.html +0 -12
  201. package/docs/types/DifEqs.html +0 -8
  202. package/docs/types/Func.html +0 -7
  203. package/docs/types/IVP.html +0 -40
  204. package/docs/types/IVP2WebWorker.html +0 -12
  205. package/docs/types/Input.html +0 -8
  206. package/docs/types/Loop.html +0 -7
  207. package/docs/types/ODEs.html +0 -31
  208. package/docs/types/Output.html +0 -6
  209. package/docs/types/Pipeline.html +0 -6
  210. package/docs/types/SolverOptions.html +0 -8
  211. package/docs/types/Update.html +0 -9
  212. package/docs/types/Wrapper.html +0 -8
@@ -0,0 +1,283 @@
1
+ import {Lsoda} from '../solver-tools/lsoda';
2
+ import {ODEs} from '../../index';
3
+ import {corrProbs} from '../examples/corr-probs';
4
+
5
+ // ─── Robertson chemical kinetics (original test) ────────────────────────────
6
+
7
+ function fex(t: number, y: Float64Array, ydot: Float64Array): number {
8
+ ydot[0] = 1.0e4 * y[1] * y[2] - 0.04 * y[0];
9
+ ydot[2] = 3.0e7 * y[1] * y[1];
10
+ ydot[1] = -(ydot[0] + ydot[2]);
11
+ return 0;
12
+ }
13
+
14
+ const expected = [
15
+ {t: 4.0000e-01, y: [9.851712e-01, 3.386380e-05, 1.479493e-02]},
16
+ {t: 4.0000e+00, y: [9.055333e-01, 2.240655e-05, 9.444430e-02]},
17
+ {t: 4.0000e+01, y: [7.158403e-01, 9.186334e-06, 2.841505e-01]},
18
+ {t: 4.0000e+02, y: [4.505250e-01, 3.222964e-06, 5.494717e-01]},
19
+ {t: 4.0000e+03, y: [1.831976e-01, 8.941773e-07, 8.168015e-01]},
20
+ {t: 4.0000e+04, y: [3.898729e-02, 1.621940e-07, 9.610125e-01]},
21
+ {t: 4.0000e+05, y: [4.936362e-03, 1.984221e-08, 9.950636e-01]},
22
+ {t: 4.0000e+06, y: [5.161833e-04, 2.065787e-09, 9.994838e-01]},
23
+ {t: 4.0000e+07, y: [5.179804e-05, 2.072027e-10, 9.999482e-01]},
24
+ {t: 4.0000e+08, y: [5.283675e-06, 2.113481e-11, 9.999947e-01]},
25
+ {t: 4.0000e+09, y: [4.658667e-07, 1.863468e-12, 9.999995e-01]},
26
+ {t: 4.0000e+10, y: [1.431100e-08, 5.724404e-14, 1.000000e+00]},
27
+ ];
28
+
29
+ // ─── Helpers ─────────────────────────────────────────────────────────────────
30
+
31
+ function relError(computed: number, reference: number): number {
32
+ if (reference === 0) return Math.abs(computed);
33
+ return Math.abs((computed - reference) / reference);
34
+ }
35
+
36
+ /** Wraps an ODEs func into an OdeFunction compatible with Lsoda (returns 0). */
37
+ function wrapFunc(ode: ODEs): (t: number, y: Float64Array, ydot: Float64Array) => number {
38
+ return (t, y, ydot) => {
39
+ ode.func(t, y, ydot);
40
+ return 0;
41
+ };
42
+ }
43
+
44
+ /**
45
+ * Solves an ODE problem and checks against the exact solution at the final time point.
46
+ * Uses combined absolute + relative tolerance: |computed - exact| < checkTol * |exact| + checkAbsTol.
47
+ */
48
+ function solveAndCheck(
49
+ ode: ODEs,
50
+ exactSolution: (t: number) => Float64Array,
51
+ checkTol: number = 1e-3,
52
+ checkAbsTol: number = 1e-6,
53
+ ) {
54
+ const neq = ode.initial.length;
55
+ const tol = ode.tolerance;
56
+ const rtol = new Float64Array(neq).fill(tol);
57
+ const atol = new Float64Array(neq).fill(tol);
58
+
59
+ const solver = new Lsoda(wrapFunc(ode), neq, {rtol, atol, itask: 1});
60
+
61
+ let y: ArrayLike<number> = [...ode.initial];
62
+ let t = ode.arg.start;
63
+ const step = ode.arg.step;
64
+ const finish = ode.arg.finish;
65
+
66
+ let tout = t + step;
67
+ while (tout <= finish + step / 2) {
68
+ const result = solver.solve(y, t, tout);
69
+ y = result.y;
70
+ t = result.t;
71
+
72
+ expect(solver.state).toBeGreaterThan(0);
73
+ tout += step;
74
+ }
75
+
76
+ // Check final solution against exact using combined abs + rel tolerance
77
+ const exact = exactSolution(t);
78
+ for (let j = 0; j < neq; j++) {
79
+ const absErr = Math.abs(y[j] - exact[j]);
80
+ const allowed = checkTol * Math.abs(exact[j]) + checkAbsTol;
81
+ expect(absErr).toBeLessThan(allowed);
82
+ }
83
+ }
84
+
85
+ // ─── Tests ───────────────────────────────────────────────────────────────────
86
+
87
+ const nonStiffProbs = corrProbs.filter((p) => p.odes.name.startsWith('non-stiff'));
88
+ const stiffProbs = corrProbs.filter((p) => p.odes.name.startsWith('stiff'));
89
+
90
+ describe('LSODA LIB', () => {
91
+ it('should solve Robertson chemical kinetics with expected accuracy', () => {
92
+ const neq = 3;
93
+ const rtol = new Float64Array([1.0e-4, 1.0e-4, 1.0e-4]);
94
+ const atol = new Float64Array([1.0e-6, 1.0e-10, 1.0e-6]);
95
+
96
+ const solver = new Lsoda(fex, neq, {
97
+ rtol,
98
+ atol,
99
+ itask: 1,
100
+ });
101
+
102
+ let y: ArrayLike<number> = [1.0, 0.0, 0.0];
103
+ let t = 0.0;
104
+ let tout = 0.4;
105
+
106
+ for (let iout = 0; iout < 12; iout++) {
107
+ const result = solver.solve(y, t, tout);
108
+ y = result.y;
109
+ t = result.t;
110
+
111
+ expect(solver.state).toBeGreaterThan(0);
112
+
113
+ const exp = expected[iout];
114
+ for (let j = 0; j < 3; j++) {
115
+ const err = relError(y[j], exp.y[j]);
116
+ expect(err).toBeLessThanOrEqual(5e-3);
117
+ }
118
+
119
+ tout *= 10.0;
120
+ }
121
+ });
122
+
123
+ describe('non-stiff problems', () => {
124
+ nonStiffProbs.forEach(({odes, exact}) => {
125
+ it(`should solve ${odes.name} problem`, () => {
126
+ solveAndCheck(odes, exact);
127
+ });
128
+ });
129
+ });
130
+
131
+ describe('stiff problems', () => {
132
+ stiffProbs.forEach(({odes, exact}) => {
133
+ it(`should solve ${odes.name} problem`, () => {
134
+ solveAndCheck(odes, exact);
135
+ });
136
+ });
137
+ });
138
+
139
+ // ─── Dense output tests ───────────────────────────────────────────────────
140
+
141
+ describe('dense output', () => {
142
+ // Helper: run Robertson to completion with dense output enabled
143
+ function solveRobertsonDense() {
144
+ const neq = 3;
145
+ const rtol = new Float64Array([1.0e-4, 1.0e-4, 1.0e-4]);
146
+ const atol = new Float64Array([1.0e-6, 1.0e-10, 1.0e-6]);
147
+
148
+ const solver = new Lsoda(fex, neq, {rtol, atol, itask: 1, dense: true});
149
+
150
+ let y: ArrayLike<number> = [1.0, 0.0, 0.0];
151
+ let t = 0.0;
152
+ let tout = 0.4;
153
+
154
+ for (let iout = 0; iout < 12; iout++) {
155
+ const result = solver.solve(y, t, tout);
156
+ y = result.y;
157
+ t = result.t;
158
+ tout *= 10.0;
159
+ }
160
+
161
+ return solver.getDenseOutput();
162
+ }
163
+
164
+ it('consistency: dense output should match direct solver results (Robertson)', () => {
165
+ const dense = solveRobertsonDense();
166
+
167
+ // Query dense output at the same tout points used in the reference test
168
+ const tPoints = Float64Array.from(expected.map((e) => e.t));
169
+ const results = dense.solveAtTimes(tPoints);
170
+
171
+ for (let i = 0; i < expected.length; i++) {
172
+ for (let j = 0; j < 3; j++) {
173
+ const err = relError(results[j][i], expected[i].y[j]);
174
+ expect(err).toBeLessThanOrEqual(5e-3);
175
+ }
176
+ }
177
+ });
178
+
179
+ it('monotonicity: uniform query should have increasing t and finite y', () => {
180
+ const dense = solveRobertsonDense();
181
+
182
+ // Query at 1000 uniform points across the full range
183
+ const tMin = dense.tMin;
184
+ const tMax = dense.tMax;
185
+ const n = 1000;
186
+ const tArray = new Float64Array(n);
187
+ for (let i = 0; i < n; i++)
188
+ tArray[i] = tMin + (tMax - tMin) * i / (n - 1);
189
+
190
+ const results = dense.solveAtTimes(tArray);
191
+ expect(results.length).toBe(3);
192
+ for (let j = 0; j < 3; j++)
193
+ expect(results[j].length).toBe(n);
194
+
195
+ for (let i = 1; i < n; i++)
196
+ expect(tArray[i]).toBeGreaterThan(tArray[i - 1]);
197
+
198
+ for (let i = 0; i < n; i++) {
199
+ for (let j = 0; j < 3; j++)
200
+ expect(Number.isFinite(results[j][i])).toBe(true);
201
+ }
202
+ });
203
+
204
+ it('boundary: query at tMin and tMax should succeed', () => {
205
+ const dense = solveRobertsonDense();
206
+
207
+ const yMin = dense.evaluateAt(dense.tMin);
208
+ const yMax = dense.evaluateAt(dense.tMax);
209
+
210
+ expect(yMin.length).toBe(3);
211
+ expect(yMax.length).toBe(3);
212
+ for (let j = 0; j < 3; j++) {
213
+ expect(Number.isFinite(yMin[j])).toBe(true);
214
+ expect(Number.isFinite(yMax[j])).toBe(true);
215
+ }
216
+ });
217
+
218
+ it('solveOnGrid: should return correct grid dimensions and quality', () => {
219
+ const dense = solveRobertsonDense();
220
+
221
+ const {t, y} = dense.solveOnGrid(0, 4e10, 1e9);
222
+
223
+ expect(t.length).toBe(41);
224
+ expect(y.length).toBe(3);
225
+ for (let j = 0; j < 3; j++)
226
+ expect(y[j].length).toBe(41);
227
+ expect(t[0]).toBeCloseTo(0, 10);
228
+ expect(t[t.length - 1]).toBeCloseTo(4e10, 0);
229
+
230
+ // Check solution quality at a sampled point (t=4e10)
231
+ const refLast = expected[expected.length - 1].y;
232
+ for (let j = 0; j < 3; j++) {
233
+ const err = relError(y[j][t.length - 1], refLast[j]);
234
+ expect(err).toBeLessThanOrEqual(5e-3);
235
+ }
236
+ });
237
+
238
+ function denseExactCheck(
239
+ ode: ODEs,
240
+ exactSolution: (t: number) => Float64Array,
241
+ checkTol: number = 1e-3,
242
+ checkAbsTol: number = 1e-6,
243
+ ) {
244
+ const neq = ode.initial.length;
245
+ const tol = ode.tolerance;
246
+ const rtol = new Float64Array(neq).fill(tol);
247
+ const atol = new Float64Array(neq).fill(tol);
248
+
249
+ const solver = new Lsoda(wrapFunc(ode), neq, {rtol, atol, itask: 1, dense: true});
250
+
251
+ let y: ArrayLike<number> = [...ode.initial];
252
+ let t = ode.arg.start;
253
+ const finish = ode.arg.finish;
254
+ const result = solver.solve(y, t, finish);
255
+ y = result.y;
256
+ t = result.t;
257
+
258
+ const dense = solver.getDenseOutput();
259
+
260
+ // Query at 100 points and compare against exact solution
261
+ const nPts = 100;
262
+ const tArr = new Float64Array(nPts + 1);
263
+ for (let i = 0; i <= nPts; i++)
264
+ tArr[i] = ode.arg.start + (finish - ode.arg.start) * i / nPts;
265
+
266
+ const results = dense.solveAtTimes(tArr);
267
+ for (let i = 0; i < tArr.length; i++) {
268
+ const exact = exactSolution(tArr[i]);
269
+ for (let j = 0; j < neq; j++) {
270
+ const absErr = Math.abs(results[j][i] - exact[j]);
271
+ const allowed = checkTol * Math.abs(exact[j]) + checkAbsTol;
272
+ expect(absErr).toBeLessThan(allowed);
273
+ }
274
+ }
275
+ }
276
+
277
+ corrProbs.forEach(({odes, exact}) => {
278
+ it(`dense output on ${odes.name} problem should match exact solution`, () => {
279
+ denseExactCheck(odes, exact);
280
+ });
281
+ });
282
+ });
283
+ });
@@ -0,0 +1,95 @@
1
+ import { Lsoda } from '../solver-tools/lsoda';
2
+ import { robertson, robertsonReferencePoint } from '../examples/robertson';
3
+ import { hires, hiresReferencePoint } from '../examples/hires';
4
+ import { vdpol, vdpolReferencePoint } from '../examples/vdpol';
5
+ import { orego, oregoReferencePoint } from '../examples/orego';
6
+ import { e5, e5ReferencePoint } from '../examples/e5';
7
+ import { pollution, pollutionReferencePoint } from '../examples/pollution';
8
+ // ─── Helpers ─────────────────────────────────────────────────────────────────
9
+ /** Wraps an ODEs func into an OdeFunction compatible with Lsoda (returns 0). */
10
+ function wrapFunc(ode) {
11
+ return (t, y, ydot) => {
12
+ ode.func(t, y, ydot);
13
+ return 0;
14
+ };
15
+ }
16
+ /** Solves a benchmark problem, checks accuracy against the reference point, and verifies solver health. */
17
+ function solveBenchmarkAndCheck(ode, referencePoint, relTol, absTol, opts) {
18
+ var _a, _b;
19
+ const neq = ode.initial.length;
20
+ const tol = ode.tolerance;
21
+ const rtol = (_a = opts === null || opts === void 0 ? void 0 : opts.rtol) !== null && _a !== void 0 ? _a : new Float64Array(neq).fill(tol);
22
+ const atol = (_b = opts === null || opts === void 0 ? void 0 : opts.atol) !== null && _b !== void 0 ? _b : new Float64Array(neq).fill(tol);
23
+ const solver = new Lsoda(wrapFunc(ode), neq, Object.assign(Object.assign({ rtol, atol, itask: 1 }, ((opts === null || opts === void 0 ? void 0 : opts.mxstep) ? { mxstep: opts.mxstep } : {})), ((opts === null || opts === void 0 ? void 0 : opts.hmax) ? { hmax: opts.hmax } : {})));
24
+ let y = [...ode.initial];
25
+ let t = ode.arg.start;
26
+ const step = ode.arg.step;
27
+ const finish = ode.arg.finish;
28
+ // Warmup phase: bootstrap very stiff problems with a small initial tout
29
+ if ((opts === null || opts === void 0 ? void 0 : opts.warmupTout) !== undefined) {
30
+ const result = solver.solve(y, t, opts.warmupTout);
31
+ y = result.y;
32
+ t = result.t;
33
+ expect(solver.state).toBeGreaterThan(0);
34
+ }
35
+ let tout = t + step;
36
+ while (tout <= finish + step / 2) {
37
+ const result = solver.solve(y, t, tout);
38
+ y = result.y;
39
+ t = result.t;
40
+ if (solver.state <= 0)
41
+ throw new Error(`${ode.name}: solver failed at t=${t} with state=${solver.state}, error: ${solver.error}`);
42
+ tout += step;
43
+ }
44
+ // Check final solution against reference point
45
+ for (let j = 0; j < neq; j++) {
46
+ const absErr = Math.abs(y[j] - referencePoint[j]);
47
+ const allowed = relTol * Math.abs(referencePoint[j]) + absTol;
48
+ expect(absErr).toBeLessThan(allowed);
49
+ }
50
+ }
51
+ // ─── Performance tests ──────────────────────────────────────────────────────
52
+ // Robertson: components span many orders of magnitude; use component-wise atol
53
+ describe('Robertson', () => {
54
+ it('should solve correctly', () => {
55
+ solveBenchmarkAndCheck(robertson, robertsonReferencePoint, 1e-2, 1e-7, {
56
+ mxstep: 50000,
57
+ atol: new Float64Array([1e-8, 1e-14, 1e-8]),
58
+ rtol: new Float64Array([1e-7, 1e-7, 1e-7]),
59
+ });
60
+ }, 60000);
61
+ });
62
+ describe('HIRES', () => {
63
+ it('should solve correctly', () => {
64
+ solveBenchmarkAndCheck(hires, hiresReferencePoint, 1e-3, 1e-12);
65
+ }, 60000);
66
+ });
67
+ // Van der Pol (mu=1000): very stiff, needs many internal steps
68
+ describe('van der Pol', () => {
69
+ it('should solve correctly', () => {
70
+ solveBenchmarkAndCheck(vdpol, vdpolReferencePoint, 1e-3, 1e-6, {
71
+ mxstep: 50000,
72
+ });
73
+ }, 60000);
74
+ });
75
+ describe('OREGO', () => {
76
+ it('should solve correctly', () => {
77
+ solveBenchmarkAndCheck(orego, oregoReferencePoint, 1e-2, 1e-6);
78
+ }, 60000);
79
+ });
80
+ // E5: extremely stiff (rate constants span 20 orders), needs warmup and many steps.
81
+ // Reference values are near-zero (y1~1e-290, y2~1e-22), so absTol must be generous.
82
+ describe('E5', () => {
83
+ it('should solve correctly', () => {
84
+ solveBenchmarkAndCheck(e5, e5ReferencePoint, 1, 1e-6, {
85
+ mxstep: 50000,
86
+ warmupTout: 1e-5,
87
+ });
88
+ }, 60000);
89
+ });
90
+ describe('Pollution', () => {
91
+ it('should solve correctly', () => {
92
+ solveBenchmarkAndCheck(pollution, pollutionReferencePoint, 1e-2, 1e-10);
93
+ }, 60000);
94
+ });
95
+ //# sourceMappingURL=lsoda-lib-performance.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lsoda-lib-performance.test.js","sourceRoot":"","sources":["lsoda-lib-performance.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAC,KAAK,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,KAAK,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,KAAK,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,EAAE,EAAE,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;AAEzE,gFAAgF;AAEhF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C,CAAC;AAEH,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,sBAAsB,CAAC,KAAK,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC,EAAE,KAAK,CAAC,CAAC;AACZ,CAAC,CAAC,CAAC;AAEH,oFAAoF;AACpF,oFAAoF;AACpF,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE;IAClB,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,sBAAsB,CAAC,EAAE,EAAE,gBAAgB,EAAE,CAAC,EAAE,IAAI,EAAE;YACpD,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;IACL,CAAC,EAAE,KAAK,CAAC,CAAC;AACZ,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,sBAAsB,CAAC,SAAS,EAAE,uBAAuB,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1E,CAAC,EAAE,KAAK,CAAC,CAAC;AACZ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,126 @@
1
+ import {Lsoda} from '../solver-tools/lsoda';
2
+ import {ODEs} from '../../index';
3
+ import {robertson, robertsonReferencePoint} from '../examples/robertson';
4
+ import {hires, hiresReferencePoint} from '../examples/hires';
5
+ import {vdpol, vdpolReferencePoint} from '../examples/vdpol';
6
+ import {orego, oregoReferencePoint} from '../examples/orego';
7
+ import {e5, e5ReferencePoint} from '../examples/e5';
8
+ import {pollution, pollutionReferencePoint} from '../examples/pollution';
9
+
10
+ // ─── Helpers ─────────────────────────────────────────────────────────────────
11
+
12
+ /** Wraps an ODEs func into an OdeFunction compatible with Lsoda (returns 0). */
13
+ function wrapFunc(ode: ODEs): (t: number, y: Float64Array, ydot: Float64Array) => number {
14
+ return (t, y, ydot) => {
15
+ ode.func(t, y, ydot);
16
+ return 0;
17
+ };
18
+ }
19
+
20
+ interface SolverOpts {
21
+ mxstep?: number;
22
+ hmax?: number;
23
+ rtol?: Float64Array;
24
+ atol?: Float64Array;
25
+ /** Small initial tout to bootstrap very stiff problems before the main loop. */
26
+ warmupTout?: number;
27
+ }
28
+
29
+ /** Solves a benchmark problem, checks accuracy against the reference point, and verifies solver health. */
30
+ function solveBenchmarkAndCheck(
31
+ ode: ODEs, referencePoint: Float64Array, relTol: number, absTol: number, opts?: SolverOpts,
32
+ ): void {
33
+ const neq = ode.initial.length;
34
+ const tol = ode.tolerance;
35
+ const rtol = opts?.rtol ?? new Float64Array(neq).fill(tol);
36
+ const atol = opts?.atol ?? new Float64Array(neq).fill(tol);
37
+
38
+ const solver = new Lsoda(wrapFunc(ode), neq, {
39
+ rtol, atol, itask: 1,
40
+ ...(opts?.mxstep ? {mxstep: opts.mxstep} : {}),
41
+ ...(opts?.hmax ? {hmax: opts.hmax} : {}),
42
+ });
43
+
44
+ let y: ArrayLike<number> = [...ode.initial];
45
+ let t = ode.arg.start;
46
+ const step = ode.arg.step;
47
+ const finish = ode.arg.finish;
48
+
49
+ // Warmup phase: bootstrap very stiff problems with a small initial tout
50
+ if (opts?.warmupTout !== undefined) {
51
+ const result = solver.solve(y, t, opts.warmupTout);
52
+ y = result.y;
53
+ t = result.t;
54
+ expect(solver.state).toBeGreaterThan(0);
55
+ }
56
+
57
+ let tout = t + step;
58
+ while (tout <= finish + step / 2) {
59
+ const result = solver.solve(y, t, tout);
60
+ y = result.y;
61
+ t = result.t;
62
+
63
+ if (solver.state <= 0)
64
+ throw new Error(`${ode.name}: solver failed at t=${t} with state=${solver.state}, error: ${solver.error}`);
65
+
66
+ tout += step;
67
+ }
68
+
69
+ // Check final solution against reference point
70
+ for (let j = 0; j < neq; j++) {
71
+ const absErr = Math.abs(y[j] - referencePoint[j]);
72
+ const allowed = relTol * Math.abs(referencePoint[j]) + absTol;
73
+ expect(absErr).toBeLessThan(allowed);
74
+ }
75
+ }
76
+
77
+ // ─── Performance tests ──────────────────────────────────────────────────────
78
+
79
+ // Robertson: components span many orders of magnitude; use component-wise atol
80
+ describe('Robertson', () => {
81
+ it('should solve correctly', () => {
82
+ solveBenchmarkAndCheck(robertson, robertsonReferencePoint, 1e-2, 1e-7, {
83
+ mxstep: 50000,
84
+ atol: new Float64Array([1e-8, 1e-14, 1e-8]),
85
+ rtol: new Float64Array([1e-7, 1e-7, 1e-7]),
86
+ });
87
+ }, 60000);
88
+ });
89
+
90
+ describe('HIRES', () => {
91
+ it('should solve correctly', () => {
92
+ solveBenchmarkAndCheck(hires, hiresReferencePoint, 1e-3, 1e-12);
93
+ }, 60000);
94
+ });
95
+
96
+ // Van der Pol (mu=1000): very stiff, needs many internal steps
97
+ describe('van der Pol', () => {
98
+ it('should solve correctly', () => {
99
+ solveBenchmarkAndCheck(vdpol, vdpolReferencePoint, 1e-3, 1e-6, {
100
+ mxstep: 50000,
101
+ });
102
+ }, 60000);
103
+ });
104
+
105
+ describe('OREGO', () => {
106
+ it('should solve correctly', () => {
107
+ solveBenchmarkAndCheck(orego, oregoReferencePoint, 1e-2, 1e-6);
108
+ }, 60000);
109
+ });
110
+
111
+ // E5: extremely stiff (rate constants span 20 orders), needs warmup and many steps.
112
+ // Reference values are near-zero (y1~1e-290, y2~1e-22), so absTol must be generous.
113
+ describe('E5', () => {
114
+ it('should solve correctly', () => {
115
+ solveBenchmarkAndCheck(e5, e5ReferencePoint, 1, 1e-6, {
116
+ mxstep: 50000,
117
+ warmupTout: 1e-5,
118
+ });
119
+ }, 60000);
120
+ });
121
+
122
+ describe('Pollution', () => {
123
+ it('should solve correctly', () => {
124
+ solveBenchmarkAndCheck(pollution, pollutionReferencePoint, 1e-2, 1e-10);
125
+ }, 60000);
126
+ });
@@ -1,13 +1,15 @@
1
1
  // Performance tests
2
2
  import { perfProbs } from '../../index';
3
- import { methods, TIMEOUT_MS } from './test-defs';
4
- methods.forEach((method, name) => {
5
- perfProbs.forEach((odes) => {
6
- test(`Performance: method - ${name}, problem - ${odes.name}`, () => {
7
- const start = performance.now();
8
- method(odes);
9
- const elapsed = performance.now() - start;
10
- expect(elapsed).toBeLessThan(TIMEOUT_MS);
3
+ import { implicitMethods, TIMEOUT_MS } from './test-defs';
4
+ implicitMethods.forEach((method, name) => {
5
+ describe(`${name}`, () => {
6
+ perfProbs.forEach((odes) => {
7
+ test(`${odes.name}`, () => {
8
+ const start = performance.now();
9
+ method(odes);
10
+ const elapsed = performance.now() - start;
11
+ expect(elapsed).toBeLessThan(TIMEOUT_MS);
12
+ });
11
13
  });
12
14
  });
13
15
  });
@@ -1 +1 @@
1
- {"version":3,"file":"performance.test.js","sourceRoot":"","sources":["performance.test.ts"],"names":[],"mappings":"AAAA,oBAAoB;AAEpB,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,OAAO,EAAE,UAAU,EAAC,MAAM,aAAa,CAAC;AAEhD,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IAC/B,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACzB,IAAI,CAAC,yBAAyB,IAAI,eAAe,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE;YACjE,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;YAChC,MAAM,CAAC,IAAI,CAAC,CAAC;YACb,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;YAC1C,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"performance.test.js","sourceRoot":"","sources":["performance.test.ts"],"names":[],"mappings":"AAAA,oBAAoB;AAEpB,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,eAAe,EAAE,UAAU,EAAC,MAAM,aAAa,CAAC;AAExD,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IACvC,QAAQ,CAAC,GAAG,IAAI,EAAE,EAAE,GAAG,EAAE;QACvB,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACzB,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE;gBACxB,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;gBAChC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACb,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;gBAC1C,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;YAC3C,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,15 +1,17 @@
1
1
  // Performance tests
2
2
 
3
3
  import {perfProbs} from '../../index';
4
- import {methods, TIMEOUT_MS} from './test-defs';
4
+ import {implicitMethods, TIMEOUT_MS} from './test-defs';
5
5
 
6
- methods.forEach((method, name) => {
7
- perfProbs.forEach((odes) => {
8
- test(`Performance: method - ${name}, problem - ${odes.name}`, () => {
9
- const start = performance.now();
10
- method(odes);
11
- const elapsed = performance.now() - start;
12
- expect(elapsed).toBeLessThan(TIMEOUT_MS);
6
+ implicitMethods.forEach((method, name) => {
7
+ describe(`${name}`, () => {
8
+ perfProbs.forEach((odes) => {
9
+ test(`${odes.name}`, () => {
10
+ const start = performance.now();
11
+ method(odes);
12
+ const elapsed = performance.now() - start;
13
+ expect(elapsed).toBeLessThan(TIMEOUT_MS);
14
+ });
13
15
  });
14
16
  });
15
17
  });
@@ -1,9 +1,22 @@
1
1
  /* eslint-disable max-len */
2
- import { mrt, ros3prw, ros34prw } from '../../index';
2
+ import { mrt, ros3prw, ros34prw, rk4, ab5, ab4, rkdp, rk3, lsoda } from '../../index';
3
3
  export const methods = new Map([
4
4
  ['MRT', mrt],
5
5
  ['ROS3PRw', ros3prw],
6
6
  ['ROS34PRw', ros34prw],
7
+ ['RK4', rk4],
8
+ ['AB5', ab5],
9
+ ['AB4', ab4],
10
+ ['RKDP', rkdp],
11
+ ['RK3', rk3],
12
+ ['LSODA', lsoda],
13
+ ]);
14
+ /** Implicit methods suitable for stiff performance benchmarks */
15
+ export const implicitMethods = new Map([
16
+ ['MRT', mrt],
17
+ ['ROS3PRw', ros3prw],
18
+ ['ROS34PRw', ros34prw],
19
+ ['LSODA', lsoda],
7
20
  ]);
8
21
  export const MAX_MAD = 0.1;
9
22
  export const TIMEOUT_MS = 10000;
@@ -1 +1 @@
1
- {"version":3,"file":"test-defs.js","sourceRoot":"","sources":["test-defs.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,OAAO,EAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AAEnD,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC;IAC7B,CAAC,KAAK,EAAE,GAAG,CAAC;IACZ,CAAC,SAAS,EAAE,OAAO,CAAC;IACpB,CAAC,UAAU,EAAE,QAAQ,CAAC;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC;AAC3B,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAEhC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uGAkCmF,CAAC;AAExG,MAAM,kBAAkB,GAAG;IACzB,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,EAAE;IACP,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,CAAC;IACL,OAAO,EAAE,EAAE;IACX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AAG,EAAE,EAAE;IACP,EAAE,EAAE,CAAC;IACL,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,OAAO,EAAE,GAAG;IACZ,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,IAAI;IACX,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,KAAK;IACZ,GAAG,EAAE,OAAO;IACZ,EAAE,EAAE,OAAO;IACX,EAAE,EAAE,OAAO;IACX,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,EAAE;CACR,CAAC;AAEF,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAQnC,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAsB;IACnD,CAAC,OAAO,EAAE,EAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,YAAY,EAAE,mBAAmB,EAAC,CAAC;IAC9F,CAAC,QAAQ,EAAE,EAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,mBAAmB,EAAE,YAAY,EAAE,oBAAoB,EAAC,CAAC;IAClG,CAAC,YAAY,EAAE,EAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,uBAAuB,EAAE,YAAY,EAAE,wBAAwB,EAAC,CAAC;CACnH,CAAC,CAAC"}
@@ -1,10 +1,24 @@
1
1
  /* eslint-disable max-len */
2
- import {mrt, ros3prw, ros34prw} from '../../index';
2
+ import {mrt, ros3prw, ros34prw, rk4, ab5, ab4, rkdp, rk3, lsoda} from '../../index';
3
3
 
4
4
  export const methods = new Map([
5
5
  ['MRT', mrt],
6
6
  ['ROS3PRw', ros3prw],
7
7
  ['ROS34PRw', ros34prw],
8
+ ['RK4', rk4],
9
+ ['AB5', ab5],
10
+ ['AB4', ab4],
11
+ ['RKDP', rkdp],
12
+ ['RK3', rk3],
13
+ ['LSODA', lsoda],
14
+ ]);
15
+
16
+ /** Implicit methods suitable for stiff performance benchmarks */
17
+ export const implicitMethods = new Map([
18
+ ['MRT', mrt],
19
+ ['ROS3PRw', ros3prw],
20
+ ['ROS34PRw', ros34prw],
21
+ ['LSODA', lsoda],
8
22
  ]);
9
23
 
10
24
  export const MAX_MAD = 0.1;
@@ -1,5 +1,5 @@
1
1
  // Tools for solving IVPs in web-workers
2
- import { mrt, ros3prw, ros34prw, getCallback } from '../solver-tools';
2
+ import { mrt, ros3prw, ros34prw, getCallback, rk4, ab5, ab4, rkdp, rk3, lsoda } from '../solver-tools';
3
3
  import { getFunc } from './scripting';
4
4
  const ARG_INIT = 0;
5
5
  const ARG_FINAL = 1;
@@ -12,6 +12,18 @@ function getMethod(name) {
12
12
  return mrt;
13
13
  case 'ros3prw':
14
14
  return ros3prw;
15
+ case 'rk4':
16
+ return rk4;
17
+ case 'ab5':
18
+ return ab5;
19
+ case 'ab4':
20
+ return ab4;
21
+ case 'rkdp':
22
+ return rkdp;
23
+ case 'rk3':
24
+ return rk3;
25
+ case 'lsoda':
26
+ return lsoda;
15
27
  default:
16
28
  return ros34prw;
17
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"solving.js","sourceRoot":"","sources":["solving.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAExC,OAAO,EAAe,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAQ,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAExF,OAAO,EAAgB,OAAO,EAAC,MAAM,aAAa,CAAC;AAEnD,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB,oCAAoC;AACpC,SAAS,SAAS,CAAC,IAAwB;IACzC,QAAQ,IAAI,EAAE,CAAC;QACf,KAAK,KAAK;YACR,OAAO,GAAG,CAAC;QAEb,KAAK,SAAS;YACZ,OAA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