Visualization

NuSA 0.4 separates visualization of the problem definition from visualization of solved results.

Problem visualization

Use nusa.visualization.plot_model() to visualize geometry, applied translational loads, and prescribed constraints:

from nusa import plot_model

ax = plot_model(model)

This function consumes a Model because it represents the finite-element problem before or after any analysis is performed.

Solved geometry

Use a completed StaticResult to plot the deformed shape:

result = model.solve()
ax = result.plot_deformed_shape(scale=10.0)

The top-level function is equivalent:

from nusa import plot_deformed_shape

ax = plot_deformed_shape(result, scale=10.0)

The plot uses the frozen geometry and displacement vector stored in the result, so it remains stable if the original model is later modified.

Scalar fields

Triangular continuum results can be plotted as nodal or element scalar fields.

Nodal field:

result.plot_nodal_field("stress_xx")

Element field:

result.plot_element_field("stress_xx")

The corresponding top-level functions are:

from nusa import plot_element_field, plot_nodal_field

plot_nodal_field(result, "stress_xx")
plot_element_field(result, "stress_xx")

Nodal field plotting uses the same recovery behavior documented in Post-processing.

Derived fields

Derived nodal fields can be plotted directly:

result.plot_nodal_field("displacement_magnitude")
result.plot_nodal_field("von_mises_stress")

Beam diagrams

Beam results expose shear-force and bending-moment diagrams based on the frozen end actions stored in the result:

result.plot_shear_diagram()
result.plot_moment_diagram()

Equivalent top-level functions are also available:

from nusa import plot_moment_diagram, plot_shear_diagram

plot_shear_diagram(result)
plot_moment_diagram(result)

Axes and Matplotlib integration

Visualization functions return Matplotlib axes, allowing callers to add titles, labels, annotations, or combine NuSA output with other plotting code:

ax = result.plot_deformed_shape(scale=20.0)
ax.set_title("Deformed shape")

Several functions also accept an existing ax argument when embedding NuSA visualizations in a larger Matplotlib workflow.

Ownership rule

A useful rule is:

plot_model(model)      -> what was defined
plot_*(result)         -> what was solved

This keeps presentation independent from mutable model solution state.

API reference

Visualization helpers for NuSA analysis results.

nusa.visualization.plot_deformed_shape(result, scale=1.0, ax=None, **kwargs)[source]

Plot frozen undeformed and deformed geometry.

nusa.visualization.plot_element_field(result, field, ax=None)[source]

Plot a scalar element field over a triangular mesh.

nusa.visualization.plot_model(model, ax=None)[source]

Plot model geometry, applied translational loads, and constraints.

nusa.visualization.plot_moment_diagram(result, ax=None)[source]

Plot the legacy beam end-moment diagram from frozen element actions.

nusa.visualization.plot_nodal_field(result, field, ax=None, recovery='average')[source]

Plot a scalar nodal field over a triangular mesh.

nusa.visualization.plot_shear_diagram(result, ax=None)[source]

Plot the legacy beam end-shear diagram from frozen element actions.