About random number for particle dispersion

Post any questions or comments regarding the LINUX version of HYSPLIT. This includes the model execution, GUIs, results, or graphics. Be sure to mention the version of LINUX you are using.
Post Reply
HWZealot
Posts: 8
Joined: August 26th, 2017, 8:54 am
Registered HYSPLIT User: Yes

About random number for particle dispersion

Post by HWZealot »

Hi, everyone.
I'm looking through the code of concentration program.
I notice that there are two ways to generate the random number for particle dispersion:
1. If Krand=1, will use the pre-calculated random number array.
2. If Krand=2, will use the "parvar" subroutine inside the dispersion subroutine to generate the random number.
I find that if the user not specify the krand in the Namelist file, the program will use 2 when particle smaller than 5000, otherwise the first method.

I try both, finding that the result are very similar with a little different.

I just curious if both random number method's result are acceptable. Because I'm trying to parallelize the inner loop through the particles. And the first random number method (pre-calculated) is good for parallelization while the second one cannot preserve the same result as the original sequential program. So I try to only use the first random number method for my parallel version if that is acceptable.

Thank you.
ariel.stein
Posts: 660
Joined: November 7th, 2012, 3:14 pm
Registered HYSPLIT User: Yes

Re: About random number for particle dispersion

Post by ariel.stein »

The first method is acceptable too. However, it is less accurate than the second. Having precomputed random numbers is a good approximation but it is not a truly random distribution.
The code is already parallelized through the particles. Please check the conditional compilation statements in hymodelc.F
HWZealot
Posts: 8
Joined: August 26th, 2017, 8:54 am
Registered HYSPLIT User: Yes

Re: About random number for particle dispersion

Post by HWZealot »

Thank you!
I Checked the source code and saw how it is using MPI to parallelize the particle loop.
And I used -DMPI flag to compile the "hycm_std" to run the same example as "hycs_std".
However I found the result PostScript produced by "hycm_std" was not the same as the one produced by "hycs_std".
I guessed that it may due to the parallel random number generation is not the same as the sequential random number generation.

If there is nothing wrong with what I said above, I wonder if this small difference between MPI version and sequential version acceptable?

Thank you.

Here are two results:
The result from sequential version: hycs_std.
sequential version.PNG
The result with the same input data from MPI version: hycm_std:
MPI.PNG
ariel.stein
Posts: 660
Joined: November 7th, 2012, 3:14 pm
Registered HYSPLIT User: Yes

Re: About random number for particle dispersion

Post by ariel.stein »

You are right, the differences you are seeing are due to the different random numbers generated by the parallelized code. However, I can see that you are not using enough particles so your concentration fields are noisy. I would suggest increasing the number of particles you release and you will see that the differences get smaller.
HWZealot
Posts: 8
Joined: August 26th, 2017, 8:54 am
Registered HYSPLIT User: Yes

Re: About random number for particle dispersion

Post by HWZealot »

Thank you.
I tried to increase the numpar from 7500 to 30000. And the differences are much smaller:

The sequential version:
hycs_std_30000P.png
The MPI version:
MPI_30000p.png
So, I think that this differences now acceptable right?

Thank you.
ariel.stein
Posts: 660
Joined: November 7th, 2012, 3:14 pm
Registered HYSPLIT User: Yes

Re: About random number for particle dispersion

Post by ariel.stein »

Yes, they are acceptable.
If you increase your particle number even more you will reach a point in which you should not see any difference. No need to do that though.
Post Reply

Return to “HYSPLIT for LINUX”