diff --git a/README.md b/README.md index f516de3..3c32595 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ settled design. What is still open, and who is asked, is on one page: | Contact | `contact/` | FEBio's `contact potential`, on its own and in a run: pair search on the device, force, tangent, gradients. FEBio's form by default, and a smooth form that the contact type `smooth contact potential` (FEBio-Warp only) or a run (`--preset febio_warp`) asks for. FEBio's `edge-to-surface contact potential` (an edge against a surface). Smooth contact measures for objectives. Count of intersecting facet pairs. FEBio's `sliding-elastic` with tension against a fixed rigid target (shape enforcement). FEBio's `sticky` in its penalty form, with `snap_tol` and release by `max_traction`, with its primary on a deformable body or on a rigid body the input moves (a clip arm on a leaflet) | Element-pair `w_tol`; step cut on a facet crossing; gradients in the radii and the exponent of the potential (`kc` has one); sticky contact in augmented Lagrangian form, and its gradients (not planned); tied contact; sliding contact with friction; a contact potential against a moving rigid body compared with FEBio; activation by step for `sliding-elastic` (a `contact potential` of a step is built) | [Contact](docs/design/contact.md) ([diagram](docs/design/contact.md#at-a-glance), [decisions](docs/design/contact.md#decision-points)), [contact in a run](docs/design/contact_in_run.md) ([diagram](docs/design/contact_in_run.md#2-where-contact-sits-in-one-iteration)), [shape enforcement](docs/design/shape_enforcement.md) ([diagram](docs/design/shape_enforcement.md#2-from-the-input-to-terms)) | | Elements | `elements/` | hex8, penta6 and tet4 solids on dedicated kernels (hex8 and tet4 also through `warp.fem`, as a cross-check); FEBio's three-field solid on hex8 and penta6 for uncoupled materials, in its penalty form; quad4 and tri3 shells; two-node trusses (regular, tension-only and smooth tension-only); springs; FEBio's beam (`linear-beam`, line2 and line3, static and dynamic). Mass for hex8, tet4 (FEBio's one-point rule), quad4 shell and truss | rigid bodies with unknowns; the augmented Lagrangian of the three-field solid | [Trusses and springs](docs/design/trusses_and_springs.md) ([diagram](docs/design/trusses_and_springs.md#2-from-the-input-to-a-term)), [elements](docs/design/elements.md) ([diagram](docs/design/elements.md#3-selection)) | | Unknowns and assembly | `discretization/`, `assembly/` | Unknowns by (node, variable); full assembly of residual and tangent into a block sparse matrix with a fixed pattern | How a new term enters the system ([open question](docs/design/open_questions.md#4-decisions-for-reviewers)); timing on a GPU at application size | [Run path](docs/design/run_path.md) ([diagram](docs/design/run_path.md#2-the-path), [decisions](docs/design/run_path.md#12-decision-points)), [assembly](docs/design/assembly.md) | -| Loads and constraints | `loads/`, `constraints/` | Follower pressure; nodal loads; mass damping; a constant body force (`const`, `body force`); load curves on mass damping `C` and on contact `kc`; FEBio's four extend modes of a load curve; body loads on an element set, applied as FEBio applies them; fixed and prescribed displacements, also one value per node from a map; `normal displacement` on a surface, with `relative`; `prescribed deformation` of a node set; the `slide-line` constraint; the `linear constraint` set and `node distance` of the `Constraints` section, by penalty or augmented Lagrangian, also declared in a step; a rigid body that is fixed or moved by the input (`rigid_fixed`, `rigid_displacement`, `rigid_rotation`, a revolute joint with a prescribed rotation), as geometry; the rigid wall (`rigid_wall`, a plane) in its penalty form | A body force that varies in space; rigid bodies that respond to load, their loads and other connectors; the rigid wall with augmented Lagrangian; the `linear constraint` boundary condition (by elimination); Lagrange multipliers as unknowns (`LAGMULT`) | [Dynamics](docs/design/dynamics.md), [constraints](docs/design/constraints.md) ([diagram](docs/design/constraints.md#2-how-a-constrained-component-is-handled)) | +| Loads and constraints | `loads/`, `constraints/` | Follower pressure; nodal loads; mass damping; a constant body force (`const`, `body force`); load curves on mass damping `C` and on contact `kc`; FEBio's four extend modes of a load curve; body loads on an element set, applied as FEBio applies them; fixed and prescribed displacements, also one value per node from a map; `normal displacement` on a surface, with `relative`; `prescribed deformation` of a node set; the `slide-line` constraint; the `linear constraint` set and `node distance` of the `Constraints` section, by penalty or augmented Lagrangian, also declared in a step; a rigid body that is fixed or moved by the input (`rigid_fixed`, `rigid_displacement`, `rigid_rotation`, a revolute joint with a prescribed rotation), as geometry; a rigid body with open components, solved for as FEBio does, static and dynamic (two entries per body, its nodes eliminated; mass and inertia; `rigid_force` and `rigid_moment` with `LOAD`; a body force on a rigid part; nodes tied by `rigid`); the rigid wall (`rigid_wall`, a plane) in its penalty form | A body force that varies in space; for rigid bodies with open components: initial velocities, static and dynamic steps in one run, `alpha_f` below 1, the other load types, connectors under load, clamped shell nodes; the rigid wall with augmented Lagrangian; the `linear constraint` boundary condition (by elimination); Lagrange multipliers as unknowns (`LAGMULT`) | [Dynamics](docs/design/dynamics.md), [constraints](docs/design/constraints.md) ([diagram](docs/design/constraints.md#2-how-a-constrained-component-is-handled)) | | Solvers | `solvers/` | The Newton strategy the input asks for, as FEBio runs it (BFGS, Broyden, full or modified Newton), with FEBio's line search; a material's `tangent_scale` applied where the input states it; full Newton whatever the input asks and the exact material tangent as options; CG, BiCGSTAB and GMRES on the device; sparse LU on the host; cuDSS on the device (the `gpu` extra; the default on a GPU), also with a pattern that only grows and factors reused across solves | Preconditioning for shells; transpose solve from cuDSS factors | [Run path](docs/design/run_path.md) ([one Newton iteration](docs/design/run_path.md#3-one-newton-iteration)), [linear solve](docs/design/linear_solve.md) ([diagram](docs/design/linear_solve.md#2-choosing-a-method)) | | Analysis | `analysis/` | Static and implicit dynamic steps with FEBio's automatic time stepper, for every alpha_f FEBio's `rhoi` and `alpha` give (below 1: domains at the interpolated configuration, and at 1/2 FEBio's energy-conserving stress). Several steps in sequence, as FEBio runs them, a static step after a dynamic one included: each with its own `Control`, and with the conditions, loads and interfaces declared in it acting while it runs. `inspect` reports which records act in which step | Rigid and initial conditions by step; gradients through a step at alpha_f = 1/2 or through a static step after a dynamic one | [Run path](docs/design/run_path.md), [dynamics](docs/design/dynamics.md) ([one dynamic step](docs/design/dynamics.md#2-one-dynamic-step)), [several steps](docs/design/steps.md) ([diagram](docs/design/steps.md#2-a-run-over-steps), [decisions](docs/design/steps.md#7-decision-points)) | | Sensitivity | `sensitivity/` | Adjoint gradients through one equilibrium solve and through the steps of a dynamic run, also with self-contact, across the boundary between analysis steps and through the history of a material; forward sensitivities of every displacement to chosen parameter directions, with the right-hand sides of all directions solved together, also through history | The radii and the exponent of the contact potential; the mass; transpose solve on cuDSS factors | [Sensitivity](docs/design/sensitivity.md) ([diagram](docs/design/sensitivity.md#2-forward-run-and-reverse-sweep)) | diff --git a/docs/design/constraints.md b/docs/design/constraints.md index 9af7901..5e67ed8 100644 --- a/docs/design/constraints.md +++ b/docs/design/constraints.md @@ -14,6 +14,8 @@ First template for discussion, November 26, 2026 (v0.2). Design only: there is n **Status, December 2, 2026 (rigid wall).** FEBio's `rigid_wall` constraint is built in its penalty form (`constraints/rigid_wall.py`): the nodes of a surface are held on one side of a plane by a force of penalty times gap times the nodal area, along the constant normal, with FEBio's stiffness in Newton and the derivative for the adjoint. `penalty` and `offset` may follow a load curve, so the wall can move. It is a term on node entries and has nothing to do with rigid bodies. Read from `FERigidWallInterface.cpp` at `e4df3f8`; one point is easy to miss: the facets are integrated at their nodes (the base class asks for it), which differs from a Gauss rule on a curved quad4 surface. Suite inputs `co08`, `co10`, `tu03` (static) and `dy03` (a ball falling on a wall, dynamic) take FEBio's time steps and iterations on CPU and on a Tesla P100, with the solution norm within 4e-9, 4e-13, 3e-12 and 2e-11 (`tests/test_rigid_wall.py`). The gradient with respect to `penalty` agrees with central differences. Refused: augmented Lagrangian (not built for the wall), facets other than quad4 and tri3, and a wall declared in a step. The `Constraints` section is otherwise as before. +**Status, December 2, 2026 (rigid bodies with unknowns).** Route A of section 7 is built for rigid bodies, in static steps, as [rigid_bodies.md](rigid_bodies.md) proposes (decisions R1 to R3). A rigid body with a component the input leaves open in some step has two entries in the field table after those of the nodes, its translation and its rotation vector, each component free, fixed or prescribed per step. Its nodes are dependent entries: the system carries their residual and their stiffness blocks to the body after the terms have assembled (`assembly/reduction.py`, checked against the dense product in `tests/test_reduction.py`; the mechanism linear constraints will share). The orientation is a quaternion updated by FEBio's composition of rotation increments through the Cayley transform (`constraints/rigid_system.py`), `rigid_force` and `rigid_moment` are read with `load_type` `LOAD`, and the boundary condition `rigid` ties nodes to such a body. A body with no open component stays on the path of November 29, and a test runs `bk_rigid_lid_moved` and `bk_rigid_lid_top_level` on both paths: the same displacements to round-off. Suite inputs `ri01`, `ri03`, `ri07` and `co42` (the peel input of the sticky contact as published, with its body free) take FEBio's time steps and iterations on CPU and on a Tesla P100, with the solution norm within 2e-12 (`tests/test_rigid_unknowns.py`). In the table of section 6, a body with an open component is no longer refused in a static step. Dynamic steps are built the same day: the mass and inertia of a body from its density (FEBio's rules: one integration point for a tet4, a given `center_of_mass` used as it is), 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. Two generated cases of a skewed body spun up by moments, `rb_spin` and `rb_spin_from_zero`, agree with FEBio 4.13.0 to 3e-12 with FEBio's iterations in every time step, and suite input `dy05` takes FEBio's counts (`tests/test_rigid_dynamics.py`). Three things of FEBio that are easy to miss are followed, since the iterations depend on them: the stiffness of a time step is formed before its first residual, when the angular momentum is still that of the last state; where the input asks for a symmetric stiffness, the solve sees the upper triangle of the rotational mass block, which is not symmetric, mirrored; and the initial angular acceleration is beta dt^2 times the one the moments give. Refused, with the reason: static and dynamic steps in one run with such a body (FEBio gives a rigid body velocities in a static step, which are not built, in either order), such a body in a dynamic step with `alpha_f` below 1 (FEBio takes the arm of the residual and the connector forces at the interpolated configuration, which is not built for a body), initial velocities of a body, a prescribed rotation beside an open one (an error in FEBio), `FOLLOW`, `TARGET` and `relative` loads, connectors under load, a contact interface with a surface on such a body (its stiffness is not carried to the body yet), nodes of a shell part tied to a body, a rigid shell part, and gradients through a system with such a body. + **Scope.** The one boundary condition the open TPVR input needs that the run path does not have, `normal displacement`, and a statement of how the masking approach would extend to the constraint types that are reserved. ## 1. Summary diff --git a/references/small_problems/README.md b/references/small_problems/README.md index 820cc21..df7a713 100644 --- a/references/small_problems/README.md +++ b/references/small_problems/README.md @@ -1,6 +1,6 @@ # Small FEBio inputs and their FEBio references -One hundred and forty small FEBio 4.0 input files for features the FEBio test suite +One hundred and forty-five small FEBio 4.0 input files for features the FEBio test suite covers thinly for the valve and device applications, with the FEBio results for each. Each input mirrors or extends a suite problem. All geometry is generated; nothing here is patient data. See @@ -96,6 +96,13 @@ of the model beside those of steps, through a dynamic step, and by a revolute jo prescribed rotation, `bk_rigid_lid_moved`, `bk_rigid_lid_top_level`, `bk_rigid_lid_dynamic` and `bk_rigid_lid_joint`, and nodes of an elastic block tied to such a body, `bk_rigid_tied_nodes` (`tests/test_rigid_moved.py`, same build); +three of these with one rigid condition taken out, so that a component of the body is open and +the body has unknowns: `bk_rigid_lid_released` (a translation open in one step of four), +`bk_rigid_lid_reopened` (a rotation that FEBio opens when a condition of a step ends) and +`bk_rigid_tied_free` (tied nodes and a free rotation) (`tests/test_rigid_unknowns.py`, same build); +a rigid body alone, spun up by moments in a dynamic step, `rb_spin` and `rb_spin_from_zero` +(`tests/test_rigid_dynamics.py`; the second has a non-symmetric stiffness, which FEBio's skyline +solver does not take, so its reference is of the build with MKL Pardiso at the same commit); seven inputs with sticky contact, a rigid arm that turns into a shell patch and holds it (`st_grasp_tri3`, `st_grasp_quad4`, and `st_grasp_in_step` with the interface declared in a second step) and an elastic block held to an elastic slab, without release (`st_block_on_slab`) and with diff --git a/references/small_problems/cases.json b/references/small_problems/cases.json index 6c3c655..4487380 100644 --- a/references/small_problems/cases.json +++ b/references/small_problems/cases.json @@ -833,6 +833,57 @@ "rigid_rotation" ] }, + { + "case": "bk_rigid_lid_released", + "tier": 2, + "tags": [ + "rigid body", + "unknowns", + "release", + "several steps" + ] + }, + { + "case": "bk_rigid_lid_reopened", + "tier": 2, + "tags": [ + "rigid body", + "unknowns", + "release", + "several steps" + ] + }, + { + "case": "rb_spin", + "tier": 2, + "tags": [ + "rigid body", + "unknowns", + "DYNAMIC", + "rigid_moment", + "rigid_force" + ] + }, + { + "case": "rb_spin_from_zero", + "tier": 2, + "tags": [ + "rigid body", + "unknowns", + "DYNAMIC", + "initial accelerations", + "non-symmetric" + ] + }, + { + "case": "bk_rigid_tied_free", + "tier": 2, + "tags": [ + "rigid body", + "unknowns", + "rigid node set" + ] + }, { "case": "ch_truss_rest_length", "tier": 2, diff --git a/references/small_problems/febio/bk_rigid_lid_released.json b/references/small_problems/febio/bk_rigid_lid_released.json new file mode 100644 index 0000000..a562881 --- /dev/null +++ b/references/small_problems/febio/bk_rigid_lid_released.json @@ -0,0 +1 @@ +{"case":"bk_rigid_lid_released","input":"inputs/bk_rigid_lid_released.feb","input_sha256":"3afcdd08204251ad7d0e842e30e19f647e23a979266cd5c455fed3e07f1e8a68","febio":{"version":"4.13.0","build":"provisional: source build at commit e4df3f8, Linux, GCC 11.5, no MKL, skyline solver, one thread; not an official release"},"records":[{"data":["ux","uy","uz"],"items":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"times":[0.0,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0,2.2,2.4,2.6,2.8,3.0,3.2,3.4,3.6,3.8,4.0],"values":[[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0163197537262,-0.00767451196841,0.00256640146636],[0.0176134512836,-0.00116417305332,-0.000791285808081],[0.0187792575942,0.00712113624895,-0.0041694748346],[0.00951365989591,-0.00785314668441,0.00313410991492],[0.0101110312401,-0.00135109783518,-0.000217829888025],[0.0106253427873,0.00693436388647,-0.00358477865372],[0.00270252909308,-0.00795742148794,0.00370433491387],[0.00260050637622,-0.00146199890762,0.000356444174889],[0.00246023050601,0.00682400770057,-0.00300142176979],[0.0352375875343,-0.015762979874,0.0],[0.0350126044088,-0.000765229772745,0.0],[0.0347876212833,0.0142325203285,0.0],[0.0202398374331,-0.0159879629995,0.0],[0.0200148543076,-0.000990212898251,0.0],[0.0197898711821,0.014007537203,0.0],[0.00524208733182,-0.016212946125,0.0],[0.00501710420632,-0.00121519602376,0.0],[0.00479212108081,0.0137825540775,0.0],[0.0352150892218,-0.0142632048639,0.0],[0.0349901060963,0.00073454523738,0.0],[0.0347651229708,0.0157322953386,0.0],[0.0202173391205,-0.0144881879894,0.0],[0.019992355995,0.000509562111874,0.0],[0.0197673728695,0.0155073122131,0.0],[0.00521958901927,-0.0147131711149,0.0],[0.00499460589377,0.000284578986367,0.0],[0.00476962276826,0.0152823290876,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0328370801488,-0.0152531410876,0.00501759934316],[0.0352412656972,-0.00217993303809,-0.00167841464213],[0.0373482712462,0.0143282308071,-0.00843039305225],[0.0191994587588,-0.0157416030513,0.00625456971104],[0.0202656007297,-0.00269674159543,-0.000434498625223],[0.0211202077786,0.0138134685945,-0.00715845885874],[0.00553646528189,-0.0160595179312,0.0075036232969],[0.00525360372058,-0.00304427468445,0.000813617168383],[0.0048444355393,0.0134642547417,-0.0058917561975],[0.0709411371345,-0.0310618078791,0.0],[0.0700414071021,-0.00107980463933,0.0],[0.0691416770697,0.0289021986004,0.0],[0.0409591338948,-0.0319615379115,0.0],[0.0400594038624,-0.00197953467173,0.0],[0.03915967383,0.028002468568,0.0],[0.0109771306551,-0.0328612679439,0.0],[0.0100774006227,-0.00287926470413,0.0],[0.00917767059026,0.0271027385356,0.0],[0.0708511641313,-0.0280636075551,0.0],[0.0699514340989,0.00191839568464,0.0],[0.0690517040665,0.0319003989244,0.0],[0.0408691608915,-0.0289633375875,0.0],[0.0399694308591,0.00101866565224,0.0],[0.0390697008267,0.031000668892,0.0],[0.0108871576518,-0.0298630676199,0.0],[0.00998742761942,0.000118935619843,0.0],[0.00908769758702,0.0301009388596,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0495472491862,-0.0227282955089,0.00735007092095],[0.0528773094677,-0.00304669418487,-0.00265861949857],[0.0557047455898,0.0216148184306,-0.0127791647267],[0.0290594489223,-0.0236619805517,0.00935843961727],[0.0304636115784,-0.00403526182662,-0.000649651609029],[0.0314873634385,0.0206363676293,-0.0107195436458],[0.00850467003191,-0.024307908531,0.0113993499517],[0.00796035160959,-0.00474555039443,0.00137144553476],[0.0071560577402,0.0199230895888,-0.00867089454205],[0.107096516666,-0.0458827161026,0.0],[0.105072883172,-0.000943441503618,0.0],[0.103049249678,0.0439958330954,0.0],[0.0621572420669,-0.0479063495966,0.0],[0.0601336085729,-0.00296707499762,0.0],[0.0581099750789,0.0419721996014,0.0],[0.0172179674679,-0.0499299830906,0.0],[0.0151943339739,-0.00499070849162,0.0],[0.0131707004798,0.0399485661074,0.0],[0.106894153316,-0.0413887886427,0.0],[0.104870519822,0.00355048595628,0.0],[0.102846886328,0.0484897605553,0.0],[0.0619548787175,-0.0434124221367,0.0],[0.0599312452235,0.00152685246228,0.0],[0.0579076117295,0.0464661270613,0.0],[0.0170156041185,-0.0454360556307,0.0],[0.0149919706245,-0.000496781031723,0.0],[0.0129683371304,0.0444424935673,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0664449958169,-0.0300924586073,0.00956042817082],[0.0705156702205,-0.00376414212188,-0.00372882393932],[0.0738467347871,0.0289746064158,-0.0172123934701],[0.0390955238259,-0.0316106219446,0.0124424911514],[0.0407049116304,-0.00536500390196,-0.000862929218035],[0.0417294917208,0.0274022778689,-0.0142667127726],[0.0116102747685,-0.0327042392155,0.0153930900972],[0.0107217452391,-0.00656463616448,0.00202995776521],[0.00939828060725,0.0262028585794,-0.0113386335614],[0.143689187377,-0.0602123667277,0.0],[0.140093505304,-0.000356263083218,0.0],[0.136497823231,0.0594998405612,0.0],[0.0838330837328,-0.0638080488007,0.0],[0.0802374016598,-0.00395194515628,0.0],[0.0766417195867,0.0559041584882,0.0],[0.0239769800884,-0.0674037308738,0.0],[0.0203812980153,-0.00754762722935,0.0],[0.0167856159422,0.0523084764151,0.0],[0.14332961917,-0.0542267563632,0.0],[0.139733937097,0.00562934728123,0.0],[0.136138255024,0.0654854509257,0.0],[0.0834735155255,-0.0578224384363,0.0],[0.0798778334525,0.00203366520816,0.0],[0.0762821513794,0.0618897688526,0.0],[0.0236174118811,-0.0614181205094,0.0],[0.020021729808,-0.00156201686491,0.0],[0.0164260477349,0.0582940867796,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0835245262116,-0.0373382283775,0.0116454631633],[0.0881506906674,-0.00433222001106,-0.00488568875908],[0.0917726124571,0.0364014941648,-0.0217268751045],[0.0493093850402,-0.0395835849681,0.0155032080072],[0.0509892941405,-0.00668432951428,-0.00107396532598],[0.0518491774153,0.0341105679319,-0.0177988017542],[0.0148566970178,-0.0412501729819,0.0194864835825],[0.0135387226619,-0.00850043164783,0.00278928933787],[0.0115740380094,0.0323058942302,-0.0138946651784],[0.180704216985,-0.0740378640359,0.0],[0.175089755953,0.000681202200923,0.0],[0.169475294921,0.0754002684377,0.0],[0.105985150748,-0.0796523250679,0.0],[0.100370689716,-0.00493325883106,0.0],[0.0947562286843,0.0697858074057,0.0],[0.0312660845115,-0.0852667860998,0.0],[0.0256516234795,-0.010547719863,0.0],[0.0200371624475,0.0641713463738,0.0],[0.180142770882,-0.0665659574122,0.0],[0.17452830985,0.0081531088246,0.0],[0.168913848818,0.0828721750614,0.0],[0.105423704645,-0.0721804184442,0.0],[0.0998092436131,0.00253864779262,0.0],[0.0941947825812,0.0772577140294,0.0],[0.0307046384083,-0.0777948794762,0.0],[0.0250901773763,-0.00307581323935,0.0],[0.0194757163444,0.0716432529974,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0835662817351,-0.0372776573546,0.0117835450345],[0.0881377644111,-0.00427832395662,-0.00473115685174],[0.0917083932407,0.0364505983571,-0.0215563300774],[0.0493560760678,-0.0395800991203,0.0156419962472],[0.0509805703111,-0.00668553786682,-0.000920064811067],[0.0517884827883,0.0341061045753,-0.0176305673657],[0.0149077843633,-0.0413036794373,0.0196229001676],[0.0135338268066,-0.00855672716663,0.0029427774838],[0.0115166468537,0.0322480204172,-0.013725642715],[0.180704216985,-0.0740378640359,0.000305810063147],[0.175089755953,0.000681202200923,0.000305810063147],[0.169475294921,0.0754002684377,0.000305810063147],[0.105985150748,-0.0796523250679,0.000305810063147],[0.100370689716,-0.00493325883106,0.000305810063147],[0.0947562286843,0.0697858074057,0.000305810063147],[0.0312660845115,-0.0852667860998,0.000305810063147],[0.0256516234795,-0.010547719863,0.000305810063147],[0.0200371624475,0.0641713463738,0.000305810063147],[0.180142770882,-0.0665659574122,0.000305810063147],[0.17452830985,0.0081531088246,0.000305810063147],[0.168913848818,0.0828721750614,0.000305810063147],[0.105423704645,-0.0721804184442,0.000305810063147],[0.0998092436131,0.00253864779262,0.000305810063147],[0.0941947825812,0.0772577140294,0.000305810063147],[0.0307046384083,-0.0777948794762,0.000305810063147],[0.0250901773763,-0.00307581323935,0.000305810063147],[0.0194757163444,0.0716432529974,0.000305810063147]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0835662817351,-0.0372776573546,0.0117835450345],[0.0881377644111,-0.00427832395662,-0.00473115685174],[0.0917083932407,0.0364505983571,-0.0215563300774],[0.0493560760678,-0.0395800991203,0.0156419962472],[0.0509805703111,-0.00668553786682,-0.000920064811064],[0.0517884827883,0.0341061045753,-0.0176305673657],[0.0149077843633,-0.0413036794373,0.0196229001676],[0.0135338268066,-0.00855672716663,0.0029427774838],[0.0115166468537,0.0322480204172,-0.013725642715],[0.180704216985,-0.0740378640359,0.000305810063153],[0.175089755953,0.000681202200923,0.000305810063153],[0.169475294921,0.0754002684377,0.000305810063153],[0.105985150748,-0.0796523250679,0.000305810063153],[0.100370689716,-0.00493325883106,0.000305810063153],[0.0947562286843,0.0697858074057,0.000305810063153],[0.0312660845115,-0.0852667860998,0.000305810063153],[0.0256516234795,-0.010547719863,0.000305810063153],[0.0200371624475,0.0641713463738,0.000305810063153],[0.180142770882,-0.0665659574122,0.000305810063153],[0.17452830985,0.0081531088246,0.000305810063153],[0.168913848818,0.0828721750614,0.000305810063153],[0.105423704645,-0.0721804184442,0.000305810063153],[0.0998092436131,0.00253864779262,0.000305810063153],[0.0941947825812,0.0772577140294,0.000305810063153],[0.0307046384083,-0.0777948794762,0.000305810063153],[0.0250901773763,-0.00307581323935,0.000305810063153],[0.0194757163444,0.0716432529974,0.000305810063153]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0835662817351,-0.0372776573546,0.0117835450345],[0.0881377644111,-0.00427832395662,-0.00473115685174],[0.0917083932407,0.0364505983571,-0.0215563300774],[0.0493560760678,-0.0395800991203,0.0156419962472],[0.0509805703111,-0.00668553786682,-0.000920064811064],[0.0517884827883,0.0341061045753,-0.0176305673657],[0.0149077843633,-0.0413036794373,0.0196229001676],[0.0135338268066,-0.00855672716663,0.0029427774838],[0.0115166468537,0.0322480204172,-0.013725642715],[0.180704216985,-0.0740378640359,0.000305810063153],[0.175089755953,0.000681202200923,0.000305810063153],[0.169475294921,0.0754002684377,0.000305810063153],[0.105985150748,-0.0796523250679,0.000305810063153],[0.100370689716,-0.00493325883106,0.000305810063153],[0.0947562286843,0.0697858074057,0.000305810063153],[0.0312660845115,-0.0852667860998,0.000305810063153],[0.0256516234795,-0.010547719863,0.000305810063153],[0.0200371624475,0.0641713463738,0.000305810063153],[0.180142770882,-0.0665659574122,0.000305810063153],[0.17452830985,0.0081531088246,0.000305810063153],[0.168913848818,0.0828721750614,0.000305810063153],[0.105423704645,-0.0721804184442,0.000305810063153],[0.0998092436131,0.00253864779262,0.000305810063153],[0.0941947825812,0.0772577140294,0.000305810063153],[0.0307046384083,-0.0777948794762,0.000305810063153],[0.0250901773763,-0.00307581323935,0.000305810063153],[0.0194757163444,0.0716432529974,0.000305810063153]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0835662817351,-0.0372776573546,0.0117835450345],[0.0881377644111,-0.00427832395662,-0.00473115685174],[0.0917083932407,0.0364505983571,-0.0215563300774],[0.0493560760678,-0.0395800991203,0.0156419962472],[0.0509805703111,-0.00668553786682,-0.000920064811064],[0.0517884827883,0.0341061045753,-0.0176305673657],[0.0149077843633,-0.0413036794373,0.0196229001676],[0.0135338268066,-0.00855672716663,0.0029427774838],[0.0115166468537,0.0322480204172,-0.013725642715],[0.180704216985,-0.0740378640359,0.000305810063153],[0.175089755953,0.000681202200923,0.000305810063153],[0.169475294921,0.0754002684377,0.000305810063153],[0.105985150748,-0.0796523250679,0.000305810063153],[0.100370689716,-0.00493325883106,0.000305810063153],[0.0947562286843,0.0697858074057,0.000305810063153],[0.0312660845115,-0.0852667860998,0.000305810063153],[0.0256516234795,-0.010547719863,0.000305810063153],[0.0200371624475,0.0641713463738,0.000305810063153],[0.180142770882,-0.0665659574122,0.000305810063153],[0.17452830985,0.0081531088246,0.000305810063153],[0.168913848818,0.0828721750614,0.000305810063153],[0.105423704645,-0.0721804184442,0.000305810063153],[0.0998092436131,0.00253864779262,0.000305810063153],[0.0941947825812,0.0772577140294,0.000305810063153],[0.0307046384083,-0.0777948794762,0.000305810063153],[0.0250901773763,-0.00307581323935,0.000305810063153],[0.0194757163444,0.0716432529974,0.000305810063153]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0835662817351,-0.0372776573546,0.0117835450345],[0.0881377644111,-0.00427832395662,-0.00473115685174],[0.0917083932407,0.0364505983571,-0.0215563300774],[0.0493560760678,-0.0395800991203,0.0156419962472],[0.0509805703111,-0.00668553786682,-0.000920064811064],[0.0517884827883,0.0341061045753,-0.0176305673657],[0.0149077843633,-0.0413036794373,0.0196229001676],[0.0135338268066,-0.00855672716663,0.0029427774838],[0.0115166468537,0.0322480204172,-0.013725642715],[0.180704216985,-0.0740378640359,0.000305810063153],[0.175089755953,0.000681202200923,0.000305810063153],[0.169475294921,0.0754002684377,0.000305810063153],[0.105985150748,-0.0796523250679,0.000305810063153],[0.100370689716,-0.00493325883106,0.000305810063153],[0.0947562286843,0.0697858074057,0.000305810063153],[0.0312660845115,-0.0852667860998,0.000305810063153],[0.0256516234795,-0.010547719863,0.000305810063153],[0.0200371624475,0.0641713463738,0.000305810063153],[0.180142770882,-0.0665659574122,0.000305810063153],[0.17452830985,0.0081531088246,0.000305810063153],[0.168913848818,0.0828721750614,0.000305810063153],[0.105423704645,-0.0721804184442,0.000305810063153],[0.0998092436131,0.00253864779262,0.000305810063153],[0.0941947825812,0.0772577140294,0.000305810063153],[0.0307046384083,-0.0777948794762,0.000305810063153],[0.0250901773763,-0.00307581323935,0.000305810063153],[0.0194757163444,0.0716432529974,0.000305810063153]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0465666085691,0.00501996059447,0.0138318368086],[0.0509549627993,0.0052828757958,-0.0033139622822],[0.054926826294,0.00664070139172,-0.0204424616941],[0.0477677843884,0.00542981987972,0.0157472743024],[0.0504359698299,0.00555913759126,-0.000926521579421],[0.0528149905713,0.00695774971821,-0.0177182715441],[0.0490016830313,0.00351181999831,0.0176274520933],[0.0499126872252,0.00366412412495,0.001457196251],[0.050658026582,0.00522433564232,-0.0149495050527],[0.1,0.00636544240465,-0.00963086673757],[0.1,0.00536550906998,-0.00964086640424],[0.1,0.00436557573532,-0.00965086607091],[0.1,0.00626544573794,0.000368466609098],[0.1,0.00526551240327,0.000358466942426],[0.1,0.00426557906861,0.000348467275755],[0.1,0.00616544907123,0.0103677999558],[0.1,0.00516551573656,0.0103578002891],[0.1,0.00416558240189,0.0103478006224],[0.1,-0.00363389094202,-0.00973086340428],[0.1,-0.00513379094402,-0.00974586290429],[0.1,-0.00663369094602,-0.00976086240429],[0.1,-0.00373388760873,0.000268469942386],[0.1,-0.00523378761073,0.00025347044238],[0.1,-0.00673368761273,0.000238470942373],[0.1,-0.00383388427544,0.0102678032891],[0.1,-0.00533378427744,0.010252803789],[0.1,-0.00683368427944,0.010237804289]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0453138200603,0.00932938476391,0.0119439387331],[0.0514845555816,0.00980416665169,-0.00568977689996],[0.057105181323,0.012642499989,-0.0231527789095],[0.0477562532906,0.0108631615077,0.0157379322432],[0.0504383078907,0.0111215403004,-0.00090611493564],[0.0528301302508,0.0139178948699,-0.0176761855741],[0.0501834895342,0.00774179171675,0.019535149923],[0.0494001233041,0.00809699912916,0.00385168761178],[0.0485680973781,0.011093340095,-0.0121696503665],[0.1,0.0129283320506,-0.0194382559082],[0.1,0.0109288653413,-0.0194782505751],[0.1,0.00892939863197,-0.0195182452421],[0.1,0.0125283853811,0.000556411185149],[0.1,0.0105289186718,0.000516416518198],[0.1,0.00852945196246,0.000476421851247],[0.1,0.0121284387116,0.0205510782785],[0.1,0.0101289720023,0.0205110836115],[0.1,0.00812950529295,0.0204710889446],[0.1,-0.00706633504268,-0.0198382025777],[0.1,-0.0100655351067,-0.0198981945781],[0.1,-0.0130647351707,-0.0199581865785],[0.1,-0.0074662817122,0.000156464515638],[0.1,-0.0104654817762,9.64725152113e-05],[0.1,-0.0134646818402,3.64805147846e-05],[0.1,-0.00786622838171,0.020151131609],[0.1,-0.0108654284457,0.0200911396085],[0.1,-0.0138646285097,0.0200311476081]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0440378630034,0.0136730990754,0.010062648489],[0.0520197193732,0.0143622665705,-0.00805845197836],[0.059312506352,0.0186943899052,-0.0258370832748],[0.0477370100087,0.0163035589418,0.0157224642761],[0.0504422286181,0.0166904815051,-0.00087200705392],[0.0528554149687,0.0208828346486,-0.0176059840835],[0.0513411704885,0.0119527347154,0.021449408938],[0.0488933712405,0.012507419352,0.00625160044834],[0.0465081740344,0.0169237948768,-0.00936936564805],[0.1,0.0196860438696,-0.0291124346237],[0.1,0.0166878435456,-0.029202407627],[0.1,0.0136896432216,-0.0292923806302],[0.1,0.0187863138372,0.000869568615983],[0.1,0.0157881135132,0.000779595612743],[0.1,0.0127899131893,0.000689622609503],[0.1,0.0178865838048,0.0308515718557],[0.1,0.0148883834808,0.0307615988525],[0.1,0.0118901831569,0.0306716258492],[0.1,-0.0102959593701,-0.0300121646561],[0.1,-0.0147932598561,-0.030147124161],[0.1,-0.019290560342,-0.0302820836659],[0.1,-0.0111956894025,-3.01614164151e-05],[0.1,-0.0156929898885,-0.000165120921275],[0.1,-0.0201902903744,-0.000300080426135],[0.1,-0.0120954194349,0.0299518418233],[0.1,-0.0165927199209,0.0298168823184],[0.1,-0.0210900204068,0.0296819228136]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0427389946884,0.0180552213977,0.0081879648249],[0.052560412858,0.0189610327088,-0.0104194588812],[0.0615485552796,0.0247993520787,-0.028493898881],[0.047710017552,0.0217545708856,0.0157010249338],[0.0504477682577,0.0222692510927,-0.000824051920651],[0.0528909229813,0.0278549757248,-0.0175075795448],[0.0524745094945,0.0161482390125,0.0233701846778],[0.0483925179734,0.0168987608009,0.00865657186517],[0.0444785407107,0.0227185138253,-0.00654999980749],[0.1,0.0266358748669,-0.0386495333418],[0.1,0.0226401401684,-0.0388094480267],[0.1,0.01864440547,-0.0389693627115],[0.1,0.0250367280182,0.0013078136428],[0.1,0.0210409933198,0.00114789895793],[0.1,0.0170452586213,0.000987984273064],[0.1,0.0234375811695,0.0412651606274],[0.1,0.0194418464711,0.0411052459425],[0.1,0.0154461117726,0.0409453312576],[0.1,-0.0133214721177,-0.0402486801905],[0.1,-0.0193150741654,-0.0404885522178],[0.1,-0.0253086762131,-0.0407284242451],[0.1,-0.0149206189664,-0.000291333205888],[0.1,-0.0209142210141,-0.000531205233192],[0.1,-0.0269078230617,-0.000771077260496],[0.1,-0.0165197658151,0.0396660137787],[0.1,-0.0225133678628,0.0394261417514],[0.1,-0.0285069699104,0.0391862697241]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0414174776749,0.0224800236002,0.00631989003439],[0.0531065992778,0.0236044533251,-0.0127722152017],[0.063813082208,0.030960414923,-0.031121704131],[0.0476752245236,0.027219793052,0.0156738332364],[0.0504549781798,0.027861163681,-0.000762043517741],[0.0529367645821,0.0348367359133,-0.0173808489858],[0.0535833013125,0.0203318334547,0.0252974118956],[0.0478976645099,0.021274335639,0.0110662534206],[0.0424794966958,0.0284802918667,-0.00371289633235],[0.1,0.0337750452028,-0.04804573735],[0.1,0.0287833743705,-0.0482955290861],[0.1,0.0237917035381,-0.0485453208222],[0.1,0.0312771278418,0.00187097097344],[0.1,0.0262854570095,0.00162117923734],[0.1,0.0212937861772,0.00137138750124],[0.1,0.0287792104809,0.0517876792969],[0.1,0.0237875396485,0.0515378875608],[0.1,0.0187958688162,0.0512880958247],[0.1,-0.0161416631206,-0.050543654711],[0.1,-0.0236291693691,-0.0509183423151],[0.1,-0.0311166756176,-0.0512930299193],[0.1,-0.0186395804816,-0.000626946387549],[0.1,-0.0261270867301,-0.0010016339917],[0.1,-0.0336145929786,-0.00137632159584],[0.1,-0.0211374978426,0.0492897619359],[0.1,-0.0286250040911,0.0489150743317],[0.1,-0.0361125103396,0.0485403867276]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0458596550393,0.0171253387896,0.00570805632035],[0.0579307146651,0.0228169781946,-0.0133104506333],[0.0688943953052,0.0357535274108,-0.0315372879444],[0.0474003444278,0.0219308587312,0.0156663155167],[0.0501832812579,0.0269662957654,-0.000767292674102],[0.0525693251952,0.0393882187364,-0.0173037343191],[0.0488595976076,0.0151805914853,0.0257311856183],[0.0427611477788,0.0203509556603,0.0115521492481],[0.0368649405081,0.0328695110827,-0.00309645214631],[0.109776163985,0.0232310159791,-0.04857500986],[0.109726207303,0.028222353818,-0.0483252264515],[0.109676250621,0.0332136916569,-0.0480754430431],[0.0997934883069,0.0206332685314,0.00133836852888],[0.0997435316252,0.0256246063703,0.00158815193731],[0.0996935749435,0.0306159442092,0.00183793534574],[0.0898108126291,0.0180355210837,0.0512517469177],[0.0897608559474,0.0230268589226,0.0515015303262],[0.0897108992657,0.0280181967615,0.0517513137346],[0.110265739465,-0.025684094842,-0.0510228872626],[0.110240761124,-0.0231884259225,-0.0508979955584],[0.110215782783,-0.0206927570031,-0.0507731038542],[0.100283063787,-0.0282818422897,-0.00110950887374],[0.100258085447,-0.0257861733702,-0.000984617169526],[0.100233107106,-0.0232905044508,-0.00085972546531],[0.0903003881096,-0.0308795897373,0.0488038695151],[0.0902754097688,-0.0283839208179,0.0489287612193],[0.0902504314279,-0.0258882518985,0.0490536529235]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0503552142776,0.011815657564,0.00509574471693],[0.0627676307001,0.0220769228815,-0.013846535988],[0.0739304289343,0.0405934933788,-0.0319490776488],[0.0471819417712,0.0166382667039,0.0156551040352],[0.0499310221219,0.0260691208412,-0.000772064012721],[0.0521655791605,0.0439348449375,-0.0172230530838],[0.0441854239567,0.00998367443909,0.0261636582587],[0.0376404607896,0.0193791350575,0.0120385058402],[0.0312125017803,0.0372050860151,-0.00247918185189],[0.119761372476,0.0128866938969,-0.0490976211277],[0.119461662364,0.0278577107123,-0.0483483458474],[0.119161952252,0.0428287275276,-0.0475990705671],[0.0998000167225,0.00998949614651,0.000805768256861],[0.0995003066104,0.0249605129619,0.00155504353714],[0.0992005964983,0.0399315297772,0.00230431881741],[0.0798386609687,0.00709229839612,0.0507091576414],[0.0795389508566,0.0220633152115,0.0514584329217],[0.0792392407445,0.0370343320268,0.0522077082019],[0.120720444835,-0.0350205599122,-0.0514953020245],[0.120470686408,-0.0225447125661,-0.0508709059576],[0.120220927982,-0.01006886522,-0.0502465098907],[0.100759089081,-0.0379177576626,-0.00159191264002],[0.100509330655,-0.0254419103165,-0.000967516573124],[0.100259572228,-0.0129660629704,-0.000343120506227],[0.0807977333275,-0.040814955413,0.0483114767445],[0.0805479749007,-0.0283391080669,0.0489358728114],[0.0802982164739,-0.0158632607208,0.0495602688783]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0549036903755,0.00655151938589,0.00448298837886],[0.0676169138867,0.0213845381609,-0.0143804453733],[0.0789208099026,0.0454799383946,-0.0323571752822],[0.0470200809735,0.0113427285464,0.0156401787249],[0.0496982194119,0.0251700890156,-0.000776348596942],[0.051725591821,0.0484764799317,-0.0171388179572],[0.039561201107,0.00474153865248,0.0265948659523],[0.03253601012,0.0183591958958,0.0125253311287],[0.0255226602575,0.0414867677444,-0.00186103309792],[0.129951566256,0.0027462183063,-0.0496134670301],[0.129202415871,0.0276895901605,-0.0483648830547],[0.128453265485,0.0526329620147,-0.0471162990793],[0.100019520031,-0.000649930106787,0.000273276678284],[0.0992703696457,0.0242934417474,0.00152186065368],[0.0985212192604,0.0492368136016,0.00277044462908],[0.0700874738059,-0.00404607851987,0.0501600203867],[0.0693383234207,0.0208972933343,0.0514086043621],[0.0685891730354,0.0458406651885,0.0526571883375],[0.13135996898,-0.0441473207796,-0.0519608049039],[0.130685733633,-0.0216982861108,-0.050837079326],[0.130011498287,0.000750748557964,-0.0497133537481],[0.101427922755,-0.0475434691927,-0.00207406119547],[0.100753687408,-0.0250944345239,-0.000950335617608],[0.100079452062,-0.00264539985512,0.000173389960251],[0.0714958765301,-0.0509396176058,0.0478126825129],[0.0708216411834,-0.028490582937,0.0489364080908],[0.0701474058367,-0.00604154826821,0.0500601336686]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0595046126019,0.00133345705484,0.0038698200912],[0.0724781260233,0.0207400712266,-0.014912154008],[0.0838651666717,0.0504124864607,-0.032761683384],[0.0469148139079,0.00604495792343,0.0156215214199],[0.0494848801215,0.0242696502198,-0.000780137452099],[0.0512494243501,0.0530129899787,-0.0170510416433],[0.0349873455165,-0.000545355493733,0.0270248449071],[0.0274481954812,0.0172914627917,0.0130126329347],[0.0197958955925,0.0457143110768,-0.00124195395569],[0.140342604116,-0.00718635370002,-0.0501224450823],[0.138944516404,0.0277180580494,-0.0483748354419],[0.137546428692,0.0626224697987,-0.0466272258015],[0.100451847831,-0.0112807534289,-0.000258999726077],[0.0990537601191,0.0236236583204,0.00148860991432],[0.0976556724068,0.0585280700698,0.00323621955471],[0.0605610915464,-0.0153751531579,0.0496044456302],[0.0591630038341,0.0195292585915,0.0513520552706],[0.0577649161218,0.0544336703409,0.053099664911],[0.142180090824,-0.0530607234278,-0.0524193034668],[0.14088186652,-0.0206494839462,-0.0507965230865],[0.139583642215,0.0117617555354,-0.0491737427061],[0.102289334539,-0.0571551231567,-0.0025558581106],[0.100991110235,-0.0247438836751,-0.000933077730229],[0.0996928859304,0.00766735580643,0.000689702650137],[0.062398578254,-0.0612495228856,0.0473075872457],[0.0611003539497,-0.0288382834041,0.048930367626],[0.0598021296454,0.0035729560775,0.0505531480064]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0641575046519,-0.00383800332996,0.00325627229247],[0.0773508241968,0.0201437656154,-0.0154416381854],[0.0887631293208,0.055390759981,-0.0331627049386],[0.0468661798359,0.000745670268843,0.0155991158886],[0.049290999614,0.0233682539124,-0.000783421575241],[0.0507371337454,0.0575442420178,-0.0169597368693],[0.0304642693096,-0.00587654360825,0.02745363135],[0.0223774097243,0.0161762627591,0.0135004189206],[0.0140326873272,0.0498874745076,-0.000621892981734],[0.150930264528,-0.0169070489096,-0.0506244544646],[0.148684012029,0.027943101019,-0.0483782019655],[0.14643775953,0.0727932509476,-0.0461319494664],[0.101096764607,-0.0218987211298,-0.000790954543953],[0.098850512108,0.0229514287988,0.00145529795515],[0.0966042596089,0.0678015787274,0.00370155045426],[0.0512632646864,-0.02689039335,0.0490425453767],[0.0490170121873,0.0179597565786,0.0512887978758],[0.0467707596882,0.0628099065072,0.0535350503749],[0.153176517027,-0.0617571988381,-0.0528707069637],[0.151055056333,-0.0193987239056,-0.0507492462701],[0.14893359564,0.022959751027,-0.0486277855765],[0.103343017106,-0.0667488710584,-0.00303720704306],[0.101221556413,-0.0243903961258,-0.000915746349459],[0.099100095719,0.0179680788067,0.00120571434414],[0.0535095171856,-0.0717405432786,0.0467962928776],[0.051388056492,-0.0293820683461,0.0489177535712],[0.0492665957984,0.0129764065865,0.0510392142648]]]},{"data":["sx","sy","sz","sxy","syz","sxz"],"items":[1,2,3,4,5,6,7,8],"times":[0.0,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0,2.2,2.4,2.6,2.8,3.0,3.2,3.4,3.6,3.8,4.0],"values":[[[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0]],[[0.00219233717304,0.00159717150658,0.00371341805566,-0.000248448557236,-0.00345114296719,0.00871828304131],[-0.00163714347329,-0.00217803942368,-0.00496667371232,0.000183342164673,0.00195848534884,0.00894225777704],[0.00217358942324,0.00211091805116,0.00502500186518,-0.000203350253384,-0.00356086054316,0.00335658492598],[-0.00160019376747,-0.00164309746182,-0.00365778708297,0.000153592879631,0.00185187087891,0.00334545271255],[-0.00239925492903,-0.00191119091264,-0.00338467456686,-8.14771669804e-05,-0.00357114175829,0.0095166703052],[0.00144051370785,0.00184260474649,0.00532065944143,7.52793900426e-05,0.00202828181159,0.00802489859562],[-0.00266407060628,-0.00222688139772,-0.00462625239125,-1.94150971076e-05,-0.00362759086089,0.00363618601853],[0.00112259039868,0.00149737731371,0.00408347542678,5.50370192699e-05,0.0019736523369,0.00290951416177]],[[0.00478048719636,0.00314388439103,0.0072724871524,-0.000663303443794,-0.00684877123484,0.0175274577538],[-0.00288327924359,-0.00444459163733,-0.0100758727529,0.000462505026673,0.00396440568376,0.0178272500222],[0.00446482695417,0.00428493763708,0.0101359575507,-0.000490855429448,-0.00716468744837,0.00680177094508],[-0.00310676065833,-0.00326581114793,-0.00720997208906,0.000335313661965,0.00365504196258,0.00666957854494],[-0.00421426929723,-0.00374074042989,-0.00664030796755,-0.00038658118673,-0.0070255139102,0.0191805084487],[0.00330154220658,0.0037000837369,0.0107326107485,0.000212654941294,0.00416441289877,0.0160033073353],[-0.00533613437385,-0.00448397783539,-0.00942315488935,-0.000139946828363,-0.00737433556025,0.00741445088483],[0.0022307688437,0.0029055958904,0.00800607864072,0.000131134672375,0.00382885634759,0.00573872644794]],[[0.00777223246272,0.00463680289163,0.0106755905136,-0.00124150086894,-0.0101905795235,0.0264265122658],[-0.00373700336045,-0.00679607963057,-0.0153234664179,0.000840642489972,0.00601660177436,0.0266535567889],[0.00687558690224,0.00652160141337,0.0153298688659,-0.000864920075021,-0.0108103343402,0.0103367421569],[-0.00451655702494,-0.0048678330914,-0.0106531236181,0.000542891574868,0.00541040355464,0.00997402257546],[-0.00541216218552,-0.00549193238657,-0.00976065943153,-0.000910747995516,-0.0103595318807,0.028990038098],[0.00556668238272,0.00557032776373,0.016227716666,0.000418667605668,0.00640527604282,0.0239317807909],[-0.00800311424101,-0.00676228722047,-0.0143906428712,-0.000372612373796,-0.0112343642688,0.0113381440045],[0.00331965392891,0.00422205687953,0.0117682183346,0.000223821298495,0.00556147387187,0.00849067839605]],[[0.0111755689573,0.00607267091665,0.0139211706117,-0.00197982204799,-0.0134743682555,0.0354144660767],[-0.00419682423971,-0.00922878678279,-0.0207051382309,0.00132087348339,0.00811382303297,0.0354196255642],[0.00940769878893,0.00882023833845,0.0206036436217,-0.00132792387906,-0.0144965918456,0.0139627250716],[-0.00582640141793,-0.00644886247929,-0.0139837777706,0.00077414680019,0.00711886884048,0.0132603032825],[-0.00596055701271,-0.00716827283234,-0.0127397119882,-0.00164837577432,-0.0135696980566,0.038943661611],[0.00821892940921,0.00745139037495,0.0217980389947,0.000699356944669,0.00874758091982,0.031806867684],[-0.0106506925496,-0.00905288734758,-0.0195284123161,-0.000728811464913,-0.0152015304513,0.0154103331486],[0.00438485211987,0.00544426099098,0.0153702959971,0.000328749098465,0.00716752319751,0.0111685898746]],[[0.0149987141575,0.00744832086162,0.0170077249865,-0.00287489821566,-0.0166980364302,0.0444903551051],[-0.00426119284497,-0.011738861456,-0.0262163901213,0.00190627285797,0.0102547348396,0.0441237845134],[0.0120629543699,0.0111799548103,0.025954092536,-0.00188221554268,-0.0182221897305,0.0176809918505],[-0.00703308731515,-0.00800859888772,-0.0171984241806,0.00102698979173,0.00878136796553,0.0165298177092],[-0.00582770977479,-0.00877346804793,-0.0155717083671,-0.00259281465231,-0.0166526033769,0.0490396550103],[0.0112407484698,0.00934148478477,0.0274358717003,0.00106024075113,0.0111878717275,0.0396251427426],[-0.0132632545421,-0.0113469708284,-0.0248358796584,-0.00122029192089,-0.0192694079098,0.0196337834048],[0.00542243893436,0.00656982673806,0.0188126813354,0.000441694163593,0.00864317965225,0.0137758512581]],[[0.0150530063557,0.00749797032193,0.0173190221473,-0.00287313693962,-0.0166780079526,0.04451553466],[-0.00418914869981,-0.0116612747218,-0.0258633811681,0.0019072094335,0.0102725673138,0.0441094616927],[0.0121135800991,0.0112312487477,0.0262611014574,-0.00188338941811,-0.0182451412638,0.017706577752],[-0.00695923172938,-0.00793530510908,-0.0168500540835,0.00102609134928,0.00876063418302,0.0165150211962],[-0.00574937141188,-0.00869176385099,-0.0152055390238,-0.00259358127221,-0.0166771271608,0.0490333851071],[0.0112900499718,0.00938564129053,0.027726560407,0.0010598264174,0.0111705472419,0.0396580424486],[-0.013180710611,-0.0112680798472,-0.024465447561,-0.00121915510923,-0.0192522683621,0.019621205622],[0.00546961533505,0.0066167581364,0.019106683423,0.000441968938082,0.00866544695984,0.0138030038967]],[[0.0150530063557,0.00749797032193,0.0173190221473,-0.00287313693962,-0.0166780079526,0.04451553466],[-0.00418914869981,-0.0116612747218,-0.0258633811681,0.0019072094335,0.0102725673138,0.0441094616927],[0.0121135800991,0.0112312487477,0.0262611014574,-0.00188338941811,-0.0182451412638,0.017706577752],[-0.00695923172938,-0.00793530510908,-0.0168500540835,0.00102609134928,0.00876063418302,0.0165150211962],[-0.00574937141188,-0.00869176385099,-0.0152055390238,-0.00259358127221,-0.0166771271608,0.0490333851071],[0.0112900499718,0.00938564129053,0.027726560407,0.0010598264174,0.0111705472419,0.0396580424486],[-0.013180710611,-0.0112680798472,-0.024465447561,-0.00121915510923,-0.0192522683621,0.019621205622],[0.00546961533505,0.0066167581364,0.019106683423,0.000441968938082,0.00866544695984,0.0138030038967]],[[0.0150530063557,0.00749797032193,0.0173190221473,-0.00287313693962,-0.0166780079526,0.04451553466],[-0.00418914869981,-0.0116612747218,-0.0258633811681,0.0019072094335,0.0102725673138,0.0441094616927],[0.0121135800991,0.0112312487477,0.0262611014574,-0.00188338941811,-0.0182451412638,0.017706577752],[-0.00695923172938,-0.00793530510908,-0.0168500540835,0.00102609134928,0.00876063418302,0.0165150211962],[-0.00574937141188,-0.00869176385099,-0.0152055390238,-0.00259358127221,-0.0166771271608,0.0490333851071],[0.0112900499718,0.00938564129053,0.027726560407,0.0010598264174,0.0111705472419,0.0396580424486],[-0.013180710611,-0.0112680798472,-0.024465447561,-0.00121915510923,-0.0192522683621,0.019621205622],[0.00546961533505,0.0066167581364,0.019106683423,0.000441968938082,0.00866544695984,0.0138030038967]],[[0.0150530063557,0.00749797032193,0.0173190221473,-0.00287313693962,-0.0166780079526,0.04451553466],[-0.00418914869981,-0.0116612747218,-0.0258633811681,0.0019072094335,0.0102725673138,0.0441094616927],[0.0121135800991,0.0112312487477,0.0262611014574,-0.00188338941811,-0.0182451412638,0.017706577752],[-0.00695923172938,-0.00793530510908,-0.0168500540835,0.00102609134928,0.00876063418302,0.0165150211962],[-0.00574937141188,-0.00869176385099,-0.0152055390238,-0.00259358127221,-0.0166771271608,0.0490333851071],[0.0112900499718,0.00938564129053,0.027726560407,0.0010598264174,0.0111705472419,0.0396580424486],[-0.013180710611,-0.0112680798472,-0.024465447561,-0.00121915510923,-0.0192522683621,0.019621205622],[0.00546961533505,0.0066167581364,0.019106683423,0.000441968938082,0.00866544695984,0.0138030038967]],[[0.0150530063557,0.00749797032193,0.0173190221473,-0.00287313693962,-0.0166780079526,0.04451553466],[-0.00418914869981,-0.0116612747218,-0.0258633811681,0.0019072094335,0.0102725673138,0.0441094616927],[0.0121135800991,0.0112312487477,0.0262611014574,-0.00188338941811,-0.0182451412638,0.017706577752],[-0.00695923172938,-0.00793530510908,-0.0168500540835,0.00102609134928,0.00876063418302,0.0165150211962],[-0.00574937141188,-0.00869176385099,-0.0152055390238,-0.00259358127221,-0.0166771271608,0.0490333851071],[0.0112900499718,0.00938564129053,0.027726560407,0.0010598264174,0.0111705472419,0.0396580424486],[-0.013180710611,-0.0112680798472,-0.024465447561,-0.00121915510923,-0.0192522683621,0.019621205622],[0.00546961533505,0.0066167581364,0.019106683423,0.000441968938082,0.00866544695984,0.0138030038967]],[[0.0139566803884,0.00995193126618,0.0205684254537,0.000477661241973,0.00479863354373,0.0300307019333],[-0.00493446247329,-0.00892779040859,-0.0230851649607,0.000341337415589,0.00530691592387,0.0308312617208],[0.0127179769019,0.00827364836023,0.0237760845636,0.000424140354172,0.00421940204729,0.0306634587479],[-0.00566979833769,-0.00992718753912,-0.0187647688824,0.000322281567306,0.00477827043999,0.0301862906097],[-0.0125667861464,-0.0131844694624,-0.028838799802,-0.000168504091186,0.00520079171858,0.0325582932174],[0.00642917307923,0.00623004114241,0.0159279802495,-0.000367896409459,0.00383606060754,0.0275617201876],[-0.00694150861382,-0.00794318657832,-0.00983236018193,-0.000169381115438,0.00564865538864,0.0323207828742],[0.0107372932594,0.0101272622002,0.0320079926747,-0.000329279646334,0.00425587702603,0.0285273540499]],[[0.0145539067026,0.0108205203586,0.0189416247768,0.000929512672965,0.00930515988838,0.0297162008394],[-0.0045862816735,-0.00838389254442,-0.0252452101778,0.000686482490389,0.0103567870031,0.0311692811325],[0.0120764448731,0.00746318834147,0.0253574026948,0.000874016828104,0.00873742001412,0.0309814850776],[-0.00605755619238,-0.0103842145908,-0.0166049880461,0.000641590975916,0.00981927704454,0.0298790444219],[-0.015542270413,-0.01625787228,-0.0381487475646,-0.000333478954474,0.0108129696635,0.0326887946702],[0.00416757292851,0.0038846295975,0.00808107994511,-0.00072143801682,0.00805716541554,0.0270562880405],[-0.00428228601219,-0.00575889241462,-0.000128669017407,-0.000342666622533,0.0108730109514,0.0322132628931],[0.0127894509333,0.0116936111678,0.0402436778146,-0.000673428674336,0.00811180736847,0.0289879486302]],[[0.0151363548235,0.0117094007462,0.0172991949374,0.00138193675567,0.0138144432539,0.0294031269666],[-0.00425071685856,-0.00780929737599,-0.0274047314436,0.00104109364254,0.0154153568277,0.0315178854994],[0.0114200243037,0.00667148064958,0.0269240048195,0.00132317165687,0.0132657211297,0.031300479815],[-0.00645913820388,-0.0108136086215,-0.0144458348846,0.000953106425432,0.0148629810827,0.0295817945876],[-0.0186330345962,-0.0196446802315,-0.0473352041351,-0.000496087711219,0.0165416449472,0.0328274922093],[0.00183031805469,0.00126485592191,0.000360709074823,-0.00107862921216,0.0123850641775,0.0265354631004],[-0.00171945082552,-0.00385509493315,0.00971292917035,-0.000519073456024,0.0159550079635,0.0321129135544],[0.0147772432407,0.0130147159668,0.0486110509662,-0.00101495761342,0.0118311175432,0.0294339346022]],[[0.0157039562957,0.0126191859875,0.0156408990772,0.00183487737098,0.0183298739783,0.0290916292602],[-0.00392750385201,-0.00720291344811,-0.0295633709087,0.00140561746473,0.020485560421,0.0318772709729],[0.0107485899644,0.00589835286666,0.028476094923,0.00177158242263,0.0178074920141,0.0316203624475],[-0.00687489077034,-0.011215832164,-0.0122875564186,0.00125722017916,0.019912179437,0.0292944439265],[-0.0218444649915,-0.0233540952497,-0.0564026207691,-0.00065656526535,0.0223805387593,0.0329746805059],[-0.000585725606852,-0.00163678158423,-0.00723516863691,-0.00143973380094,0.0168122459234,0.0259989687439],[0.000751141468131,-0.00222434100744,0.0196952341324,-0.000698756575571,0.0208879093003,0.0320195086252],[0.0167032159311,0.0140977314831,0.057110686563,-0.0013541182465,0.0154063522258,0.0298654235421]],[[0.0162566056154,0.0135505926998,0.0139665057329,0.00228826902529,0.0228549186201,0.0287818705843],[-0.0036163901205,-0.00656350609278,-0.0317207289421,0.00178051304686,0.0255703813422,0.0322476531156],[0.0100619776074,0.00514371557034,0.0300138631269,0.00221923118932,0.0223659114322,0.0319410663813],[-0.00730517976156,-0.0115912309409,-0.0101303930805,0.00155431537616,0.0249696609652,0.0290169158957],[-0.025182249392,-0.0273957944984,-0.0653558103643,-0.000815170345614,0.0283234091772,0.0331306726591],[-0.00308383152036,-0.00482791246593,-0.0147089039928,-0.00180501856043,0.0213311541541,0.0254464972044],[0.00313343532688,-0.000859411222369,0.0298207358055,-0.000881861891391,0.0256648377486,0.0319328304339],[0.0185698174021,0.0149498017916,0.0657428824044,-0.00169116035554,0.0188300375824,0.0302824911553]],[[0.0164326893267,0.0131166464824,0.0133323485696,0.00203147518302,0.0205522660088,0.0303767288556],[-0.00351586855046,-0.00680581790081,-0.0323467032992,0.00206753848518,0.0268785652204,0.0338938270838],[0.00986420881163,0.00520396179044,0.0305738145679,0.00184192264798,0.0199977211194,0.0299542223081],[-0.00757134066701,-0.01133447909,-0.00955115467044,0.00164883917846,0.026209211414,0.0269741765028],[-0.0246946692069,-0.0273325655238,-0.0651791844835,-0.00106342700557,0.0260056762114,0.0348827774144],[-0.00258298327895,-0.00467537803962,-0.0138219380471,-0.00171602923713,0.0226266138828,0.0269886686998],[0.00267088625988,-0.00115530253,0.0287548227602,-0.0010756157367,0.0231618892616,0.0297607994725],[0.0182613942785,0.0147390136855,0.0654659661054,-0.00153510156381,0.0201704614093,0.0283699856517]],[[0.0166141887001,0.012691634706,0.0126840882875,0.00175917726583,0.0182662995063,0.0319983600691],[-0.00342912834888,-0.00705926802052,-0.0329881956888,0.00236965262346,0.0282034883993,0.0355333244274],[0.00967787439503,0.00527404412257,0.0311201517941,0.00148636104522,0.0176110166176,0.027995124583],[-0.00784345310036,-0.0110921265388,-0.00898726619824,0.00172752519837,0.0274301938265,0.0249243877573],[-0.0241961856644,-0.0272549484848,-0.0650140884414,-0.0013351601806,0.0237448170818,0.0366978851565],[-0.00209129102371,-0.00453514351742,-0.0129501565366,-0.00161310891198,0.0239732067808,0.0284845703397],[0.00221289661879,-0.0014330784608,0.0276697320871,-0.00124355426333,0.0206037035101,0.0276606653294],[0.0179441913025,0.014519723446,0.0651691373713,-0.00138875677432,0.0214534891341,0.0264099939373]],[[0.0168017531988,0.0122751373126,0.0120217103244,0.00147120314093,0.015997208468,0.0336467305691],[-0.00335644774495,-0.00732340793052,-0.0336452745677,0.00268690454606,0.0295453481544,0.0371661524929],[0.00950218281062,0.00535451290711,0.031652903317,0.001152398494,0.0152060393931,0.0260638303241],[-0.00812126049533,-0.0108646052221,-0.00843866177945,0.00179051900631,0.0286327955925,0.0228675362639],[-0.0236847406496,-0.0271655942205,-0.0648605422488,-0.00163076339992,0.0215419552714,0.0385748335692],[-0.00161008799999,-0.00440636740787,-0.0120935555242,-0.00149599022717,0.025369905869,0.0299330758698],[0.0017574308332,-0.00169011802163,0.0265655284183,-0.00138644730569,0.0179917805246,0.0256334723103],[0.017619375332,0.0142912490637,0.0648523250321,-0.00125181056302,0.0226780278038,0.0244037759847]],[[0.0169960351107,0.0118667259521,0.0113451984605,0.0011673899073,0.0137451842652,0.0353218033625],[-0.00329810683486,-0.00759778967443,-0.0343180116167,0.00301933860793,0.0309043435323,0.0387923123305],[0.00933634563288,0.00544590892825,0.0321720968475,0.000839874477691,0.0127830290606,0.0241603919544],[-0.00840450850665,-0.0106523458236,-0.0079052781028,0.00183796976203,0.0298172020385,0.0208036021908],[-0.0231582621631,-0.02706717691,-0.0647185682478,-0.00195049322268,0.0193981946898,0.0405124474244],[-0.00114071851186,-0.00428819342456,-0.0112521337263,-0.00136447425279,0.0268156648514,0.0313330768294],[0.00130249096809,-0.0019238448207,0.0254422752391,-0.00150519682312,0.0153276365232,0.0236802387249],[0.0172880928922,0.0140529316962,0.0645154558717,-0.0011238857258,0.0238430071679,0.0223526137905]],[[0.0171976893983,0.0114659639992,0.0106545348691,0.000847584096885,0.0115104201832,0.0370235380732],[-0.00325438757978,-0.00788196588528,-0.0350064817024,0.00336699447921,0.0322806752417,0.0404117986696],[0.00917957780881,0.00554876329872,0.0326777592589,0.000548616112662,0.0103422232279,0.0222848572252],[-0.00869294496509,-0.0104557777786,-0.00738705448335,0.00187003025669,0.0309835963027,0.0187325592983],[-0.0226146707147,-0.0269623875572,-0.0645881911453,-0.00229446870494,0.0173146197184,0.0425095388539],[-0.000684534306911,-0.00417975408382,-0.0104258925792,-0.00121843085502,0.0283094183781,0.032683482794],[0.000846122823509,-0.00213173328632,0.0243000349327,-0.00160083521011,0.0126128035338,0.0218019566721],[0.0169514668033,0.0138041389962,0.0641584547026,-0.00100454431247,0.0249473801312,0.0202578110387]]]}]} diff --git a/references/small_problems/febio/bk_rigid_lid_reopened.json b/references/small_problems/febio/bk_rigid_lid_reopened.json new file mode 100644 index 0000000..517f209 --- /dev/null +++ b/references/small_problems/febio/bk_rigid_lid_reopened.json @@ -0,0 +1 @@ +{"case":"bk_rigid_lid_reopened","input":"inputs/bk_rigid_lid_reopened.feb","input_sha256":"f8f7831830a2cf33093ebf1ee56830e3ddddd88fbe35342f7518975322023ce9","febio":{"version":"4.13.0","build":"provisional: source build at commit e4df3f8, Linux, GCC 11.5, no MKL, skyline solver, one thread; not an official release"},"records":[{"data":["ux","uy","uz"],"items":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"times":[0.0,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0],"values":[[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0115782814603,-0.00771773936487,0.00102524269697],[0.0125733651602,-0.00121819214505,-0.000657646315503],[0.0134683689183,0.00708647851281,-0.00235092380761],[0.00478167649734,-0.0078436440927,0.00156672054149],[0.00506651387641,-0.00135205557581,-0.000108822272226],[0.00529706514177,0.00694797220088,-0.00179128325932],[-0.00202122366805,-0.00790080967861,0.00211126757734],[-0.00244785416659,-0.00141445656697,0.000440594777253],[-0.00288301864221,0.00688232364685,-0.00123391802169],[0.0252375875343,-0.015762979874,0.0],[0.0250126044088,-0.000765229772745,0.0],[0.0247876212833,0.0142325203285,0.0],[0.0102398374331,-0.0159879629995,0.0],[0.0100148543076,-0.000990212898251,0.0],[0.00978987118206,0.014007537203,0.0],[-0.00475791266818,-0.016212946125,0.0],[-0.00498289579368,-0.00121519602376,0.0],[-0.00520787891919,0.0137825540775,0.0],[0.0252150892218,-0.0142632048639,0.0],[0.0249901060963,0.00073454523738,0.0],[0.0247651229708,0.0157322953386,0.0],[0.0102173391205,-0.0144881879894,0.0],[0.00999235599501,0.000509562111874,0.0],[0.00976737286951,0.0155073122131,0.0],[-0.00478041098073,-0.0147131711149,0.0],[-0.00500539410623,0.000284578986367,0.0],[-0.00523037723174,0.0152823290876,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0233013205629,-0.0153453751568,0.00199485383434],[0.0251722406587,-0.00231420254588,-0.00136319675443],[0.0267966710361,0.0142712467563,-0.00474775585538],[0.00969917163018,-0.0157040957636,0.00312609472375],[0.0101767620836,-0.00270063330934,-0.000216887333633],[0.0104976317714,0.0138681460189,-0.00357486812459],[-0.00393072824373,-0.015915036089,0.00427076153222],[-0.0048507541959,-0.00293582100019,0.000932185571251],[-0.00583802723666,0.013616922974,-0.00241129404164],[0.0509411371345,-0.0310618078791,0.0],[0.0500414071021,-0.00107980463933,0.0],[0.0491416770697,0.0289021986004,0.0],[0.0209591338948,-0.0319615379115,0.0],[0.0200594038624,-0.00197953467173,0.0],[0.01915967383,0.028002468568,0.0],[-0.00902286934494,-0.0328612679439,0.0],[-0.00992259937734,-0.00287926470413,0.0],[-0.0108223294097,0.0271027385356,0.0],[0.0508511641313,-0.0280636075551,0.0],[0.0499514340989,0.00191839568464,0.0],[0.0490517040665,0.0319003989244,0.0],[0.0208691608915,-0.0289633375875,0.0],[0.0199694308591,0.00101866565224,0.0],[0.0190697008267,0.031000668892,0.0],[-0.00911284234818,-0.0298630676199,0.0],[-0.0100125723806,0.000118935619843,0.0],[-0.010912302413,0.0301009388596,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0351668991755,-0.0228785735319,0.00290799077409],[0.0377932699406,-0.00328709643498,-0.00211572422649],[0.039983137615,0.0215507350961,-0.00718956395825],[0.01475359378,-0.0235788334534,0.00467693302735],[0.0153306258934,-0.00404415962507,-0.000324031260387],[0.0156030168943,0.020759863264,-0.00535006850084],[-0.00572696962863,-0.0240429522409,0.00647891821993],[-0.00720806279057,-0.00456289456911,0.00147497829025],[-0.00886290558764,0.0202047258089,-0.00353179819742],[0.0770965166659,-0.0458827161026,0.0],[0.0750728831719,-0.000943441503618,0.0],[0.0730492496779,0.0439958330954,0.0],[0.0321572420669,-0.0479063495966,0.0],[0.0301336085729,-0.00296707499762,0.0],[0.0281099750789,0.0419721996014,0.0],[-0.0127820325321,-0.0499299830906,0.0],[-0.0148056660261,-0.00499070849162,0.0],[-0.0168292995202,0.0399485661074,0.0],[0.0768941533165,-0.0413887886427,0.0],[0.0748705198225,0.00355048595628,0.0],[0.0728468863285,0.0484897605553,0.0],[0.0319548787175,-0.0434124221367,0.0],[0.0299312452235,0.00152685246228,0.0],[0.0279076117295,0.0464661270613,0.0],[-0.0129843958815,-0.0454360556307,0.0],[-0.0150080293755,-0.000496781031723,0.0],[-0.0170316628696,0.0444424935673,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0471725941853,-0.0303130457807,0.00376383914234],[0.050433117335,-0.00413606693386,-0.00291423377666],[0.053026140046,0.0289213963148,-0.00967547644182],[0.0199459748138,-0.0314652284589,0.00621798253267],[0.0205279279386,-0.00538108253828,-0.000430088616941],[0.0206145006777,0.0276225317637,-0.00711624924813],[-0.00740829511745,-0.0322848388879,0.00873619399946],[-0.00951918207106,-0.00629453771821,0.00206922072524],[-0.0119556510145,0.0266466658171,-0.00459507064296],[0.103689187377,-0.0602123667277,0.0],[0.100093505304,-0.000356263083218,0.0],[0.0964978232312,0.0594998405612,0.0],[0.0438330837328,-0.0638080488007,0.0],[0.0402374016598,-0.00395194515628,0.0],[0.0366417195867,0.0559041584882,0.0],[-0.0160230199116,-0.0674037308738,0.0],[-0.0196187019847,-0.00754762722935,0.0],[-0.0232143840578,0.0523084764151,0.0],[0.10332961917,-0.0542267563632,0.0],[0.0997339370969,0.00562934728123,0.0],[0.0961382550239,0.0654854509257,0.0],[0.0434735155255,-0.0578224384363,0.0],[0.0398778334525,0.00203366520816,0.0],[0.0362821513794,0.0618897688526,0.0],[-0.0163825881189,-0.0614181205094,0.0],[-0.019978270192,-0.00156201686491,0.0],[-0.0235739522651,0.0582940867796,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.059315779301,-0.0376445601591,0.00456161903647],[0.0630884773198,-0.00486043201523,-0.00375766987631],[0.0659241832877,0.0363797129751,-0.0122046817926],[0.0252772609847,-0.039360542617,0.00774792876063],[0.0257684327794,-0.00670987358001,-0.000534892453429],[0.0255333229099,0.0344556214005,-0.00887282219626],[-0.00897293914083,-0.040640979345,0.0110430575117],[-0.0117835500144,-0.00812967205906,0.00271520278725],[-0.0151143762944,0.0329436772565,-0.00560071755385],[0.130704216985,-0.0740378640359,0.0],[0.125089755953,0.000681202200923,0.0],[0.119475294921,0.0754002684377,0.0],[0.0559851507483,-0.0796523250679,0.0],[0.0503706897163,-0.00493325883106,0.0],[0.0447562286843,0.0697858074057,0.0],[-0.0187339154885,-0.0852667860998,0.0],[-0.0243483765205,-0.010547719863,0.0],[-0.0299628375525,0.0641713463738,0.0],[0.130142770882,-0.0665659574122,0.0],[0.12452830985,0.0081531088246,0.0],[0.118913848818,0.0828721750614,0.0],[0.0554237046451,-0.0721804184442,0.0],[0.0498092436131,0.00253864779262,0.0],[0.0441947825812,0.0772577140294,0.0],[-0.0192953615917,-0.0777948794762,0.0],[-0.0249098226237,-0.00307581323935,0.0],[-0.0305242836556,0.0716432529974,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.026967039736,-0.00154013470711,0.00486211239576],[0.0305628605752,-0.0014553218279,-0.00568430405288],[0.0338661134054,-0.00143862086075,-0.0162517733128],[0.0269492025909,3.85244204593e-10,0.00483748905313],[0.030557073269,6.5196753378e-11,-0.00568162462354],[0.0338718504673,-3.36380673316e-10,-0.0162255600431],[0.0269670404051,0.00154013547287,0.0048621123296],[0.0305628613069,0.00145532195373,-0.0056843041186],[0.0338661141958,0.00143862018366,-0.0162517733798],[0.0599999992698,7.78461295425e-10,-0.01],[0.0599999992698,4.8213877335e-11,-0.01],[0.0599999992698,-6.82033318711e-10,-0.01],[0.06,7.78461295425e-10,-0.01],[0.06,4.8213877335e-11,-0.01],[0.06,-6.82033429733e-10,-0.01],[0.0600000007302,7.78461295425e-10,-0.01],[0.0600000007302,4.8213877335e-11,-0.01],[0.0600000007302,-6.82033429733e-10,-0.01],[0.0599999992698,7.05436487003e-10,-0.01],[0.0599999992698,-2.48108200651e-11,-0.01],[0.0599999992698,-7.55058238155e-10,-0.01],[0.06,7.05436487003e-10,-0.01],[0.06,-2.48108200651e-11,-0.01],[0.06,-7.55058127133e-10,-0.01],[0.0600000007302,7.05436598025e-10,-0.01],[0.0600000007302,-2.48108200651e-11,-0.01],[0.0600000007302,-7.55058127133e-10,-0.01]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0302143771455,-0.00336835298362,0.00190623180344],[0.0359116076994,-0.00320801819976,-0.0108265647745],[0.0411663380195,-0.00314688034691,-0.0235614057789],[0.0301842987676,4.68037650559e-12,0.00183801751304],[0.0358995695565,7.83014011328e-13,-0.0108199783554],[0.041171211469,-4.08011241984e-12,-0.023490253214],[0.0302143771536,0.00336835299292,0.0019062318026],[0.0359116077082,0.00320801820127,-0.0108265647753],[0.041166338029,0.0031468803387,-0.0235614057797],[0.0699999999912,9.41635658336e-12,-0.02],[0.0699999999912,5.83200154836e-13,-0.02],[0.0699999999912,-8.24984525138e-12,-0.02],[0.07,9.41635658336e-12,-0.02],[0.07,5.83200154836e-13,-0.02],[0.07,-8.24995627369e-12,-0.02],[0.0700000000088,9.41624556106e-12,-0.02],[0.0700000000088,5.83311177138e-13,-0.02],[0.0700000000088,-8.24995627369e-12,-0.02],[0.0699999999912,8.53306314497e-12,-0.02],[0.0699999999912,-3.00204305859e-13,-0.02],[0.0699999999912,-9.13336073438e-12,-0.02],[0.07,8.53306314497e-12,-0.02],[0.07,-3.00093283556e-13,-0.02],[0.07,-9.13324971208e-12,-0.02],[0.0700000000088,8.53295212266e-12,-0.02],[0.0700000000088,-3.00093283556e-13,-0.02],[0.0700000000088,-9.13324971208e-12,-0.02]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0334662917769,-0.00521032247609,-0.00104339208941],[0.0412681007631,-0.00497120766044,-0.0159711259244],[0.048474104038,-0.00486727416549,-0.0308875430232],[0.0334226532473,1.19707252778e-13,-0.00117046004268],[0.0412502463996,1.9803055733e-14,-0.015959774487],[0.0484800009193,-1.042413118e-13,-0.0307566872225],[0.0334662917771,0.00521032247633,-0.00104339208943],[0.0412681007634,0.00497120766048,-0.0159711259245],[0.0484741040383,0.00486727416528,-0.0308875430232],[0.0799999999998,2.39919195621e-13,-0.03],[0.0799999999998,1.487698853e-14,-0.03],[0.0799999999998,-2.10276240864e-13,-0.03],[0.08,2.39919195621e-13,-0.03],[0.08,1.487698853e-14,-0.03],[0.08,-2.10220729713e-13,-0.03],[0.0800000000002,2.40030217924e-13,-0.03],[0.0800000000002,1.487698853e-14,-0.03],[0.0800000000002,-2.10276240864e-13,-0.03],[0.0799999999998,2.17492690524e-13,-0.03],[0.0799999999998,-7.54951656745e-15,-0.03],[0.0799999999998,-2.32702745961e-13,-0.03],[0.08,2.17492690524e-13,-0.03],[0.08,-7.66053886991e-15,-0.03],[0.08,-2.32758257113e-13,-0.03],[0.0800000000002,2.17381668222e-13,-0.03],[0.0800000000002,-7.66053886991e-15,-0.03],[0.0800000000002,-2.32702745961e-13,-0.03]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0367230798577,-0.00706632702188,-0.0039872539971],[0.0466327081738,-0.00674514185195,-0.0211179866895],[0.0557895787192,-0.00660003001422,-0.0382302007893],[0.0366643433479,5.44314867896e-15,-0.00418913478434],[0.0466095059118,8.91062677831e-16,-0.0211009735078],[0.055798616345,-4.72481460779e-15,-0.0380241543102],[0.0367230798577,0.0070663270219,-0.0039872539971],[0.0466327081738,0.00674514185196,-0.0211179866895],[0.0557895787192,0.00660003001421,-0.0382302007893],[0.09,1.08801856413e-14,-0.04],[0.09,6.66133814775e-16,-0.04],[0.09,-9.54791801178e-15,-0.04],[0.09,1.08801856413e-14,-0.04],[0.09,6.66133814775e-16,-0.04],[0.09,-9.54791801178e-15,-0.04],[0.09,1.08801856413e-14,-0.04],[0.09,6.66133814775e-16,-0.04],[0.09,-9.54791801178e-15,-0.04],[0.09,9.88098491916e-15,-0.04],[0.09,-4.4408920985e-16,-0.04],[0.09,-1.06581410364e-14,-0.04],[0.09,9.88098491916e-15,-0.04],[0.09,-3.33066907388e-16,-0.04],[0.09,-1.06026298852e-14,-0.04],[0.09,9.99200722163e-15,-0.04],[0.09,-3.33066907388e-16,-0.04],[0.09,-1.05471187339e-14,-0.04]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0399850467436,-0.00893666291216,-0.00692587780438],[0.0520058247173,-0.00853009477101,-0.0262671433818],[0.0631129449773,-0.00834538402888,-0.045589395118],[0.0399094458035,3.79902748827e-16,-0.00721924278003],[0.0519777783565,1.57325050244e-17,-0.0262435326996],[0.0631274827895,-2.93165289848e-16,-0.0452919207021],[0.0399850467436,0.00893666291216,-0.00692587780438],[0.0520058247173,0.00853009477101,-0.0262671433818],[0.0631129449773,0.00834538402888,-0.045589395118],[0.1,7.77156117238e-16,-0.05],[0.1,0.0,-0.05],[0.1,-6.66133814775e-16,-0.05],[0.1,7.77156117238e-16,-0.05],[0.1,0.0,-0.05],[0.1,-6.66133814775e-16,-0.05],[0.1,8.881784197e-16,-0.05],[0.1,0.0,-0.05],[0.1,-6.66133814775e-16,-0.05],[0.1,6.66133814775e-16,-0.05],[0.1,0.0,-0.05],[0.1,-6.66133814775e-16,-0.05],[0.1,6.66133814775e-16,-0.05],[0.1,0.0,-0.05],[0.1,-7.77156117238e-16,-0.05],[0.1,6.66133814775e-16,-0.05],[0.1,0.0,-0.05],[0.1,-7.77156117238e-16,-0.05]]]},{"data":["sx","sy","sz","sxy","syz","sxz"],"items":[1,2,3,4,5,6,7,8],"times":[0.0,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0],"values":[[[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0]],[[0.00103888882711,0.000691547157773,0.00155158512189,-0.000217479437709,-0.00347112283672,0.00571042369493],[-0.000904073072745,-0.00121563923949,-0.00279105795967,0.000168240145776,0.00194129892575,0.00587345098629],[0.00108837021638,0.00117771199597,0.00280294903826,-0.000171753796371,-0.00354289654159,0.000349599567957],[-0.000792328902054,-0.000708687622254,-0.0015442343834,0.000137872440461,0.00186951996419,0.00026803478791],[-0.00124430648721,-0.000883590767955,-0.0014300907771,-4.31702051328e-05,-0.00355069570115,0.00626494772566],[0.00071672209032,0.000991151563076,0.00292818035628,6.43402659266e-05,0.00204629352727,0.0052542264042],[-0.00136557930712,-0.00116758845568,-0.00259753205618,2.20435139659e-05,-0.00364519592286,0.000387295312588],[0.000509789143793,0.00067124176797,0.00175511645313,4.57830740122e-05,0.00195648824032,0.000149087009507]],[[0.00222126047337,0.00137236005762,0.00301158596935,-0.000541945711238,-0.00689844921411,0.0114892253141],[-0.0016912631421,-0.00248881798668,-0.00567712113745,0.000399846397277,0.00392537041452,0.0117164444828],[0.00217900591524,0.00240325047072,0.00563488731494,-0.000362787282676,-0.00712407310317,0.000766052195006],[-0.00161555078257,-0.0014218935254,-0.0030589896419,0.000274517872206,0.00369672966143,0.00052276282708],[-0.00227223881876,-0.0017138725815,-0.00281910122956,-0.000232832371452,-0.00697468211145,0.0126771916758],[0.00158732439755,0.00198419977358,0.00588479642512,0.000168804249907,0.00420721896256,0.0104192882663],[-0.00281701205633,-0.00232758731196,-0.00530210912259,2.66039390437e-05,-0.00741413726642,0.000923772087737],[0.000958871536803,0.00128865973673,0.00341039200159,9.42545481886e-05,0.00378947528731,0.00019650677605]],[[0.00355236152284,0.00204009552882,0.00437966694459,-0.000972529714118,-0.010280676722,0.0173362894797],[-0.00236199085557,-0.0038174291346,-0.00865711403606,0.000696315106323,0.00595225086199,0.0175288925695],[0.00327212327403,0.00367754252153,0.00849526873148,-0.000574661252502,-0.0107428599729,0.0012499856852],[-0.00246828492465,-0.00214052455589,-0.00454303011048,0.000409079597671,0.00548254808356,0.000764801056226],[-0.00306513543167,-0.00249801952927,-0.00416534991861,-0.000566796478879,-0.0102681508981,0.0192339184568],[0.00260232494884,0.00298025571273,0.00886754763148,0.000317183006584,0.00647941215019,0.0154915966045],[-0.004351693465,-0.00347089406847,-0.00811353776316,6.66286447434e-06,-0.0113017499443,0.00161348361765],[0.00134632809548,0.00184945753594,0.00496559786703,0.000143881766556,0.00549513988341,0.000146256154375]],[[0.00503750526249,0.00269239997247,0.00565548895268,-0.00150827558372,-0.013616525608,0.0232514842226],[-0.00291665025684,-0.005199339095,-0.0117299546172,0.00105914553251,0.0080219483886,0.023310648451],[0.00436794342401,0.00500141598484,0.0113835284477,-0.000808969405183,-0.0143985839505,0.00180203945332],[-0.00334913511372,-0.00286548498295,-0.00599509762361,0.000540764824432,0.00722788086226,0.00099470413867],[-0.003604551501,-0.003243339492,-0.00546720075093,-0.001042019947,-0.0134273624507,0.0259322204787],[0.00375194270198,0.00398050635595,0.0118741884413,0.000512845891582,0.00885938992302,0.0204676425437],[-0.00596639150919,-0.0045886055968,-0.0110315894931,-4.53204626124e-05,-0.015302799188,0.00246033496608],[0.00167138903835,0.00235096097117,0.00642046847325,0.00019335217681,0.00706978612788,2.44496908422e-06]],[[0.00668207105837,0.00332691270917,0.00683870944643,-0.00214814006808,-0.0169047371046,0.0292346578745],[-0.00335561557782,-0.00663238863539,-0.0148945537018,0.00148983772455,0.0101344428438,0.0290615078525],[0.00546669379249,0.00637559682632,0.0142990811497,-0.00106733617069,-0.0180905698775,0.00242286500697],[-0.00425669267296,-0.00359767458388,-0.00741390805612,0.000668844366098,0.00893361820449,0.0012129658108],[-0.00387232539216,-0.00395723212823,-0.00672306867839,-0.00165460437715,-0.0164486478936,0.0327690958512],[0.00502613644138,0.00498619344266,0.0149025329201,0.000758733145098,0.0113435529556,0.0253440051139],[-0.00765720006402,-0.00567206460039,-0.0140559904339,-0.000137389156197,-0.0194118888299,0.00346807470313],[0.00193341182028,0.00279064248442,0.00777469564694,0.000241568152675,0.00850984578924,-0.000230707572911]],[[0.00548298095275,0.00374436502248,0.00286890079093,-5.5773012392e-06,-0.000567403661566,0.0173583127475],[-0.00641885721253,-0.00810244893943,-0.0241919352134,-1.50402869084e-05,-0.000511878044388,0.018951914693],[0.00548298096567,0.00374436499278,0.00286890071419,5.57733544314e-06,0.000567404001526,0.0173583130087],[-0.00641885719922,-0.00810244897221,-0.0241919352905,1.50402645952e-05,0.00051187785811,0.0189519149636],[-0.00932953115944,-0.00884420575639,-0.0238584561063,4.00346049658e-06,0.000560016035169,0.0198910581015],[0.00290938516932,0.0034369243202,0.00445273436981,-8.84795208822e-06,0.000526269992039,0.0157775978452],[-0.00932953111733,-0.00884420573553,-0.02385845603,-4.00343996316e-06,-0.00056001568646,0.0198910583865],[0.00290938520558,0.00343692434253,0.00445273444307,8.84794173823e-06,-0.000526270185183,0.0157775980945]],[[0.00510117497357,0.00289498166253,-0.00525418001263,-2.54367778297e-05,-0.0012430929889,0.0196153021328],[-0.00932006005995,-0.0115628575216,-0.0378673184609,-4.33741325658e-05,-0.00111760888871,0.0225249056147],[0.00510117497375,0.00289498166216,-0.00525418001361,2.54367782815e-05,0.001243092993,0.0196153021359],[-0.00932006005974,-0.0115628575221,-0.0378673184619,4.33741322783e-05,0.00111760888644,0.0225249056179],[-0.0129047968048,-0.012580573198,-0.0379792652174,1.96563850029e-05,0.00122326268864,0.0234975191292],[0.00221872999942,0.00268659418569,-0.00292103728639,-8.55501883718e-06,0.00115427071386,0.0176436716063],[-0.0129047968042,-0.0125805731977,-0.0379792652164,-1.96563847063e-05,-0.00122326268446,0.0234975191327],[0.00221872999992,0.00268659418599,-0.00292103728545,8.55501869917e-06,-0.00115427071617,0.0176436716093]],[[0.00475013440378,0.00202878890409,-0.0134169463865,-5.62200773878e-05,-0.00192110702605,0.0218439404109],[-0.0122250342183,-0.0151331509085,-0.0517335667128,-8.71316330893e-05,-0.00171956871871,0.026053693219],[0.00475013440378,0.00202878890408,-0.0134169463865,5.62200774003e-05,0.00192110702615,0.0218439404109],[-0.0122250342183,-0.0151331509085,-0.0517335667128,8.71316330815e-05,0.00171956871865,0.0260536932191],[-0.016515140799,-0.0164413639242,-0.0523092219425,5.14208227051e-05,0.00188358191961,0.0270622293572],[0.00154189345093,0.0019258414176,-0.0103172535739,1.06985208747e-07,0.00178537496131,0.0194785856053],[-0.016515140799,-0.0164413639242,-0.0523092219425,-5.14208226963e-05,-0.00188358191951,0.0270622293573],[0.00154189345094,0.0019258414176,-0.0103172535738,-1.06985212615e-07,-0.00178537496137,0.0194785856054]],[[0.00442971419173,0.00114488943935,-0.0216218058009,-9.82341514987e-05,-0.00260161798125,0.0240444191499],[-0.0151351115293,-0.0188175402021,-0.0657976792332,-0.000146829521599,-0.00231747753573,0.029537610693],[0.00442971419173,0.00114488943935,-0.0216218058009,9.82341514994e-05,0.00260161798126,0.02404441915],[-0.0151351115293,-0.0188175402021,-0.0657976792332,0.000146829521598,0.00231747753573,0.029537610693],[-0.0201635202204,-0.02043154845,-0.0668563302433,9.98361553536e-05,0.00254074505775,0.0305848004062],[0.000878138766968,0.00115419419049,-0.0177372811987,1.73437832465e-05,0.00241979128571,0.0212821520564],[-0.0201635202204,-0.02043154845,-0.0668563302433,-9.98361553531e-05,-0.00254074505774,0.0305848004062],[0.000878138766969,0.0011541941905,-0.0177372811987,-1.73437832467e-05,-0.00241979128572,0.0212821520564]],[[0.00413975554094,0.000242333184612,-0.0298713022717,-0.000151801420976,-0.00328480659114,0.0262169490259],[-0.0180516869231,-0.0226204307939,-0.0800669673119,-0.000223006770782,-0.0029110400071,0.0329759741302],[0.00413975554094,0.000242333184612,-0.0298713022717,0.000151801420976,0.00328480659114,0.0262169490259],[-0.0180516869231,-0.0226204307939,-0.0800669673119,0.000223006770782,0.0029110400071,0.0329759741302],[-0.0238530524195,-0.0245563337559,-0.0816289641649,0.000165463882223,0.00319451326943,0.0340648454175],[0.000226671799782,0.000371155755261,-0.0251825584462,4.33703064265e-05,0.00305773927268,0.0230541737052],[-0.0238530524195,-0.0245563337559,-0.0816289641649,-0.000165463882223,-0.00319451326943,0.0340648454175],[0.000226671799782,0.000371155755261,-0.0251825584462,-4.33703064264e-05,-0.00305773927268,0.0230541737052]]]}]} diff --git a/references/small_problems/febio/bk_rigid_tied_free.json b/references/small_problems/febio/bk_rigid_tied_free.json new file mode 100644 index 0000000..540c4be --- /dev/null +++ b/references/small_problems/febio/bk_rigid_tied_free.json @@ -0,0 +1 @@ +{"case":"bk_rigid_tied_free","input":"inputs/bk_rigid_tied_free.feb","input_sha256":"53c44d9b85282975dc60b51fde841675a5913f959f5a489868e95595855ffa60","febio":{"version":"4.13.0","build":"provisional: source build at commit e4df3f8, Linux, GCC 11.5, no MKL, skyline solver, one thread; not an official release"},"records":[{"data":["ux","uy","uz"],"items":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35],"times":[0.0,0.2,0.4,0.6,0.8,1.0],"values":[[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.00954537382995,-0.000324322308753,0.00301660953987],[0.0101924279085,-0.000247082948349,-0.000334949807233],[0.0107806144868,-0.000143404848312,-0.00370200915931],[0.00943960414975,-0.000418658124504,0.00313270484818],[0.0100760811156,-0.000342546846853,-0.000217860330879],[0.0106541343132,-0.000232831311617,-0.00358341626954],[0.00933632930274,-0.000511483361082,0.0032477035404],[0.00995958207735,-0.000436772478786,-0.000100599789177],[0.0105249197829,-0.000321264873521,-0.00346352183355],[0.0202343246994,-0.000910281031283,-1.11022302463e-16],[0.0202342570486,-0.000650183340707,0.0],[0.0202341893977,-0.000390085650132,0.0],[0.0199742270088,-0.000910348682096,-1.11022302463e-16],[0.019974159358,-0.00065025099152,0.0],[0.0199740917072,-0.000390153300945,0.0],[0.0197141293182,-0.000910416332909,-1.11022302463e-16],[0.0197140616674,-0.000650318642334,0.0],[0.0197139940166,-0.000390220951758,0.0],[0.0201300826707,-0.000130015019881,0.0],[0.0201300150199,0.000130082670694,0.0],[0.0198699849801,-0.000130082670694,0.0],[0.0198699173293,0.000130015019881,0.0],[0.0201300826707,-0.000130015019881,0.0],[0.0201300150199,0.000130082670694,0.0],[0.0198699849801,-0.000130082670694,0.0],[0.0198699173293,0.000130015019881,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0191371435626,-0.000617212023639,0.0060263677649],[0.0203804964078,-0.00045843381026,-0.00066745977749],[0.0215069288799,-0.000262103621182,-0.00739764258989],[0.018926471151,-0.000827985060669,0.00625874317631],[0.0201524564649,-0.000676046070026,-0.000435408146889],[0.0212617870611,-0.000459558297864,-0.00716332935638],[0.0187244807028,-0.00103481475932,0.00648595740103],[0.0199232832579,-0.000890933391749,-0.000202808809149],[0.0210059213518,-0.000655353815767,-0.00692339095905],[0.0404629603614,-0.00179657693784,-1.11022302463e-16],[0.040462696807,-0.00128320147017,0.0],[0.0404624332526,-0.000769826002506,0.0],[0.0399495848938,-0.00179684049228,-1.11022302463e-16],[0.0399493213393,-0.00128346502461,0.0],[0.0399490577849,-0.000770089556947,0.0],[0.0394362094261,-0.00179710404672,-1.11022302463e-16],[0.0394359458717,-0.00128372857906,0.0],[0.0394356823172,-0.000770353111387,0.0],[0.0402568195111,-0.000256555956614,0.0],[0.0402565559566,0.000256819511054,0.0],[0.0397434440434,-0.000256819511054,0.0],[0.0397431804889,0.000256555956614,0.0],[0.0402568195111,-0.000256555956614,0.0],[0.0402565559566,0.000256819511054,0.0],[0.0397434440434,-0.000256819511054,0.0],[0.0397431804889,0.000256555956614,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0287750444975,-0.000879100277941,0.00902824163108],[0.0305644228523,-0.00063449589154,-0.000997449550029],[0.0321793729661,-0.000356366903023,-0.0110861291287],[0.0284603153464,-0.00122833664683,0.00937766204124],[0.0302291653997,-0.00100085788595,-0.00065261237137],[0.0318231407193,-0.000680435228268,-0.0107393785674],[0.0281640472143,-0.00157030724671,0.00971396869755],[0.029890995339,-0.00136277365844,-0.000306584539926],[0.0314430780352,-0.00100250012564,-0.0103787335714],[0.060686117655,-0.00265985136193,0.0],[0.0606855398934,-0.00189974526267,0.0],[0.0606849621318,-0.00113963916342,0.0],[0.0599260115557,-0.00266042912354,0.0],[0.0599254337941,-0.00190032302429,0.0],[0.0599248560325,-0.00114021692504,0.0],[0.0591659054565,-0.00266100688516,0.0],[0.0591653276949,-0.00190090078591,0.0],[0.0591647499332,-0.00114079468665,0.0],[0.0603803419304,-0.000379764168818,0.0],[0.0603797641688,0.000380341930434,0.0],[0.0596202358312,-0.000380341930434,0.0],[0.0596196580696,0.000379764168818,0.0],[0.0603803419304,-0.000379764168818,0.0],[0.0603797641688,0.000380341930434,0.0],[0.0596202358312,-0.000380341930434,0.0],[0.0596196580696,0.000379764168818,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0384587737646,-0.00111040547282,0.0120212097393],[0.0407444266259,-0.000775704497396,-0.00132484448799],[0.0427983980153,-0.00042645495752,-0.0147666954084],[0.0380408350549,-0.00162004837044,0.0124890043465],[0.0403062511036,-0.00131732298858,-0.000869444948411],[0.0423383931492,-0.000895702529889,-0.0143111965789],[0.0376545979501,-0.00211824568579,0.0129309416335],[0.0398626192722,-0.00185255334555,-0.000411887834787],[0.0418365037358,-0.00136291895038,-0.0138286799238],[0.0809039969276,-0.00350101657661,0.0],[0.0809029958305,-0.00250046870119,0.0],[0.0809019947335,-0.00149992082578,0.0],[0.0799034490521,-0.00350201767367,0.0],[0.0799024479551,-0.00250146979825,0.0],[0.079901446858,-0.00150092192283,0.0],[0.0789029011767,-0.00350301877072,0.0],[0.0789019000797,-0.0025024708953,0.0],[0.0789008989826,-0.00150192301988,0.0],[0.0805007744862,-0.000499773389182,0.0],[0.0804997733892,0.000500774486235,0.0],[0.0795002266108,-0.000500774486235,0.0],[0.0794992255138,0.000499773389182,0.0],[0.0805007744862,-0.000499773389182,0.0],[0.0804997733892,0.000500774486235,0.0],[0.0795002266108,-0.000500774486235,0.0],[0.0794992255138,0.000499773389182,0.0]],[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0481879909364,-0.00131153516073,0.0150042628664],[0.0509207287601,-0.000882488629294,-0.00164957644984],[0.0533644773101,-0.000472619103108,-0.0184385664199],[0.0476677120132,-0.00200343719893,0.0155923080627],[0.0503837600708,-0.00162576422316,-0.0010858809652],[0.0528077577584,-0.00110558796737,-0.0178784084913],[0.0471956774085,-0.0026788885547,0.0161360785538],[0.0498380642511,-0.00236050328476,-0.00051868269882],[0.0521863518868,-0.00173680832288,-0.0172723646645],[0.101116789095,-0.00432093789933,-1.11022302463e-16],[0.101115264001,-0.00308599204689,-2.22044604925e-16],[0.101113738908,-0.00185104619444,0.0],[0.0998818432423,-0.00432246299291,-1.11022302463e-16],[0.0998803181487,-0.00308751714047,-2.22044604925e-16],[0.0998787930551,-0.00185257128803,0.0],[0.0986468973899,-0.0043239880865,-1.11022302463e-16],[0.0986453722963,-0.00308904223405,-2.22044604925e-16],[0.0986438472027,-0.00185409638161,0.0],[0.100618235473,-0.00061671037943,0.0],[0.100616710379,0.000618235473014,0.0],[0.0993832896206,-0.000618235473014,0.0],[0.099381764527,0.00061671037943,0.0],[0.100618235473,-0.00061671037943,0.0],[0.100616710379,0.000618235473014,0.0],[0.0993832896206,-0.000618235473014,0.0],[0.099381764527,0.00061671037943,0.0]]]},{"data":["sx","sy","sz","sxy","syz","sxz"],"items":[1,2,3,4,5,6,7,8],"times":[0.0,0.2,0.4,0.6,0.8,1.0],"values":[[[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0]],[[0.00211504878292,0.00177669159241,0.00422832126111,-1.16528669167e-05,-0.000209247312392,0.00604151635913],[-0.00166384220031,-0.0019561477127,-0.00443563468288,-4.63238520003e-06,-0.000132073814138,0.00618807946769],[0.00223346081634,0.0019044809868,0.00452935951472,-1.12021109426e-05,-0.000280271836546,0.00595767127462],[-0.00154650548633,-0.00182999693337,-0.00414046531358,-2.47634795264e-06,-0.000197958799373,0.00609990499241],[-0.00246208711947,-0.00201895666167,-0.00382983960017,5.95723435649e-06,-0.000307152515059,0.00654631739087],[0.00134241818898,0.00173979253886,0.00486021416058,6.43566011286e-06,-0.000170043471587,0.00555931922264],[-0.00258635560953,-0.0021454485172,-0.0041339742226,2.09270371533e-06,-0.00023600177592,0.00644038097416],[0.0012226495622,0.00161838462031,0.00456794721897,4.44802006527e-06,-0.000103708578716,0.00546698753824]],[[0.00447565599287,0.0035399984671,0.00845726543599,-3.08375760751e-05,-0.00040341155714,0.0121109049084],[-0.00306028007485,-0.00391716058068,-0.00885329672575,-1.62768800997e-05,-0.000251355624357,0.0123507385172],[0.00470335233215,0.00379237929658,0.00905186300621,-3.40698687198e-05,-0.000563906899791,0.0119462172027],[-0.0028316696132,-0.00366455901234,-0.00826430732187,-1.28031276822e-05,-0.000399123716865,0.0121786793622],[-0.00463718335708,-0.0040449958567,-0.00764505896901,-7.77535392101e-07,-0.000616305820649,0.0130865584636],[0.00290139756632,0.00346474216918,0.00972021606235,4.64680516701e-06,-0.000345930767098,0.0111610282385],[-0.00489487035238,-0.00429884968197,-0.00825298579152,-7.46298447097e-06,-0.000456002867067,0.0128759318845],[0.00265844165391,0.00322488722708,0.00914215932083,4.34132901146e-06,-0.000196525305272,0.0109771213464]],[[0.00708086195131,0.00528911980939,0.0126848375639,-5.66490894048e-05,-0.000582667346514,0.0182075616919],[-0.00418771571143,-0.00588211023781,-0.0132511262913,-3.42042539155e-05,-0.000358138640594,0.0184874862667],[0.00740890760157,0.00566304645976,0.0135657178222,-6.86986154451e-05,-0.000851138585594,0.0179648678887],[-0.00385377652058,-0.0055027630079,-0.0123697639801,-3.12090591827e-05,-0.000603577583541,0.0182357573563],[-0.00652316698958,-0.00607721361331,-0.0114439994247,-2.03606924902e-05,-0.000927643896975,0.0196202717712],[0.0046762799332,0.00517415470971,0.0145781404261,-5.52933115146e-06,-0.000527824550372,0.0168045115491],[-0.00692304222316,-0.00645938165928,-0.012355363652,-2.77297637952e-05,-0.000660340131368,0.0193060732905],[0.00430702036358,0.00481875323941,0.0137207293548,3.55397813218e-07,-0.000278469175848,0.0165298057566]],[[0.00992968221751,0.00702328577996,0.016909065819,-8.82067430042e-05,-0.000747187120144,0.0243308666265],[-0.00504459090732,-0.0078500514909,-0.0176272624719,-5.76970734027e-05,-0.000452711164516,0.0245978416541],[0.0103493213218,0.00751585701744,0.0180691479655,-0.000115197535627,-0.0011421803077,0.0240128469893],[-0.00461115863064,-0.00734367344057,-0.0164550764278,-5.79354783662e-05,-0.000811387575154,0.0242705852409],[-0.00811795834917,-0.00811469182534,-0.0152250070263,-5.29695989445e-05,-0.00124132969141,0.0261470045903],[0.00666638026947,0.0068673614057,0.019432148287,-2.42655088236e-05,-0.000715874213924,0.0224891432],[-0.00866842527389,-0.00862620116419,-0.0164394324165,-5.7786616219e-05,-0.000849343305999,0.0257302327581],[0.00616799114062,0.00639925409328,0.0183017732708,-6.84868178266e-06,-0.000349562329151,0.0221244346613]],[[0.0130211089227,0.00874175738799,0.0211280026766,-0.000124653635471,-0.000897142307341,0.0304801843446],[-0.00562938935495,-0.00982002369607,-0.0219798460554,-8.60492684675e-05,-0.000535357135781,0.0306813347142],[0.013523752497,0.00935020905747,0.0225603960643,-0.000173687941654,-0.0014372263821,0.0300893721779],[-0.00510219808652,-0.00918634348596,-0.0205184907678,-9.32350010382e-05,-0.00102260636131,0.030282622002],[-0.00941952293674,-0.0101564990714,-0.0189864336145,-9.88005735938e-05,-0.00155750669556,0.0326663043235],[0.0088709886782,0.00854371940289,0.0242804285279,-5.17432254446e-05,-0.000910216159063,0.0282142881867],[-0.0101286316786,-0.0107984447276,-0.02050351444,-9.67281870677e-05,-0.001023335941,0.0321478458935],[0.00824092295058,0.00796568744277,0.0228834310224,-1.66239762653e-05,-0.000409830715854,0.0277603924015]]]}]} diff --git a/references/small_problems/febio/rb_spin.json b/references/small_problems/febio/rb_spin.json new file mode 100644 index 0000000..a254456 --- /dev/null +++ b/references/small_problems/febio/rb_spin.json @@ -0,0 +1 @@ +{"case":"rb_spin","input":"inputs/rb_spin.feb","input_sha256":"6c54541d460339e0c166c0eef4e78c8b60db98881d3dcf15b56b19a695501c10","febio":{"version":"4.13.0","build":"provisional: source build at commit e4df3f8, Linux, GCC 11.5, no MKL, skyline solver, one thread; not an official release"},"records":[{"data":["ux","uy","uz"],"items":[1,2,3,4,5,6,7,8],"times":[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0],"values":[[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0]],[[8.57913374204e-05,6.21606536584e-05,-0.000117802779418],[0.000107132858378,0.000275831393289,-0.000188480682995],[-0.000127861242192,6.20986322197e-05,0.000162189093831],[-0.000106519721235,0.00027576937185,9.15111902542e-05],[0.000128529875359,-0.000217822094526,-0.00011784288788],[0.000107140880394,-4.16375918402e-06,-0.000132522416807],[-8.51298253544e-05,-0.000153784754719,0.000149345370493],[-8.94234051438e-05,-5.21195186507e-05,0.000134649798182]],[[0.000514825102646,0.000373513808534,-0.000706810258242],[0.000642167497521,0.00165613891367,-0.00112976182915],[-0.000767146639169,0.000371280983836,0.000973128093441],[-0.000639804244294,0.00165390608897,0.000550176522536],[0.00077193662511,-0.00130609625856,-0.00070825385744],[0.000642884671623,-2.39177183602e-05,-0.000795217758008],[-0.000510291550496,-0.000923608536457,0.000895197173521],[-0.000536498894998,-0.000313274023096,0.000807655833274]],[[0.00163045456894,0.00118774011805,-0.00223807183586],[0.00202783528166,0.00525385562615,-0.00356866171774],[-0.00242911715242,0.00116534887989,0.00308187669667],[-0.0020317364397,0.00523146438799,0.00175128681479],[0.00245065132925,-0.00412892083436,-0.00225254174375],[0.00203611769769,-6.72835738915e-05,-0.00251914191913],[-0.00161149332994,-0.00293214915723,0.00282782828019],[-0.00169794825738,-0.000997176277727,0.00255544014165]],[[0.0037759141243,0.00277315365044,-0.00518197782778],[0.00466990572381,0.0122084887309,-0.00822484621706],[-0.00562440294779,0.00265306461088,0.00713864296353],[-0.00473041134829,0.0120883996914,0.00409577457424],[0.00570260420488,-0.00952987774469,-0.0052595191922],[0.00471653238997,-0.000118560472104,-0.00583826342322],[-0.00371152489952,-0.00682296893129,0.00651785970606],[-0.00392692068221,-0.00233286421675,0.00590809892927]],[[0.00729369930293,0.0054296253243,-0.0100071126418],[0.0089371647664,0.0237153094396,-0.0157637326422],[-0.0108617483082,0.00498143367496,0.0137954532904],[-0.00921828284469,0.0232671177903,0.00803883328999],[0.0111027288428,-0.0183075452901,-0.0102961353963],[0.0091151047841,-0.000111499504617,-0.0112922422102],[-0.00710434255754,-0.0132834774543,0.0124935215137],[-0.00756835480033,-0.00458229991458,0.011381805598]],[[0.0125241671122,0.00951236761225,-0.0171778104325],[0.0151323062504,0.0410637338214,-0.0267540239855],[-0.0186449153204,0.00819003669416,0.0237049680621],[-0.0160367761822,0.0397414029033,0.014128754509],[0.0192893474084,-0.0311785570673,-0.0180289321444],[0.0156636700601,0.000108342958189,-0.0194285899985],[-0.0120323657557,-0.0230751480502,0.0212074656391],[-0.0129519709855,-0.00806461789654,0.0194673591002]],[[0.0198025670496,0.01546265212,-0.0271491722039],[0.0234522555541,0.0656811099954,-0.0416094913105],[-0.0294657908297,0.0121528032395,0.0375143536304],[-0.0258161023253,0.0623712611149,0.0230540345239],[0.03099597465,-0.0487244392644,-0.0292740673306],[0.0247919915785,0.00083204883488,-0.0308016812703],[-0.0186555274145,-0.0370680462487,0.0329912685468],[-0.0203821474458,-0.0131863947032,0.0306136965564]],[[0.0294532060325,0.0238454280606,-0.0403575084506],[0.0339357636779,0.0991754648767,-0.0605115230035],[-0.0437905649272,0.0165083146494,0.0558492668038],[-0.0393080072818,0.0918383514654,0.0356952522509],[0.0470859306913,-0.0713164435839,-0.0450518743833],[0.0369197341448,0.0025461705499,-0.0459645338853],[-0.0270103861035,-0.0562746593526,0.0479948997629],[-0.0301234927865,-0.0204767938767,0.0452044938878]],[[0.0417787992863,0.0353934630117,-0.0572031513769],[0.0463956172445,0.143367031581,-0.0833081562576],[-0.0620344612685,0.0205812282131,0.0792808192218],[-0.0574176433103,0.128554796782,0.0531758143411],[0.0685853950034,-0.09901058356,-0.0666391914575],[0.0524395608507,0.00600053804909,-0.0654474022185],[-0.0369572179805,-0.0818751148319,0.066107796795],[-0.0423804138464,-0.0306256118515,0.0635251700017]],[[0.0570422668958,0.0510568207054,-0.0780213408209],[0.0603328841752,0.200293320791,-0.109385402077],[-0.0845190447114,0.0233003017765,0.108266094533],[-0.081228427432,0.172536801862,0.0769020332773],[0.0967079123181,-0.131403677653,-0.0956085950201],[0.0716862672761,0.0122815186462,-0.0897151692049],[-0.0481130534534,-0.115221942125,0.0868582450176],[-0.0572684403265,-0.0445209451684,0.0857167691531]]]}]} diff --git a/references/small_problems/febio/rb_spin_from_zero.json b/references/small_problems/febio/rb_spin_from_zero.json new file mode 100644 index 0000000..197725b --- /dev/null +++ b/references/small_problems/febio/rb_spin_from_zero.json @@ -0,0 +1 @@ +{"case":"rb_spin_from_zero","input":"inputs/rb_spin_from_zero.feb","input_sha256":"4ffb4c604c0ac5d1e66ecf3eb3ddfe2ce3cf0e7e7fd6f8d9652df576e6e9349e","febio":{"version":"4.13.0","build":"provisional: source build at commit e4df3f8, Linux, GCC 11.5, MKL 2024.2 (Pardiso), one thread; not an official release"},"records":[{"data":["ux","uy","uz"],"items":[1,2,3,4,5,6,7,8],"times":[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0],"values":[[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0]],[[0.000861369874165,0.000975502197979,-0.00118118955418],[0.00107329125497,0.00312042298042,-0.00188531954685],[-0.00128173082016,0.000969268342888,0.00162501619982],[-0.00106980943936,0.00311418912533,0.000920886207137],[0.00129089399104,-0.00182978922953,-0.00118521663776],[0.00107419523298,0.000313884781887,-0.00132810547964],[-0.000852923309875,-0.00119273386555,0.00149393629104],[-0.000897812421186,-0.000171176425129,0.00134943661573]],[[0.00430356602385,0.00421153494728,-0.00589850860533],[0.0053142788955,0.0149608953757,-0.00934467346763],[-0.00640055102112,0.00405598489068,0.00811925853693],[-0.00538983814948,0.0148053453191,0.00467309367463],[0.00649810015221,-0.00978351198062,-0.00599885229903],[0.00536798961486,0.000934738436445,-0.00664146373289],[-0.00422392654262,-0.0067189204104,0.0074055983988],[-0.00447622342863,-0.00159868876449,0.00672284948747]],[[0.0111774826035,0.0101801279363,-0.0153154039703],[0.0135530123793,0.0382812306822,-0.0239087665542],[-0.016620068656,0.00912971622563,0.0211128295934],[-0.0142445388803,0.0372308189715,0.0125194670095],[0.0171426687966,-0.026095767544,-0.0159913944715],[0.0139586883204,0.0017952528597,-0.0172991103426],[-0.010776150068,-0.0187473607823,0.018951677324],[-0.011574056067,-0.00536669857068,0.0173735652524]],[[0.0214642781314,0.0192880108489,-0.0293980089335],[0.0253010461984,0.0737637178367,-0.044866745873],[-0.0319005146625,0.015406269485,0.0406063745146],[-0.0280637465955,0.0698819764727,0.0251376375752],[0.0336860693706,-0.0501594772406,-0.0318872700355],[0.0268498788788,0.00353988147436,-0.0333551302853],[-0.0201286367871,-0.0378149587492,0.0355766238343],[-0.0220761107832,-0.01189459527,0.0331130591437]],[[0.0351193310728,0.0321466105472,-0.0480698849528],[0.039795178668,0.122353287887,-0.071103167179],[-0.0521416900306,0.0217176231157,0.066536944164],[-0.0474658424354,0.111924300456,0.0435036619378],[0.0567900178316,-0.0809861949094,-0.0547263644802],[0.0440136612061,0.0071346849445,-0.054838280883],[-0.0316860796263,-0.0646660487618,0.0564086848423],[-0.0357941615483,-0.0217982910906,0.0536341766284]],[[0.0520522888112,0.0495708554119,-0.0711807530972],[0.0559654507764,0.185157467965,-0.101046389538],[-0.0771351886985,0.0265305360696,0.0987026717089],[-0.0732220267333,0.162117148623,0.068837035268],[0.087275387069,-0.117119084515,-0.0858007262667],[0.0653510535322,0.0138594641701,-0.0816896777464],[-0.0446137661765,-0.100174629671,0.0802195103513],[-0.0524488604101,-0.035872056957,0.0784825696037]],[[0.0721001253483,0.0725725416958,-0.0984642740487],[0.072400903909,0.263304048953,-0.132613153995],[-0.106502833957,0.0279860066011,0.136665677266],[-0.106202055396,0.218717513859,0.10251679732],[0.126060119945,-0.156529040652,-0.126558525558],[0.0906403066443,0.0252851595869,-0.113681415241],[-0.0578106945713,-0.145233719622,0.105380660312],[-0.071646510033,-0.0550601523225,0.107020070025]],[[0.0949933132303,0.102343735234,-0.129485058116],[0.0873210293628,0.357751489248,-0.163161960997],[-0.139624492534,0.0239712668544,0.179638182968],[-0.147296776401,0.279379020868,0.145961280087],[0.174071022715,-0.196506623535,-0.178467088293],[0.119475177695,0.0432266368026,-0.150319342957],[-0.0698870023821,-0.200607939762,0.129826779159],[-0.0928517636084,-0.0804148229322,0.138381712424]],[[0.120315777758,0.140224426791,-0.163575984791],[0.0985634549725,0.469049421027,-0.189472008371],[-0.175560774512,0.0122373655224,0.22636054915],[-0.197313097298,0.341062359758,0.200464525571],[0.232124670512,-0.233568055624,-0.242827402609],[0.151197037273,0.0696595263575,-0.1907361194],[-0.0791538751617,-0.26674723046,0.151038420277],[-0.115357951299,-0.113036641445,0.171429136359]],[[0.147460241652,0.187647542714,-0.199768414388],[0.103600990095,0.597051594038,-0.207768551415],[-0.212979293067,-0.00942496605559,0.274984980163],[-0.256838544625,0.399979085268,0.266984843136],[0.300774395258,-0.26339995761,-0.320535269679],[0.184827236757,0.106589591959,-0.233584727796],[-0.0836361009703,-0.343563426246,0.166060685601],[-0.138257598029,-0.153992876807,0.204704485368]]]}]} diff --git a/references/small_problems/generate.py b/references/small_problems/generate.py index 1d91d06..bf93d13 100644 --- a/references/small_problems/generate.py +++ b/references/small_problems/generate.py @@ -32,6 +32,7 @@ from __future__ import annotations +import re import inspect import itertools import json @@ -3870,6 +3871,71 @@ def rigid_tied_nodes(): ) +def rigid_spin(from_zero=False): + """A rigid body alone, spun up by moments: the dynamics of a body. + + One skewed hex8 of material "rigid body" (density 2), so that its + inertia is not diagonal, free in all six components, in a dynamic + step of ten time steps of 0.1. Two `rigid_moment` loads, 0.4 about x + and 0.25 about z, and a `rigid_force` of 0.3 in y, load_type LOAD. The + body turns about an axis that is not a principal axis, so the angular + momentum and the rotational mass matrix of FEBio's rigid solver are + exercised, and it translates under the force. + + Two forms. Ramped: the loads follow a curve from 0 to 1, the stiffness + is symmetric (FEBio then keeps the upper triangle of the rotational + mass block, which is not symmetric) and reformed in every iteration. + From zero: the loads act from time zero, so FEBio's initial + accelerations are not zero; the stiffness is non-symmetric, with BFGS + updates between reformations. + + Logged: the displacement of the eight nodes. + """ + grid = Grid( + (1, 1, 1), (1, 1, 1), mapping=lambda x, y, z: (x + 0.3 * y * z, y + 0.2 * x * z - 0.1 * x, z * (1 + 0.4 * x * y)) + ) + lc = "" if from_zero else ' lc="1"' + load = lambda name, kind, dof, value: ( # noqa: E731 + f'\t\t\n\t\t\tbody\n\t\t\t{dof}\n' + f"\t\t\t{value:g}\n\t\t\tLOAD\n" + "\t\t\t0\n\t\t" + ) + step = control("DYNAMIC", steps=10, dt=0.1) + if from_zero: + step = step.replace(">symmetric<", ">non-symmetric<").replace("0<", "10<") + return deck( + inspect.cleandoc(rigid_spin.__doc__), + [ + section( + "Material", + '\t\t\n' + "\t\t\t2\n\t\t\t1\n\t\t\t0\n\t\t", + ), + section("Mesh", grid.nodes_xml("Object1"), grid.elems_xml("Part1"), nodeset("all", list(grid.nodes))), + section("MeshDomains", '\t\t'), + section( + "Rigid", + load("about x", "rigid_moment", "Ru", 0.4), + load("about z", "rigid_moment", "Rw", 0.25), + load("along y", "rigid_force", "Ry", 0.3), + ), + step, + section("LoadData", load_curve(1, [(0, 0), (1, 1)])), + output(''), + ], + ) + + +def _without_rigid_bc(text: str, name: str) -> str: + """An input without its first rigid condition of the given name.""" + changed, count = re.subn( + rf'[ \t]*\n', "", text, count=1, flags=re.DOTALL + ) + if count != 1: + raise ValueError(f"no rigid_bc named {name!r}") + return changed + + def main() -> None: OUT.mkdir(parents=True, exist_ok=True) cases = {} @@ -3984,6 +4050,24 @@ def main() -> None: sticky_block_snap_in_step(), 2, ["sticky", "several steps", "snap_tol"]) # fmt: skip cases["bk_rigid_tied_nodes"] = ( rigid_tied_nodes(), 2, ["rigid body", "rigid node set", "rigid_displacement", "rigid_rotation"]) # fmt: skip + # A rigid body with a component that no condition holds: an unknown + # (docs/design/rigid_bodies.md). Each is one of the inputs above with one + # rigid condition taken out. The lid moved through four steps, without + # the displacement of step 2: z is open in that step, and the lid goes + # where the block pushes it. The lid with conditions of the model, + # without the fixed condition of step 2: the rotation that step 1 + # prescribed is open in step 2. The tied nodes, without the rotation of + # the body: it turns as the block it is tied to lets it. + cases["bk_rigid_lid_released"] = ( + _without_rigid_bc(rigid_lid(), "down"), 2, ["rigid body", "unknowns", "release", "several steps"]) # fmt: skip + cases["bk_rigid_lid_reopened"] = ( + _without_rigid_bc(rigid_lid(top=True), "again"), 2, ["rigid body", "unknowns", "release", "several steps"]) # fmt: skip + cases["rb_spin"] = ( + rigid_spin(), 2, ["rigid body", "unknowns", "DYNAMIC", "rigid_moment", "rigid_force"]) # fmt: skip + cases["rb_spin_from_zero"] = ( + rigid_spin(from_zero=True), 2, ["rigid body", "unknowns", "DYNAMIC", "initial accelerations", "non-symmetric"]) # fmt: skip + cases["bk_rigid_tied_free"] = ( + _without_rigid_bc(rigid_tied_nodes(), "twist"), 2, ["rigid body", "unknowns", "rigid node set"]) # fmt: skip # Trusses as chordae, kept in a file of their own (generate_trusses.py). from generate_trusses import cases as truss_cases diff --git a/references/small_problems/inputs/bk_rigid_lid_released.feb b/references/small_problems/inputs/bk_rigid_lid_released.feb new file mode 100644 index 0000000..8d9aadb --- /dev/null +++ b/references/small_problems/inputs/bk_rigid_lid_released.feb @@ -0,0 +1,330 @@ + + + + + + + 1 + 1 + 0.3 + + + 1 + 1 + 0 + + + + + 0,0,0 + 0.5,0,0 + 1,0,0 + 0,0.5,0 + 0.5,0.5,0 + 1,0.5,0 + 0,1,0 + 0.5,1,0 + 1,1,0 + 0.050000000000000003,0,0.5 + 0.55000000000000004,0,0.52500000000000002 + 1.05,0,0.55000000000000004 + 0.050000000000000003,0.5,0.5 + 0.55000000000000004,0.5,0.52500000000000002 + 1.05,0.5,0.55000000000000004 + 0.050000000000000003,1,0.5 + 0.55000000000000004,1,0.52500000000000002 + 1.05,1,0.55000000000000004 + 0.10000000000000001,0,1 + 0.59999999999999998,0,1.05 + 1.1000000000000001,0,1.1000000000000001 + 0.10000000000000001,0.5,1 + 0.59999999999999998,0.5,1.05 + 1.1000000000000001,0.5,1.1000000000000001 + 0.10000000000000001,1,1 + 0.59999999999999998,1,1.05 + 1.1000000000000001,1,1.1000000000000001 + 0.15000000000000002,0,1.5 + 0.65000000000000002,0,1.5750000000000002 + 1.1499999999999999,0,1.6500000000000001 + 0.15000000000000002,0.5,1.5 + 0.65000000000000002,0.5,1.5750000000000002 + 1.1499999999999999,0.5,1.6500000000000001 + 0.15000000000000002,1,1.5 + 0.65000000000000002,1,1.5750000000000002 + 1.1499999999999999,1,1.6500000000000001 + + + 1,2,5,4,10,11,14,13 + 2,3,6,5,11,12,15,14 + 4,5,8,7,13,14,17,16 + 5,6,9,8,14,15,18,17 + 10,11,14,13,19,20,23,22 + 11,12,15,14,20,21,24,23 + 13,14,17,16,22,23,26,25 + 14,15,18,17,23,24,27,26 + + + 19,20,23,22,28,29,32,31 + 20,21,24,23,29,30,33,32 + 22,23,26,25,31,32,35,34 + 23,24,27,26,32,33,36,35 + + 1,2,3,4,5,6,7,8,9 + 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36 + 1,2,3,4,5,6,7,8 + + + + + + + + 111 + + + + + + STATIC + 5 + 0.2 + + symmetric + 25 + 1e-7 + 1e-12 + 0 + 0.9 + + 0 + + + + + + lid + 0 + 1 + 1 + 1 + 1 + 0 + + + lid + x + 0.1 + 0 + + + lid + Rw + 0.15 + 0 + + + + + + STATIC + 5 + 0.2 + + symmetric + 25 + 1e-7 + 1e-12 + 0 + 0.9 + + 0 + + + + + + lid + 1 + 1 + 0 + 1 + 1 + 1 + + + + + + STATIC + 5 + 0.2 + + symmetric + 25 + 1e-7 + 1e-12 + 0 + 0.9 + + 0 + + + + + + lid + 1 + 1 + 1 + 0 + 1 + 1 + + + lid + Ru + 0.1 + 0 + + + + + + STATIC + 5 + 0.2 + + symmetric + 25 + 1e-7 + 1e-12 + 0 + 0.9 + + 0 + + + + + + lid + 1 + 1 + 1 + 0 + 0 + 0 + + + lid + Ru + 0 + 1 + + + lid + Rv + 0 + 1 + + + lid + Rw + 0.1 + 1 + + + + + + + LINEAR + CONSTANT + + 0,0 + 1,1 + + + + LINEAR + CONSTANT + + 1,0 + 2,1 + + + + LINEAR + CONSTANT + + 2,0 + 3,1 + + + + LINEAR + CONSTANT + + 3,0 + 4,1 + + + + + + + + + + + + + + + diff --git a/references/small_problems/inputs/bk_rigid_lid_reopened.feb b/references/small_problems/inputs/bk_rigid_lid_reopened.feb new file mode 100644 index 0000000..f47e17d --- /dev/null +++ b/references/small_problems/inputs/bk_rigid_lid_reopened.feb @@ -0,0 +1,239 @@ + + + + + + + 1 + 1 + 0.3 + + + 1 + 1 + 0 + + + + + 0,0,0 + 0.5,0,0 + 1,0,0 + 0,0.5,0 + 0.5,0.5,0 + 1,0.5,0 + 0,1,0 + 0.5,1,0 + 1,1,0 + 0.050000000000000003,0,0.5 + 0.55000000000000004,0,0.52500000000000002 + 1.05,0,0.55000000000000004 + 0.050000000000000003,0.5,0.5 + 0.55000000000000004,0.5,0.52500000000000002 + 1.05,0.5,0.55000000000000004 + 0.050000000000000003,1,0.5 + 0.55000000000000004,1,0.52500000000000002 + 1.05,1,0.55000000000000004 + 0.10000000000000001,0,1 + 0.59999999999999998,0,1.05 + 1.1000000000000001,0,1.1000000000000001 + 0.10000000000000001,0.5,1 + 0.59999999999999998,0.5,1.05 + 1.1000000000000001,0.5,1.1000000000000001 + 0.10000000000000001,1,1 + 0.59999999999999998,1,1.05 + 1.1000000000000001,1,1.1000000000000001 + 0.15000000000000002,0,1.5 + 0.65000000000000002,0,1.5750000000000002 + 1.1499999999999999,0,1.6500000000000001 + 0.15000000000000002,0.5,1.5 + 0.65000000000000002,0.5,1.5750000000000002 + 1.1499999999999999,0.5,1.6500000000000001 + 0.15000000000000002,1,1.5 + 0.65000000000000002,1,1.5750000000000002 + 1.1499999999999999,1,1.6500000000000001 + + + 1,2,5,4,10,11,14,13 + 2,3,6,5,11,12,15,14 + 4,5,8,7,13,14,17,16 + 5,6,9,8,14,15,18,17 + 10,11,14,13,19,20,23,22 + 11,12,15,14,20,21,24,23 + 13,14,17,16,22,23,26,25 + 14,15,18,17,23,24,27,26 + + + 19,20,23,22,28,29,32,31 + 20,21,24,23,29,30,33,32 + 22,23,26,25,31,32,35,34 + 23,24,27,26,32,33,36,35 + + 1,2,3,4,5,6,7,8,9 + 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36 + 1,2,3,4,5,6,7,8 + + + + + + + + 111 + + + + + lid + 1 + 1 + 1 + 1 + 1 + 1 + + + lid + x + 0.1 + 1 + + + + + + STATIC + 5 + 0.2 + + symmetric + 25 + 1e-7 + 1e-12 + 0 + 0.9 + + 0 + + + + + + lid + Rw + 0.15 + 0 + + + + + + STATIC + 5 + 0.2 + + symmetric + 25 + 1e-7 + 1e-12 + 0 + 0.9 + + 0 + + + + + + lid + z + -0.05 + 1 + + + + + + + LINEAR + CONSTANT + + 0,0 + 1,1 + + + + LINEAR + CONSTANT + + 1,0 + 2,1 + + + + LINEAR + CONSTANT + + 0,0 + 2,1 + + + + + + + + + + + + + + + diff --git a/references/small_problems/inputs/bk_rigid_tied_free.feb b/references/small_problems/inputs/bk_rigid_tied_free.feb new file mode 100644 index 0000000..1038c09 --- /dev/null +++ b/references/small_problems/inputs/bk_rigid_tied_free.feb @@ -0,0 +1,156 @@ + + + + + + + 1 + 1 + 0.3 + + + 1 + 1 + 0 + + + + + 0,0,0 + 0.5,0,0 + 1,0,0 + 0,0.5,0 + 0.5,0.5,0 + 1,0.5,0 + 0,1,0 + 0.5,1,0 + 1,1,0 + 0.050000000000000003,0,0.5 + 0.55000000000000004,0,0.52500000000000002 + 1.05,0,0.55000000000000004 + 0.050000000000000003,0.5,0.5 + 0.55000000000000004,0.5,0.52500000000000002 + 1.05,0.5,0.55000000000000004 + 0.050000000000000003,1,0.5 + 0.55000000000000004,1,0.52500000000000002 + 1.05,1,0.55000000000000004 + 0.10000000000000001,0,1 + 0.59999999999999998,0,1.05 + 1.1000000000000001,0,1.1000000000000001 + 0.10000000000000001,0.5,1 + 0.59999999999999998,0.5,1.05 + 1.1000000000000001,0.5,1.1000000000000001 + 0.10000000000000001,1,1 + 0.59999999999999998,1,1.05 + 1.1000000000000001,1,1.1000000000000001 + + + 1.6000000000000001,0.20000000000000001,1.3 + 2.1000000000000001,0.20000000000000001,1.3 + 1.6000000000000001,0.69999999999999996,1.3 + 2.1000000000000001,0.69999999999999996,1.3 + 1.6000000000000001,0.20000000000000001,1.8 + 2.1000000000000001,0.20000000000000001,1.8 + 1.6000000000000001,0.69999999999999996,1.8 + 2.1000000000000001,0.69999999999999996,1.8 + + + 1,2,5,4,10,11,14,13 + 2,3,6,5,11,12,15,14 + 4,5,8,7,13,14,17,16 + 5,6,9,8,14,15,18,17 + 10,11,14,13,19,20,23,22 + 11,12,15,14,20,21,24,23 + 13,14,17,16,22,23,26,25 + 14,15,18,17,23,24,27,26 + + + 28,29,31,30,32,33,35,34 + + 1,2,3,4,5,6,7,8,9 + 19,20,21,22,23,24,25,26,27 + 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35 + + + + + + + + 111 + + + lid + + + + + lid + 0 + 1 + 1 + 1 + 1 + 0 + + + lid + x + 0.1 + 0 + + + + STATIC + 5 + 0.2 + + symmetric + 25 + 1e-7 + 1e-12 + 0 + 0.9 + + 0 + + + + + + LINEAR + CONSTANT + + 0,0 + 1,1 + + + + + + + + + + + + + + + diff --git a/references/small_problems/inputs/rb_spin.feb b/references/small_problems/inputs/rb_spin.feb new file mode 100644 index 0000000..be0ef16 --- /dev/null +++ b/references/small_problems/inputs/rb_spin.feb @@ -0,0 +1,111 @@ + + + + + + + 2 + 1 + 0 + + + + + 0,0,0 + 1,-0.10000000000000001,0 + 0,1,0 + 1,0.90000000000000002,0 + 0,0,1 + 1,0.10000000000000001,1 + 0.29999999999999999,1,1 + 1.3,1.0999999999999999,1.3999999999999999 + + + 1,2,4,3,5,6,8,7 + + 1,2,3,4,5,6,7,8 + + + + + + + body + Ru + 0.4 + LOAD + 0 + + + body + Rw + 0.25 + LOAD + 0 + + + body + Ry + 0.3 + LOAD + 0 + + + + DYNAMIC + 10 + 0.1 + + symmetric + 25 + 1e-7 + 1e-12 + 0 + 0.9 + + 0 + + + + + + LINEAR + CONSTANT + + 0,0 + 1,1 + + + + + + + + + + + + + + diff --git a/references/small_problems/inputs/rb_spin_from_zero.feb b/references/small_problems/inputs/rb_spin_from_zero.feb new file mode 100644 index 0000000..42c57f2 --- /dev/null +++ b/references/small_problems/inputs/rb_spin_from_zero.feb @@ -0,0 +1,111 @@ + + + + + + + 2 + 1 + 0 + + + + + 0,0,0 + 1,-0.10000000000000001,0 + 0,1,0 + 1,0.90000000000000002,0 + 0,0,1 + 1,0.10000000000000001,1 + 0.29999999999999999,1,1 + 1.3,1.0999999999999999,1.3999999999999999 + + + 1,2,4,3,5,6,8,7 + + 1,2,3,4,5,6,7,8 + + + + + + + body + Ru + 0.4 + LOAD + 0 + + + body + Rw + 0.25 + LOAD + 0 + + + body + Ry + 0.3 + LOAD + 0 + + + + DYNAMIC + 10 + 0.1 + + non-symmetric + 25 + 1e-7 + 1e-12 + 0 + 0.9 + + 10 + + + + + + LINEAR + CONSTANT + + 0,0 + 1,1 + + + + + + + + + + + + + + diff --git a/src/febio_warp/analysis/dynamics.py b/src/febio_warp/analysis/dynamics.py index 65525c0..fcd42f4 100644 --- a/src/febio_warp/analysis/dynamics.py +++ b/src/febio_warp/analysis/dynamics.py @@ -361,6 +361,9 @@ def initial_state(system: System, linear_solver: str = "auto") -> State: for term in system.terms: if not term.internal: term.residual(state, None, F) + if system.reduction is not None: + # A load on a node of a rigid body acts on the body. + system.reduction.carry_residual(F) system.mask(F) if float(wp.utils.array_inner(F, F)) > 0.0: A = system.mass_matrix() @@ -375,6 +378,12 @@ def initial_state(system: System, linear_solver: str = "auto") -> State: a0 = wp.array(host, dtype=vec3d, device=device) state.a = a0 state.a_mass = wp.clone(a0) + for term in system.terms: + # A term with accelerations of its own takes them (the rigid + # system: the angular acceleration of a body, and the + # acceleration of the nodes that follow one). + if hasattr(term, "take_initial_accelerations"): + term.take_initial_accelerations(state) return state diff --git a/src/febio_warp/analysis/steps.py b/src/febio_warp/analysis/steps.py index 44718ed..0b6952e 100644 --- a/src/febio_warp/analysis/steps.py +++ b/src/febio_warp/analysis/steps.py @@ -44,8 +44,9 @@ from ..assembly.system import RestartRecord, SolveError, State, System from ..compiled import inspect, shell_directors, shell_thickness -from ..constraints import linear_constraint_set, node_distance, rigid, rigid_wall, slide_line +from ..constraints import linear_constraint_set, node_distance, rigid, rigid_system, rigid_wall, slide_line from ..constraints import prestrain as prestrain_constraint +from ..constraints.rigid_parts import body_nodes, rigid_unknowns from ..contact import edge_to_surface, sliding_elastic, sticky from ..contact.in_run import SMOOTH_TYPE as SMOOTH_POTENTIAL_TYPE from ..contact.in_run import TYPE as POTENTIAL_TYPE @@ -243,13 +244,111 @@ def midpoint_rows(model) -> list: return rows +def rigid_body_rows(model) -> list: + """Coverage rows for what a rigid body with unknowns + (constraints/rigid_system.py) is not built for in time: refused. + + Static and dynamic steps in one run. FEBio's rigid solver updates the + velocities and accelerations of a body in every step, static ones + included (FERigidSolverNew::UpdateRigidBodies has no test of the + analysis type), so a dynamic step that follows a static one starts with + them, and a static step after a dynamic one changes them. The nodes + have FEBio's rule for a static step after a dynamic one + (analysis/dynamics.py, `static_predictor`); the bodies do not yet. + + alpha_f below 1. FEBio assembles the residual of a rigid node with the + arm interpolated between the last state and the current one + (FEResidualVector::Assemble), and the rigid terms would take alpha_f as + the domains do. Built at alpha_f = 1 only.""" + unknowns = rigid_unknowns(model) + if not unknowns: + return [] + rows = [] + integration = [TimeIntegration.from_control(s.control) for s in model.steps] + dynamic = [ti is not None for ti in integration] + for name in unknowns: + if any(dynamic) and not all(dynamic): + rows.append( + ( + "analysis", + "DYNAMIC", + NOT_SUPPORTED, + f"rigid body {name}", + "static and dynamic steps in one run with a rigid body that has open components: the " + "velocities FEBio gives a rigid body in a static step are not built", + ) + ) + for step, ti in zip(model.steps, integration): + if ti is not None and ti.alpha_f != 1.0: + rows.append( + ( + "analysis", + "DYNAMIC", + NOT_SUPPORTED, + f"step {step.id}: rigid body {name}", + f"alpha_f {ti.alpha_f:g} with a rigid body that has open components: built for alpha_f = 1 " + "only (FEBio takes the arm of a rigid node at the interpolated configuration)", + ) + ) + return rows + + +def part_nodal_mass(model, block, fields) -> tuple: + """(entries, nodal mass) of one part of a rigid body with unknowns: the + integral of the density times each shape function + (rigid_parts.mass_properties, restricted to the part).""" + from ..constraints.rigid_parts import _quadrature + + density = float(model.material(model.domain_of(block.name).material).params.get("density", 1.0)) + _, H, w = _quadrature(block, model.mesh.nodes) + nodal = np.zeros(len(model.mesh.nodes)) + np.add.at(nodal, block.connectivity, density * np.einsum("eq,qn->en", w, H)) + nodes = np.unique(block.connectivity) + return fields.entries_of("displacement", nodes), nodal[nodes] + + def contact_support(record, model): """Coverage of one contact record, by its type.""" + known = None for module in (sliding_elastic, sticky): known = module.inspect_contact(record, model) if known is not None: - return known - return inspect_contact(record, model) + break + if known is None: + known = inspect_contact(record, model) + if known is not None and known[0] == IMPLEMENTED: + on_body = _surface_on_a_body_with_unknowns(record, model) + if on_body: + return NOT_SUPPORTED, on_body + return known + + +def _surface_on_a_body_with_unknowns(record, model) -> str: + """The reason a contact interface is refused for a rigid body with + unknowns, or "". The nodes of such a body are dependent entries + (assembly/reduction.py). The contact terms keep their stiffness in a + matrix of their own, which the system does not carry to the entries of + the body yet, so an interface with a surface on such a body would run + with a tangent that leaves the body out + (docs/design/rigid_bodies.md, section 5.2; piece K1-5).""" + unknowns = rigid_unknowns(model) + if not unknowns: + return "" + names = model.mesh.surface_pair(record.attrs.get("surface_pair")) or () + names = [*names, record.attrs.get("surface")] + bodies = body_nodes(model, list(unknowns)) + for name in names: + surface = model.mesh.surfaces.get(name) if name else None + if surface is None or not surface.facets: + continue + nodes = np.unique(np.concatenate(surface.facets)) + for body, of_body in bodies.items(): + if np.isin(nodes, of_body).any(): + return ( + f"surface {name!r} is on rigid body {body!r}, which has unknowns: the contact stiffness is " + "not carried to the body yet" + ) + return "" def constraint_support(record, model): @@ -310,12 +409,15 @@ def inspect_model(model): constraint_support=constraint_support, several_steps=True, tied_rigid_nodes=True, + rigid_body_unknowns=True, surface_conditions=True, deformation_conditions=True, three_field_support=is_three_field, step_constraints=STEP_CONSTRAINTS, ) - for row in midpoint_rows(model) + beam_alpha_rows(model) + static_after_dynamic_rows(model): + for row in ( + midpoint_rows(model) + beam_alpha_rows(model) + static_after_dynamic_rows(model) + rigid_body_rows(model) + ): report.add(*row) return report @@ -343,6 +445,10 @@ def select_domain( dom = model.domain_of(block.name) if rigid.is_geometry_rigid_part(model, block.name): return rigid.RigidGeometryPart(block.name) + if dom.material in rigid_unknowns(model): + # A part of a rigid body with unknowns: nothing of its own but the + # mass a body force acts through (constraints/rigid_system.py). + return rigid.RigidBodyPart(block.name, *part_nodal_mass(model, block, fields)) if is_beam(model, block, dom): material = model.material(dom.material) # FEElasticBeamMaterial: density 1 and everything else 0 unless given. @@ -715,6 +821,9 @@ def build_system( # body force, which acts in a static step too. domains = {} for term, block in zip(terms, model.mesh.blocks): + if isinstance(term, rigid.RigidBodyPart): + domains[block.name] = term # carries a body force to its body + continue if isinstance(term, rigid.FixedRigidPart): continue # no mass: the body is fixed, or placed by the input material = model.material(model.domain_of(block.name).material) @@ -802,7 +911,15 @@ def build_system( set_rest_lengths(terms, rest_length) for row in rest_length_rows(terms): report.add(*row) + if fields.bodies: + # Rigid bodies with unknowns: one term for all of them, which also + # owns the dependent entries (their nodes). + terms.append(rigid_system.RigidSystem(model, fields, device)) system = System(model, fields, terms, device) + if fields.bodies: + system.rigid = terms[-1] + system.rigid.system = system + system.set_reduction(system.rigid.reduction) #: What the Newton loop calls after a converged iteration (FEBio's #: augmentations): the prestrain constraints of the input. system.augmentations = augmentations diff --git a/src/febio_warp/assembly/reduction.py b/src/febio_warp/assembly/reduction.py new file mode 100644 index 0000000..893f771 --- /dev/null +++ b/src/febio_warp/assembly/reduction.py @@ -0,0 +1,278 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 The FEBio-Warp-Python Authors +# SPDX-License-Identifier: Apache-2.0 +"""Dependent entries: unknowns that follow other unknowns, eliminated after assembly. + +TEMPLATE (Handoff K, thread K1, December 2026). Structure for discussion, not +final. docs/design/rigid_bodies.md, section 5.2 (decision R1). + +FEBio counterpart + Two places where FEBio gives a degree of freedom no equation of its own + and carries what is assembled on it to other equations: + + a node of a rigid body FERigidSolver::RigidStiffnessSolid and + FEResidualVector::Assemble carry the stiffness + and the residual to the six equations of the body + a linear constraint FELinearConstraintManager::AssembleStiffness and + AssembleResidual carry them to the child + degrees of freedom + + https://github.com/febiosoftware/FEBio/blob/develop/FEBioMech/FERigidSolver.cpp + https://github.com/febiosoftware/FEBio/blob/develop/FECore/FELinearConstraintManager.cpp + +Same as FEBio + The reduced matrix and residual. With u_i = sum over masters m of + T_im u_m for a dependent entry i (to first order, for a rigid node), + and A_im the matrix that carries a residual, FEBio's reduced system is + + R_m += A_im R_i residual + K_mj += A_im K_ij a dependent row + K_in += K_ij T_jn a dependent column + K_mn += A_im K_ij T_jn both + + For a node of a rigid body at the arm z from the center of mass, with Z + the skew matrix of z (Z f = z x f), the masters are the two entries of + the body and T = [I, -Z], A = [I; Z]. FEBio takes the arm of A + interpolated with alpha_f and that of T current, so the two are kept + apart. For a linear constraint both hold the coefficient on the + components concerned and are constant. + +Different, and why + FEBio does this while it assembles each element matrix. Here the terms + assemble on the node entries as they always do, and the system carries + the blocks and the residual afterwards, in three kernels. The terms do + not change, the work is only on the blocks that touch a dependent entry, + and the matrix pattern stays fixed: the carried blocks have (row, + column) pairs that are known once the terms have placed theirs. + +What this module is, and is not + The table and the three operations. It does not know what a rigid body + or a constraint is: an owner (the rigid system; a linear constraint + term) fills the table, keeps its matrices current, and writes the values + of the dependent entries after every update of the solution. The + components of a dependent entry that stay unknowns of their own (`own`, + for a linear constraint on one component) are left to the mask of the + system as free components. + +Rules + A master is not a dependent entry (FEBio: a parent may not be a child). + The dependent components of an entry are marked DEPENDENT in the field + table, so the mask of the system takes their rows and columns out. + +Gradients + The three operations are kernels with inputs and outputs. The adjoint + does not yet spread its solution to the dependent entries, so + sensitivity/adjoint.py and forward.py refuse a system with a reduction + (docs/design/rigid_bodies.md, section 8). +""" + +from __future__ import annotations + +import numpy as np +import warp as wp + +vec3d = wp.vec3d +mat33d = wp.mat33d + + +@wp.kernel +def _carry_residual( + link_dependent: wp.array(dtype=wp.int32), + link_master: wp.array(dtype=wp.int32), + A: wp.array(dtype=mat33d), + R: wp.array(dtype=vec3d), +): + """R_m += A_im R_i for every link of a dependent entry i to a master m.""" + k = wp.tid() + wp.atomic_add(R, link_master[k], A[k] * R[link_dependent[k]]) + + +@wp.kernel +def _keep_own(dependent: wp.array(dtype=wp.int32), own: wp.array(dtype=vec3d), x: wp.array(dtype=vec3d)): + """x_i = own_i x_i: the components of a dependent entry that follow masters start from zero.""" + k = wp.tid() + x[dependent[k]] = wp.cw_mul(own[k], x[dependent[k]]) + + +@wp.kernel +def _spread( + link_dependent: wp.array(dtype=wp.int32), + link_master: wp.array(dtype=wp.int32), + T: wp.array(dtype=mat33d), + x: wp.array(dtype=vec3d), +): + """x_i += T_im x_m.""" + k = wp.tid() + wp.atomic_add(x, link_dependent[k], T[k] * x[link_master[k]]) + + +@wp.kernel +def _carry_blocks( + source: wp.array(dtype=wp.int32), + left: wp.array(dtype=wp.int32), + right: wp.array(dtype=wp.int32), + A: wp.array(dtype=mat33d), + T: wp.array(dtype=mat33d), + vals: wp.array(dtype=mat33d), + rows: wp.array(dtype=wp.int32), + cols: wp.array(dtype=wp.int32), + free: wp.array(dtype=vec3d), + out: wp.array(dtype=mat33d), +): + """One carried block: A K T of its source block, with A or T the + identity where that side is not carried, and the constrained rows and + columns of the target zeroed (as `_constrain_blocks` of the system).""" + k = wp.tid() + block = vals[source[k]] + if left[k] >= 0: + block = A[left[k]] * block + if right[k] >= 0: + block = block * T[right[k]] + out[k] = wp.diag(free[rows[k]]) * block * wp.diag(free[cols[k]]) + + +class Reduction: + """The dependent entries of a system and the three operations on them. + + Args: + n: Number of entries of the field table. + dependent: (d,) entry index of each dependent entry, each once. + own: (d, 3) 1 for the components of each that stay unknowns of + their own, 0 for those that follow masters. + link_dependent: (l,) for each link, the position of its dependent + entry in `dependent`. + link_master: (l,) the master entry of each link. + device: The Warp device. + + `T` and `A` are device arrays of one 3x3 matrix per link, zero when the + Reduction is made; the owner writes them (`set_matrices`, or a kernel of + its own on the arrays) before the operations are used and whenever they + change. + """ + + def __init__(self, n: int, dependent, own, link_dependent, link_master, device): + dependent = np.asarray(dependent, dtype=np.int32) + link_position = np.asarray(link_dependent, dtype=np.int32) + link_master = np.asarray(link_master, dtype=np.int32) + own = np.asarray(own, dtype=np.float64).reshape(len(dependent), 3) + if len(np.unique(dependent)) != len(dependent): + raise ValueError("a dependent entry is listed twice") + if np.isin(link_master, dependent).any(): + raise ValueError("a master entry is itself dependent (FEBio: a parent may not be a child)") + self.n = n + self.device = device + self.count = len(dependent) + self.links = len(link_master) + self._dependent = dependent + self._own = own + self._link_position = link_position + self._link_master = link_master + self.dependent = wp.array(dependent, dtype=wp.int32, device=device) + self.own = wp.array(own, dtype=vec3d, device=device) + self.link_dependent = wp.array(dependent[link_position], dtype=wp.int32, device=device) + self.link_master = wp.array(link_master, dtype=wp.int32, device=device) + self.T = wp.zeros(self.links, dtype=mat33d, device=device) + self.A = wp.zeros(self.links, dtype=mat33d, device=device) + # The carried blocks, laid out when the terms have placed theirs. + self.carried = 0 + self.rows = self.cols = None + self._source = self._left = self._right = None + + def set_matrices(self, T: np.ndarray, A: np.ndarray | None = None) -> None: + """Write the matrices of every link from host arrays (l, 3, 3). With + A None the residual is carried by the transpose of T, which is the + case of a constant table and of a rigid node at alpha_f = 1.""" + T = np.asarray(T, dtype=np.float64).reshape(self.links, 3, 3) + A = np.transpose(T, (0, 2, 1)) if A is None else np.asarray(A, dtype=np.float64).reshape(self.links, 3, 3) + self.T.assign(T) + self.A.assign(A) + + # -- the three operations ------------------------------------------------ + + def carry_residual(self, R: wp.array) -> None: + """R_m += A_im R_i. The values at the dependent entries are left in + place; the mask of the system takes them out.""" + wp.launch( + _carry_residual, + dim=self.links, + inputs=[self.link_dependent, self.link_master, self.A], + outputs=[R], + device=self.device, + ) + + def spread(self, x: wp.array) -> None: + """x_i = own_i x_i + sum of T_im x_m at every dependent entry: an + increment of the unknowns, as the nodes see it.""" + wp.launch(_keep_own, dim=self.count, inputs=[self.dependent, self.own], outputs=[x], device=self.device) + wp.launch( + _spread, + dim=self.links, + inputs=[self.link_dependent, self.link_master, self.T], + outputs=[x], + device=self.device, + ) + + def lay_out(self, rows: np.ndarray, cols: np.ndarray) -> None: + """Find the carried blocks of a block list: for each block (i, j) + with a dependent row or column, the blocks (m, j), (i, n) and (m, n) + of the masters. Called once, by the system, when the terms have + written their (row, column) pairs. + + A target whose row or column entry is dependent in all three + components would be zeroed by the mask, and is left out. + """ + rows = np.asarray(rows, dtype=np.int32) + cols = np.asarray(cols, dtype=np.int32) + # Links per entry, as a start and a count (the links sorted by entry). + order = np.argsort(self._link_position, kind="stable") + per_dependent = np.bincount(self._link_position, minlength=self.count) + first = np.concatenate([[0], np.cumsum(per_dependent)[:-1]]) + count = np.zeros(self.n, dtype=np.int64) + start = np.zeros(self.n, dtype=np.int64) + count[self._dependent] = per_dependent + start[self._dependent] = first + follows_fully = np.zeros(self.n, dtype=bool) + follows_fully[self._dependent] = ~self._own.any(axis=1) + + def expand(blocks, entries): + """Each block once per link of its entry: (block, link).""" + c = count[entries] + repeated = np.repeat(np.arange(len(blocks)), c) + within = np.arange(c.sum()) - np.repeat(np.cumsum(c) - c, c) + return repeated, order[start[entries][repeated] + within] + + none = np.zeros(0, dtype=np.int64) + row_side = np.flatnonzero((count[rows] > 0) & ~follows_fully[cols]) + k, link = expand(row_side, rows[row_side]) + source, left, right = [row_side[k]], [link], [np.full(len(k), -1)] + col_side = np.flatnonzero((count[cols] > 0) & ~follows_fully[rows]) + k, link = expand(col_side, cols[col_side]) + source.append(col_side[k]) + left.append(np.full(len(k), -1)) + right.append(link) + both = np.flatnonzero((count[rows] > 0) & (count[cols] > 0)) + k, link_left = expand(both, rows[both]) + k2, link_right = expand(both[k], cols[both[k]]) if len(k) else (none, none) + source.append(both[k][k2]) + left.append(link_left[k2]) + right.append(link_right) + source, left, right = (np.concatenate(x).astype(np.int32) for x in (source, left, right)) + self.carried = len(source) + target_rows = np.where(left >= 0, self._link_master[np.maximum(left, 0)], rows[source]) + target_cols = np.where(right >= 0, self._link_master[np.maximum(right, 0)], cols[source]) + as_array = lambda x: wp.array(x.astype(np.int32), dtype=wp.int32, device=self.device) + self.rows, self.cols = as_array(target_rows), as_array(target_cols) + self._source, self._left, self._right = as_array(source), as_array(left), as_array(right) + + def carry_blocks(self, vals: wp.array, free: wp.array, out: wp.array) -> None: + """The values of the carried blocks, from the blocks the terms have + written (`vals`), with the constrained rows and columns of each + zeroed (`free`), into `out` (one block per carried block).""" + if self.carried == 0: + return + wp.launch( + _carry_blocks, + dim=self.carried, + inputs=[self._source, self._left, self._right, self.A, self.T, vals, self.rows, self.cols, free], + outputs=[out], + device=self.device, + ) diff --git a/src/febio_warp/assembly/system.py b/src/febio_warp/assembly/system.py index 13c068e..50cceda 100644 --- a/src/febio_warp/assembly/system.py +++ b/src/febio_warp/assembly/system.py @@ -423,6 +423,12 @@ def _mask_vector(x: wp.array(dtype=vec3d), free: wp.array(dtype=vec3d)): x[i] = wp.cw_mul(x[i], free[i]) +@wp.kernel +def _add_vectors(x: wp.array(dtype=vec3d), y: wp.array(dtype=vec3d)): + i = wp.tid() + y[i] = y[i] + x[i] + + @wp.kernel def _constrain_blocks( rows: wp.array(dtype=wp.int32), @@ -657,6 +663,23 @@ def __init__(self, model, fields: FieldTable, terms: list, device): # Per analysis step: its TimeIntegration, or None for a static step. # None for a model whose steps are all static. self.step_time_integration = None + # Dependent entries (assembly/reduction.py): None for a system + # without any. Set by `set_reduction` before the first assembly. + self.reduction = None + self._rows_all = self._cols_all = None # the block list with the carried blocks + + def set_reduction(self, reduction) -> None: + """Give the system its dependent entries: unknowns that follow other + unknowns (the nodes of a rigid body, the parent of a linear + constraint), whose residual and blocks are carried to their masters + after the terms have assembled (assembly/reduction.py). The owner of + the table marks the dependent components DEPENDENT in the field + table, keeps the matrices of the table current and writes the values + of the dependent entries. Before the first assembly only: the + pattern of the matrix includes the carried blocks.""" + if self._map is not None: + raise RuntimeError("set_reduction: the matrix pattern is already built") + self.reduction = reduction @property def has_damping(self) -> bool: @@ -825,6 +848,10 @@ def residual(self, state: State, requires_grad: bool = False) -> wp.array: self._dynamic_residual(state, R) elif self.time_integration is None and state.v_material is not None and self.damping_loads: self._static_damping_residual(state, R) + if self.reduction is not None: + # What the terms assembled on a dependent entry goes to its + # masters (FEResidualVector::Assemble for a rigid node). + self.reduction.carry_residual(R) return R def _static_damping_residual(self, state: State, R: wp.array) -> None: @@ -994,6 +1021,21 @@ def constrained_matrix(self, with_contact: bool = True): """The matrix the linear solve uses, from the last `tangent`. The sparsity is analysed at the first call; later calls refill values.""" total = self.block_count + rows, cols = self.rows, self.cols + if self.reduction is not None: + # The carried blocks follow the blocks of the terms and the + # diagonal in one longer list, with (row, column) pairs that are + # fixed once the terms have placed theirs. + if self._rows_all is None: + self.reduction.lay_out(self.rows.numpy()[:total], self.cols.numpy()[:total]) + extra = self.reduction.carried + host = lambda own, carried: np.concatenate([own.numpy(), carried.numpy()]) if extra else own.numpy() + self._rows_all = wp.array(host(self.rows, self.reduction.rows), dtype=wp.int32, device=self.device) + self._cols_all = wp.array(host(self.cols, self.reduction.cols), dtype=wp.int32, device=self.device) + self.constrained_vals = wp.zeros(total + self.n + extra, dtype=mat33d, device=self.device) + rows, cols = self._rows_all, self._cols_all + if self.reduction.carried: + self.reduction.carry_blocks(self.vals, self.free, self.constrained_vals[total + self.n :]) wp.launch( _constrain_blocks, dim=total + self.n, @@ -1004,8 +1046,8 @@ def constrained_matrix(self, with_contact: bool = True): if self._map is None: self._map = warp.sparse.bsr_set_from_triplets( self._A, - self.rows, - self.cols, + rows, + cols, self.constrained_vals, prune_numerical_zeros=False, build_mapping=True, @@ -1052,18 +1094,29 @@ def apply_tangent(self, x: wp.array, y: wp.array, alpha: float = 1.0) -> None: """y += alpha K x with the unconstrained K of the last `tangent`: the block buffer, and the terms that offer `apply_own_tangent`.""" total = self.block_count + target = y + if self.reduction is not None: + # With dependent entries the product is that of the reduced + # matrix: the vector is spread to the dependent entries, K is + # applied, and the result is carried back to the masters. + x = wp.clone(x) + self.reduction.spread(x) + target = wp.zeros_like(y) wp.launch( _apply_blocks, dim=total, inputs=[self.rows, self.cols, self.vals, x, alpha], - outputs=[y], + outputs=[target], device=self.device, ) # A term whose blocks are in a matrix of its own may add its product # itself (sticky contact: an attached node that the input moves). for term in self.terms: if hasattr(term, "apply_own_tangent"): - term.apply_own_tangent(x, y, alpha) + term.apply_own_tangent(x, target, alpha) + if self.reduction is not None: + self.reduction.carry_residual(target) + wp.launch(_add_vectors, dim=self.n, inputs=[target], outputs=[y], device=self.device) def matrix(self): """The unconstrained K of the last `tangent` as a matrix of its own. diff --git a/src/febio_warp/compiled.py b/src/febio_warp/compiled.py index 73a4a29..108d243 100644 --- a/src/febio_warp/compiled.py +++ b/src/febio_warp/compiled.py @@ -43,6 +43,7 @@ rigid_materials, rigid_motions, rigid_part_nodes, + rigid_unknowns, rotations_returned_to_zero, ) from .coverage import ( @@ -85,14 +86,26 @@ ACTIVATED_AT_TIME_ZERO_ONLY = ("sliding-elastic",) -def _rigid_support(record, model, moved: dict, fixed: set) -> tuple: +def _open_components(unknown, model) -> str: + """The open components of a body with unknowns, step by step, in words.""" + names = ("x", "y", "z", "Ru", "Rv", "Rw") + parts = [] + for s, plan in enumerate(unknown.steps): + open_ = [names[c] for c, how in enumerate(plan) if how is None] + parts.append(f"step {model.steps[s].id}: {', '.join(open_) if open_ else 'none'}") + return "; ".join(parts) + + +def _rigid_support(record, model, moved: dict, fixed: set, unknowns: dict | None = None) -> tuple: """(status, note) of one entry of a Rigid section: read when every body - it names is kept as geometry (constraints/rigid_parts.py).""" + it names is kept as geometry, or has unknowns that the run path solves + for (`unknowns`; constraints/rigid_parts.py).""" by_id = {str(m.id): m.name for m in model.materials} + unknowns = unknowns or {} def body(tag): rb = str(record.get(tag)) - return rb if rb in moved else by_id.get(rb.split(".", maxsplit=1)[0]) + return rb if rb in moved or rb in unknowns else by_id.get(rb.split(".", maxsplit=1)[0]) if record.tag == "rigid_bc" and record.type in (RIGID_FIXED, RIGID_DISPLACEMENT, RIGID_ROTATION): name = body("rb") @@ -100,6 +113,15 @@ def body(tag): return IMPLEMENTED, "the body is fixed in all six components" if name in moved: return IMPLEMENTED, "the body is moved by the input: no unknowns" + if name in unknowns: + return IMPLEMENTED, "the body has unknowns; open components, " + _open_components(unknowns[name], model) + return NOT_SUPPORTED, "" + if record.tag == "rigid_load" and record.type in ("rigid_force", "rigid_moment"): + name = body("rb") + if name in unknowns and any(load.name == (record.name or "") for load in unknowns[name].loads): + return IMPLEMENTED, "load_type LOAD: the value times its load curve on one component of the body" + if name in moved: + return IMPLEMENTED, "no effect: the body has no open component" return NOT_SUPPORTED, "" if record.tag == "rigid_connector" and record.type == RIGID_REVOLUTE: if body("body_a") in moved and body("body_b") in moved: @@ -121,6 +143,7 @@ def inspect( constraint_support=None, several_steps: bool = False, tied_rigid_nodes: bool = False, + rigid_body_unknowns: bool = False, surface_conditions: bool = False, deformation_conditions: bool = False, three_field_support=None, @@ -154,6 +177,9 @@ def inspect( `prescribed deformation` (constraints/prescribed_deformation.py). three_field_support: optional function (model, block, domain) -> bool, True for a part the run path runs as FEBio's three-field solid. + rigid_body_unknowns: True if the run path solves for the open components + of a rigid body (constraints/rigid_system.py), in static steps. + tied_rigid_nodes: True if the run path reads the boundary condition "rigid", which ties a node set to a rigid body that is fixed or moved by the input. @@ -201,6 +227,7 @@ def inspect( # Domains, elements and materials. fixed_rigid = fixed_rigid_materials(model) rigid_moved, rigid_problems = rigid_motions(model) + unknown_bodies = rigid_unknowns(model) if rigid_body_unknowns else {} for block in model.mesh.blocks: try: dom = model.domain_of(block.name) @@ -220,26 +247,32 @@ def inspect( # (constraints/rigid_parts.py). fixed = dom.material in fixed_rigid moved = dom.material in rigid_moved and not fixed + unknown = dom.material in unknown_bodies rep.add( "domain", f"rigid, {block.febio_type}", - IMPLEMENTED if fixed or moved else NOT_SUPPORTED, + IMPLEMENTED if fixed or moved or unknown else NOT_SUPPORTED, where, "fixed rigid body: geometry only, nodes fixed" if fixed else "rigid body moved by the input: geometry only, nodes prescribed" if moved + else "rigid body with unknowns: its nodes follow it; open components, " + + _open_components(unknown_bodies[dom.material], model) + if unknown else "a rigid body that can move: " + rigid_problems.get(dom.material, ""), ) rep.add( "material", "rigid body", - IMPLEMENTED if fixed or moved else NOT_SUPPORTED, + IMPLEMENTED if fixed or moved or unknown else NOT_SUPPORTED, f"material {dom.material}", "its parameters have no effect on a fixed body" if fixed else "only center_of_mass is used: the body has no unknowns, so no mass" if moved + else "density, and center_of_mass or the center of mass of its parts" + if unknown else "", ) continue @@ -470,7 +503,7 @@ def inspect( for r in step.other: if r.tag == "Rigid": for c in r.children: - status, note = _rigid_support(c, model, rigid_moved, fixed_rigid) + status, note = _rigid_support(c, model, rigid_moved, fixed_rigid, unknown_bodies) rep.add("Rigid", c.type or c.tag, status, f"step {step.id}: {c.name or ''}", note) continue if r.tag == "Constraints" and step_constraints: @@ -497,7 +530,7 @@ def inspect( "from the value the body had, as in FEBio. To keep them, prescribe all three rotation components " "with relative 1 (zero for those to keep)", ) - tied = rigid_moved if tied_rigid_nodes else None + tied = {**rigid_moved, **unknown_bodies} if tied_rigid_nodes else None for r in model.boundary: _inspect_bc( r, @@ -535,7 +568,7 @@ def inspect( continue if r.tag == "Rigid": for c in r.children: - status, note = _rigid_support(c, model, rigid_moved, fixed_rigid) + status, note = _rigid_support(c, model, rigid_moved, fixed_rigid, unknown_bodies) rep.add("Rigid", c.type or c.tag, status, c.name or "", note) continue if r.children: @@ -769,6 +802,8 @@ def _tied_support(r, model, tied, in_step) -> tuple: continue if shell and nodes & set(np.unique(b.connectivity).tolist()): return NOT_SUPPORTED, f"nodes of shell part {b.name!r} (their shell displacements are clamped in FEBio)" + if not hasattr(tied[body], "moves"): + return IMPLEMENTED, f"{len(nodes)} nodes follow rigid body {body!r}, which has unknowns" how = "moved by the input" if tied[body].moves else "fixed" return IMPLEMENTED, f"{len(nodes)} nodes follow rigid body {body!r}, which is {how}" diff --git a/src/febio_warp/constraints/rigid.py b/src/febio_warp/constraints/rigid.py index 1fa154e..dccfb88 100644 --- a/src/febio_warp/constraints/rigid.py +++ b/src/febio_warp/constraints/rigid.py @@ -51,3 +51,29 @@ def mass_coefficients(self) -> np.ndarray: # The name this term had when only fixed bodies were read. FixedRigidPart = RigidGeometryPart + + +class RigidBodyPart(RigidGeometryPart): + """A part of a rigid body with unknowns (constraints/rigid_system.py). + + Like a part kept as geometry it has no stiffness, no internal force and + no element mass (FERigidSolidDomain): the mass and the inertia of the + body are those of the rigid system. It does carry a body force, as + FERigidSolidDomain::BodyForce does: minus the density times the force + per unit mass, integrated with the shape functions, on its nodes, from + where the system carries it to the body. `lumped_mass` gives those + integrals to loads/body_force.py. + + Args: + name: The part. + entries: (n,) displacement entries of the nodes of the part. + nodal_mass: (n,) the integral of the density times the shape + function of each node. + """ + + def __init__(self, name: str, entries: np.ndarray, nodal_mass: np.ndarray): + super().__init__(name) + self._entries, self._nodal_mass = entries, nodal_mass + + def lumped_mass(self) -> tuple: + return self._entries, self._nodal_mass diff --git a/src/febio_warp/constraints/rigid_parts.py b/src/febio_warp/constraints/rigid_parts.py index 093b9db..c48f87f 100644 --- a/src/febio_warp/constraints/rigid_parts.py +++ b/src/febio_warp/constraints/rigid_parts.py @@ -89,11 +89,18 @@ section 7: 4.4e-5 rad apart in the first time step, 4.2e-7 from the third on). +A body with unknowns (December 2026) + A body with a component that no condition holds in some step is not + geometry: it is listed by `rigid_unknowns`, with the same replay of + activation, and solved for by constraints/rigid_system.py + (docs/design/rigid_bodies.md). `rigid_motions` still names it among the + bodies that are not geometry. `rigid_force` and `rigid_moment` with + load_type LOAD are read for it. + Reserved, not implemented - A rigid body with an unknown component, rigid loads, initial - conditions, other connectors (decision W1 (b), B1 of - docs/design/constraints.md), a moving rigid shell part, and dropping the - nodes of a rigid body from the field table. + Initial conditions, the other load types, connectors under load + (decision W1 (b)), a moving rigid shell part, and dropping the nodes of + a rigid body from the field table. """ from __future__ import annotations @@ -107,6 +114,11 @@ DISPLACEMENT = "rigid_displacement" ROTATION = "rigid_rotation" REVOLUTE = "rigid revolute joint" +FORCE = "rigid_force" +MOMENT = "rigid_moment" +# The `dof` of a rigid load -> index among the six components +# (FERigidBodyForce: "Rx", "Ry", "Rz"; FERigidBodyMoment: "Ru", "Rv", "Rw"). +_LOAD_DOF = {FORCE: {"Rx": 0, "Ry": 1, "Rz": 2}, MOMENT: {"Ru": 3, "Rv": 4, "Rw": 5}} TIED = "rigid" # the boundary condition that ties a node set to a body _COMPONENTS = ("Rx_dof", "Ry_dof", "Rz_dof", "Ru_dof", "Rv_dof", "Rw_dof") # The `dof` of a prescribed rigid condition -> index among the six components. @@ -235,6 +247,67 @@ class _Component: origin: np.ndarray = field(default_factory=lambda: np.zeros(3)) # joint: its origin +@dataclass +class RigidLoad: + """One `rigid_force` or `rigid_moment` with `load_type` LOAD: the value + times its load curve on one component of a body (FERigidBodyForce, + FERigidBodyMoment).""" + + material: str + component: int # 0 to 5: x, y, z, Ru, Rv, Rw + value: float + load_controller: int | None + name: str = "" + # Indices of the analysis steps in which the load acts; None for every + # step (a load of the model). + steps: tuple | None = None + + +@dataclass +class RigidUnknown: + """A rigid body with a component the input leaves open in some step: a + body with unknowns (docs/design/rigid_bodies.md). + + `steps[s][c]` says how component c (x, y, z, Ru, Rv, Rw) is set while + analysis step s runs, as for a RigidMotion, with None for an open + component, which is an unknown. + """ + + material: str + center: np.ndarray # (3,) the center of mass in the reference configuration + steps: list + ends: list + loads: list = field(default_factory=list) # RigidLoad + # FERigidBody::m_mass and m_moi: the mass, and the inertia about `center` + # in the reference orientation (`mass_properties`). + mass: float = 0.0 + inertia: np.ndarray = field(default_factory=lambda: np.zeros((3, 3))) + + def rotations_known(self, step: int) -> bool: + """True if a rotation component is prescribed in the step: then all + three are known, and the rotation is that of the prescribed values + (FEBio's m_bpofr; a mix with open components is refused).""" + return any(how is not None and how.kind == "prescribed" for how in self.steps[step][3:]) + + +def _read_load(model, r) -> tuple: + """(RigidLoad, None) for a rigid load that is read, (None, body, reason) + for one of a kind that is not built, (None, None, None) for one whose + entries are not read at all.""" + name = _body_name(model, r.get("rb")) + value = r.child("value") + c = _LOAD_DOF[r.type].get(str(r.get("dof"))) + if name is None or c is None or value is None or not isinstance(value.value, (int, float)): + return None, None, None + kind = str(r.get("load_type", "LOAD")).upper() + if kind not in ("LOAD", "0"): + return None, name, f"{r.type} {r.name or ''}: load_type {kind} is not built" + if int(float(r.get("relative", 0))) != 0: + return None, name, f"{r.type} {r.name or ''}: relative is not built" + lc = value.attrs.get("lc") + return RigidLoad(name, c, float(value.value), int(lc) if lc else None, r.name or ""), None, None + + @dataclass class RigidMotion: """The motion of one rigid body that the input sets completely. @@ -334,6 +407,81 @@ def volume_centroid(model, material: str) -> np.ndarray: return moment / volume +def _quadrature(block, X: np.ndarray): + """(positions (e, q, 3), shape functions (q, n), weights (e, q)) of the + integration points of a tet4 or hex8 part in the reference + configuration, by the rules FEBio gives these elements by default: + one point for a tet4 (FE_TET4G1), 2 x 2 x 2 for a hex8 (FE_HEX8G8).""" + x = X[block.connectivity] + if block.febio_type == "tet4": + H = np.full((1, 4), 0.25) + volume = np.einsum("ei,ei->e", x[:, 1] - x[:, 0], np.cross(x[:, 2] - x[:, 0], x[:, 3] - x[:, 0])) / 6.0 + return x.mean(axis=1)[:, None, :], H, volume[:, None] + if block.febio_type == "hex8": + g = 1.0 / np.sqrt(3.0) + signs = np.array( + [[-1, -1, -1], [1, -1, -1], [1, 1, -1], [-1, 1, -1], [-1, -1, 1], [1, -1, 1], [1, 1, 1], [-1, 1, 1]], + dtype=np.float64, + ) + H, weights = [], [] + for point in signs * g: + H.append(0.125 * np.prod(1.0 + signs * point, axis=1)) + dN = 0.125 * np.stack( + [signs[:, a] * np.prod(np.delete(1.0 + signs * point, a, axis=1), axis=1) for a in range(3)], axis=1 + ) + weights.append(np.linalg.det(np.einsum("na,eni->eia", dN, x))) + H = np.array(H) + return np.einsum("qn,eni->eqi", H, x), H, np.stack(weights, axis=1) + raise RigidMotionError(f"the mass of a rigid {block.febio_type} part is not computed here") + + +def mass_properties(model, material: str, center: np.ndarray | None = None) -> tuple: + """Mass, center of mass and inertia of a rigid body, and the mass each + node of its parts carries. + + FEBio counterpart: FERigidBody::UpdateMass, UpdateCOM and UpdateMOI with + FERigidSolidDomain::CalculateMass, CalculateCOM and CalculateMOI. The + density is integrated over the parts in the reference configuration; + the inertia about the origin is the integral of + density ((x . x) I - x x^T), with x interpolated to the integration + point, and is moved to the center by the parallel axis theorem, + m_moi = moi - m ((c . c) I - c c^T). FEBio uses the center of the body + there, which is the `center_of_mass` of the material where the input + gives one, whether or not that is the true center of mass. + + Args: + model: The Model. + material: Name of the rigid material. + center: The center to use, or None for the center of mass. + + Returns: + (mass, center, inertia (3, 3), nodes, nodal mass): the last two are + the nodes of the parts and the integral of density times the shape + function of each, which is how a body force acts on the body + (FERigidSolidDomain::BodyForce). + """ + density = float(model.material(material).params.get("density", 1.0)) + mass, moment, about_origin = 0.0, np.zeros(3), np.zeros((3, 3)) + nodal = np.zeros(len(model.mesh.nodes)) + for b in model.mesh.blocks: + if _block_material(model, b) != material: + continue + x, H, w = _quadrature(b, model.mesh.nodes) + w = density * w + mass += w.sum() + moment += np.einsum("eq,eqi->i", w, x) + about_origin += np.einsum("eq,eq->", w, np.einsum("eqi,eqi->eq", x, x)) * np.eye(3) - np.einsum( + "eq,eqi,eqj->ij", w, x, x + ) + np.add.at(nodal, b.connectivity, np.einsum("eq,qn->en", w, H)) + if mass <= 0.0: + raise RigidMotionError(f"rigid body {material!r} has no mass") + c = moment / mass if center is None else np.asarray(center, dtype=np.float64) + inertia = about_origin - mass * ((c @ c) * np.eye(3) - np.outer(c, c)) + nodes = np.flatnonzero(nodal != 0.0).astype(np.int32) + return mass, c, 0.5 * (inertia + inertia.T), nodes, nodal[nodes] + + def _axis_index(axis) -> int | None: """0, 1 or 2 if `axis` is along a coordinate axis in the positive sense.""" a = np.asarray(axis, dtype=np.float64).ravel() @@ -351,13 +499,30 @@ def rigid_motions(model) -> tuple: (motions, problems): `motions` maps the material name of every rigid body whose six components are set in every step to its RigidMotion (a body fixed throughout included, with `moves` False); `problems` - maps the name of every other rigid body to the reason. + maps the name of every other rigid body to the reason. A body with + an open component is among the problems here, since it is not + geometry; `rigid_unknowns` has those of them that can be given + unknowns. """ + return _reading(model)[:2] + + +def rigid_unknowns(model) -> dict: + """Material name -> RigidUnknown, for every rigid body with a component + the input leaves open in some step that the rigid system can solve for + (constraints/rigid_system.py). A body that is refused for another reason + is not here, and `rigid_motions` has the reason.""" + return _reading(model)[2] + + +def _reading(model) -> tuple: + """(motions, problems, unknowns): see `rigid_motions` and `rigid_unknowns`.""" from ..model.activity import step_spans names = rigid_materials(model) if not names: - return {}, {} + return {}, {}, {} + loads = {name: [] for name in names} ends = [span.end for span in step_spans(model)] plans = {name: [[None] * 6 for _ in ends] for name in names} joints = [[] for _ in ends] @@ -414,6 +579,18 @@ def read(records) -> list: how = _Component("joint", float(rotation.value), int(lc) if lc else None, False, b, r.name or "") how.origin = np.asarray(r.get("joint_origin"), dtype=np.float64).ravel() items.append(("joint", a, 3 + axis, how)) + elif r.tag == "rigid_load" and r.type in _LOAD_DOF: + # A load on a component with no equation does nothing in + # FEBio, so a load that is read is no problem for a body + # kept as geometry either. + load, body, reason = _read_load(model, r) + if load is not None: + items.append(("load", load.material, load)) + elif body is not None: + problem(body, reason) + else: + for name in names: + problem(name, f"Rigid entry <{r.tag}> is not read") else: for name in names: problem(name, f"Rigid entry <{r.tag}> is not read") @@ -461,12 +638,19 @@ def deactivate(items, step_id): top = read(rigid_records(model)) activate(top, 0) + for kind, name, *rest in top: + if kind == "load": + loads[name].append(rest[0]) for s in range(len(ends)): own = read([c for r in model.steps[s].other if r.tag == "Rigid" for c in r.children]) activate(own, s) + for kind, name, *rest in own: + if kind == "load": + rest[0].steps = (s,) + loads[name].append(rest[0]) for name in names: plans[name][s] = list(state[name]) - joints[s] = [(name, c, how) for kind, name, c, how in top + own if kind == "joint"] + joints[s] = [(item[1], item[2], item[3]) for item in top + own if item[0] == "joint"] deactivate(own, model.steps[s].id) for name in names: for c in range(6): @@ -497,12 +681,19 @@ def deactivate(items, step_id): ) motions: dict = {} + unknowns: dict = {} for name in names: if name in problems: continue plan = plans[name] open_ = [(s, c) for s in range(len(ends)) for c in range(6) if plan[s][c] is None] if open_: + unknown, reason = _unknown(model, name, plan, ends, loads[name]) + if unknown is not None: + unknowns[name] = unknown + elif reason: + problems[name] = reason + continue s, c = open_[0] why = opened_before[name][s][c] problems[name] = ( @@ -559,7 +750,39 @@ def deactivate(items, step_id): problems[name] = reason del motions[name] changed = True - return motions, problems + return motions, problems, unknowns + + +def _unknown(model, name: str, plan: list, ends: list, loads: list) -> tuple: + """(RigidUnknown, None) for a body with open components that the rigid + system can solve for, or (None, reason). An empty reason leaves the + message of `rigid_motions` (the body is not geometry) as it is.""" + for s, step in enumerate(plan): + if any(how is not None and how.kind == "joint" for how in step): + return None, "a joint with a prescribed rotation on a body with open components is not built" + rotations = step[3:] + if any(how is not None and how.kind == "prescribed" for how in rotations) and any( + how is None for how in rotations + ): + return None, ( + f"step {model.steps[s].id}: a rotation component is prescribed and another is open; FEBio stops " + 'with "Rigid body rotations cannot mix prescribed and free components"' + ) + shells = [ + b.name + for b in model.mesh.blocks + if _block_material(model, b) == name and model.domain_of(b.name).kind == "ShellDomain" + ] + if shells: + return None, f"a rigid shell part with open components ({shells[0]}) is not read" + declared = model.material(name).value("center_of_mass") + try: + mass, center, inertia, _, _ = mass_properties( + model, name, None if declared is None else np.asarray(declared, dtype=np.float64).ravel() + ) + except RigidMotionError as err: + return None, str(err) + return RigidUnknown(name, center, plan, ends, loads, mass, inertia), None def geometry_rigid_materials(model) -> set: diff --git a/src/febio_warp/constraints/rigid_system.py b/src/febio_warp/constraints/rigid_system.py new file mode 100644 index 0000000..d26d075 --- /dev/null +++ b/src/febio_warp/constraints/rigid_system.py @@ -0,0 +1,563 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 The FEBio-Warp-Python Authors +# SPDX-License-Identifier: Apache-2.0 +"""Rigid bodies with unknowns: the update of the bodies, their nodes and their loads. + +TEMPLATE (Handoff K, thread K1, December 2026). Structure for discussion, not +final. docs/design/rigid_bodies.md, sections 4 and 5. + +FEBio counterpart + FERigidBody, FERigidSystem and FERigidSolverNew: a rigid body has up to + six equations, its nodes have none and follow it, and what is assembled + on its nodes is carried to its equations. + https://github.com/febiosoftware/FEBio/blob/develop/FEBioMech/FERigidSolver.cpp + https://github.com/febiosoftware/FEBio/blob/develop/FEBioMech/FERigidBody.cpp + https://github.com/febiosoftware/FEBio/blob/develop/FEBioMech/FERigidForce.cpp + +Same as FEBio (source at e4df3f8) + unknowns two entries per body in the field table, after those of the + nodes: the translation of the center of mass, and the + rotation vector (discretization/fields.py, RigidBodyEntries) + update FERigidSolverNew::UpdateIncrements and UpdateRigidBodies. + The translation adds. The rotation increments of a time step + are composed as rotations through the Cayley transform: with + q(v) the rotation of angle 2 atan(|v| / 2) about v, the + total increment Ui of the time step becomes the Cayley + vector of q(ui) q(Ui), on the components with an equation, + and the orientation is Q = q(ui) q(Ui) Q_p, with Q_p that of + the last converged state. This is done at every trial of the + line search, from the accepted Ui and the trial ui + rotations in a step that prescribes a rotation component, all three + all known are known (FEBio's m_bpofr; a mix with open ones is an error + there and refused in the reading) and Q is the rotation of + the vector of the prescribed values, with zero for a fixed + component, whatever the rotation was before (question 14 of + docs/design/open_questions.md) + the entry `rigid rotation` holds the rotation vector of Q + (FERigidBody::m_Ut[3..5], from quatd::GetRotationVector: the + angle is in [0, 2 pi]), or the prescribed values where all + three are known + nodes x = r + Q (X - r0) for every node of a body, with r0 the + center of mass in the reference configuration and r its + current position (FERigidSystem::UpdateMesh); the nodal + displacement is x - X + elimination the stiffness and the residual of the nodes go to the body + through the arm z = x - r: column matrices [I, -Z], row + matrices [I; Z] with Z f = z x f + (FERigidSolver::RigidStiffnessSolid, FEResidualVector:: + Assemble), at alpha_f = 1. FEBio's tangent leaves out the + change of the arm with the rotation, and so does this one + loads `rigid_force` and `rigid_moment` with load_type LOAD: the + value times its load curve on the equation of one component + (FERigidBodyForce::LoadVector, FERigidBodyMoment::LoadVector) + rigid parts no stiffness, no internal force and no element mass + (FERigidSolidDomain); the part is in the term list as + geometry (constraints/rigid.py), and carries a body force to + the body through its nodes (FERigidSolidDomain::BodyForce) + dynamics FERigidSolverNew::InertialForces, UpdateRigidBodies and + FERigidSolver::RigidMassMatrix. Translation: Newmark on the + center of mass, the inertial force -m (alpha_m a + + (1 - alpha_m) a_p) and the mass m alpha_m / (beta dt^2). + Rotation: with q = Q Q_p^-1 the rotation of the time step + and vq its Cayley vector, + w = q [gamma / (beta dt) vq - w_p + + (2 - gamma / beta) (w_p + al_p dt / 2)] + al = q [vq / (beta dt^2) - w_p / (beta dt) + + (1 - 1 / (2 beta)) al_p] + the angular momentum h = J w with J = R J0 R^T, its rate + dh = w x h + J al, the inertial moment + -(alpha_m dh + (1 - alpha_m) dh_p), and the mass block + alpha_m ([(gamma W + I / dt) J - gamma H] / (beta dt) T + - DH) + with W, H, DH the skew matrices of w, h, dh and + T = I + skew(vq) / 2 + vq vq^T / 4. Not symmetric. + FEBio forms the stiffness of a time step before its first + residual (FENewtonSolver::QNInit), when h and dh are still + those of the last state: followed, since the iterations + depend on it. And where the input asks for a symmetric + stiffness (`symmetric_stiffness`, the default), FEBio keeps + the upper triangle of this block and the solve sees it + mirrored: followed in Newton's tangent, for the same reason + initial FESolidSolver2::InitAccelerations: the bodies are in the + accelerations mass matrix, with m on the translations and, on the + rotations, the block above at rest, J / (beta dt^2) with dt + the first step size (FEBio sets 1 / (beta dt^2) to 1 for the + translations only). The nodes of a body take the + acceleration of its center of mass + +Different, and why + The bodies are few, so their kinematics are computed on the host, in + NumPy, from the handful of numbers of their entries; the nodes, which + are many, are placed and their arms formed by kernels on the device. + +Reserved, not implemented + Initial conditions (`initial_rigid_velocity`, + `initial_rigid_angular_velocity`), the velocities FEBio gives a body in + a static step (a dynamic step after a static one is refused for such a + body), the load types FOLLOW and TARGET and `relative` loads, + connectors, clamped shell nodes, a parent body, the interpolation of the + row arm with alpha_f below 1, and the body state in the State (it is + held by this term and committed with the time step, as the beam domain + holds its rotations). + +Gradients + None: `adjoint_ready` is False, and a system with dependent entries is + refused by the adjoint (docs/design/rigid_bodies.md, section 8). +""" + +from __future__ import annotations + +from typing import Any + +import numpy as np +import warp as wp + +from ..assembly.reduction import Reduction +from ..assembly.system import BlockTangent, State, Term +from ..discretization.fields import FIXED +from ..materials.status import OK + +vec3d = wp.vec3d +mat33d = wp.mat33d + +# -- quaternions as FEBio's quatd has them: (x, y, z, w), unit --------------- + +IDENTITY = np.array([0.0, 0.0, 0.0, 1.0]) + + +def quat_of_angle(angle: float, v: np.ndarray) -> np.ndarray: + """quatd(angle, v): the rotation by `angle` about the direction of v + (the identity for a zero vector).""" + length = float(np.linalg.norm(v)) + if length == 0.0: + return IDENTITY.copy() + return np.array([*(np.sin(0.5 * angle) * np.asarray(v) / length), np.cos(0.5 * angle)]) + + +def quat_of_vector(v: np.ndarray) -> np.ndarray: + """quatd(vec3d): the rotation of the rotation vector v (axis times angle).""" + return quat_of_angle(float(np.linalg.norm(v)), v) + + +def quat_of_cayley(v: np.ndarray) -> np.ndarray: + """The rotation of angle 2 atan(|v| / 2) about v: FEBio's Cayley + transform of a rotation increment (FERigidSolverNew).""" + return quat_of_angle(2.0 * np.arctan(0.5 * float(np.linalg.norm(v))), v) + + +def quat_multiply(a: np.ndarray, b: np.ndarray) -> np.ndarray: + """a b: the rotation b followed by the rotation a. Normalized + (quatd::MakeUnit).""" + av, bv = a[:3], b[:3] + q = np.array([*(a[3] * bv + b[3] * av + np.cross(av, bv)), a[3] * b[3] - av @ bv]) + return q / np.linalg.norm(q) + + +def quat_angle(q: np.ndarray) -> float: + """quatd::GetAngle: 2 atan2(|(x, y, z)|, w), in [0, 2 pi].""" + return 2.0 * float(np.arctan2(np.linalg.norm(q[:3]), q[3])) + + +def quat_axis(q: np.ndarray) -> np.ndarray: + """quatd::GetVector: the unit vector along (x, y, z), or zero.""" + length = float(np.linalg.norm(q[:3])) + return q[:3] / length if length > 0.0 else np.zeros(3) + + +def rotation_vector(q: np.ndarray) -> np.ndarray: + """quatd::GetRotationVector: the axis times the angle.""" + return quat_axis(q) * quat_angle(q) + + +def cayley_vector(q: np.ndarray) -> np.ndarray: + """The axis times 2 tan(angle / 2): the inverse of `quat_of_cayley`.""" + return quat_axis(q) * (2.0 * np.tan(0.5 * quat_angle(q))) + + +def rotation_matrix(q: np.ndarray) -> np.ndarray: + """quatd::RotationMatrix of a unit quaternion.""" + x, y, z, w = q + return np.array( + [ + [1.0 - 2.0 * (y * y + z * z), 2.0 * (x * y - z * w), 2.0 * (x * z + y * w)], + [2.0 * (x * y + z * w), 1.0 - 2.0 * (x * x + z * z), 2.0 * (y * z - x * w)], + [2.0 * (x * z - y * w), 2.0 * (y * z + x * w), 1.0 - 2.0 * (x * x + y * y)], + ] + ) + + +# -- kernels over the nodes of the bodies ------------------------------------ + + +@wp.kernel +def _place_nodes( + node_entry: wp.array(dtype=wp.int32), + node_body: wp.array(dtype=wp.int32), + X: wp.array(dtype=vec3d), + arm0: wp.array(dtype=vec3d), + position: wp.array(dtype=vec3d), + rotation: wp.array(dtype=mat33d), + u: wp.array(dtype=vec3d), +): + """u = r + Q (X - r0) - X at every node of a body (FERigidSystem::UpdateMesh).""" + k = wp.tid() + b = node_body[k] + u[node_entry[k]] = position[b] + rotation[b] * arm0[k] - X[k] + + +@wp.kernel +def _arms( + node_entry: wp.array(dtype=wp.int32), + node_body: wp.array(dtype=wp.int32), + X: wp.array(dtype=vec3d), + center: wp.array(dtype=vec3d), + body_entry: wp.array(dtype=wp.int32), + u: wp.array(dtype=vec3d), + T: wp.array(dtype=mat33d), + A: wp.array(dtype=mat33d), +): + """The matrices of the two links of every node, to the translation and + to the rotation of its body, from the current arm z = x - r + (FERigidSolver::RigidStiffnessSolid): a node moves by dr + dtheta x z, + and a force f on it is the force f and the moment z x f on the body.""" + k = wp.tid() + b = node_body[k] + z = X[k] + u[node_entry[k]] - (center[b] + u[body_entry[b]]) + Z = wp.skew(z) + identity = wp.identity(n=3, dtype=wp.float64) + T[2 * k] = identity + A[2 * k] = identity + T[2 * k + 1] = -Z + A[2 * k + 1] = Z + + +@wp.kernel +def _add_at( + entries: wp.array(dtype=wp.int32), + values: wp.array(dtype=vec3d), + out: wp.array(dtype=vec3d), +): + k = wp.tid() + wp.atomic_add(out, entries[k], values[k]) + + +class RigidSystem(Term): + """Every rigid body with unknowns of a model, as one Term. + + Args: + model: The Model, for the load curves. + fields: The field table, with the entries of the bodies + (`FieldTable.bodies`). + device: The Warp device. + + The term owns the dependent entries of the system (`reduction`), which + `build_system` hands to the System. + """ + + name = "rigid bodies" + internal = False + element_type = "rigid" + #: The orientation of a body is kept here and committed with the time + #: step, not in the State, and the adjoint does not follow the update. + adjoint_ready = False + + def __init__(self, model, fields, device): + self.model = model + self.fields = fields + self.device = device + self.bodies = bodies = fields.bodies + self.n = fields.count + count = len(bodies) + # The entries of the bodies are the last ones of the table, in the + # order displacement, rotation, per body. + self.first = bodies[0].displacement + assert [b.displacement for b in bodies] == [self.first + 2 * k for k in range(count)] + assert self.first + 2 * count == fields.count + mesh = model.mesh + nodes = np.concatenate([b.nodes for b in bodies]) + node_entry = np.concatenate([b.node_entries for b in bodies]).astype(np.int32) + node_body = np.concatenate([np.full(len(b.nodes), k) for k, b in enumerate(bodies)]).astype(np.int32) + centers = np.array([b.center for b in bodies]) + as_device = lambda a, dtype: wp.array(a, dtype=dtype, device=device) + self.node_entry = as_device(node_entry, wp.int32) + self.node_body = as_device(node_body, wp.int32) + self.X = as_device(mesh.nodes[nodes], vec3d) + self.arm0 = as_device(mesh.nodes[nodes] - centers[node_body], vec3d) + self.center = as_device(centers, vec3d) + self.body_entry = as_device(np.array([b.displacement for b in bodies], dtype=np.int32), wp.int32) + self._centers = centers + # Dependent entries: every node of a body follows the two entries of + # the body in all three components. + k = np.arange(len(nodes)) + masters = np.stack([node_body * 2 + self.first, node_body * 2 + self.first + 1], axis=1).ravel() + self.reduction = Reduction( + fields.count, node_entry, np.zeros((len(nodes), 3)), np.repeat(k, 2), masters, device + ) + # The orientation at the last converged state (m_qp), the one of the + # iterate (m_qt), and the rotation increment of the time step, as + # FEBio's solution vector holds it (the Cayley vector, Ui). + self.Qp = np.tile(IDENTITY, (count, 1)) + self.Q = self.Qp.copy() + self.Ui = np.zeros((count, 3)) + self._position = wp.zeros(count, dtype=vec3d, device=device) + self._rotation = wp.zeros(count, dtype=mat33d, device=device) + # Two blocks per body: (translation, translation), which holds the + # mass through the mass of the system, and (rotation, rotation). + self.block_count = 2 * count + self._block_rows = as_device(self.first + np.arange(2 * count, dtype=np.int32), wp.int32) + self.mass = np.array([b.unknown.mass for b in bodies]) + self.inertia = np.array([b.unknown.inertia for b in bodies]) + # Angular velocity, angular acceleration, angular momentum and its + # rate (m_wt, m_alt, m_ht, m_dht), spatial frame: at the last + # converged state and at the iterate. + zeros = lambda: np.zeros((count, 3)) + self.wp_, self.alp, self.hp, self.dhp = zeros(), zeros(), zeros(), zeros() + self.w, self.al, self.h, self.dh = zeros(), zeros(), zeros(), zeros() + self._vq = zeros() + self._moved = False # an update of the bodies was made in this time step + self.system = None # set by build_system: for the time integration of the step + + # -- the state of the bodies --------------------------------------------- + + def positions(self, u: wp.array) -> np.ndarray: + """(bodies, 3) current position of the center of mass of every body.""" + return self._centers + self._entries(u)[0::2] + + def _entries(self, array: wp.array) -> np.ndarray: + """(2 bodies, 3) host copy of the entries of the bodies.""" + return array[self.first : self.first + 2 * len(self.bodies)].numpy() + + def _write_entries(self, array: wp.array, values: np.ndarray) -> None: + host = wp.array(values, dtype=vec3d, device=self.device) + wp.copy(array, host, dest_offset=self.first, count=len(values)) + + # -- Term ---------------------------------------------------------------- + + def begin_time_step(self) -> None: + self.Q = self.Qp.copy() + self.Ui[:] = 0.0 + self.w, self.al, self.h, self.dh = self.wp_.copy(), self.alp.copy(), self.hp.copy(), self.dhp.copy() + self._moved = False + + def commit(self, trial_history: Any) -> None: + self.Qp = self.Q.copy() + self.wp_, self.alp, self.hp, self.dhp = self.w.copy(), self.al.copy(), self.h.copy(), self.dh.copy() + + def rollback(self) -> None: + self.Q = self.Qp.copy() + + def restart_data(self) -> dict | None: + return { + "Q": self.Qp.copy(), + "w": self.wp_.copy(), + "al": self.alp.copy(), + "h": self.hp.copy(), + "dh": self.dhp.copy(), + } + + def set_restart_data(self, data: dict | None, state: State) -> None: + count = len(self.bodies) + self.Qp = np.tile(IDENTITY, (count, 1)) if data is None else np.array(data["Q"], dtype=np.float64) + self.Q = self.Qp.copy() + get = lambda key: np.zeros((count, 3)) if data is None else np.array(data[key], dtype=np.float64) + self.wp_, self.alp, self.hp, self.dhp = get("w"), get("al"), get("h"), get("dh") + if data is None and state.a is not None: + # The start of a run: the angular acceleration of each body is + # what the initial accelerations gave its rotation entry + # (FESolidSolver2::InitAccelerations, m_alt = m_alp = a0), zero + # where no load acts at time zero. + self.alp = self._entries(state.a)[1::2].copy() + + def _symmetric_storage(self) -> bool: + """True if the solver of the current step keeps a symmetric matrix: + `symmetric_stiffness` of the input, symmetric unless it says + otherwise (FESolver: m_msymm = REAL_SYMMETRIC).""" + solver = self.model.steps[self.fields.step].control.child("solver") + value = "symmetric" if solver is None else str(solver.get("symmetric_stiffness", "symmetric")) + return value.strip().lower() in ("symmetric", "1") + + def _dynamic(self, state: State): + """The time integration of the step if it is dynamic, or None.""" + ti = self.system.time_integration if self.system is not None else None + return ti if ti is not None and state.v is not None and state.dt > 0.0 else None + + def _rotational_kinematics(self, state: State, ti) -> None: + """FERigidSolverNew::UpdateRigidBodies (and PrepStep, where the body + has not turned): angular velocity and acceleration from the rotation + of the time step, then the angular momentum and its rate as + InertialForces takes them.""" + dt, beta, gamma = state.dt, ti.beta, ti.gamma + a = 1.0 / (beta * dt) + b = a / dt + c = 1.0 - 0.5 / beta + for k in range(len(self.bodies)): + q = quat_multiply(self.Q[k], self.Qp[k] * np.array([-1.0, -1.0, -1.0, 1.0])) + vq = cayley_vector(q) + turn = rotation_matrix(q) + self._vq[k] = vq + self.w[k] = turn @ ( + vq * (a * gamma) - self.wp_[k] + (self.wp_[k] + self.alp[k] * dt / 2.0) * (2.0 - gamma / beta) + ) + self.al[k] = turn @ (vq * b - self.wp_[k] * a + self.alp[k] * c) + R = rotation_matrix(self.Q[k]) + J = R @ self.inertia[k] @ R.T + self.h[k] = J @ self.w[k] + self.dh[k] = np.cross(self.w[k], self.h[k]) + J @ self.al[k] + + def _rotational_mass(self, state: State, ti) -> np.ndarray: + """(bodies, 3, 3): FERigidSolver::RigidMassMatrix, the rotation block.""" + dt, beta, gamma = state.dt, ti.beta, ti.gamma + skew = lambda v: np.array([[0.0, -v[2], v[1]], [v[2], 0.0, -v[0]], [-v[1], v[0], 0.0]]) + out = np.zeros((len(self.bodies), 3, 3)) + for k in range(len(self.bodies)): + R = rotation_matrix(self.Q[k]) + J = R @ self.inertia[k] @ R.T + vq = self._vq[k] + T = np.eye(3) + 0.5 * skew(vq) + 0.25 * np.outer(vq, vq) + # Before the first update of a time step FEBio's body still + # holds the angular momentum and its rate of the last state. + h, dh = (self.h[k], self.dh[k]) if self._moved else (self.hp[k], self.dhp[k]) + K = (((skew(self.w[k]) * gamma + np.eye(3) / dt) @ J - skew(h) * gamma) / (beta * dt)) @ T - skew(dh) + out[k] = ti.alpha_m * K + return out + + def linearize(self, state: State, history: Any, exact: bool = False) -> BlockTangent: + """The blocks of the bodies: zero on the translations, where the + system adds the mass, and the rotational mass block in a dynamic + step.""" + blocks = np.zeros((self.block_count, 3, 3)) + ti = self._dynamic(state) + if ti is not None: + K = self._rotational_mass(state, ti) + if not exact and self._symmetric_storage(): + # FEBio stores a symmetric matrix as its upper triangle, so + # of this block, which is not symmetric, the solve sees the + # upper triangle mirrored. Measured on a spinning body: with + # it the iterates are FEBio's, without it they converge + # faster than FEBio's (tests/test_rigid_dynamics.py). + K = np.array([np.triu(k) + np.triu(k, 1).T for k in K]) + blocks[1::2] = K + wp.copy(self.rows, self._block_rows) + wp.copy(self.cols, self._block_rows) + self.vals.assign(blocks) + return BlockTangent(self.n, self.rows, self.cols, self.vals) + + def add_initial_mass_blocks(self) -> None: + """The rotation blocks of the mass matrix of the initial + accelerations (System.mass_matrix): RigidMassMatrix at time zero + and at rest, J / (beta dt^2) with dt the first step size.""" + ti = self.system.time_integration + dt = float(self.model.steps[0].control.get("step_size", 1.0)) + blocks = self.vals.numpy() + for k in range(len(self.bodies)): + R = rotation_matrix(self.Q[k]) + blocks[2 * k + 1] += R @ self.inertia[k] @ R.T / (ti.beta * dt * dt) + self.vals.assign(blocks) + + def take_initial_accelerations(self, state: State) -> None: + """FESolidSolver2::InitAccelerations: a node of a body starts with + the acceleration of the center of mass. The angular acceleration of + each body is what was solved for on its rotation entry; it stays in + `state.a` there and is taken when the run starts + (`set_restart_data`).""" + a = state.a.numpy() + a[self.node_entry.numpy()] = a[self.body_entry.numpy()[self.node_body.numpy()]] + state.a.assign(a) + state.a_mass.assign(a) + + def incremental_update(self, du, s, final, first, free, u_start, u) -> None: + """FERigidSolverNew::UpdateRigidBodies at a trial increment `s du` + on top of the increments accepted in this time step, and, with + `final`, UpdateIncrements for the increment taken. `u` comes in with + the increment added on every entry; the rotation entries and the + nodes of the bodies are written here.""" + entries = self._entries(u) + increments = self._entries(du) + free_entries = self._entries(free) + bc = self.fields.bc + for k, body in enumerate(self.bodies): + if body.unknown.rotations_known(self.fields.step): + # All three known: the rotation of the prescribed values, + # zero for a fixed component. + vector = np.where(bc[body.rotation] == FIXED, 0.0, entries[2 * k + 1]) + self.Q[k] = quat_of_vector(vector) + entries[2 * k + 1] = vector + continue + on = free_entries[2 * k + 1] + q = quat_multiply(quat_of_cayley(float(s) * increments[2 * k + 1] * on), quat_of_cayley(self.Ui[k])) + self.Q[k] = quat_multiply(q, self.Qp[k]) + entries[2 * k + 1] = rotation_vector(self.Q[k]) + if final: + # Written on the components with an equation only. + self.Ui[k] = np.where(on != 0.0, cayley_vector(q), self.Ui[k]) + self._moved = True + self._write_entries(u, entries) + self._position.assign(self._centers + entries[0::2]) + self._rotation.assign(np.array([rotation_matrix(q) for q in self.Q])) + wp.launch( + _place_nodes, + dim=len(self.node_entry), + inputs=[self.node_entry, self.node_body, self.X, self.arm0, self._position, self._rotation], + outputs=[u], + device=self.device, + ) + + def write_total_increment(self, Ui: wp.array) -> None: + """The rotation entries of the total increment of the time step, as + FEBio's solution vector holds them: the composed Cayley vector, not + the sum of the increments. Called by the Newton loop after an + increment is taken; its convergence norms count this.""" + entries = self._entries(Ui) + for k, body in enumerate(self.bodies): + if not body.unknown.rotations_known(self.fields.step): + entries[2 * k + 1] = self.Ui[k] + self._write_entries(Ui, entries) + + def update(self, state: State) -> int: + """The arms of the nodes at this state, for the elimination.""" + wp.launch( + _arms, + dim=len(self.node_entry), + inputs=[self.node_entry, self.node_body, self.X, self.center, self.body_entry, state.u], + outputs=[self.reduction.T, self.reduction.A], + device=self.device, + ) + ti = self._dynamic(state) + if ti is not None: + self._rotational_kinematics(state, ti) + return OK + + def residual(self, state: State, history: Any, out: wp.array) -> None: + """The rigid loads: a value times its load curve on one component of + a body (load_type LOAD).""" + values = np.zeros((2 * len(self.bodies), 3)) + for k, body in enumerate(self.bodies): + for load in body.unknown.loads: + if load.steps is not None and self.fields.step not in load.steps: + continue + factor = ( + 1.0 + if load.load_controller is None + else self.model.load_controller(load.load_controller).value(state.time) + ) + values[2 * k + load.component // 3, load.component % 3] += load.value * factor + ti = self._dynamic(state) + if ti is not None: + # The inertial moment (InertialForces). The inertial force of + # the translation is that of the mass of the system. + for k in range(len(self.bodies)): + values[2 * k + 1] -= ti.alpha_m * self.dh[k] + (1.0 - ti.alpha_m) * self.dhp[k] + if not values.any(): + return + entries = wp.array(self.first + np.arange(len(values), dtype=np.int32), dtype=wp.int32, device=self.device) + wp.launch( + _add_at, + dim=len(values), + inputs=[entries, wp.array(values, dtype=vec3d, device=self.device)], + outputs=[out], + device=self.device, + ) + + def mass_coefficients(self) -> np.ndarray: + """The mass of each body on its translation block, and zero on the + rotation block, whose inertia is not a number times the identity.""" + return np.stack([self.mass, np.zeros(len(self.bodies))], axis=1).reshape(-1) diff --git a/src/febio_warp/discretization/fields.py b/src/febio_warp/discretization/fields.py index a240f3f..7b9d0cd 100644 --- a/src/febio_warp/discretization/fields.py +++ b/src/febio_warp/discretization/fields.py @@ -44,7 +44,14 @@ from ..constraints import normal_displacement, prescribed_deformation from ..constraints.prescribed import nodal_scale -from ..constraints.rigid_parts import fixed_rigid_materials, fixed_rigid_nodes, moving_rigid_nodes, rigid_motions +from ..constraints.rigid_parts import ( + body_nodes, + fixed_rigid_materials, + fixed_rigid_nodes, + moving_rigid_nodes, + rigid_motions, + rigid_unknowns, +) from ..model import activity as model_activity # FEBio variable names, and the component tags FEBio uses for them in input @@ -75,6 +82,10 @@ UPDATE_RULE = {"displacement": "add", "shell displacement": "add", "rotation": "compose"} FREE, FIXED, PRESCRIBED = 0, 1, 2 +# A component that follows other unknowns: a node of a rigid body with +# unknowns, the parent of a linear constraint (assembly/reduction.py). Not +# solved for and not prescribed: the owner of the dependence writes its value. +DEPENDENT = 3 # Prescribed conditions read by this template. Which conditions the replay of # activation reads, fixed and prescribed, is in model/activity.py. @@ -125,6 +136,28 @@ class RigidPrescribed: material: str # the rigid body +@dataclass +class RigidBodyEntries: + """A rigid body with unknowns in the field table (constraints/rigid_system.py). + + FEBio counterpart: the six equations of an FERigidBody (m_LM), which + follow those of the nodes. Here they are two entries after the node + entries: `displacement` holds the translation of the center of mass + (FEBio's Rx, Ry, Rz; m_Ut[0..2]) and `rotation` the rotation vector + (Ru, Rv, Rw; m_Ut[3..5]). Each component is free, fixed or prescribed + per analysis step like every other. The displacement entries of the + nodes of the body are DEPENDENT: they follow the body. + """ + + material: str + displacement: int # entry index + rotation: int # entry index + nodes: np.ndarray # (n,) node indices: those of the parts and those tied to the body + node_entries: np.ndarray # (n,) their displacement entries + center: np.ndarray # (3,) the center of mass in the reference configuration + unknown: object = None # the RigidUnknown of constraints/rigid_parts.py + + @dataclass class StepFields: """The state of every component while one analysis step runs. @@ -167,6 +200,9 @@ class FieldTable: # (material name -> RigidMotion). The same in every step. rigid: list = field(default_factory=list) rigid_motions: dict = field(default_factory=dict) + # Rigid bodies with unknowns: RigidBodyEntries per body, in the order of + # their entries, which follow those of the nodes. + bodies: list = field(default_factory=list) # Factors of prescribed conditions that are parameters (`Prescribed.parameter`): # name -> array of one number. A host array when the table is built; the # System replaces each by a device array with a gradient @@ -379,12 +415,22 @@ def build_field_table(model) -> FieldTable: entry = np.full(active.shape, -1, dtype=np.int32) entry[active] = np.arange(active.sum(), dtype=np.int32) count = int(active.sum()) + # Rigid bodies with unknowns: two entries each, after those of the nodes + # (FERigidSolver::InitEquations numbers the bodies after the nodes). + unknowns = rigid_unknowns(model) + bodies = [] + for name, nodes in body_nodes(model, list(unknowns)).items(): + bodies.append( + RigidBodyEntries(name, count, count + 1, nodes, entry[nodes, 0], unknowns[name].center, unknowns[name]) + ) + count += 2 table = FieldTable( variables=VARIABLES, entry=entry, count=count, bc=np.full((count, 3), FREE, dtype=np.int32), + bodies=bodies, ) # Nodes that no element uses. FEBio excludes them from the analysis # (FEMesh::RemoveIsolatedVertices, called by FEModel::Init); here they @@ -468,6 +514,8 @@ def build_field_table(model) -> FieldTable: p.entries, p.scale = p.entries[keep], p.scale[keep] if p.offset is not None: p.offset = p.offset[keep] + for body in table.bodies: + _lay_body(table, body, s) zeroed = table.steps[s].zeroed if s > 0 and zeroed.any(): # The first time step of the step: see FieldTable.set_step. @@ -482,6 +530,51 @@ def build_field_table(model) -> FieldTable: return table +def _lay_body(table: FieldTable, body: RigidBodyEntries, s: int) -> None: + """Lay one rigid body with unknowns on step s: the state of its six + components from the replay of FEBio's activation (rigid_parts), its + prescribed components as prescribed conditions on its two entries, and + its nodes as dependent entries, whatever a nodal condition says of them + (in FEBio a rigid node has no equation of its own). + + `relative`: FEBio takes the value the component has when the condition + is activated (FERigidPrescribedBC::Activate, m_ref), which is the value + of the entry then; `FieldTable.activate` stores it for a condition + declared in a step. A condition of the model is activated at time zero, + where it is zero. + """ + fields = table.steps[s] + e = body.node_entries + fields.bc[e] = DEPENDENT + fields.zeroed[e] = False + fields.released[e] = False + for p in fields.prescribed: + keep = ~np.isin(p.entries, e) + p.entries, p.scale = p.entries[keep], p.scale[keep] + if p.offset is not None: + p.offset = p.offset[keep] + for c, how in enumerate(body.unknown.steps[s]): + target = body.displacement if c < 3 else body.rotation + if how is None: + continue # open: an unknown + if how.kind == "fixed": + fields.bc[target, c % 3] = FIXED + continue + fields.bc[target, c % 3] = PRESCRIBED + declared = how.reference_step if how.relative and how.reference_step > 0 else None + fields.prescribed.append( + Prescribed( + np.array([target], dtype=np.int32), + c % 3, + np.array([how.value]), + how.load_controller, + relative=how.relative and declared is not None, + declared=declared, + offset=np.zeros(1) if how.relative and declared is not None else None, + ) + ) + + class _HostParameter: """One number with the `numpy` and `assign` of a device array: what a parameter of the table is until a System gives it a device array.""" diff --git a/src/febio_warp/sensitivity/adjoint.py b/src/febio_warp/sensitivity/adjoint.py index aa7f773..a87586d 100644 --- a/src/febio_warp/sensitivity/adjoint.py +++ b/src/febio_warp/sensitivity/adjoint.py @@ -91,6 +91,11 @@ def adjoint_solve( "gradients through a static step that follows a dynamic one are not built: its state carries the velocity " "the dynamic step left (State.v_material), which a mass damping load reads" ) + if getattr(system, "reduction", None) is not None: + raise NotImplementedError( + "gradients through a system with dependent entries (a rigid body with unknowns, a linear " + "constraint) are not built: the adjoint solution is not spread to the dependent entries" + ) for term in system.terms: # A term with state that an update changes (the attachments of sticky # contact) would be brought to this state with the history of diff --git a/src/febio_warp/sensitivity/forward.py b/src/febio_warp/sensitivity/forward.py index c4b26dc..035826e 100644 --- a/src/febio_warp/sensitivity/forward.py +++ b/src/febio_warp/sensitivity/forward.py @@ -464,6 +464,11 @@ def derivative(self, evaluate, out: wp.array, local_evaluate=None) -> None: def _check_terms(system: System) -> None: + if getattr(system, "reduction", None) is not None: + raise NotImplementedError( + "sensitivities through a system with dependent entries (a rigid body with unknowns, a linear " + "constraint) are not built" + ) for term in system.terms: # As in the adjoint: a term whose history is not kept per state. if not getattr(term, "adjoint_ready", True): diff --git a/src/febio_warp/solvers/nonlinear/newton.py b/src/febio_warp/solvers/nonlinear/newton.py index ebef9e6..2c7afe1 100644 --- a/src/febio_warp/solvers/nonlinear/newton.py +++ b/src/febio_warp/solvers/nonlinear/newton.py @@ -1088,6 +1088,12 @@ def evaluate(s, u_base=u_base, du=du, trial=trial, first=(it == 0)): # The increment taken, for the terms that keep it (du is scaled). for term in incremental: term.incremental_update(du, 1.0, True, it == 0, system.free, u_start, u) + # A term whose unknowns do not add writes the total increment + # of the time step as FEBio's solution vector holds it, since + # the convergence norms count it (a rigid body: its rotation + # increments are composed, FERigidSolverNew::UpdateIncrements). + if hasattr(term, "write_total_increment"): + term.write_total_increment(Ui) # FESolidSolver2::Quasin: the solution norm of the scaled increment, # the energy norm |ls (ui . R1)|. normR1, normu, normU = inner(R1, R1), inner(du, du), inner(Ui, Ui) diff --git a/tests/test_reduction.py b/tests/test_reduction.py new file mode 100644 index 0000000..e3d18d9 --- /dev/null +++ b/tests/test_reduction.py @@ -0,0 +1,255 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 The FEBio-Warp-Python Authors +# SPDX-License-Identifier: Apache-2.0 +"""Dependent entries and their elimination (assembly/reduction.py). + +The mechanism by which a node of a rigid body, or the parent of a linear +constraint, follows other unknowns: its residual and its stiffness blocks +are carried to its masters after the terms have assembled. No rigid body and +no constraint is involved here; the table is built by hand on +`bk_body_force` of references/small_problems (two hex8, 12 nodes), so that +the three operations are checked on their own: + + matrix the matrix the linear solve gets against the product + L K T formed densely on the host, masked as the system masks + it, for a table in which a dependent entry has two masters + (one of them prescribed), another keeps two components of + its own, and the row matrices are not the transposes of the + column matrices (as for a rigid node with alpha_f below 1) + residual the carried residual against L R + product `System.apply_tangent` against L K T x + run a run of the block with the table, a term of the test + writing the dependent entries after every update: the + constraints hold, the carried residual is zero at the free + components, and Newton converges as fast as without the + table, which it would not with a wrong tangent + rules a master that is dependent, a dependent entry listed twice, + a table given after the pattern is built, and gradients, + which are refused + +Nothing here is compared with FEBio: the reduced matrix is defined by the +product, and FEBio's use of it is compared where the rigid bodies and the +linear constraints are (docs/design/rigid_bodies.md, section 5.2). + +Tolerances. Matrix, residual and product: sums of a few products of numbers +of order 1, compared at 1e-12 of the largest value. Run: the constraints are +written, not solved, so they hold to round-off (1e-14); the residual is +compared with the first residual of the last time step at 1e-8, far inside +what full Newton leaves after its last iterate. +""" + +import pathlib +import unittest + +import numpy as np +import warp as wp +from support import DEVICE, setUpModule, tearDownModule # noqa: F401 (device for the module) + +from febio_warp.analysis.steps import build_system, run +from febio_warp.assembly.reduction import Reduction +from febio_warp.assembly.system import Term +from febio_warp.discretization.fields import DEPENDENT +from febio_warp.io import read_feb +from febio_warp.sensitivity.adjoint import adjoint_solve + + +def dense(A) -> np.ndarray: + """Host dense copy of a matrix of 3x3 blocks, over (entry, component).""" + n = A.nrow + nnz = A.nnz_sync() + offsets = A.offsets.numpy()[: n + 1] + rows = np.repeat(np.arange(n), np.diff(offsets)) + cols = A.columns.numpy()[:nnz] + vals = A.values.numpy()[:nnz] + K = np.zeros((n, 3, A.ncol, 3)) + np.add.at(K, (rows, slice(None), cols, slice(None)), vals) + return K.reshape(3 * n, 3 * A.ncol) + + +CASES = pathlib.Path(__file__).resolve().parents[1] / "references" / "small_problems" / "inputs" + +EXACT = 1e-12 + +# Nodes of bk_body_force, from zero: 0 to 3 at z = 0 (z fixed), 4 to 7 in the +# middle, 8 to 11 on top (z prescribed). Even nodes are on x = 0 (x fixed), +# nodes 0, 1, 4, 5, 8, 9 on y = 0 (y fixed). Node 7 is free in all three. +FULL, PARTIAL = 7, 5 +MASTER, MOVED = 3, 11 + + +def table(rng): + """The hand-built table: node 7 follows node 3 and node 11 (which the + input moves in z) in all three components; node 5 follows node 3 in x + only and keeps y and z. Returns (dependent nodes, own, link position, + master nodes, T, A, components marked dependent).""" + dependent = np.array([FULL, PARTIAL]) + own = np.array([[0.0, 0.0, 0.0], [0.0, 1.0, 1.0]]) + position = np.array([0, 0, 1]) + masters = np.array([MASTER, MOVED, MASTER]) + T = 0.4 * rng.standard_normal((3, 3, 3)) + A = 0.4 * rng.standard_normal((3, 3, 3)) + # Node 5 follows in x only: the rows of T for y and z are zero, and A + # carries only the x component of its residual. + T[2, 1:, :] = 0.0 + A[2, :, 1:] = 0.0 + return dependent, own, position, masters, T, A + + +def build(same_transpose=False, seed=7): + """The system with the table, and what the host needs to form L K T.""" + system = build_system(read_feb(CASES / "bk_body_force.feb"), device=DEVICE) + fields = system.fields + dependent, own, position, masters, T, A = table(np.random.default_rng(seed)) + if same_transpose: + A = np.transpose(T, (0, 2, 1)).copy() + entry = fields.entries_of("displacement") + for step in fields.steps: + step.bc[entry[dependent]] = np.where(own == 0.0, DEPENDENT, step.bc[entry[dependent]]) + system.set_step(0) + reduction = Reduction(system.n, entry[dependent], own, position, entry[masters], DEVICE) + reduction.set_matrices(T, A) + system.set_reduction(reduction) + # Dense operators over (entry, component): u = Tm q and R_reduced = Lm R. + n = system.n + Tm, Lm = np.eye(3 * n), np.eye(3 * n) + for k, e in enumerate(entry[dependent]): + Tm[3 * e : 3 * e + 3, 3 * e : 3 * e + 3] = np.diag(own[k]) + for link in range(len(masters)): + i, m = entry[dependent[position[link]]], entry[masters[link]] + Tm[3 * i : 3 * i + 3, 3 * m : 3 * m + 3] += T[link] + Lm[3 * m : 3 * m + 3, 3 * i : 3 * i + 3] += A[link] + return system, Tm, Lm, (entry[dependent], own, position, entry[masters], T) + + +def random_state(system, seed=11): + state = system.state() + state.time = 0.5 + state.dt = 0.1 + state.u.assign(0.02 * np.random.default_rng(seed).standard_normal((system.n, 3))) + return state + + +class OperationTests(unittest.TestCase): + def test_the_matrix_is_the_product(self): + system, Tm, Lm, _ = build() + state = random_state(system) + system.update(state) + system.tangent(state) + K = dense(system.matrix()) + F = np.diag(system.fields.free.ravel()) + expected = F @ Lm @ K @ Tm @ F + (np.eye(len(F)) - F) + found = dense(system.constrained_matrix()) + np.testing.assert_allclose(found, expected, atol=EXACT * abs(expected).max()) + # The table is not a no-op: the carried blocks are a visible part. + self.assertGreater(abs(expected - (F @ K @ F + np.eye(len(F)) - F)).max(), 1e-3 * abs(K).max()) + # A second assembly refills the values through the map of the first. + system.tangent(state) + np.testing.assert_allclose(dense(system.constrained_matrix()), expected, atol=EXACT * abs(expected).max()) + + def test_the_residual_is_carried(self): + system, _, Lm, _ = build() + state = random_state(system) + system.update(state) + reduction, system.reduction = system.reduction, None + R = system.residual(state).numpy().ravel() + system.reduction = reduction + found = system.residual(state).numpy().ravel() + np.testing.assert_allclose(found, Lm @ R, atol=EXACT * abs(R).max()) + self.assertGreater(abs(found - R).max(), 1e-3 * abs(R).max()) + + def test_the_product_is_that_of_the_reduced_matrix(self): + system, Tm, Lm, _ = build() + state = random_state(system) + system.update(state) + system.tangent(state) + K = dense(system.matrix()) + x = np.random.default_rng(5).standard_normal((system.n, 3)) + y0 = np.random.default_rng(6).standard_normal((system.n, 3)) + y = wp.array(y0, dtype=wp.vec3d, device=DEVICE) + system.apply_tangent(wp.array(x, dtype=wp.vec3d, device=DEVICE), y, alpha=-0.7) + expected = y0.ravel() - 0.7 * (Lm @ K @ Tm @ x.ravel()) + np.testing.assert_allclose(y.numpy().ravel(), expected, atol=EXACT * abs(expected).max()) + + def test_spread(self): + system, Tm, _, _ = build() + x = np.random.default_rng(2).standard_normal((system.n, 3)) + spread = wp.array(x, dtype=wp.vec3d, device=DEVICE) + system.reduction.spread(spread) + np.testing.assert_allclose(spread.numpy().ravel(), Tm @ x.ravel(), atol=EXACT) + + +class _Follow(Term): + """The owner of the test's table: writes the dependent components from + their masters after every update of the solution, through the hook of + the Newton loop that the beam uses.""" + + name = "follow" + adjoint_ready = False + + def __init__(self, dependent, own, position, masters, T): + self.table = dependent, own, position, masters, T + + def residual(self, state, history, out): + pass + + def incremental_update(self, du, s, final, first, free, u_start, u): + dependent, own, position, masters, T = self.table + host = u.numpy() + value = host[dependent] * own + for link in range(len(masters)): + value[position[link]] += T[link] @ host[masters[link]] + host[dependent] = value + u.assign(host) + + +class RunTests(unittest.TestCase): + def test_a_run_with_dependent_entries(self): + plain = run(build_system(read_feb(CASES / "bk_body_force.feb"), device=DEVICE)) + system, _, _, tied = build(same_transpose=True) + system.all_terms.append(_Follow(*tied)) + system.set_step(0) + results, states = run(system, keep_states=True) + dependent, own, position, masters, T = tied + u = states[-1].u.numpy() + value = u[dependent] * own + for link in range(len(masters)): + value[position[link]] += T[link] @ u[masters[link]] + np.testing.assert_allclose(u[dependent], value, atol=1e-14) + self.assertGreater(abs(u[dependent[0]]).max(), 1e-3) # the tie moves the node + # Equilibrium of the reduced system at the free components. The + # reference is the residual with the solution of the plain run. + system.update(states[-1]) + R = system.residual(states[-1]).numpy() * system.fields.free + start = system.state() + start.time, start.dt = states[-1].time, states[-1].dt + system.update(start) + reference = abs(system.residual(start).numpy() * system.fields.free).max() + self.assertLess(abs(R).max(), 1e-8 * reference) + # The same number of iterations as without the table, within one per + # time step: the tangent is that of the residual. + mine = [s.iterations for s in results.states[1:]] + theirs = [s.iterations for s in plain.states[1:]] + self.assertEqual(len(mine), len(theirs)) + self.assertLessEqual(max(abs(a - b) for a, b in zip(mine, theirs)), 1) + self.assertEqual(int((system.fields.bc == DEPENDENT).sum()), 4) + self.assertFalse((system.fields.free[dependent[0]] != 0.0).any()) + + +class RuleTests(unittest.TestCase): + def test_what_is_refused(self): + with self.assertRaisesRegex(ValueError, "a parent may not be a child"): + Reduction(10, [1, 2], np.zeros((2, 3)), [0, 1], [2, 5], DEVICE) + with self.assertRaisesRegex(ValueError, "listed twice"): + Reduction(10, [1, 1], np.zeros((2, 3)), [0, 1], [3, 5], DEVICE) + system, _, _, _ = build() + state = random_state(system) + system.update(state) + system.tangent(state) + system.constrained_matrix() + with self.assertRaisesRegex(RuntimeError, "pattern is already built"): + system.set_reduction(system.reduction) + with self.assertRaisesRegex(NotImplementedError, "dependent entries"): + adjoint_solve(system, state, np.zeros((system.n, 3))) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_rigid_dynamics.py b/tests/test_rigid_dynamics.py new file mode 100644 index 0000000..6f1dd6f --- /dev/null +++ b/tests/test_rigid_dynamics.py @@ -0,0 +1,205 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 The FEBio-Warp-Python Authors +# SPDX-License-Identifier: Apache-2.0 +"""A rigid body with unknowns in a dynamic step (constraints/rigid_system.py). + +Mass and inertia of a body, FEBio's update of its angular velocity and +acceleration, the inertial force and moment, the rotational mass block, a +body force on a rigid part, and the initial accelerations. What is covered: + + spinning `rb_spin` and `rb_spin_from_zero` of references/small_problems + against FEBio 4.13.0 (e4df3f8): one skewed rigid hex8, free + in all six components, spun up by two moments about axes + that are not principal axes and pushed by a force, over ten + dynamic time steps. `rb_spin`: loads on a curve, a symmetric + stiffness, a reformation in every iteration. + `rb_spin_from_zero`: loads from time zero, so that FEBio's + initial accelerations act; a non-symmetric stiffness with + BFGS updates (FEBio's reference is of its MKL Pardiso build: + its skyline solver takes no non-symmetric matrix). + Displacement of the eight nodes at every state, and FEBio's + iterations in every time step + suite `dy05`: one rigid hex8 under a body force (`const`), which + reaches the body through the nodes of its part; FEBio's + steps, iterations and norm + mass mass, center of mass and inertia of a hex8 cube and of tet4 + parts against closed forms, with FEBio's rules (one + integration point for a tet4; a given center used as it is) + the block the rotational mass block Newton gets is the upper triangle + mirrored where the input asks for a symmetric stiffness, and + the block itself otherwise and for the adjoint + +Tolerances. FEBio's log has 12 digits and the runs converge to dtol 1e-7 +on the same iterates: observed, relative to the largest displacement, 2.5e-12 +(`rb_spin`) and 8.1e-13 (`rb_spin_from_zero`) on CPU and on a Tesla P100 +(December 2, 2026), compared at 1e-9. The iterations per time step were +FEBio's exactly on both devices (3 3 4 4 5 5 5 6 6 6, and 4 4 5 6 6 6 6 7 8 +8); the total is compared within 2. Before the symmetric storage was +followed, the first case converged faster than FEBio, which is how that +rule was found. `dy05`: observed 9e-16, compared at 1e-10. Closed forms: +1e-13. +""" + +import json +import os +import pathlib +import unittest + +import numpy as np +from support import DEVICE, setUpModule, tearDownModule # noqa: F401 (device for the module) + +from febio_warp.analysis.choices import FEBIO_4_13 +from febio_warp.analysis.steps import build_system, inspect_model, run +from febio_warp.constraints import rigid_parts +from febio_warp.discretization.fields import FREE +from febio_warp.io import read_feb + +CASES = pathlib.Path(__file__).resolve().parents[1] / "references" / "small_problems" +SUITE = os.environ.get("FEBIO_TEST_SUITE") + +AGREEMENT = 1e-9 +CLOSED_FORM = 1e-13 + + +def small(case): + ref = json.loads((CASES / "febio" / f"{case}.json").read_text()) + return ref, read_feb(CASES / ref["input"]) + + +class FebioAgreementTests(unittest.TestCase): + def against_febio(self, case, febio_iterations): + ref, model = small(case) + report = inspect_model(model) + self.assertTrue(report.runnable, report.table()) + system = build_system(model, device=DEVICE) + results, states = run(system, keep_states=True) + record = next(r for r in ref["records"] if "ux" in r["data"]) + logged = np.array(record["values"]) + u = np.stack([s.displacement[model.mesh.node_index(record["items"])] for s in results.states]) + self.assertEqual(u.shape, logged.shape) + self.assertLess(abs(u - logged).max() / abs(logged).max(), AGREEMENT) + iterations = [s.iterations for s in results.states[1:]] + self.assertLessEqual(abs(sum(iterations) - sum(febio_iterations)), 2) + # The body turns by a visible angle about an axis that is none of + # the coordinate axes, and moves. + body = system.fields.bodies[0] + rotation = states[-1].u.numpy()[body.rotation] + self.assertGreater(np.linalg.norm(rotation), 0.2) + self.assertGreater(abs(rotation).min(), 0.02) + self.assertGreater(abs(states[-1].u.numpy()[body.displacement][1]), 0.01) + return system, states + + def test_spun_up_by_moments(self): + self.against_febio("rb_spin", (3, 3, 4, 4, 5, 5, 5, 6, 6, 6)) + + def test_loads_from_time_zero_and_a_non_symmetric_stiffness(self): + system, states = self.against_febio("rb_spin_from_zero", (4, 4, 5, 6, 6, 6, 6, 7, 8, 8)) + # FEBio's initial accelerations: the translation starts with + # force / mass, and the rotation with what FEBio's mass matrix of + # time zero gives, beta dt^2 times the angular acceleration of the + # moments (FEBio sets 1 / (beta dt^2) to 1 for the translations only). + body = system.fields.bodies[0] + a0 = states[0].a.numpy() + np.testing.assert_allclose(a0[body.displacement], [0.0, 0.3 / body.unknown.mass, 0.0], atol=1e-12) + expected = 0.25 * 0.1**2 * np.linalg.solve(body.unknown.inertia, [0.4, 0.0, 0.25]) + np.testing.assert_allclose(a0[body.rotation], expected, rtol=1e-10) + # Every node of the body starts with the acceleration of the center. + np.testing.assert_allclose(a0[body.node_entries], np.tile(a0[body.displacement], (8, 1)), atol=1e-12) + + def test_the_rotational_mass_block(self): + """`rb_spin` asks for a symmetric stiffness: Newton's block of the + rotation is the upper triangle of FEBio's block mirrored, and the + block for the adjoint is the block itself, which is not symmetric + once the body turns.""" + _, model = small("rb_spin") + system = build_system(model, device=DEVICE) + _, states = run(system, keep_states=True) + state = states[-1] + rigid = system.rigid + ti = system.time_integration + full = rigid._rotational_mass(state, ti)[0] + self.assertGreater(abs(full - full.T).max(), 1e-3 * abs(full).max()) + rigid.linearize(state, None, False) + newton = rigid.vals.numpy()[1] + np.testing.assert_allclose(newton, np.triu(full) + np.triu(full, 1).T, atol=CLOSED_FORM * abs(full).max()) + rigid.linearize(state, None, True) + np.testing.assert_allclose(rigid.vals.numpy()[1], full, atol=CLOSED_FORM * abs(full).max()) + # The translation block is left to the mass of the system. + np.testing.assert_array_equal(rigid.vals.numpy()[0], np.zeros((3, 3))) + np.testing.assert_allclose(rigid.mass_coefficients(), [rigid.mass[0], 0.0], atol=0) + + +@unittest.skipUnless(SUITE, "set FEBIO_TEST_SUITE to a checkout of the FEBio test suite") +class SuiteTests(unittest.TestCase): + def test_a_rigid_element_under_a_body_force(self): + from test_febio_suite import stored_values + + steps, iterations, norm = stored_values()["dy05"] + model = read_feb(pathlib.Path(SUITE) / "Verify" / "dy05.feb") + report = inspect_model(model) + self.assertTrue(report.runnable, report.table()) + system = build_system(model, device=DEVICE, **FEBIO_4_13) + results, states = run(system, keep_states=True) + self.assertEqual(len(results.states) - 1, steps) + self.assertLessEqual(abs(sum(s.iterations for s in results.states[1:]) - iterations), 2) + found = float(np.linalg.norm(states[-1].u.numpy()[system.fields.bc == FREE])) + self.assertLess(abs(found - norm) / norm, 1e-10) + + +class MassTests(unittest.TestCase): + def test_a_cube(self): + """The rigid hex8 of `bk_rigid_tied_nodes`: a cube of side 0.5 at + (1.6, 0.2, 1.3), density 1. Mass 1/8, the center in the middle, and + the inertia m s^2 / 6 about every axis.""" + _, model = small("bk_rigid_tied_nodes") + mass, center, inertia, nodes, nodal = rigid_parts.mass_properties(model, "lid") + self.assertAlmostEqual(mass, 0.125, delta=CLOSED_FORM) + np.testing.assert_allclose(center, [1.85, 0.45, 1.55], rtol=CLOSED_FORM) + np.testing.assert_allclose(inertia, 0.125 * 0.25 / 6.0 * np.eye(3), atol=CLOSED_FORM) + # The nodes of the part share the mass equally. + self.assertEqual(len(nodes), 8) + np.testing.assert_allclose(nodal, 0.125 / 8.0, rtol=CLOSED_FORM) + # A center that is given is used as it is, also for the inertia: + # FEBio subtracts m ((c . c) I - c c^T) with that center from the + # inertia about the origin. + c = np.array([1.0, 0.0, 1.0]) + _, given, about_given, _, _ = rigid_parts.mass_properties(model, "lid", c) + np.testing.assert_array_equal(given, c) + shift = lambda p: mass * ((p @ p) * np.eye(3) - np.outer(p, p)) + np.testing.assert_allclose(about_given, inertia + shift(center) - shift(c), atol=CLOSED_FORM) + + def test_tetrahedra_have_one_integration_point(self): + """FEBio integrates a tet4 with one point, so each tetrahedron + counts as its mass at its centroid: the inertia of a body of tet4 + is that of those point masses.""" + from febio_warp.model.model import ElementBlock + + _, model = small("bk_rigid_tied_nodes") + block = next(b for b in model.mesh.blocks if rigid_parts._block_material(model, b) == "lid") + corners = block.connectivity[0] + # Five tetrahedra of the hexahedron (FEBio's node order of a hex8). + local = np.array([[0, 1, 3, 4], [1, 2, 3, 6], [1, 5, 4, 6], [3, 7, 6, 4], [1, 3, 4, 6]]) + tets = corners[local].astype(np.int32) + # Oriented so that every volume is positive, as FEBio requires. + x = model.mesh.nodes[tets] + inverted = np.einsum("ei,ei->e", x[:, 1] - x[:, 0], np.cross(x[:, 2] - x[:, 0], x[:, 3] - x[:, 0])) < 0 + tets[inverted] = tets[inverted][:, [0, 2, 1, 3]] + block.connectivity = tets + block.febio_type = "tet4" + block.ids = np.arange(1, 6, dtype=np.int32) + self.assertIsInstance(block, ElementBlock) + mass, center, inertia, _, _ = rigid_parts.mass_properties(model, "lid") + x = model.mesh.nodes[block.connectivity] + volume = np.einsum("ei,ei->e", x[:, 1] - x[:, 0], np.cross(x[:, 2] - x[:, 0], x[:, 3] - x[:, 0])) / 6.0 + centroid = x.mean(axis=1) + self.assertAlmostEqual(mass, 0.125, delta=CLOSED_FORM) + np.testing.assert_allclose(center, [1.85, 0.45, 1.55], rtol=CLOSED_FORM) + r = centroid - center + points = sum(v * ((p @ p) * np.eye(3) - np.outer(p, p)) for v, p in zip(volume, r)) + np.testing.assert_allclose(inertia, points, atol=CLOSED_FORM) + # Less than the inertia of the cube: the spread inside each + # tetrahedron is left out. + self.assertLess(np.trace(inertia), 0.9 * 3 * 0.125 * 0.25 / 6.0) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_rigid_moved.py b/tests/test_rigid_moved.py index 760d542..c958c79 100644 --- a/tests/test_rigid_moved.py +++ b/tests/test_rigid_moved.py @@ -312,10 +312,12 @@ def test_tied_nodes_that_are_refused(self): self.assertTrue(inspect_model(tied).runnable) section = next(r for r in tied.other_sections if r.tag == "Rigid") section.children = [c for c in section.children if c.name != "twist"] + # Refused until December 2, 2026; since then the body has unknowns + # and the tie is read (`bk_rigid_tied_free`, tests/test_rigid_unknowns.py). report = inspect_model(tied) - self.assertFalse(report.runnable) + self.assertTrue(report.runnable, report.table()) entry = next(e for e in report.entries if e.where == "tie") - self.assertIn("rigid body 'lid' can move under the loads", entry.note) + self.assertIn("rigid body 'lid', which has unknowns", entry.note) def test_what_is_refused(self): _, model = load("bk_rigid_lid_moved") @@ -326,9 +328,13 @@ def test_what_is_refused(self): motions, problems = rigid_parts.rigid_motions(loose) self.assertNotIn("lid", motions) self.assertIn("neither fixed nor prescribed in step 2", problems["lid"]) + # Not geometry: since December 2, 2026 a body with unknowns, compared + # with FEBio on this very change (`bk_rigid_lid_released`, + # tests/test_rigid_unknowns.py). + self.assertIn("lid", rigid_parts.rigid_unknowns(loose)) report = inspect_model(loose) - self.assertFalse(report.runnable) - self.assertIn("a rigid body that can move", report.table()) + self.assertTrue(report.runnable, report.table()) + self.assertIn("rigid body with unknowns", report.table()) # A joint whose origin is not the center of mass of the body it turns. _, hinged = load("bk_rigid_lid_joint") hinged = copy.deepcopy(hinged) @@ -353,8 +359,10 @@ def test_a_component_opened_when_a_step_condition_ends(self): (FERigidPrescribedBC::Deactivate, FERigidFixedBCNew::Deactivate). Seen in FEBio 4.13.0: with a rigid_fixed of the model on all six components and a displacement prescribed in step 1 only, the lid is - back at zero at the end of step 2. Free rigid motion is not built, - so such a body is refused.""" + back at zero at the end of step 2. Such a body is not geometry; + since December 2, 2026 it has unknowns in the step where a + component is open (`bk_rigid_lid_reopened`, + tests/test_rigid_unknowns.py, against FEBio).""" _, model = load("bk_rigid_lid_top_level") # Without the fixed condition of step 2, Rw is open there. freed = copy.deepcopy(model) @@ -364,9 +372,10 @@ def test_a_component_opened_when_a_step_condition_ends(self): self.assertNotIn("lid", motions) self.assertIn("Rw is neither fixed nor prescribed in step 2", problems["lid"]) self.assertIn("open since 'twist' of step 1 ended", problems["lid"]) + self.assertIn("lid", rigid_parts.rigid_unknowns(freed)) report = inspect_model(freed) - self.assertFalse(report.runnable) - self.assertIn("FEBio leaves it open whatever a condition of the model says", report.table()) + self.assertTrue(report.runnable, report.table()) + self.assertIn("open components, step 1: none; step 2: Rw", report.table()) # A condition of step 1 on a component that a prescribed condition # of the model holds: when step 1 ends, FEBio opens it as well. twice = copy.deepcopy(model) diff --git a/tests/test_rigid_unknowns.py b/tests/test_rigid_unknowns.py new file mode 100644 index 0000000..462dfe6 --- /dev/null +++ b/tests/test_rigid_unknowns.py @@ -0,0 +1,390 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 The FEBio-Warp-Python Authors +# SPDX-License-Identifier: Apache-2.0 +"""Rigid bodies with unknowns (constraints/rigid_system.py, rigid_parts.py). + +A rigid body with a component the input leaves open is solved for: two +entries per body in the field table, its nodes as dependent entries +(tests/test_reduction.py has the elimination on its own), FEBio's update of +the rotation. What is covered: + + suite four inputs of FEBio's test suite that need nothing else, with + FEBio's strategy: its time steps, its iterations and the norm + of its solution, which counts the unknowns of the bodies. + `ri01`: a body free in all six components, tied to an + elastic block (boundary condition `rigid`) and loaded by a + `rigid_force`. `ri03`: two translations open, a translation + and a rotation prescribed, two rotations fixed. `ri07`: a + knee, the patella free to turn about one axis between two + bodies the input moves, held by springs. `co42`: the peel + input of the sticky contact as published, with its pulling + body free in x and in the rotation about y (until now it was + compared with those two held, tests/test_sticky.py) + two paths `bk_rigid_lid_moved` and `bk_rigid_lid_top_level` of + references/small_problems, whose lid the input moves in all + six components, run with the lid given entries by force: + the same displacements as on the path of November 29, where + the lid is geometry, and so FEBio's. This holds FEBio's + rules for a prescribed rotation (all three known; a fixed + one returns to zero), `relative`, and the first right-hand + side of a time step on the new path + rotations the quaternion functions against closed forms, and the + composition of increments through the Cayley transform + a free body equilibrium of a body under a load: what the elastic block + gives the nodes of the body is the load, as force and as + moment about the center of mass + reading the entries of a body in the field table, its nodes as + dependent entries, the coverage report naming the open + components per step; and what is refused: a prescribed + rotation beside an open one (an error in FEBio), a dynamic + step after a static one, the load types that are not built, + gradients + +Tolerances. Suite: observed on CPU and on a Tesla P100 (December 2, 2026) +steps and iterations equal to FEBio's and the norm within 4e-13 (`ri01`), +2e-12 (`ri03`), 3e-13 (`ri07`), 5e-13 (`co42`); compared at 1e-10, and at +1e-6 where a count is not FEBio's, with the slack on counts of +tests/test_febio_suite.py. Two paths: the lid's nodes are written from the +body on one path and prescribed on the other, and the elastic block is +solved to the same tolerance from the same iterates: observed 3e-15 and +below, compared at 1e-11 of the largest displacement. Rotations: 1e-14. +Equilibrium: the residual Newton leaves, compared at 1e-7 of the load. +""" + +import copy +import json +import os +import pathlib +import unittest +from unittest import mock + +import numpy as np +import warp as wp +from support import DEVICE, full_tier, setUpModule, tearDownModule # noqa: F401 (device for the module) + +from febio_warp.analysis.choices import FEBIO_4_13 +from febio_warp.analysis.steps import build_system, inspect_model, run +from febio_warp.constraints import rigid_parts +from febio_warp.constraints import rigid_system as rs +from febio_warp.discretization.fields import DEPENDENT, FIXED, FREE, PRESCRIBED, build_field_table +from febio_warp.io import read_feb +from febio_warp.model import Record +from febio_warp.sensitivity.adjoint import adjoint_solve + +CASES = pathlib.Path(__file__).resolve().parents[1] / "references" / "small_problems" +SUITE = os.environ.get("FEBIO_TEST_SUITE") + +NORM = 1e-10 +OTHER_PATH = 1e-6 +ITERATION_SLACK = 2 +TWO_PATHS = 1e-11 +ROTATION = 1e-14 +QUICK = ("ri01", "co42") +FULL = ("ri03", "ri07") + + +def suite(name): + return read_feb(pathlib.Path(SUITE) / "Verify" / f"{name}.feb") + + +def small(case): + ref = json.loads((CASES / "febio" / f"{case}.json").read_text()) + return read_feb(CASES / ref["input"]) + + +@unittest.skipUnless(SUITE, "set FEBIO_TEST_SUITE to a checkout of the FEBio test suite") +class SuiteTests(unittest.TestCase): + def compare(self, names): + from test_febio_suite import stored_values + + stored = stored_values() + for name in names: + with self.subTest(problem=name): + model = suite(name) + report = inspect_model(model) + self.assertTrue(report.runnable, report.table()) + self.assertIn("rigid body with unknowns", report.table()) + system = build_system(model, device=DEVICE, **FEBIO_4_13) + results, states = run(system, keep_states=True) + steps, iterations, norm = stored[name] + mine = sum(s.iterations for s in results.states[1:]) + self.assertEqual(len(results.states) - 1, steps) + self.assertLessEqual(abs(mine - iterations), ITERATION_SLACK) + # FEBio's norm counts the equations of the bodies; here they + # are the free components of the entries of the bodies. + found = float(np.linalg.norm(states[-1].u.numpy()[system.fields.bc == FREE])) + same_path = mine == iterations and not DEVICE.startswith("cuda") + self.assertLess(abs(found - norm) / norm, NORM if same_path else OTHER_PATH) + + def test_a_free_body_and_the_peel_as_published(self): + self.compare(QUICK) + + @full_tier("a body with prescribed and open components, and a knee; about 20 s on CPU or on a GPU") + def test_prescribed_beside_open_components_and_a_knee(self): + self.compare(FULL) + + def test_a_load_is_carried_by_the_block(self): + """`ri01` at its end: the forces the elastic block puts on the nodes + of the body add up to minus the load, 0.05 in x at that time, and + their moment about the center of mass is zero, since the load is a + force at the center.""" + model = suite("ri01") + system = build_system(model, device=DEVICE, **FEBIO_4_13) + _, states = run(system, keep_states=True) + state = states[-1] + system.update(state) + R = wp.zeros(system.n, dtype=wp.vec3d, device=DEVICE) + for term in system.terms: + if term is not system.rigid: + term.residual(state, None, R) + system.reduction.carry_residual(R) + body = system.fields.bodies[0] + load = body.unknown.loads[0] + applied = load.value * model.load_controller(load.load_controller).value(state.time) + force, moment = R.numpy()[body.displacement], R.numpy()[body.rotation] + self.assertGreater(abs(applied), 1e-3) + np.testing.assert_allclose(force, [-applied, 0.0, 0.0], atol=1e-7 * abs(applied)) + np.testing.assert_allclose(moment, 0.0, atol=1e-7 * abs(applied)) + + +class FebioAgreementTests(unittest.TestCase): + """Three inputs of references/small_problems against FEBio 4.13.0 + (e4df3f8): each is a stored input of a body moved by the input with one + rigid condition taken out, so that a component is open. + + bk_rigid_lid_released the lid moved through four steps, without the + displacement of step 2: z is prescribed + before that step and after it, and open in + it, where the lid goes to where the block + pushes it + bk_rigid_lid_reopened the rotation about z prescribed in step 1 by + a condition of the step, over a fixed + condition of the model: FEBio opens it when + the step ends, and in step 2 the lid turns + back + bk_rigid_tied_free nodes of the block tied to a body whose + rotation about z is open + + Displacement of every node of the block and stress of its elements at + every state: observed 2.7e-12, 2.2e-12 and 4.3e-12 of the largest value + on CPU (the log has 12 digits), compared at 1e-9. The iterations are + FEBio's 52, 30 and 26, compared within 2. + """ + + def against_febio(self, case, febio_iterations): + ref = json.loads((CASES / "febio" / f"{case}.json").read_text()) + model = read_feb(CASES / ref["input"]) + self.assertIn("lid", rigid_parts.rigid_unknowns(model)) + results = run(build_system(model, device=DEVICE)) + nodes_rec = next(r for r in ref["records"] if "ux" in r["data"]) + stress_rec = next(r for r in ref["records"] if "sx" in r["data"]) + logged_u, logged_s = np.array(nodes_rec["values"]), np.array(stress_rec["values"]) + u = np.stack([s.displacement[model.mesh.node_index(nodes_rec["items"])] for s in results.states]) + stress = np.stack([s.stress["Part1"] for s in results.states]) + self.assertEqual(u.shape, logged_u.shape) + self.assertEqual(stress.shape, logged_s.shape) + self.assertLess(abs(u - logged_u).max() / abs(logged_u).max(), 1e-9) + self.assertLess(abs(stress - logged_s).max() / abs(logged_s).max(), 1e-9) + self.assertLessEqual(abs(sum(s.iterations for s in results.states[1:]) - febio_iterations), 2) + return results + + def test_a_component_open_in_one_step_of_four(self): + results = self.against_febio("bk_rigid_lid_released", 52) + self.assertEqual(len(results.states), 21) # four steps of five time steps + + def test_a_rotation_opened_when_a_step_condition_ends(self): + self.against_febio("bk_rigid_lid_reopened", 30) + + def test_tied_nodes_and_a_free_rotation(self): + self.against_febio("bk_rigid_tied_free", 26) + + +def as_unknowns(reading): + """The reading of rigid_parts with every body that the input moves given + unknowns instead: a body whose six components are all prescribed or + fixed, on the path of a body with open ones.""" + + def changed(model): + motions, problems, unknowns = reading(model) + for name, motion in list(motions.items()): + if not motion.moves: + continue + center = motion.center if motion.center is not None else rigid_parts.volume_centroid(model, name) + unknowns[name] = rigid_parts.RigidUnknown(name, center, motion.steps, motion.ends) + del motions[name] + return motions, problems, unknowns + + return changed + + +class TwoPathTests(unittest.TestCase): + def both(self, case): + model = small(case) + geometry = run(build_system(model, device=DEVICE)) + with mock.patch.object(rigid_parts, "_reading", as_unknowns(rigid_parts._reading)): + system = build_system(small(case), device=DEVICE) + self.assertEqual(len(system.fields.bodies), 1) + # Nothing is open: the body's six components are prescribed or + # fixed in every step, and its nodes are dependent entries. + body = system.fields.bodies[0] + for step in system.fields.steps: + self.assertFalse((step.bc[[body.displacement, body.rotation]] == FREE).any()) + self.assertTrue((step.bc[body.node_entries] == DEPENDENT).all()) + unknowns = run(system) + self.assertEqual(len(unknowns.states), len(geometry.states)) + largest = max(abs(s.displacement).max() for s in geometry.states) + for a, b in zip(unknowns.states, geometry.states): + np.testing.assert_allclose(a.displacement, b.displacement, atol=TWO_PATHS * largest) + self.assertLessEqual(abs(a.iterations - b.iterations), 1) + + def test_moved_through_four_steps(self): + self.both("bk_rigid_lid_moved") + + def test_conditions_of_the_model_beside_those_of_steps(self): + self.both("bk_rigid_lid_top_level") + + +class RotationTests(unittest.TestCase): + def test_quaternions_as_febio_has_them(self): + quarter = rs.quat_of_vector(np.array([0.0, 0.0, 0.5 * np.pi])) + np.testing.assert_allclose(rs.rotation_matrix(quarter) @ [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], atol=ROTATION) + np.testing.assert_allclose(rs.quat_of_vector(np.zeros(3)), rs.IDENTITY, atol=0) + # a b is b first, then a. + about_x = rs.quat_of_vector(np.array([0.5 * np.pi, 0.0, 0.0])) + both = rs.rotation_matrix(rs.quat_multiply(about_x, quarter)) + np.testing.assert_allclose(both, rs.rotation_matrix(about_x) @ rs.rotation_matrix(quarter), atol=ROTATION) + # The rotation vector comes back, with an angle in [0, 2 pi]: a + # turn of 1.5 pi about z stays 1.5 pi about z. + v = np.array([0.3, -0.2, 0.5]) + np.testing.assert_allclose(rs.rotation_vector(rs.quat_of_vector(v)), v, atol=ROTATION) + far = np.array([0.0, 0.0, 1.5 * np.pi]) + np.testing.assert_allclose(rs.rotation_vector(rs.quat_of_vector(far)), far, atol=ROTATION) + + def test_the_cayley_transform(self): + """q(v) turns by 2 atan(|v| / 2) about v, and `cayley_vector` is its + inverse. Two increments about one axis compose to the Cayley vector + of the sum of their angles, not to the sum of the vectors.""" + v = np.array([0.4, 0.1, -0.3]) + q = rs.quat_of_cayley(v) + self.assertAlmostEqual(rs.quat_angle(q), 2.0 * np.arctan(0.5 * np.linalg.norm(v)), delta=ROTATION) + np.testing.assert_allclose(rs.cayley_vector(q), v, atol=ROTATION) + a, b = np.array([0.0, 0.0, 0.6]), np.array([0.0, 0.0, 0.8]) + total = rs.cayley_vector(rs.quat_multiply(rs.quat_of_cayley(a), rs.quat_of_cayley(b))) + angle = 2.0 * np.arctan(0.3) + 2.0 * np.arctan(0.4) + np.testing.assert_allclose(total, [0.0, 0.0, 2.0 * np.tan(0.5 * angle)], atol=ROTATION) + self.assertGreater(abs(total[2] - 1.4), 0.1) + + +class ReadingTests(unittest.TestCase): + def freed(self): + """`bk_rigid_tied_free`: `bk_rigid_tied_nodes` with the rotation of + its body about z left open.""" + return small("bk_rigid_tied_free") + + def test_entries_and_dependent_nodes(self): + model = self.freed() + self.assertEqual(list(rigid_parts.rigid_unknowns(model)), ["lid"]) + self.assertIn("lid", rigid_parts.rigid_motions(model)[1]) # not geometry + table = build_field_table(model) + nodes = len(model.mesh.nodes) + body = table.bodies[0] + self.assertEqual((body.displacement, body.rotation, table.count), (nodes, nodes + 1, nodes + 2)) + # The nodes of the part and the nodes tied to the body. + tied = model.mesh.node_set_indices("top") + self.assertTrue(np.isin(tied, body.nodes).all()) + self.assertGreater(len(body.nodes), len(tied)) + self.assertTrue((table.bc[body.node_entries] == DEPENDENT).all()) + np.testing.assert_array_equal(table.bc[body.displacement], [PRESCRIBED, FIXED, FIXED]) + np.testing.assert_array_equal(table.bc[body.rotation], [FIXED, FIXED, FREE]) + + def test_the_report_names_the_open_components(self): + model = self.freed() + report = inspect_model(model) + self.assertTrue(report.runnable, report.table()) + table = report.table() + self.assertIn("rigid body with unknowns: its nodes follow it; open components, step 1: Rw", table) + self.assertIn("nodes follow rigid body 'lid', which has unknowns", table) + self.assertIn("the body has unknowns; open components, step 1: Rw", table) + # It runs, and the lid turns: nothing holds its rotation about z + # but the block it is tied to. + system = build_system(model, device=DEVICE) + _, states = run(system, keep_states=True) + rotation = states[-1].u.numpy()[system.fields.bodies[0].rotation] + np.testing.assert_allclose(rotation[:2], 0.0, atol=0) + self.assertGreater(abs(rotation[2]), 1e-4) + + def test_what_is_refused(self): + # A prescribed rotation beside an open one: an error in FEBio. + model = small("bk_rigid_lid_moved") + section = next(r for r in model.steps[0].other if r.tag == "Rigid") + fixed = next(c for c in section.children if c.type == rigid_parts.FIXED) + self.assertEqual(int(fixed.get("Ru_dof")), 1) + fixed.set("Ru_dof", 0) + self.assertNotIn("lid", rigid_parts.rigid_unknowns(model)) + self.assertIn("cannot mix prescribed and free components", rigid_parts.rigid_motions(model)[1]["lid"]) + self.assertFalse(inspect_model(model).runnable) + # Static and dynamic steps in one run: FEBio gives a rigid body + # velocities in a static step, which are not built + # (tests/test_rigid_dynamics.py has the dynamic steps that run). + model = small("bk_rigid_lid_released") + model.steps[2].control.set("analysis", "DYNAMIC") + self.assertIn("lid", rigid_parts.rigid_unknowns(model)) + report = inspect_model(model) + self.assertFalse(report.runnable) + self.assertIn("static and dynamic steps in one run with a rigid body", report.table()) + # A dynamic step with alpha_f below 1 (rhoi 0.5). + damped = small("rb_spin") + damped.steps[0].control.child("solver").children.append(Record("rhoi", {}, 0.5)) + report = inspect_model(damped) + self.assertFalse(report.runnable) + self.assertIn("with a rigid body that has open components: built for alpha_f = 1", report.table()) + # Load types that are not built, and a load that is not read. + base = self.freed() + for extra, reason in ( + ([Record("load_type", {}, "FOLLOW")], "load_type FOLLOW is not built"), + ([Record("load_type", {}, "TARGET")], "load_type TARGET is not built"), + ([Record("relative", {}, 1)], "relative is not built"), + ): + model = copy.deepcopy(base) + load = Record( + "rigid_load", + {"name": "push", "type": "rigid_moment"}, + None, + [Record("rb", {}, "lid"), Record("dof", {}, "Rw"), Record("value", {"lc": "1"}, 0.1), *extra], + ) + next(r for r in model.other_sections if r.tag == "Rigid").children.append(load) + self.assertNotIn("lid", rigid_parts.rigid_unknowns(model)) + self.assertIn(reason, rigid_parts.rigid_motions(model)[1]["lid"]) + self.assertFalse(inspect_model(model).runnable) + + def test_a_moment_turns_the_body(self): + """A `rigid_moment` about z on the freed lid turns it further the + same way a positive moment should: the rotation about z grows with + the moment.""" + angles = [] + for value in (0.0, 0.02): + model = self.freed() + load = Record( + "rigid_load", + {"name": "turn", "type": "rigid_moment"}, + None, + [Record("rb", {}, "lid"), Record("dof", {}, "Rw"), Record("value", {"lc": "1"}, value)], + ) + next(r for r in model.other_sections if r.tag == "Rigid").children.append(load) + report = inspect_model(model) + self.assertTrue(report.runnable, report.table()) + self.assertIn("load_type LOAD", report.table()) + system = build_system(model, device=DEVICE) + _, states = run(system, keep_states=True) + angles.append(states[-1].u.numpy()[system.fields.bodies[0].rotation][2]) + self.assertGreater(angles[1] - angles[0], 1e-4) + + def test_gradients_are_refused(self): + system = build_system(self.freed(), device=DEVICE) + _, states = run(system, keep_states=True) + self.assertFalse(system.rigid.adjoint_ready) + with self.assertRaisesRegex(NotImplementedError, "dependent entries"): + adjoint_solve(system, states[-1], np.zeros((system.n, 3))) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_sticky.py b/tests/test_sticky.py index 34e1061..5811237 100644 --- a/tests/test_sticky.py +++ b/tests/test_sticky.py @@ -665,17 +665,18 @@ def lost(m): self.assertTrue(inspect_model(model).runnable) # the penalty's is read def test_a_primary_on_a_body_that_can_move_is_refused(self): - """What keeps the suite's three sticky inputs from running as - published, without the suite: with the arm's prescribed rotation - taken out, that component is free, the body is an unknown of FEBio's - rigid solver, and the report refuses the input for it.""" + """With the arm's prescribed rotation taken out, that component is + free and the body has unknowns (since December 2, 2026 such a body + is solved for, constraints/rigid_system.py). The sticky surface is + then on a body with unknowns, and the report refuses the interface: + its stiffness is not carried to the body yet.""" _, model = load("st_grasp_tri3") changed = copy.deepcopy(model) section = next(r for r in changed.other_sections if r.tag == "Rigid") section.children = [c for c in section.children if c.name != "turn"] report = inspect_model(changed) self.assertFalse(report.runnable) - self.assertIn("a rigid body that can move", report.table()) + self.assertIn("which has unknowns: the contact stiffness is not carried to the body yet", report.table()) def test_the_adjoint_refuses_the_term(self): _, model = load("st_grasp_tri3") @@ -686,31 +687,35 @@ def test_the_adjoint_refuses_the_term(self): @unittest.skipUnless(SUITE, "set FEBIO_TEST_SUITE to a checkout of the FEBio test suite") def test_suite_sticky_inputs(self): """The three sticky inputs of the FEBio test suite (commit 986005f) - as published. Each is refused for the rigid body that pulls, which - is free in two components. In co42 that is all: its sticky interface - (with `max_traction` and `snap_tol`) and the node set tied to the - body are read. sh30 also joins shells to solid elements, and sh31 - has quad8 facets and quadratic elements.""" - for name, sticky_reads, others in ( - ("co42", True, ()), - ("sh30", True, ("shell attached to solid elements",)), - ("sh31", False, ("shell attached to solid elements", "hex20", "quad8")), + as published. In each the rigid body that pulls is free in two + components. Until December 2, 2026 that refused all three; since + then such a body has unknowns (constraints/rigid_system.py), and + co42 runs as published and agrees with FEBio + (tests/test_rigid_unknowns.py): its sticky interface (with + `max_traction` and `snap_tol`) and the node set tied to the body are + read. sh30 also joins shells to solid elements, and sh31 has quad8 + facets and quadratic elements; both tie nodes of a shell part.""" + for name, runs, sticky_reads, others in ( + ("co42", True, True, ()), + ("sh30", False, True, ("shell attached to solid elements",)), + ("sh31", False, False, ("shell attached to solid elements", "hex20", "quad8")), ): with self.subTest(name): model = read_feb(pathlib.Path(SUITE) / "Verify" / f"{name}.feb") report = inspect_model(model) - self.assertFalse(report.runnable) + self.assertEqual(report.runnable, runs, report.table()) row = next(e for e in report.entries if e.febio_name == "sticky") if sticky_reads: self.assertIn("released above max_traction", row.note) else: self.assertIn("primary facets other than tri3 and quad4", row.note) table = report.table() - self.assertIn("a rigid body that can move", table) for other in others: self.assertIn(other, table) tied = next(e for e in report.entries if e.febio_name == "rigid" and e.category == "boundary condition") - self.assertIn("can move under the loads", tied.note) + if runs: + self.assertIn("rigid body with unknowns", table) + self.assertIn("which has unknowns", tied.note) # With the body held nothing else of co42 is refused. model = held(read_feb(pathlib.Path(SUITE) / "Verify" / "co42.feb")) report = inspect_model(model)