Skip to content

A comprehensive Python library for structural engineering analysis implementing theoretical frameworks for beams, columns, plates, and other structural elements with full type safety and analytical verification.

License

Notifications You must be signed in to change notification settings

osama-ata/structural-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Structural Analysis Library

A comprehensive Python library for structural engineering analysis implementing various theoretical frameworks for beams, columns, plates, and other structural elements.

πŸš€ Features

  • 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

πŸ“¦ Installation

# Using pip
pip install structural-analysis

# Using UV (recommended for development)
uv add structural-analysis

πŸ—οΈ Quick Start

from 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']}")

πŸ“š Available Theories

Beam Theory

  • Euler-Bernoulli: Classical beam bending for slender beams
  • Timoshenko: Includes shear deformation effects (coming soon)
  • Reddy-Bickford: Higher-order shear theory (coming soon)

Column Theory

  • Euler Buckling: βœ… Elastic buckling analysis with multiple end conditions
  • Rankine-Gordon: Combined buckling-crushing (coming soon)
  • Johnson Parabolic: Inelastic buckling (coming soon)

Additional Categories

  • 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...

πŸ”§ Advanced Usage

Beam Analysis with Different Loading

# 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"
)

Column Analysis with Different End Conditions

# 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}")

🎯 Return Value Structure

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
}

πŸ›οΈ Architecture

The library follows a modular architecture where:

  1. Categories (e.g., "Beam Theory") β†’ Python modules (beam_theory.py)
  2. Theory Names (e.g., "Euler-Bernoulli") β†’ Class methods (euler_bernoulli())
  3. 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)

πŸ§ͺ Testing and Validation

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

πŸ› οΈ Development

Environment Setup

# Clone and setup
git clone https://github.com/your-username/structural-analysis.git
cd structural-analysis
uv sync

# Activate environment
uv shell

Adding New Theories

  1. Plan Theory: Reference the development roadmap for planned theories
  2. Implement Method: Add method to appropriate module (e.g., beam_theory.py) following established patterns
  3. Write Tests: Create comprehensive tests with analytical verification (see contributing guide)
  4. Quality Checks: Run ruff format . && ruff check . --fix && uv run pytest tests/ -v
  5. Documentation: Update theory docs and examples

See our Contributing Guide for detailed implementation guidelines.

πŸ“– Engineering Background

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

🀝 Contributing

We welcome contributions! Please see our development workflow in .github/copilot-instructions.md.

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ”— References

  • 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

About

A comprehensive Python library for structural engineering analysis implementing theoretical frameworks for beams, columns, plates, and other structural elements with full type safety and analytical verification.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published