0% found this document useful (0 votes)
6 views5 pages

Homework 6

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Homework 6

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CE 521 - Structural Dynamics

Instructor: Prof. Wang, Ph.D, P.E


Homework 6
(Numerical Integration)

1. Given: A water tower (SDF system) has the following dynamic properties as shown in Figure
(a). It is subjected to the half-sine-wave loading shown in Figure (b). Neglect damping and
assume that the tower is initiated at rest.

Required:
1) Using the Trapezoidal Method, determine the displacement response history of the system
to the given half-cycle sine pulse force for the first 3.0 second by using the time interval
∆t = 0.1 second. Include your MATLAB code in your submission.
2) Repeat (1) by using the time interval ∆t = 0.05 second.
3) Evaluate the theoretical solution. Compare with the numerical solution in 1) and 2) above.
Display the difference between your numerical answer and analytical answer.
4) Using the Simpson’s Method, determine the displacement response history of the system to
the given half-cycle sine pulse force for the first 2.0 second by using the time interval
∆t = 0.1 second.
5) Submit a figure using MATLAB containing all four plots as required above.
>> % MATLAB Code for Water Tower Displacement Response to Half-Sine
Wave Force

% Given Parameters
w = 978.8; % Weight of the tower in kips
k = 100; % Stiffness in kips/in
g = 386.4; % Acceleration due to gravity in in/s^2
m = w / g; % Mass of the tower in kips-s^2/in
wn = sqrt(k / m); % Natural frequency of the system in rad/s

% Define the force function P(t)


P_max = 100; % Peak force in kips
T_half = 0.6; % Duration of half sine wave in seconds
force = @(t) (t <= T_half) .* (P_max * sin(pi * t / T_half)); % Piecewise function

% Time setup
t_end = 3.0; % Total time for response calculation
dt1 = 0.1; % First time step interval in seconds
dt2 = 0.05; % Second time step interval in seconds
time1 = 0:dt1:t_end; % Time vector for dt = 0.1 sec
time2 = 0:dt2:t_end; % Time vector for dt = 0.05 sec

%% 1) Displacement response using Trapezoidal Method with dt = 0.1


u1 = zeros(size(time1)); % Initialize displacement vector for dt = 0.1
v1 = zeros(size(time1)); % Initialize velocity vector for dt = 0.1

for i = 1:length(time1)-1
t = time1(i);
t_next = time1(i+1);
% External force at current and next time step
P_current = force(t);
P_next = force(t_next);

% Trapezoidal method for acceleration


a_current = (P_current - k * u1(i)) / m;
u1(i+1) = u1(i) + dt1 * v1(i) + (dt1^2 / (2 * m)) * (P_current - k * u1(i));
v1(i+1) = v1(i) + (dt1 / 2) * (a_current + (P_next - k * u1(i+1)) / m);
end

%% 2) Displacement response using Trapezoidal Method with dt = 0.05


u2 = zeros(size(time2)); % Initialize displacement vector for dt = 0.05
v2 = zeros(size(time2)); % Initialize velocity vector for dt = 0.05

for i = 1:length(time2)-1
t = time2(i);
t_next = time2(i+1);
% External force at current and next time step
P_current = force(t);
P_next = force(t_next);

% Trapezoidal method for acceleration


a_current = (P_current - k * u2(i)) / m;
u2(i+1) = u2(i) + dt2 * v2(i) + (dt2^2 / (2 * m)) * (P_current - k * u2(i));
v2(i+1) = v2(i) + (dt2 / 2) * (a_current + (P_next - k * u2(i+1)) / m);
end
%% 3) Theoretical solution
u_theoretical = zeros(size(time1)); % Placeholder for theoretical
displacement solution
for i = 1:length(time1)
t = time1(i);
if t <= T_half
u_theoretical(i) = (P_max / k) * (1 - cos(wn * t));
else
u_theoretical(i) = (P_max / k) * (1 - cos(wn * T_half)) * cos(wn * (t
- T_half));
end
end

%% 4) Plot the results


figure;
hold on;
plot(time1, u1, 'b', 'DisplayName', 'Numerical Solution (dt = 0.1 s)');
plot(time2, u2, 'r--', 'DisplayName', 'Numerical Solution (dt = 0.05 s)');
plot(time1, u_theoretical, 'g', 'DisplayName', 'Theoretical Solution');
xlabel('Time (s)');
ylabel('Displacement (in)');
legend;
title('Displacement Response of Water Tower');

%% Plot the difference between numerical and theoretical solutions


diff_dt1 = u1 - u_theoretical; % Difference for dt = 0.1
diff_dt2 = interp1(time2, u2, time1) - u_theoretical; % Interpolated
difference for dt = 0.05

figure;
plot(time1, abs(diff_dt1), 'b', 'DisplayName', '|Numerical - Theoretical|
(dt = 0.1 s)');
hold on;
plot(time1, abs(diff_dt2), 'r--', 'DisplayName', '|Numerical - Theoretical|
(dt = 0.05 s)');
xlabel('Time (s)');
ylabel('Absolute Difference (in)');
legend;
title('Difference Between Numerical and Theoretical Solutions');

>>
Trapezoidal Numerical Integration MATLAB
For Displacement Response Histo
Eora mit in ku
m
t

I tming It é
A sinwalt e de
If
figit f fn sina.coswpt coswot.sinwofd
n

fiigltse coswntdt fiftontfigure sina.tt


f.fr
A B
A F T dT E FLI Tg T COSWDT

B gleldt E
g T
ig t Sin WDT

Trapezoidal Method
A Flo 2 f 20 7 24130 f 24 Cn Dots f n ot
20 t 3413017 29 In Dot not
B 910 2g g
St 0.01 sec

You might also like