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, Planefrom xfea.meshing import MeshingSettingsfrom xfea.model import ElasticIsotropic, Model, Part, ShellSectionfrom 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"Ask before solving
Section titled “Ask before solving”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. |
Reading a field
Section titled “Reading a field”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 mmlowest = disp.get_min_result("z") # the most negative z of the fieldprint(lowest.z, lowest.location.xyz) # the value, and the node it is atprint(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 allget_result_at(location)takes a node for a field at nodes, an element for a field at elements.get_max_resultandget_min_resultcompare signed values of one stored component: a downward deflection isget_min_result("z").resultsis the list of all the results, one per node or integration point.- A result gives its components (
.x,.y,.z,.xx…), its.vectorand.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).
Stresses
Section titled “Stresses”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) # MPaprint(peak.s11, peak.s22, peak.s12) # components, 1 2 3 for x y zprint(peak.smax, peak.smin) # the largest and the smallest principal stressprint(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.
Increments of a nonlinear step
Section titled “Increments of a nonlinear step”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 oneprint(disp.get_result_at(tip, frame=1).z)Keeping the answer with the run
Section titled “Keeping the answer with the run”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.
Reading results again later
Section titled “Reading results again later”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))Frequencies and buckling factors
Section titled “Frequencies and buckling factors”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