espressomd-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ESPResSo] [t_random]


From: Axel Arnold
Subject: Re: [ESPResSo] [t_random]
Date: Wed, 14 Jul 2010 11:08:07 +0200
User-agent: KMail/1.10.3 (Linux/2.6.27.45-0.1-default; KDE/4.1.3; x86_64; ; )

On Tuesday 13 July 2010 21:22:50 Owen Hickey wrote:
> You need to sed the random number generator as while the numbers appear to
> be random they are in fact deterministic so for one processor:
> t_random seed [expr abs([clock clicks]%100000)]

Another good choice is

t_random seed [pid]

which has the advantage, that if you for example batch-submit your jobs and 4 
start at the same time, with modern systems the chance are actually quite good 
that several start in the same second, which means you  get again the same 
seed. The process id pid however is always different.

Finally, the tcl built-in RNG is always initialized from some "true" random 
source, so that also works:

t_random seed [expr int(rand(()*32768)]

>
> or for 128 processors:
> set Seeds [list {}]
> set _ran [pid]
> for {set i 0} {$i<128} {incr i} {
>   lappend Seeds {0}
> }
> for {set i 0} {$i<128} {incr i} {
>   set _ran [expr ($_ran * 9301 + 49297) % 233280]
>   set seed [expr int(1000000000 * ($_ran / double(233280)))]
>   lset Seeds $i $seed
> }
>
> puts $Seeds

> t_random seed [lindex $Seeds 0] [lindex $Seeds 1] [lindex $Seeds 2] [lindex
....
> [lindex $Seeds 125] [lindex $Seeds 126] [lindex $Seeds 127]

That can be done much easier:

set seed [pid]
for {set i 0} {$i< [setmd n_nodes]} {incr i} {
        lappend Seeds [expr $seed + $i]
}
eval t_random seed $Seeds

This has the advantage that it works for any number of CPUs, and using a 
simple linear sequence for the seeds works as good as using a pseudo-random 
series.

Finally, you should always save the seed somewhere. In case something really 
unusual happens in your simulation that you want to investigate further, you 
need exactly the same seed again to reproduce the simulation.

Cheers,
Axel
-- 
JP Dr. Axel Arnold Tel: +49 711 685 67609
ICP, Universität Stuttgart      Email: address@hidden
Pfaffenwaldring 27
70569 Stuttgart, Germany




reply via email to

[Prev in Thread] Current Thread [Next in Thread]