Resources Numerical accuracy Calculation policy

Mode shapes returned by the simulation worker

The vibration mode shapes that the simulation worker returns for a modal study.

How the precision is kept

Each mode is sampled at the plot mesh vertices, stored in a Float32Array, and then divided by the largest displacement so the biggest value is 1. The division happens on the 32-bit values.

Open item. Keep the normalized mode shapes in a Float64Array and make 32-bit copies only for drawing.

Calculations under this policy

1 calculation 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.

sim-worker.js PartCraft 0.8.1 32-bit in part 1 calculation Reviewed

Tests None found by the review

Normalized mode shapes

32-bit in part

Samples each mode at the plot vertices and scales it to a largest displacement of 1.

uᵥ = sample(modeᵥ) ÷ max |u|

The samples are rounded to 32-bit when written into the Float32Array and rounded again after the division. The maximum itself is taken from the 64-bit samples, so the largest value ends up within about one 32-bit rounding of 1.

  • sim-worker.js
  • lines 23 to 30
  • PartCraft 0.8.1
const shapes = r.shapes.map((u) => {
  const nv = pm.positions.length / 3, out = new Float32Array(nv * 3), t = new Float64Array(3);
  let mx = 0;
  for (let v = 0; v < nv; v++) { sampleField(r.model, u, 3, [pm.positions[3 * v], pm.positions[3 * v + 1], pm.positions[3 * v + 2]], t); out.set(t, 3 * v); mx = Math.max(mx, Math.hypot(t[0], t[1], t[2])); }
  for (let i = 0; i < out.length; i++) out[i] /= mx || 1;
  ctx.transfer(out.buffer);
  return out;
});

In detail

Method
Sample the mode at each vertex, scale by 1 ÷ max |u|.
Number types
The sampling buffer is a Float64Array of 3; the stored shape is a Float32Array. The maximum is found from the 64-bit samples before they are stored.
Tolerances
A zero maximum divides by 1.
Limits
A mode shape is a relative shape: its size is arbitrary, so the 32-bit storage matters only for how finely the shape is resolved. The frequencies in the same result are not touched here.

Approach: 32-bit step, flagged

One step stores or exchanges 32-bit values that reach a number a person reads. It is listed here with its open item, and the step is either moved to 64-bit or the app will warn where the number is read.

Every policy that takes this approach