Skip to content

Commit 6208b28

Browse files
doc: add interactive diffsol solver (#245)
* doc: add interactive diffsol solver * tidy up
1 parent 76f929d commit 6208b28

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
- [Using Diffsol from other languages](./use/use_from_other_languages.md)
4444
- [Python](./use/python.md)
4545
- [WebAssembly](./use/webassembly.md)
46+
- [WebAssembly with JIT](./use/webassembly-jit.md)
4647
- [Benchmarks](./benchmarks/benchmarks.md)
4748
- [Sundials](./benchmarks/sundials.md)
4849
- [Python (Diffrax & Casadi)](./benchmarks/python.md)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<script src="https://cdn.plot.ly/plotly-2.26.0.min.js"></script>
2+
<script src="https://diffsol-js.fly.dev/diffsol.min.js"></script>
3+
<link rel="stylesheet" href="https://diffsol-js.fly.dev/interactive-solver.css" />
4+
5+
<div id="solver" style="background-color: white; border-radius: 10px; padding: 20px;"></div>
6+
7+
<script>
8+
const { createInteractiveSolver, MatrixType, LinearSolverType, OdeSolverType } = window.DiffSol;
9+
createInteractiveSolver({
10+
divId: 'solver',
11+
diffslCode: `in_i { y0 = 1.0 }
12+
a { 2.0/3.0 } b { 4.0/3.0 }
13+
c { 1.0 } d { 1.0 }
14+
u_i {
15+
y1 = y0,
16+
y2 = y0,
17+
}
18+
F_i {
19+
a * y1 - b * y1 * y2,
20+
c * y1 * y2 - d * y2,
21+
}`,
22+
sliders: {
23+
y0: {
24+
label: 'Initial Value (y0)',
25+
min: 0.1,
26+
max: 5,
27+
initial: 1,
28+
},
29+
},
30+
outputs: {
31+
y1: {
32+
label: 'prey (y1)',
33+
},
34+
y2: {
35+
label: 'predator (y2)',
36+
},
37+
},
38+
moduleConfig: {
39+
backendUrl: 'https://diffsol-js.fly.dev',
40+
},
41+
finalTime: 20.0,
42+
matrixType: MatrixType.FaerDense,
43+
linearSolverType: LinearSolverType.Lu,
44+
showCodeEditor: true,
45+
});
46+
</script>

book/src/use/webassembly-jit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# WebAssembly with JIT
2+
3+
It is possible to use Diffsol from WebAssembly with JIT compilation, but this requires a bit more work and a backend server to perform the actual JIT compilation. If you are interested in using Diffsol in this way, please get in touch. In the meantime, you can try out the interactive diffsol solver below:
4+
5+
{{#include images/webassembly-jit.html}}

0 commit comments

Comments
 (0)