Is it possible, even in theory, to determine the work done and the heat exchanged in a general, non-quasistatic process?
Example situation: Consider a tube separated into two sides A and B by a piston that is initially in a fixed position. The piston conducts heat. Initially, side A is filled with a cool, low-density gas and side B is empty. At t=0, we rapidly fill side B with a hot gas to an extremely high density. We then quickly release the piston, causing it to rapidly move towards side A. Assume the piston moves fast enough that the process cannot be considered quasi-static. Furthermore, assume that initial temperature difference between the gasses is large enough to ensure that they interact thermally during this process.
Question: Can we define the work done on A in this process?
My thinking: In a non-quasi-static process, mechanical interaction causes the energy levels defined by the Hamiltonian to shift. At the same time, the interaction causes transitions between energy levels to occur. The combination of these two effects results in a change in average energy of the system (A). According to Reif, this energy change is defined as the work. However, at the same time we have thermal interaction between A and B. These interactions do not cause the energy levels of A to shift, but it does cause transitions between energy levels.
At any step in the process, the most we could know about our system is the energy levels and the population of those energy levels by an ensemble of similar systems. However, I don't see how we can determine which transitions from the original state were induced by mechanical interactions and which were induced by thermal interactions. Therefore, I don't see how we can separate the total average energy change into work and heat.
Any insights into this problem or where my thinking went astray is deeply appreciated.