Datum: time-domain dynamics, jerk, hodograph & export#670
Merged
Conversation
Session 6 — release the driver and run the mechanism under its own physics.
- solver/dynamics.ts: single-DOF Eksergian equation of motion
I(θ)θ̈ + ½I′θ̇² = τ − cθ̇ − V′, with I(θ), I′(θ), V′(θ) built from the exact
first/second-order kinematic coefficients and lumped rod masses; substepped
RK4 integrator. A live "Release & run" mode + Dynamics panel (gravity/density/
damping/torque sliders, kinetic+potential+total energy read-out and plot).
- solver/ad3.ts: cubic-dual {v,d1,d2,d3} AD backend (a 4th instantiation of the
one residual algebra, atan2 exact to 3rd order) → the jerk field x‴(θ), with
the mixed term recovered by polarising three hyper-dual passes.
- Hodograph (velocity-vector-tip locus) + velocity-ratio / dead-point readout.
- model/export.ts: solved sketch → vector SVG and real DXF (LINE/CIRCLE/ARC +
sampled-spline LWPOLYLINE), motion profile → CSV.
- Self-tests 32 → 41: dynamics vs closed-form pendulum θ̈=−(g/L)cosθ (2e-8),
energy conservation (3e-9·mgL), monotone damped dissipation, I′ vs finite-diff,
static equilibrium, jerk vs finite-diff of acceleration (2.7e-5), SVG/DXF/CSV
fidelity. Verified headless in Chromium (0 console errors) + verify-project.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BzHyorzzwSMikwadDgjdyQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Session 6 — Datum comes alive
Datum already tells you where a driven mechanism sits and how fast it moves (exact velocity + acceleration off the constraint Jacobian). This session lets go of the crank: give the links mass and the mechanism runs under its own physics — a four-bar falls, swings, overshoots and settles under gravity, no driver.
The physics (the elegant part)
A well-constrained driven mechanism has exactly one degree of freedom, so its whole configuration is an implicit function
x(θ)of a single generalized coordinate. The exact first- and second-order kinematic coefficients from Session 5 (x'=J⁺e_driver,x'') are precisely what a one-DOF Lagrangian needs, so the entire dynamics collapse to a single scalar ODE — the classical Eksergian equation of motion:Each RHS eval is one re-solve + one kinematics pass — machinery Datum already owns. Mass is lumped honestly (each link a uniform rod, mass split to its endpoints), making it a bona-fide Lagrangian system whose total energy is conserved exactly.
What's new
solver/dynamics.ts— the Eksergian EOM assembler + a substepped RK4 integrator; a live "Release & run" mode and a Dynamics panel (gravity / density / damping / torque sliders, kinetic+potential+total energy read-out and an energy-vs-time plot where T and V trade off while E stays flat — the visual proof of conservation).solver/ad3.ts— a cubic-dual{v,d1,d2,d3}AD backend (a fourth instantiation of the one residual algebra,atan2carried exactly to third order) giving the jerk fieldx‴(θ) = J⁺(−3x'ᵀHx″ − x'ᵀTx'x'), the mixed term recovered by polarising three hyper-dual passes; plotted alongside speed/accel for cam smoothness.model/export.ts— the solved sketch to vector SVG (exact Béziers & arcs) and a real DXF (LINE / CIRCLE / ARC entities + sampled-spline LWPOLYLINEs, opens in any CAD), and the motion profile to CSV.Verification
Self-test suite 32 → 41, each re-deriving a claim from an independent reference:
θ̈=−(g/L)cosθ— worst 2e-8I′(θ)vs finite-diff ofI(θ)(~5e-5)arcGeomVerified end-to-end headless in Chromium (four-bar swings under gravity, energy plot live, all three exports download valid files, hodograph + jerk curve render, 0 console errors) plus
node scripts/verify-project.mjs datum-cad-9r4k(scope + conformance + lint + build all green).🤖 Generated with Claude Code
https://claude.ai/code/session_01BzHyorzzwSMikwadDgjdyQ
Generated by Claude Code