pycba.analysis.BeamAnalysis#

class BeamAnalysis(L, EI, R, LM=None, eletype=None, D=None)[source]#

Bases: object

Direct-stiffness continuous beam analyser.

Assembles the global stiffness matrix from individual span stiffness matrices, applies support boundary conditions (including elastic springs and prescribed displacements), solves the linear system for nodal displacements, and recovers support reactions and distributed load effects along each member.

After calling analyze(), results are available through beam_results:

  • beam_results.R — reactions at fully-fixed DOFs.

  • beam_results.Rs — spring forces k_s × u_i at spring DOFs.

  • beam_results.D — global nodal displacement vector.

  • beam_results.results — concatenated member load-effect arrays (x, M, V, D, R).

Construct a beam analysis object.

Parameters:
  • L (ndarray) – Span lengths. Length N for an N-span beam.

  • EI (Union[float, ndarray]) – Flexural rigidity of each span. A scalar value is applied to all spans; otherwise one value per span is required.

  • R (ndarray) –

    Nodal restraint vector, length 2(N+1). Two entries per node (vertical DOF then rotational DOF), ordered left to right:

    • -1 — fully restrained (zero displacement unless overridden by D).

    • 0 — free.

    • +k — elastic spring stiffness in consistent units.

  • LM (Optional[List[List[Union[int, float]]]]) –

    Load matrix: a list of load descriptors, each of the form [span, load_type, value, a, c]. Load types:

    1. UDL — value is load intensity; set a = c = 0.

    2. Point load — value at distance a from the span start.

    3. Partial UDL — value intensity from a for length c.

    4. Moment load — value at distance a from the span start.

  • eletype (Optional[ndarray]) –

    Element type for each span, controlling which end(s) carry moment:

    1. Fixed–fixed (default).

    2. Fixed–pinned (moment release at right end).

    3. Pinned–fixed (moment release at left end).

    4. Pinned–pinned (moment releases at both ends).

    At an internal hinge, only one of the two members meeting at that node should have a pinned end.

  • D (Optional[list]) – Prescribed-displacement vector, length 2(N+1) (same as R). Use None for DOFs whose displacement is unknown (the default). Provide a float for DOFs with a known displacement (e.g. a support settlement — negative = downward). Fixed supports (R = -1) default to zero displacement unless D provides an explicit override.

Raises:

ValueError – If R and D have different lengths, or EI is not scalar and its length differs from len(L).

Methods

add_ml

Append a concentrated moment load.

add_pl

Append a point load.

add_pudl

Append a partial uniformly-distributed load.

add_udl

Append a full-span uniformly-distributed load.

analyze

Execute the direct-stiffness analysis.

plot_results

Plot bending moment, shear force, and deflection diagrams.

set_loads

Replace the current load matrix with a new one.

Attributes

beam

The underlying Beam object.

beam_results

Post-analysis results object.

property beam_results: BeamResults#

Post-analysis results object.

None until analyze() has been called successfully. Provides nodal displacements (D), reactions at fixed supports (R), spring forces (Rs), and per-member load-effect arrays (vRes, results).

Type:

BeamResults

property beam: Beam#

The underlying Beam object.

Provides direct access to span geometry, stiffness matrices, restraints, and prescribed displacements.

Type:

Beam

set_loads(LM)[source]#

Replace the current load matrix with a new one.

Any loads previously added via add_udl(), add_pl(), add_pudl(), or add_ml() are discarded.

Parameters:

LM (List[List[Union[int, float]]]) – New load matrix in the same format as the LM argument of __init__().

add_udl(i_span, w)[source]#

Append a full-span uniformly-distributed load.

Parameters:
  • i_span (int) – 1-based span index.

  • w (float) – Load intensity. Positive values act downward.

add_pl(i_span, p, a)[source]#

Append a point load.

Parameters:
  • i_span (int) – 1-based span index.

  • p (float) – Load magnitude. Positive values act downward.

  • a (float) – Distance from the left end of the span to the load.

add_pudl(i_span, w, a, c)[source]#

Append a partial uniformly-distributed load.

Any portion of the load that extends beyond the end of the span is silently ignored.

Parameters:
  • i_span (int) – 1-based span index.

  • w (float) – Load intensity. Positive values act downward.

  • a (float) – Distance from the left end of the span to the start of the load.

  • c (float) – Length (cover) of the partial UDL.

add_ml(i_span, m, a)[source]#

Append a concentrated moment load.

Parameters:
  • i_span (int) – 1-based span index.

  • m (float) – Moment magnitude. Positive values are counter-clockwise.

  • a (float) – Distance from the left end of the span to the load.

analyze(npts=None)[source]#

Execute the direct-stiffness analysis.

Assembles the unrestricted global stiffness matrix, validates the model, applies boundary conditions (including spring supports and prescribed displacements), solves for nodal displacements, and recovers support reactions. Results are stored in beam_results.

Parameters:

npts (Optional[int]) – Number of evaluation points along each member for computing distributed load effects (bending moment, shear, deflection). Must be greater than 3; defaults to 100 if omitted or 3.

Returns:

0 on successful completion.

Return type:

int

Raises:

ValueError – If the model is invalid (see _validate()) or if the structure is geometrically unstable (see _solver()).

plot_results()[source]#

Plot bending moment, shear force, and deflection diagrams.

Produces a three-panel figure of bending moment, shear force, and deflection along the beam. Bending moment is plotted with the sagging-positive convention (y-axis inverted so sagging appears below the beam line).

Note

The axis labels (“kNm”, “kN”, “mm”) and the deflection scaling (×1000) assume a kN / m unit system. If a different consistent unit system is used the plots will still be correct in shape but the labels and deflection axis values will need interpretation.

Has no effect and prints a warning if analyze() has not been called yet.