Mechanics

Statics: equilibrium analysis of rigid bodies and structures.

Provides:
  • Beam: Cantilever beam analysis

  • StaticsParticle: Particle equilibrium

  • StressTensor3D: 3D stress tensor

  • StressTransform: Symbolic stress transformation

  • PrincipalStresses: Principal stress calculation

class mechlab.mechanics.statics.StaticsParticle(forces)[source]

Bases: object

Represents a particle in statics.

Calculates resultant force, inclination angles, and unit vectors.

Example

>>> F1 = (10, 20, 0)
>>> F2 = (5, -10, 15)
>>> p = StaticsParticle([F1, F2])
>>> p.resultant()
Matrix([[15], [10], [15]])
Parameters:

forces (list)

resultant()[source]

Calculate and return the resultant force vector.

Return type:

MutableDenseMatrix

inclination()[source]

Calculate inclination angles of the resultant force.

Return type:

tuple

unit_vector()[source]

Calculate the unit vector of the resultant force.

Return type:

tuple

class mechlab.mechanics.statics.Beam(L, E, I)[source]

Bases: object

Cantilever beam with end load.

Calculates maximum deflection and slope.

Example

>>> beam = Beam(L=2, E=200e9, I=1e-6)
>>> beam.max_deflection(load=1000)
0.0133...
Parameters:
max_deflection(load)[source]

Calculate maximum deflection: δ = PL³/(3EI).

Parameters:

load (float)

Return type:

float

slope(x)[source]

Calculate slope at position x (simplified).

Parameters:

x (float)

Return type:

float

class mechlab.mechanics.statics.StressTensor3D(components)[source]

Bases: object

Represents a 3D stress tensor.

The stress tensor is a symmetric 3x3 matrix:
[[σxx, τxy, τxz],

[τxy, σyy, τyz], [τxz, τyz, σzz]]

Example

>>> tensor = StressTensor3D([[100, 25, 0], [25, 50, 0], [0, 0, 0]])
>>> tensor.components
array([[100,  25,   0],
       [ 25,  50,   0],
       [  0,   0,   0]])
Parameters:

components (list[list[float]])

trace()[source]

Return the trace (sum of diagonal elements).

Return type:

float

hydrostatic()[source]

Return hydrostatic stress: σ_h = (σxx + σyy + σzz) / 3.

Return type:

float

class mechlab.mechanics.statics.StressTransform[source]

Bases: object

Symbolic stress tensor transformation in 3D.

Uses direction cosines (l, m, n) to transform stress tensor from one coordinate system to another.

Example

>>> transform = StressTransform()
>>> result = transform.transform()  # Returns symbolic L * σ * L^T
transform()[source]

Compute transformed stress tensor: σ’ = L * σ * L^T.

Return type:

MutableDenseMatrix

class mechlab.mechanics.statics.PrincipalStresses[source]

Bases: object

Calculate principal stresses from stress tensor.

Principal stresses are the eigenvalues of the stress tensor, representing normal stresses on planes with no shear stress.

Example

>>> tensor = [[100, 25, 0], [25, 50, 0], [0, 0, 0]]
>>> PrincipalStresses.calculate(tensor)
[110.355..., 39.644..., 0.0]
static calculate(stress_tensor)[source]

Calculate principal stresses (eigenvalues) sorted in descending order.

Parameters:

stress_tensor (list[list[float]]) – 3x3 stress tensor

Returns:

List of principal stresses [σ1, σ2, σ3] where σ1 >= σ2 >= σ3

Return type:

list[float]