Beam (Pint)
fpc.beam
beam.py - a unit-aware Beam dataclass.
This module shows two ideas working together:
* ``@dataclass`` models a real-world *thing* (a rectangular beam) as an
object with named fields, instead of passing a fistful of loose floats to
every function.
* Pint quantities give every field and result physical units, so the math
is self-checking and the answers come back in whatever unit you ask for.
Build one like this::
from fpc.units import Q_
from fpc.beam import Beam
beam = Beam(
length=Q_(2.0, "m"),
width=Q_(50, "mm"),
height=Q_(100, "mm"),
modulus=Q_(200, "GPa"),
)
print(beam.moment_of_inertia.to("mm**4"))
print(beam.max_deflection_point_load(load=Q_(5, "kN")).to("mm"))
The properties (area, moment of inertia, mass) are computed on demand from the dimensions, so they always stay consistent with the beam's geometry.
Beam
dataclass
A straight beam with a rectangular cross-section, in physical units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
Quantity
|
span of the beam (a |
required |
width
|
Quantity
|
cross-section width b ( |
required |
height
|
Quantity
|
cross-section height h ( |
required |
modulus
|
Quantity
|
Young's modulus E (a |
(lambda: STEEL_MODULUS)()
|
density
|
Quantity
|
material density ( |
(lambda: STEEL_DENSITY)()
|
Source code in fpc/beam.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
area
property
Cross-sectional area A = width * height.
moment_of_inertia
property
Second moment of area about the bending (strong) axis: I = b*h^3/12.
This is the property that resists bending; a taller section (bigger h) is dramatically stiffer because h is cubed.
mass
property
Total mass = density * volume = density * area * length.
__post_init__()
Validate units and signs right after the object is created.
Catching a bad input here (e.g. a time passed where a length belongs, or a negative width) gives a clear error instead of a wrong number later on.
Source code in fpc/beam.py
65 66 67 68 69 70 71 72 73 74 75 76 | |
max_deflection_point_load(*, load)
Maximum deflection of a simply supported beam with a central load.
delta = P * L^3 / (48 * E * I). The result carries length units, so
call .to("mm") on it to read it off in millimetres.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
load
|
central point load P (a |
required |
Returns:
| Type | Description |
|---|---|
|
maximum deflection (a |
Source code in fpc/beam.py
108 109 110 111 112 113 114 115 116 117 118 119 120 | |
max_bending_stress_point_load(*, load)
Peak bending stress for a simply supported beam, central point load.
The maximum bending moment is M = PL/4 at midspan; the peak stress is sigma = Mc/I with c = h/2 (distance to the outer fibre).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
load
|
central point load P (a |
required |
Returns:
| Type | Description |
|---|---|
|
maximum bending stress (a |
Source code in fpc/beam.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
euler_buckling_load(*, end_factor=1.0)
Critical axial buckling load (Euler), about the weakest axis.
P_cr = pi^2 * E * I_min / (K*L)^2. A column buckles about whichever axis has the smaller second moment of area, so we use the minimum here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
end_factor
|
effective-length factor K (1.0 pinned-pinned, 0.5 fixed-fixed, 2.0 fixed-free), defaults to pinned-pinned |
1.0
|
Returns:
| Type | Description |
|---|---|
|
critical axial load (a |
Source code in fpc/beam.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |