Formats the flux density, forces and flux per line that the magnet study shows, and states the size of the air box.
How the precision is kept
The study is solved elsewhere, through magnetSolve in phys-worker.js; this file formats the 64-bit results for the panel. Readouts are shortened with toPrecision, 4 significant digits by default. The exported CSV and VTK files are written by lib/results.js.
Calculations under this policy
2 calculations in 1 source file. The code is read from the released app when this page loads. It is the calculation people run, not a copy kept for this page.
text = v to p significant digits (p = 4 by default); flux in mWb when |Φ| ≥ 10⁻³ Wb, else µWb
toPrecision(p) on the 64-bit result, converted back to a number to drop trailing zeros. Flux is multiplied by 1e3 or 1e6 before rounding. These are display texts; the solver's values are not changed.
addons/magnetics/main.js
lines 120 to 121
PartCraft 0.8.1
const fmt = (v, p = 4) => String(+Number(v).toPrecision(p));
function fmtFlux(wb) { const a = Math.abs(wb); return a >= 1e-3 ? fmt(wb * 1e3) + ' mWb' : fmt(wb * 1e6) + ' µWb'; } // i18n-ignore: units
Air box size
64-bit
The width and height of the air box shown under the setup.