Results#

class planestress.post.results.Results(plane_stress: PlaneStress, u: npt.NDArray[np.float64])[source]#

Bases: object

Class for plane-stress results.

Parameters:
  • plane_stress (PlaneStress) – PlaneStress analysis object used to generate these results.

  • u (npt.NDArray[np.float64]) – Displacement vector.

Variables:
  • ux (npt.NDArray[np.float64]) – x component of the displacement vector.

  • uy (npt.NDArray[np.float64]) – y component of the displacement vector.

  • uxy (npt.NDArray[np.float64]) – Resultant component of the displacement vector.

  • f (npt.NDArray[np.float64]) – Calculated nodal forces.

  • element_results (list[ElementResults]) – List of ElementResults objects.

Methods

calculate_element_results

Calculates and stores the element results in self.element_results.

calculate_node_forces

Calculates and stores the resultant nodal forces.

get_nodal_stresses

Calculates the nodal stresses.

partition_displacements

Partitions the u vector into x and y displacement vectors.

plot_deformed_shape

Plots the deformed shape.

plot_displacement_contour

Plots the displacement contours.

plot_stress

Plots the stress contours.

Attributes

plane_stress

u

ux

uy

uxy

f

element_results

partition_displacements() None[source]#

Partitions the u vector into x and y displacement vectors.

calculate_node_forces(k: ndarray[Any, dtype[float64]]) None[source]#

Calculates and stores the resultant nodal forces.

Parameters:

k (ndarray[Any, dtype[float64]]) – Original stiffness matrix (before modification).

calculate_element_results(elements: list[FiniteElement]) None[source]#

Calculates and stores the element results in self.element_results.

Parameters:

elements (list[FiniteElement]) – List of FiniteElement objects used during the analysis.

get_nodal_stresses(agg_func: ~typing.Callable[[list[float]], float] = <function average>) ndarray[Any, dtype[float64]][source]#

Calculates the nodal stresses.

Parameters:

agg_func (Callable[[list[float]], float]) – A function that aggregates the stresses if the point is shared by several elements. The function must receive a list of stresses and return a single stress. Defaults to np.average.

Returns:

A numpy.ndarray of the nodal stresses of size [n x 3], where n is the number of nodes in the mesh. The columns consist of the three stress components, (sig_xx, sig_yy, sig_xy).

Return type:

ndarray[Any, dtype[float64]]

plot_displacement_contour(direction: str, **kwargs: Any) Axes[source]#

Plots the displacement contours.

Parameters:
  • direction (str) – Displacement field to plot. May be either "x", "y" or "xy" (resultant displacement).

  • kwargs (Any) – See below.

Keyword Arguments:
  • title (str) – Plot title. Defaults to "Displacement Contours [{direction}]".

  • contours (bool) – If set to True, plots contour lines. Defaults to False.

  • colormap (str) – Matplotlib color map, see https://matplotlib.org/stable/tutorials/colors/colormaps.html for more detail. Defaults to "coolwarm".

  • normalize (bool) – If set to True, CenteredNorm is used to scale the colormap, if set to False, the default linear scaling is used. CenteredNorm effectively places the centre of the colormap at zero displacement. Defaults to True.

  • colorbar_format (str) – Number formatting string for displacements, see https://docs.python.org/3/library/string.html. Defaults to "{x:.4e}", i.e. exponential format with 4 decimal places.

  • colorbar_label (str) – Colorbar label. Defaults to "Displacement".

  • alpha (float) – Transparency of the mesh outlines, \(0 \leq \alpha \leq 1\). Defaults to 0.2.

  • kwargs (dict[str, Any]) – Other keyword arguments are passed to plotting_context().

Raises:

ValueError – If the value for direction is not valid.

Returns:

Matplotlib axes object.

Return type:

Axes

Example

TODO.

plot_deformed_shape(displacement_scale: float, **kwargs: Any) Axes[source]#

Plots the deformed shape.

Parameters:
  • displacement_scale (float) – Displacement scale.

  • kwargs (Any) – See below.

Keyword Arguments:
  • title (str) – Plot title. Defaults to "Deformed Shape [ds = {displacement_scale}]".

  • alpha (float) – Transparency of the mesh outlines, \(0 \leq \alpha \leq 1\). Defaults to 0.8.

  • kwargs (dict[str, Any]) – Other keyword arguments are passed to plotting_context().

Returns:

Matplotlib axes object.

Return type:

Axes

Example

TODO.

plot_stress(stress: str, **kwargs: Any) Axes[source]#

Plots the stress contours.

Parameters:
  • stress (str) – Stress value to plot. See below for list of values.

  • kwargs (Any) – See below.

Keyword Arguments:
  • title (str) – Plot title. Defaults to "Stress Contour Plot - {stress}".

  • contours (bool) – If set to True, plots contour lines. Defaults to False.

  • colormap (str) – Matplotlib color map, see https://matplotlib.org/stable/tutorials/colors/colormaps.html for more detail. Defaults to "coolwarm".

  • stress_limits (tuple[float, float] | None) – Custom colorbar stress limits (sig_min, sig_max). Values outside these limits will appear as white. Defaults to None.

  • normalize (bool) – If set to True, CenteredNorm is used to scale the colormap, if set to False, the default linear scaling is used. CenteredNorm effectively places the centre of the colormap at zero displacement. Defaults to True.

  • colorbar_format (str) – Number formatting string for stresses, see https://docs.python.org/3/library/string.html. Defaults to "{x:.4e}", i.e. exponential format with 4 decimal places.

  • colorbar_label (str) – Colorbar label. Defaults to "Stress".

  • alpha (float) – Transparency of the mesh outlines, \(0 \leq \alpha \leq 1\). Defaults to 0.2.

  • agg_func (Callable[[list[float]], float]) – A function that aggregates the stresses if the point is shared by several elements. The function must receive a list of stresses and return a single stress. Defaults to np.average.

  • kwargs (dict[str, Any]) – Other keyword arguments are passed to plotting_context().

Raises:

ValueError – If the value for stress is not valid.

Returns:

Matplotlib axes object.

Return type:

Axes

Example

TODO.

Stress plotting options

Below is a list of the acceptable values for stress:

  • "xx" - stress in the x direction.

  • "yy" - stress in the y direction.

  • "xy" - shear stress in the xy direction.

  • TODO others.