Skip to content

Parametric: kinematic mates, motion studies and static stress analysis - #257

Merged
jelveh merged 118 commits into
mainfrom
parmf-nov27/integration
Nov 28, 2026
Merged

jelveh merged 118 commits into
mainfrom
parmf-nov27/integration

Conversation

@jelveh

@jelveh jelveh commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Adds kinematics to assemblies and linear static stress analysis to parts.

Assemblies: limit and mechanical mates, motion studies

Limit mates

  • Distance and angle mates can take a minimum and maximum instead of a value. The component moves freely between them, and a drag stops at the limits.

Mechanical mates

  • Hinge: with optional angle limits.
  • Slider: with optional travel limits.
  • Gear: ratio from pitch diameters or teeth, with a reverse option.
  • Rack and pinion: by pitch diameter or travel per turn.
  • Screw: pitch, right- or left-hand.
  • Width: centres a tab between two faces.
  • Slot: a pin travels along a slot and stops at its ends.
  • Cam follower: a vertex, roller or flat face follower on a convex cam profile read from the part's faces.
  • Universal joint: tan φ₂ = tan φ₁ / cos β, with no branch flips past ±90° or ±180°.

Gear, rack and screw turns add up past ±180°. Dragging one gear turns the other, and dragging a rack turns its pinion.

Every new mate has its own Mate panel, appears in the Mates folder (edit, suppress, delete, flip) and is undoable. Each counts correctly in the degree-of-freedom and conflict reporting, and is strictly validated in the file.

Motion studies (Motion Study on the Assembly tab)

  • Motors: rotary or linear, at constant speed or oscillating. They go on a hinge or slider, or drive a distance or angle mate with a constant-speed, harmonic or ramp profile.
  • Computing frames: frames are computed in small slices with progress and Cancel, so the interface never freezes. A study stops with a message when it reaches a limit or locks up.
  • Playback: play, pause, loop, scrub and speed.
  • Plots: displacement, velocity and acceleration (or their angular versions) of a component, a point on it, or a mate. CSV export.
  • Interference: a check over the motion lists the times where parts overlap.
  • Saving: studies save with the assembly. Editing the assembly marks results out of date.

Parts: static stress analysis (new Analysis tab)

  • Materials: presets now have elastic modulus, Poisson's ratio, yield and tensile strength, and so do custom materials. Wood presets are refused for analysis because wood is anisotropic.
  • Fixtures: fixed, roller/slider and fixed hinge.
  • Loads:
    • force: total, normal or along a picked direction;
    • pressure;
    • gravity.
  • Values and references: values are in the part's units. Fixtures and loads are referenced by face name and flagged when their faces are gone.
  • Mesher: written for this, in TypeScript. It fills the part with a lattice of tetrahedra and trims them at its surface. Nodes are snapped to edges and corners, so each boundary triangle belongs to one face, and midside nodes sit on curved surfaces. Mesh size goes from coarse to fine.
  • Solver:
    • 10-node quadratic tetrahedra.
    • Conjugate gradients with a multigrid preconditioner, in its own worker, with progress and Cancel.
    • Studies that leave the part free to move are caught and the free motion is named.
  • Results:
    • plots: von Mises, principal stresses, displacement (total and X/Y/Z), equivalent strain and factor of safety, on the deformed shape;
    • a legend, mesh lines and click-to-probe;
    • a summary with reactions against the applied loads;
    • warnings above yield;
    • CSV and printable report export.
  • Saving: the study saves with the part. Results go out of date when the part, study or material changes. The analysis code and its worker load only when the tab is first used.

Accuracy (unit tests)

Case Result Theory
Cantilever tip deflection 1.0031 mm 1.000 mm (+0.3%)
Cantilever bending stress 75.26 MPa 75 MPa
Bar in tension F/A and FL/AE to 1e-8 exact
Plate with a hole stress concentration 3.21 about 3.2

Reactions balance the applied loads to under 1e-5, and a gravity load equals mass × g. A fine mesh of the bracket example (332k unknowns) solves in about 8 s.

Limitations

  • Linear static only: small displacements, isotropic linear elastic material, parts only (no assemblies or contact).
  • The mesh is uniform, with no local refinement. Thin walls get a finer mesh automatically, up to about a million unknowns.

Testing

  • npm run build passes on Node 22.
  • Unit tests: all 51 files and 981 tests pass on Node 22, with TZ=UTC.
  • Browser tests: the whole Parametric suite, desktop and mobile, passes (795 tests). New specs: assembly-kinematics.spec.ts and analysis.spec.ts.
  • Assembly drag cost is unchanged: about 4.7 ms per step on a 10-component chain, before and after.

Review fixes (94 commits, one per fix, each with a regression test)

Mates and motion

  • Fast motors no longer lock up: frames over half a turn are solved in smaller steps, and velocities stay accurate where steps change.
  • Gear, rack and screw turns of any size in one solve; dragging a rack far no longer jumps the other way.
  • Hinge limits past ±180° hold; a limit with equal ends fixes the part.
  • Contradicting gears and odd gear rings are over defined; a rack along its pinion's axis and a universal joint at 90° are refused with a message.
  • Flipped sliders on edges and bevel gears at right angles solve stably.
  • A limited hinge or a universal joint takes its zero from where it puts the parts.
  • Conical faces get an axis for mates.
  • A mate driver stops at a zero distance, or at 0° or 180°, instead of pushing one part through another.
  • Long studies keep only moving parts per frame: 335 MB → 16 MB for 300 parts over 20,000 frames.
  • Interference over a motion runs 4× faster, can be cancelled, and reports pairs it couldn't check.
  • Motion panel: sliders and unlimited hinges can be plotted; long studies plot and export without crashing.
  • Keyboard: Escape and Enter work inside the motor form, and the time slider steps one frame at a time with a spoken time.
  • Studies are marked out of date after a drag.
  • A seeded fuzz test checks degree-of-freedom counts, finite solves and save/reload on random assemblies.

Stress analysis

  • Solve about twice as fast: multigrid setup and cycles, and meshing.
  • Thin-walled parts mesh at the default setting; settings are capped at about 1M unknowns.
  • A mesh that misses part of a thin wall is refused instead of solved.
  • Edge recovery leaves fewer slivers.
  • Rollers hold only along the true surface: planes, cylinders, spheres and cones.
  • Reactions shared between fixtures are split correctly.
  • No 20,000-iteration fallback after the multigrid fails.
  • A clear message when the worker can't start.
  • Run waits for a pending rebuild, so loads land on the right faces.
  • Results stay current when the shape comes back to what was solved, and go out of date for edits made during a run.
  • Progress and Cancel show on the first run and in Mesh Now.
  • Fixture and load symbols follow rebuilds.
  • Direction picking works; fixture and load panels close when their item goes.
  • Inch parts show material values in psi; legend ticks are consistent, with powers of ten for large values.
  • CSV has one number per row; the report has a legend caption and clean page breaks.
  • Loading the analysis code can be retried.
  • Material dialog marks only the wrong field and refuses yield above tensile strength.
  • Names follow the app's style (Fixed1, Force1).
  • Phone layout fixes.

… solver and assembly files

Distance and angle mates can be kept between limits; hinge, gear, rack and
pinion, screw, width and slot mates. Coupling mates measure motion from where
each solve starts, so turns add up past a full turn. Motion studies step the
solver frame by frame with rotary, linear and mate-driving motors, stop at
limits or lock-ups, and give paths, turns and mate values with derivatives.
…studies

The Mate panel limits distance and angle mates and makes hinge, gear, rack and
pinion, screw, width and slot mates, each with its own selection boxes and
values. Motion studies have rotary, linear and mate-driving motors, are
calculated in slices with progress and cancel, play back with loop and scrub,
and plot a component's or mate's motion with velocity and acceleration, with
CSV download. Studies are listed in the design tree and saved with the
assembly; editing the assembly puts their results out of date.
Checks up to 40 frames spread over the motion with the worker's interference
detection, lists the times where components overlap (a click goes to that
frame), and puts the shown scene back afterwards.
…run in a worker, result plots with legend, probe and report
… are solved with weak springs, others reported as unstable
… hinges and sliders

Slider: one straight edge or axis, or two planar faces, on each component;
one move along it, no turn, optional travel limits from where it was added.
Cam: a follower (vertex, roller or flat face) touching the convex outline of
the cam's profile faces (an exact circle for an eccentric, exact arcs and
corners otherwise); a profile with a hollow is refused with its depth.
Universal joint: the cross piece holds the two yokes square, so the output
turns by atan(tan phi / cos beta), with an optional joint point.
Rotary motors can go on a hinge and linear motors on a slider.
…frames over half a turn are solved in smaller steps)
…ing components per frame (300 components, 20000 frames: 335 MB to 16 MB, 2.7 s to 0.9 s)
…used (the follower rode across the gap as if the cam were flat there)
…s a nearly incompressible material

When the multigrid solve ran out of iterations the solver went on with up to
20,000 block Jacobi iterations (about 30 s on a 45k-unknown beam, many minutes
on a fine mesh) before giving the same error; block Jacobi now only takes over
when the multigrid breaks down. A Poisson's ratio above 0.49 is named as the
cause, and the progress no longer goes below zero while the residual rises.
…esh error, not results on a third of it

A 100 x 100 x 0.5 plate meshed at the finest setting (0.65 mm elements) kept
a third of its volume, in ragged pieces, and was solved as if it were the
part. The mesher now refuses a mesh that misses (or adds) more than a tenth
of the part's volume and says that walls are thinner than the elements.
…opied again

The Analysis workspace already hands the client a copy of the surface for
the worker, but the client posted it without a transfer list, so it was
copied a second time. Tests cover the worker and client: progress, moved
arrays both ways, messages for the user and internal failures, Cancel, and
a worker that dies.
… body force, pressure in a hole) and mesh determinism
… edges normal to each face

The normals of all the fixture's faces were averaged at each node, so a node
on the edge between two of its faces (the bottom and back of a block, say)
was held only along the diagonal and slid across both faces: a block pressed
on rollers picked together on three faces showed 0.70 to 1.22 MPa instead of
a uniform 1 MPa. Normals are now kept per face and merged only where faces
meet nearly tangent.
…ure along the directions it holds

Each node's whole reaction went to the first fixture on it, so a roller under
a bar fixed at its end reported a sideways reaction (1.8 N of a 100 N pull)
that a frictionless roller cannot carry. The reaction is now split along the
node's constraint directions, each to the fixture that holds it.
The mesher finds the boundary of the tetrahedra four times, each time with a
string key and a sort per face; faces are now keyed by their two lowest
corners. The fine bracket meshes in about 0.4 s instead of 1.1 s, with the
same mesh (checked node for node on the examples).
…so a free sliding part is caught

Beside a sharp edge the mesher can leave a boundary triangle across two faces.
A roller took its normal from those triangles, so on a 37 degree wedge on
rollers under it and behind it the stray triangle held it along X: pushed
along X it was solved with no warning instead of being reported as free to
slide. A face whose triangles (all but a few) are coplanar is now held along
its own normal at every node.
…aft can slide and turn

A roller took its directions from the facets' normals, which lean along and
around a cylinder's axis: a 20 mm shaft on a roller around its side, pushed
100 N along its axis, was solved with a 100 N axial reaction (a frictionless
roller cannot carry it) instead of being reported as free to slide. A face
whose facets all face away from one axis, with its nodes at one distance
from it, is now held along the radius at each node; other curved faces are
held as before.
… six unrolled)

About 0.6 s less setup on the fine bracket (Galerkin products 2.0 + 1.3 s
down to 1.7 + 0.95 s), with the same displacements.
…elps, instead of making slivers

On coarse meshes the later edge recovery passes refused most moves and split
edges, making more crossings each pass (25, 29, 36, 66, 96 on the coarse
bracket) and squashing elements: worst quality 0.008, 356 elements below
0.1. It now stops when a pass finds no fewer crossings than the last one.
Coarse bracket: worst quality 0.053 (3 below 0.1), von Mises at its surface
nodes against a mesh 3 times finer 9.8% rms (was 16.9%), volume 1.9% short
(was 1.4%); quarter fineness 0.073 -> 0.178; the flange's default mesh
0.048 -> 0.119; finer meshes of the examples are unchanged.
…ld not start, not that the part is too large

The worker now says when its code has loaded; an error from a worker that
never did (offline, or the app updated under the page) asks to check the
connection and reload, instead of suggesting a coarser mesh.
… of the first taking it all

Three fixed fixtures on one face reported 300 N, 0 N and 0 N for a 300 N
load. Along each direction held at a node, the reaction is now shared
equally by the fixtures that hold that direction (each fixture's own
directions there), so each reports 100 N; a roller still gets only its
normal share, and the total is unchanged.
… angle past 0° or 180° stops the study there with a message (the bar went through the plate)
…t in every frame and lists the same frames after cancelled checks
…ad of one string (the same bytes; a long study no longer holds hundreds of megabytes twice)
…from where it started), not only of limited ones
…onent, not from where it was before (it was over defined when other mates turned it)
…lt size, and no mesh offered is too large to solve

The default element size kept meshes near 150k unknowns from the part's
volume alone, which on a 200 x 100 x 1.5 plate was 2.35 mm: no setting could
mesh it. Where the walls (2V/A) are thinner than that, the default is now the
wall thickness, up to a budget of 1,000,000 unknowns; compact parts keep their
sizes. The plate solves at the default in about 19 s (842k unknowns), its tip
deflection 0.96 of beam theory; a 1.5 mm sheet metal L bracket in about 5 s
(229k), 0.95 of two-cantilever theory.

- Where some walls are still thinner (a thin plate with a thick boss), the
  worker meshes finer in steps, down to the smallest size offered, and says
  so through the mesh's size; at that size it says the walls need more than
  a browser can solve.
- The finest size offered stops at the same budget (measured in Chromium:
  961k unknowns peak at 2.4 GB in the page's process, 21 s; 2.1M at 4.3 GB).
- The unknowns estimate counts the cut elements at the surface (within 3% of
  a cube, the bracket and the plate; the volume-only one was 26% low on the
  plate and 25% high on the cube).
…lve, estimates unknowns with the surface, and says when walls needed a finer mesh

- The Fine end stops at about a million unknowns, and the panel says
  "(the finest mesh solvable here)" there.
- The unknowns shown count the elements cut at the surface (a 1.5 mm plate
  showed about a third too few).
- A mesh made finer than set, because some walls are thinner, says so in
  the status (elements of 1.2 mm: the part's walls are thinner than the
  size set).
An end-to-end test meshes and solves a 100 x 50 x 1.5 plate at the default
and checks its deflection against beam theory.
… spheres, cylinders, cones and other surfaces of revolution

The part's surface for analysis now carries each face's surface: a plane's
normal, a sphere's centre, or the axis of a surface of revolution (read from
a circular edge of the face, as this OpenCascade build cannot give a cone's
or a torus's axis). Given these, a roller holds a plane along its normal, a
sphere and a cylinder along the radius, and a cone or torus along the facets'
normals with no part around the axis. A frustum on a roller on its cone was
held against turning by the facets (no free motion found); it is now free to
turn about its axis, and solved with that motion held by weak springs.
…ces (a cone's, a sphere's)

The workspace passes each roller face's surface, as the part gives it, to
the solver. The flange on a roller on its chamfer, pressed on its top, is
reported free to turn about its axis (the facets held it before).
…uld not be computed (it called them clear), as the Interference Detection panel does
…where the point puts the shafts (adding it turned the input shaft, its yoke 64° out of the shafts' plane)
…or mates, read from a circular edge (this OpenCascade build cannot give a cone's axis, so they had none)
… reading the file back (the sample's title matched before it was saved)
@jelveh
jelveh merged commit 7cec522 into main Nov 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant