A buckling step
Demonstrates a multi-step problem where a preload step is followed by an eigenvalue buckling analysis.

The model before it is solved: its parts, supports (red) and loads (blue).
Open in 3D turn it, cut it, hide parts: in xfea's viewer, in your browser
The script
Section titled “The script”examples/scripts/02_core_concepts/steps/buckling_analysis.py. Run it from the repository with uv run python examples/scripts/02_core_concepts/steps/buckling_analysis.py, or, with xfea-examples installed, xfea-examples run 02_core_concepts/steps/buckling_analysis.py.
import math
from xfea.model import GeneralBCfrom xfea.model.fields import MechanicalBCFieldfrom xfea.problem import BucklingAnalysisfrom xfea.problem import Problemfrom xfea.problem import StaticStepfrom xfea.results import DisplacementFieldResultsfrom xfea_examples import out_dirfrom xfea_examples.models import cantilever_beam_model
beam_width = 15 # [mm] square cross-section widthbeam_height = 15 # [mm] square cross-section heightaxial_load = -1_000 # [N] axial compressive preload
model, part, tip_nodes, material, section, length = cantilever_beam_model( name="buckling_analysis", width=beam_width, height=beam_height, fix_start=False,)
start_nodes = part.nodes.subgroup(lambda node: abs(node.x - 0.0) <= 1e-6)end_nodes = tip_nodeshinge = GeneralBC(x=False, y=True, z=True, xx=True, yy=False, zz=False)model.add_pin_bc(nodes=start_nodes)model.add_bcs(MechanicalBCField(distribution=end_nodes, condition=hinge))
problem = model.add_problem(Problem(name="buckling_problem"))preload = problem.add_step(StaticStep(name="preload"))preload.add_uniform_forcefield(nodes=end_nodes, x=axial_load, load_case="service")preload.add_field_outputs([DisplacementFieldResults()])
buckling = BucklingAnalysis(modes=3, algorithm="SUBSPACE")problem.add_step(buckling)
problem.analyse_and_extract(path=out_dir(model.name), verbose=True)
critical_load = (math.pi**2) * material.E * section.Iyy / (length**2)print(f"Reference Euler load: {critical_load}")print(f"First buckling factor: {buckling.mode_factor(1)}")© 2026 Francesco Ranaudo · Text and pictures CC BY 4.0 · Code Elastic License 2.0 · how to reuse them