# Energy conservation and the 1st law of thermodynamics with external forces

I have a box filled with a gas ( a real gas , cannot be approximated to a ideal gas) in which the molecules are jiggling. This box is in a gravitational field and an electric field and has a piston over it. The piston is not diathermal and the gas is somehow doing work on the piston. Together with this , the box is moving in the gravitational field as well as the electric field and there is an external force on the box which is continuously accelerating it. Moreover outside the box there is some medium which is applying a non conservative force on the box as it moves ( friction ).

What would be the 1st law in this case for the entire box piston system. I am not asking for a solution ( it might not be possible ). I am asking what the general equation of the 1st law would become ( just the terms that would be added ) due to gravitational , electric and non conservative force effect. What shall be the energy Conservation equation in the above

Well, the complete form of the first law of thermodynamics (that is sometimes overlooked) is $$\Delta E=Q-W$$where $$E=U+(KE)+(PE)$$ Also, in this equation, W includes piston work, frictional work, work related to an electric field, etc. The system, according to your description includes the solid box and its contents (the gas). Actually, the electric field could be lumped in with the PE or it could be included separately in the work. But the PE would usually be considered to include gravitational.