pycba.section.SectionEI#

class SectionEI(segments=None)[source]#

Bases: object

Segment-built, piecewise variable flexural rigidity over one span.

A member assigned a SectionEI is analysed with the flexibility-integrated non-prismatic element (see pycba.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 via add_segment(). A spec is either a tuple/list (seg_type, x, ei) or (seg_type, x, ei, degree), or a mapping with keys seg_type, x, ei and optionally degree. When None (the default) an empty section is created, to be populated by chained add_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

add_segment

Append a contiguous segment to the section.

plot

Plot EI(x) over the whole span as an input-verification figure.

validate_length

Check that the section's total coverage equals the span length L.

Attributes

breakpoints

sorted span-local breakpoint coordinates.

is_constant

True when EI(x) is a single constant value.

length

total covered length (running end of the last segment).

pieces

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' – constant EI over [x0, x1]. x = [x0, x1] and ei is a scalar.

    • 'linear' – a single linear piece. x = [x0, x1] and ei = [ei0, ei1].

    • 'pwl' – piecewise-linear. x = [x0, x1, ..., xn] with n >= 2 strictly-increasing stations and ei of the same length; n - 1 linear 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]]. ei is either a list of sample values (same length as x; a polynomial of order degree, default len(x) - 1, is fitted) or a callable ei(x_local) evaluated in the span-local physical coordinate (in which case degree sets 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:

SectionEI

Raises:

ValueError – If seg_type is unknown; x is not strictly increasing; the lengths of x and ei are 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 pwl kink. 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#

True when EI(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 by L). Default 1e-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 x with differing EI) the value of the piece ending at x is 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 pwl interior 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 x carrying a different EI across 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 with plt.subplots(**kwargs); otherwise the given axes (and its parent figure) are used and **kwargs is 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; default 200.

  • show_breakpoints (bool) – When True (default) mark the segment boundaries and pwl kinks at breakpoints with light vertical gridlines.

  • annotate (bool) – When True (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() when ax 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)