I have a volume with N molecules; I need to assign to each particle a velocity vector: |vi|=[vx,vy,vz]T
Answer
The Maxwell-Boltzmann distribution is a continuous probability distribution of particles as a function of either momentum, energy, or speed. Since you want the velocity vector, we start with that: pV(vx,vy,vz)=(m2πkT)3/2exp(−m2kTv2)
In order to sample from the distribution in (1), you need the cumulative distribution function, defined as (for the continuous case) FX(x)˙=∫x−∞pV(vx)dv
It is from this that you can draw your random velocities to match the distribution. Pick a random number in the range 0 to 1, set it as FX(x) and find the x such that the two sides of (1) are equal. There are a number of ways to do this, you'll have to find the one that works best for you.
No comments:
Post a Comment