Compression of ideal gas using an adiabatic-movable wall - does the energy of the gas change? TL;DR: When compressing an ideal gas quasi-statically, $\text{d}U=\text{d}Q-P\text{d}V$. If we do this adiabatically then $\text{d}Q=0$ thus $\text{d}U=-P\text{d}V$. But this doesn't make sense since the process of slowly moving a wall should not change the energy of the atoms of the gas. How is this resolved?

Consider a system of an ideal ideal gas in a chamber with walls that are impenetrable to any matter or energy flows. There is only one wall which is movable, but it does not allow flow of matter or heat (it is adiabatic).
Now, suppose we quasi-statically push the movable wall (from the outside). By the laws of thermodynamics, $\text{d}U=\text{d}Q-P\text{d}V$ along the process, where $\text{d}U$ is the infinitesimal change in energy of the ideal gas, $\text{d}Q$ is the infinitesimal heat flux into the gas, $\text{d}V$ is the infinitesimal volume change of the gas, and $P$ is the instantaneous pressure of the gas.
Now, since the wall is adiabatic, $\text{d}Q=0$, thus the change of energy is only due to the work done: $\text{d}U=-P\text{d}V$
But, from microscopic considerations, we know that pushing the wall should not change the energy $U$. The reason is that all the energy of the ideal gas is the kinetic energy of its constituent atoms, and the atoms bounce off the walls elastically, with no increase or decrease of their energy (and the movable wall is moved quasi-statically, thus it is almost motionless). Therefore, $\text{d}U=0$ On the other hand, $\text{d}V\neq0$ and also $P\neq0$. How is this contradiction with $\text{d}U=-P\text{d}V$ resolved?

My attempts to solving this problem:


*

*Maybe it is not possible to perform work with no heat flux, thus the situation described here can never happen even in principle? I am bothered by this explanation, because even if there is no truly adiabatic wall, I can imagine that I can make its "heat conductance" very small, such that $\text{d}Q$ will be too small to balance the equation. Also, there is nothing in the mechanics of the problem that doesn't allow (at least as a thought experiment) the wall to be friction-less, balanced exactly on both of its sides by pressure (such that for each hit of an ideal gas atoms on one side, there is an exactly opposite application of pressure on the other side, with perfect timing). And we can imagine that we push the wall only during time intervals between consecutive hits of atoms, so that when they hit the wall, it is truly motionless, and when the wall moves there is no resistance of any sort.

*Expanding upon the previous point: In the idealized method of pushing the wall, described in the previous point, I actually do not perform any work, since the wall is friction-less and there is no applied pressure by the gas during the movement. Thus, we cannot say that there was any work applied on the gas. If this is a solution, why do we model the quasi-static work term to be $-P\text{d}V$, if it actually depends on the exact way the work was done? Was there anything not quasi-static about my description? And when is this term applicable? Is it only valid if we move the wall rapidly enough so that it adds to the kinetic energy of the bouncing atoms?

 A: I think you've misunderstood the nature of an elastic collision. The total KE of participating bodies stays the same. You seem to be assuming that the KE of molecules striking a moving piston is unchanged in the collision. It isn't. The molecules gain KE from the piston if the piston is moving 'inwards'. The piston loses KE (or it would if the KE wasn't replenished by the agency pushing the piston).
[Think of a ball landing on a cricket bat that the batsman is swinging at high speed. The ball will leave the bat moving faster than it approached. Or do the maths for a head-on elastic collision between body of mass M (representing the piston) and a body of mass m (a gas molecule).]
A: I guess the confusion is due to ignoring macroscopic approach. 
Assuming there is only one molecule in the chamber. And, each time, you chose the time to move the piston when the molecule is away. In this case, you do not do any work and internal energy doesn't change. 
On the other hand, if you move the piston when the molecule hits the piston, work is then done. And, at the same time, the molecule is accelerated. In this case, the velocity increases and the internal energy increases.
In a situation where there are millions of molecules, it is impossible to move the piston without any molecules hitting on it. So the work is done and a group of molecules accelerated. This causes internal energy increasing.   
