pycba.beam.Beam#
- class Beam(L=None, EI=None, R=None, LM=None, eletype=None, D=None, supports=None, GAv=None, kf=None)[source]#
Bases:
objectA continuous beam: its members, supports and loads.
A beam is built from one or more members — each a two-node Euler–Bernoulli (or, with
GAv, Timoshenko) element of given length andEI— added withadd_member()(or the olderadd_span()).Member vs span. A member is the element between two adjacent nodes; a clear span is the distance between two supports. In the common case the two coincide, but a clear span may be modelled with several members (e.g. to place an intermediate node, a load discontinuity or an internal hinge), so
no_memberscounts the elements, not the supported spans.Constructs a beam object
- Parameters:
L (
Optional[ndarray]) – A vector of member lengths (one per member; a clear span between supports may comprise several members).EI (
Optional[ndarray]) – A vector of member flexural rigidities.R (
Optional[ndarray]) – A vector describing the support conditions at each member end (the low-level restraint vector). Provide eitherRor the friendliersupports, not both.LM (
Optional[List[List[Union[int,float]]]]) – The load matrix: a list of loads on the beam; each load with several parameters.eletype (
Optional[ndarray]) – A vector of the member types, each an integer code1-4, aMemberType, or a name string ("FF"/"FP"/"PF"/"PP"). Defaults to a fixed-fixed element.D (
Optional[ndarray]) – A vector of prescribed displacements. Must have same length as R. Use None for DOFs without prescribed displacement.supports (
Optional[Sequence[Union[str,Sequence[float]]]]) – A friendlier alternative toR: one entry per node (left to right), each a support name ("p"/"pin"/"pinned","r"/"roller","e"/"encastre"/"fixed","f"/"free") or a raw[vertical, rotation]DOF pair (e.g.[5e4, 0]for a vertical spring). Lowered toRviasupports_to_R(). Mutually exclusive withR.GAv (
Union[float,SectionEI,Sequence,None]) – Transverse shear rigidityG·A_vof each span (A_vthe shear area). A span with a finiteGAvis analysed as a shear-deformable Timoshenko element;None(the default) keeps the member on the exact Euler–Bernoulli path, bit-for-bit unchanged. LikeEI: a single scalar (or oneSectionEIdescribingGAv(x)) applies to all spans, otherwise one entry per span (eachNone, a scalar, or aSectionEI).kf (
Union[float,Sequence,None]) – Winkler foundation modulus (modulus of subgrade reaction per unit beam length). A span with a finitekfrests on an elastic (Winkler) foundation, modelled as a statically-condensed beam-on-elastic-foundation super-element;None(default) leaves the span unsupported by a foundation. A scalar applies to all spans, otherwise one entry per span.
- Return type:
None.
Methods
Adds a new load to the beam's load matrix
Add a member (span) to the beam, naming its type.
Add a span to the continuous beam
Returns the span index and position in span for a position given in global coordinates on the beam
Returns Released End Forces for the member; that is, the Consistent Nodal Loads modified for the element type (i.e. releases).
Returns the stiffness matrix for the ith span
Stiffness matrix for a fixed-fixed element
Stiffness matrix for a prismatic fixed-fixed Timoshenko element.
Stiffness matrix for a fixed-pinned element
Stiffness matrix for a pinned-fixed element
Stiffness matrix for a pinned-pinned element
4x4 stiffness matrix of a non-prismatic (variable-EI) element.
2x2 moment-rotation stiffness of the (chord-relative) element ends.
4x4 Timoshenko element stiffness for scalar or variable
EI/GAv.Draw a structural schematic of the beam.
Write the TikZ/
stanlisource topath(and optionally compile it).Generate a TikZ/
stanlirepresentation of the beam.Attributes
returns: length -- The total length of the beam :rtype: float
Returns the load matrix for the beam
Returns the number of fixed restraints of the beam (fully-supported DOFs)
The number of members in the beam.
Returns the number of restraints of the beam
Deprecated alias of
no_members.Returns the prescribed displacements vector for the beam
Returns the restraints vector for the beam
A counter that increments whenever the beam structure changes.
- add_span(L, EI, eletype=1, GAv=None, kf=None)[source]#
Add a span to the continuous beam
- Parameters:
L (
float) – The length of the member.EI (
float) – The flexural rigidity of the member.eletype (
Union[int,str,MemberType]) – The element type for the member, as the integer code1-4, aMemberType(e.g.MemberType.FP), or its case-insensitive name (e.g."FP"). SeeMemberType.GAv (
Union[float,SectionEI,None]) – Transverse shear rigidityG·A_vof the member. When given (and finite) the member is a shear-deformable Timoshenko element;None(default) keeps the exact Euler–Bernoulli element. ASectionEIdescribes a variableGAv(x).kf (
Optional[float]) – Winkler foundation modulus. When given, the member rests on an elastic (Winkler) foundation (prismatic, fixed-fixed, noGAv).
- Return type:
None.
- add_member(L, EI, mbr_type=MemberType.FF, GAv=None, kf=None)[source]#
Add a member (span) to the beam, naming its type.
A friendlier alias of
add_span()whosembr_typeaccepts aMemberType, a name string ("FF"/"FP"/"PF"/"PP"), or the integer code1-4.- Parameters:
L (
float) – The length of the member.EI (
float) – The flexural rigidity of the member.mbr_type (
Union[int,str,MemberType]) – The member type / moment-release pattern (defaultFF).GAv (
Union[float,SectionEI,None]) – Transverse shear rigidityG·A_v; when given the member is a shear-deformable Timoshenko element (seeadd_span()).kf (
Optional[float]) – Winkler foundation modulus; when given the member rests on an elastic (Winkler) foundation (seeadd_span()).
- property loads: List[List[int | float]]#
Returns the load matrix for the beam
- Returns:
LM – The load matrix for the beam
- Return type:
- add_load(load)[source]#
Adds a new load to the beam’s load matrix
- Parameters:
load (
List[Union[int,float]]) – A list describing the load to be added- Return type:
None
- property restraints: ndarray#
Returns the restraints vector for the beam
- Returns:
_restraints – The restraints vector for the beam
- Return type:
np.ndarray
- property structure_version: int#
A counter that increments whenever the beam structure changes.
Bumped by changes to geometry, rigidity, restraints or prescribed displacements (but not loads). Used to invalidate a cached stability check (see
pycba.analysis.BeamAnalysis.is_stable()).- Type:
int
- property prescribed_displacements: list#
Returns the prescribed displacements vector for the beam
- Returns:
_prescribed_displacements – The prescribed displacements vector for the beam
- Return type:
list
- property no_members#
The number of members in the beam.
A member is an element between two nodes; a clear span (the distance between two supports) may comprise several members (e.g. to place an intermediate node, load discontinuity or internal hinge).
- Returns:
no_members
- Return type:
int
- property no_spans#
Deprecated alias of
no_members.
- property no_restraints#
Returns the number of restraints of the beam
- Returns:
no_restraints – The number of restraints in the beam
- Return type:
int
- property no_fixed_restraints#
Returns the number of fixed restraints of the beam (fully-supported DOFs)
- Returns:
no_fixed_restraints – The number of fixed restraints in the beam
- Return type:
int
- property length#
returns: length – The total length of the beam :rtype: float
- get_local_span_coords(pos)[source]#
Returns the span index and position in span for a position given in global coordinates on the beam
- Parameters:
pos (
float) – The position of interest in global coordinates along the length of the beam- Return type:
(
int,float)- Returns:
ispan (int) – The index (1-based) of the span in which the point of interest falls
pos_in_span (float) – The local coordinate along the member of the point of interest
- plot(loads=None, *, tikz=None, ax=None, save=None, compile=False, load_cases=None, **kwargs)[source]#
Draw a structural schematic of the beam.
By default this renders with matplotlib; saving to a
.texpath (or passingtikz=True) produces publication-quality TikZ/stanlioutput instead. The beam structure (geometry, supports, internal hinges) is always drawn; the loads layer is optional and its source is selected withloads:None(default) - the beam’s own load matrixself.LM.[]- draw the bare structure only.a PyCBA load matrix, a
LoadCase, or aLoadCombination(supply itsLoadCasesviaload_cases).
- Parameters:
loads (list | LoadCase | LoadCombination, optional) – The load source to draw.
tikz (bool, optional) – Backend selector.
None(default) infers it fromsave: a.textarget renders TikZ/stanli; anything else (or nosave) renders with matplotlib. PassTrue/Falseto force the backend - e.g.tikz=Trueto return the LaTeX source, or to render an otherwise-ambiguous.pdftarget via TikZ.ax (matplotlib.axes.Axes, optional) – Axes to draw into (matplotlib backend only); a new figure is created if omitted.
save (str or pathlib.Path, optional) – If given, also write the visualisation to this path; the file extension selects the backend when
tikzisNone. A.textarget writes the TikZ/stanlisource; any other extension is saved by matplotlib (format inferred from the extension, e.g..png/.pdf/.svg). Under the TikZ backend a.pdftarget is compiled withpdflatex.compile (bool) – Under the TikZ backend with
saveset, runpdflatexto also produce a PDF (requires a LaTeX install withstanli). A.pdfsave target enables this automatically. Ignored for the matplotlib backend.load_cases (pycba.load_cases.LoadCases, optional) – Required only when
loadsis aLoadCombination.**kwargs – Forwarded to the backend renderer:
pycba.render.BeamPlotter.render_mpl()(dimensions,labels,load_values,color,units) or, whentikz=True,pycba.render.BeamPlotter.render_tikz()(standalone,scale,dimensions,labels,load_values,units).unitsselects the display unit system (seepycba.set_units()).
- Returns:
matplotlib.axes.Axes – The axes drawn into (matplotlib backend).
str – The LaTeX source, when the TikZ backend is selected and
saveis not given.pathlib.Path – The written file, when the TikZ backend is selected with
save(the.texpath, or the.pdfwhen compiled).
- to_tikz(loads=None, *, load_cases=None, **kwargs)[source]#
Generate a TikZ/
stanlirepresentation of the beam.Loads are selected with
loadsexactly as forplot().- Parameters:
loads (list | LoadCase | LoadCombination, optional) – The load source to draw.
load_cases (pycba.load_cases.LoadCases, optional) – Required only when
loadsis aLoadCombination.**kwargs – Forwarded to
pycba.render.BeamPlotter.render_tikz()(standalone,scale,dimensions,labels,load_values).
- Returns:
The LaTeX source.
- Return type:
str
- save_tikz(path, loads=None, *, compile=False, load_cases=None, **kwargs)[source]#
Write the TikZ/
stanlisource topath(and optionally compile it).Loads are selected with
loadsexactly as forplot().- Parameters:
path (str or pathlib.Path) – Output
.texpath.loads (list | LoadCase | LoadCombination, optional) – The load source to draw.
compile (bool) – If
True, runpdflatexto also produce a PDF (requires a LaTeX install with thestanlipackage).load_cases (pycba.load_cases.LoadCases, optional) – Required only when
loadsis aLoadCombination.
- Returns:
The
.texpath, or the produced.pdfwhencompile=True.- Return type:
pathlib.Path
- get_ref(i_span)[source]#
Returns Released End Forces for the member; that is, the Consistent Nodal Loads modified for the element type (i.e. releases)
- Parameters:
ispan (int) – The index (1-based) of the span in which the point of interest falls
- Returns:
ref – The totalled CNL object for the member, considering all loads.
- Return type:
LoadCNL
- get_span_k(i_span)[source]#
Returns the stiffness matrix for the ith span
- Parameters:
ispan (int) – The index (1-based) of the span in which the point of interest falls
- Returns:
kb – The stiffness matrix for the member
- Return type:
ndarray
- k_FF(EI, L)[source]#
Stiffness matrix for a fixed-fixed element
- Parameters:
EI (
float) – The flexural rigidity for the member (assumed prismatic)L (
float) – The length of the member
- Returns:
k – The stiffness matrix for the member
- Return type:
ndarray
- k_FP(EI, L)[source]#
Stiffness matrix for a fixed-pinned element
- Parameters:
EI (
float) – The flexural rigidity for the member (assumed prismatic)L (
float) – The length of the member
- Returns:
k – The stiffness matrix for the member
- Return type:
ndarray
- k_PF(EI, L)[source]#
Stiffness matrix for a pinned-fixed element
- Parameters:
EI (
float) – The flexural rigidity for the member (assumed prismatic)L (
float) – The length of the member
- Returns:
k – The stiffness matrix for the member
- Return type:
ndarray
- k_PP(EI, L)[source]#
Stiffness matrix for a pinned-pinned element
- Parameters:
EI (
float) – The flexural rigidity for the member (assumed prismatic)L (
float) – The length of the member
- Returns:
k – The stiffness matrix for the member
- Return type:
ndarray
- k_theta(EI, L)[source]#
2x2 moment-rotation stiffness of the (chord-relative) element ends.
This is the inverse of the rotational flexibility matrix (see
_flexibility()), relating the end moments[M_i, M_j]to the chord-relative end rotations[theta_i, theta_j].- Parameters:
EI (
SectionEI) – The variable-rigidity description of the member.L (
float) – The length of the member.
- Returns:
The end moment-rotation stiffness matrix
K_theta = F^-1.- Return type:
ndarray
- k_nonprismatic(EI, L, eType)[source]#
4x4 stiffness matrix of a non-prismatic (variable-EI) element.
The 2x2 moment-rotation stiffness
K_thetafrom flexibility integration (seek_theta()) is expanded to the full 4-DOF element using the kinematic transformation that removes the rigid-body chord rotationpsi = (v_j - v_i)/L:\[\begin{split}\begin{bmatrix} \theta_i \\ \theta_j \end{bmatrix} = T \begin{bmatrix} v_i \\ \theta_i \\ v_j \\ \theta_j \end{bmatrix}, \quad T = \begin{bmatrix} 1/L & 1 & -1/L & 0 \\ 1/L & 0 & -1/L & 1 \end{bmatrix}\end{split}\]so the element stiffness is
k = T^T K_theta T. The end shears emerge automatically as(M_i + M_j)/Lfrom this transformation, matching PyCBA’s DOF order[v_i, theta_i, v_j, theta_j]and sign convention.Moment releases (element types 2, 3, 4) are imposed by static condensation of the released rotational DOF(s), exactly mirroring the prismatic
k_FP(),k_PF(), andk_PP(): the released row/column are zeroed and their flexibility is condensed out.For a constant
EI(x)this reproduces the closed-form prismatick_FF(),k_FP(),k_PF(),k_PP()to machine precision.- Parameters:
EI (
SectionEI) – The variable-rigidity description of the member.L (
float) – The length of the member.eType (
int) – The element type (1: FF, 2: FP, 3: PF, 4: PP).
- Returns:
k – The element stiffness matrix.
- Return type:
ndarray
- k_FF_timo(EI, GAv, L)[source]#
Stiffness matrix for a prismatic fixed-fixed Timoshenko element.
The standard two-node shear-flexible element introduces the dimensionless shear parameter
\[\Phi = \frac{12 EI}{G A_v L^2}\]so the element stiffness is
\[\begin{split}k = \frac{EI}{(1+\Phi)L^3} \begin{bmatrix} 12 & 6L & -12 & 6L \\ 6L & (4+\Phi)L^2 & -6L & (2-\Phi)L^2 \\ -12 & -6L & 12 & -6L \\ 6L & (2-\Phi)L^2 & -6L & (4+\Phi)L^2 \end{bmatrix}\end{split}\]As
GAv -> inf(\Phi -> 0) this reduces exactly to the Euler–Bernoullik_FF(). The DOF order and sign convention match the rest of PyCBA,[v_i, theta_i, v_j, theta_j], withthetathe cross-section rotation.- Parameters:
EI (
float) – The flexural rigidity of the member (assumed prismatic).GAv (
float) – The transverse shear rigidityG·A_vof the member.L (
float) – The length of the member.
- Returns:
k – The element stiffness matrix.
- Return type:
ndarray
- k_timoshenko(EI, GAv, L, eType)[source]#
4x4 Timoshenko element stiffness for scalar or variable
EI/GAv.The 2x2 moment-rotation stiffness
K_theta(the inverse of the shear-augmented flexibility, see_timo_flexibility()) is expanded to the full 4-DOF element by the same kinematic chord transformation used for the non-prismatic element (seek_nonprismatic()), and moment releases (element types 2, 3, 4) are imposed by static condensation. This single path covers prismatic and non-prismatic, constant- and variable-shear members; for a constantEI/GAvit reproducesk_FF_timo()(and hence the Euler–Bernoulli element asGAv -> inf) to machine precision.- Parameters:
- Returns:
k – The element stiffness matrix.
- Return type:
ndarray