Preprocessing: Trusses
The anastruct.preprocess.truss module provides ready-made truss generators for common
structural truss configurations. Geometry — nodes, elements, and supports — is built automatically
from a small set of input parameters, so you can focus on loading and analysis rather than model
construction.
Importing
The truss module is available at the top level of the anastruct package:
from anastruct import truss
You can also import individual classes or the factory function directly:
from anastruct.preprocess.truss import PrattFlatTruss, FinkRoofTruss, create_truss
Once instantiated, every truss exposes its underlying SystemElements model as
truss.system.
Section properties
Both flat and roof trusses accept separate section dictionaries for each structural component.
As with beams, only EI is required — the other keys are filled with defaults if omitted.
Providing a partial dictionary (e.g. {"EI": 5000}) merges with the defaults, so a single
key is always sufficient:
top_chord_section— top chord (default{"EI": 1e6, "EA": 1e8, "g": 0.0})bottom_chord_section— bottom chord (same default)web_section— diagonal web members (same default)web_verticals_section— vertical web members (defaults toweb_section)
If all section arguments are omitted the truss uses the module defaults throughout.
Flat trusses
Flat trusses have parallel top and bottom chords divided into repeating panel bays. Three web patterns are available: Howe (diagonals in compression under gravity), Pratt (diagonals in tension under gravity), and Warren (diagonal-only web, no vertical members).
All flat truss types require three parameters: width (total span), height
(depth between chords), and unit_width (width of each panel bay).
Howe flat truss
- class anastruct.preprocess.truss.HoweFlatTruss(width, height, unit_width, end_type='triangle_down', supports_loc='bottom_chord', min_end_fraction=0.5, enforce_even_units=True, top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
Howe flat truss with vertical web members and diagonal members in compression.
The Howe truss features vertical web members and diagonal members sloping toward the center. Under gravity loads, diagonals are typically in compression and verticals in tension, making it efficient for steel trusses.
Pratt flat truss
- class anastruct.preprocess.truss.PrattFlatTruss(width, height, unit_width, end_type='triangle_down', supports_loc='bottom_chord', min_end_fraction=0.5, enforce_even_units=True, top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
Pratt flat truss with vertical web members and diagonal members in tension.
The Pratt truss features vertical web members and diagonal members sloping away from the center. Under gravity loads, diagonals are typically in tension and verticals in compression, making it efficient for a wide range of applications.
Warren flat truss
- class anastruct.preprocess.truss.WarrenFlatTruss(width, height, unit_width, end_type='triangle_down', supports_loc='bottom_chord', top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
Warren flat truss with diagonal-only web members forming a zigzag pattern.
The Warren truss has no vertical web members (except optionally at midspan). Diagonal members alternate direction, creating a series of equilateral or isosceles triangles. This configuration is simple and efficient.
Note: Warren trusses don’t support the “flat” end_type - only “triangle_down” or “triangle_up”.
Roof trusses
Roof trusses have sloped top chords meeting at a central peak. The truss height is computed
automatically from width and roof_pitch_deg — you do not specify it directly.
An optional eave overhang can be added with overhang_length.
The two required parameters are width (total span) and roof_pitch_deg (slope
angle in degrees, between 0 and 90).
Class |
Typical span |
Description |
|---|---|---|
|
up to ~8 m |
Single central vertical (king post); simplest pitched roof truss |
|
8–15 m |
Two verticals at quarter points with diagonal bracing |
|
10–20 m |
W-shaped web; most common general-purpose roof truss |
|
10–20 m |
Verticals with diagonals sloping toward the peak (compression) |
|
10–20 m |
Verticals with diagonals sloping away from the peak (tension) |
|
15–25 m |
Diagonals radiating from lower chord panel points |
|
12–20 m |
Enhanced Queen Post with additional web members |
|
20–30 m |
Two W patterns for long-span applications |
|
20–30 m |
Enhanced Howe for long spans or heavy loading |
|
20–30 m |
Enhanced Fan with additional web members |
|
any |
Room-in-roof truss with habitable attic space |
King Post
- class anastruct.preprocess.truss.KingPostRoofTruss(width, roof_pitch_deg, overhang_length=0.0, top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
King Post roof truss - simplest pitched roof truss with single center vertical.
Features a single vertical member (king post) at the center supporting the peak. Suitable for short spans (up to ~8m). No diagonal web members.
Queen Post
- class anastruct.preprocess.truss.QueenPostRoofTruss(width, roof_pitch_deg, overhang_length=0.0, top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
Queen Post roof truss with two vertical members and diagonal bracing.
Features two vertical members (queen posts) at quarter points with diagonal members from center to quarter points. Suitable for medium spans (8-15m). More efficient than King Post for longer spans.
Fink
- class anastruct.preprocess.truss.FinkRoofTruss(width, roof_pitch_deg, overhang_length=0.0, top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
Fink roof truss with W-shaped web configuration.
Features diagonal members forming a W pattern between peak and supports. Efficient for medium to long spans (10-20m). The symmetrical W pattern distributes loads effectively with minimal material usage.
Howe
- class anastruct.preprocess.truss.HoweRoofTruss(width, roof_pitch_deg, overhang_length=0.0, top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
Howe roof truss with vertical posts and diagonal compression members.
Features vertical posts with diagonals sloping toward the peak. Under gravity loads, diagonals are in compression and verticals in tension. Suitable for medium to long spans with good load distribution.
Pratt
- class anastruct.preprocess.truss.PrattRoofTruss(width, roof_pitch_deg, overhang_length=0.0, top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
Pratt roof truss with vertical posts and diagonal tension members.
Features vertical posts with diagonals sloping away from the peak. Under gravity loads, diagonals are in tension and verticals in compression. Widely used for its efficiency and simple construction.
Fan
- class anastruct.preprocess.truss.FanRoofTruss(width, roof_pitch_deg, overhang_length=0.0, top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
Fan roof truss with radiating diagonal members forming a fan pattern.
Features diagonal members radiating from lower chord panel points up to the top chord, creating a fan-like appearance. Provides excellent load distribution for longer spans (15-25m).
Modified Queen Post
- class anastruct.preprocess.truss.ModifiedQueenPostRoofTruss(width, roof_pitch_deg, overhang_length=0.0, top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
Modified Queen Post roof truss with enhanced web configuration.
An enhanced version of the Queen Post truss with additional web members for better load distribution and reduced member forces. Suitable for medium to long spans (12-20m).
Double Fink
- class anastruct.preprocess.truss.DoubleFinkRoofTruss(width, roof_pitch_deg, overhang_length=0.0, top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
Double Fink roof truss with two W-shaped web patterns.
An extension of the Fink truss with additional web members creating two W patterns. Suitable for longer spans (20-30m) where a standard Fink would have excessive member lengths.
Double Howe
- class anastruct.preprocess.truss.DoubleHoweRoofTruss(width, roof_pitch_deg, overhang_length=0.0, top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
Double Howe roof truss with enhanced vertical and diagonal web pattern.
An extension of the Howe truss with additional verticals and diagonals for increased load capacity and reduced member lengths. Suitable for long spans (20-30m) or heavy loading conditions.
Modified Fan
- class anastruct.preprocess.truss.ModifiedFanRoofTruss(width, roof_pitch_deg, overhang_length=0.0, top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
Modified Fan roof truss with enhanced radiating web pattern.
An enhanced version of the Fan truss with additional web members for improved structural performance. Suitable for long spans (20-30m) with excellent load distribution characteristics.
Attic (room-in-roof) truss
The attic truss creates vertical walls and a flat ceiling to provide usable space beneath
the roof. It requires two additional parameters beyond the standard roof truss inputs:
attic_width (interior floor width, which must be less than the total width)
and an optional attic_height (ceiling height; if omitted it defaults to the height
where the vertical walls naturally meet the sloped top chord).
- class anastruct.preprocess.truss.AtticRoofTruss(width, roof_pitch_deg, attic_width, attic_height=None, overhang_length=0.0, top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
Attic (or Room-in-Roof) truss with habitable space under the roof.
Creates a truss with vertical walls and a flat ceiling to provide usable attic space. The geometry includes: - Vertical attic walls at the edges of the attic space - Horizontal ceiling beam - Sloped top chords from walls to peak - Diagonal and vertical web members for support
The attic space is defined by attic_width (floor width) and attic_height (ceiling height). If attic_height is not specified, it defaults to the height where the vertical walls meet the sloped roof.
- Attributes:
attic_width (float): Width of the attic floor (interior dimension) attic_height (float): Height of the attic ceiling wall_x (float): Horizontal position where attic walls are located wall_y (float): Height at top of attic walls where they meet the roof slope ceiling_y (float): Vertical position of the ceiling beam (equals attic_height) ceiling_x (float): Horizontal position where ceiling meets the sloped top chord wall_ceiling_intersect (bool): True if wall top and ceiling intersection coincide
- __init__(width, roof_pitch_deg, attic_width, attic_height=None, overhang_length=0.0, top_chord_section=None, bottom_chord_section=None, web_section=None, web_verticals_section=None)[source]
Initialize an attic roof truss.
- Args:
width (float): Total span of the truss roof_pitch_deg (float): Roof pitch angle in degrees attic_width (float): Interior width of the attic space. Must be less than width. attic_height (Optional[float]): Height of the attic ceiling. If None, defaults
to the height where vertical walls meet the roof slope. Must be at least as high as the wall intersection point.
overhang_length (float): Length of roof overhang. Defaults to 0.0. top_chord_section (Optional[SectionProps]): Section properties for top chord bottom_chord_section (Optional[SectionProps]): Section properties for bottom chord web_section (Optional[SectionProps]): Section properties for diagonal webs web_verticals_section (Optional[SectionProps]): Section properties for vertical webs
- Raises:
ValueError: If attic dimensions are invalid or create impossible geometry
Factory function
- anastruct.preprocess.truss.create_truss(truss_type, **kwargs)[source]
Factory function to create truss instances by type name.
Provides a convenient way to create trusses without importing specific classes. Type names are case-insensitive and can use underscores or hyphens as separators.
- Return type:
- Args:
- truss_type (str): Name of the truss type. Supported types:
Flat trusses: “howe”, “pratt”, “warren” Roof trusses: “king_post”, “queen_post”, “fink”, “howe_roof”, “pratt_roof”,
“fan”, “modified_queen_post”, “double_fink”, “double_howe”, “modified_fan”, “attic”
**kwargs: Arguments to pass to the truss constructor
- Returns:
Truss: An instance of the requested truss type
- Raises:
ValueError: If truss_type is not recognized
- Examples:
>>> truss = create_truss("howe", width=20, height=2.5, unit_width=2.0) >>> truss = create_truss("king-post", width=10, roof_pitch_deg=30)
Applying loads
Distributed loads can be applied to the full top or bottom chord in a single call:
- Truss.apply_q_load_to_top_chord(q, direction='element', rotation=None, q_perp=None, chord_segment=None)[source]
Apply distributed load to all elements in the top chord.
- Return type:
- 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)
- Truss.apply_q_load_to_bottom_chord(q, direction='element', rotation=None, q_perp=None, chord_segment=None)[source]
Apply distributed load to all elements in the bottom chord.
- Return type:
- 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)
For roof trusses the top chord is segmented into "left" and "right" slopes.
Passing chord_segment="left" or chord_segment="right" restricts the load to
one slope; omitting the argument applies it to both.
Point loads and element-level loads can be applied through truss.system using the
standard methods described in Loads.
Examples
Pratt flat truss with a distributed roof load
1from anastruct import truss
2
3# 18 m span, 2 m deep, 3 m panel bays
4# Providing only EI for each chord — EA and g use defaults
5t = truss.PrattFlatTruss(
6 width=18.0,
7 height=2.0,
8 unit_width=3.0,
9 top_chord_section={"EI": 5000},
10 web_section={"EI": 100},
11)
12
13# 10 kN/m downward load applied vertically along the top chord
14t.apply_q_load_to_top_chord(q=-10, direction="y")
15
16t.system.solve()
17t.show_structure()
18t.system.show_axial_force()
19t.system.show_displacement()
Fink roof truss with wind load
For roof trusses the peak height is derived from the pitch: a 30° pitch on a 12 m span gives
a peak at 6 × tan(30°) ≈ 3.46 m. Wind load is commonly applied perpendicular to the slope
using direction="element".
1from anastruct import truss
2
3# 12 m span at 30° pitch — height computed automatically
4t = truss.FinkRoofTruss(
5 width=12.0,
6 roof_pitch_deg=30,
7 top_chord_section={"EI": 8000, "EA": 2e8},
8 bottom_chord_section={"EI": 8000, "EA": 2e8},
9 web_section={"EI": 100, "EA": 8e7},
10)
11
12# 2 kN/m wind load perpendicular to each top-chord slope
13t.apply_q_load_to_top_chord(q=-2, direction="element")
14
15t.system.solve()
16t.show_structure()
17t.system.show_bending_moment()
18t.system.show_reaction_force()