NTNUJAVA Virtual Physics LaboratoryEnjoy the fun of physics with simulations! Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
June 06, 2020, 07:24:00 pm

Wisdom consists of the anticipation of consequences. ..."Norman Cousins(1913-1990, American author)"

 Pages: 1 [2]   Go Down
 Author Topic: Molecular Model for an Ideal Gas  (Read 477911 times) 0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #30 on: April 07, 2009, 10:12:38 am » posted from:Taipei,T\'ai-pei,Taiwan

I am not familiar with MathLab, but I believe it can be done.
You need to define your model (variables/relations/constraints) and write the code to deal with it.
If you are familiar with MathLab, you should be able to learn EJS very quickly!
You can check out SWF movie show step by step instructions to create java simulation with EJS to know what EJS can help you.
 Logged
CharlieD
Newbie

Offline

Posts: 6

 « Embed this message Reply #31 on: May 21, 2009, 08:43:38 pm » posted from:London,London, City of,United Kingdom

Hi Fu-Kwun Hwang,

I really like your application but would be interested in something similar but different.  I am interested in the mixing potentials of different gasses under ambient pressure.  I'd really like a application that simulates the behaviour of three different gasses in a fixed volume over time.

lets say three hypothetical gasses: Gas A, Gas B and Gas C.  Effectively running your application in three different colours in the same volume.

Inputs

The size and shape of the container (2 dimensions is fine),
The mass of the gas molecules, A B and C  (and or the gravitational effect buoyancy)
The quantity of the individual gasses
The over all energy of all the particles, i.e. temperature

I'd like to be able to monitor the system with respect to time from a random orientation

Particle particle interactions can for now be avoided to make the programming easier...

Is this the sort of thing that you could do?

Many thanks

Charlie.
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #32 on: May 21, 2009, 10:07:29 pm » posted from:Taipei,T\'ai-pei,Taiwan

1. The size and shape of the container:
I can add size as an input, but what do you mean by the shape of the container? Do you mean Square, Circle,... or just different width and height for rectangular shape?
2. The mass of the gas molecules, A B and C  (and or the gravitational effect buoyancy)
This can be done easily.

3. The quantity of the individual gasses:
What is the range of for the number of particles? Remember collision need to be checked at least n*(n-1)/2 times.

4. The over all energy of all the particles, i.e. temperature
Do you mean the average energy for all the particles?

Please provide possible range for all the physics properties, it will save me a lot of time and the result will be better fit with what you really want.
 Logged
CharlieD
Newbie

Offline

Posts: 6

 « Embed this message Reply #33 on: May 22, 2009, 05:24:40 pm » posted from:London,London, City of,United Kingdom

Hi Fu-Kwun Hwang,

Size and shape.  rectangular is good.  would want to see the difference between a square container verses a tall thin rectangular one..

The number of particles would depend on the size and pressure.  Could you maybe set Gas A as the basis that fills the remaining volume, and then allow for Gas B and C to be filled up to the whole volume as well.  i.e. if the volume can hold 1000 molecules and you specify that Gas B has 100 molecules and Gas C has 200 then Gas A would be set to 700. ranges would then be 0-1000 for each B and C with A set automatically.  Would be good to have as big a volume as is possible though I understand that the bigger the more complex the calculations.  What sort of size would be reasonable?  is 10 litres of space too much? 20L?

Temperature is the average temperature / energy of the molecules.

Would be good to be able to speed up the simulation of the time so a time factor could be written in to i.e. 1s = 1h in simulation time etc.

Physical properties:
Gasses will be molecular mass 2-50.
temp 200 K to 400K
simulation time 0 s to few days.
Three different colours for the different gasses, say Red, Blue, Yellow

Size would be rectangular from tall thin to wide flat as big as is reasonable, set by the volume.  I'll run it direct off a PC so much more RAM for the calculations than off a website

Hope this helps.

Charlie.
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #34 on: May 23, 2009, 11:21:13 am » posted from:Taipei,T\'ai-pei,Taiwan

I modified browian motion simulation to fit most of your request.
The following is 1000 particles randomly distributed (position, velocity and direction).
Number of three different particles are NA, NB and NC, there mass are ma,mb,mc
The temperature T define the average velocity: Vavg proportional to sqrt(T/m)

The dimension of volume (e.g. 10 liters) is meanless if you mean to simulate a real volume.
Because there are almost 1019 particles in 1 cm3.
Unless the colume is just used to calculate the pressure.

For the same reason, change the width/height of the container will not be able to represent real case.

There are limitation for the simulation: for example: in real world, most of the gas molecular moving with speed faster than speed of sound. And there are more than 1019 particles in 1 cm3. if you want to visualize it. The particle can not move too fast on the screen.

The simulation has to be design in a proper way to show the effect. And for different purpose, it need to be designed differently.

Please write down the real problem you are studying and what kind of phenomena you are interested.
May be we can find out a better way to simulate it.
It might not be necessary to calculate the collision between particles, unless you want to study the energy transfer between particles.
It will be better if you can write down the physics model of the system.

The following is the simulation I have created for you!

Embed a running copy of this simulation

Embed a running copy link(show simulation in a popuped window)
Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
• Please feel free to post your ideas about how to use the simulation for better teaching and learning.
• Post questions to be asked to help students to think, to explore.
• Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!
 *** There are 2 more attached files. You need to login to acces it! Logged
CharlieD
Newbie

Offline

Posts: 6

 « Embed this message Reply #35 on: May 26, 2009, 04:15:15 pm » posted from:London,London, City of,United Kingdom

Hia,

Simulation is fantastic.

I'm trying to visualise how different gasses will separate out in different closed containers. e.g. if you had a container of air with some helium and some Argon, mass 29, 4, and 40 respectively, then the helium would settle out at the top of the container, air in the middle and argon at the bottom. I'm interested in how long this process would take is it minutes hours, days or weeks.

Is there a buoyancy effect on the force on each particle or is the mass only used to calculate the elastic collisions with other particles?

Each particle will have a downward force of 9.8 x real Mass. (Real mass = Mass x 1.66054 x 10E-27 Kg)  the heavier molecules will therefore have a larger force pushing them down and will effectively settle out at the bottom first. (sorry if this is so obvious that it is already in the equations)

I think maybe the scale is so small that the particles are not given the space to settle and the proximity of the walls mean that the elastic collisions far out weigh the buoyancy differences of the gas molecules.  If we were to define each dot as a unit volume of gas, say 1000 molecules, then the model would be considerably bigger and the distance between the walls would be significantly longer reducing the effect of the elastic collisions while the downward force would be considerably higher.  in real terms 1000 molecules is a fraction of a fraction of a cm3 so easily justifiable as a modelling constraint.

Can you have a button to turn off the particle particle interactions? and see if they settle better with only particle-wall interactions.

Cheers

C.
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #36 on: May 26, 2009, 06:25:10 pm » posted from:Taipei,T'ai-pei,Taiwan

Now, I understand more what you want for the simulation.
There is no gravity in the previous version.
I just added gravity (can be changed with slider) and also draw Yaverage for three different particles.
The difference between those three curves (Yaverage)are due to statistical error (because number of particles are not big enough).

1. Gravity g can be changed with slider.
2. Collision between particles can be turn off with check box.
3. The top boundary can be turn on/off.

The separation process will be faster if you un-check closetop check box.
The above simulation has been updated with new version.
 Logged
CharlieD
Newbie

Offline

Posts: 6

 « Embed this message Reply #37 on: May 28, 2009, 06:05:07 pm » posted from:London,London, City of,United Kingdom

Hia.  This is fantastic and beginning to look like I had envisaged..

Can I suggest a couple more alterations?

1) the particles now really clump at the bottom of the container with largely vacuum at the top.  could we maybe change the gravity effect into a relative vertical component vector.  By this I mean Ma =29 therefore relative to it's self it has a vertical force of 29/29 upwards and 29/29 downwards. Gas B has a upwards force of Ma/Mb and downwards force of Mb/Ma  and Gas C has a upwards force of Ma/Mc and downwards Mc/Ma.  This way lighter gasses will rise while Heavier gasses will fall. The space will be more uniformly filled without all the gas accumulating at the bottom..

The alternative is to incorporate some force of attraction towards the empty space that is higher for the smaller less dense molecules than it is for the heavier more dense molecules.. (this I think is quite a challenge..)

2) could you extend the temperature range to cover much lower temperatures.  This will slow the particles down and might help to lower the significance of the P-P interactions while not affecting the gravitational forces.

Cheers

C
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #38 on: May 29, 2009, 10:08:05 am » posted from:Taipei,T\'ai-pei,Taiwan

1. Simulation can be done with different model. What is important is how make sense of the simulation.
The gravity is the same (-g ) for all particles in the above simulation, because that what phyiscs tell me.

Quote
Ma =29 therefore relative to it's self it has a vertical force of 29/29 upwards and 29/29 downwards. Gas B has a upwards force of Ma/Mb and downwards force of Mb/Ma  and Gas C has a upwards force of Ma/Mc and downwards Mc/Ma.
I do not understand the physics meaning of your model:
1. What do you mean by upward force and downward force?
If particle A has the same upwards and downwards force, the net force is zero. Then, particle should move with constant velocity.
2. Why the download forces and upwards force are different for particle B/C?
3. Do you mean force or acceleration?

The temperature range can be change easily. However, the value of temperature slider (T) was used to calculate the initial average velocity for all the particles. It is not the real temperature when it reach equilibrium later on. In order to visualize the effect you want, the gravitation energy was set to a much larger value (compared to real gas under STP condition).

If you just want to have three different gas particles moving in different layer, it can be generated, too! However, it is far from real!

Do you really want to simulate some physical model you have?
Or you just want to have some visualized effect?
Are you using it for teaching purpose? What is the purpose to have such simulation?

For real gas:
The separation between gas particles are much larger than the size of the particles.
And there are 1019 particles in 1 cm3.

A good model need to be designed properly to simulate real gas.
 Logged
CharlieD
Newbie

Offline

Posts: 6

 « Embed this message Reply #39 on: May 29, 2009, 07:06:15 pm » posted from:London,London, City of,United Kingdom

Hia, I'm after a good combination of visual effect and real science.  I think i know what will happen in reality and I'm trying to form a model that will show what happens with a set of principles and constraints that can be argued from  scientific first principles.  The effect of gravity will not be the same on all particles as the force downwards will depend on the mass. the acceleration downwards might be uniform but there is also the buoyancy effect from the displacement of the other atoms as one falls due to gravity. The lighter gasses will rise to the top and the heavier gasses will sink to the bottom, relative to the mass of the main constituent of the volume. Setting the gravitational effect on gas A as uniformly up and down (i.e. no effect) was in my mind a way of simplifying the process to make the model appear more like the real situation.  This should stop the appearance of a vacuum at the top and a dense cloud of gas at the bottom.  The relative effects would be multiplied by the gravitational acceleration.

In effect the particle A should have no relative gravitational effect, B should have a positive effect in the upwards direction and C should have a positive effect in the down wards direction.

A balloon of helium has the potential to lift the amount of weight that is equal to the difference in mass of the volume of Helium and the mass of air that is displaced. There is therefore an upward force provided by each molecule that is equal to it's buoyancy or mass difference  times the gravitational constant.

To explain this better 24 litres of helium would displace 24 litres of Air  so the mass of the 24 litres would be 4gramms rather than 29gramms. There is therefore the potential to lift 25 grams  so the overall force upwards is 0.025 x 9.8 N. mathematically this equates to  (Mb-Ma/1000)*9.8 (negative = upwards, positive = downwards)

In the case of an individual molecule it would be (Mb-Ma)x1.66054 x 10E-27 X 9.8 N. again this would be negative for upwards and positive for downwards.

We can easily expand the area so that there is more space between the molecules if that helps the reality of the gas.

In a big enough system the gasses should separate out completely given enough time with only a small overlap  in the "mixing region".

If I can get it to give the results I need with a reasonable level of scientifically sound assumptions then I'd like to use it in a lecture and a scientific paper.  (Naturally you will be acknowledged.)

Sorry if it seems a bit confused above.

C
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #40 on: May 30, 2009, 11:29:42 pm » posted from:Taipei,T\'ai-pei,Taiwan

Here is another simulation with more options.
ga,gb,gc to adjust gravity for different particles.
gscale: adjust over all gravity scale
vscale: adjust over all velocity (to change ratio between relative thermal energy and gravitation energy )
diameter: to change the collision rate.

I can not find the right parameters to show what you would like to see.
May be some other factors need to be considered.

It seems that you are trying to using particle model to simulate fluid behavior.
I think we need to find a better model to simulate what you want!

I will be busy for a few days.

Embed a running copy of this simulation

Embed a running copy link(show simulation in a popuped window)
Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
• Please feel free to post your ideas about how to use the simulation for better teaching and learning.
• Post questions to be asked to help students to think, to explore.
• Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!
 Logged
CharlieD
Newbie

Offline

Posts: 6

 « Embed this message Reply #41 on: June 04, 2009, 08:40:36 pm » posted from:London,London, City of,United Kingdom

Many thanks, that is fantastic.  I can now show what I am after i just need to justify it from a physics perspective so that it is meaningful...

Will have a play and then be back in touch if i can think of any other tweeks.

Cheers again.
 Logged
mirlinda
Newbie

Offline

Posts: 3

 « Embed this message Reply #42 on: September 11, 2009, 04:08:09 pm » posted from:Tetovo,Tetovo,Macedonia

Dear author,

I would like to say that this is a wonderful simulation! My high-school students liked it very much.

Could you sent the source code by email: m.ebibi@seeu.edu.mk.

I woud like to make some changes.

I am so thankfull to you.

Regards
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #43 on: September 11, 2009, 11:48:32 pm » posted from:Taipei,T\'ai-pei,Taiwan

The above simulation is created with EJS. Please
2. Click c:\Ejs4.2\EjsConsole.jar to test the installation (Your computer need to support java :assume java run time has been installed)
5. RIght click in the simulation and select "open EJS model" to open source code in EJS.
6. You can modify variables/ relations/GUI element and properties in the simulation and click run button to compile it.

If you need the source code for the simulation at the first post, just download idealGas.java
However, it was written more than 10 years ago with JDK1.0.2.
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #44 on: December 29, 2010, 07:50:37 am » posted from:Taipei,T'ai-pei,Taiwan

Code:
I receive question related to this simulation as private message.
[quote]
Good morning, professor.

I have been using a model like this for my students.

My students learn that the "starting point" is 300 K, 100 kPa, 1.00 L, and approximately 0.040 moles of gas. If we use air, we find that the "average velocity" is something like 450 m/s, not 100 m/s. why is there a discrepancy between this simulation and the value that I've calculated?

I assume you are talking about smulation at Molecular Model for an Ideal Gas

The velocity of ideal gas depends on temperature and mass of the particle.
The average velocity for hydrogen atom will be much larger than average velocity for oxygen atom.
I did not specify temperature and mass of the particle in the simulation.
The simulation was designed to show relation between number of particle N, pressure P and Volume V.
You can ask student what is the initial temoerature if the simulation is for air.
The temperature of the simulation is related to velocity.
How to change the velocity so that it is can be used to simulate air at room temperature.

I just pick up simple number: N=200 P-50 V=100 without specify any unit for the above parameter.
In reality, there is more than 1019 particle in 1 cm3.
There is no way to add so many particle in the simulation.
The pressure is proportion to the number of objects on top of the movable piston.
 Logged
lookang
Hero Member

Offline

Posts: 1796

http://weelookang.blogspot.com

 « Embed this message Reply #45 on: December 29, 2010, 08:26:25 am » posted from:Singapore,,Singapore

http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1455.0
This simulation is remixed to address the real life values.
I introduce some constants to make the simulation reflect real numbers.

Maybe can introduce this simulation
 Logged
ahmedelshfie
Ahmed
Hero Member

Offline

Posts: 954

 « Embed this message Reply #46 on: February 08, 2011, 05:50:11 pm » posted from:SAO PAULO,SAO PAULO,BRAZIL

Here is Molecular Model by paul Falstad.

 gas.jpg (90.43 KB, 808x709 - viewed 1334 times.) « Last Edit: February 08, 2011, 05:52:22 pm by ahmedelshfie » Logged
surya316
Newbie

Offline

Posts: 1

Dear Professor ,
Can you please email  me  the 2nd collision simulation source code where you kept the volume constant. I tried downloading the files directly but it tells me that the files are corrupted. Do help me out
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #48 on: March 17, 2011, 02:08:38 pm » posted from:Taipei,T'ai-pei,Taiwan

Please provide the message where you found the simulation.
I do not know which one you need.
 Logged
naive
Newbie

Offline

Posts: 3

 « Embed this message Reply #49 on: March 01, 2012, 08:04:26 am » posted from:,,Satellite Provider

Hi Fu-Kwun Hwang,
Bernoulli's equation (ignoring gravity) can be illustrated with a straight tube connected to a tapering tube connected to another straight tube, with pistons in the straight tubes.
question 1: can this be simulated with an ideal gas between the pistons?
question 2: is Bernoulli's equation  true for an ideal gas?
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #50 on: March 01, 2012, 08:43:24 pm » posted from:LONDON,ENGLAND,UNITED KINGDOM

Bernoulli's equation :
Do you mean : $P+\tfrac{1}{2}\rho v^2+\rho g h=$constant

Quote
question 1: can this be simulated with an ideal gas between the pistons?
Could you describe your model in more detail? I can not catch your ideas.

Quote
question 2: is Bernoulli's equation  true for an ideal gas?

The Bernoulli's principle is valid for incompressible flows (e.g. most liquid flows) and also for compressible flows (e.g. gases) moving at low Mach numbers
 Logged
naive
Newbie

Offline

Posts: 3

 « Embed this message Reply #51 on: March 03, 2012, 05:32:32 am » posted from:-,-,UNITED STATES

hi!
you have the equation. let's ignore the third (gravitational) term.

i hope this diagram clarifies ( " * " outlines a 3-section tube, " + " outlines the pistons.):
Code:
* * * * * * * * *
+ *
+ *
+ * * * * * * * * * * * * *
+ +
+ gas enclosed +
+ +
+ * * * * * * * * * * * * *
+ *
+ *
* * * * * * * * *
basically, we're changing the shape of an ideal gas, keeping the volume the same. but we're looking at the process while it is happening, not a "before" and "after" situation.
it's not clear that we can ignore the temperature.
nor is it clear that the pressure on one piston is the same as the pressure on the wall of its corresponding straight tube section.
nor is it clear that the density in the straight tube sections is the same.

i thought a simulation might help see what's happening. i have no idea if anyone has done this.

thanks again.

 Logged
naive
Newbie

Offline

Posts: 3

 « Embed this message Reply #52 on: March 03, 2012, 05:39:17 am » posted from:-,-,UNITED STATES

sorry!

my diagram got screwed up in the posting. spaces got deleted. i don't know how to correct this.
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #53 on: March 03, 2012, 06:21:25 am »

You can add text in between [code] and [/code]  to keep space in the text. (I have already modified your text for you. :-)

Bernoulli's equation is valid for steady fluid which can be represented by stream lines.

It is a different situation you have pistons on both side of the tube: this is a closed system.

We can use fluid model to simulate gas flow when the mean free path is much smaller than the size of the tube. (fluid dynamics)

The molecular model can be used when the mean free path is smaller than the size of the tube, and this is a good time to use particles to simulate the situation.  (However, a lot of computational power is needed: to simulate large number of particles!)
 Logged
ptnk_triz
Newbie

Offline

Posts: 2

 « Embed this message Reply #54 on: July 12, 2012, 10:22:31 pm » posted from:Montreal,Quebec,Canada

Hello Prof Hwang,

Could you tell me the relation of the number of collision and pressure in your ideal gas model?

How can you calculate pressure exactly?
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #55 on: July 12, 2012, 10:37:40 pm » posted from:Tucheng,T'ai-wan,Taiwan

If you are talking about the simulation at the first post: then the umber of particles are 200 as default and can be changed from user input.
The pressure was calculated by momentum change per second.
Because there are limited number of particles so that the pressure change over time.
In real case, it will be more than $10^{19}$particles per center meter square.

 Logged
ptnk_triz
Newbie

Offline

Posts: 2

 « Embed this message Reply #56 on: July 12, 2012, 10:51:29 pm » posted from:Montreal,Quebec,Canada

The pressure is calculated by the momentum change per second. Can you tell me the equation?

The momentum is the average momentum of all the particles?

Do you think, could we find any relation betweens the number of collision of particles on the wall and the pressure?

I just know that : p = F / A

I dont know the relation of p and momentum, could you write down the relation.
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #57 on: July 12, 2012, 11:25:16 pm » posted from:Tucheng,T'ai-wan,Taiwan

From the simulation, I can calculate how many particle collide with the wall per second,
Wih velocity and mass, the momentum can be calculated.

$\vec{F}=\frac{d\vec{P}}{dt}=\frac{d (m\vec{V})}{dt}$

and Pressure $P=\frac{F}{A}$  normal component of the momentum need to be calculated to from the pressure.
 Logged
diinxcom
watchlist
Jr. Member

Offline

Posts: 25

Designer

 « Embed this message Reply #58 on: December 14, 2014, 06:00:31 pm » posted from:,,Satellite Provider

-*-