# Expansion or Compression Work by Gas ##=\int{P_{ext}dV}##

Mentor
In private discussions, another member @burian and I have been discussing why, in compression and expansion of a gas, the work can be calculated from ##W=\int{P_{ext}dV}##. We thought it would be of value to open the discussion to the full membership.

When the external pressure applied is transferred from the the piston on to the gas, the gas will push back the piston by an equal and opposite amount. Now, since we have two forces acting on the piston, the original force due to Ext P and the inside gas pushing back, it must be that the net force on piston is zero and hence it can not move Therefore no compression.

Burian: Would you like to elaborate on this before I or others offer an answer.

binis

anuttarasammyak
Gold Member
P in thermodynamics 1st law is ##P_{in}##. dV >0 or <0 until inner pressure and out pressure balance and cease see-saw if any.

burian
In private discussions, another member @burian and I have been discussing why, in compression and expansion of a gas, the work can be calculated from ##W=\int{P_{ext}dV}##. We thought it would be of value to open the discussion to the full membership.

When the external pressure applied is transferred from the the piston on to the gas, the gas will push back the piston by an equal and opposite amount. Now, since we have two forces acting on the piston, the original force due to Ext P and the inside gas pushing back, it must be that the net force on piston is zero and hence it can not move Therefore no compression.

Burian: Would you like to elaborate on this before I or others offer an answer.
Yes, in thermodynamics, we often say work done on gas by environment= work done on environment by gas. If these two are equal, then it must be that pressure of gas on the piston at boundary with environment and pressure of environment at boundary with gas must be same. But, if this is so, how can the piston move at all?

Mentor
Yes, in thermodynamics, we often say work done on gas by environment= work done on environment by gas. If these two are equal, then it must be that pressure of gas on the piston at boundary with environment and pressure of environment at boundary with gas must be same. But, if this is so, how can the piston move at all?
Are we talking about a piston that has mass? Also, we need to be careful specifying exactly what we consider our system, and the boundary at which our system ends and the surroundings begin? Where are these in your thinking? Is your system the gas, or is it the gas plus the piston?

anuttarasammyak
Gold Member
If these two are equal,
Yes, no works. And if not equal e.g. heating inner gas ?

burian
jack action
Gold Member
the gas will push back the piston by an equal and opposite amount.
That is not really true. You have to consider Newton's first law, ##\sum F = ma##. So converting the pressure to force acting on the piston of mass ##m## and area ##A##, you get:
$$P_{int}A - P_{ext}A = ma$$
So if you know that ##P_{int} \neq P_{ext}## then ##a \neq 0##. This means the boudary (i.e. the piston) will accelerate as long as ##P_{int} \neq P_{ext}##.

Imagine a closed cylinder with a piston mechanically held in position in the middle. There is a gas under different pressure on either side. Release the lock of the piston. What happens?

Mentor
Here is some background information on reversible and irreversible deformations of gas.

At thermodynamic equilibrium, the local normal compressive stress exerted by the gas on the inside face of the piston is given by $$\sigma_z=P=\frac{nRT}{V}=\frac{RT}{v}\tag{1}$$where v is the specific volume of the gas. All these parameters are uniform throughout the gas, and do not vary with spatial location. So they are also the averages at the piston face.

For a reversible expansion or compression, the deformation of the gas is infinitely slow, and the gas thus passes through a continuous sequence of thermodynamic equilibrium states. As such, the same Eqn. 1 applies to the gas at each instant during the entire reversible expansion or compression.

The situation for irreversible expansions or compressions is very different. Unlike a reversible expansion or compression, for the irreversible case, the parameters are not spatially uniform and vary with spatial position within the gas. In addition, we know from fluid mechanics that the local compressive stress exerted by the gas on the inside face of the piston includes viscous stresses, and is given by $$\sigma_z=\frac{RT}{v}-\frac{4}{3}\mu\frac{\partial w}{\partial z}\tag{2}$$ where w is the axial component of gas velocity (which varies with spatial location within the gas) and ##\mu## is the gas viscosity. As a result of Eqn. 2, the local normal compressive stress varies not only with the gas volume but also with the rate of change of gas volume. If we average the local compressive stress variations over the piston face, we obtain $$\bar{\sigma_z}=\frac{\int{\sigma_z dA}}{A}$$
This average normal compressive stress is what we usually more loosely refer to as the "internal pressure" of the gas in a reversible or irreversible compression or expansion: $$P_{int}=\bar{\sigma_z}=\frac{\int{\sigma_z dA}}{A}$$Note that, for the irreversible case, this internal pressure includes the effects of viscous stresses.

vanhees71 and burian
Are we talking about a piston that has mass? Also, we need to be careful specifying exactly what we consider our system, and the boundary at which our system ends and the surroundings begin? Where are these in your thinking? Is your system the gas, or is it the gas plus the piston?
In my mind I had a massless piston but knowing what happens in each case would be good as well.

The boundary is the region of space the gas encloses, i.e: the interior of piston + inner face of piston, the envrionment is whole space excluding the mentioned region.

That is not really true. You have to consider Newton's first law, ##\sum F = ma##. So converting the pressure to force acting on the piston of mass ##m## and area ##A##, you get:
$$P_{int}A - P_{ext}A = ma$$
So if you know that ##P_{int} \neq P_{ext}## then ##a \neq 0##. This means the boudary (i.e. the piston) will accelerate as long as ##P_{int} \neq P_{ext}##.

Imagine a closed cylinder with a piston mechanically held in position in the middle. There is a gas under different pressure on either side. Release the lock of the piston. What happens?
Hmm but if they are not equal then how is work done on gas by environment = work done on environment by gas in magnitude?

Mentor
In my mind I had a massless piston but knowing what happens in each case would be good as well.

The boundary is the region of space the gas encloses, i.e: the interior of piston + inner face of piston, the envrionment is whole space excluding the mentioned region.
The boundary has to be a surface. So pick one: inside face of piston or outside face?

The boundary has to be a surface. So pick one: inside face of piston or outside face?
mm yes, I think a cylindrical piston with a disc on top, take the cylinders boundary and the inside face of the disc (the gluing face)

Mentor
mm yes, I think a cylindrical piston with a disc on top, take the cylinders boundary and the inside face of the disc (the gluing face)
I don't understand. Are you selecting the gas as your system and the inside face of the piston to be its interface with the surroundings? Or, are you splitting the piston into two parts, and taking the boundary of your system as the interface between the two parts?

Last edited:
Mentor
I'm going to continue what I was discussing in post #7 for an irreversible deformation of the gas. If ##\bar{\sigma_z}=P_{int}## is the average force per unit area exerted by the gas on the inside face of the piston, and we choose the gas alone as our system, then, calling the average external force per unit area exerted by the piston on the gas ##P_{ext}##, we must have that $$P_{ext}=P_{int}=\bar{\sigma_z}$$
Let's next consider the situation where we are dealing with a piston that has mass M. Let ##P_0(t)## represent the force per unit area applied by some outside medium to the outside face of the piston at time t during the irreversible expansion of compression. If we do a force balance on the piston during the irreversible process, we obtain: $$P_{int}(t)A-P_0(t)A=m\frac{du}{dt}$$or $$P_{int}A=P_{ext}A=\bar{\sigma_z}A=P_0(t)A+m\frac{du}{dt}$$where u is the piston velocity. What do you obtain if you multiply this equation by the piston velocity ##u=dz/dt## (where z is the displacement of the piston from time zero to time t), and integrate between time t = 0 and arbitrary time t?

sophiecentaur
Gold Member
Please help me to distinguish between this perceived paradox (?) of forces on the piston and the forces / work involved in stretching a spring. Newton 3 always applies but it doesn't preclude acceleration. The work done in both cases has to be calculated quasi-statically (assuming start and finish situations are static) and assumes equilibrium at each end. If the masses are accelerating then kinetic energy (of the piston and also the gas) has to be brought in.
What else is relevant here?

burian
anuttarasammyak
Gold Member
Please help me to distinguish between this perceived paradox (?) of forces on the piston and the forces / work involved in stretching a spring. Newton 3 always applies but it doesn't preclude acceleration. The work done in both cases has to be calculated quasi-statically (assuming start and finish situations are static) and assumes equilibrium at each end. If the masses are accelerating then kinetic energy (of the piston and also the gas) has to be brought in.
What else is relevant here?
Ref. My previous post on heating inner gas, inner pressure surpass out pressure slightly , ideally infinitesimal, and gas pushes piston out and inner pressure decrease . Piston with kinetic energy and change of gas pressure with its position, vibrates around the equilibrium.

Then keeping heating the gas, inner pressure rise again and do the same procedure again. When gas push the piston if piston is coming in, its kinetic energy decrease. If the piston is going out, kinetic energy increases. We will not observe synchronization of piston motion and gas pushing. We may be able to expect motion of piston after finite change of volume remains small, ideally infinitesimal one, to be disregarded.

Mentor
Please help me to distinguish between this perceived paradox (?) of forces on the piston and the forces / work involved in stretching a spring. Newton 3 always applies but it doesn't preclude acceleration. The work done in both cases has to be calculated quasi-statically (assuming start and finish situations are static) and assumes equilibrium at each end. If the masses are accelerating then kinetic energy (of the piston and also the gas) has to be brought in.
What else is relevant here?
What do you think the kinetic energy of the piston is in the final state when the system has equilibrated?

sophiecentaur
Gold Member
We will not observe synchronization of piston motion and gas pushing.
The speed at which the effect of applied pressure transmits through the gas is basically the speed of sound in the gas. There will be a delay as with any force deforming anything.
What do you think the kinetic energy of the piston is in the final state when the system has equilibrated?
It has to be zero. But then no work is being done; it's all over folks. On the way to the new situation, there has to have been some acceleration and some motion; non-equilibrium.

I am frequently seeing people having problems when they feel it's necessary to distinguish Work Done On and Work Done By. Force times distance is just Work Done. The piston does work on the gas when it's compressing because the gas gets the energy - and vice versa. The sign of the work takes care of the On and By.

Also, we are seeing, here, the idea that N3 implies equilibrium and of course, that leads to no resulting motion. The fact that a gas is involved makes it seem more complicated than it really is. A spring with mass would do for the purpose and it's probably easier to understand.

Mentor
The speed at which the effect of applied pressure transmits through the gas is basically the speed of sound in the gas. There will be a delay as with any force deforming anything.

It has to be zero. But then no work is being done;
This is not correct. The piston in the final state will have been displaced to a new equilibrium position, and work will have been done. If you follow the continuation of the development that I started in post #13 (in progress), you will see how this plays out.
A spring with mass would do for the purpose and it's probably easier to understand.
In an irreversible compression or expansion, the gas behaves more like a spring and damper in parallel than just a spring. The damper accounts for the viscous dissipative behavior of the gas, which, for a frictonless piston, is the mechanism responsible for the damping of the piston motion.

vanhees71
I'm going to continue what I was discussing in post #7 for an irreversible deformation of the gas. If ##\bar{\sigma_z}=P_{int}## is the average force per unit area exerted by the gas on the inside face of the piston, and we choose the gas alone as our system, then, calling the average external force per unit area exerted by the piston on the gas ##P_{ext}##, we must have that $$P_{ext}=P_{int}=\bar{\sigma_z}$$
Let's next consider the situation where we are dealing with a piston that has mass M. Let ##P_0(t)## represent the force per unit area applied by some outside medium to the outside face of the piston at time t during the irreversible expansion of compression. If we do a force balance on the piston during the irreversible process, we obtain: $$P_{int}(t)A-P_0(t)A=m\frac{du}{dt}$$or $$P_{int}A=P_{ext}A=\bar{\sigma_z}A=P_0(t)A+m\frac{du}{dt}$$where u is the piston velocity. What do you obtain if you multiply this equation by the piston velocity ##u=dz/dt## (where z is the displacement of the piston from time zero to time t), and integrate between time t = 0 and arbitrary time t?
I had seen this yesterday and didn't pick up on what you meant but I get it now, if you do that you get the energy conservation equation.

vanhees71
I don't understand. Are you selecting the gas as your system and the inside face of the piston to be its interface with the surroundings? Or, are you splitting the piston into two parts, and taking the boundary of your system as the interface between the two parts?
The second way it is not fully clear to me, could you rephrase it?

The speed at which the effect of applied pressure transmits through the gas is basically the speed of sound in the gas. There will be a delay as with any force deforming anything.

It has to be zero. But then no work is being done; it's all over folks. On the way to the new situation, there has to have been some acceleration and some motion; non-equilibrium.

I am frequently seeing people having problems when they feel it's necessary to distinguish Work Done On and Work Done By. Force times distance is just Work Done. The piston does work on the gas when it's compressing because the gas gets the energy - and vice versa. The sign of the work takes care of the On and By.

Also, we are seeing, here, the idea that N3 implies equilibrium and of course, that leads to no resulting motion. The fact that a gas is involved makes it seem more complicated than it really is. A spring with mass would do for the purpose and it's probably easier to understand.

How did you conclude that speed of pressure transmission is same as speed of gas?

Mentor
I had seen this yesterday and didn't pick up on what you meant but I get it now, if you do that you get the energy conservation equation.
That is correct. What we obtain is: $$W_g(t)=\int_{V_i}^{V(t)}{P_{int}dV}=\int_{V_i}^{V(t)}{P_0dV}+\frac{1}{2}mu(t)^2$$where ##W_g(t)## is the work done by the gas (on the piston) during the irreversible process up to time t, ##V_i## is the initial gas volume, ##V(t)## is the gas volume at time t, and u(t) is the piston velocity at time t. If, at long times, the external medium pressure ##P_0## is constant and the system equilibrates at infinite time ##t\rightarrow \infty##, what do you think happens to the velocity u of the piston?

vanhees71
That is correct. What we obtain is: $$W_g(t)=\int_{V_i}^{V(t)}{P_{int}dV}=\int_{V_i}^{V(t)}{P_0dV}+\frac{1}{2}mu(t)^2$$where ##W_g(t)## is the work done by the gas (on the piston) during the irreversible process up to time t, ##V_i## is the initial gas volume, ##V(t)## is the gas volume at time t, and u(t) is the piston velocity at time t. If, at long times, the external medium pressure ##P_0## is constant and the system equilibrates at infinite time ##t\rightarrow \infty##, what do you think happens to the velocity u of the piston?
Wow how on earth did you get such a depth understanding of thermodynamics?

It looks to me as you take time to infinity, the velocity term dies off.. so even if it is immediately not that the work done on environment by gas = work done on gas by environment, it is true in infinite time in both reversible and irreversible cases.

vanhees71
Gold Member
2021 Award
I think the main problem one has with pressure as a student, it's usually taught in a not so clear way. For me the "click in understanding" came, when I first read books about hydrodynamics, where pressure is introduced as what it really is in the logical theoretical description, namely part of the stress tensor of a fluid.

The idea is that you consider the fluid in some volume. To write down the equation of motion you have to take the (material) time derivative of the momentum of the fluid in this volume and equate it with the total force acting on this volume of fluid, and this consists of two parts: the "volume force", i.e., the forces acting on each fluid element within the volume (e.g., the gravitational force from the Earth) and forces due to adjacent fluid along the boundary of the volume, and this is described with help of the stress tensor.

In a perfect fluid in the (local) rest frame of a fluid element the stress tensor is isotropic, i.e., it's given by a scalar ##P## with ##\sigma_{ij}=-P \delta_{ij}## (the sign is a convention). Now it's easy to derive the equation of motion on a small volume ##\mathrm{d}^3 r## of the fluid. The left-hand side "##m \vec{a}##" is
$$\mathrm{d}^3 r \rho \mathrm{D}_t \vec{v}=\mathrm{d}^3 r \rho (\partial_t \vec{v} + \vec{v} \cdot \vec{\nabla} \vec{v}.$$
On the right hand side you have the volume force
$$\vec{F}_{\text{vol}}=\mathrm{d}^3 r \vec{f}.$$
For the (homogeneous) gravitational force of the Earth
$$\vec{f}=\rho \vec{g},$$
where ##\vec{g}## is the gravitational acceleration.

Finally there's a force due to the stress from adjacent fluid on the surface of the volume under consideration. We have to bring this also in the form of a volume force. The trick is Gauss's theorem:
$$F_{\text{boundary},k}=\int_{\partial \Delta V} \mathrm{d}^2 f_j \sigma_{kj}=-\int_{\partial \Delta V} \mathrm{d}^2 f_k P=-\int_{\Delta V} \mathrm{d}^3 r \partial_k P \simeq \mathrm{d}^3 r (-\partial_k P).$$
This means at the end we have the Euler equation of motion
$$\rho (\partial_t \vec{v}+\vec{v} \cdot \vec{\nabla} \vec{v})=\rho \vec{g}-\vec{\nabla} P.$$

Mentor
Wow how on earth did you get such a depth understanding of thermodynamics?
Well, like you, I spent a lot of time thinking about it. And I had the benefit of years of practical modeling experience.
It looks to me as you take time to infinity, the velocity term dies off.. so even if it is immediately not that the work done on environment by gas = work done on gas by environment, it is true in infinite time in both reversible and irreversible cases.
It depends on what you mean by the environment. If, by the environment, you mean the inside face of the piston (which is what the gas actually does work on), then the work done by the gas on the environment is equal in magnitude to the work done by the environment on the gas at all times. In any event, at infinite time, we have$$W_g(\infty)=\int_{V_i}^{V(\infty)}{P_{int}dV}=\int_{V_i}^{V(\infty)}{P_0dV}$$

cianfa72 and sophiecentaur