pycba.utils.supports_to_R#

supports_to_R(supports, n_nodes=None)[source]#

Lower a per-node list of named supports to a raw restraint vector R.

This is the friendly front-end to the low-level R vector used throughout PyCBA: one entry per node (left to right), each either a support name or a raw [vertical, rotation] DOF pair. The result is exactly the R you would otherwise write by hand, so supports= and R= are interchangeable on the Beam / BeamAnalysis constructors.

Recognised names (case-insensitive):

  • "p" / "pin" / "pinned" and "r" / "roller" -> [-1, 0] (vertical held, rotation free).

  • "e" / "encastre" / "fixed" / "clamped" -> [-1, -1] (fully fixed).

  • "f" / "free" -> [0, 0] (unrestrained, e.g. a cantilever tip).

Elastic springs are given as a raw pair, e.g. [5e4, 0] for a vertical spring (stiffness 5e4) with the rotation free.

An internal hinge is not a support (it is a member moment release) and is rejected; release the moment on the adjacent member via its element type instead.

Parameters:
  • supports (Sequence[Union[str, Sequence[float]]]) – One entry per node, ordered left to right.

  • n_nodes (Optional[int]) – Expected number of nodes (= number of spans + 1). If given, the length of supports is validated against it for a clear early error.

Returns:

The restraint vector R of length 2 * len(supports).

Return type:

list

Raises:

ValueError – If n_nodes is given and does not match len(supports), or any entry is not a recognised name or valid [vertical, rotation] pair.