diff-grok 1.0.10 → 1.2.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.
- package/.claude/settings.local.json +11 -0
- package/.claude/skills/license-updater/SKILL.md +149 -0
- package/.claude/skills/license-updater/references/compatibility.md +68 -0
- package/.claude/skills/license-updater/references/templates.md +151 -0
- package/.claude/skills/license-updater/scripts/generate_license_files.py +467 -0
- package/CLAUDE.md +104 -0
- package/LICENSE +1 -1
- package/README.MD +121 -27
- package/THIRD_PARTY_LICENSES +135 -0
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/BasicModelPipelineCreator.html +4 -4
- package/docs/classes/Callback.html +5 -5
- package/docs/classes/CyclicModelPipelineCreator.html +4 -4
- package/docs/classes/IterCheckerCallback.html +5 -5
- package/docs/classes/PipelineCreator.html +4 -4
- package/docs/classes/TimeCheckerCallback.html +5 -5
- package/docs/classes/UpdatesModelPipelineCreator.html +4 -4
- package/docs/functions/ab4.html +8 -0
- package/docs/functions/ab5.html +8 -0
- package/docs/functions/applyPipeline.html +2 -2
- package/docs/functions/getCallback.html +2 -2
- package/docs/functions/getIVP.html +2 -2
- package/docs/functions/getInputVector.html +2 -2
- package/docs/functions/getIvp2WebWorker.html +2 -2
- package/docs/functions/getJScode.html +2 -2
- package/docs/functions/getOutputNames.html +2 -2
- package/docs/functions/getPipelineCreator.html +2 -2
- package/docs/functions/lsoda.html +8 -0
- package/docs/functions/mrt.html +2 -2
- package/docs/functions/printE5.html +2 -2
- package/docs/functions/printHires.html +2 -2
- package/docs/functions/printOrego.html +2 -2
- package/docs/functions/printPollution.html +2 -2
- package/docs/functions/printRobertson.html +2 -2
- package/docs/functions/printVdpol.html +2 -2
- package/docs/functions/rk3.html +8 -0
- package/docs/functions/rk4.html +8 -0
- package/docs/functions/rkdp.html +8 -0
- package/docs/functions/ros34prw.html +2 -2
- package/docs/functions/ros3prw.html +2 -2
- package/docs/functions/solveIvp.html +2 -2
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +100 -15
- package/docs/media/E5.png +0 -0
- package/docs/media/HIRES.png +0 -0
- package/docs/media/OREGO.png +0 -0
- package/docs/media/POLL-full.png +0 -0
- package/docs/media/ROBER.png +0 -0
- package/docs/media/VDP0L.png +0 -0
- package/docs/media/cyclic-model.js +3 -1
- package/docs/media/cyclic-model.js.map +1 -1
- package/docs/media/cyclic-model.ts +3 -1
- package/docs/modules.html +1 -1
- package/docs/types/Arg.html +7 -7
- package/docs/types/DifEqs.html +4 -4
- package/docs/types/Func.html +2 -2
- package/docs/types/IVP.html +20 -20
- package/docs/types/IVP2WebWorker.html +7 -7
- package/docs/types/Input.html +4 -4
- package/docs/types/Loop.html +4 -4
- package/docs/types/ODEs.html +8 -8
- package/docs/types/Output.html +4 -4
- package/docs/types/Pipeline.html +4 -4
- package/docs/types/SolverOptions.html +5 -5
- package/docs/types/Update.html +5 -5
- package/docs/types/Wrapper.html +5 -5
- package/images/E5.png +0 -0
- package/images/HIRES.png +0 -0
- package/images/OREGO.png +0 -0
- package/images/POLL-full.png +0 -0
- package/images/ROBER.png +0 -0
- package/images/VDP0L.png +0 -0
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/index.ts +2 -1
- package/jest.config.js +1 -0
- package/package.json +4 -2
- package/src/examples/check-methods.js +15 -3
- package/src/examples/check-methods.js.map +1 -1
- package/src/examples/check-methods.ts +18 -3
- package/src/examples/cyclic-model.js +3 -1
- package/src/examples/cyclic-model.js.map +1 -1
- package/src/examples/cyclic-model.ts +3 -1
- package/src/solver-tools/ab4-method.js +332 -0
- package/src/solver-tools/ab4-method.js.map +1 -0
- package/src/solver-tools/ab4-method.ts +395 -0
- package/src/solver-tools/ab5-method.js +334 -0
- package/src/solver-tools/ab5-method.js.map +1 -0
- package/src/solver-tools/ab5-method.ts +397 -0
- package/src/solver-tools/cvode/common.js +487 -0
- package/src/solver-tools/cvode/common.js.map +1 -0
- package/src/solver-tools/cvode/common.ts +549 -0
- package/src/solver-tools/cvode/cvode.js +1062 -0
- package/src/solver-tools/cvode/cvode.js.map +1 -0
- package/src/solver-tools/cvode/cvode.ts +1226 -0
- package/src/solver-tools/cvode/cvode_adams.js +124 -0
- package/src/solver-tools/cvode/cvode_adams.js.map +1 -0
- package/src/solver-tools/cvode/cvode_adams.ts +142 -0
- package/src/solver-tools/cvode/cvode_bdf.js +153 -0
- package/src/solver-tools/cvode/cvode_bdf.js.map +1 -0
- package/src/solver-tools/cvode/cvode_bdf.ts +164 -0
- package/src/solver-tools/cvode/cvode_class.js +158 -0
- package/src/solver-tools/cvode/cvode_class.js.map +1 -0
- package/src/solver-tools/cvode/cvode_class.ts +271 -0
- package/src/solver-tools/cvode/cvode_hin.js +119 -0
- package/src/solver-tools/cvode/cvode_hin.js.map +1 -0
- package/src/solver-tools/cvode/cvode_hin.ts +150 -0
- package/src/solver-tools/cvode/cvode_io.js +203 -0
- package/src/solver-tools/cvode/cvode_io.js.map +1 -0
- package/src/solver-tools/cvode/cvode_io.ts +258 -0
- package/src/solver-tools/cvode/cvode_ls.js +210 -0
- package/src/solver-tools/cvode/cvode_ls.js.map +1 -0
- package/src/solver-tools/cvode/cvode_ls.ts +249 -0
- package/src/solver-tools/cvode/cvode_nls.js +220 -0
- package/src/solver-tools/cvode/cvode_nls.js.map +1 -0
- package/src/solver-tools/cvode/cvode_nls.ts +259 -0
- package/src/solver-tools/cvode/cvode_root.js +415 -0
- package/src/solver-tools/cvode/cvode_root.js.map +1 -0
- package/src/solver-tools/cvode/cvode_root.ts +503 -0
- package/src/solver-tools/cvode/dense_linalg.js +131 -0
- package/src/solver-tools/cvode/dense_linalg.js.map +1 -0
- package/src/solver-tools/cvode/dense_linalg.ts +144 -0
- package/src/solver-tools/cvode/index.js +26 -0
- package/src/solver-tools/cvode/index.js.map +1 -0
- package/src/solver-tools/cvode/index.ts +64 -0
- package/src/solver-tools/cvode-method.js +114 -0
- package/src/solver-tools/cvode-method.js.map +1 -0
- package/src/solver-tools/cvode-method.ts +129 -0
- package/src/solver-tools/index.js +7 -0
- package/src/solver-tools/index.js.map +1 -1
- package/src/solver-tools/index.ts +7 -0
- package/src/solver-tools/lsoda/blas.js +257 -0
- package/src/solver-tools/lsoda/blas.js.map +1 -0
- package/src/solver-tools/lsoda/blas.ts +279 -0
- package/src/solver-tools/lsoda/cfode.js +84 -0
- package/src/solver-tools/lsoda/cfode.js.map +1 -0
- package/src/solver-tools/lsoda/cfode.ts +95 -0
- package/src/solver-tools/lsoda/common.js +94 -0
- package/src/solver-tools/lsoda/common.js.map +1 -0
- package/src/solver-tools/lsoda/common.ts +135 -0
- package/src/solver-tools/lsoda/corfailure.js +36 -0
- package/src/solver-tools/lsoda/corfailure.js.map +1 -0
- package/src/solver-tools/lsoda/corfailure.ts +42 -0
- package/src/solver-tools/lsoda/correction.js +112 -0
- package/src/solver-tools/lsoda/correction.js.map +1 -0
- package/src/solver-tools/lsoda/correction.ts +131 -0
- package/src/solver-tools/lsoda/dense.js +121 -0
- package/src/solver-tools/lsoda/dense.js.map +1 -0
- package/src/solver-tools/lsoda/dense.ts +141 -0
- package/src/solver-tools/lsoda/index.js +15 -0
- package/src/solver-tools/lsoda/index.js.map +1 -0
- package/src/solver-tools/lsoda/index.ts +17 -0
- package/src/solver-tools/lsoda/intdy.js +54 -0
- package/src/solver-tools/lsoda/intdy.js.map +1 -0
- package/src/solver-tools/lsoda/intdy.ts +62 -0
- package/src/solver-tools/lsoda/lsoda.js +578 -0
- package/src/solver-tools/lsoda/lsoda.js.map +1 -0
- package/src/solver-tools/lsoda/lsoda.ts +644 -0
- package/src/solver-tools/lsoda/methodswitch.js +108 -0
- package/src/solver-tools/lsoda/methodswitch.js.map +1 -0
- package/src/solver-tools/lsoda/methodswitch.ts +119 -0
- package/src/solver-tools/lsoda/orderswitch.js +97 -0
- package/src/solver-tools/lsoda/orderswitch.js.map +1 -0
- package/src/solver-tools/lsoda/orderswitch.ts +107 -0
- package/src/solver-tools/lsoda/prja.js +54 -0
- package/src/solver-tools/lsoda/prja.js.map +1 -0
- package/src/solver-tools/lsoda/prja.ts +61 -0
- package/src/solver-tools/lsoda/scaleh.js +41 -0
- package/src/solver-tools/lsoda/scaleh.js.map +1 -0
- package/src/solver-tools/lsoda/scaleh.ts +45 -0
- package/src/solver-tools/lsoda/solsy.js +25 -0
- package/src/solver-tools/lsoda/solsy.js.map +1 -0
- package/src/solver-tools/lsoda/solsy.ts +30 -0
- package/src/solver-tools/lsoda/stoda.js +270 -0
- package/src/solver-tools/lsoda/stoda.js.map +1 -0
- package/src/solver-tools/lsoda/stoda.ts +298 -0
- package/src/solver-tools/lsoda-method.js +134 -0
- package/src/solver-tools/lsoda-method.js.map +1 -0
- package/src/solver-tools/lsoda-method.ts +154 -0
- package/src/solver-tools/mrt-method.js +81 -18
- package/src/solver-tools/mrt-method.js.map +1 -1
- package/src/solver-tools/mrt-method.ts +111 -21
- package/src/solver-tools/rk3-method.js +210 -0
- package/src/solver-tools/rk3-method.js.map +1 -0
- package/src/solver-tools/rk3-method.ts +257 -0
- package/src/solver-tools/rk4-method.js +236 -0
- package/src/solver-tools/rk4-method.js.map +1 -0
- package/src/solver-tools/rk4-method.ts +286 -0
- package/src/solver-tools/rkdp-method.js +247 -0
- package/src/solver-tools/rkdp-method.js.map +1 -0
- package/src/solver-tools/rkdp-method.ts +300 -0
- package/src/solver-tools/ros34prw-method.js +1 -1
- package/src/solver-tools/ros34prw-method.js.map +1 -1
- package/src/solver-tools/ros34prw-method.ts +1 -1
- package/src/solver-tools/ros3prw-method.js +1 -1
- package/src/solver-tools/ros3prw-method.js.map +1 -1
- package/src/solver-tools/ros3prw-method.ts +1 -1
- package/src/solver-tools/solver-defs.js +7 -0
- package/src/solver-tools/solver-defs.js.map +1 -1
- package/src/solver-tools/solver-defs.ts +7 -0
- package/src/tests/correctness.test.js +6 -4
- package/src/tests/correctness.test.js.map +1 -1
- package/src/tests/correctness.test.ts +6 -4
- package/src/tests/cvode-lib-correctness.test.js +404 -0
- package/src/tests/cvode-lib-correctness.test.js.map +1 -0
- package/src/tests/cvode-lib-correctness.test.ts +505 -0
- package/src/tests/cvode-lib-performance.test.js +103 -0
- package/src/tests/cvode-lib-performance.test.js.map +1 -0
- package/src/tests/cvode-lib-performance.test.ts +128 -0
- package/src/tests/lsoda-lib-correctness.test.js +223 -0
- package/src/tests/lsoda-lib-correctness.test.js.map +1 -0
- package/src/tests/lsoda-lib-correctness.test.ts +283 -0
- package/src/tests/lsoda-lib-performance.test.js +95 -0
- package/src/tests/lsoda-lib-performance.test.js.map +1 -0
- package/src/tests/lsoda-lib-performance.test.ts +126 -0
- package/src/tests/performance.test.js +12 -8
- package/src/tests/performance.test.js.map +1 -1
- package/src/tests/performance.test.ts +12 -8
- package/src/tests/test-defs.js +20 -1
- package/src/tests/test-defs.js.map +1 -1
- package/src/tests/test-defs.ts +22 -1
- package/src/worker-tools/solving.js +15 -1
- package/src/worker-tools/solving.js.map +1 -1
- package/src/worker-tools/solving.ts +23 -1
|
@@ -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,gFAAgF;AAChF,SAAS,QAAQ,CAAC,GAAS;IACzB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;QACpB,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QACrB,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;AACJ,CAAC;AAWD,2GAA2G;AAC3G,SAAS,sBAAsB,CAC7B,GAAS,EAAE,cAA4B,EAAE,MAAc,EAAE,MAAc,EAAE,IAAiB;;IAE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,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,17 @@
|
|
|
1
1
|
// Performance tests
|
|
2
2
|
import { perfProbs } from '../../index';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import { implicitMethods, perfExclusions, TIMEOUT_MS } from './test-defs';
|
|
4
|
+
implicitMethods.forEach((method, name) => {
|
|
5
|
+
describe(`${name}`, () => {
|
|
6
|
+
const excluded = perfExclusions.get(name);
|
|
7
|
+
perfProbs.forEach((odes) => {
|
|
8
|
+
const testFn = (excluded === null || excluded === void 0 ? void 0 : excluded.has(odes.name)) ? test.skip : test;
|
|
9
|
+
testFn(`${odes.name}`, () => {
|
|
10
|
+
const start = performance.now();
|
|
11
|
+
method(odes);
|
|
12
|
+
const elapsed = performance.now() - start;
|
|
13
|
+
expect(elapsed).toBeLessThan(TIMEOUT_MS);
|
|
14
|
+
});
|
|
11
15
|
});
|
|
12
16
|
});
|
|
13
17
|
});
|
|
@@ -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,
|
|
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,cAAc,EAAE,UAAU,EAAC,MAAM,aAAa,CAAC;AAExE,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IACvC,QAAQ,CAAC,GAAG,IAAI,EAAE,EAAE,GAAG,EAAE;QACvB,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC1C,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACzB,MAAM,MAAM,GAAG,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YAC3D,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE;gBAC1B,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,19 @@
|
|
|
1
1
|
// Performance tests
|
|
2
2
|
|
|
3
3
|
import {perfProbs} from '../../index';
|
|
4
|
-
import {
|
|
4
|
+
import {implicitMethods, perfExclusions, TIMEOUT_MS} from './test-defs';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
implicitMethods.forEach((method, name) => {
|
|
7
|
+
describe(`${name}`, () => {
|
|
8
|
+
const excluded = perfExclusions.get(name);
|
|
9
|
+
perfProbs.forEach((odes) => {
|
|
10
|
+
const testFn = excluded?.has(odes.name) ? test.skip : test;
|
|
11
|
+
testFn(`${odes.name}`, () => {
|
|
12
|
+
const start = performance.now();
|
|
13
|
+
method(odes);
|
|
14
|
+
const elapsed = performance.now() - start;
|
|
15
|
+
expect(elapsed).toBeLessThan(TIMEOUT_MS);
|
|
16
|
+
});
|
|
13
17
|
});
|
|
14
18
|
});
|
|
15
19
|
});
|
package/src/tests/test-defs.js
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
|
-
import { mrt, ros3prw, ros34prw } from '../../index';
|
|
2
|
+
import { mrt, ros3prw, ros34prw, rk4, ab5, ab4, rkdp, rk3, lsoda, cvode } 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
|
+
['CVODE', cvode],
|
|
14
|
+
]);
|
|
15
|
+
/** Implicit methods suitable for stiff performance benchmarks */
|
|
16
|
+
export const implicitMethods = new Map([
|
|
17
|
+
['MRT', mrt],
|
|
18
|
+
['ROS3PRw', ros3prw],
|
|
19
|
+
['ROS34PRw', ros34prw],
|
|
20
|
+
['LSODA', lsoda],
|
|
21
|
+
['CVODE', cvode],
|
|
22
|
+
]);
|
|
23
|
+
/** Performance problems to skip per method (known limitations) */
|
|
24
|
+
export const perfExclusions = new Map([
|
|
25
|
+
['CVODE', new Set(['E5'])],
|
|
7
26
|
]);
|
|
8
27
|
export const MAX_MAD = 0.1;
|
|
9
28
|
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;
|
|
1
|
+
{"version":3,"file":"test-defs.js","sourceRoot":"","sources":["test-defs.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,OAAO,EAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAC;AAE3F,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;IACtB,CAAC,KAAK,EAAE,GAAG,CAAC;IACZ,CAAC,KAAK,EAAE,GAAG,CAAC;IACZ,CAAC,KAAK,EAAE,GAAG,CAAC;IACZ,CAAC,MAAM,EAAE,IAAI,CAAC;IACd,CAAC,KAAK,EAAE,GAAG,CAAC;IACZ,CAAC,OAAO,EAAE,KAAK,CAAC;IAChB,CAAC,OAAO,EAAE,KAAK,CAAC;CACjB,CAAC,CAAC;AAEH,iEAAiE;AACjE,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IACrC,CAAC,KAAK,EAAE,GAAG,CAAC;IACZ,CAAC,SAAS,EAAE,OAAO,CAAC;IACpB,CAAC,UAAU,EAAE,QAAQ,CAAC;IACtB,CAAC,OAAO,EAAE,KAAK,CAAC;IAChB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,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiDR,CAAC;AAElB,MAAM,uBAAuB,GAAG;IAC9B,GAAG,EAAE,CAAC;IACN,GAAG,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"}
|
package/src/tests/test-defs.ts
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
|
-
import {mrt, ros3prw, ros34prw} from '../../index';
|
|
2
|
+
import {mrt, ros3prw, ros34prw, rk4, ab5, ab4, rkdp, rk3, lsoda, cvode} 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
|
+
['CVODE', cvode],
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
/** Implicit methods suitable for stiff performance benchmarks */
|
|
18
|
+
export const implicitMethods = new Map([
|
|
19
|
+
['MRT', mrt],
|
|
20
|
+
['ROS3PRw', ros3prw],
|
|
21
|
+
['ROS34PRw', ros34prw],
|
|
22
|
+
['LSODA', lsoda],
|
|
23
|
+
['CVODE', cvode],
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
/** Performance problems to skip per method (known limitations) */
|
|
27
|
+
export const perfExclusions = new Map<string, Set<string>>([
|
|
28
|
+
['CVODE', new Set(['E5'])],
|
|
8
29
|
]);
|
|
9
30
|
|
|
10
31
|
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, cvode } from '../solver-tools';
|
|
3
3
|
import { getFunc } from './scripting';
|
|
4
4
|
const ARG_INIT = 0;
|
|
5
5
|
const ARG_FINAL = 1;
|
|
@@ -12,6 +12,20 @@ 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;
|
|
27
|
+
case 'cvode':
|
|
28
|
+
return cvode;
|
|
15
29
|
default:
|
|
16
30
|
return ros34prw;
|
|
17
31
|
}
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"solving.js","sourceRoot":"","sources":["solving.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAExC,OAAO,EAAe,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAQ,WAAW,EAC7D,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAEjE,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,OAAO,OAAO,CAAC;QAEjB,KAAK,KAAK;YACR,OAAO,GAAG,CAAC;QAEb,KAAK,KAAK;YACR,OAAO,GAAG,CAAC;QAEb,KAAK,KAAK;YACR,OAAO,GAAG,CAAC;QAEb,KAAK,MAAM;YACT,OAAO,IAAI,CAAC;QAEd,KAAK,KAAK;YACR,OAAO,G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AG,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAE7C,OAAO,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Tools for solving IVPs in web-workers
|
|
2
2
|
|
|
3
|
-
import {SolverMethod, mrt, ros3prw, ros34prw, ODEs, getCallback
|
|
3
|
+
import {SolverMethod, mrt, ros3prw, ros34prw, ODEs, getCallback,
|
|
4
|
+
rk4, ab5, ab4, rkdp, rk3, lsoda, cvode} from '../solver-tools';
|
|
4
5
|
import {Func} from '../solver-tools/solver-defs';
|
|
5
6
|
import {IVP2WebWorker, getFunc} from './scripting';
|
|
6
7
|
|
|
@@ -18,6 +19,27 @@ function getMethod(name: string | undefined): SolverMethod {
|
|
|
18
19
|
case 'ros3prw':
|
|
19
20
|
return ros3prw;
|
|
20
21
|
|
|
22
|
+
case 'rk4':
|
|
23
|
+
return rk4;
|
|
24
|
+
|
|
25
|
+
case 'ab5':
|
|
26
|
+
return ab5;
|
|
27
|
+
|
|
28
|
+
case 'ab4':
|
|
29
|
+
return ab4;
|
|
30
|
+
|
|
31
|
+
case 'rkdp':
|
|
32
|
+
return rkdp;
|
|
33
|
+
|
|
34
|
+
case 'rk3':
|
|
35
|
+
return rk3;
|
|
36
|
+
|
|
37
|
+
case 'lsoda':
|
|
38
|
+
return lsoda;
|
|
39
|
+
|
|
40
|
+
case 'cvode':
|
|
41
|
+
return cvode;
|
|
42
|
+
|
|
21
43
|
default:
|
|
22
44
|
return ros34prw;
|
|
23
45
|
}
|