A cantilever beam
Demonstrates a one-dimensional model with section properties and a static step. The solver, database, mesher, and viewer are resolved from the default stack.

The model before it is solved: its parts, supports (red) and loads (blue).
![The result: the deformed shape coloured by displacement (magnitude [mm])](/examples/getting-started/02-beam-results.webp)
The deformed shape, 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
The script
Section titled “The script”examples/scripts/01_getting_started/02_beam.py. Run it from the repository with uv run python examples/scripts/01_getting_started/02_beam.py, or, with xfea-examples installed, xfea-examples run 01_getting_started/02_beam.py.
from xfea.problem import Problemfrom xfea.problem import StaticStepfrom xfea.results import DisplacementFieldResultsfrom xfea.results import ReactionFieldResults
from xfea_examples import out_dirfrom xfea_examples.models import cantilever_beam_modelfrom xfea_examples import show_viewer
tip_load = -1_000 # [N] downward tip force
model, _, tip_nodes, material, section, length = cantilever_beam_model( name="getting_started_beam")
problem = model.add_problem(Problem(name="beam_problem"))step = problem.add_step(StaticStep(name="service"))step.add_uniform_forcefield(nodes=tip_nodes, z=tip_load, load_case="service")
disp = DisplacementFieldResults()react = ReactionFieldResults()step.add_field_outputs([disp, react])
problem.analyse_and_extract(path=out_dir(model.name), verbose=True)
delta_fea = disp.get_min_result("z").z# z-bending with orientation [0,1,0] is about the strong axis: Ixx = w·h³/12delta_ref = (tip_load * length**3) / (3.0 * material.E * section.Ixx)
print(f"Tip deflection from analysis: {delta_fea}")print(f"Euler-Bernoulli reference deflection: {delta_ref}")
show_viewer(model, results={disp: "x"}, units="mm")© 2026 Francesco Ranaudo · Text and pictures CC BY 4.0 · Code Elastic License 2.0 · how to reuse them