anastruct.preprocess.truss_class ================================ .. py:module:: anastruct.preprocess.truss_class Attributes ---------- .. autoapisummary:: anastruct.preprocess.truss_class.DEFAULT_TRUSS_SECTION Classes ------- .. autoapisummary:: anastruct.preprocess.truss_class.Truss anastruct.preprocess.truss_class.FlatTruss anastruct.preprocess.truss_class.RoofTruss Module Contents --------------- .. py:data:: DEFAULT_TRUSS_SECTION :type: anastruct._types.SectionProps .. py:class:: Truss(width: float, height: float, top_chord_section: Optional[anastruct._types.SectionProps] = None, bottom_chord_section: Optional[anastruct._types.SectionProps] = None, web_section: Optional[anastruct._types.SectionProps] = None, web_verticals_section: Optional[anastruct._types.SectionProps] = None, top_chord_continuous: bool = True, bottom_chord_continuous: bool = True, supports_type: Literal['simple', 'pinned', 'fixed'] = 'simple') Bases: :py:obj:`abc.ABC` Abstract base class for 2D truss structures. Provides a framework for creating parametric truss geometries with automated node generation, connectivity, and support definitions. Subclasses implement specific truss types (Howe, Pratt, Warren, etc.). The truss generation follows a three-phase process: 1. define_nodes() - Generate node coordinates 2. define_connectivity() - Define which nodes connect to form elements 3. define_supports() - Define support locations and types Attributes: width (float): Total span of the truss (length units) height (float): Height of the truss (length units) top_chord_section (SectionProps): Section properties for top chord elements bottom_chord_section (SectionProps): Section properties for bottom chord elements web_section (SectionProps): Section properties for diagonal web elements web_verticals_section (SectionProps): Section properties for vertical web elements top_chord_continuous (bool): If True, top chord is continuous; if False, pinned at joints bottom_chord_continuous (bool): If True, bottom chord is continuous; if False, pinned at joints supports_type (Literal["simple", "pinned", "fixed"]): Type of supports to apply system (SystemElements): The FEM system containing all nodes, elements, and supports .. py:attribute:: width :type: float .. py:attribute:: height :type: float .. py:attribute:: top_chord_section :type: anastruct._types.SectionProps .. py:attribute:: bottom_chord_section :type: anastruct._types.SectionProps .. py:attribute:: web_section :type: anastruct._types.SectionProps .. py:attribute:: web_verticals_section :type: anastruct._types.SectionProps .. py:attribute:: top_chord_continuous :type: bool .. py:attribute:: bottom_chord_continuous :type: bool .. py:attribute:: supports_type :type: Literal['simple', 'pinned', 'fixed'] .. py:attribute:: nodes :type: list[anastruct.vertex.Vertex] .. py:attribute:: top_chord_node_ids :type: Union[list[int], dict[str, list[int]]] .. py:attribute:: bottom_chord_node_ids :type: Union[list[int], dict[str, list[int]]] .. py:attribute:: web_node_pairs :type: list[tuple[int, int]] .. py:attribute:: web_verticals_node_pairs :type: list[tuple[int, int]] .. py:attribute:: support_definitions :type: dict[int, Literal['fixed', 'pinned', 'roller']] .. py:attribute:: top_chord_length :type: float .. py:attribute:: bottom_chord_length :type: float .. py:attribute:: top_chord_element_ids :type: Union[list[int], dict[str, list[int]]] .. py:attribute:: bottom_chord_element_ids :type: Union[list[int], dict[str, list[int]]] .. py:attribute:: web_element_ids :type: list[int] .. py:attribute:: web_verticals_element_ids :type: list[int] .. py:attribute:: system :type: anastruct.fem.system.SystemElements .. py:property:: type :type: str :abstractmethod: Return the human-readable name of the truss type. .. py:method:: define_nodes() -> None :abstractmethod: Generate node coordinates and populate self.nodes list. Must be implemented by subclasses. Should create Vertex objects representing all node locations in the truss. .. py:method:: define_connectivity() -> None :abstractmethod: Define element connectivity by populating node ID lists. Must be implemented by subclasses. Should populate: - self.top_chord_node_ids - self.bottom_chord_node_ids - self.web_node_pairs - self.web_verticals_node_pairs .. py:method:: define_supports() -> None :abstractmethod: Define support locations and types by populating self.support_definitions. Must be implemented by subclasses. .. py:method:: add_nodes() -> None Add all nodes from self.nodes to the SystemElements. .. py:method:: add_elements() -> None Create elements from connectivity definitions and add to SystemElements. Populates element ID lists: - self.top_chord_element_ids - self.bottom_chord_element_ids - self.web_element_ids - self.web_verticals_element_ids .. py:method:: add_supports() -> None Add supports from self.support_definitions to the SystemElements. .. py:method:: _resolve_support_type(is_primary: bool = True) -> Literal['fixed', 'pinned', 'roller'] Helper to resolve support type from "simple" to specific type. Args: is_primary (bool): If True, this is the primary (left) support. If False, this is the secondary (right) support. Returns: Literal["fixed", "pinned", "roller"]: The resolved support type. For "simple", returns "pinned" if primary, "roller" if secondary. .. py:method:: get_element_ids_of_chord(chord: Literal['top', 'bottom'], chord_segment: None = None) -> list[int] get_element_ids_of_chord(chord: Literal['top', 'bottom'], chord_segment: str) -> list[int] Get element IDs for a chord (top or bottom). Args: chord (Literal["top", "bottom"]): Which chord to query chord_segment (Optional[str]): If the chord is segmented (dict of segments), specify which segment to get. If None and chord is segmented, returns all element IDs from all segments concatenated. Returns: list[int]: Element IDs of the requested chord (segment) Raises: ValueError: If chord is not "top" or "bottom" KeyError: If chord_segment is specified but doesn't exist in the chord .. py:method:: apply_q_load_to_top_chord(q: Union[float, Sequence[float]], direction: Union[anastruct._types.LoadDirection, Sequence[anastruct._types.LoadDirection]] = 'element', rotation: Optional[Union[float, Sequence[float]]] = None, q_perp: Optional[Union[float, Sequence[float]]] = None, chord_segment: Optional[str] = None) -> None Apply distributed load to all elements in the top chord. 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 chord_segment (Optional[str]): If specified, apply load only to this segment (for trusses with segmented chords like roof trusses) .. py:method:: apply_q_load_to_bottom_chord(q: Union[float, Sequence[float]], direction: Union[anastruct._types.LoadDirection, Sequence[anastruct._types.LoadDirection]] = 'element', rotation: Optional[Union[float, Sequence[float]]] = None, q_perp: Optional[Union[float, Sequence[float]]] = None, chord_segment: Optional[str] = None) -> None Apply distributed load to all elements in the bottom chord. 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 chord_segment (Optional[str]): If specified, apply load only to this segment (for trusses with segmented chords like roof trusses) .. py:method:: validate() -> bool Validate truss geometry and connectivity. Checks for common truss definition issues: - All node IDs in connectivity 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 .. py:method:: show_structure() -> None Display the truss structure using matplotlib. .. py:class:: FlatTruss(width: float, height: float, unit_width: float, end_type: EndType = 'triangle_down', supports_loc: SupportLoc = 'bottom_chord', min_end_fraction: float = 0.5, enforce_even_units: bool = True, top_chord_section: Optional[anastruct._types.SectionProps] = None, bottom_chord_section: Optional[anastruct._types.SectionProps] = None, web_section: Optional[anastruct._types.SectionProps] = None, web_verticals_section: Optional[anastruct._types.SectionProps] = None) Bases: :py:obj:`Truss` Abstract base class for flat (parallel chord) truss structures. Flat trusses have parallel top and bottom chords and are divided into repeating panel units. Specific truss patterns (Howe, Pratt, Warren) are implemented by subclasses. Attributes: unit_width (float): Width of each panel/bay end_type (EndType): Configuration of truss ends - "flat", "triangle_down", or "triangle_up" supports_loc (SupportLoc): Where supports are placed - "bottom_chord", "top_chord", or "both" min_end_fraction (float): Minimum width of end panels as fraction of unit_width enforce_even_units (bool): If True, ensure even number of panels for symmetry n_units (int): Computed number of panel units end_width (float): Computed width of end panels .. py:attribute:: EndType .. py:attribute:: SupportLoc .. py:attribute:: unit_width :type: float .. py:attribute:: end_type :type: FlatTruss.EndType .. py:attribute:: supports_loc :type: FlatTruss.SupportLoc .. py:attribute:: min_end_fraction :type: float .. py:attribute:: enforce_even_units :type: bool .. py:attribute:: n_units :type: int .. py:attribute:: end_width :type: float .. py:property:: type :type: str :abstractmethod: Return the human-readable name of the truss type. .. py:method:: define_nodes() -> None :abstractmethod: Generate node coordinates and populate self.nodes list. Must be implemented by subclasses. Should create Vertex objects representing all node locations in the truss. .. py:method:: define_connectivity() -> None :abstractmethod: Define element connectivity by populating node ID lists. Must be implemented by subclasses. Should populate: - self.top_chord_node_ids - self.bottom_chord_node_ids - self.web_node_pairs - self.web_verticals_node_pairs .. py:method:: define_supports() -> None Define support locations for flat trusses. Default implementation places supports at the ends of the truss. Assumes single-segment (non-dict) chord node ID lists. .. py:class:: RoofTruss(width: float, roof_pitch_deg: float, overhang_length: float = 0.0, top_chord_section: Optional[anastruct._types.SectionProps] = None, bottom_chord_section: Optional[anastruct._types.SectionProps] = None, web_section: Optional[anastruct._types.SectionProps] = None, web_verticals_section: Optional[anastruct._types.SectionProps] = None) Bases: :py:obj:`Truss` Abstract base class for peaked roof truss structures. Roof trusses have sloped top chords meeting at a peak, forming a triangular profile. Height is computed from span and roof pitch. Specific truss patterns (King Post, Queen Post, Fink, etc.) are implemented by subclasses. Attributes: overhang_length (float): Length of roof overhang beyond supports roof_pitch_deg (float): Roof pitch angle in degrees roof_pitch (float): Roof pitch angle in radians (computed) .. py:attribute:: overhang_length :type: float .. py:attribute:: roof_pitch_deg :type: float .. py:attribute:: roof_pitch :type: float .. py:property:: type :type: str :abstractmethod: Return the human-readable name of the truss type. .. py:method:: define_nodes() -> None :abstractmethod: Generate node coordinates and populate self.nodes list. Must be implemented by subclasses. Should create Vertex objects representing all node locations in the truss. .. py:method:: define_connectivity() -> None :abstractmethod: Define element connectivity by populating node ID lists. Must be implemented by subclasses. Should populate: - self.top_chord_node_ids - self.bottom_chord_node_ids - self.web_node_pairs - self.web_verticals_node_pairs .. py:method:: define_supports() -> None Define support locations for roof trusses. Default implementation places supports at the ends of the bottom chord. Assumes single-segment (non-dict) bottom chord node ID list.