Skip to content

Commit 6f68121

Browse files
committed
pushers game
1 parent 83d8b67 commit 6f68121

File tree

9 files changed

+1244
-20
lines changed

9 files changed

+1244
-20
lines changed

docs/content/fun/pushers.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
hide:
3+
- footer
4+
libraries:
5+
- p5
6+
- expr-eval
7+
scripts:
8+
- pushers
9+
---
10+
11+
# Particle pushers
12+
13+
!!! Warning "Under construction"
14+
15+
Some of the functionality of this tool is still in development!
16+
17+
This demo tool allows you to integrate particle trajectories in the analytically prescribed electric and magnetic fields. You may vary the fields themselves below (fields can be non-uniform and even time-varying), inject particles of different charge-to-mass ratios (by either dragging on the screen or using an injector at the bottom), and pick different parameters of the simulation (like the integration timestep, and the algorithm). You may also visualize your fields by ticking the checkboxes next to the corresponding components (the colormap is automatically rescaled to accomodate for its dynamic range).
18+
19+
The tool uses natural units, in which $c = 1$, and all the particle velocities are four-velocities, i.e., $\bm{u}\equiv \gamma\bm{\beta}$. When dragging on the screen with the right click, the charge-to-mass for the injected particle is $q/m=1$ (red), while the right click injects a particle with $q/m=-1$ (blue). Electric and magnetic fields can be either picked from a limited number of presets using the dropdown, or you can type them in in a functional form (as a function of $x$, $y$, $z$ position and time, $t$) using the boxes below (the evaluator accepts all sorts of expressions outlined [here](https://github.com/silentmatt/expr-eval)).
20+
21+
<div id="pushers">
22+
<div id="configs" style="display: inline-block">
23+
24+
<div class="dropdown">
25+
<span class="label">Field presets: </span>
26+
<select name="field-presets" id="select-field-presets">
27+
<option value="ExB">E-cross-B drift</option>
28+
<option value="betatron">betatron drift</option>
29+
<option value="gradb">grad-B drift</option>
30+
<option value="dipole">magnetic dipole</option>
31+
<option value="mirror">magnetic mirror</option>
32+
<option value="noise">magnetic noise</option>
33+
</select>
34+
</div>
35+
36+
<div class="dropdown">
37+
<span class="label">Pusher: </span>
38+
<select name="pushers" id="select-pushers">
39+
<option value="Boris">Boris</option>
40+
<option value="Vay">Vay</option>
41+
<option value="Implicit">Implicit</option>
42+
</select>
43+
</div>
44+
45+
</div>
46+
47+
<div id="canvas" class="p5canvas" style="position: relative">
48+
</div>
49+
<div id="simulation">
50+
<div class="control-element">
51+
<table id="input-fields">
52+
<tr>
53+
<th></th>
54+
<th>$x$</th>
55+
<th>$y$</th>
56+
<th>$z$</th>
57+
</tr>
58+
<tr>
59+
<td>$\bm{E}$</td>
60+
<td><input type="text" id="input-ex"/><input type="checkbox" id="draw-ex"/></td>
61+
<td><input type="text" id="input-ey" value="0.1"/><input type="checkbox" id="draw-ey"/></td>
62+
<td><input type="text" id="input-ez"/><input type="checkbox" id="draw-ez"/></td>
63+
</tr>
64+
<tr>
65+
<td>$\bm{B}$</td>
66+
<td><input type="text" id="input-bx"/><input type="checkbox" id="draw-bx"/></td>
67+
<td><input type="text" id="input-by"/><input type="checkbox" id="draw-by"/></td>
68+
<td><input type="text" id="input-bz" value="1"/><input type="checkbox" id="draw-bz"/></td>
69+
</tr>
70+
</table>
71+
</div>
72+
<div class="control-element">
73+
<table id="input-inject">
74+
<tr>
75+
<td colspan="3">$x$: <input type="number" id="input-x" value="0"/></td>
76+
<td colspan="3">$y$: <input type="number" id="input-y" value="0"/></td>
77+
</tr>
78+
<tr>
79+
<td colspan="2">$u_x$: <input type="number" id="input-ux" value="1"/></td>
80+
<td colspan="2">$u_y$: <input type="number" id="input-uy" value="1"/></td>
81+
<td colspan="2">$u_z$: <input type="number" id="input-uz" value="0"/></td>
82+
</tr>
83+
<tr>
84+
<td colspan="3">$q/m$: <input type="number" id="input-charge" value="1"/></td>
85+
<td colspan="3"><input id="btn-inject" type="button" value="Inject a particle"></input></td>
86+
</tr>
87+
</table>
88+
</div>
89+
</div>
90+
</div>
91+
92+

docs/js/hooks/expr-eval.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
document$.subscribe(() => {
2+
if (window.exprEval) {
3+
console.log("expr-eval initialized");
4+
} else {
5+
console.error("expr-eval is not loaded");
6+
}
7+
});

0 commit comments

Comments
 (0)