Infinite square well that suddenly decreases in size A well known exercise in basic quantum mechanics is the sudden (diabatic) increase of the length of an infinite square well.
Now consider a particle in an eigenstate of an infinite well that is suddenly decreased in length. At first glance, this seems troublesome since the eigenstate of the initial well cannot be expanded in the eigenstates of the smaller well.
So I thought about normalizing the initial eigenstate again inside the smaller well before calculating the overlap. This is what I got so far:
If the particle was initially in the ground state of an infinite well from $0$ tot $2a$, the renormalized wave function in a smaller well from $0$ to $a$ is
\begin{equation}
\phi_1 = \sqrt{\frac{2}{a}} \sin \frac{\pi x}{2a}.
\end{equation}
The eigenstates of the smaller well are
\begin{equation}
\psi_n = \sqrt{\frac{2}{a}} \sin \frac{n\pi x}{a},
\end{equation}
and so the overlap is
\begin{equation}
c_n = \frac{2}{a} \int_0^a dx \sin \frac{\pi x}{2a} \sin \frac{n\pi x}{a} = (-1)^n \frac{8n}{\pi\left(1-4n^2\right)}
\end{equation}
Now the problem is that the expectation value of the energy diverges,
\begin{equation}
\left< E \right> = \sum_n \left|c_n\right|^2 E_n = \frac{32 \hbar^2}{ma^2} \sum_n \frac{n^4}{\left(1-4n^2\right)^2}.
\end{equation}
This is because the wave function is discontinuous at $x=a$ so the first derivative contains a term proportional to $\delta(x-a)$.
So I concluded that this method is unsatisfactory since it yields non-physical results.
Is there a solution or is the problem ill defined? The adiabatic limit is certainly well defined.
EDIT
Following Kevin Zhou's proposal, I considered this system instead

                        

For $E<V_0$, the solutions are given by
\begin{align}
\psi_1(x) & = \sin kx \\
\psi_2(x) & = \frac{\sin ka}{\sinh \lambda a} \sinh \lambda(2a-x),
\end{align}
with $k=\sqrt{2mE}/\hbar$ and $\lambda=\sqrt{2m(V_0-E)}/\hbar$. And the spectrum is found from
\begin{equation}
\lambda \tan ka = -k \tanh \lambda a,
\end{equation}
which has to be solved numerically. For $E>V_0$ we simply let $\lambda \rightarrow iq$ with $q=\sqrt{2m(E-V_0)}/\hbar$.
 A: Too long for a comment: Another possibility is to consider the case of the infinite square well potential with a moving wall. This can be solved exactly for the case of constant speed, $v$ (where for an expanding well $v$ is psoitive and for a contracting well $v$ is negative: See Griffiths, Introduction to Quantum Mechanics (2005), Problem 10.1 who references the work of Doescher and Rice Am J Phys {\bf 37} 1246 (1969) (Griffiths only considers $v$ positive (an expanding well), but Doescher and Rice make it clear the solution it is also valid for a negative $v$).
If the original well is of width $a$, a complete set of eigenfunctions are $$\Phi_n(x,t) \equiv \sqrt{\frac{2}{w}} \sin\frac{n \pi}{w}x \, e^{i (m vx^2 - 2E^i_n at)/(2 \hbar w)}$$ with $w(t) \equiv a + vt$ is the instantaneous width of the well and $E^i_n = \frac{n^2 \pi^2 \hbar^2}{2ma^2}$ is the $n^{th}$ allowed energy of the original well. Any solution is a linear combinationof the $\Phi_n(x,t)$ and the coefficients may be determined in the usual manner.
A: I'd say that the  non adiabatic problem is ill-defined. Lets see.
All the initial solutions $\Psi_n(x) = A_n \sin(n \pi x / 2a)$ have a probability 
current
$\Psi'^* \Psi - \Psi^* \Psi'$ equal to zero everywhere, so in principle you can cut them at any point without having a leak of probability. The problem is that the boundary conditions for the domain of any hamiltonian -of any self-adjoint operator- must be unique, compatible with linearity. 
Depending on $n$, the central cut $(a/2,3a/2)$ of the original eigenfunction goes to 4 different hamiltonians:
$n \mod 4 = 1 \to$  $\Psi(a/2)=\Psi'(a/2), \Psi(3a/2)=-\Psi'(3a/2)$
$n \mod 4 = 2 \to$ $\Psi'(\frac a2)=0, \Psi'(\frac{3a}2)=0$
$n \mod 4 = 3 \to$ $\Psi(\frac a2)=-\Psi'(\frac a2), \Psi(\frac{3a}2)=\Psi'(\frac{3a}2)$
$n \mod 4 = 0 \to$  $\Psi(\frac a2)=0, \Psi(\frac{3a}2)=0$
The cut to $(0,a)$ goes to two different hamiltonians
$n \mod 2 = 1 \to \Psi(0)=0, \Psi'(a)=0$
$n \mod 2 = 0 \to$ $ \Psi(0)=0, \Psi(a)=0$
which is simpler, but it is still the same problem: the eigenfunctions of one hamiltonian are out of the scope of the other. This should be the origin of the infinity you get when adding across all the projections to get an expectation value; really the discontinuity at the border is mathematically irrelevant because you are integrating in $L^2(0,a)$; you should get a finite result if you overlap and add against the set of functions in the same domain, i.e. with  the same boundary conditions.
It could make sense to claim that you can trash half of the spectrum because it is also the thing we are doing in position space: we are trashing all the eigenvalues $|\delta_x>$ for $x$ greater than $a$. But the same is happening with the central cut, and there we are forced to trash three of every four values of energy. So the argument does not look very strong. 
A: The suggestion of Kevin Zhou, on other hand, has the advantage that we could try to control all the poles of the original well and the halved one. The polology of the square well was studied in Nussenzveig "The poles of the S-matrix of a rectangular potential well or barrier" Nuclear Physics, 11:409–521, 1959. and revisited in his book "Causality and Dispersion Relations". Some details in Spanish can be guessed from chapter 3.2 of my thesis, but the article of B. Belchev, S.G. Neale and M.A. Walton does a more complete review, and I did not include the plots in my document.
A half-baked idea to exploit here is that as we shrink the potential form $2a$ to $a$ no eigenstate is really lost. What happens in the scattering matrix is that the corresponding pole moves across the imaginary axis $ik$ until it collides with another pole coming from a pure "anti-bound" state ('Gamow vectors', or discrete states inserted in the continuous E>0 part of the spectrum, if I recall correctly) and then both poles leave symmetrically the imaginary axis going to be resonances in the complex plane (some authors -me- also call resonances to the "anti-bound" states). You can see it in fig 5 of BNW article. 
So it could make sense to analyze the halved problem as a function not only of the eigenvalues $E_n$ left, but also of the resonances leaked into the complex plane. And combine the process of halving the potential with the increase of $V_0$. 
