-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtensileDataAnalaysis.m
115 lines (95 loc) · 4.63 KB
/
tensileDataAnalaysis.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
%{
This program can plot EnggStress-EnggStrain, TrueStress-TrueStrain and also
find out yield stress and UTS on its own. This is semi-automatic as it
reqires user input one time. This program is broken into three sections:
1) Import and plotting of raw data
2) Yield stress determination: this section requires manual input
3) True stress and true stress calculation and plotting
Method:
1) change the filename in Section 1 -- filename = '-----'
2) run section 1
3) go to figure, choose brush tool and select the elastic region data where
you want to fit the straight line to determine modulus (apparant)
4) In the same selected data right click and select 'create new variable'
modify the default name 'ans' to 'ans1'
5) go to program and run section 2 only or all the remaining sections.
Another approach could be to use import data tool to import Engg
Stress-Strain data and save that as 'EnggStress' and 'EnggStrain' variable
in the workspace. Plot it and then follow step 3 onwards.
-prepared by Dr. Manasij Kumar Yadava, IIT Kanpur
%}
clear;
close;
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The first part is about getting the engg stress and engg strain data into the matlab workspace
% you can use matlab tools to get the two columns into the workspace. These variables can be renamed
% according to the respective variable names in this script
%%
plot(EnggStrain,EnggStress,'-.b')
pause
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Part2 - Manual
%{
% Now go to the figure and use brush tool to select the elastic deformation
% data. It will appear in red color.Right click and save as workspace
% variable 'elast'. This will be a numel(strain)X 2 matrix. now run the
% following:
%}
linfit = fit(ans1(:,1),ans1(:,2),'poly1');
slope = linfit.p1;
hold on
plot(linspace(0,0.1,10)+0.002, linfit.p2+linfit.p1.*linspace(0,0.1,10))
err = EnggStress - polyval([linfit.p1,(linfit.p2-0.002*linfit.p1)],EnggStrain);
[index] = find(abs(err)== min(abs(err)));
yieldStress = EnggStress(index);
hold off
%% part3 - auto
TrueStrain = log(ones(length(EnggStrain),1)+EnggStrain);
TrueStress = EnggStress.*(ones(length(EnggStrain),1)+EnggStrain);
TruePlasticStrain = TrueStrain - TrueStress*(1/linfit.p1);
maxStressIndex = find (TrueStress == max(TrueStress));
TplStrain =TruePlasticStrain(index:maxStressIndex)-TruePlasticStrain(index);
TplStress= TrueStress(index:maxStressIndex);
UTS = TrueStress(maxStressIndex);
UTS_Engg = max(EnggStress);
% h = figure;
plot((TruePlasticStrain(index:maxStressIndex)-TruePlasticStrain(index)),TrueStress(index:maxStressIndex),'-r');
% ax = plot((TruePlasticStrain(index:maxStressIndex)-TruePlasticStrain(index)),TrueStress(index:maxStressIndex),'-r');
ylim([0 inf]);
pbaspect([1 1 1]);
% % % save('testData.mat','yieldStress','UTS','linfit','EnggStress','EnggStrain','TrueStrain','TrueStress','TplStrain','TplStress');
% % clearvars ;%ax ans ans1 err h index linfit maxStressIndex TruePlasticStrain;
%% K-M plotting
% Set up fittype and options.
%Degree of polynomial used for fitting. 5 works fine. But check it though. One needs to verify
%the fit, particularly at the elastoplastic region to get good KM curve
% fitmodel = {'x^5','x^4','x^3','x^2','x','sqrt(0.001+x)','1'};
% fitmodel = {'x^7','x^6','x^5','x^4','x^3','x^2','x','sqrt(0.001+x)','1'};
fitmodel = {'x^9','x^8','x^7','x^6','x^5','x^4','x^3','x^2','x','sqrt(0.001+x)','1'};
ft = fittype( fitmodel );
% Fit model to data.
[fitresult, gof] = fit( TplStrain,TplStress, ft );
% Plot fit with data.
figure( 'Name', [fitmodel,'fit']);
h = plot( fitresult, TplStrain,TplStress );
legend( h, 'True Stress vs. True Plastic Strain', [fitmodel,'fit'] , 'Location', 'SouthEast' );
% Label axes
xlabel( 'True Plastic Strain');
ylabel( 'True Stress');
grid on
KMY = differentiate(fitresult,TplStrain);
figure( 'Name', 'd(sigma)/d(epsilon) vs sigma' );
KMX = fitresult(TplStrain);
h1 = plot(KMX,KMY);
xlabel( 'True Stress - Yield Stress (MPa)' );
ylabel( 'd(sigma)/d(epsilon)' );
grid on
grid minor
%%
save(saveLocation,'yieldStress','UTS','linfit','EnggStress','EnggStrain','TrueStrain','TrueStress','TplStrain','TplStress','UTS_Engg','KMX','KMY');
%% To save in excel sheet
A_matrix = padcat(EnggStress,EnggStrain,TrueStrain,TrueStress,TplStrain,TplStress,KMX,KMY,yieldStress,UTS,UTS_Engg);
xlswrite('AnalysedData.xls',A_matrix); I