# README

## Overview

This MATLAB script performs a parametric structural study of a spring-type wheel with a modified spiral architecture using MSC Patran and MSC Nastran.

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

The purpose of the script is to evaluate the structural response of the modified spiral wheel while varying selected geometric and architectural parameters.

---

## Main Features

- Parametric generation of a modified spiral 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 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`

---

## Input Parameters

The script defines several groups of parameters.

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

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

### Architectural parameters
- `N_elem_vec`: number of reinforcement elements

### 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

For each parameter combination, the script performs the following steps:

1. Defines the current geometric configuration
2. Creates a Patran session file
3. Builds the modified spiral wheel geometry:
   - outer ring
   - inner hub
   - spiral-like reinforcement surfaces
4. Assigns materials and shell properties
5. Applies boundary conditions and load
6. Generates the finite element 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 displacement, stress, and mass 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 safety margin with respect to yielding.

---

## Saved Results

The script saves the aggregated table in:

`TAB_tol_spiral.mat`

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 analysis files are overwritten during each iteration.
- The code reads displacement, stress, and mass directly from the Nastran HDF5 result file.
- The current material assignment is set to `AlSi10Mg` for all shell components.
- The reinforcement geometry is built with a modified spiral layout using two sets of curved connections.

---

## Typical Generated Files

During execution, the script may generate files such as:

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

---

## Purpose

This script is intended for automated parametric, tolerance, and robustness studies of modified spiral wheel structural configurations.