A Python-based structural analysis tool for analysing two-dimensional beams and frame structures using the direct stiffness method.
This project explores the implementation of a structural solver from first principles, covering structural modelling, element stiffness, load application, global system assembly and the calculation of nodal displacements, support reactions and element forces.
- Structural modelling: Define nodes, frame elements, support restraints and material and cross-sectional properties.
- Frame analysis: Solve the assembled structural system to obtain nodal displacements and support reactions.
- Element force recovery: Retrieve element force results for further structural assessment.
- Loading: Apply point loads using the project's load modelling interface.
- Example models: Explore cantilever beams, simply supported beams and portal frames.
- Validation: Develop automated tests comparing numerical results against analytical solutions and structural equilibrium checks.
The solver represents structures using two-dimensional frame elements, with three degrees of freedom per node:
- Horizontal displacement, (u_x)
- Vertical displacement, (u_y)
- Rotation, (\theta_z)
Each element is defined by its end nodes, Young's modulus (E), cross-sectional area (A) and second moment of area (I).
The analysis follows the direct stiffness method:
- Define the structural geometry, element properties and boundary conditions.
- Form the element stiffness matrices.
- Assemble the global stiffness matrix and load vector.
- Apply support restraints and solve for nodal displacements.
- Calculate support reactions and recover element forces.
The solver uses the following sign conventions:
- Local x-axis: Positive from the element's start node (i) to its end node (j).
- Local y-axis: Positive perpendicular to the local x-axis, following the element's local coordinate system.
- Axial force: Positive in tension and negative in compression.
- Shear force: Positive in the direction of the positive local y-axis, subject to the element end-force convention.
- Bending moment: Positive counter-clockwise about the out-of-plane (z)-axis, subject to the element end-force convention.
- Displacements: Positive in the direction of the corresponding global or local coordinate axis.
- Rotations: Positive counter-clockwise.
The sign of reported element end forces depends on the local coordinate system and the force-recovery convention used by the solver.
- Python 3.12 or a compatible Python version
- NumPy
- pytest (for running the test suite)
Install the dependencies listed in requirements.txt.
Clone the repository and navigate into the project directory:
git clone https://github.com/SofiaV23-png/FrameAnalysis.git
cd FrameAnalysisCreate and activate a virtual environment:
python3 -m venv FA_venv
source FA_venv/bin/activateInstall the project dependencies:
python -m pip install -r requirements.txtRun an example from the repository root using Python's module syntax. For example:
python -m examples.cantileverOther available examples include:
python -m examples.simply_supported_beam
python -m examples.portal_frameEach example defines a structural model, runs the analysis and displays the resulting displacements, reactions and element forces.
FrameAnalysis/
├── analysis/ # Analysis and solution procedures
├── models/ # Nodes, elements, loads and frame models
├── examples/ # Demonstration structural models
├── tests/ # Automated tests
├── main.py
├── requirements.txt
├── .gitignore
└── README.md
Run the automated test suite from the repository root:
pytestThe aim of the validation suite is to check solver behaviour against known analytical solutions for simple structural systems, alongside checks on boundary conditions, support reactions and equilibrium.
For meaningful validation, expected values should be derived independently of the solver. Tests should also account for the sign conventions and degree-of-freedom ordering used by the implementation.
Features and improvements actively being worked on:
- Expanding the validation suite to cover additional structural configurations and loading cases.
- Improving the presentation and visualisation of analysis results.
- Refining the handling of element forces and support reactions.
Potential extensions to explore after the current development work:
- Support for distributed loads and more complex loading conditions.
- Visualisation of bending moment, shear force and axial force diagrams.
- Improved input validation, error handling and numerical robustness.
- Automated calculation of second moments of area for standard cross-sections and a library of predefined material properties.
This project combines structural engineering theory with software development to explore how numerical methods can be translated into practical engineering tools. It provides a foundation for further work in computational structural analysis and engineering software.