Skip to content

A small multi-part analysis

Demonstrates a stacked two-part model, interface detection, a static load case, and result extraction with the generic workflow APIs.

The model before it is solved: parts, supports and loads

The model before it is solved: its parts, supports (red) and loads (blue).

The result: the model coloured by displacement (magnitude [mm])

The model, coloured by displacement (magnitude [mm]), in xfea’s 3D viewer.

Open in 3D turn it, cut it, pick any field: in xfea's viewer, in your browser

examples/scripts/03_workflows/assemblies/multi_part_analysis.py. Run it from the repository with uv run python examples/scripts/03_workflows/assemblies/multi_part_analysis.py, or, with xfea-examples installed, xfea-examples run 03_workflows/assemblies/multi_part_analysis.py.

from xfea.geometry import Translation
from xfea.model import HardContactFrictionPenalty
from xfea.problem import Problem
from xfea.problem import StaticStep
from xfea.results import DisplacementFieldResults
from xfea_examples import out_dir
from xfea_examples.models import solid_box_model
from xfea_examples import show_viewer
stack_offset_z = 1000 # [mm] vertical offset between blocks
mu = 0.9 # [-] friction coefficient
g = 9810 # [mm/s^2] gravity
total_top_load = -5_000 # [N] total downward load on top face (-5 kN)
model, part_a, _, _, _ = solid_box_model(name="multi_part_analysis", element_order=2)
part_b = part_a.copy()
part_b.name = "upper_block"
part_b.transform(Translation.from_vector([0, 0, stack_offset_z]))
model.add_part(part_b)
contact = HardContactFrictionPenalty(mu=mu, tol=1)
model.detect_interfaces(behavior=contact, method="face_intersection")
base_nodes = part_a.find_nodes_on_plane(part_a.bottom_plane)
model.add_fix_bc(base_nodes)
problem = model.add_problem(Problem(name="assembly_problem"))
step = problem.add_step(StaticStep(name="service", nlgeom=True))
top_nodes = part_b.find_nodes_on_plane(part_b.top_plane)
step.add_gravity_field(g=g)
step.add_uniform_forcefield(nodes=top_nodes, z=total_top_load / max(1, len(top_nodes)), load_case="service")
disp = DisplacementFieldResults()
step.add_field_outputs([disp])
problem.analyse_and_extract(path=out_dir(model.name), verbose=True, cpus=8)
print(f"Interfaces detected: {len(model.interfaces)}")
print(f"Maximum vertical displacement: {disp.get_min_result('z').z}")
show_viewer(model=model)

© 2026 Francesco Ranaudo · Text and pictures CC BY 4.0 · Code Elastic License 2.0 · how to reuse them