% Young's Modulus programme
% This programme will calculate the Young's Modulus for 5 samples.
% THe slope of the stress strain curve is calculated
% The formula below is readily found online or from books
% The second half of the programme will calucate the stress slope curve
% using data imported MANUALLY from excel. Load data manually then run the code
% Copyright David Paterson, University of Strathclyde, Glasgow, UK.
% Reuse or reuse with editing is permitted but must cite the author of this work.
% David A.P. Paterson, "Life Cycle and Ultrasonic Based Non-Destructive Analysis of Recycled and Remanufactured Carbon Fibre Reinforced Plastic Composite",
% Doctoral Thesis, Univeristy of Strathclyde, Glasgow, 2018
ext_length = A; % extensiometer length is set at 50mm
%========================= Start of v-CFRP Samples ============================================
%================================================================================================
Sample1_A = A; % Average cross sectional area (mm^2)
Sample1_Force1 = B; % Force at data point 1 (N)
%Sample1_Force1 = C; % Force at data point 1 (N)
%Sample1_Force1 = D; % Force at data point 1 (N)
%Sample1_Force2 = E; % Force at data point 2 (N)
%Sample1_Force2 = F;% Force at data point 2 (N)
Sample1_Force2 = G;% Force at data point 2 (N)
Sample1_ext_disp1 = B; % Ext at data point 1
%Sample1_ext_disp1 = C; % Ext at data point 1
%Sample1_ext_disp1 = D; % Ext at data point 1
%Sample1_ext_disp2 = E; % Ext at data point 2
%Sample1_ext_disp2 = F;% Ext at data point 2
Sample1_ext_disp2 = G;% Ext at data point 2
E1 = (ext_length*(Sample1_Force2 - Sample1_Force1))/(Sample1_A*(Sample1_ext_disp2-Sample1_ext_disp1)) * (1e+6);
Sample2_A = A; % Average cross sectional area (mm^2)
Sample2_Force1 = B; % Force at data point 1 (N)
%Sample2_Force1 = C; % Force at data point 1 (N)
%Sample2_Force1 = D; % Force at data point 1 (N)
%Sample2_Force2 = E; % Force at data point 2 (N)
%Sample2_Force2 = F;% Force at data point 2 (N)
Sample2_Force2 = G;% Force at data point 2 (N)
Sample2_ext_disp1 = B; % Ext at data point 1
%Sample2_ext_disp1 = C; % Ext at data point 1
%Sample2_ext_disp1 = D; % Ext at data point 1
%Sample2_ext_disp2 = E; % Ext at data point 2
%Sample2_ext_disp2 = F;% Ext at data point 2
Sample2_ext_disp2 = G;% Ext at data point 2
E2 = (ext_length*(Sample2_Force2 - Sample2_Force1))/(Sample2_A*(Sample2_ext_disp2-Sample2_ext_disp1)) * (1e+6);
Sample3_A = A; % Average cross sectional area (mm^2)
Sample3_Force1 = B; % Force at data point 1 (N)
%Sample3_Force1 = C; % Force at data point 1 (N)
%Sample3_Force1 = D; % Force at data point 1 (N)
%Sample3_Force2 = E; % Force at data point 2 (N)
%Sample3_Force2 = F;% Force at data point 2 (N)
Sample3_Force2 = G;% Force at data point 2 (N)
Sample3_ext_disp1 = B; % Ext at data point 1
%Sample3_ext_disp1 = C; % Ext at data point 1
%Sample3_ext_disp1 = D; % Ext at data point 1
%Sample3_ext_disp2 = E; % Ext at data point 2
%Sample3_ext_disp2 = F;% Ext at data point 2
Sample3_ext_disp2 = G;% Ext at data point 2
E3 = (ext_length*(Sample3_Force2 - Sample3_Force1))/(Sample3_A*(Sample3_ext_disp2-Sample3_ext_disp1)) * (1e+6);
Sample4_A = A; % Average cross sectional area (mm^2)
Sample4_Force1 = B; % Force at data point 1 (N)
%Sample4_Force1 = C; % Force at data point 1 (N)
%Sample4_Force1 = D; % Force at data point 1 (N)
%Sample4_Force2 = E; % Force at data point 2 (N)
%Sample4_Force2 = F;% Force at data point 2 (N)
Sample4_Force2 = G;% Force at data point 2 (N)
Sample4_ext_disp1 = B; % Ext at data point 1
%Sample4_ext_disp1 = C; % Ext at data point 1
%Sample4_ext_disp1 = D; % Ext at data point 1
%Sample4_ext_disp2 = E; % Ext at data point 2
%Sample4_ext_disp2 = F;% Ext at data point 2
Sample4_ext_disp2 = G;% Ext at data point 2
E4 = (ext_length*(Sample4_Force2 - Sample4_Force1))/(Sample4_A*(Sample4_ext_disp2-Sample4_ext_disp1)) * (1e+6);
Sample5_A = A; % Average cross sectional area (mm^2)
Sample5_Force1 = B; % Force at data point 1 (N)
%Sample5_Force1 = C; % Force at data point 1 (N)
%Sample5_Force1 = D; % Force at data point 1 (N)
%Sample5_Force2 = E; % Force at data point 2 (N)
%Sample5_Force2 = F;% Force at data point 2 (N)
Sample5_Force2 = G;% Force at data point 2 (N)
Sample5_ext_disp1 = B; % Ext at data point 1
%Sample5_ext_disp1 = C; % Ext at data point 1
%Sample5_ext_disp1 = D; % Ext at data point 1
%Sample5_ext_disp2 = E; % Ext at data point 2
%Sample5_ext_disp2 = F;% Ext at data point 2
Sample5_ext_disp2 = G;% Ext at data point 2
E5 = (ext_length*(Sample5_Force2 - Sample5_Force1))/(Sample5_A*(Sample5_ext_disp2-Sample5_ext_disp1)) * (1e+6);
v_CFRP_Average_YM_Mech = (E1+E2+E3+E4+E5)/5 % Average YM from the v-CFRP samples
STD_DEV = sqrt((((E1-v_CFRP_Average_YM_Mech)^2)+((E2-v_CFRP_Average_YM_Mech)^2)+((E3-v_CFRP_Average_YM_Mech)^2)+((E4-v_CFRP_Average_YM_Mech)^2)+((E5-v_CFRP_Average_YM_Mech)^2))/5)
% ========================== End of v-CFRP Samples ============================================
% ==============================================================================================
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%% graph and larger average of YM system for samples % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This sectin of code needs information from mechanical testing machine in
% order to execute correctly. THe strain and stress are taken from
% displacement and force used in this instance.
% % This section of code will produce various force strain graphs for the v-CFRP samples. The ym modulus is also calculated.
% % The young's modulus is calculated using various YM's over the force range of around 2500 - 35,000. More specifically, from
% % 1-10 YM is calculated (1 - 10 being numbers from excel rows), then 11-20, then 21 - 30. All the way to around the value of 35,000.
% % The YM's are then summed and the average and std dev is given. This value works to around the same value as for doing it the method above.
%
% figure(1);
% plot(strain1,stress1);
% %Scatter(Strain,Stress,'filled') % data from experimental
% hold on
% axis([0 1 0 45000]) % Sets the axis values for both x and y
% grid on
% xlabel('Displacement (mm)'); % labels the x axis
% ylabel('Force (N)'); % Labels the y axis
% title('Force vs displacement for v-CFRP sample 1 (tensile testing in fibre direction)') % Labels the graph
%
% counter = 1;
% counter2 = 10;
% counter3 = 1;
% while counter < 90
%
% YM_TEST1(counter) = (ext_length*(stress1(counter2) - stress1(counter3)))/(Sample1_A*(strain1(counter2)-strain1(counter3)))* (1e+6);
%
% Test_stress1(counter) = stress1(counter2); % allows the user to pick numbers to to find out which matrix element force is equated
% Test_strain1(counter) = strain1(counter2); % allows the user to pick numbers to to find out which matrix element force is equated
%
% counter = counter + 1;
% counter2 = counter2 + 10;
% counter3 = counter3 + 10;
%
% end;
%
% figure(2);
% plot(strain2,stress2);
% %Scatter(Strain,Stress,'filled') % data from experimental
% hold on
% axis([0 1 0 45000]) % Sets the axis values for both x and y
% grid on
% xlabel('Displacement (mm)'); % labels the x axis
% ylabel('Force (N)'); % Labels the y axis
% title('Force vs displacement for v-CFRP sample 1 (tensile testing in fibre direction)') % Labels the graph
%
% counter = 1;
% counter2 = 10;
% counter3 = 1;
% while counter < 90
%
% YM_TEST2(counter) = (ext_length*(stress2(counter2) - stress2(counter3)))/(Sample2_A*(strain2(counter2)-strain2(counter3)))* (1e+6);
%
% Test_stress2(counter) = stress2(counter2); % allows the user to pick numbers to to find out which matrix element force is equated
% Test_strain2(counter) = strain2(counter2); % allows the user to pick numbers to to find out which matrix element force is equated
%
% counter = counter + 1;
% counter2 = counter2 + 10;
% counter3 = counter3 + 10;
%
% end;
%
%
% figure(3);
% plot(strain3,stress3);
% %Scatter(Strain,Stress,'filled') % data from experimental
% hold on
% axis([0 1 0 45000]) % Sets the axis values for both x and y
% grid on
% xlabel('Displacement (mm)'); % labels the x axis
% ylabel('Force (N)'); % Labels the y axis
% title('Force vs displacement for v-CFRP sample 1 (tensile testing in fibre direction)') % Labels the graph
%
% counter = 1;
% counter2 = 10;
% counter3 = 1;
% while counter < 90
%
% YM_TEST3(counter) = (ext_length*(stress3(counter2) - stress3(counter3)))/(Sample3_A*(strain3(counter2)-strain3(counter3)))* (1e+6);
%
% Test_stress3(counter) = stress3(counter2); % allows the user to pick numbers to to find out which matrix element force is equated
% Test_strain3(counter) = strain3(counter2); % allows the user to pick numbers to to find out which matrix element force is equated
%
% counter = counter + 1;
% counter2 = counter2 + 10;
% counter3 = counter3 + 10;
%
% end;
%
% figure(4);
% plot(strain4,stress4);
% %Scatter(Strain,Stress,'filled') % data from experimental
% hold on
% axis([0 1 0 45000]) % Sets the axis values for both x and y
% grid on
% xlabel('Displacement (mm)'); % labels the x axis
% ylabel('Force (N)'); % Labels the y axis
% title('Force vs displacement for v-CFRP sample 1 (tensile testing in fibre direction)') % Labels the graph
%
% counter = 1;
% counter2 = 10;
% counter3 = 1;
% while counter < 90
%
% YM_TEST4(counter) = (ext_length*(stress4(counter2) - stress4(counter3)))/(Sample4_A*(strain4(counter2)-strain4(counter3)))* (1e+6);
%
% Test_stress4(counter) = stress4(counter2); % allows the user to pick numbers to to find out which matrix element force is equated
% Test_strain4(counter) = strain4(counter2); % allows the user to pick numbers to to find out which matrix element force is equated
%
% counter = counter + 1;
% counter2 = counter2 + 10;
% counter3 = counter3 + 10;
%
% end;
%
% figure(5);
% plot(strain5,stress5);
% %Scatter(Strain,Stress,'filled') % data from experimental
% hold on
% axis([0 1 0 45000]) % Sets the axis values for both x and y
% grid on
% xlabel('Displacement (mm)'); % labels the x axis
% ylabel('Force (N)'); % Labels the y axis
% title('Force vs displacement for v-CFRP sample 1 (tensile testing in fibre direction)') % Labels the graph
%
% counter = 1;
% counter2 = 10;
% counter3 = 1;
% while counter < 90
%
% YM_TEST5(counter) = (ext_length*(stress5(counter2) - stress5(counter3)))/(Sample5_A*(strain5(counter2)-strain5(counter3)))* (1e+6);
%
% Test_stress5(counter) = stress5(counter2); % allows the user to pick numbers to to find out which matrix element force is equated
% Test_strain5(counter) = strain5(counter2); % allows the user to pick numbers to to find out which matrix element force is equated
%
% counter = counter + 1;
% counter2 = counter2 + 10;
% counter3 = counter3 + 10;
% end;
%
% Larger_Avg1 = (sum(YM_TEST1(5:89)))/85;
% Larger_Avg2 = (sum(YM_TEST2(5:89)))/85;
% Larger_Avg3 = (sum(YM_TEST3(5:89)))/85;
% Larger_Avg4 = (sum(YM_TEST4(5:89)))/85;
% Larger_Avg5 = (sum(YM_TEST5(5:89)))/85;
%
% Larger_Overall_avg = (Larger_Avg1+Larger_Avg2+Larger_Avg3+Larger_Avg4+Larger_Avg5)/5
% Larger_STD_DEV = sqrt((((Larger_Avg1-Larger_Overall_avg)^2)+((Larger_Avg2-Larger_Overall_avg)^2)+((Larger_Avg3-Larger_Overall_avg)^2)+((Larger_Avg4-Larger_Overall_avg)^2)+((Larger_Avg5-Larger_Overall_avg)^2))/5)
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%% graph and large average of YM system for samples % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% graph using mechanical, LSM and ROM YM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x = [A,0,0]; % data for 1st bar chart LSM derived YM from average of indivdual samples
y = [0,B,0]; % data for 2nd bar chart ROM derived from Average of individual samples
z = [0,0,C]; % data for 3rd bar chart Mechanically derived form average of individual samples
bar(x,'r') % produces bar chart
hold on % places a hold on the bar chart
bar(y,'c') % produces bar chart
bar(z,'y') % produces bar chart
ylim([0 130]) % set the limits on the y axis of bar graph
set(gca,'XTickLabel',{'Ultrasound', 'Rule of Mixtures', 'Mechanical'}) % sets the x axis on bar graph
ylabel('Gpa') % sets the y label
title('Youngs Modulus values from ultrasound, ROM and mechanical data') % Labels the graph
YMs = [A,B,C]; % values if Young's modulus figures
Std_dev = [A,B,C]; % standard deviation values for 1st, 2nd and 3rd bar charts
errorbar(YMs,Std_dev,'.k') % this error bar, inserts the std deviation operators.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% graph using mechanical, LSM and ROM YM %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%