add_truss() method for axial-only elements.
Overview
In this example, you’ll build a simple 2D truss consisting of:- 5 nodes forming a trapezoidal geometry
- 8 bar elements with two different cross-sectional areas
- Fixed and roller supports at the base
- Concentrated loads at the top chord
Complete Example
Define sections
Create two different sections for different member types:
For truss elements, only the area matters. The inertia and k_factor are not used in axial-only analysis.
Complete Code
Here’s the complete truss analysis example:Understanding Truss Behavior
Sign Convention
Sign Convention
- Positive axial force = Tension (member is being pulled)
- Negative axial force = Compression (member is being pushed)
Truss Assumptions
Truss Assumptions
Truss elements in milcapy make these assumptions:
- Members carry only axial forces (no bending or shear)
- Loads are applied only at joints (nodes)
- Members are connected with frictionless pins
- Member weight is negligible or applied at nodes
When to Use Trusses vs Beams
When to Use Trusses vs Beams
Use
add_truss() when:- Members are slender and connected at joints
- Loads are applied at nodes only
- You only care about axial forces
add_member() (beams) when:- Members have bending moments
- Distributed loads are applied along members
- Joint connections are rigid (moment-resisting)
Next Steps
Portal Frame
Learn how to model frame structures with beams
Membrane Analysis
Explore 2D plane stress elements
API Reference
View the SystemModel API documentation
Load Patterns
Learn about different loading types
