# Bracket Displacement Maximization Study

**Study Name**: bracket_displacement_maximizing
**Created**: 2025-11-16
**Phase**: 3.3 - Optimization Setup Wizard

## Overview

This study demonstrates the complete Phase 3.3 workflow for optimizing a bracket design to maximize displacement while maintaining structural safety.

## Problem Statement

**Objective**: Maximize the displacement of a bracket under load

**Constraints**:
- Safety factor ≥ 4.0
- Material: Aluminum 6061-T6 (Yield strength = 276 MPa)
- Allowable stress: 69 MPa (276/4)

**Design Variables**:
- `tip_thickness`: 15-25 mm (baseline: 17 mm)
- `support_angle`: 20-40° (baseline: 38°)

## Model Information

- **Geometry**: Bracket part with tip and support features
- **Mesh**: 585 nodes, 316 elements (CHEXA, CPENTA)
- **Load**: Applied force at tip
- **Boundary Conditions**: Fixed support at base

## Optimization Setup

### Phase 3.3 Wizard Workflow

1. **Model Introspection** - Read NX expressions from .prt file
2. **Baseline Simulation** - Run initial simulation to validate setup
3. **OP2 Introspection** - Auto-detect element types (CHEXA, CPENTA)
4. **Workflow Configuration** - Build LLM workflow with detected element types
5. **Pipeline Validation** - Dry-run test of all components
6. **Optimization** - Run 20-trial TPE optimization

### Extractors

- **Displacement**: Extract max displacement from OP2 file
- **Stress**: Extract von Mises stress from solid elements (auto-detected: CHEXA)

### Calculations

- **Safety Factor**: `SF = 276.0 / max_von_mises`
- **Objective**: `neg_displacement = -max_displacement` (minimize for maximization)

### Constraints

- **Safety Factor Hook**: Enforces SF ≥ 4.0 with penalty

## Directory Structure

```
bracket_displacement_maximizing/
├── model/                    # NX model files (isolated from tests/)
│   ├── Bracket.prt          # Part geometry
│   ├── Bracket_fem1.fem     # FE model
│   └── Bracket_sim1.sim     # Simulation setup
├── results/                  # Optimization results
│   ├── optimization_history.json
│   ├── best_design.json
│   └── trial_*.op2          # OP2 files for each trial
├── config/                   # Study configuration
│   └── study_config.json    # Complete study setup
├── run_optimization.py       # Main optimization script
├── optimization_log.txt      # Execution log
└── README.md                # This file
```

## Running the Study

```bash
cd studies/bracket_displacement_maximizing
python run_optimization.py
```

The script will:
1. Initialize the Phase 3.3 wizard
2. Validate the complete pipeline
3. Run 20 optimization trials
4. Save results to `results/` directory
5. Generate comprehensive report

## Results

Results are saved in the `results/` directory:
- **optimization_history.json**: Complete trial history
- **best_design.json**: Best design parameters and performance
- **optimization_report.md**: Human-readable summary

## Key Features Demonstrated

✅ **Phase 3.3 Wizard** - Automated validation before optimization
✅ **Dynamic Element Detection** - Auto-detects all element types from OP2
✅ **Self-Contained Study** - Isolated model files prevent conflicts
✅ **Complete Logging** - Full execution trace for debugging
✅ **Reproducible** - Configuration files enable exact reproduction

## Notes

- All simulations run in the `model/` directory to isolate from test files
- OP2 files are regenerated for each trial (no caching issues)
- Study can be re-run without affecting other tests or studies
- Configuration is fully documented in `config/study_config.json`

## References

- [Phase 3.3 Wizard Documentation](../../docs/PHASE_3_3_WIZARD.md)
- [Hook Architecture](../../docs/HOOK_ARCHITECTURE.md)
- [LLM Integration](../../docs/PHASE_2_7_LLM_INTEGRATION.md)
