This repository contains a Python implementation of a matrix structural analysis for a 3D truss structure. The project includes the ability to calculate node displacements, reaction forces, and element forces for a given structure based on user-defined inputs.
- main.py: The main entry point for the program. It contains the core logic to set up and solve the structural analysis.
- swingset.py: A script that executes the analysis and handles output formatting and debugging.
- plot.py: Contains the function for plotting the 3D structure based on node coordinates and element connectivity.
- analysis.py: Contains helper functions for calculating element stiffness matrices and transformation matrices.
- Calculate nodal displacements under given loads.
- Compute reaction forces at fixed supports.
- Determine internal forces in each element.
- Plot the 3D structure for visual analysis.
- Python 3.x
- NumPy
- Matplotlib
You can install the required packages using the following command:
pip install numpy matplotlib-
Running the Analysis:
- Ensure that the necessary files (
main.py,swingset.py,plot.py,analysis.py) are in the same directory. - Run the main script to execute the analysis and view the results:
python main.py
- Ensure that the necessary files (
-
Debugging:
- The script outputs detailed variables and matrices used in the analysis. If additional debugging information is needed, you can enable more print statements in
swingset.pyor add to thedebug.pyfile.
- The script outputs detailed variables and matrices used in the analysis. If additional debugging information is needed, you can enable more print statements in
-
Plotting:
- The structure can be visualized by running the plot function in
plot.py. The structure is plotted in 3D using Matplotlib, with nodes and elements clearly indicated.
- The structure can be visualized by running the plot function in
(An example output of deflections)
(Plot of the structure)
-
Input Setup:
- Define the number of nodes (
nnodes) and elements (nele). - Set up node coordinates and element connectivity (
coordandends). - Specify external forces and fixity conditions.
- Define the number of nodes (
-
Matrix Assembly:
- Local stiffness matrices are computed for each element using the
estifffunction fromanalysis.py. - Transformation matrices are calculated to account for the orientation of each element using the
etranfunction. - Global stiffness matrix is assembled by aggregating local matrices.
- Local stiffness matrices are computed for each element using the
-
Solving:
- The global stiffness matrix is partitioned into free and fixed degrees of freedom.
- The displacement vector for free nodes is solved using linear algebra.
- Reaction forces and internal element forces are calculated.
-
Output:
- The script outputs node displacements and reaction forces.
- The structure is visualized using Matplotlib.
- Web Application: Plan to develop a web app that allows users to interactively plot structures and input material properties.
- Additional Debugging: Incorporate a more robust debugging mechanism, potentially via a
debug.pyfile to hold additional variable outputs.


