Phase difference of driving frequency and oscillating frequency

The oscillator frequency $\omega$ says nothing about the actual oscillator phase. Let us suppose that your oscillator oscillates freely like this: $$x(t) = A_0\cdot\cos(\omega t + \phi_0),\; t<0.$$ At $t=0$ it has a phase $\phi_0$. Depending on its value the oscillator can be moving forward or backward with some velocity. If you switch your external force on at $t=0$ and onwards, say, to push your particle in a positive direction, then, depending on the particle phase, the force will accelerate or decelerate the particle.

Generally you write down the external force in the same way: $$F_\text{ext}(t)=F_0\cdot \cos(\omega t +\Phi_0).$$ This expression stays in the driven oscillator equation, namely, in the right-hand side. The resonance happens always, i.e., the external force will supply energy to the particle, but this supplying can start immediately if the force direction and the particle velocity direction coincide. Otherwise the external force first slows down the particle and only then starts pumping its amplitude.

The particle velocity phase is shifted with respect to the particle coordinate $$v(t) = -A \sin(\omega t + \phi_0)=A\cos(\omega t + \phi_0 +\pi/2),\; t<0.\;$$ So, when $\Phi_0 =\phi_0 +\pi/2\;$ the force is in phase with velocity (not with coordinate) - you have not only the same direction for the velocity and for the force, but also coincidence of instants when both the velocity and the force become zero (no time intervals with their opposite signs).

EDIT: The permanent phase shift of $\pi/2$ in a resonant case with friction (as described in user17581 answer) is a self-established thing and its meaning is simple - the external force in the end compensates exactly the friction force; the latter being proportional to velocity which is shifted by $\pi/2$ with respect to the coordinate time-dependence (so the oscillator oscillates as if it were free, without losses).


It would depend on damping effects being taken into account or not.

Invoking Newton's 2nd Law of motion, a differential equation for the motion of a damped harmonic oscillator can be written (including an external, sinusoidal driving force term):

$m\frac{d^2x}{dt^2}+2m\xi\omega_0\frac{dx}{dt}+m\omega_0^2x=F_0\sin\left(\omega t\right)$

Where $m$ is the inertial mass of the system, $\omega_0$ is its characteristic frequency, $\xi$ a dimensionless damping factor... And, last but not least, where $F_0$ is the amplitude of the driving force and $\omega$ its frequency.

The stationary ($t\rightarrow\infty$) solution takes the shape $x\left(t\right)=A_0\sin\left(\omega t-\varphi_0\right)$, where $A_0$ is an amplitude factor (whose particular expression in terms of the particular parameters is not relevant to this question) and $\varphi_0$ is phase lag, which is this phase difference you are asking about.

This phase difference can be calculated to be $\varphi_0=\left|\arctan\left(\xi\dfrac{2\omega\omega_0}{\omega^2-\omega_0^2}\right)\right|$. It is a phase lag, so with the (implicitly) chosen phase convention, it has to be positive.

If there was no damping whatsoever in the system, $\xi$ would be zero, and you would be right: $\varphi_0=0$. The stationary motion of the oscillator would be in phase with the driving force (regardless of which is the relationship between $\omega$ and $\omega_0$).

But in an undamped resonant situation the amplitude $A_0$ diverges, which means that the stationary solution is never reached (starting from reasonable, finite initial conditions for the system). Also, in a physical down-to-earth situation, the system would eventually breakdown somewhere, somehow, since energy is being introduced into the system with perfect efficiency (that is what 'resonance' is all about) and without any means to dissipate it. Somewhere, sooner or later, something would go boom or crash. That is how nasty undamped resonances are.

On the other hand, for a non-zero damping, in the resonant case $\omega=\omega_0$, the argument of the $\arctan$ function diverges, so the phase difference turns out in this case to be $\frac{\pi}{2}$.

To sum up, the $\frac{\pi}{2}$ phase appears as an effect of damping in the system, and just a little bit of it is enough to offset the oscillatory response from the system. As it happens, every realistic, down-to-earth harmonic system has some kind of damping in its dynamics. Even if the damping is so small that the induced dephasing in an out-of-resonance situation is negligible for every purpose that the model has, damping has to be taken into account in resonant and closely resonant motion, otherwise the model yields highly unphysical results.


For resonance to occur (at $\gamma$=0 and $\omega=\omega_0$), the system must be able to absorb all the energy input coming from the external driving force, and this results in incessant growth in the amplitude. For this to happen, the external force, which does not have to be in sine/cosine form, should be positive (pushing forward) while the oscillator is traveling from $-A$ (amplitude) to $+A$, and the external force should be negative (pulling back) while the oscillator is traveling from $+A$ to $-A$.

The plot below shows the solution of $\ddot{x}(t)+\omega_0^2x(t)=f(\omega_0 t)$ where $f(\omega t)$ is a square-wave of which frequency $\omega$ here matches the natural frequency of the harmonic oscillator $\omega_0$. The amplitude grows in time due to the resonance ($\omega=\omega_0$) as expected.

xxx

One can observe from the plot above that the force is positive while the oscillator is traveling in the forward direction (green shaded region), and the force is negative while the oscillator is traveling in the backward direction (pink shaded region); this leads to a complete absorption of the energy from the driving force.

Now let's have a sine-wave external force instead of a square wave. The result is the same, but this time we can discuss the phase difference between the two sine waves (the amplitude and the external force). From the plot, one can see how $x(t)$ and the force have a phase difference of $\phi=\pi/2$.

enter image description here

In layman terms, the force should be positive (forward) while the oscillator is moving forward, and vice verse. (Note that this statement does not say the force should be positive when the oscillator amplitude is positive.)

Finally, that the phase $\phi = \arctan \left( \frac{2 \xi \omega \omega_0}{\omega^2 -\omega_0^2} \right)$ becomes equal to $\pi/2$ when $\omega \rightarrow \omega_0$ (here $\omega_0=3$) and $\xi \rightarrow 0$ can be seen from the plot below. For $\omega \rightarrow \omega_0=3$, we get $\phi=\pi/2$ for all nonzero values of $\xi$. When $\xi=0$, we get a step function (not shown in the plot), but we can consider $\phi=\pi/2$ for any value of $\xi$ that is arbitrarily close to zero.

enter image description here

Want to see all of these in action? Here's a video from MIT: https://www.youtube.com/watch?v=aZNnwQ8HJHU

Hope all these help.