anastruct.preprocess.beam_class
Attributes
Classes
Abstract base class for 2D beam structures. |
Module Contents
- class anastruct.preprocess.beam_class.Beam(length: float | None = None, span_lengths: list[float] | None = None, angle: float = 0.0, section: anastruct._types.SectionProps | None = None)[source]
Bases:
abc.ABCAbstract base class for 2D beam structures.
Provides a framework for creating parametric beam geometries with automated node generation, connectivity, and support definitions. Subclasses implement specific beam types (simple, cantilever, etc.).
The beam generation follows a two-phase process: 1. define_nodes() - Generate node coordinates and span connectivity 2. define_supports() - Define support locations and types
- Attributes:
length (float): Total length of the beam (length units) angle (float): Angle of the beam (degrees; 0 = horizontal, positive = CCW); defaults to 0.0 section (SectionProps): Section properties for all beam elements; defaults to DEFAULT_BEAM_SECTION supports_type (Literal[“simple”, “pinned”, “fixed”]): Type of supports to apply; defaults to “simple” system (SystemElements): The FEM system containing all nodes, elements, and supports
- nodes: list[anastruct.vertex.Vertex][source]
- abstract define_nodes() None[source]
Generate node coordinates and populate self.nodes list.
Must be implemented by subclasses. Should create Vertex objects representing all node locations in the beam. Should also populate self.node_ids dictionary mapping spanwise node indices to global node IDs.
- abstract define_supports() None[source]
Define support locations and types by populating self.support_definitions.
Must be implemented by subclasses.
- add_elements() None[source]
Create elements from connectivity definitions and add to SystemElements.
Populates element ID list self.element_ids.
- get_element_ids_of_spans(spans: int | Sequence[int] | None) list[int][source]
Get element IDs for a span.
- Args:
- span_ids (int, sequence, None): The ID of the span to query. If None, returns
element IDs for all spans. If a sequence, returns IDs for all specified spans.
- Returns:
list[int]: Element IDs of the requested span
- Raises:
KeyError: If span_id does not exist
- apply_q_load_to_spans(q: float | Sequence[float], direction: anastruct._types.LoadDirection | Sequence[anastruct._types.LoadDirection] = 'element', rotation: float | Sequence[float] | None = None, q_perp: float | Sequence[float] | None = None, spans: int | Sequence[int] | None = None) None[source]
Apply distributed load to all elements within one or more spans.
- Args:
q (Union[float, Sequence[float]]): Load magnitude (force/length units) direction (Union[LoadDirection, Sequence[LoadDirection]]): Load direction.
Options: “element”, “x”, “y”, “parallel”, “perpendicular”, “angle”
- rotation (Optional[Union[float, Sequence[float]]]): Rotation angle in degrees
(used with direction=”angle”)
q_perp (Optional[Union[float, Sequence[float]]]): Perpendicular load component
- apply_point_load_to_spans(Fx: float | Sequence[float] = 0.0, Fy: float | Sequence[float] = 0.0, rotation: float | Sequence[float] = 0.0, absolute_location: float | None = None, relative_location: float | None = None, spans: int | Sequence[int] | None = None, tolerance: float | None = None) None[source]
Apply point load to elements within one or more spans.
- Args:
Fx (Union[float, Sequence[float]]): Horizontal load component (force units) Fy (Union[float, Sequence[float]]): Vertical load component (force units) rotation (Union[float, Sequence[float]]): Rotation angle in degrees absolute_location (Optional[float]): Absolute location along the beam length (length units).
Either absolute_location or relative_location must be provided.
- relative_location (Optional[float]): Relative location along the beam length
(0.0 = start of span, 1.0 = end of span). Either absolute_location or relative_location must be provided.
- spans (Optional[Union[int, Sequence[int]]]): Span(s) to apply the load to. If None,
applies to all spans.
- tolerance (float): Tolerance for matching existing node locations (length units).
Defaults to beam length * 1e-4.
- validate() bool[source]
Validate beam geometry and connectivity.
Checks for common beam definition issues: - All node IDs in span lists reference valid nodes - No duplicate nodes at the same location - All elements have non-zero length
- Returns:
bool: True if validation passes
- Raises:
ValueError: If validation fails with description of the issue