Files
Atomizer/README.md
Anto01 90a9e020d8 feat: Complete Phase 3.1 - Extractor Orchestration & End-to-End Automation
Phase 3.1 completes the ZERO-MANUAL-CODING automation pipeline by
integrating all phases into a seamless workflow from natural language
request to final objective value.

Key Features:
- ExtractorOrchestrator integrates Phase 2.7 LLM + Phase 3.0 Research Agent
- Automatic extractor generation from LLM workflow output
- Dynamic loading and execution on real OP2 files
- Smart parameter filtering per extraction pattern type
- Multi-extractor support in single workflow
- Complete end-to-end test passed on real bracket OP2

Complete Automation Pipeline:
  User Natural Language Request
      ↓
  Phase 2.7 LLM Analysis
      ↓
  Phase 3.1 Orchestrator
      ↓
  Phase 3.0 Research Agent (auto OP2 code gen)
      ↓
  Generated Extractor Modules
      ↓
  Dynamic Execution on Real OP2
      ↓
  Phase 2.8 Inline Calculations
      ↓
  Phase 2.9 Post-Processing Hooks
      ↓
  Final Objective → Optuna

Test Results:
- Generated displacement extractor: PASSED
- Executed on bracket OP2: PASSED
- Extracted max_displacement: 0.361783mm at node 91
- Calculated normalized objective: 0.072357
- Multi-extractor generation: PASSED

New Files:
- optimization_engine/extractor_orchestrator.py (380+ lines)
- tests/test_phase_3_1_integration.py (200+ lines)
- docs/SESSION_SUMMARY_PHASE_3_1.md (comprehensive documentation)
- optimization_engine/result_extractors/generated/ (auto-generated extractors)

Modified Files:
- README.md - Added Phase 3.1 completion status

ZERO MANUAL CODING - Complete automation achieved!

Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 19:39:04 -05:00

385 lines
16 KiB
Markdown

# Atomizer
> Advanced LLM-native optimization platform for Siemens NX Simcenter
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![License](https://img.shields.io/badge/license-Proprietary-red.svg)](LICENSE)
[![Status](https://img.shields.io/badge/status-alpha-yellow.svg)](https://github.com)
## Overview
Atomizer is an **LLM-native optimization framework** for Siemens NX Simcenter that transforms how engineers interact with optimization workflows. Instead of manual JSON configuration and scripting, Atomizer uses AI as a collaborative engineering assistant.
### Core Philosophy
Atomizer enables engineers to:
- **Describe optimizations in natural language** instead of writing configuration files
- **Generate custom analysis functions on-the-fly** (RSS metrics, weighted objectives, constraints)
- **Get intelligent recommendations** based on optimization results and surrogate models
- **Generate comprehensive reports** with AI-written insights and visualizations
- **Extend the framework autonomously** through LLM-driven code generation
### Key Features
- **LLM-Driven Workflow**: Natural language study creation, configuration, and analysis
- **Advanced Optimization**: Optuna-powered TPE, Gaussian Process surrogates, multi-objective Pareto fronts
- **Dynamic Code Generation**: AI writes custom Python functions and NX journal scripts during optimization
- **Intelligent Decision Support**: Surrogate quality assessment, sensitivity analysis, engineering recommendations
- **Real-Time Monitoring**: Interactive web dashboard with live progress tracking
- **Extensible Architecture**: Plugin system with hooks for pre/post mesh, solve, and extraction phases
- **Self-Improving**: Feature registry that learns from user workflows and expands capabilities
📘 See [DEVELOPMENT_ROADMAP.md](DEVELOPMENT_ROADMAP.md) for the complete vision and implementation plan.
## Architecture
```
┌─────────────────────────────────────────────────────────┐
│ LLM Interface Layer │
│ Claude Skill + Natural Language Parser + Workflow Mgr │
└─────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│ Optimization Engine Core │
│ Plugin System + Feature Registry + Code Generator │
└─────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│ Execution Layer │
│ NX Solver (via Journals) + Optuna + Result Extractors │
└─────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│ Analysis & Reporting │
│ Surrogate Quality + Sensitivity + Report Generator │
└─────────────────────────────────────────────────────────┘
```
## Quick Start
### Prerequisites
- **Siemens NX 2412** with NX Nastran solver
- **Python 3.10+** (recommend Anaconda)
- **Git** for version control
### Installation
1. **Clone the repository**:
```bash
git clone https://github.com/yourusername/Atomizer.git
cd Atomizer
```
2. **Create Python environment**:
```bash
conda create -n atomizer python=3.10
conda activate atomizer
```
3. **Install dependencies**:
```bash
pip install -r requirements.txt
```
4. **Configure NX path** (edit if needed):
- Default NX path: `C:\Program Files\Siemens\Simcenter3D_2412\NXBIN\run_journal.exe`
- Update in `optimization_engine/nx_solver.py` if different
### Basic Usage
#### Example 1: Natural Language Optimization (Future - Phase 2)
```
User: "Let's create a new study to minimize stress on my bracket"
LLM: "Study created! Please drop your .sim file into the study folder,
then I'll explore it to find available design parameters."
User: "Done. I want to vary wall_thickness between 3-8mm"
LLM: "Perfect! I've configured:
- Objective: Minimize max von Mises stress
- Design variable: wall_thickness (3.0 - 8.0 mm)
- Sampler: TPE with 50 trials
Ready to start?"
User: "Yes, go!"
LLM: "Optimization running! View progress at http://localhost:8080"
```
#### Example 2: Current JSON Configuration
Create `studies/my_study/config.json`:
```json
{
"sim_file": "studies/bracket_stress_minimization/model/Bracket_sim1.sim",
"design_variables": [
{
"name": "wall_thickness",
"expression_name": "wall_thickness",
"min": 3.0,
"max": 8.0,
"units": "mm"
}
],
"objectives": [
{
"name": "max_stress",
"extractor": "stress_extractor",
"metric": "max_von_mises",
"direction": "minimize",
"weight": 1.0,
"units": "MPa"
}
],
"optimization_settings": {
"n_trials": 50,
"sampler": "TPE",
"n_startup_trials": 20
}
}
```
Run optimization:
```bash
python tests/test_journal_optimization.py
# Or use the quick 5-trial test:
python run_5trial_test.py
```
## Features
- **Intelligent Optimization**: Optuna-powered TPE sampler with multi-objective support
- **NX Integration**: Seamless journal-based control of Siemens NX Simcenter
- **Smart Logging**: Detailed per-trial logs + high-level optimization progress tracking
- **Plugin System**: Extensible hooks at pre-solve, post-solve, and post-extraction points
- **Study Management**: Isolated study folders with automatic result organization
- **Resume Capability**: Interrupt and resume optimizations without data loss
- **Web Dashboard**: Real-time monitoring and configuration UI
- **Example Study**: Bracket stress minimization with full documentation
**🚀 What's Next**: Natural language optimization configuration via LLM interface (Phase 2)
For detailed development status and todos, see [DEVELOPMENT.md](DEVELOPMENT.md).
For the long-term vision, see [DEVELOPMENT_ROADMAP.md](DEVELOPMENT_ROADMAP.md).
## Project Structure
```
Atomizer/
├── optimization_engine/ # Core optimization logic
│ ├── runner.py # Main optimization runner
│ ├── nx_solver.py # NX journal execution
│ ├── nx_updater.py # NX model parameter updates
│ ├── pynastran_research_agent.py # Phase 3: Auto OP2 code gen ✅
│ ├── hook_generator.py # Phase 2.9: Auto hook generation ✅
│ ├── result_extractors/ # OP2/F06 parsers
│ │ └── extractors.py # Stress, displacement extractors
│ └── plugins/ # Plugin system (Phase 1 ✅)
│ ├── hook_manager.py # Hook registration & execution
│ ├── hooks.py # HookPoint enum, Hook dataclass
│ ├── pre_solve/ # Pre-solve lifecycle hooks
│ │ ├── detailed_logger.py
│ │ └── optimization_logger.py
│ ├── post_solve/ # Post-solve lifecycle hooks
│ │ └── log_solve_complete.py
│ ├── post_extraction/ # Post-extraction lifecycle hooks
│ │ ├── log_results.py
│ │ └── optimization_logger_results.py
│ └── post_calculation/ # Post-calculation hooks (Phase 2.9 ✅)
│ ├── weighted_objective_test.py
│ ├── safety_factor_hook.py
│ └── min_to_avg_ratio_hook.py
├── dashboard/ # Web UI
│ ├── api/ # Flask backend
│ ├── frontend/ # HTML/CSS/JS
│ └── scripts/ # NX expression extraction
├── studies/ # Optimization studies
│ ├── README.md # Comprehensive studies guide
│ └── bracket_stress_minimization/ # Example study
│ ├── README.md # Study documentation
│ ├── model/ # FEA model files (.prt, .sim, .fem)
│ ├── optimization_config_stress_displacement.json
│ └── optimization_results/ # Generated results (gitignored)
│ ├── optimization.log # High-level progress log
│ ├── trial_logs/ # Detailed per-trial logs
│ ├── history.json # Complete optimization history
│ └── study_*.db # Optuna database
├── tests/ # Unit and integration tests
│ ├── test_hooks_with_bracket.py
│ ├── run_5trial_test.py
│ └── test_journal_optimization.py
├── docs/ # Documentation
├── atomizer_paths.py # Intelligent path resolution
├── DEVELOPMENT_ROADMAP.md # Future vision and phases
└── README.md # This file
```
## Example: Bracket Stress Minimization
A complete working example is in `studies/bracket_stress_minimization/`:
```bash
# Run the bracket optimization (50 trials, TPE sampler)
python tests/test_journal_optimization.py
# View results
python dashboard/start_dashboard.py
# Open http://localhost:8080 in browser
```
**What it does**:
1. Loads `Bracket_sim1.sim` with wall thickness = 5mm
2. Varies thickness from 3-8mm over 50 trials
3. Runs FEA solve for each trial
4. Extracts max stress and displacement from OP2
5. Finds optimal thickness that minimizes stress
**Results** (typical):
- Best thickness: ~4.2mm
- Stress reduction: 15-20% vs. baseline
- Convergence: ~30 trials to plateau
## Dashboard Usage
Start the dashboard:
```bash
python dashboard/start_dashboard.py
```
Features:
- **Create studies** with folder structure (sim/, results/, config.json)
- **Drop .sim/.prt files** into study folders
- **Explore .sim files** to extract expressions via NX
- **Configure optimization** with 5-step wizard:
1. Simulation files
2. Design variables
3. Objectives
4. Constraints
5. Optimization settings
- **Monitor progress** with real-time charts
- **View results** with trial history and best parameters
## Vision: LLM-Native Engineering Assistant
Atomizer is evolving into a comprehensive AI-powered engineering platform. See [DEVELOPMENT_ROADMAP.md](DEVELOPMENT_ROADMAP.md) for details on:
- **Phase 1-7 development plan** with timelines and deliverables
- **Example use cases** demonstrating natural language workflows
- **Architecture diagrams** showing plugin system and LLM integration
- **Success metrics** for each phase
### Future Capabilities
```
User: "Add RSS function combining stress and displacement"
→ LLM: Writes Python function, validates, registers as custom objective
User: "Use surrogate to predict these 10 parameter sets"
→ LLM: Checks surrogate R² > 0.9, runs predictions with confidence intervals
User: "Make an optimization report"
→ LLM: Generates HTML with plots, insights, recommendations (30 seconds)
User: "Why did trial #34 perform best?"
→ LLM: "Trial #34 had optimal stress distribution due to thickness 4.2mm
creating uniform load paths. Fillet radius 3.1mm reduced stress
concentration by 18%. This combination is Pareto-optimal."
```
## Development Status
### Completed Phases
- [x] **Phase 1**: Core optimization engine & Plugin system ✅
- NX journal integration
- Web dashboard
- Lifecycle hooks (pre-solve, post-solve, post-extraction)
- [x] **Phase 2.5**: Intelligent Codebase-Aware Gap Detection ✅
- Scans existing capabilities before requesting examples
- Matches workflow steps to implemented features
- 80-90% accuracy on complex optimization requests
- [x] **Phase 2.6**: Intelligent Step Classification ✅
- Distinguishes engineering features from inline calculations
- Identifies post-processing hooks vs FEA operations
- Foundation for smart code generation
- [x] **Phase 2.7**: LLM-Powered Workflow Intelligence ✅
- Replaces static regex with Claude AI analysis
- Detects ALL intermediate calculation steps
- Understands engineering context (PCOMP, CBAR, element forces, etc.)
- 95%+ expected accuracy with full nuance detection
- [x] **Phase 2.8**: Inline Code Generation ✅
- Auto-generates Python code for simple math operations
- Handles avg/min/max, normalization, percentage calculations
- Direct integration with Phase 2.7 LLM output
- Zero manual coding for trivial operations
- [x] **Phase 2.9**: Post-Processing Hook Generation ✅
- Auto-generates standalone Python middleware scripts
- Integrated with Phase 1 lifecycle hook system
- Handles weighted objectives, custom formulas, constraints, comparisons
- Complete JSON-based I/O for optimization loops
- Zero manual scripting for post-processing operations
- [x] **Phase 3**: pyNastran Documentation Integration ✅
- Automated OP2 extraction code generation
- Documentation research via WebFetch
- 3 core extraction patterns (displacement, stress, force)
- Knowledge base for learned patterns
- Successfully tested on real OP2 files
- Zero manual coding for result extraction!
- [x] **Phase 3.1**: Complete Automation Pipeline ✅
- Extractor orchestrator integrates Phase 2.7 + Phase 3.0
- Automatic extractor generation from LLM output
- Dynamic loading and execution on real OP2 files
- End-to-end test passed: Request → Code → Execution → Objective
- ZERO MANUAL CODING - Complete automation achieved!
### Next Priorities
- [ ] **Phase 3.2**: Optimization runner integration with orchestrator
- [ ] **Phase 3.5**: NXOpen introspection & pattern curation
- [ ] **Phase 4**: Code generation for complex FEA features
- [ ] **Phase 5**: Analysis & decision support
- [ ] **Phase 6**: Automated reporting
**For Developers**:
- [DEVELOPMENT.md](DEVELOPMENT.md) - Current status, todos, and active development
- [DEVELOPMENT_ROADMAP.md](DEVELOPMENT_ROADMAP.md) - Strategic vision and long-term plan
- [CHANGELOG.md](CHANGELOG.md) - Version history and changes
## License
Proprietary - Atomaste © 2025
## Support
- **Documentation**: [docs/](docs/)
- **Studies**: [studies/](studies/) - Optimization study templates and examples
- **Development Roadmap**: [DEVELOPMENT_ROADMAP.md](DEVELOPMENT_ROADMAP.md)
- **Email**: antoine@atomaste.com
## Resources
### NXOpen References
- **Official API Docs**: [Siemens NXOpen Documentation](https://docs.sw.siemens.com/en-US/doc/209349590/)
- **NXOpenTSE**: [The Scripting Engineer's Guide](https://nxopentsedocumentation.thescriptingengineer.com/)
- **Our Guide**: [NXOpen Resources](docs/NXOPEN_RESOURCES.md)
### Optimization
- **Optuna Documentation**: [optuna.readthedocs.io](https://optuna.readthedocs.io/)
- **pyNastran**: [github.com/SteveDoyle2/pyNastran](https://github.com/SteveDoyle2/pyNastran)
---
**Built with ❤️ by Atomaste** | Powered by Optuna, NXOpen, and Claude