Skip to content

About

Focused port of GPU-accelerated, differentiable biomechanics in warp-python

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

FEBio-Warp-Python

GPU-accelerated, differentiable finite element mechanics for cardiovascular simulation, written in Python on Warp and built in concert with the FEBio team to support the P3 CHD project. The formulations follow FEBio, but deviate where it makes sense for warp. The architecture is designed for the GPU and for differentiation, follows the development conventions of Warp, and is meant to work with Newton, 3D Slicer, SlicerHeart and SlicerSimVascular.

FEBio-Warp is intended to stand next to FEBio, not to replace it. FEBio remains the place for broad constitutive modeling and general biomechanics. FEBio-Warp targets a focused set of applications where speed and gradients matter.

Project status

Early stage, nothing released. As of November 27, 2026, first implementations of the model and FEBio input and output, materials, contact, and a run path from a model to a result are on main. They agree with FEBio on single elements and small meshes, on CPU and on a GPU. No application input runs end to end yet, and interfaces will change.

Try it

uv sync --extra dev                                                        # environment with Warp
uv run -m warp_febio inspect references/single_element/hex8_pressure.feb   # what the input needs, and whether it can run
uv run -m warp_febio run references/single_element/hex8_pressure.feb -o hex8_pressure.xplt
uv run examples/run_path/basic_example.py                                  # the run path step by step, with gradients

inspect lists every feature of a FEBio input by its FEBio name and says whether FEBio-Warp implements it. run solves the input and writes a FEBio plot file (.xplt). The example prints each stage, compares the result with FEBio, and ends with adjoint gradients. Add --device cuda:0 to run, or cuda:0 after the example, to use a GPU. Install has the details.

Driving applications

The first targets set the scope. Capabilities are added because one of these needs them.

Application Needs
Atrioventricular valve closure and repair Quadrilateral shell leaflets, fiber-reinforced hyperelastic tissue, chordae as trusses or springs, pressure loading, leaflet self-contact
Self-expanding nitinol devices (transcatheter pulmonary valve replacement, septal occluders) Beam frames, nitinol material, device-to-vessel contact, hyperelastic vessel wall
Patch and material verification problems Small problems with known or FEBio reference solutions, used to verify each component

Design and status

flowchart LR
    feb([".feb"]):::done --> model["Model and I/O"]:::done
    model --> system
    subgraph system["System on the device"]
        direction TB
        mat["Materials"]:::done
        elem["Solids and shells<br/>hex8, tet4, quad4"]:::done
        loads["Pressure, nodal loads, mass damping,<br/>fixed and prescribed displacements"]:::done
        pot["Contact potential<br/>on its own"]:::done
        chord["Trusses and springs<br/>for chordae"]:::done
        inrun["Contact in a run<br/>first template"]:::done
        beams["Beams, three-field solid,<br/>constraints"]:::todo
    end
    system --> run
    subgraph run["Run path"]
        direction TB
        static["One static or dynamic step, Newton,<br/>iterative or direct linear solve"]:::done
        dyn["Several steps, quasi-Newton,<br/>preconditioning"]:::todo
    end
    run --> results([".xplt, VTKHDF"]):::done
    run -.-> grad["Gradients through<br/>one equilibrium solve"]:::done
    grad -.-> traj["Gradients over steps"]:::todo
    febio["FEBio, same input"] -.->|verification| results
    classDef done fill:#d8f0e1,stroke:#1a7f47,color:#0b3d20
    classDef todo fill:#f6f6f6,stroke:#8a8a8a,color:#444444,stroke-dasharray:5 4
Loading

Green boxes work today. Dashed boxes have a design note and no code yet.

The table gives the same picture by area. "Works today" means code on main, tested on CPU and on a GPU, and compared with FEBio where a counterpart exists. It is a first implementation, not a settled design: the run path in particular is a template, and each design note ends with decision points that are still open.

Area Package Works today Still to do Design notes and diagrams
Model, input and output model/, io/ One model object for what a FEBio input defines. Reads and writes .feb (all 538 FEBio test suite inputs read and write back equal), reads and writes .xplt, writes VTKHDF, exchanges meshes with 3D Slicer. A coverage report and the command line say whether an input can run Registry of plot and log variables; log file output Model and I/O (diagram, decisions), output (diagram)
Materials materials/ FEBio's material structure, compiled into one Warp kernel per material tree, with gradients. Neo-Hookean, isotropic elastic, isotropic Lee-Sacks, HGO (unconstrained and uncoupled), solid mixtures; spring and linear truss laws for chordae. Effective-modulus nitinol: the device model of Zelonis et al. (arXiv 2507.06337) and Maheshwari et al. (J Mech Behav Biomed Mater 2026, arXiv 2601.05410), an elastic frame whose Young's modulus steps between compression and release Under redesign after review. Superelastic nitinol: only a shell of the interface exists (a simple uniaxial law, not for device results), and FEBio has no counterpart to verify against. Ogden, tangent_scale, per-element material axes Materials (diagram, decisions)
Contact contact/ Point-based contact potential: pair search on the device, force, tangent, gradients; reads FEBio's contact potential block. Tested on its own. First template of the potential as a term of a run, with its tangent in a matrix of its own. Small cases and FEBio suite problem co62 agree with FEBio, and the open mitral input closes end to end, within half a percent of FEBio's stresses over FEBio's run A smooth tier for gradients, contact in the adjoint, objectives for coaptation; FEBio's element-pair form of w_tol; activation by step; sliding, sticky and tied contact Contact (diagram, decisions), contact in a run (diagram)
Elements elements/ hex8 and tet4 solids, quad4 shell. Draft: two-node trusses (regular and tension-only) and springs for chordae, with gradients of chord tension and the chord force on a node set (a papillary tip) as an output. Consistent mass for hex8, quad4 shell and truss. Tested on CPU and on a GPU Trusses in a dynamic run against FEBio (suite dy16, dy17); tet4 mass; three-field solid, penta6, tri3 shell; beams Trusses and springs (diagram), elements (diagram)
Unknowns and assembly discretization/, assembly/ Unknowns by (node, variable); full assembly of residual and tangent into a block sparse matrix with a fixed pattern Timing on a GPU at application size Run path (diagram, decisions), assembly
Loads and constraints loads/, constraints/ Follower pressure; nodal loads; mass damping on a whole part; fixed and prescribed displacements. With one step, loads written inside the step Constant body force; mass damping on part of a part; activation by step; normal-displacement and multipoint constraints Dynamics, constraints (diagram)
Solvers solvers/ Full Newton with FEBio's line search; Warp's CG, BiCGSTAB and GMRES on the device; a dense direct solve for checks and a sparse LU on the host; optionally NVIDIA cuDSS on the device (through nvmath-python, not a dependency), which took a shell patch from 20 s to 2 s Quasi-Newton (BFGS), FEBio's tangent_scale, preconditioning for shells; the transpose solve from cuDSS factors for the adjoint Run path (one Newton iteration), linear solve (diagram)
Analysis analysis/ One static step, or one implicit dynamic step series as FEBio's solid solver takes it (alpha_f = 1: the defaults, rhoi 0 or -1), with FEBio's automatic time stepper alpha_f below 1; several steps Run path, dynamics (one dynamic step)
Sensitivity sensitivity/ Adjoint gradients through one equilibrium solve or one dynamic step, also with self-contact (smooth contact tier), checked against finite differences and a closed form Gradients over steps and trajectories; gradients with respect to contact parameters Sensitivity (diagram)
Verification tests/, references/ Stored FEBio references for material points, single elements, small meshes and 22 small problems; agreement to about 1e-12. Two dynamic cases, two contact cases and a shell patch on chord springs (static and dynamic) agree with FEBio. Tests in a quick and a full tier, on CPU and on a GPU A runner for FEBio test suite problems; the application inputs Verification (diagram, decisions)

Where to read more:

Testing uses the FEBio test suite first, then the open models in the FEBio model repository user projects, with small generated inputs only where neither has a case that fits.

Relation to FEBio's structure

The package layout under src/warp_febio/ follows FEBio's separation of concerns.

FEBio-Warp FEBio counterpart
mesh/, discretization/ FECore mesh, degrees of freedom, element traits
elements/ FEBioMech domains
materials/ FEBioMech materials
loads/, constraints/, contact/ FEBioMech loads, constraints and contact interfaces
assembly/, solvers/ FECore solver interfaces, NumCore linear solvers
analysis/ FECore analysis steps
io/ FEBioXML, FEBioPlot
sensitivity/ Added here

Contributing

Large new sections start as a design note in docs/design/: a template of the approach and its open decisions, for discussion before and alongside the code. Exploratory work is welcome and belongs in pilots/ until it has been designed, reviewed and verified against FEBio. See CONTRIBUTING.md.

Pilot work

The initial prototypes were contributed by @aslanseda9: an explicit membrane patch solver, Lee-Sacks and neo-Hookean material-point functions, and a solid elasticity check built on warp.fem. They were written to explore the approach, not as verified implementations, and each one lists what it does and does not establish. They remain available and runnable in pilots/ and at the pilot-2026-11 tag. They are not maintained and are not a dependency of the package.

The FEBio inputs and results assembled during the pilot phase are kept in references/febio/. They will be reviewed for inclusion in the verification harness and should not be read as verified benchmarks until then.

Install

The project uses uv for environments and Ruff for linting and formatting, as Warp does.

uv sync --extra dev
uv run -m unittest discover -s tests -v                                  # quick tier, CPU, about 15 s
WARP_FEBIO_TEST_DEVICE=cuda:0 uv run -m unittest discover -s tests -v    # the same on a GPU
WARP_FEBIO_TEST_LEVEL=full uv run -m unittest discover -s tests -v       # full tier, before merging

The tests run on CPU or on a GPU and come in two tiers; see CONTRIBUTING.

uv sync creates .venv with the versions recorded in uv.lock. The dev extra installs everything the tests use, including Warp. To use the package, the warp extra (uv sync --extra warp, or pip install -e ".[warp]") installs Warp, which compiling and running a model needs. Without it, pip install -e . installs only the model and the FEBio file readers and writers (warp_febio.model, warp_febio.io), which depend on NumPy alone and can be used inside 3D Slicer.

Python 3.11 or later; 3.12 is the tested version and the one uv selects from .python-version. Warp is pinned to 1.19.0; see the Warp installation guide.

See CONTRIBUTING.md for formatting and the pre-commit hooks.

Acknowledgments

FEBio-Warp builds on the formulations, documentation and test suites of FEBio, developed at the University of Utah, and on Warp.

License

FEBio-Warp-Python is released under the Apache License 2.0, the same license as Warp. Contributions are accepted under the same terms.

FEBio is distributed separately under the MIT license. Material in this repository that derives from FEBio, including the reference inputs under references/febio/, keeps its attribution to the FEBio project.

About

Focused port of GPU-accelerated, differentiable biomechanics in warp-python

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages