Driving force of driven damped harmonic oscillator missing
Mostra commenti meno recenti
Hello. Below is my code for a simple driven damped spring oscillator. For some reason the response is always that of a damped oscillator, regardless of the amplitude of the driving force. I've tried running the code with a much smaller oscillator frequency (and damping coefficient) and it works as expected, but with this set of parameters the effects of the driving force cannot be seen. My code borrows from the template code in the ode45 page. Any help is appreciated.
c0=299792458; %speed of light
lase_lambda = 1064e-9; %wavelength
lase_freq = c0/lase_lambda;
w0 = 2*pi*lase_freq; %Oscillation frequency
tend = 1e-13; %end time
ft = linspace(0,tend,1000); %time vector
f = 5*cos(ft*w0); %Driving force
options=odeset('RelTol',1e-6,'AbsTol',1e-6);
p0 = [1 0]; %initial position and velocity
[t,p] = ode45(@(t,y) SpringFunction(t,y,ft,f), [0 tend], p0, options);
plot(t,p(:,1)) %plot the first column (x) vs. time
function dydt = SpringFunction(t,y,ft,f)
f = interp1(ft,f,t);
c0=299792458; %speed of light
lase_lambda = 1064e-9; %wavelength
lase_freq = c0/lase_lambda;
w0 = 2*pi*lase_freq; %Oscillation frequency
tau2 = 500e-6;
c = 1/tau2*1e10; %Damping coefficient
dydt = zeros(size(y));
dydt(1) = y(2);
dydt(2) = f-c*y(2)-(w0^2)*y(1);
end
Risposta accettata
Più risposte (1)
c0=299792458; %speed of light
lase_lambda = 1064e-9; %wavelength
lase_freq = c0/lase_lambda;
w0 = 2*pi*lase_freq; %Oscillation frequency
tend = 1e-13; %end time
ft = linspace(0,tend,1000); %time vector
f = 10*cos(ft*w0) %Driving force
options=odeset('RelTol',1e-6,'AbsTol',1e-6);
p0 = [1 0]; %initial position and velocity
[t,p] = ode45(@(t,y) SpringFunction(t,y,ft,f), [0 tend], p0, options);
plot(t,p(:,1)) %plot the first column (x) vs. time
function dydt = SpringFunction(t,y,ft,f)
f = interp1(ft,f,t);
c0=299792458; %speed of light
lase_lambda = 1064e-9; %wavelength
lase_freq = c0/lase_lambda;
w0 = 2*pi*lase_freq; %Oscillation frequency
tau2 = 500e-6;
c = 1/(tau2*1e10); %Damping coefficient check this value too hgh
dydt = zeros(size(y));
dydt(1) = y(2);
dydt(2) = f-c*y(2)-(w0^2)*y(1);
end
5 Commenti
VBBV
il 23 Nov 2022
Your damping coefficient seems to be too unreasnobaly high value, May be you mean this
c = 1/(tau2*1e10);
in place of
c = 1/tau2*1e10;
Jerry Yeung
il 23 Nov 2022
Do you mean the values for damping coefficient (2e13) and oscillator frequency(1.77e15) produce underdamped system ? or overdamped ? are these values fixed for your system ?
c0=299792458; %speed of light
lase_lambda = 1064e-9; %wavelength
lase_freq = c0/lase_lambda;
w0 = 2*pi*lase_freq %Oscillation frequency
tau2 = 500e-6;
c = 1/(tau2*1e10) %
Jerry Yeung
il 23 Nov 2022
do you mean the effec of driving force effect on vibration amplitude ?
c0=299792458; %speed of light
lase_lambda = 1064e-9; %wavelength
lase_freq = c0/lase_lambda;
w0 = 2*pi*lase_freq; %Oscillation frequency
tend = 1e-13; %end time
ft = 0.5;
options=odeset('RelTol',1e-6,'AbsTol',1e-6);
p0 = [0 0]; %initial position and velocity
F = [1 100 1000] % different force amplitudes
for k = 1:length(F)
f = F(k)*cos(ft*w0); %Driving force
[t,p] = ode45(@(t,y) SpringFunction(t,y,ft,f), [0 tend], p0, options);
plot(t,p(:,1)) %plot the first column (x) vs. time
hold on
end
legend('F = 1','F = 100','F = 1000')
function dydt = SpringFunction(t,y,ft,f)
% f = interp1(ft,f,t);
c0=299792458; %speed of light
lase_lambda = 1064e-9; %wavelength
lase_freq = c0/lase_lambda;
w0 = 2*pi*lase_freq; %Oscillation frequency
tau2 = 500e-6;
c = 1/(tau2*1e5); %Damping coefficient check this value too hgh
dydt = zeros(size(y));
dydt(1) = y(2);
dydt(2) = f-c*y(2)-(w0^2)*y(1);
end
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


