Exercise 3: | Random plaquette |
Goals: | Generating random numbers in QDP |
Concepts: | Random state, Canned routines |
Directory: | $HOME/examples/03-random-plaquette |
How to: | $
cd
$HOME/examples/03-random-plaquette $ make $ submit plaquette |
Random numbers are very important for Lattice QCD codes. Very often it is important to be able to generate pseudo-random number reliably, e.g., independent on the size of the machine the program runs on. QDP provides such an facility. The random number generator is represented by a parallel variable of type QDP_RandomState. It is possible to use more than one generator at the same time. The QDP library knows how to produce the uniform and normal distributions out of the QDP_RandomState. The following functions are defined in <qdp.h>:
void QDP_R_eq_random_S(QDP_Real *, QDP_RandomState *, QDP_Subset);
|
To use a random number generator, first one creates a random state and sets a seed. This is done in file main.c, lines 22 and 24. The routine init_random() is defined in file random.c. We will not go into details how it works, it suffices to say that on each lattice site it converts the seed into an independent random stream.
11 QDP_RandomState *random_state;
|
In this example, instead of making all links equal to unity, we set them to random values. Since the library does not provide a random SU(3) matrices for us, we build them by hand in file random-link.c.
26 /* allocate the gauge field and make it random */ |