-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspatialmode_numeric.m
56 lines (49 loc) · 9.19 KB
/
spatialmode_numeric.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
function spatialmode_numeric
% Beam properties
L = 1; % Length of the beam in meters
a = 6.35e-3; % Side length of the square cross-section in meters
I = a^4 / 12; % Moment of inertia
E = 69e9; % Young's modulus in Pa
rho = 2700; % Density of aluminum in kg/m^3
A = a^2; % Cross-sectional area
P = -10; % Tip payload in Newtons
EI = E * I; % The flexural rigidity
% First mode approximated root for clamped-free beam
k1 = 1.87510407;
% Calculate omega_1 using the given relationship
omega_1 = (k1^2 * sqrt(E * I / (rho * A)));
% Define the mesh points
xmesh = linspace(0, L, 1000);
% Initial guess for the solution
solinit = bvpinit(xmesh, [0 0 0 0]);
% Solve the boundary value problem
sol = bvp4c(@(x, y) beamODE(x, y, omega_1,rho,A,EI), @(ya, yb) beamBC(ya, yb, P, EI, L), solinit);
% Plot the solution
x = linspace(0, L, 100);
y = deval(sol, x);
figure(1);
plot(x, y(1, :), 'r');
xlabel('x');
ylabel('\phi(x)');
title('Beam deflection with given properties');
% Example of evaluating and plotting a symbolic expression
syms x
phiSol1 = (1204306519316021*11417981541647679048466287755595961091061972992^(1/2)*141153237138531503619427459802038107605809441625^(1/2)*exp(-(11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x)/11417981541647679048466287755595961091061972992)*exp(-(11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x*1i)/11417981541647679048466287755595961091061972992)*(exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x)/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*1i)/11417981541647679048466287755595961091061972992)*(1 + 1i) - exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x*1i)/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4))/11417981541647679048466287755595961091061972992)*(1 - 1i) + 2*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x)/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4))/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*1i)/5708990770823839524233143877797980545530986496) + exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x)/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4))/5708990770823839524233143877797980545530986496)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*1i)/11417981541647679048466287755595961091061972992)*(1 - 1i) - exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x*1i)/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4))/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*1i)/5708990770823839524233143877797980545530986496)*(1 + 1i) - 2*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x*1i)/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4))/5708990770823839524233143877797980545530986496)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*1i)/11417981541647679048466287755595961091061972992) + 2*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x)/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x*1i)/5708990770823839524233143877797980545530986496)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4))/11417981541647679048466287755595961091061972992) - exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x)/5708990770823839524233143877797980545530986496)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x*1i)/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4))/11417981541647679048466287755595961091061972992)*(1 + 1i) + exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x)/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x*1i)/5708990770823839524233143877797980545530986496)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*1i)/11417981541647679048466287755595961091061972992)*(1 - 1i) - 2*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x)/5708990770823839524233143877797980545530986496)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x*1i)/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*1i)/11417981541647679048466287755595961091061972992) + exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x)/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x*1i)/5708990770823839524233143877797980545530986496)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4))/5708990770823839524233143877797980545530986496)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*1i)/11417981541647679048466287755595961091061972992)*(1 + 1i) - exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x)/5708990770823839524233143877797980545530986496)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*x*1i)/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4))/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*1i)/5708990770823839524233143877797980545530986496)*(1 - 1i)))/(317848833089614868387540012941499855700062587525475124379648000*(exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4))/5708990770823839524233143877797980545530986496) + exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*1i)/5708990770823839524233143877797980545530986496) + 4*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4))/11417981541647679048466287755595961091061972992)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*1i)/11417981541647679048466287755595961091061972992) + exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4))/5708990770823839524233143877797980545530986496)*exp((11417981541647679048466287755595961091061972992^(3/4)*141153237138531503619427459802038107605809441625^(1/4)*1i)/5708990770823839524233143877797980545530986496) + 1));
phiSol1_numeric = matlabFunction(phiSol1);
% Evaluate over the range of x
x_vals = linspace(0, L, 1000);
phiSol1_vals = phiSol1_numeric(x_vals);
%hold on
% Plot the solution
figure(2);
plot(x_vals, phiSol1_vals, 'b');
xlabel('x');
ylabel('\phi(x) (Symbolic Solution)');
title('Beam deflection (Symbolic Solution)');
end
function dydx = beamODE(x, y, omega,rho,A,EI)
dydx = [y(2); y(3); y(4); omega^2 *y(1)*(rho*A/EI)];
end
function res = beamBC(ya, yb, P, EI, L)
res = [ya(1); ya(2); yb(3) - P * L / EI; yb(4)];
end