femethods.elements module

The elements module contains finite element classes

Currently the only element that is defined is a beam element.

class femethods.elements.Beam(length: float, loads: List[Load], reactions: List[Reaction], E: float = 1, Ixx: float = 1)[source]

Bases: femethods.core._base_elements.BeamElement

A Beam defines a beam element for analysis

A beam element is a slender member that is subjected to transverse loading. It is assumed to have homogeneous properties, with a constant cross-section.

Parameters:
  • length (float) – the length of a beam. This is the total length of the beam, this is not the length of the meshed element. This must be a float that is greater than 0.
  • loads (list) – list of load elements
  • reactions (list) – list of reactions acting on the beam
  • E (float, optional) – Young’s modulus of the beam in units of \(\frac{force}{length^2}\). Defaults to 1. The \(force\) units used here are the same units that are used in the input forces, and calculated reaction forces. The \(length\) unit must be the same as the area moment of inertia (Ixx) and the beam length units.
  • Ixx (float, optional) – Area moment of inertia of the beam. Defaults to 1. This is constant (constant cross-sectional area) along the length of the beam. This is in units of \(length^4\). This must be the same length unit of Young’s modulus (E) and the beam length.
bending_stress(x, dx=1, c=1)[source]

returns the bending stress at global coordinate x

Deprecated since version 0.1.7a1: calculate bending stress as Beam.moment(x) * c / Ixx

deflection(x: float) → numpy.float64[source]

Calculate deflection of the beam at location x

Parameters:

x (float | int) – location along the length of the beam where deflection should be calculated.

Returns:

deflection of the beam in units of the beam length

Return type:

float

Raises:
  • ValueError – when the \(0\leq x \leq length\) is False
  • TypeError – when x cannot be converted to a float
moment(x: float, dx: float = 1e-05, order: int = 9) → numpy.float64[source]

Calculate the moment at location x

Calculate the moment in the beam at the global x value by taking the second derivative of the deflection curve.

\(M(x) = E \cdot Ixx \cdot \frac{d^2 v(x)}{dx^2}\)

where \(M\) is the moment, \(E\) is Young’s modulus and \(Ixx\) is the area moment of inertia.

Parameters:
  • x (int) – location along the beam where moment is calculated
  • dx (float, optional) – spacing. Default is 1e-5
  • order (int, optional) – number of points to use, must be odd. Default is 9
Returns:

moment in beam at location x

Return type:

float

Raises:
  • ValueError – when the \(0\leq x \leq length\) is False
  • TypeError – when x cannot be converted to a float

For more information on the parameters, see the scipy.misc.derivative documentation.

plot(n=250, title='Beam Analysis', diagrams=None, diagram_labels=None, **kwargs)[source]

Plot the deflection, moment, and shear along the length of the beam

The plot method will create a matplotlib.pyplot figure with the deflection, moment, and shear diagrams along the length of the beam element. Which of these diagrams, and their order may be customized.

Parameters:
  • n (int) – defaults to 250: number of data-points to use in plots
  • title (str) – title on top of plot
  • diagrams (tuple) – defaults to (‘shear’, ‘moment’, ‘deflection’) tuple of diagrams to plot. All values in tuple must be strings, and one of the defaults. Valid values are ('shear', 'moment', 'deflection')
  • diagram_labels (tuple) – y-axis labels for subplots. Must have the same length as diagrams
Returns:

Tuple of matplotlib.pyplot figure and list of axes in the form (figure, axes)

Return type:

tuple

Note

The plot method will create the figure handle, but will not automatically show the figure. To show the figure use Beam.show() or matplotlib.pyplot.show()

Changed in version 0.1.7a1: Removed bending_stress parameter

Changed in version 0.1.7a1: Added diagrams and diagram_labels parameters

shear(x: float, dx: float = 0.01, order: int = 5) → numpy.float64[source]

Calculate the shear force in the beam at location x

Calculate the shear in the beam at the global x value by taking the third derivative of the deflection curve.

\(V(x) = E \cdot Ixx \cdot \frac{d^3 v(x)}{dx^3}\)

where \(V\) is the shear force, \(E\) is Young’s modulus and \(Ixx\) is the area moment of inertia.

Parameters:
  • x (int) – location along the beam where moment is calculated
  • dx (float, optional) – spacing. Default is 0.01
  • order (int, optional) – number of points to use, must be odd. Default is 5
Returns:

moment in beam at location x

Return type:

float

Raises:
  • ValueError – when the \(0\leq x \leq length\) is False
  • TypeError – when x cannot be converted to a float

For more information on the parameters, see the scipy.misc.derivative documentation.

static show(*args, **kwargs) → None[source]

Wrapper function for showing matplotlib figure

This method gives direct access to the matplotlib.pyplot.show function so the calling code is not required to import matplotlib directly just to show the plots

Parameters:args/kwargs – args and kwargs are passed directly to matplotlib.pyplot.show