How to distribute molecules to states using C++

  • Context: C/C++ 
  • Thread starter Thread starter dilatoryyang
  • Start date Start date
  • Tags Tags
    C++ Molecules States
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
dilatoryyang
Messages
3
Reaction score
0
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.
 
Physics news on Phys.org
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.