Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2D Truss Solver (Matrix Stiffness Method)

Python implementation of a planar truss solver for strength-of-materials coursework. The code reads node/element/material data from CSV files, assembles the global stiffness matrix, solves for nodal displacements and support reactions, and reports axial forces, stresses, and material phase for each member.

Features

  • Linear-elastic 2D truss analysis using the matrix stiffness method (NumPy)
  • CSV-driven inputs for nodes, elements, and materials; easy to edit for new cases
  • Computes nodal displacements, support reactions, axial forces, stresses, and state (tension/compression)
  • Flags plastic/fracture phases based on yield/ultimate stress limits
  • Text tables generated via tabulate and saved to io/result.txt
  • Modular layout (io/, model/, solver/) for simple extension or replacement of components

Project Layout

  • main.py — orchestrates reading inputs, assembling, solving, and writing results
  • io/reader.py — loads CSV data from io/
  • io/writer.py — formats and writes result tables to io/result.txt
  • model/ — core classes: Node, Element, Material
  • solver/ — assembly (assembly.py), boundary conditions (boundary.py), and linear solution (solve.py)
  • io/*.csv — sample datasets for nodes, elements, and material properties

Input File Formats (CSV)

  • io/nodes_input.csv
    • Columns: ID, x, y, F_x, F_y, constrained_x, constrained_y
    • constrained_*: 1 for fixed DOF, 0 for free. Use consistent units for forces and lengths.
  • io/elements_input.csv
    • Columns: ID, node_1, node_2, cross_sectional_area, material
    • material must match a name in material.csv; area in square meters.
  • io/material.csv
    • Columns: name, E, S_y, S_u
    • E in GPa; S_y and S_u in MPa. Values are converted to Pascals internally.

Requirements

  • Python 3.9+
  • Packages: numpy, tabulate (see requirements.txt)

How to Run

From the directory that contains the mom_project folder:

python -m venv .venv
.venv\Scripts\activate
pip install -r mom_project/requirements.txt
python -m mom_project.main

After execution, open mom_project/io/result.txt to view:

  • Nodal displacements (Ux, Uy)
  • Support reactions (Rx, Ry) at constrained DOFs
  • Element axial forces, stresses, tension/compression state, and phase (Elastic/Plastic/Fracture)

Sample Output (truncated)

Nodal Displacements (Ux, Uy):
|   Node |           Ux |           Uy |
|      3 | -2.35357e-05 | -3.09817e-05 |
...
Element Axial Forces and Stresses:
|   Element |                N |            Sigma | State       | Phase   |
|         6 | -2.82843e+04     | 2.35702e+06      | Tension     | Elastic |

Assumptions and Notes

  • Pin-jointed, small-displacement, linear-elastic truss; no geometric or material nonlinearity.
  • Node IDs and element connectivity must be consistent across CSV files.
  • Units must be compatible across forces, lengths, and material properties.
  • To analyze a new case, edit the three CSV files in io/ and rerun python -m mom_project.main.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages