# Bracket Stress Minimization Study

## Overview

This study optimizes a structural bracket to minimize maximum von Mises stress while maintaining displacement constraints.

## Objective

Minimize maximum von Mises stress in the bracket under applied loading conditions.

## Design Variables

- **tip_thickness**: 15.0 - 25.0 mm
  - Controls the thickness of the bracket tip
  - Directly affects stress distribution and structural rigidity

- **support_angle**: 20.0 - 40.0 degrees
  - Controls the angle of the support structure
  - Affects load path and stress concentration

## Constraints

- **Maximum displacement** ≤ 1.0 mm
  - Ensures the bracket maintains acceptable deformation under load
  - Prevents excessive deflection that could affect functionality

## Model Information

All FEA files are located in [model/](model/):
- **Part**: [Bracket.prt](model/Bracket.prt)
- **Simulation**: [Bracket_sim1.sim](model/Bracket_sim1.sim)
- **FEM**: [Bracket_fem1.fem](model/Bracket_fem1.fem)

## Optimization Settings

- **Sampler**: TPE (Tree-structured Parzen Estimator)
- **Total trials**: 50
- **Startup trials**: 20 (random sampling for initial exploration)
- **TPE candidates**: 24
- **Multivariate**: Enabled

## Running the Optimization

From the project root:

```bash
python run_5trial_test.py  # Quick 5-trial test
```

Or for the full optimization:

```python
from pathlib import Path
from optimization_engine.runner import OptimizationRunner

config_path = Path("studies/bracket_stress_minimization/optimization_config_stress_displacement.json")
runner = OptimizationRunner(
    config_path=config_path,
    model_updater=bracket_model_updater,
    simulation_runner=bracket_simulation_runner,
    result_extractors={...}
)

study = runner.run(study_name="bracket_study", n_trials=50)
```

## Results

Results are stored in [optimization_results/](optimization_results/):

- **trial_logs/**: Detailed logs for each trial iteration
- **history.json**: Complete trial-by-trial results
- **history.csv**: Results in CSV format for analysis
- **optimization_summary.json**: Best parameters and final results
- **study_*.db**: Optuna database for resuming optimizations

## Notes

- Uses NX Simcenter 2412 for FEA simulation
- Journal-based solver execution for automation
- Results extracted from OP2 files using pyNastran
- Stress values in MPa, displacement in mm

## Analysis

Post-optimization analysis plots and reports will be stored in [analysis/](analysis/).
