This file provides guidance for Claude Code when working with this repository.
FEM is a Python toolkit for simulating acoustic radiation force excitations and shear wave propagation in soft tissue using finite element methods. It integrates with LS-DYNA, a commercial finite element solver.
# Install package in development mode
pip install -e .
# Run tests (uses pytest with parallel execution)
pytest -v tests/
# Build documentation
cd docs && make htmlfem/
├── mesh/ # Mesh generation and boundary conditions
├── dyna/ # LS-DYNA mesh/material definitions (v9.0.0+ dataclass-based)
├── post/ # Post-processing LS-DYNA output to HDF5/MAT/VTK
├── field/ # Field II acoustic simulation integration
tests/ # Pytest tests with fixture data (nodes.dyn, elems.dyn, nodout)
examples/ # Complete workflow examples
docs/ # Sphinx RST documentation
- Axial: -z direction
- Lateral: +y direction
- Elevation: -x direction
- Units: CGS (centimeters, grams, seconds)
- Node arrays:
[id, x, y, z, tc, rc]as numpy structured arrays - Element arrays:
[id, pid, n1-n8]for 8-node solid elements - Common naming:
nodeIDcoords(nic),sortedNodeIDcoords(snic) - Spatial sorting uses Fortran order ('F') for LS-DYNA compatibility
.dyn- LS-DYNA keyword input files (comma-separated,*or$prefix for comments)nodout- LS-DYNA binary node output- Output formats: HDF5 (.h5), MAT (v5), VTR/PVD (Paraview)
- Dataclass-based design with
@dataclassdecorator - Mixin pattern in
fem/dyna/:_structure.py,_constraints.py,_loads.py,_writer.py - Material hierarchy with base
Materialclass
Core: numpy, scipy, h5py, matplotlib, pyevtk Build: scikit-build, cmake (for C/SWIG acceleration in post-processing) Docs: sphinx>=7.2.0
- Generate mesh:
GenMesh.run(xyz_bounds, num_elements) - Apply boundary conditions:
bc.apply_face_bc_only(face_constraints) - Define loads:
TopLoad.generate_loads(loadtype='disp', ...) - Run LS-DYNA (external)
- Extract results:
create_disp_dat()(nodout → HDF5) - Generate visualization:
create_res_sim()(HDF5/MAT/PVD)
- GitHub Actions workflows in
.github/workflows/ python-package.yml- Runs pytest on Python 3.11docs.yml- Builds and deploys Sphinx docs to GitHub Pages