Skip to content

Results

Results are asked for before the solve and read after it, through field objects: one for displacements, one for reactions, one for stresses. They read from a results database, the same whatever solver produced the results.

The samples on this page continue from one model, a concrete slab 4 m by 2 m and 200 mm thick, held along one short edge and loaded by 5 kN/m²:

from pathlib import Path
from xfea.geometry import Mesh, Plane
from xfea.meshing import MeshingSettings
from xfea.model import ElasticIsotropic, Model, Part, ShellSection
from xfea.problem import Problem, StaticStep
model = Model(name="slab")
concrete = ElasticIsotropic(E=30_000, v=0.2, density=2.4e-9) # N, mm, t
slab = model.add_part(Part(name="slab"))
slab.base_geometry = Mesh.from_meshgrid(4000, 8, 2000, 4)
slab.mesh(
settings=MeshingSettings(max=250, element_order=2),
section=ShellSection(t=200, material=concrete),
)
model.add_fix_bc(nodes=slab.find_nodes_on_plane(Plane((0, 0, 0), (1, 0, 0))))
problem = model.add_problem(Problem(name="pressure"))
step = problem.add_step(StaticStep(name="load"))
step.add_surface_field(surface=slab.find_faces_on_plane(Plane((0, 0, 0), (0, 0, 1))), z=-0.005)
output = Path(__file__).resolve().parent / "output"
from xfea.results import DisplacementFieldResults, ReactionFieldResults, StressFieldResults
disp = DisplacementFieldResults()
react = ReactionFieldResults()
stress = StressFieldResults()
step.add_field_outputs([disp, react, stress])
problem.analyse_and_extract(path=output)
Field What it holds
DisplacementFieldResults Displacements at the nodes: x, y, z, and rotations xx, yy, zz in radians.
ReactionFieldResults Reactions at the nodes the supports hold: forces x, y, z, moments xx, yy, zz.
StressFieldResults Stresses at each integration point of each element: s11 to s23.
TemperatureFieldResults Temperatures at the nodes: T.
ContactForcesFieldResults The total normal and tangential force on each contact pair.
ContactStressFieldResults Contact pressure, opening, slip and shear at the nodes in contact.
tip = slab.find_closest_nodes_to_point((4000, 1000, 0), single=True)
print(disp.get_result_at(tip).z) # the result at one node: -7.84 mm
lowest = disp.get_min_result("z") # the most negative z of the field
print(lowest.z, lowest.location.xyz) # the value, and the node it is at
print(disp.get_max_result("z").z) # the most positive z
print(sum(r.z for r in react.results)) # every result of the field: 40000 N in all
  • get_result_at(location) takes a node for a field at nodes, an element for a field at elements.
  • get_max_result and get_min_result compare signed values of one stored component: a downward deflection is get_min_result("z").
  • results is the list of all the results, one per node or integration point.
  • A result gives its components (.x, .y, .z, .xx …), its .vector and .magnitude, and its .location.

By hand, as a cantilever strip, the tip moves between 7.7 mm (a plate, with 1 − ν²) and 8.0 mm (a beam).

A stress result is at one integration point of one element, in the global axes. Besides the six components it gives the usual derived values:

peak = max(stress.results, key=lambda r: r.von_mises_stress)
print(peak.von_mises_stress) # MPa
print(peak.s11, peak.s22, peak.s12) # components, 1 2 3 for x y z
print(peak.smax, peak.smin) # the largest and the smallest principal stress
print(peak.location.name, peak.ip) # the element, and the integration point
  • Integration points are inside the elements, also through a shell’s thickness: the values there are below the stress at the surface.
  • A large gap between the mean and the peak stress is a concentration or a singularity. Stress at a sharp corner depends on the mesh: refine twice and compare.
  • Von Mises is for ductile metals; principal stresses for brittle materials.

A nonlinear step keeps a frame per increment. Everything above reads the end of the step unless told otherwise:

print(disp.frames_in_step()) # [1] here: a linear step has one
print(disp.get_result_at(tip, frame=1).z)
problem.record_result("tip deflection", disp.get_result_at(tip).z, "mm", note="L/250 = 16 mm")

The value goes in the run record (run.json) and the report (report.html) in the problem’s folder, beside the convergence, the model’s make-up and the warnings: one page to open or to send.

A solve saves the model as model.pkl next to the problem’s folder, and the results stay in the problem’s database, pressure/pressure-results.db. Another script reopens both without solving again:

from xfea.model import Model
again = Model.from_pickle(output / "model.pkl")
last_step = list(again.problems)[0].steps[-1]
for field in last_step.field_outputs:
print(type(field).__name__, len(field.results))

A modal or buckling step gives its results itself: modal.frequencies, modal.mode_shape(1), buckling.mode_factor(1). See Analysis.

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