-
Notifications
You must be signed in to change notification settings - Fork 0
/
simply_supported_beam_gen_loading.m
176 lines (176 loc) · 6.89 KB
/
simply_supported_beam_gen_loading.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
%=============================================================================================
% MATLAB script file to find the approximate Fourier series expansion for any given loading
% acting at a simply supported beam of length L, and also the B.M.D., S.F.D. and deformed
% shape of the beam due to the loading represented by the Fourier series.
% For further details, go to the link below:
% https://github.com/SubhadipN/Fourier_Series/blob/main/README.md
%=============================================================================================
% Prepared by SUBHADIP NASKAR, RESEARCH SCHOLAR, IIT GUWAHATI
%=============================================================================================
clear all; clc; warning ('off','all');
%=============================================================================================
% INPUTS::
% Length of the beam (m)::
L = 5;
% Modulus of rigidity of the beam (kN-m^2)::
EI = 11250;
% Position of Load Function::
LP = [0 0.4; 0.5 1.0]*L;
% Intensity of Load Function (kN/m)::
LI = [20 20; 10 40];
% Number of terms in Fourier series::
n = 50;
%=============================================================================================
% Discrete the total length of the beam::
ll = -0.001*L:0.001:1.001*L;
%=============================================================================================
subplot (2,2,1);
box on; hold on; grid minor;
xlim([min(ll) max(ll)]);
if min(LI,[],"all") >= 0
ylim([-0.10*max(LI,[],"all") 1.25*max(LI,[],"all")]);
else
ylim(1.25*[min(LI,[],"all") max(LI,[],"all")]);
end
frame_h = get(handle(gcf),'JavaFrame');
set(frame_h,'Maximized',1);
plot(ll,zeros(length(ll),1),'b','LineWidth',2);
set(gca,'fontsize',20);
set(gca,'FontName','Times New Roman');
xlabel('Length of beam (m)');
ylabel('Loading (kN)');
title('Fourier Series Expansion of the Loading');
%---------------------------------------------------------------------------------------------
elem = size(LP); elem = elem(1,1);
for ii = 1:elem
x1 = LP(ii,1); y1 = LI(ii,1);
x2 = LP(ii,2); y2 = LI(ii,2);
m(ii) = (y2-y1)/(x2-x1);
c(ii) = (x2*y1-x1*y2)/(x2-x1);
l = linspace(x1,x2,1000);
h1 = linspace(0,y1,10);
h2 = linspace(0,y2,10);
for jj = 1:length(l)
y(jj) = m(ii)*l(jj)+c(ii);
end
h(1) = plot(l,y,'r','LineWidth',2);
plot(x1*ones(length(h1),1),h1,'r','LineWidth',2);
plot(x2*ones(length(h2),1),h2,'r','LineWidth',2);
end
%=============================================================================================
% Calculation of mean value::
area = 0;
for ii = 1:elem
area = area+trapz([LP(ii,1) LP(ii,2)],[LI(ii,1) LI(ii,2)]);
end
wm = area/L;
a0 = wm/2;
%=============================================================================================
% Estimation of Fourier Coefficients::
for ii = 1:n
area1 = 0; area2 = 0;
for jj = 1:elem
x = linspace(LP(jj,1),LP(jj,2),L*1000);
for k = 1:length(x)
if LI(jj,1) == LI(jj,2)
y1(k) = LI(jj,1)*cos(ii*pi*x(k)/L);
y2(k) = LI(jj,1)*sin(ii*pi*x(k)/L);
else
f = LI(jj,1)+(x(k)-LP(jj,1))*(LI(jj,2)-LI(jj,1))/(LP(jj,2)-LP(jj,1));
y1(k) = f*cos(ii*pi*x(k)/L);
y2(k) = f*sin(ii*pi*x(k)/L);
end
end
area1 = area1+trapz(x,y1);
area2 = area2+trapz(x,y2);
end
a(ii) = area1/L;
b(ii) = area2/L;
end
%=============================================================================================
% Estimation of summation of Harmonic Functions::
for ii = 1:length(ll)
sum = -a0;
for jj = 1:n
sum = sum+a(jj)*cos(jj*pi*ll(ii)/L)+b(jj)*sin(jj*pi*ll(ii)/L);
end
wf(ii) = sum;
end
h(2) = plot(ll,wm+wf,'k','LineWidth',2);
legend(h,'Exact Loading','Fourier Series Expansion','Location','best');
%=============================================================================================
% various responses::
bm = zeros(length(ll),1);
sf = zeros(length(ll),1);
disp = zeros(length(ll),1);
Ln = L./((1:1:n)*pi);
for ii = 1:length(ll)
bm(ii) = 0.5*a0*ll(ii)*(L-ll(ii));
sf(ii) = a0*(L/2-ll(ii));
disp(ii) = a0*(-L^3*ll(ii)/24+L*ll(ii)^3/12-ll(ii)^4/24);
for jj = 1:n
% bending moment::
bms = Ln(jj)^2*sin(ll(ii)/Ln(jj));
bmc = Ln(jj)*ll(ii)*(1-cos(jj*pi))/(jj*pi)+Ln(jj)^2*(cos(ll(ii)/Ln(jj))-1);
bm(ii) = bm(ii)+a(jj)*bmc+b(jj)*bms;
% shear force::
sfs = Ln(jj)*cos(ll(ii)/Ln(jj));
sfc = Ln(jj)*(1-cos(jj*pi))/(jj*pi)-Ln(jj)*sin(ll(ii)/Ln(jj));
sf(ii) = sf(ii)+a(jj)*sfc+b(jj)*sfs;
% deflection profile::
disps = -Ln(jj)^4*sin(ll(ii)/Ln(jj));
dispc = Ln(jj)^4*(1-cos(ll(ii)/Ln(jj)))-Ln(jj)^3*(1-cos(jj*pi))*ll(ii)/(jj*pi)+ ...
L*Ln(jj)^2*(2+cos(jj*pi))*ll(ii)/6-Ln(jj)^2*ll(ii)^2/2+ ...
Ln(jj)*(1-cos(jj*pi))*ll(ii)^3/(6*jj*pi);
disp(ii) = disp(ii)+a(jj)*dispc+b(jj)*disps;
end
end
disp = disp/EI;
%=============================================================================================
% Plot the bending moment::
subplot (2,2,2);
box on; hold on; grid on; grid minor;
xlim([min(ll) max(ll)]);
ylim(1.25*[min(bm) max(bm)]);
frame_h = get(handle(gcf),'JavaFrame');
set(frame_h,'Maximized',1);
set(gca,'fontsize',20);
set(gca,'FontName','Times New Roman');
plot(ll,zeros(length(ll),1),'b','LineWidth',2);
plot(ll,bm,'g','LineWidth',2);
xlabel('Length of beam (m)');
ylabel('Bending Moment (kNm)');
title('Bending Moment Diagram');
%--------------------------------------------------------------------------------------------
% Plot the shear force:
subplot (2,2,3);
box on; hold on; grid on; grid minor;
xlim([min(ll) max(ll)]);
ylim(1.25*[min(sf) max(sf)]);
frame_h = get(handle(gcf),'JavaFrame');
set(frame_h,'Maximized',1);
set(gca,'fontsize',20);
set(gca,'FontName','Times New Roman');
plot(ll,zeros(length(ll),1),'b','LineWidth',2);
plot(ll,sf,'g','LineWidth',2);
plot([0,0],[0,sf(1)],'g','LineWidth',2);
plot([L,L],[0,sf(end)],'g','LineWidth',2);
xlabel('Length of beam (m)');
ylabel('Shear Force (kN)');
title('Shear Force Diagram');
%--------------------------------------------------------------------------------------------
% Plot the deformed shape:
subplot (2,2,4);
box on; hold on; grid on; grid minor;
xlim([min(ll) max(ll)]);
ylim(1.2*[1000*min(disp) 1000*max(disp)]);
frame_h = get(handle(gcf),'JavaFrame');
set(frame_h,'Maximized',1);
set(gca,'fontsize',20);
set(gca,'FontName','Times New Roman');
plot(ll,zeros(length(ll),1),'b','LineWidth',2);
plot(ll,1000*disp,'g','LineWidth',2);
xlabel('Length of beam (m)');
ylabel('Deflection (mm)');
title('Deformed Shape of the Beam');
%=============================================================================================