  We study the exact solution for the energy density of a real massless scalar
field in a two-dimensional spacetime, inside a non-static cavity with an
arbitrary initial field state, taking into account the Neumann and Dirichlet
boundary conditions. This work generalizes the exact solution proposed by Cole
and Schieve in the context of the Dirichlet boundary condition and vacuum as
the initial state. We investigate diagonal states, examining the vacuum and
thermal field as particular cases. We also study non-diagonal initial field
states, taking as examples the coherent and Schrodinger cat states.
