feat: Add neural loop automation - templates, auto-trainer, CLI
Closes the neural training loop with automated workflow: - atomizer.py: One-command neural workflow CLI - auto_trainer.py: Auto-training trigger system (50pt threshold) - template_loader.py: Study creation from templates - study_reset.py: Study reset/cleanup utility - 3 templates: beam stiffness, bracket stress, frequency tuning - State assessment document (Nov 25) Usage: python atomizer.py neural-optimize --study my_study --trials 500 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
149
templates/README.md
Normal file
149
templates/README.md
Normal file
@@ -0,0 +1,149 @@
|
||||
# Atomizer Study Templates
|
||||
|
||||
Quick-start templates for common structural optimization problems.
|
||||
|
||||
## Available Templates
|
||||
|
||||
| Template | Analysis | Objectives | Use Case |
|
||||
|----------|----------|------------|----------|
|
||||
| `beam_stiffness_optimization` | Static | Maximize stiffness | Cantilever beams, support arms |
|
||||
| `bracket_stress_minimization` | Static | Minimize stress | Mounting brackets, L-brackets |
|
||||
| `frequency_tuning` | Modal | Minimize mass + Maximize frequency | Motor mounts, drone arms |
|
||||
|
||||
## Usage
|
||||
|
||||
### Option 1: Create Study from Template (Recommended)
|
||||
|
||||
```bash
|
||||
python -m atomizer create-study --template beam_stiffness --name my_beam_study
|
||||
```
|
||||
|
||||
This creates a new study folder with:
|
||||
- `1_setup/optimization_config.json` - Configuration (editable)
|
||||
- `1_setup/model/` - Empty folder for your NX files
|
||||
- `2_results/` - Empty folder for results
|
||||
- `run_optimization.py` - Runner script
|
||||
- `README.md` - Study-specific instructions
|
||||
|
||||
### Option 2: Copy and Customize
|
||||
|
||||
1. Copy template JSON to your study folder:
|
||||
```bash
|
||||
copy templates\beam_stiffness_optimization.json studies\my_study\1_setup\optimization_config.json
|
||||
```
|
||||
|
||||
2. Edit the config:
|
||||
- Update `study_name`
|
||||
- Adjust `design_variables` bounds for your model
|
||||
- Modify `constraints` thresholds
|
||||
- Update `simulation` file names
|
||||
|
||||
3. Add your NX model files to `1_setup/model/`
|
||||
|
||||
4. Run optimization:
|
||||
```bash
|
||||
python studies\my_study\run_optimization.py --trials 50
|
||||
```
|
||||
|
||||
## Template Details
|
||||
|
||||
### Beam Stiffness Optimization
|
||||
|
||||
**Goal**: Maximize bending stiffness (minimize tip displacement) while staying under mass budget.
|
||||
|
||||
**Design Variables**:
|
||||
- `beam_width` - Cross-section width (mm)
|
||||
- `beam_height` - Cross-section height (mm)
|
||||
- `beam_length` - Overall length (mm)
|
||||
|
||||
**Constraints**:
|
||||
- Maximum mass limit
|
||||
- Maximum stress limit
|
||||
|
||||
**Required NX Expressions**: `beam_width`, `beam_height`, `beam_length`
|
||||
|
||||
---
|
||||
|
||||
### Bracket Stress Minimization
|
||||
|
||||
**Goal**: Minimize peak von Mises stress to increase fatigue life and safety factor.
|
||||
|
||||
**Design Variables**:
|
||||
- `wall_thickness` - Main wall thickness (mm)
|
||||
- `fillet_radius` - Corner radius (mm) - key for stress relief
|
||||
- `web_thickness` - Stiffening web thickness (mm)
|
||||
- `rib_count` - Number of stiffening ribs (integer)
|
||||
|
||||
**Constraints**:
|
||||
- Maximum displacement limit (stiffness)
|
||||
- Maximum mass limit (weight budget)
|
||||
|
||||
**Required NX Expressions**: `wall_thickness`, `fillet_radius`, `web_thickness`, `rib_count`
|
||||
|
||||
---
|
||||
|
||||
### Frequency Tuning
|
||||
|
||||
**Goal**: Multi-objective - minimize mass while maximizing first natural frequency to avoid resonance.
|
||||
|
||||
**Design Variables**:
|
||||
- `section_width` - Cross-section width (mm)
|
||||
- `section_height` - Cross-section height (mm)
|
||||
- `arm_length` - Cantilever length (mm)
|
||||
- `wall_thickness` - Wall thickness for hollow sections (mm)
|
||||
|
||||
**Constraints**:
|
||||
- Minimum frequency limit (above excitation)
|
||||
- Maximum stress limit (static strength)
|
||||
|
||||
**Required NX Expressions**: `section_width`, `section_height`, `arm_length`, `wall_thickness`
|
||||
|
||||
**Note**: Requires modal analysis solution (SOL 103) in NX simulation.
|
||||
|
||||
## Customizing Templates
|
||||
|
||||
Templates are JSON files with placeholders. Key sections to customize:
|
||||
|
||||
```json
|
||||
{
|
||||
"study_name": "your_study_name",
|
||||
"design_variables": [
|
||||
{
|
||||
"parameter": "your_nx_expression_name",
|
||||
"bounds": [min_value, max_value],
|
||||
"description": "What this parameter controls"
|
||||
}
|
||||
],
|
||||
"constraints": [
|
||||
{
|
||||
"name": "your_constraint",
|
||||
"type": "less_than",
|
||||
"threshold": your_limit
|
||||
}
|
||||
],
|
||||
"simulation": {
|
||||
"model_file": "YourModel.prt",
|
||||
"sim_file": "YourModel_sim1.sim"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Creating Custom Templates
|
||||
|
||||
1. Copy an existing template closest to your problem
|
||||
2. Modify for your specific use case
|
||||
3. Save as `templates/your_template_name.json`
|
||||
4. The template will be available via `--template your_template_name`
|
||||
|
||||
## Neural Network Training
|
||||
|
||||
All templates include `training_data_export` enabled by default:
|
||||
|
||||
```json
|
||||
"training_data_export": {
|
||||
"enabled": true,
|
||||
"export_dir": "atomizer_field_training_data/${study_name}"
|
||||
}
|
||||
```
|
||||
|
||||
This automatically exports training data for AtomizerField neural surrogate training.
|
||||
112
templates/beam_stiffness_optimization.json
Normal file
112
templates/beam_stiffness_optimization.json
Normal file
@@ -0,0 +1,112 @@
|
||||
{
|
||||
"study_name": "beam_stiffness_optimization",
|
||||
"description": "Beam Stiffness Optimization - Maximize stiffness while minimizing mass",
|
||||
"engineering_context": "Cantilever beam optimization. Find optimal cross-section dimensions to maximize bending stiffness under tip load while minimizing weight.",
|
||||
"template_info": {
|
||||
"category": "structural",
|
||||
"analysis_type": "static",
|
||||
"typical_applications": ["cantilever beams", "support arms", "brackets"],
|
||||
"required_nx_expressions": ["beam_width", "beam_height", "beam_length"]
|
||||
},
|
||||
|
||||
"optimization_settings": {
|
||||
"protocol": "protocol_10_single_objective",
|
||||
"n_trials": 50,
|
||||
"sampler": "TPE",
|
||||
"pruner": "MedianPruner",
|
||||
"timeout_per_trial": 300
|
||||
},
|
||||
|
||||
"design_variables": [
|
||||
{
|
||||
"parameter": "beam_width",
|
||||
"bounds": [10, 50],
|
||||
"description": "Beam cross-section width (mm)",
|
||||
"units": "mm"
|
||||
},
|
||||
{
|
||||
"parameter": "beam_height",
|
||||
"bounds": [10, 80],
|
||||
"description": "Beam cross-section height (mm)",
|
||||
"units": "mm"
|
||||
},
|
||||
{
|
||||
"parameter": "beam_length",
|
||||
"bounds": [100, 500],
|
||||
"description": "Beam length (mm)",
|
||||
"units": "mm"
|
||||
}
|
||||
],
|
||||
|
||||
"objectives": [
|
||||
{
|
||||
"name": "stiffness",
|
||||
"goal": "maximize",
|
||||
"weight": 1.0,
|
||||
"description": "Effective bending stiffness (inverse of tip displacement under unit load)",
|
||||
"target": 10000,
|
||||
"extraction": {
|
||||
"action": "extract_displacement",
|
||||
"domain": "result_extraction",
|
||||
"params": {
|
||||
"result_type": "displacement",
|
||||
"metric": "max",
|
||||
"invert": true
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
"constraints": [
|
||||
{
|
||||
"name": "max_mass_limit",
|
||||
"type": "less_than",
|
||||
"threshold": 500,
|
||||
"description": "Maximum mass < 500g",
|
||||
"extraction": {
|
||||
"action": "extract_mass",
|
||||
"domain": "result_extraction",
|
||||
"params": {
|
||||
"result_type": "mass",
|
||||
"metric": "total"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "max_stress_limit",
|
||||
"type": "less_than",
|
||||
"threshold": 200,
|
||||
"description": "Maximum von Mises stress < 200 MPa",
|
||||
"extraction": {
|
||||
"action": "extract_stress",
|
||||
"domain": "result_extraction",
|
||||
"params": {
|
||||
"result_type": "stress",
|
||||
"metric": "max_von_mises"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
"simulation": {
|
||||
"model_file": "Beam.prt",
|
||||
"sim_file": "Beam_sim1.sim",
|
||||
"fem_file": "Beam_fem1.fem",
|
||||
"solver": "nastran",
|
||||
"analysis_types": ["static"]
|
||||
},
|
||||
|
||||
"reporting": {
|
||||
"generate_plots": true,
|
||||
"save_incremental": true,
|
||||
"llm_summary": false
|
||||
},
|
||||
|
||||
"training_data_export": {
|
||||
"enabled": true,
|
||||
"export_dir": "atomizer_field_training_data/${study_name}",
|
||||
"export_every_n_trials": 1,
|
||||
"include_mesh": true,
|
||||
"compress": false
|
||||
}
|
||||
}
|
||||
117
templates/bracket_stress_minimization.json
Normal file
117
templates/bracket_stress_minimization.json
Normal file
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"study_name": "bracket_stress_minimization",
|
||||
"description": "Bracket Stress Minimization - Minimize peak stress while maintaining stiffness",
|
||||
"engineering_context": "L-bracket or mounting bracket optimization. Minimize stress concentrations by adjusting fillet radii, wall thickness, and material distribution.",
|
||||
"template_info": {
|
||||
"category": "structural",
|
||||
"analysis_type": "static",
|
||||
"typical_applications": ["mounting brackets", "L-brackets", "gusset plates", "corner joints"],
|
||||
"required_nx_expressions": ["wall_thickness", "fillet_radius", "web_thickness"]
|
||||
},
|
||||
|
||||
"optimization_settings": {
|
||||
"protocol": "protocol_10_single_objective",
|
||||
"n_trials": 75,
|
||||
"sampler": "TPE",
|
||||
"pruner": "MedianPruner",
|
||||
"timeout_per_trial": 400
|
||||
},
|
||||
|
||||
"design_variables": [
|
||||
{
|
||||
"parameter": "wall_thickness",
|
||||
"bounds": [2, 10],
|
||||
"description": "Main wall thickness (mm)",
|
||||
"units": "mm"
|
||||
},
|
||||
{
|
||||
"parameter": "fillet_radius",
|
||||
"bounds": [3, 20],
|
||||
"description": "Corner fillet radius (mm) - stress relief",
|
||||
"units": "mm"
|
||||
},
|
||||
{
|
||||
"parameter": "web_thickness",
|
||||
"bounds": [1, 8],
|
||||
"description": "Stiffening web thickness (mm)",
|
||||
"units": "mm"
|
||||
},
|
||||
{
|
||||
"parameter": "rib_count",
|
||||
"bounds": [0, 5],
|
||||
"description": "Number of stiffening ribs",
|
||||
"type": "integer"
|
||||
}
|
||||
],
|
||||
|
||||
"objectives": [
|
||||
{
|
||||
"name": "max_stress",
|
||||
"goal": "minimize",
|
||||
"weight": 1.0,
|
||||
"description": "Peak von Mises stress (MPa)",
|
||||
"target": 50,
|
||||
"extraction": {
|
||||
"action": "extract_stress",
|
||||
"domain": "result_extraction",
|
||||
"params": {
|
||||
"result_type": "stress",
|
||||
"metric": "max_von_mises"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
"constraints": [
|
||||
{
|
||||
"name": "max_displacement_limit",
|
||||
"type": "less_than",
|
||||
"threshold": 0.5,
|
||||
"description": "Maximum displacement < 0.5mm for stiffness requirement",
|
||||
"extraction": {
|
||||
"action": "extract_displacement",
|
||||
"domain": "result_extraction",
|
||||
"params": {
|
||||
"result_type": "displacement",
|
||||
"metric": "max"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "max_mass_limit",
|
||||
"type": "less_than",
|
||||
"threshold": 200,
|
||||
"description": "Maximum mass < 200g for weight budget",
|
||||
"extraction": {
|
||||
"action": "extract_mass",
|
||||
"domain": "result_extraction",
|
||||
"params": {
|
||||
"result_type": "mass",
|
||||
"metric": "total"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
"simulation": {
|
||||
"model_file": "Bracket.prt",
|
||||
"sim_file": "Bracket_sim1.sim",
|
||||
"fem_file": "Bracket_fem1.fem",
|
||||
"solver": "nastran",
|
||||
"analysis_types": ["static"]
|
||||
},
|
||||
|
||||
"reporting": {
|
||||
"generate_plots": true,
|
||||
"save_incremental": true,
|
||||
"llm_summary": false
|
||||
},
|
||||
|
||||
"training_data_export": {
|
||||
"enabled": true,
|
||||
"export_dir": "atomizer_field_training_data/${study_name}",
|
||||
"export_every_n_trials": 1,
|
||||
"include_mesh": true,
|
||||
"compress": false
|
||||
}
|
||||
}
|
||||
133
templates/frequency_tuning.json
Normal file
133
templates/frequency_tuning.json
Normal file
@@ -0,0 +1,133 @@
|
||||
{
|
||||
"study_name": "frequency_tuning_optimization",
|
||||
"description": "Natural Frequency Tuning - Adjust structural dynamics to avoid resonance",
|
||||
"engineering_context": "Modal optimization for avoiding resonance with excitation sources (motors, rotors, vibration). Tune natural frequencies away from operating frequencies while minimizing mass.",
|
||||
"template_info": {
|
||||
"category": "dynamics",
|
||||
"analysis_type": "modal",
|
||||
"typical_applications": ["motor mounts", "drone arms", "rotating equipment supports", "vibration isolation"],
|
||||
"required_nx_expressions": ["section_width", "section_height", "arm_length"],
|
||||
"notes": "Requires modal analysis (SOL 103) solution in NX"
|
||||
},
|
||||
|
||||
"optimization_settings": {
|
||||
"protocol": "protocol_11_multi_objective",
|
||||
"n_trials": 60,
|
||||
"sampler": "NSGAIISampler",
|
||||
"pruner": null,
|
||||
"timeout_per_trial": 500
|
||||
},
|
||||
|
||||
"design_variables": [
|
||||
{
|
||||
"parameter": "section_width",
|
||||
"bounds": [10, 40],
|
||||
"description": "Cross-section width (mm) - affects stiffness",
|
||||
"units": "mm"
|
||||
},
|
||||
{
|
||||
"parameter": "section_height",
|
||||
"bounds": [10, 60],
|
||||
"description": "Cross-section height (mm) - affects stiffness in bending plane",
|
||||
"units": "mm"
|
||||
},
|
||||
{
|
||||
"parameter": "arm_length",
|
||||
"bounds": [80, 200],
|
||||
"description": "Arm/cantilever length (mm) - strongly affects frequency",
|
||||
"units": "mm"
|
||||
},
|
||||
{
|
||||
"parameter": "wall_thickness",
|
||||
"bounds": [1, 5],
|
||||
"description": "Wall thickness for hollow sections (mm)",
|
||||
"units": "mm"
|
||||
}
|
||||
],
|
||||
|
||||
"objectives": [
|
||||
{
|
||||
"name": "mass",
|
||||
"goal": "minimize",
|
||||
"weight": 1.0,
|
||||
"description": "Total mass (grams) - minimize for weight savings",
|
||||
"target": 50,
|
||||
"extraction": {
|
||||
"action": "extract_mass",
|
||||
"domain": "result_extraction",
|
||||
"params": {
|
||||
"result_type": "mass",
|
||||
"metric": "total"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "first_frequency",
|
||||
"goal": "maximize",
|
||||
"weight": 1.0,
|
||||
"description": "First natural frequency (Hz) - push away from excitation",
|
||||
"target": 200,
|
||||
"extraction": {
|
||||
"action": "extract_frequency",
|
||||
"domain": "result_extraction",
|
||||
"params": {
|
||||
"result_type": "frequency",
|
||||
"mode_number": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
"constraints": [
|
||||
{
|
||||
"name": "min_frequency_limit",
|
||||
"type": "greater_than",
|
||||
"threshold": 120,
|
||||
"description": "First natural frequency > 120 Hz (above rotor harmonics)",
|
||||
"extraction": {
|
||||
"action": "extract_frequency",
|
||||
"domain": "result_extraction",
|
||||
"params": {
|
||||
"result_type": "frequency",
|
||||
"mode_number": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "max_stress_limit",
|
||||
"type": "less_than",
|
||||
"threshold": 150,
|
||||
"description": "Maximum stress < 150 MPa under static load",
|
||||
"extraction": {
|
||||
"action": "extract_stress",
|
||||
"domain": "result_extraction",
|
||||
"params": {
|
||||
"result_type": "stress",
|
||||
"metric": "max_von_mises"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
"simulation": {
|
||||
"model_file": "Arm.prt",
|
||||
"sim_file": "Arm_sim1.sim",
|
||||
"fem_file": "Arm_fem1.fem",
|
||||
"solver": "nastran",
|
||||
"analysis_types": ["modal", "static"]
|
||||
},
|
||||
|
||||
"reporting": {
|
||||
"generate_plots": true,
|
||||
"save_incremental": true,
|
||||
"llm_summary": false
|
||||
},
|
||||
|
||||
"training_data_export": {
|
||||
"enabled": true,
|
||||
"export_dir": "atomizer_field_training_data/${study_name}",
|
||||
"export_every_n_trials": 1,
|
||||
"include_mesh": true,
|
||||
"compress": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user