Resources Numerical accuracy

Calculations

Every calculation under our calculation policies: what it works out, its formula and the precision it runs at. Open one to see its code as it is in the released app.

  • 6,917 calculations in 1,248 source files
  • 143 exact
  • 6,286 in 64-bit
  • 335 with a 32-bit step
  • Last reviewed

Calculations

  • Permeability of free space

    The constant μ₀ used for air, linear materials and the Maxwell stress.

    μ₀ = 4 × 10⁻⁷ × π

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Reluctivity from a measured B–H curve

    Turns a table of B and H points into ν(B²) and its derivative for the solver.

    H(B) by a monotone cubic through the points; beyond the last point H = H_s + (B − B_s) ÷ μ₀; ν = H ÷ B; dν/dB² = (H′ ÷ B − H ÷ B²) ÷ (2B)

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Banded Cholesky solve

    Factors the tangent matrix and solves for the correction of the potential.

    K = L Lᵀ in band storage; forward then back substitution

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Triangle areas and shape-function gradients

    The area, center and the three gradient vectors of every triangle.

    d = (x₁ − x₀)(y₂ − y₀) − (x₂ − x₀)(y₁ − y₀); area = |d| ÷ 2; ∇Nᵢ = (bᵢ, cᵢ) ÷ d

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Residual and tangent matrix

    Assembles the out-of-balance load and, when asked, the tangent stiffness for the current potential.

    R = load − Σ ν A (∇Nᵢ·∇A); K_ik = Σ A (ν ∇Nᵢ·∇N_k + 2ν′ (∇Nᵢ·∇A)(∇N_k·∇A))

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Newton iteration

    Repeats solve and update until the potential stops changing.

    A ← A + α ΔA, α halved until the residual norm falls; stop when |ΔA| ÷ |A| < tol or |R| < 1e-14 × |load|

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Flux density and energy per element

    The flux density in each triangle and the stored energy per unit depth.

    B = (∂A/∂y, −∂A/∂x); |B| = hypot; energy = Σ ½ ν(|B|²) |B|² × area

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Force and torque by the Maxwell stress

    The force per meter of depth and the torque about the origin on everything inside a set of elements.

    t = ((B_x² − ½B²) n_x + B_x B_y n_y, B_x B_y n_x + (B_y² − ½B²) n_y) ÷ μ₀; F = Σ t × dl; τ = Σ (x t_y − y t_x) dl

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Sketch regions in SI units

    Converts each profile to meters and sets its material, magnet direction or coil current density.

    x_m = x_mm × 1e-3; area_m² = area_mm² × 1e-3 × 1e-3; B_r = B (cos θ, sin θ); J = I ÷ area

    Magnet study: 2D field, force and torque magnet-study.js
    • PartCraft
    64-bit
  • Mesh sizes for the study

    The triangle size asked for in each body, in each air gap and in the surrounding air.

    base = size × (1 + 2 pad) ÷ 14 ÷ q; body: narrowest side ÷ 5 ÷ q; gap: gap ÷ 4 ÷ q

    Magnet study: 2D field, force and torque magnet-study.js
    • PartCraft
    64-bit
  • Air gap between two bodies

    The narrowest distance between two profiles that stand apart.

    d = min over the corners of each profile of the distance to the other's edges

    Magnet study: 2D field, force and torque magnet-study.js
    • PartCraft
    64-bit
  • Force and torque on each body

    The force in newtons and the torque about the body's own center, for the depth given.

    F = F_per_m × depth; τ = (τ_origin − (c_x F_y − c_y F_x)) × depth

    Magnet study: 2D field, force and torque magnet-study.js
    • PartCraft
    64-bit
  • Results as CSV

    Writes the peak flux density, forces and torques to a CSV file.

    number → toPrecision(8)

    Magnet study: 2D field, force and torque magnet-study.js
    • PartCraft
    64-bit
  • Orientation test

    Which side of a directed line a point lies on, used to walk the triangulation.

    (b_x − a_x)(c_y − a_y) − (b_y − a_y)(c_x − a_x)

    Magnet study: 2D field, force and torque magnetmesh.js
    • PartCraft
    64-bit
  • In-circle test

    Whether a new point lies inside the circle through a triangle's corners, which decides the Delaunay cavity.

    3 × 3 determinant of (a − d, b − d, c − d) with their squared lengths

    Magnet study: 2D field, force and torque magnetmesh.js
    • PartCraft
    64-bit
  • Circumcenter and quality of a triangle

    A triangle's circumcenter, circumradius and shortest edge, used to decide whether to refine it.

    u = (c_y |b|² − b_y |c|², b_x |c|² − c_x |b|²) ÷ (2 (b_x c_y − b_y c_x)), b and c relative to a

    Magnet study: 2D field, force and torque magnetmesh.js
    • PartCraft
    64-bit
  • Encroached boundary segment

    Whether a point lies inside the circle whose diameter is a boundary segment, in which case the segment is split at its midpoint.

    (p − mid)² < (|a − b|² ÷ 4) × (1 − 1e-12)

    Magnet study: 2D field, force and torque magnetmesh.js
    • PartCraft
    64-bit
  • Smallest and largest mesh angle

    The mesh quality figures shown with the result.

    angle = atan2(|u × v|, u·v) in degrees

    Magnet study: 2D field, force and torque magnetmesh.js
    • PartCraft
    64-bit
  • Coarse element matrix

    Forms Rᵀ K R for one fine element inside a coarse element.

    K_coarse += s × Rᵀ K R

    Geometric multigrid for the voxel stress model mg.js
    • PartCraft
    64-bit
  • Inverse of each node's 3 × 3 block

    Inverts the diagonal block of every node for the block Jacobi smoother.

    D⁻¹ = adj(D) ÷ det(D)

    Geometric multigrid for the voxel stress model mg.js
    • PartCraft
    64-bit
  • Damped block Jacobi sweep

    One smoothing step on a level.

    x ← x + ω D⁻¹ (b − A x), ω = 0.6

    Geometric multigrid for the voxel stress model mg.js
    • PartCraft
    64-bit
  • Restriction and prolongation

    Moves residuals to the coarser grid and corrections back to the finer one.

    weight = ½ for each direction in which the fine node lies between two coarse nodes

    Geometric multigrid for the voxel stress model mg.js
    • PartCraft
    64-bit
  • Coarsest-level factorization

    Factors the coarsest level's matrix once so each cycle can solve it directly.

    A = L Lᵀ in band storage, nodes renumbered with the longest axis slowest

    Geometric multigrid for the voxel stress model mg.js
    • PartCraft
    64-bit
  • Coarsest-level solve

    Forward and back substitution with the stored factor.

    Geometric multigrid for the voxel stress model mg.js
    • PartCraft
    64-bit
  • Signed area of a pixel outline

    Tells an outer outline from a hole and gives the hole size used to drop specks.

    a = ½ × Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ); hole kept when 2 × √(|a| ÷ π) ≥ minHole

    Photo to sketch: outline fitting and scale photo-sketch.js
    • PartCraft
    64-bit
  • Outline simplification

    Keeps only the outline points that lie farther than the tolerance from the chord between their neighbors.

    d = |dx·(Qy − Ay) − dy·(Qx − Ax)| ÷ L; keep the farthest point when d > tol

    Photo to sketch: outline fitting and scale photo-sketch.js
    • PartCraft
    64-bit
  • Circle through outline points

    The center and radius of the circle that best fits a run of outline points, with its largest and root-mean-square deviation.

    u = x − x̄, v = y − ȳ; solve [Σu² Σuv; Σuv Σv²]·(u_c, v_c) = ½·(Σu³ + Σuv², Σv³ + Σvu²); r = mean distance to the center

    Photo to sketch: outline fitting and scale photo-sketch.js
    • PartCraft
    64-bit
  • Line through outline points

    The direction of the straight line that best fits a run of outline points, through their centroid.

    θ = ½ × atan2(2·Σuv, Σu² − Σv²); d = (cos θ, sin θ)

    Photo to sketch: outline fitting and scale photo-sketch.js
    • PartCraft
    64-bit
  • Corner where two fitted lines meet

    Places a corner of the sketch at the intersection of the two fitted lines on either side of it.

    den = u_d × v_d; t = ((v_p − u_p) × v_d) ÷ den; corner = u_p + t·u_d

    Photo to sketch: outline fitting and scale photo-sketch.js
    • PartCraft
    64-bit
  • Arc ends and refit

    Extends each arc along the outline while the points stay on its circle, fits the circle again and puts the two end points on it.

    grow while | |P − c| − r | ≤ min(0.75, tol ÷ 2); end = c + r·(P − c) ÷ |P − c|

    Photo to sketch: outline fitting and scale photo-sketch.js
    • PartCraft
    64-bit
  • Squaring of near-horizontal and near-vertical lines

    Makes a line that is within the squaring angle of horizontal or vertical exactly so, by giving both ends the same coordinate.

    angle = |atan2(B_y − A_y, B_x − A_x)| in degrees; shared y = (A_y + B_y) ÷ 2 or shared x = (A_x + B_x) ÷ 2

    Photo to sketch: outline fitting and scale photo-sketch.js
    • PartCraft
    64-bit
  • Scale of a silhouette

    Millimeters per pixel from one stated length, and the mapping of pixel coordinates to sketch coordinates.

    mm = stated length ÷ pixel extent; X = (x − x₀) × mm; Y = (y₁ − y) × mm

    Photo to sketch: outline fitting and scale photo-sketch.js
    • PartCraft
    64-bit
  • Scale of a pen drawing

    Millimeters per pixel for traced pen lines, from one stated length and the extent of the traced lines and arcs.

    extent from line ends, arc ends and arc centers; mm = stated length ÷ extent

    Photo to sketch: outline fitting and scale photo-sketch.js
    • PartCraft
    64-bit
  • Dot product in chunks

    Each thread sums its share of a dot product in chunks of 4096 entries.

    P_c = Σ aᵢ·bᵢ over chunk c

    Threaded solver kernels and conjugate gradients pool.js
    • PartCraft
    64-bit
  • Sum of the chunk partials

    Adds the chunk sums of a dot product in chunk order on the coordinating thread.

    a·b = Σ P_c

    Threaded solver kernels and conjugate gradients pool.js
    • PartCraft
    64-bit
  • Conjugate-gradient update

    Advances the solution and the residual by one step and sums the new residual's square.

    x += α·p; r −= α·q; P_c = Σ rᵢ²

    Threaded solver kernels and conjugate gradients pool.js
    • PartCraft
    64-bit
  • Sparse matrix times vector

    y = A·x for a matrix stored row by row, with the rows split between the threads.

    y_r = Σ_k v_k · x[col_k]

    Threaded solver kernels and conjugate gradients pool.js
    • PartCraft
    64-bit
  • Voxel stiffness times vector

    y = K·x for a voxel model without assembling K: each node gathers the contributions of its elements.

    y_n = Σ over elements at n of s_e · (K_e · x_e) rows of n, plus the 3 × 3 penalty block of a constrained node

    Threaded solver kernels and conjugate gradients pool.js
    • PartCraft
    64-bit
  • Node-block preconditioner and smoother

    Multiplies each node's three values by its 3 × 3 block, or adds a damped correction ω·M·(b − r).

    dst = M·src or dst += ω · M · (b − src)

    Threaded solver kernels and conjugate gradients pool.js
    • PartCraft
    64-bit
  • Constraint projection

    Sets the values of inactive nodes to zero and applies each constrained node's 3 × 3 projector.

    v_n = 0 (inactive); v_n ← P_n · v_n (constrained)

    Threaded solver kernels and conjugate gradients pool.js
    • PartCraft
    64-bit
  • Multigrid restriction

    Carries a residual from a fine grid to the grid of half the resolution.

    r_c(N) = Σ over the 27 fine neighbors of w · r_f; w = product per axis of 1 (same node) or ½ (between nodes)

    Threaded solver kernels and conjugate gradients pool.js
    • PartCraft
    64-bit
  • Multigrid prolongation

    Adds a coarse-grid correction to the fine grid by linear interpolation.

    x_f(n) += w · Σ x_c over the 1, 2, 4 or 8 coarse nodes around n; w = ½ per axis in which n lies between coarse nodes

    Threaded solver kernels and conjugate gradients pool.js
    • PartCraft
    64-bit
  • Geometric stiffness times vector

    y = s·(G ⊗ I₃)·x from per-element blocks, used by the buckling study.

    y_n = s · Σ over elements at n of Σ_b G_e[a, b] · x_b

    Threaded solver kernels and conjugate gradients pool.js
    • PartCraft
    64-bit
  • Conjugate gradients for a voxel model

    Solves K·u = f for a voxel stress model on the thread pool.

    res = ‖r‖ ÷ ‖b‖; stop when res < tol; α = (r·z) ÷ (p·Kp); β = (r·z)_new ÷ (r·z)_old

    Threaded solver kernels and conjugate gradients pool.js
    • PartCraft
    64-bit
  • Conjugate gradients for a sparse matrix

    Solves A·x = b for an assembled sparse matrix on the thread pool.

    res = ‖r‖ ÷ ‖b‖; stop when res < tol; α = (r·z) ÷ (p·Ap)

    Threaded solver kernels and conjugate gradients pool.js
    • PartCraft
    64-bit
  • Bend allowance

    The length of the neutral layer through a bend, which the flat pattern gives to that bend.

    BA = θ × (r + k × t)

    Sheet metal bends and flat pattern sheetmetal.js
    • PartCraft
    64-bit
  • Chain of profile lines

    Orders the lines of an open profile end to end, or reports that they are not one chain.

    two ends are the same point when their distance ≤ 1e-6 × max(1, largest coordinate size)

    Sheet metal bends and flat pattern sheetmetal.js
    • PartCraft
    64-bit
  • Bend angle, center and tangent length

    For every corner of the profile: the signed bend angle, the radius on the path side and the offset side, the distance the bend takes from each leg, and the bend's center.

    θ = atan2(u × w, u · w); d = r_path × tan(|θ| ÷ 2); c = P + left(u) × sign(θ) × r_path − u × d

    Sheet metal bends and flat pattern sheetmetal.js
    • PartCraft
    64-bit
  • Arc of a bend in the profile

    The arc of a bend between its two tangent points, with its middle point and 17 points along it.

    sweep = a₁ − a₀ brought to (0, 2π] or [−2π, 0); point = c + r × (cos t, sin t)

    Sheet metal bends and flat pattern sheetmetal.js
    • PartCraft
    64-bit
  • Straight runs between bends

    The flat length of each leg: its drawn length less what the bends at its ends take.

    straightⱼ = |Pⱼ₊₁ − Pⱼ| − dⱼ − dⱼ₊₁

    Sheet metal bends and flat pattern sheetmetal.js
    • PartCraft
    64-bit

A calculation is added only after its source was read. Each statement can be checked in the code shown on its policy's page; the app repositories are public. When a release changes a calculation, its page says so until it has been read again.