Skip to content

EngineerWithData/LLM-steel-design

Repository files navigation

LLM Agent Framework for Structural Steel Design

An LLM agent prototype for structural steel design automation, which integrated building layout generation, structural analysis, and visualization.

Project overview

This repository combines three preliminary components: building layout generation, PINN-based strength prediction, and an automated structural analysis based on OpenSeesPy code generation.

Project Information:

Main features

Implemented features

1. Building framing geometry design (Task 1)

  • Generate layouts from natural-language building descriptions
  • Create SVG blueprints with columns, beams, and connections
  • Calculate column loads automatically

2. Steel strength verification (Task 2)

  • Calculate column compressive strength with a PINN model
  • Support chat-based interaction
  • Support multi-turn conversations with context memory
  • Recognize design parameters in multiple formats
  • Support OpenAI-compatible APIs and DashScope

3. Structural analysis automation (Task 3)

  • Use separate agents for geometry parsing, code translation, and validation
  • Convert structural descriptions into a JSON intermediate format
  • Generate OpenSeesPy code from structured models
  • Validate syntax, semantics, and structural stability
  • Run OpenSeesPy analyses and parse results automatically
  • Generate engineering summaries with displacements, forces, and checks

4. Integrated workflow

  • Support an end-to-end workflow from natural-language input to analysis results
  • Generate JSON and natural-language reports
  • Coordinate multiple specialized components in one workflow

Features under development

  • Further tuning and optimization of the framing geometry design module
  • Strength prediction of structural steel components based on pre-trained ML models, such as flexural strength alculation
  • The accuracy, efficiency, robustness, and user interaction of this prototype agent-based steel building design will be further evaluated with AISC steel-framed building archetype examples

Quick start

For setup instructions, see QUICKSTART.md.

1. Install dependencies

pip install -r requirements.txt

2. Configure environment variables

Create a .env file with one of the following configurations:

# DashScope
DASHSCOPE_API_KEY=your-api-key
LLM_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
LLM_MODEL=qwen-max

# Or OpenAI
# OPENAI_API_KEY=your-openai-api-key
# LLM_BASE_URL=https://api.openai.com/v1
# LLM_MODEL=gpt-4-turbo-preview

3. Choose a workflow

Option A: Startup scripts

Linux/macOS:

./start_agent.sh

Windows:

start_agent.bat

Option B: Direct commands

Interactive workflow:

python integrated_design.py --mode interactive

Conversational agent:

python -m agent.agent

Quick examples:

python examples/examples_quickstart.py

4. Example workflow

Command: python integrated_design.py --mode interactive

Describe your building: I need a 3-story office building with 4 rooms per floor,
each 20x15 feet, with a central corridor

Dead load (psf) [default: 50]: 60
Live load (psf) [default: 40]: 50
Number of floors [default: 1]: 3

[System processes the design...]

Blueprint saved to: output/blueprint.svg
Analysis results: output/opensees_analysis/
Design report saved to: output/complete_design_report.json

Usage examples

Command-line interaction

python -m agent.agent

Example:

User: Hello, I want to calculate steel column strength
Agent: Please provide A, I, c, L, fy, and delta_o.

User: A=10, I=100, c=5, L=120, fy=50, delta_o=0.1
Agent: [Returns the calculated strength and a short explanation]

Python API

from agent import SteelDesignAgent

agent = SteelDesignAgent(
    model_path="PINN model/normal/model_20250123_165719.pth"
)

response = agent.chat(
    "Calculate steel column strength: A=10, I=100, c=5, L=120, fy=50, delta_o=0.1"
)
print(response)

Direct tool call

from agent.tools import SteelStrengthCalculator

calculator = SteelStrengthCalculator(
    model_path="PINN model/normal/model_20250123_165719.pth"
)

params = {
    'A': 10.0,
    'I': 100.0,
    'c': 5.0,
    'L': 120.0,
    'fy': 50.0,
    'delta_o': 0.1,
}

result = calculator.calculate_column_strength(params)
print(result)

Run tests

python -m pytest tests/ -v

Run example scripts

python examples/usage_examples.py
python examples/multi_turn_demo.py
python examples/examples_quickstart.py

Project Structure

LLM_steel_design/
├── agent/                          # Agent core code (Task 2)
│   ├── agent.py                    # LLM Agent main program
│   ├── config.py                   # Configuration file
│   ├── models/
│   │   └── pinn_predictor.py      # PINN model inference
│   ├── tools/
│   │   └── steel_strength_tools.py # Steel strength calculation tools
│   └── utils/
│       └── create_scalers.py      # Scaler generation tool
├── building_design/                # Building design module (Task 1)
│   ├── __init__.py                 # Module initialization
│   ├── building_parser.py          # Natural language building parser
│   ├── blueprint_generator.py      # 3D blueprint SVG generator
│   └── column_analyzer.py          # Column load analysis and optimization
├── openSeesIntegrate/              # Structural analysis module (Task 3)
│   ├── agents/                     # Multi-agent system
│   │   ├── geometry_agent.py       # Natural language → JSON
│   │   ├── code_translator.py      # JSON → OpenSeesPy code
│   │   └── model_validator.py      # Model and code validation
│   ├── models/                     # Data models
│   │   ├── structural_json.py      # Structural JSON schema
│   │   └── wsection_database.py    # W-section database (40+ sections)
│   ├── executor/                   # Execution engine
│   │   ├── opensees_runner.py      # OpenSeesPy executor
│   │   └── result_parser.py        # Result parser and interpreter
│   ├── opensees_integration.py     # Complete integration system
│   └── openseespyDoc/              # OpenSeesPy documentation (468 files)
├── integrated_design.py            # Complete system integration
├── examples/
│   └── examples_quickstart.py      # NEW: Quick start examples
├── tests/                          # Test suite
│   ├── test_agent.py               # Agent tests
│   ├── test_llm_agent.py           # LLM integration tests
│   ├── test_steel_tools.py         # Steel tools tests
│   └── test_integration.py         # Integration tests
├── PINN model/
│   └── normal/
│       ├── model_20250123_165719.pth  # Pre-trained model
│       └── scalers.pkl                # Scaler
├── output/                         # Generated files directory
│   ├── blueprint.svg               # Generated blueprints
│   ├── design_report.json          # Design reports
│   └── demo_generated_code.py      # NEW: Generated OpenSeesPy code
├── README.md                       # This document
├── requirements.txt                # Python dependencies
├── env.example                     # Environment variable template
├── start_agent.sh                  # Linux/Mac startup script
└── start_agent.bat                 # Windows startup script

Parameter Description

Steel Column Strength Prediction Input Parameters

Parameter Symbol Unit Description Supported Parameter Names
Cross-sectional Area A in² Steel column cross-sectional area A, area
Moment of Inertia I in⁴ Section moment of inertia I, inertia
Distance c in Distance from section center to edge c, distance
Length L in Effective length of column L, length
Yield Strength fy ksi Steel yield strength fy, yield_strength
Initial Imperfection delta_o in Initial geometric imperfection delta_o, imperfection

Output Results

{
  "success": true,
  "component_type": "column",
  "nominal_strength_Pn": 670.74,      // PINN predicted compressive strength (kip)
  "theoretical_strength": 469.28,     // Perry-Robertson theoretical strength (kip)
  "prediction_ratio": 1.43,           // Ratio of predicted to theoretical value
  "unit": "kip",
  "message": "Steel column strength calculation successful"
}

Technical Architecture

Complete System Architecture (v3.0)

The system consists of three integrated tasks working together:

Task 1: Building Design

  • Natural language parsing for building descriptions
  • Automated room layout generation
  • 3D blueprint SVG visualization
  • Column load calculation and analysis

Task 2: Steel Strength Verification

  • Model Type: Physics-Informed Neural Network (PINN)
  • Input Features: A, I, c, L, fy, delta_o (6 features)
  • Output: Steel column compressive strength Pn (kip)
  • Physical Constraints: Perry-Robertson formula
  • Network Structure: 3 hidden layers, 64 neurons per layer

Task 3: Structural Analysis Automation

  • Multi-Agent Architecture:
    • Geometry Agent: Natural language → Structural JSON
    • Code Translation Agent: JSON → OpenSeesPy code (template-based)
    • Model Validation Agent: Three-layer validation (syntax, semantic, structural)
  • W-Section Database: 40+ AISC standard sections
  • OpenSeesPy Integration: Automated execution and result parsing
  • Natural Language Output: Engineering reports with design checks

Integration System

  • Framework: OpenAI Function Calling
  • Supported Models: Qwen, GPT-4, and OpenAI-compatible APIs
  • Workflow Orchestration: Seamless agent coordination
  • Output: Comprehensive design reports with all analysis results

Structural Analysis Documentation

Task 3 provides fully automated structural analysis using OpenSeesPy. The workflow is:

  1. Natural Language to JSON – The Geometry Agent parses the user's description (e.g., "A two‑story frame with 20‑ft columns and a 30‑ft beam") and creates a structured JSON model.
  2. JSON to OpenSeesPy – The Code Translation Agent converts the JSON into a complete OpenSeesPy script based on validated templates.
  3. Model Validation – The Validation Agent performs three layers of checks:
    • Syntax: Ensures the generated Python code is syntactically correct.
    • Semantic: Verifies that geometric relationships and boundary conditions are consistent.
    • Structural: Checks for duplicate node IDs, unsupported element types, and stability of the model.
  4. Execution & Parsing – OpenSeesPy runs the model, and the Result Parser extracts displacements, reactions, and member forces. The system then produces a concise natural‑language report that highlights:
    • Maximum lateral displacement and its location
    • Critical member forces and utilization ratios
    • Design check status (pass/fail) against AISC limits
    • Suggested remedial actions if any checks fail

Command‑line usage

python integrated_design.py --mode interactive   # Step‑by‑step wizard
# or
python -m agent.agent   # Direct chat interface, then call `analyze_structure` tool

Example query

User: Perform structural analysis for a portal frame with two 20‑ft columns, a 30‑ft beam, dead load 50 psf, live load 40 psf, static analysis.

The agent will return a JSON block containing max_displacement, support_reactions, critical_forces, and a brief natural‑language summary suitable for inclusion in a paper.

This automation eliminates manual scripting errors and accelerates the design verification cycle.

Test Results

Test Statistics

Task 3 tests

  • Core functionality tests: 8/8 passed (100%)
  • Force equilibrium: Error < 0.001%
  • Code generation: 110+ lines of valid OpenSeesPy code
  • Result parsing: Displacement and force extraction validated
  • Test coverage: All multi-agent components verified

Overall System Tests

  • Test Framework: pytest 7.4.4
  • Test Files: 12+
  • Test Count: 58+
  • Pass rate: 100%
  • Lines of Code: 10,000+ lines (including Task 3.3)
  • Execution Time: ~3 seconds

Test Categories

Unit Tests (37)

  • test_pinn_model.py (9 tests)

    • Perry-Robertson formula calculation
    • Model loading and prediction
    • Batch prediction
    • Boundary condition testing
  • test_steel_tools.py (13 tests)

    • Parameter parsing (standard/Chinese/English formats)
    • Parameter validation
    • Steel column strength calculation
    • Different parameter effects
  • test_llm_agent.py (11 tests)

    • Agent initialization and configuration
    • Conversation history management
    • Tool integration
    • Tool definition validation
  • test_conversation_features.py (4 tests)

    • Conversation history recording
    • Conversation reset
    • System prompt validation
    • Enhanced prompt content

Integration Tests (8 tests)

  • test_integration.py
    • End-to-end workflow
    • Multi-scenario design
    • Parametric studies
    • Real-world scenarios

Functional Tests (5 tests)

  • test_agent.py
    • Basic functionality verification
    • Quick testing

Run Tests

# Run all tests
cd tests
pytest -v

# Run specific test file
pytest test_pinn_model.py -v

# Show detailed output
pytest -v -s

# Generate coverage report
pytest --cov=agent --cov-report=html

Common Questions

Q1: Prompt "API key not set"

A: Make sure you've created a .env file in the project root directory and correctly filled in DASHSCOPE_API_KEY or OPENAI_API_KEY

Q2: Prompt "Model file does not exist"

A: Make sure the PINN model/normal/model_20250123_165719.pth file exists

Q3: How to switch to OpenAI API?

A: Modify the .env file:

OPENAI_API_KEY=your-openai-key
LLM_BASE_URL=https://api.openai.com/v1
LLM_MODEL=gpt-4-turbo-preview

Q4: Large difference between predicted and theoretical values?

A: This is normal. The PINN model considers more physical effects, and predicted values are typically 30-60% higher than Perry-Robertson theoretical values. It's recommended to regenerate the scaler using actual training data to improve accuracy.

Q5: How to add new component types?

A: Add new calculation functions in agent/tools/steel_strength_tools.py and define corresponding tools in STEEL_STRENGTH_TOOLS.

Dependencies

torch>=2.0.0
numpy>=1.24.0
pandas>=2.0.0
scikit-learn>=1.3.0
matplotlib>=3.7.0
seaborn>=0.12.0
openai>=1.0.0
python-dotenv>=1.0.0
svgwrite>=1.4.0          # For blueprint generation
pydantic>=2.0.0          # NEW: For structural data validation
openseespy>=3.5.0        # NEW: For structural analysis

Development Team

  • Kai Chen - PINN model development and Agent framework implementation
  • Cem Bartu Cevik - Geometry optimization module development
  • Zhidong Zhang - ML model development, Project guidance, Repository Organization, and Post-processing
  • Cristopher D. Moen - Project advisor

References

  1. OpenAI Function Calling Documentation
  2. ANSI/AISC. (2022). AISC 360-22: Specification for Structural Steel Buildings. https://www.aisc.org/aisc/publications/current-standards/aisc-360/
  3. ASCE. (2022). ASCE/SEI 7-22 Minimum Design Loads and Associated Criteria for Buildings and Other Structures. American Society of Civil Engineering. https://sp360.asce.org/personifyebusiness/Merchandise/Product-Details/productId/276865145
  4. Chen, J., & Bao, Y. (2025). Multi-agent large language model framework for code-compliant automated design of reinforced concrete structures. Automation in Construction, 177, 106331. https://doi.org/10.1016/j.autcon.2025.106331
  5. Geng, Z., Liu, J., Cao, R., Cheng, L., Wang, H., & Cheng, M. (2025). A Lightweight Large Language Model-Based Multi-Agent System for 2D Frame Structural Analysis (arXiv:2510.05414). arXiv. https://doi.org/10.48550/arXiv.2510.05414
  6. Liang, H., Kalaleh, M. T., & Mei, Q. (2025). Integrating Large Language Models for Automated Structural Analysis (arXiv:2504.09754). arXiv. https://doi.org/10.48550/arXiv.2504.09754
  7. Liang, H., Zhou, Y., Kalaleh, M. T., & Mei, Q. (2025). Automating Structural Engineering Workflows with Large Language Model Agents (arXiv:2510.11004). arXiv. https://doi.org/10.48550/arXiv.2510.11004
  8. Liu, J., Geng, Z., Cao, R., Cheng, L., Bocchini, P., & Cheng, M. (2025). A Large Language Model-Empowered Agent for Reliable and Robust Structural Analysis (arXiv:2507.02938). arXiv. https://doi.org/10.48550/arXiv.2507.02938
  9. Mazzoni, S., McKenna, F., Scott, M. H., & Fenves, G. L. (2006). OpenSees command language manual (pp. 137–158). Pacific Earthquake Engineering Research (PEER) Center.
  10. Sarker, P. K., Shoumik, S. C., Palit, S., Chowdhury, A. A. N., Alam, M. S., Gazi, M. D. H., & Rahman, M. (2025). Machine learning applications in predicting structural failures and earthquake damage. International Journal of Research in Civil Engineering and Technology, 6(1), 36–45. https://doi.org/10.22271/27078264.2025.v6.i1a.79
  11. Silvia, M. (2024). The OpenSeesPy Library—OpenSeesPy 3.5.1.3 documentation. https://openseespydoc.readthedocs.io/en/latest/index.html
  12. Wu, Q., Bansal, G., Zhang, J., Wu, Y., Li, B., Zhu, E., Jiang, L., Zhang, X., Zhang, S., Liu, J., Awadallah, A. H., White, R. W., Burger, D., & Wang, C. (2023). AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation (arXiv:2308.08155). arXiv. https://doi.org/10.48550/arXiv.2308.08155
  13. Yu, H., Wang, Y., Cheng, T., Yan, Y., Dawson, K. A., Li, S. F. Y., Zheng, Y., & Jin, Y. (2025). Empowering scientific discovery with explainable small domain-specific and large language models. Artificial Intelligence Review, 58(12), 371. https://doi.org/10.1007/s10462-025-11365-w
  14. Zhang, Z., Chen, K., Cevik, C. B., & Moen, C. D. (2025). Mechanics-informed data-driven prediction model of steel column strength. Proceedings of the Annual Stability Conference Structural Stability Research Council.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Associated research paper

This associated research paper is available in "2026 Proceedings of the SSRC Annual Stability Conference": https://files.ssrcweb.org/proceedings/2026/Zhang_et_al_SSRC_2026.pdf

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors