Put the lesson Visualizing Materials Properties into practice by writing a program yourself.
The starter code holds the full stress–strain curve of a steel sample.
Find the ultimate tensile strength (the highest stress) and the strain at which it occurs, then plot the curve with that point highlighted.
np.argmax() to find the position of the highest stress.UTS: 520 MPa and At strain: 0.120 (3 decimal places).UTS: 520 MPa At strain: 0.120
Write your program below and press Run. Each run is checked against the expected output.
Press Run to see what your program prints.
One possible solution. Other programs that print the same output are correct too.
import numpy as npimport matplotlib.pyplot as pltstrain = np.array([0.0, 0.001, 0.002, 0.005, 0.02, 0.05, 0.08, 0.12, 0.16, 0.20, 0.22])stress = np.array([0, 200, 350, 380, 400, 450, 500, 520, 510, 470, 430]) # MPapeak = np.argmax(stress)print(f"UTS: {stress[peak]} MPa")print(f"At strain: {strain[peak]:.3f}")plt.plot(strain * 100, stress, marker="o", markersize=4, label="Steel")plt.plot(strain[peak] * 100, stress[peak], "o", markersize=9, label="UTS")plt.xlabel("Strain (%)")plt.ylabel("Stress (MPa)")plt.title("Tensile test")plt.legend()plt.grid(True)plt.show()