I understand resonance occurs when natural frequency and the excitation frequency aligns. I am looking for some explanation on how this satisfies law of conservation of energy. Preferably, at atomic level.
Elements of answer for continuum mechanics (therefore not at the atomic level...) : resonance is a structural effect, not only material effect (it depends on the shape of the structure as well). When vibrating under prescribed load pulsating at a certain frequency, the application point of the load also vibrates. Depending on the movement of this point, the external load may inject energy into the system ; if they are synchronized (at the eigenfrequency of the structure), it will continuously inject energy.
There is no need to go at atomic level, it can be explained from fundamentals of vibrations.
There is a misconception about the resonance that the amplitude of vibration is infinite (mathematically) and it violets the law of energy conservation.
Consider a spring (k), mass (m) system which excited by the harmonic force f(t) = Fo sin (wt), its complete solution is x(t) = xc + xp.
xc = complementary part which is due to initial conditions and xp = particular solution.
At resonance condition the excitation frequency w = wn = sqrt(k/m), the xp = Fo/2k *wn t cos (wt). It can be seen that at resonance the response x(t) is governed by the xp which grows unbounded with time. Therefore the resonance is not an instantaneous phenomenon but it takes time to build.
Now analyze the situation using work and energy.
Consider a harmonic force f(t) = Fo sin (wt) with the displacement y(t) = Y sin(wt – ϕ), the corresponding WD per cycle = ∫ f dy = π Fo Y sin ϕ.
When ϕ = 0, 1800 f(t) and y(t) are in phase or out of phase and WD = 0.
When ϕ = + ve acute angle, f(t) is ahead of y(t) and WD = + ve i.e. energy is added to the system.
When ϕ = – ve acute angle, f(t) is lagging behind of y(t) and WD = – ve i.e. energy is removed from the system.
When ϕ = ± 900 , WD is maximum either + ve or – ve.
Referring to any standard book on vibration it is seen that, at the resonance, f(t) is ahead of x(t) by 900 and there is an energy addition and response growth in every cycle of excitation. The energy addition increases the maximum potential energy which is responsible for the amplitude of vibration. According to the work–energy principle this does not violet the energy conservation law.