Mass-spring systems with various forcing functions
> | with(DEtools):
|
Here is a simple example with no external forcing: y''+y'+y=0, y(0)=1 & y'(0)=0.
> | DEplot(diff(y(t),t$2)+diff(y(t),t)+y(t)=0,y(t),t=0..20,[[y(0)=1,D(y)(0)=0]],stepsize=0.05); |
Next we add a cos(1*t) forcing term and use y(0)=y'(0)=0. Change the frequency of the cos(1*t) term and see what happens. You may need to change the plot range to see what you need. Can you find the natural frequency empirically?
> | DEplot(diff(y(t),t$2)+diff(y(t),t)+y(t)=cos(1*t),y(t),t=0..30,[[y(0)=0,D(y)(0)=0]],stepsize=0.05); |
Next we introduce a tool for discontinuous forcing functions. It is called the Heaviside function, but I will just use h(t). It is 0 when t<0, then it is 1 after that.
> | h := t-> Heaviside(t); |
> | plot(h(t),t=-3..10, thickness=3); |
The trick is we can use h(t) like a switch. Here is an example. It will go on at t=1 and off at t=3.
> | plot(h(t-1) - h(t-3),t=-3..10, thickness=3); |
Now let's use this as a forcing function. (Play with this. Lower the damping. Move the time window when the external force is on.)
> | DEplot(diff(y(t),t$2)+1*diff(y(t),t)+y(t)=h(t-1) - h(t-3),y(t),t=0..20,[[y(0)=0,D(y)(0)=0]],stepsize=0.05); |
Here is a fancy example. (Play with this. What kinds of shapes can you make?)
> | F := t -> 2*(h(t-Pi) - h(t-2*Pi)) + 0.4*(t-4*Pi)*(h(t-4*Pi)-h(t-6*Pi)) + 4*sin(t)*(h(t-7*Pi)-h(t-8*Pi)); |
> | plot(F(t),t=0..30,thickness=3); |
> | DEplot(diff(y(t),t$2)+1*diff(y(t),t)+y(t)=F(t),y(t),t=0..40,[[y(0)=0,D(y)(0)=0]],stepsize=0.05);
|
Experiment!