Repository navigation
Add the dynamics of a rigid body with open components - #113
Merged
Merged
Conversation
A node of a rigid body, and the parent of a linear constraint, has no equation of its own in FEBio: what is assembled on it is carried to other equations. This adds that mechanism once, for both (decision R1 of docs/design/rigid_bodies.md), so that the rigid bodies of thread K1 and the linear constraints of thread K3 share it. The terms assemble on node entries as before. The system then carries the residual and the blocks of a dependent entry to its masters, in three kernels, and the matrix pattern stays fixed. An owner fills the table; none exists yet, so no run changes. The adjoint and the forward sensitivities refuse a system with a table. Checked against the dense product on a small elastic problem, on CPU and on a Tesla P100. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
A rigid body that shares no element with anything (dy05 of the suite) has dependent entries and no carried block, and the empty slice of the block list raised. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
A rigid body with a component that no condition holds was refused. It is the most common reason a suite input does not run, and the last stage of the published clip procedure needs it (Handoff K, thread K1). Such a body now has two entries in the field table, its translation and its rotation vector, and its nodes are dependent entries that the system eliminates. The orientation is a quaternion updated as FEBio's rigid solver updates it; rigid_force and rigid_moment are read with load_type LOAD. Static steps only: the mass and inertia of a body are not built yet, and a contact surface on such a body is refused until its stiffness is carried to the body. Suite inputs ri01, ri03, ri07 and co42 as published take FEBio's time steps and iterations on CPU and on a Tesla P100. Three generated inputs with a released component agree with FEBio 4.13.0 to 4e-12, and a moved body gives the same result on the old path and the new. A body with no open component stays on the old path. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
A body with unknowns was refused in a dynamic step. This adds its mass and inertia from the density, FEBio's update of the angular velocity and acceleration, the inertial force and moment, the rotational mass block, a body force on a rigid part and the initial accelerations. Three things of FEBio's rigid solver are followed because its iterations depend on them: the stiffness of a time step is formed before its first residual, with the angular momentum of the last state; a symmetric stiffness keeps the upper triangle of the rotational mass block, which is not symmetric; and the initial angular acceleration is scaled by beta dt^2. Two generated cases of a body spun up by moments agree with FEBio 4.13.0 to 3e-12 with its iterations in every time step, and suite input dy05 takes FEBio's counts, on CPU and on a Tesla P100. A dynamic step after a static one, and initial velocities, are refused. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
3 of 5 tasks
3 of 5 tasks
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.
This pull request sits on #112 (
mattjolley/rigid-body-unknowns) and is to be merged after it. Until that is merged, the diff here also shows its commits; the commits of this pull request are the last one.What does this change, and why?
A rigid body with open components was refused in a dynamic step. This adds what a dynamic step needs, to FEBio 4.13.0 at
e4df3f8(FERigidSolverNew::InertialForcesandUpdateRigidBodies,FERigidSolver::RigidMassMatrix,FESolidSolver2::InitAccelerations). Design note:docs/design/rigid_bodies.md, sections 4.3 and 13.What is built:
center_of_massused as it is, also for the inertia.FERigidSolidDomain::BodyForce).Three things of FEBio that are easy to miss are followed, because its iterations depend on them:
symmetric_stiffnesssymmetric, which is the default, FEBio stores the upper triangle and its solve sees it mirrored. Before this was followed, the spinning body below converged in fewer iterations than FEBio's. Newton gets the mirrored block;linearize(exact=True)gives the block itself.FENewtonSolver::QNInit), with the angular momentum of the last state.Shared files, named plainly: six lines in
solvers/nonlinear/newton.py(after an increment is taken, a term may write the total increment of the time step as FEBio's solution vector holds it, since the convergence norm counts it: for a body, the composed rotation increment; no effect was measured on the cases below) and two hooks inanalysis/dynamics.py,initial_state.Where a body meets the work of #104 and of the static step after a dynamic one: it refuses, with the reason, and a test holds each. A dynamic step with alpha_f below 1 (FEBio takes the arm of a rigid node at the interpolated configuration, which is not joined to
State.domain_uyet); static and dynamic steps in one run, in either order (FEBio's rigid solver updates the velocities of a body in a static step too). Also refused: initial velocities of a body.Validation
All of the following with Warp 1.20.0.
Tests added or changed:
tests/test_rigid_dynamics.py, new: the two generated inputs and the suite input below; mass, center and inertia of a hex8 cube and of tet4 parts against closed forms; the initial accelerations; the rotational mass block as Newton and as the adjoint get it.tests/test_rigid_unknowns.py: the refusal of a dynamic step becomes the two refusals named above.FEBio reference (input file, quantity compared, tolerance, FEBio version), or N/A: Two generated inputs with references from FEBio 4.13.0 at
e4df3f8(displacement of the eight nodes at every state; compared at 1e-9) and one suite input (986005f, presetFEBIO_4_13).rb_spinrb_spin_from_zerody05The same on CPU and on a Tesla P100. The reference of
rb_spin_from_zerois from the FEBio build with MKL Pardiso at the same commit, since FEBio's skyline solver takes no non-symmetric matrix; the other references of this repository are from the skyline build.Devices the full tier ran on (CPU, and the GPU model if CUDA; say so clearly if no GPU was used):
d876c2e, which is the tip of the five rigid body pull requests, Warp 1.20.0: quick tier of the whole repository on CPU, 1,187 tests, none failed (91 skipped); on a Tesla P100 (cuDSS; the versions of thegpuextra), 1,187 tests, one failure (82 skipped):tests/test_history_adjoint.py,ForwardSweep.test_the_jacobian_of_a_static_run_goes_through_the_steps(from History in the forward sweep #101), which fails on unchangedmainat25b5aacon the same GPU and passes on CPU; it is not of this pull request. The full tier of the nine test files these five pull requests add, change or meet (test_rigid_wall,test_reduction,test_rigid_unknowns,test_rigid_dynamics,test_rigid_moved,test_rigid_refusals,test_sticky,test_alpha_f,test_static_after_dynamic): 125 tests, none failed, on CPU and on a Tesla P100.Checklist
uvx pre-commit run --all-filespasses. (Run on the files of this change: passes.)FEBIO_WARP_TEST_LEVEL=full uv run -m unittest discover -s tests, and withFEBIO_WARP_TEST_DEVICE=cuda:0for code that runs on the device. (Not run in full; see Validation.)git commit -s).🤖 Generated with Claude Code