Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to distribute molecules to states using C++

  1. May 3, 2009 #1
    I don't know how to distribute large amount of molecules(say a million) to many ro-vibrational states(say 100 states), according to the relative population of these states. As is very important when I want to simulate numerically the classical trajectory of these molecules in a spatially inhomogeneous electric field.
     
  2. jcsd
  3. May 3, 2009 #2

    alxm

    User Avatar
    Science Advisor

    Doesn't sound very hard. If you have the relative populations, e.g. say 50%, 25%, 15%, 10% (four states) then you could, for instance: Pick a random number between 0 and 1 (which is what most random functions return) if it's 0-.5 assign state 1, if it's 0.5-0.75 assign state 2, 0.75-0.90 assign state 3 and 0.9-1 assign state 4.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to distribute molecules to states using C++
Loading...