AI for Mechanical Engineering: Solid Mechanics

By Sebin Lee
http://iailab.kaist.ac.kr/
Industrial AI Lab at KAIST

# 1. Stress-strain Curve¶

Tensile Test

Tensile testing is a destructive test process that provides information about the tensile strength, yield strength, and ductility of the metallic material.

Stress-strain Curve

The tensile test result can be represented as a stress-strain curve, which shows the relationship between stress and strain.

Some of the major properties in stress-strain curve

• Young’s modulus: Relationship between tensile stress and axial strain in the linear elastic region
• Yield strength: Stress corresponding to the yield point
• Ultimate tensile strength: The maximum stress that a material can withstand while being stretched

How to find Young's modulus from the stress-strain curve

• Young's modulus is the slope of the stress-strain curve in the elastic region
• We can caculate the slope using linear regression

## 1.1. Linear Regression¶

Recall linear regression

$\text{Given} \; \begin{cases} x_{i} \; \text{: inputs} \\ y_{i} \; \text{: outputs} \end{cases}$ , Find $\theta_{0}$ and $\theta_{1}$

$$x= \begin{bmatrix} x_{1} \\ x_{2} \\ \vdots \\ x_{m} \end{bmatrix}, \qquad y= \begin{bmatrix} y_{1} \\ y_{2} \\ \vdots \\ y_{m} \end{bmatrix} \approx \hat{y}_{i} = \theta_{0} + \theta_{1}x_{i}$$

• $\hat{y}_{i}$ : predicted output

• in many cases, a linear model is used to predict $y_{i}$

$$\hat{y}_{i} = \theta_{0} + \theta_{1}x_{i} \; \quad \text{ such that }\quad \min\limits_{\theta_{0}, \theta_{1}}\sum\limits_{i = 1}^{m} (\hat{y}_{i} - y_{i})^2$$

• Optimization problem

$$\min\limits_{\theta_{0}, \theta_{1}}\sum\limits_{i = 1}^{m} (\hat{y}_{i} - y_{i})^2 =\min\limits_{\theta}\lVert\Phi\theta-y\rVert^2_2 \qquad \qquad \left(\text{same as} \; \min_{x} \lVert Ax-b \rVert_2^2 \right)$$

$$\text{solution} \; \theta^* = (\Phi^{T}\Phi)^{-1}\Phi^{T} y$$

## 1.2. Young’s Modulus with Linear Regression¶

Find Young's modulus from tensile test data using linear regression

Dataset Preparation

Download tensile test data for aluminum 6061-T651

In [ ]:
import numpy as np
import matplotlib.pyplot as plt
from sklearn import linear_model

In [ ]:
data = np.loadtxt('T_020_A_1_001_022_03.csv', delimiter=',', skiprows=1)
data = data[:data.shape[0]-1,:]

In [ ]:
plt.plot(data[:,0],data[:,1])
plt.xlabel('strain')
plt.ylabel('stress [MPa]')
plt.title('Stress–strain curve')
plt.grid('on')


Use linear algebra for linear regression

In [ ]:
elastic_data = data[:101,:]
x = elastic_data[:,0].reshape(-1,1)
y = elastic_data[:,1].reshape(-1,1)

A = np.hstack([x**0, x])
A = np.asmatrix(A)

theta = (A.T*A).I*A.T*y

xp = np.arange(data[0,0], data[yield_index,0], 0.0001).reshape(-1, 1)
yp = theta[0,0] + theta[1,0]*xp

plt.plot(data[:,0],data[:,1])
plt.plot(xp, yp)

plt.xlabel('strain')
plt.ylabel('stress [MPa]')
plt.title('Stress–strain curve')
plt.grid('on')
plt.show()

print('Youngs modulus: {:.2f}[GPa]'.format(theta[1,0]/1000))

Youngs modulus: 63.49[GPa]


Use Scikit-Learn module for linear regression

In [ ]:
elastic_data = data[:yield_index,:]
x = elastic_data[:,0].reshape(-1,1)
y = elastic_data[:,1].reshape(-1,1)

reg = linear_model.LinearRegression()
reg.fit(x, y)

xp = np.arange(data[0,0], data[yield_index,0], 0.0001).reshape(-1, 1)

plt.plot(data[:,0],data[:,1])
plt.plot(xp, reg.predict(xp))

plt.xlabel('strain')
plt.ylabel('stress [MPa]')
plt.title('Stress–strain curve')
plt.grid('on')
plt.show()

print('Youngs modulus: {:.2f}[GPa]'.format(reg.coef_[0][0]/1000))

Youngs modulus: 63.49[GPa]


## 1.3. Young’s Modulus and Temperature¶

In [ ]:
data = np.loadtxt('T_200_A_1_094_041_14.csv', delimiter=',', skiprows=1)
data = data[:data.shape[0]-1,:]

In [ ]:
plt.plot(data[:,0],data[:,1])
plt.xlabel('strain')
plt.ylabel('stress [MPa]')
plt.title('Stress–strain curve')
plt.grid('on')


Use linear algebra for linear regression

In [ ]:
elastic_data = data[:37,:]
x = elastic_data[:,0].reshape(-1,1)
y = elastic_data[:,1].reshape(-1,1)

A = np.hstack([x**0, x])
A = np.asmatrix(A)

theta = (A.T*A).I*A.T*y

xp = np.arange(data[0,0], data[yield_index,0], 0.0001).reshape(-1, 1)
yp = theta[0,0] + theta[1,0]*xp

plt.plot(data[:,0],data[:,1])
plt.plot(xp, yp)

plt.xlabel('strain')
plt.ylabel('stress [MPa]')
plt.title('Stress–strain curve')
plt.grid('on')
plt.show()

print('Youngs modulus: {:.2f}[GPa]'.format(theta[1,0]/1000))

Youngs modulus: 59.00[GPa]


Use Scikit-Learn module for linear regression

In [ ]:
elastic_data = data[:yield_index,:]
x = elastic_data[:,0].reshape(-1,1)
y = elastic_data[:,1].reshape(-1,1)

reg = linear_model.LinearRegression()
reg.fit(x, y)

xp = np.arange(data[0,0], data[yield_index,0], 0.0001).reshape(-1, 1)

plt.plot(data[:,0],data[:,1])
plt.plot(xp, reg.predict(xp))

plt.xlabel('strain')
plt.ylabel('stress [MPa]')
plt.title('Stress–strain curve')
plt.grid('on')
plt.show()

print('Youngs modulus: {:.2f}[GPa]'.format(reg.coef_[0][0]/1000))