0% found this document useful (0 votes)
22 views3 pages

BMHC17 P3.Ipynb - Colaboratory

Uploaded by

aresjod45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

BMHC17 P3.Ipynb - Colaboratory

Uploaded by

aresjod45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

10/14/23, 12:17 PM BMHC17 P3.

ipynb - Colaboratory

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

from google.colab import drive


drive.mount('/content/drive')

# Load data for steel and aluminum


df_steel = pd.read_excel('/content/drive/MyDrive/Colab Notebooks/Data3steel.xls')
df_al = pd.read_excel('/content/drive/MyDrive/Colab Notebooks/Data3aluminium.xls')

Mounted at /content/drive
WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero
WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero

# Display the first few rows of the steel dataset


df_steel.head()

TESTNUM POINTNUM TIME POSIT FORCE EXT CH5 CH6 CH7 CH8

0 523 1 6.189 0.07302 202.924728 0.000402 -0.028272 NaN NaN NaN

1 523 2 6.549 0.07396 205.714890 -0.000238 -0.034549 NaN NaN NaN

2 523 3 7.148 0.07624 217.763336 -0.000713 -0.030140 NaN NaN NaN

3 523 4 9.146 0.08438 316.306122 0.002377 -0.025968 NaN NaN NaN

4 523 5 10.041 0.08822 417.003357 0.003089 -0.024100 NaN NaN NaN

# Display the first few rows of the aluminum dataset


df_al.head()

TESTNUM POINTNUM TIME POSIT FORCE EXT CH5 CH6 CH7 CH8

0 542 1 8.470 0.02256 201.146011 -0.001444 0.007552 NaN NaN NaN

1 542 2 8.632 0.02330 206.599442 0.000302 0.007552 NaN NaN NaN

2 542 3 10.027 0.02846 287.512573 0.003044 0.018898 NaN NaN NaN

3 542 4 11.031 0.03232 365.380981 0.009881 0.022061 NaN NaN NaN

4 542 5 11.928 0.03616 447.813965 0.014085 0.033652 NaN NaN NaN

# Calculate area, stress, and strain for aluminum and steel


d = 0.506
r = d / 2
A = np.pi * r**2
stress_al = (df_al['FORCE'] / A) * 0.001
strain_al = df_al['CH5'] * 0.01
stress_steel = (df_steel['FORCE'] / A) * 0.001
strain_steel = df_steel['CH5'] * 0.01

# Create a plot for stress-strain curves


fig, ax = plt.subplots()
ax.plot(strain_al, stress_al)
ax.plot(strain_steel, stress_steel)
ax.set_xlabel('Strain (mm/mm)')
ax.set_ylabel('Stress (kN/mm2)')
ax.set_title('Stress-Strain Curve of Al6061 and Steel1018 in Tension')
ax.legend(['Al6061', 'Steel1018'])

https://colab.research.google.com/drive/12E5_rt0VW_p940NiCAoIxkKtLf8ixgDB#printMode=true 1/3
10/14/23, 12:17 PM BMHC17 P3.ipynb - Colaboratory
# Calculate and display the tensile
<matplotlib.legend.Legend strength for aluminum and steel
at 0x7ab1509e4d90>
ts_al = np.max(stress_al)
ts_steel = np.max(stress_steel)
final_ts_steel = 6.8976 * ts_steel
print(f'The tensile strength of Steel1018 in KN/mm2: {round(final_ts_steel, 1)} KN/mm2')
final_ts_al = 6.8976 * ts_al
print(f'The tensile strength of Al6061 in KN/mm2: {round(final_ts_al, 1)} KN/mm2')

The tensile strength of Steel1018 in KN/mm2: 658.7 KN/mm2


The tensile strength of Al6061 in KN/mm2: 326.5 KN/mm2

# Create an inset plot for the elastic region


fig, ax = plt.subplots()
ax.plot(strain_al, stress_al)
ax.plot(strain_steel, stress_steel)
ax.set_title('Inset of Elastic Region')
ax.set_xlabel('Strain (mm/mm)')
ax.set_ylabel('Stress (KN/mm2)')
ax.legend(['Al6061', 'Steel1018'])
ax.set_xlim([0, 0.003])
ax.set_ylim([0, 75])
plt.show()

# Find the elastic modulus of Al6061


linear_stress_al_mask = stress_al < 35
linear_stress_al = stress_al[linear_stress_al_mask]
linear_strain_al = strain_al[linear_stress_al_mask]
from scipy.stats import linregress
linear_regression_output = linregress(linear_strain_al, linear_stress_al)
E_al = linear_regression_output[0]
final_E_al = 6.8976 * E_al
print(f'The elastic modulus of Al6061 is {round(final_E_al, 1)} KN/mm2')

The elastic modulus of Al6061 is 68350.9 KN/mm2

# Find the elastic modulus of Steel1018


linear_stress_steel_mask = stress_steel < 55
linear_stress_steel = stress_steel[linear_stress_steel_mask]
linear_strain_steel = strain_steel[linear_stress_steel_mask]
linear_regression_output_steel = linregress(linear_strain_steel, linear_stress_steel)
E_steel = linear_regression_output_steel[0]
final_E_steel = 6.8976 * E_steel
print(f'The elastic modulus of Steel1018 is {round(final_E_steel, 1)} KN/mm2')

The elastic modulus of Steel1018 is 276768.8 KN/mm2

# Find the ductility for Al6061


stress_al_array = np.array(stress_al)
stress_al_last = stress_al_array[-1]
strain_al_array = np.array(strain_al)
strain_al_last = strain_al_array[-1]
EL_al = -stress_al_last / final_E_al + strain_al_last
print(f'The ductility of Al6061 is {round(EL_al * 100, 1)}%')

The ductility of Al6061 is 20.7%

# Find the ductility of Steel1018


stress_steel_array = np.array(stress_steel)
stress_steel_last = stress_steel_array[-1]
strain_steel_array = np.array(strain_steel)
strain_steel_last = strain_steel_array[-1]
EL_steel = -stress_steel_last / final_E_steel + strain_steel_last
print(f'The ductility of Steel1018 is {round(EL_steel * 100, 1)}%')

The ductility of Steel1018 is 25.1%

https://colab.research.google.com/drive/12E5_rt0VW_p940NiCAoIxkKtLf8ixgDB#printMode=true 2/3
10/14/23, 12:17 PM BMHC17 P3.ipynb - Colaboratory

https://colab.research.google.com/drive/12E5_rt0VW_p940NiCAoIxkKtLf8ixgDB#printMode=true 3/3

You might also like