Load data from CSV
The raw Load vs Displacement data is stored in a CSV file. Import the data directly into a DataFrame using thepandas function .read_csv().
| Displacement [mm] | Load [N] | |
|---|---|---|
| 0 | 0.000000 | 0.000 |
| 1 | 0.005282 | 273.392 |
| 2 | 0.005282 | 307.173 |
| 3 | 0.006010 | 331.741 |
| 4 | 0.006738 | 352.556 |
| Displacement | Load | |
|---|---|---|
| 0 | 0.000000 | 0.000 |
| 1 | 0.000005 | 273.392 |
| 2 | 0.000005 | 307.173 |
| 3 | 0.000006 | 331.741 |
| 4 | 0.000007 | 352.556 |
Process the data
Plot Load-Displacement data
This code snippet is optional, and is included to increase the size of all plots generated in this notebook.matplotlib to plot the Load-Displacement curve. For this plot, we’ve divided df.Load by 1e3 so the y-axis is
displayed in kN.

Convert Load-Displacement to Stress-Strain
Converting the Load-Displacement curve into Stress-Strain requires the gauge length and area, given here as constants in SI units. In a full workflow, these values can be loaded from a source file. Calculate the Stress and Strain and store as new columns in the DataFrame.| Displacement | Load | Strain | Stress | |
|---|---|---|---|---|
| 0 | 0.000000 | 0.000 | 0.000000 | 0.000000e+00 |
| 1 | 0.000005 | 273.392 | 0.000066 | 1.208322e+07 |
| 2 | 0.000005 | 307.173 | 0.000066 | 1.357626e+07 |
| 3 | 0.000006 | 331.741 | 0.000075 | 1.466210e+07 |
| 4 | 0.000007 | 352.556 | 0.000084 | 1.558207e+07 |


Calculate Ultimate tensile strength
Ultimate tensile strength can be calculated by taking the maximum value of thedf.Stress column.
Calculate and store the tensile strength in SI units and MPa (the latter will be used later).

Calculate Young’s modulus
Calculate Young’s modulus by taking the gradient of the Stress-Strain curve between 5% and 25% of the total tensile strength (chordal fit method). There is no interpolation, because the Stress-Strain values closest to the 5% and 25% bounds are used.
Calculate 0.2% offset yield stress
The offset yield stress is determined by calculating the intercept between the chordal fit line and the stress response. First add the offset chordal fit line to the plot, to show where the yield stress lies.

Calculate Elongation at failure
The data has been pre-processed before import, so the last point in the data series is the failure point.
Calculate True Stress-Strain
Since there is a 1:1 relationship between engineering and true stress-strain values, True Stress-Strain is added to the DataFrame as additional columns.| Displacement | Load | Strain | Stress | find_intercept | True_Strain | True_Stress | |
|---|---|---|---|---|---|---|---|
| 0 | 0.000000 | 0.000 | 0.000000 | 0.000000e+00 | 4.093098e+08 | 0.000000 | 0.000000e+00 |
| 1 | 0.000005 | 273.392 | 0.000066 | 1.208322e+07 | 4.078764e+08 | 0.000066 | 1.208402e+07 |
| 2 | 0.000005 | 307.173 | 0.000066 | 1.357626e+07 | 4.093694e+08 | 0.000066 | 1.357715e+07 |
| 3 | 0.000006 | 331.741 | 0.000075 | 1.466210e+07 | 4.085924e+08 | 0.000075 | 1.466320e+07 |
| 4 | 0.000007 | 352.556 | 0.000084 | 1.558207e+07 | 4.076494e+08 | 0.000084 | 1.558338e+07 |

Calculate True Stress-True Plastic Strain
Create a new DataFrame to store the True Stress-True Plastic Strain, since the x-axis is different to Stress-Strain.| Strain | Stress | |
|---|---|---|
| 0 | 0.000000 | 3.355557e+08 |
| 1 | 0.000008 | 3.370594e+08 |
| 2 | 0.000029 | 3.374152e+08 |
| 3 | 0.000050 | 3.377409e+08 |
| 4 | 0.000067 | 3.380495e+08 |

Import data and results into Granta MI
Finally, import the raw data, processed data and results into a new Granta MI record. Connect to Granta MI and specify a database and table.datetime.now() to ensure the record name is unique.
At this stage, the record has only been created in the MI Scripting Toolkit. The changes will be pushed to Granta MI
when session.update() is called at the end of the notebook.