# README

## Overview

This MATLAB script performs a parametric structural study of a spring-type hoop wheel using MSC Patran and MSC Nastran.

The script automatically generates the wheel geometry, assigns materials and shell properties, creates the finite element model, runs a linear static analysis, reads the results from the generated HDF5 file, and stores the output in a MATLAB table.

The goal is to evaluate the structural behavior of the wheel while varying selected geometric and architectural parameters.

---

## Main Features

- Parametric generation of a hoop wheel architecture
- Automatic creation of Patran session files
- Automatic execution of MSC Patran and MSC Nastran
- Extraction of:
  - vertical deflection
  - maximum von Mises stress
  - wheel mass
  - wheel stiffness
  - durability index
- Automatic storage of results in a `.mat` table

---

## Software Requirements

To run this script, the following software is required:

- MATLAB
- MSC Patran
- MSC Nastran

The script also assumes that:

- Patran is installed at  
  `C:\Program Files\MSC.Software\NaPa_SE\20241\Patran\bin\patran.exe`
- Nastran is installed at  
  `C:\Program Files\MSC.Software\NaPa_SE\20241\Nastran\bin\nastran.exe`

If your installation paths are different, update the corresponding variables in the script.

---

## Input Parameters

The script defines several groups of parameters.

### Geometric parameters
- `R_ext_vec`: outer radius
- `B_vec`: wheel width
- `t_ext_vec`: outer ring thickness
- `t_int_vec`: inner ring thickness
- `t_rinf_vec`: reinforcement thickness
- `R_int_vec`: hub radius

### Vehicle and loading parameters
- `N_vec`: number of wheels
- `M_vec`: vehicle mass
- `g`: gravitational acceleration

### Architectural parameters
- `N_elem_vec`: number of reinforcements

### Material parameters
The material structure includes:
- name
- Young’s modulus
- Poisson’s ratio
- density
- yield stress

### Mesh parameter
- `mesh_vec`: element size used for meshing

---

## Analysis Workflow

The script performs the following steps for each parameter combination:

1. Defines the current geometric and structural configuration
2. Creates a Patran session file
3. Builds the hoop wheel geometry:
   - outer ring
   - inner hub
   - reinforcements
4. Assigns materials and shell properties
5. Applies boundary conditions and load
6. Generates the mesh
7. Creates an RBE3 connection between the central load point and the inner hub
8. Writes the analysis deck
9. Runs Patran and Nastran
10. Reads results from the `.h5` output file
11. Stores the results in a MATLAB matrix and table

---

## Output Variables

The output table contains the following columns:

- `R ext [m]`
- `R int [m]`
- `Width [m]`
- `t ext [m]`
- `t int [m]`
- `t rinf [m]`
- `Vehicle weight [N]`
- `Load [N]`
- `N° rinf`
- `Material ext & int`
- `Material rinf`
- `Vertical deflection [m]`
- `Maximum stress [Pa]`
- `Wheel mass [kg]`
- `Wheel stiffness [kg/s^2]`
- `Durability index`

---

## Durability Index

The durability index is computed as:

`DI = 1 - S_Mises_max / sigma_y`

where:

- `S_Mises_max` is the maximum von Mises stress
- `sigma_y` is the material yield stress

A higher durability index indicates a larger margin with respect to yielding.

---

## Saved Results

The script saves the aggregated table in:

`TAB_tol_hoop.mat`

inside the folder:

`C:\Users\Sofia\OneDrive - Politecnico di Torino\TESI MAGISTRALE\Matlab tesi\Cartella risultati analisi\Tolerance_robustness`

If the file already exists:
- the new results are appended
- identical duplicate rows are removed
- the table is sorted
- the file is overwritten with the updated table

---

## Notes

- The script is configured for a linear static analysis.
- The session file and database files are overwritten during each iteration.
- The code reads displacement, stress, and mass directly from the Nastran HDF5 result file.
- The current material selection is set to `AlSi10Mg` for all shell components.

---

## Typical Generated Files

During execution, the script may generate files such as:

- `architecture.ses`
- `architecture.db`
- `architecture_hoop.bdf`
- `architecture_hoop.h5`
- `patran.ses.01`
- `architecture.db.jou`
- `patran.conf.ini`

---

## Authoring Note

This script is designed for automated tolerance robustness analysis and parametric studies of hoop wheel structural configurations.