A comprehensive Python library for structural engineering analysis implementing various theoretical frameworks for beams, columns, plates, and other structural elements.
- Complete Type Safety: Full type annotations and validated inputs
- Engineering-Focused: Designed by engineers, for engineers
- Analytical Verification: All implementations tested against known analytical solutions
- Modern Python: Built with UV package management and Ruff linting
- Comprehensive Theory Coverage: Implementation of classical and advanced structural analysis theories
# Using pip
pip install structural-analysis
# Using UV (recommended for development)
uv add structural-analysisfrom structural_analysis import StructuralAnalysis
# Initialize the analysis library
analysis = StructuralAnalysis()
# Analyze a simply supported beam
beam_result = analysis.beam_theory.euler_bernoulli(
length=4.0, # 4 meter beam
E=200e9, # Steel elastic modulus (Pa)
second_moment=8.33e-6, # Second moment of area (m^4)
load_type="point", # Point load
load_magnitude=10000, # 10 kN load
load_position=2.0, # At center
boundary_conditions="simply_supported"
)
print(f"Max deflection: {beam_result['max_deflection']:.6f} m")
print(f"Max moment: {beam_result['max_moment']:.0f} NΒ·m")
# Analyze column buckling
column_result = analysis.column_theory.euler_buckling(
length=3.0, # 3 meter column
E=200e9, # Steel elastic modulus (Pa)
second_moment=8.33e-6, # Second moment of area (m^4)
end_conditions="pinned", # Pinned-pinned ends
safety_factor=2.0 # Design safety factor
)
print(f"Critical load: {column_result['critical_load']/1000:.1f} kN")
print(f"Design load: {column_result['design_load']/1000:.1f} kN")
print(f"Recommendation: {column_result['recommendation']}")- Euler-Bernoulli: Classical beam bending for slender beams
- Timoshenko: Includes shear deformation effects (coming soon)
- Reddy-Bickford: Higher-order shear theory (coming soon)
- Euler Buckling: β Elastic buckling analysis with multiple end conditions
- Rankine-Gordon: Combined buckling-crushing (coming soon)
- Johnson Parabolic: Inelastic buckling (coming soon)
- Plate/Shell Theory: Kirchhoff, Mindlin-Reissner theories
- Material Theory: Linear elastic, elastic-plastic, viscoelastic
- Dynamic Theory: Natural frequencies, response analysis
- Energy Methods: Castigliano's theorem, virtual work
- And many more...
# Distributed load on cantilever
cantilever_result = analysis.beam_theory.euler_bernoulli(
length=3.0,
E=200e9,
second_moment=5.21e-6,
load_type="distributed",
load_magnitude=5000, # 5 kN/m
boundary_conditions="cantilever",
num_points=200 # High resolution analysis
)
# Applied moment
moment_result = analysis.beam_theory.euler_bernoulli(
length=4.0,
E=200e9,
second_moment=8.33e-6,
load_type="moment",
load_magnitude=15000, # 15 kNΒ·m
load_position=1.0, # 1m from left end
boundary_conditions="simply_supported"
)# Fixed-fixed column (strongest)
fixed_result = analysis.column_theory.euler_buckling(
length=4.0,
E=200e9,
second_moment=8.33e-6,
end_conditions="fixed", # K = 0.5
safety_factor=2.5
)
# Cantilever column (weakest)
cantilever_result = analysis.column_theory.euler_buckling(
length=4.0,
E=200e9,
second_moment=8.33e-6,
end_conditions="fixed_free", # K = 2.0
safety_factor=3.0
)
print(f"Fixed-fixed critical load: {fixed_result['critical_load']/1000:.1f} kN")
print(f"Cantilever critical load: {cantilever_result['critical_load']/1000:.1f} kN")
print(f"Strength ratio: {fixed_result['critical_load']/cantilever_result['critical_load']:.1f}")All analysis methods return structured dictionaries with both arrays and scalars:
{
# Arrays for plotting and detailed analysis
'x': np.array([...]), # Position coordinates
'deflection': np.array([...]), # Deflection values
'moment': np.array([...]), # Moment values
'shear': np.array([...]), # Shear values
# Scalars for engineering review
'max_deflection': float, # Maximum deflection
'max_moment': float, # Maximum moment
'max_shear': float, # Maximum shear
}The library follows a modular architecture where:
- Categories (e.g., "Beam Theory") β Python modules (
beam_theory.py) - Theory Names (e.g., "Euler-Bernoulli") β Class methods (
euler_bernoulli()) - Main Class
StructuralAnalysisβ Unified access to all theories
StructuralAnalysis
βββ beam_theory (BeamTheory)
β βββ euler_bernoulli()
β βββ timoshenko()
β βββ ...
βββ column_theory (ColumnTheory)
β βββ euler_buckling()
β βββ rankine_gordon()
β βββ ...
βββ ... (other theory categories)
All implementations are validated against analytical solutions:
# Run all tests
uv run pytest tests/ -v
# Run specific theory tests
uv run pytest tests/test_beam_theory.py -v
uv run pytest tests/test_column_theory.py -v
# Check code quality
ruff format .
ruff check . --fix# Clone and setup
git clone https://github.com/your-username/structural-analysis.git
cd structural-analysis
uv sync
# Activate environment
uv shell- Plan Theory: Reference the development roadmap for planned theories
- Implement Method: Add method to appropriate module (e.g.,
beam_theory.py) following established patterns - Write Tests: Create comprehensive tests with analytical verification (see contributing guide)
- Quality Checks: Run
ruff format . && ruff check . --fix && uv run pytest tests/ -v - Documentation: Update theory docs and examples
See our Contributing Guide for detailed implementation guidelines.
This library implements classical structural engineering theories with modern software practices:
- Euler-Bernoulli Beam Theory: Small deflections, plane sections remain plane
- Euler Buckling Theory: Elastic instability of perfect columns
- Engineering Units: SI units throughout (N, Pa, m, kg)
- Safety Factors: Built-in design load calculations
- Boundary Conditions: Complete support for real-world constraints
We welcome contributions! Please see our development workflow in .github/copilot-instructions.md.
MIT License - see LICENSE file for details.
- Timoshenko, S.P. & Gere, J.M. "Theory of Elastic Stability"
- Hibbeler, R.C. "Structural Analysis"
- Classical structural engineering texts and modern research
Built with β€οΈ for the structural engineering community