Skip to content

Instantly share code, notes, and snippets.

@CameronCarroll
Created December 12, 2016 14:05
Show Gist options
  • Save CameronCarroll/caae668c3e520ef7dfd0cf52f1a31000 to your computer and use it in GitHub Desktop.
Save CameronCarroll/caae668c3e520ef7dfd0cf52f1a31000 to your computer and use it in GitHub Desktop.
% Calculations for ME 241 Lab 6: Tensile Testing
% Group 2, December 12, Fall 2016
clear;
clc;
F_al = [0
181.1
362.2
543.3
724.4
769.6
814.9
860.2
905.5
916.6
927.8
938.9
950.1
961.2
972.4
983.5
994.7
1005.8
1017.0];
d_al = [0.0000
0.0008
0.0016
0.0024
0.0032
0.0034
0.0037
0.0042
0.0060
0.0071
0.0086
0.0108
0.0141
0.0189
0.0258
0.0357
0.0500
0.0706
0.1000];
F_steel = [0
242.8
485.5
728.3
971.1
1031.8
1092.4
1153.1
1213.8
1236.8
1259.8
1282.7
1305.7
1328.7
1351.6
1374.6
1397.5
1420.5
1443.5];
d_steel = [0
0.0004
0.0007
0.0011
0.0015
0.0016
0.0018
0.0023
0.0039
0.0051
0.0069
0.0098
0.0142
0.0209
0.0309
0.0460
0.0683
0.1014
0.1500];
% calculate stress at dogbone area (smallest area)
% stress = force / area (psi)
A = 0.25 * 0.100;
stress_al = F_al / A;
stress_steel = F_steel / A;
% calculate strain = (L - L0) / L0 (in/in)
L0 = 1; % original length
strain_al = d_al / L0;
strain_steel = d_steel / L0;
% calculate modulus of elasticity
% E = stress / strain
E_al = stress_al ./ strain_al;
E_steel = stress_steel ./ strain_steel;
% Ran code and hand picked the linear regions of modulus of elasticity:
% Also need to get the appropriate X values (displacements.)
E_linear_al = E_al(2:6);
E_linear_steel = E_steel(2:7);
d_linear_al = d_al(2:6);
d_linear_steel = d_steel(2:7);
% Use polyfit to get the slope and intercept for linear fit:
p_al_coeffs = polyfit(d_linear_al, E_linear_al, 1);
p_steel_coeffs = polyfit(d_linear_steel, E_linear_steel, 1);
p_al = p_al_coeffs(1) * d_linear_al + p_al_coeffs(2);
p_steel = p_steel_coeffs(1) * d_linear_steel + p_steel_coeffs(2);
modulus_elasticity_aluminum = p_al_coeffs(2)
modulus_elasticity_steel = p_steel_coeffs(2)
% Determine tensile strength... that's just stress when it broke.
tensile_strength_aluminum = stress_al(end)
tensile_strength_steel = stress_steel(end)
hold on
plot(d_al, F_al)
plot(d_steel, F_steel)
title('Force vs Displacement');
xlabel('Displacement (in)');
ylabel('Force (lb)');
legend('6061-T6 Aluminum', '1018 Cold Rolled Steel', 'location', 'best')
figure();
plot(d_linear_steel, E_linear_steel, 'b', d_linear_steel, p_steel, 'r')
title('Modulus of Elasticity (Steel)')
xlabel('Strain (in/in)')
ylabel('Stress (psi)')
label1 = ['E (steel): ' num2str(modulus_elasticity_steel)]
legend('Experimental Data', label1, 'location', 'best')
figure();
plot(d_linear_al, E_linear_al, 'b', d_linear_al, p_al, 'r')
title('Modulus of Elasticity (Aluminum)')
xlabel('Strain (in/in)')
ylabel('Stress (psi)')
label2 = ['E (aluminum): ' num2str(modulus_elasticity_aluminum)]
legend('Experimental Data', label2, 'location', 'best')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment