numpy and scipy, and determine
how the toughness and energy stored in the material up to the yield point varies with temperature.
Connect to Granta MI
Create a session, and specify a database and table.Use a DataFrame to prepare the data
Build a DataFrame for each functional attribute
MI Scripting Toolkit’s list-of-lists format for functional data can be loaded directly into a DataFrame, as long as you separate the datum into the first list item (the column headers) and the subsequent list items (the datapoints).| Y min (Tensile Stress/Strain, L [Pa]) | Y max (Tensile Stress/Strain, L [Pa]) | Strain [strain] | Temperature [°C] | Time [s] | Other [] | Stress/Strain Curve Type [] | Estimated point? | |
|---|---|---|---|---|---|---|---|---|
| 0 | 0.000000e+00 | 0.000000e+00 | 0.00000 | -73.332999 | 1800.0 | None | Yield | False |
| 1 | 3.964485e+08 | 3.964485e+08 | 0.00209 | -73.332999 | 1800.0 | None | Yield | False |
| 2 | 7.136074e+08 | 7.136074e+08 | 0.00376 | -73.332999 | 1800.0 | None | Yield | False |
| 3 | 1.030766e+09 | 1.030766e+09 | 0.00544 | -73.332999 | 1800.0 | None | Yield | False |
| 4 | 1.268635e+09 | 1.268635e+09 | 0.00669 | -73.332999 | 1800.0 | None | Yield | False |
Refine the data
Define a function that takes a DataFrame and performs the following transformations as needed:- Removes columns that aren’t required, including the duplicated y-axis column
- Renames the x and y columns
- Copies columns
| x | Temperature | y | |
|---|---|---|---|
| 0 | 0.00000 | -73.332999 | 0.000000e+00 |
| 1 | 0.00209 | -73.332999 | 3.964485e+08 |
| 2 | 0.00376 | -73.332999 | 7.136074e+08 |
| 3 | 0.00544 | -73.332999 | 1.030766e+09 |
| 4 | 0.00669 | -73.332999 | 1.268635e+09 |
| x | y | |
|---|---|---|
| 0 | -195.555602 | 2.034443e+09 |
| 1 | -184.444403 | 1.994060e+09 |
| 2 | -173.333296 | 1.957518e+09 |
| 3 | -162.221999 | 1.924320e+09 |
| 4 | -151.110999 | 1.894286e+09 |
| x | y | |
|---|---|---|
| 0 | -73.332999 | 1.891060e+11 |
| 1 | -62.222006 | 1.886130e+11 |
| 2 | -51.110999 | 1.879552e+11 |
| 3 | -40.000006 | 1.872244e+11 |
| 4 | -28.888998 | 1.864384e+11 |
Calculate the area under the curves
Calculate the yield strain for each temperature
We need to integrate from x = 0 to the yield strain value. To calculate the yield strain, we require the exact Young’s modulus and Yield stress at each temperature. Our data may not have a value at that temperature, so use theinterp1d function to interpolate between datapoints.
get_yield_strain_at(), to calculate the yield strain from the interpolated values of
Young’s modulus and Yield stress. Assume an offset strain value of 0.02%.
Re-sample the stress-strain curve up to the yield strain point
Define a function to generate a re-sampled set of x-y points for the stress-strain curve, up to the yield strain value. Useget_yield_strain_at() to calculate the x limit of the resampling, then create a new set of linearly-spaced x
values up to this limit. Then use interp1d to calculate the corresponding set of y values.
Perform the numerical integration
Define a function that uses Simpson’s rule to perform the numerical integration on the resampled data points.Run the calculations for each stress-strain curve
Use theDataFrame.groupby() function to generate sub-DataFrames for each unique temperature value. Iterate over
these, storing the results of area_under_stress_strain_curve() in a dict.
| x | y | |
|---|---|---|
| 0 | -73.332999 | 8.500279e+06 |
| 1 | 26.666986 | 7.931328e+06 |
| 2 | 148.889001 | 7.063304e+06 |
| 3 | 315.555994 | 6.036317e+06 |
| 4 | 426.667017 | 5.433286e+06 |
| 5 | 537.777979 | 2.680041e+06 |
Plot the results
This code snippet is optional, and is included to increase the size of all plots generated in this notebook.Plot Deformation Energy vs Temperature
Plot the accumulated energy (or Deformation Energy ) vs Temperature. As temperature increases, the deformation energy stored up to the yield point is reduced.
Compare Deformation Energy at temperature extrema
The area under the high- and low-temperature Stress-Strain curves can be shown graphically, providing a more visual comparison. Create a basic Stress-Strain plot at both temperatures, dividing the plotted y values by and changing the y-axis units to MPa. Add the legend manually.
ax.fill_between() to fill the space between the resampled curves and the x-axis, and set the lower limit for
both axes to 0. (fig forces jupyter to re-plot the existing chart.)

