How to simulate pressure in an ideal gas simulation

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 3K views
leibo
Messages
11
Reaction score
1
Hello

I wrote a simple simulation of an 2D ideal gas, with elastic collisions. I wonder how should I simulate the pressure that is implemented on the particles in the box, by a piston with certain weight. it's easy to adjust the area of the box and the temperature of the particles which is proportional to the velocity squared, but I don't know how to change the pressure directly.

Thanks!
 
Physics news on Phys.org
If the gas is ideal then you don't have the freedom to simultaneously control the temperature, pressure, volume and particle number- you may dictate three parameters, and the fourth will then be fixed according to the ideal gas equation: PV = nRT. In short, you can't arbitrarily change the pressure without losing control of one of the other variables.

Having said that, I'm intrigued about your simulation- surely if the gas particles are colliding elastically, then that breaks one of the ideal gas conditions: that the particles are non-interacting.
 
MikeyW said:
If the gas is ideal then you don't have the freedom to simultaneously control the temperature, pressure, volume and particle number- you may dictate three parameters, and the fourth will then be fixed according to the ideal gas equation: PV = nRT. In short, you can't arbitrarily change the pressure without losing control of one of the other variables.

Having said that, I'm intrigued about your simulation- surely if the gas particles are colliding elastically, then that breaks one of the ideal gas conditions: that the particles are non-interacting.

Yes, you are right, it's a simulation of very simple real gas, rather than an ideal gas. I understand I can not decide the values of all 4 variables n,p,V,T. Yet, I can suddenly change T, with constant n, and V,P would change correspondingly to the equation. In the same way I want to be able to change the pressure P.
 
How do you mean "suddenly change T"? Are you arbitrarily changing the average kinetic energy? As a result of this the temperature and pressure will both change (at constant volume). To control the pressure, you can change T and keep everything else constant.