Mechanics¶
Feature |
Static Analysis (Beam) |
Dynamics (RigidBody) |
|---|---|---|
Primary Goal |
Deformation & Stress |
Motion & Forces |
Key Variable |
$I$ (Inertia) |
$m$ (Mass) |
Governing Law |
Euler-Bernoulli Theory |
Newton’s Second Law ($F=ma$) |
Main Output |
Deflection ($delta$) |
Acceleration ($a$) |
—
Static Analysis¶
- class mechlab.mechanics.SimplySupportedBeam(length, load, E, I)[source]
Bases:
objectSimply supported beam with center point load.
Calculates reactions, maximum moment, and maximum deflection for a beam with a concentrated load at the center.
- L
Beam length (m)
- P
Point load at center (N)
- E
Young’s modulus (Pa)
- I
Second moment of area (m^4)
- RA
Reaction at support A (N)
- RB
Reaction at support B (N)
- M_max
Maximum bending moment (N·m)
- delta_max
Maximum deflection (m)
Example
>>> beam = SimplySupportedBeam(5, 1000, 200e9, 1e-4) >>> beam.M_max 1250.0
- class mechlab.mechanics.Beam(L, E, I)[source]
Bases:
objectCantilever 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...
- max_deflection(load)[source]
Calculate maximum deflection: δ = PL³/(3EI).
- class mechlab.mechanics.StaticsParticle(forces)[source]
Bases:
objectRepresents 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
Stress Analysis¶
- class mechlab.mechanics.StressState(sx, sy, txy, unit='MPa')[source]
Bases:
objectPlane stress state (σx, σy, τxy) with optional unit conversion.
- property sigma_x: float
- property sigma_y: float
- property tau_xy: float
- property sx: float
- property sy: float
- property txy: float
- principal(unit=None)[source]
Return principal stresses (σ1, σ2).
- principal_stresses(unit=None)[source]
Alias for
principal().
- max_shear(unit=None)[source]
Return maximum shear stress (τmax).
- von_mises(unit=None)[source]
Return Von Mises equivalent stress.
- class mechlab.mechanics.StressTensor3D(components)[source]
Bases:
objectRepresents 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]])
- class mechlab.mechanics.StressTransform[source]
Bases:
objectSymbolic 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.PrincipalStresses[source]
Bases:
objectCalculate 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]
Rigid Body Dynamics¶
- class mechlab.mechanics.RigidBody(mass, position)[source]
Bases:
objectRepresents a point mass for dynamic calculations.
Example
>>> body = RigidBody(mass=10, position=(0, 0, 0)) >>> body.weight() 98.1
- class mechlab.mechanics.DynamicsOfParticle(position, velocity, mass)[source]
Bases:
objectRepresents a particle in dynamics.
Tracks position, velocity, and mass for kinematic calculations.
Example
>>> p = DynamicsOfParticle(position=(0, 0, 0), velocity=(5, 0, 0), mass=10) >>> p.kinetic_energy() 125.0
- Parameters: