Where does the change in energy come from when trapping a photon between mirrors? You have a photon traveling with E=hf and you trap it between two perfectly reflecting mirrors (like a QM particle in a box). The photon has to make a standing wave between the mirrors and its spacial frequency is dependant on the distance between the mirrors, L. Its time frequency, and hence energy are derived from the spacial frequency; Therefore E is dependant on L. Where does the change in energy come from?
 A: When you change the separation between the mirrors you are doing [positive or negative] mechanical work against the radiation pressure of the photon. This work is the source of energy here. The situation is completely analogous to the classical gas (or a single particle) under piston. 
More explicitly:
1) The frequency of the photon, for the lowest mode standing wave is
$\nu = \frac{c}{2L}$;
2) The momentum associated with the photon is
$p = \frac{E}{c} = \frac{h \nu}{c}$;
3) The pressure on the mirror is
$P = 2 \nu p =  \frac{2h}{c} \nu^2 = \frac{h c}{2} \frac{1}{L^2}$;
4) The mechanical work (per unit area) done by moving the mirror from infinity to L is
$A = \int_{\infty}^L PdL = \frac{h c}{2} \frac{1}{L}$
The latter can be recognized as $h \nu$ which is the photon energy E.
A: There is no reason why the energy of a particle should not change, if there are interactions with other particles or with macroscopic objects like mirrors.
The exception is when you have fixed mirrors, and when the photon has one of the authorized energies compatible with the distance of the mirrors, but it is an exception.
You may consider, that, when you bring closer the mirrors separated by a distance $D$, from $D=+\infty$ to $D=L$, the energy of the photon changes progressively and fits with one of the authorized energies $E_n(D) =\frac{n\pi}{D}$
A: The point is, the photon's state doesn't have to be an eigenstate. When you trap it between mirrors, its state will be described as a linear superposition of energy eigenstates. However, the expectation value of the photon's energy will be the initial energy of the photon.
A: If you have a single photon with energy $h\nu= \frac{hc}{\lambda}$ ( $c$ the velocity of light) and two macroscopic  "perfectly reflecting mirrors" the answer is the $\lambda$ depends on the Heisenberg uncertainty principle:

This means that the photon has an uncertainty in wavelength  and therefore frequency that can accommodate what you call "energy change" without taking it from anything, accommodating the standing wave condition within the HUP. (standing waves can have zillions of oscillations in place) . Do not forget that the wavelengths are of order $10^{-8}$ centimeters, impossible to place mirrors  well macroscopically anyway.
If the mirrors are attempted to be at a distance the order of angstroms ( maybe with nanotechnology) the photon has to be treated quantum mechanically to find the probability of reflection versus scattering and one will find that there exists no "perfect mirror" at the microscopic level so the thought experiment has no meaning physically. 
