pycba.section.SectionEI#
- class SectionEI(segments=None)[source]#
Bases:
objectSegment-built, piecewise variable flexural rigidity over one span.
A member assigned a
SectionEIis analysed with the flexibility-integrated non-prismatic element (seepycba.beam.Beam.k_nonprismatic()), whose flexibility integrals are evaluated piece-by-piece between consecutive breakpoints. When the section is a single constant segment the element reproduces the closed-form prismatic stiffness to machine precision.The section is built by chaining
add_segment()calls, or in one line by passing a list of segment specs to the constructor.Construct a (possibly empty) variable-rigidity section.
- Parameters:
segments (
Optional[Sequence]) – When given, each spec is added in turn viaadd_segment(). A spec is either a tuple/list(seg_type, x, ei)or(seg_type, x, ei, degree), or a mapping with keysseg_type,x,eiand optionallydegree. WhenNone(the default) an empty section is created, to be populated by chainedadd_segment()calls.
Examples
One-liner (a straight haunch then a flat soffit):
sec = SectionEI([ ("linear", [0.0, 3.0], [3.0e5, 1.2e5]), ("const", [3.0, 9.0], 1.2e5), ("linear", [9.0, 12.0], [1.2e5, 3.0e5]), ])
Chained:
sec = (SectionEI() .add_segment("linear", [0.0, 3.0], [3.0e5, 1.2e5]) .add_segment("const", [3.0, 9.0], 1.2e5) .add_segment("linear", [9.0, 12.0], [1.2e5, 3.0e5]))
Methods
Append a contiguous segment to the section.
Plot
EI(x)over the whole span as an input-verification figure.Check that the section's total coverage equals the span length
L.Attributes
sorted span-local breakpoint coordinates.
TruewhenEI(x)is a single constant value.total covered length (running end of the last segment).
the internal linear/poly pieces.
- add_segment(seg_type, x, ei, degree=None)[source]#
Append a contiguous segment to the section.
- Parameters:
seg_type (
str) –The kind of variation over the segment:
'const'– constantEIover[x0, x1].x = [x0, x1]andeiis a scalar.'linear'– a single linear piece.x = [x0, x1]andei = [ei0, ei1].'pwl'– piecewise-linear.x = [x0, x1, ..., xn]withn >= 2strictly-increasing stations andeiof the same length;n - 1linear pieces with kinks at the interior stations. ('linear'is the two-point case;'const'a flat run.)'poly'– a single polynomial piece over[x[0], x[-1]].eiis either a list of sample values (same length asx; a polynomial of orderdegree, defaultlen(x) - 1, is fitted) or acallableei(x_local)evaluated in the span-local physical coordinate (in which casedegreesets the integration order, default 8).
x (
Sequence[float]) – The segment station(s) in span-local physical coordinates, strictly increasing.ei (
Union[float,Sequence[float],Callable]) – The rigidity value(s) or, for'poly', optionally a callable.degree (
Optional[int]) – Polynomial order for a'poly'segment. Ignored for the other types.
- Returns:
self, to allow chaining.- Return type:
- Raises:
ValueError – If
seg_typeis unknown;xis not strictly increasing; the lengths ofxandeiare inconsistent; any rigidity is non-positive; or the segment is not contiguous with the running end of the section (a gap or an overlap).
- property length: float#
total covered length (running end of the last segment).
- Type:
float
- property breakpoints: ndarray#
sorted span-local breakpoint coordinates.
Includes the section start, every segment join, and every interior
pwlkink. Coincident coordinates (e.g. a step at a join) are collapsed to a single value. The flexibility integration is split at these breakpoints so kinks and steps are captured exactly.- Type:
np.ndarray
- property pieces: list#
the internal linear/poly pieces.
- Type:
list of
_Piece
- property is_constant: bool#
TruewhenEI(x)is a single constant value.- Type:
bool
- validate_length(L, atol=1e-06)[source]#
Check that the section’s total coverage equals the span length
L.- Parameters:
L (
float) – The span length the section is attached to.atol (
float) – Absolute tolerance (scaled byL). Default1e-6.
- Raises:
ValueError – If the section is empty, or its coverage differs from
L.- Return type:
None
- __call__(x)[source]#
Evaluate
EI(x)piecewise in the span-local physical coordinate.At an internal step (coincident
xwith differingEI) the value of the piece ending atxis returned (left-continuous); at the section ends the natural end piece is used.- Parameters:
x (
Union[float,ndarray]) – Span-local position(s).- Returns:
The rigidity
EI(x).- Return type:
Union[float,ndarray]
- plot(ax=None, n=200, show_breakpoints=True, annotate=True, **kwargs)[source]#
Plot
EI(x)over the whole span as an input-verification figure.The rigidity is drawn piece by piece over each piece’s own
[x0, x1]interval, so the curve faithfully reflects what was entered:a kink (e.g. a
pwlinterior station, or a join where the slope changes) renders as a slope change with no break, because adjacent pieces share the boundary value;a step (a coincident
xcarrying a differentEIacross a join) renders as a genuine discontinuity – the left piece ends at its value and the right piece starts at its own value, with no spurious vertical line connecting them. A thin dashed connector is drawn at each such step purely to make the jump easy to read.
Constant pieces appear flat, linear pieces straight, and polynomial pieces are sampled smoothly.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axes to draw into. When
None(default) a new figure and axes are created withplt.subplots(**kwargs); otherwise the given axes (and its parent figure) are used and**kwargsis ignored.n (
int) – Total number of sample points distributed across the pieces (proportional to each piece’s length, at least 2 per piece). Used for smooth sampling of polynomial pieces; default200.show_breakpoints (
bool) – WhenTrue(default) mark the segment boundaries andpwlkinks atbreakpointswith light vertical gridlines.annotate (
bool) – WhenTrue(default) lightly label each piece with its degree (const/linear/poly) via a legend, so the entered variation can be confirmed at a glance.**kwargs – Passed to
matplotlib.pyplot.subplots()whenax is None.
- Returns:
The figure and axes, matching the PyCBA plotting convention.
plt.show()is never called.- Return type:
(matplotlib.figure.Figure, matplotlib.axes.Axes)