Loads
Loads belong to a step. Each of the step’s add_... methods makes a field: a load and where it acts. All of them
are in the global axes.
The samples on this page continue from one model, a steel cantilever of beam elements, 2 m long:
from pathlib import Path
from xfea.model import BeamElement, ElasticIsotropic, Model, Node, Part, RectangularSectionfrom xfea.problem import Problem, StaticStepfrom xfea.results import DisplacementFieldResults, ReactionFieldResults
model = Model(name="cantilever")steel = ElasticIsotropic(E=210_000, v=0.3, density=7.85e-9) # N, mm, tsection = RectangularSection(w=50, h=100, material=steel)
part = model.add_part(Part(name="beam"))nodes = [part.add_node(Node(xyz=[i * 100.0, 0, 0])) for i in range(21)]beams = [ part.add_element(BeamElement(nodes=[a, b], section=section, orientation=[0, 1, 0])) for a, b in zip(nodes, nodes[1:])]model.add_fix_bc(nodes=[nodes[0]])
output = Path(__file__).resolve().parent / "output"
problem = model.add_problem(Problem(name="loads"))step = problem.add_step(StaticStep(name="service"))Forces and moments at nodes
Section titled “Forces and moments at nodes”step.add_uniform_forcefield(nodes=[nodes[-1]], z=-1000) # N at each node givenx, y, z are forces and xx, yy, zz moments about those axes. Only nodes with rotations, those of beams
and shells, take a moment.
Loads along beams
Section titled “Loads along beams”step.add_uniform_line_load(distribution=beams, z=-2.0) # N/mm along each elementGive the components x, y, z, or a magnitude with a direction. The load goes to the nodes as its
work-equivalent end forces and moments, so several elements per member still matter: the solver’s beam element has
its own error.
Self-weight
Section titled “Self-weight”step.add_gravity_field() # g = 9810 mm/s² along -z, on every elementEach element weighs its mass times g, so the materials need a density. For a model in metres pass g=9.81; for
another direction, a unit vector in x, y, z; for some elements only, distribution=part.elements.
Solving, and checking the total
Section titled “Solving, and checking the total”disp = DisplacementFieldResults()react = ReactionFieldResults()step.add_field_outputs([disp, react])problem.analyse_and_extract(path=output)
applied = 1000 + 2.0 * 2000 + 7.85e-9 * (50 * 100 * 2000) * 9810 # tip force, line load, weightprint(sum(r.z for r in react.results), applied) # 5770 N bothThe sum of the reactions against the loads you meant to apply is the first check of any analysis.
Pressure on faces
Section titled “Pressure on faces”A surface load acts on the faces of shell and solid elements, found by where they are:
from xfea.geometry import Mesh, Planefrom xfea.meshing import MeshingSettingsfrom xfea.model import ShellSection
slab_model = Model(name="slab")concrete = ElasticIsotropic(E=30_000, v=0.2, density=2.4e-9)slab = slab_model.add_part(Part(name="slab"))slab.base_geometry = Mesh.from_meshgrid(4000, 8, 2000, 4) # 4 m by 2 m, in the xy planeslab.mesh( settings=MeshingSettings(max=250, element_order=2), section=ShellSection(t=200, material=concrete),)slab_model.add_fix_bc(nodes=slab.find_nodes_on_plane(Plane((0, 0, 0), (1, 0, 0))))
pressure = slab_model.add_problem(Problem(name="pressure"))load = pressure.add_step(StaticStep(name="load"))faces = slab.find_faces_on_plane(Plane((0, 0, 0), (0, 0, 1)))load.add_surface_field(surface=faces, z=-0.005) # MPa: 5 kN/m² down
slab_react = ReactionFieldResults()load.add_field_outputs([slab_react])pressure.analyse_and_extract(path=output)print(sum(r.z for r in slab_react.results)) # 40000 N = 0.005 MPa x 4000 mm x 2000 mmA surface load keeps one global direction on every face. On a curved surface, such as the inside of a pipe, it is not a normal pressure: load such a surface in flat patches, each with its own direction.
Imposed displacements
Section titled “Imposed displacements”A step can also move nodes: a support that settles, a jack.
settlement = model.add_problem(Problem(name="settlement"))move = settlement.add_step(StaticStep(name="settle"))move.add_uniform_displacement_field(nodes=[nodes[-1]], z=-5.0) # the tip pushed 5 mm down
support = ReactionFieldResults()move.add_field_outputs([support])settlement.analyse_and_extract(path=output)print(support.get_result_at(nodes[0]).z) # the force it takes: 1646 NEach component is None (free), True (held at zero) or a number: a length for x, y, z, an angle in radians
for xx, yy, zz.
© 2026 Francesco Ranaudo · Text and pictures CC BY 4.0 · Code Elastic License 2.0 · how to reuse them