In a magnetic fusion reactor, heat and fusion ash are extracted in a ``divertor.'' Here the plasma is neutralized (either on a material surface or by a gas blanket). The design of a divertor requires understanding the interaction of plasmas with neutral atoms and molecules. Typically the transport of neutrals is modeled by Monte Carlo, because
We (Daren Stotler and Charles Karney) have written a Monte Carlo code, degas2 (https://w3.pppl.gov/degas2), to model the neutral transport. Amongst the design goals were:
The parallelism is realized by regarding the calculation of each Monte Carlo flight as independent and assigning them to processes in an arbitrary manner (in practice this is done so as to achieve load balance).
For this reason we associate each flight with an independent sequence of random numbers
|
Choose the subtractive generator (Knuth, Vol 2)
|
The second property holds when X is of the form
|
This allows the basic random number sequence to be generated by the Fortran code
x(n) = x(n-k) - x(n-j) if (x(n) < 0.0) x(n) = 1.0 + x(n)In practice random numbers are generated in batches as needed and stored in an array which acts as a circular buffer.
These sequences need to be initialized with k numbers. We use a conventional linear congruential random number generator for this purpose:
|
Given a1 and c1, it is easy to generate an and cn which step the linear congruential sequence forward n steps
|
In practice, we pre-calculate a63 and c63 which are needed to step to the seed for flight f+1 given the seed for flight f. Given Y0, a63, and c63, we can also calculate Y63f in O(log(f)) steps by decomposing q in binary.
The random numbers for a Monte Carlo now requires the specification of a 56-bit random seed (17 decimal digit) for the linear congruential sequence. This is represented internally by 4 14-digit integers and this needs to be communicated to each process.
For flight f, the linear congruential sequence is marched forward 63f steps in O(log(f)) operations. The subtractive generator is initialized with the next 63 members of the sequence which are calculated in O(63)) operations. All this is relatively slow multiple-precision integer arithmetic. But there isn't much of it.
Finally, individual random numbers for flight f can be calculated using the subtractive generator which takes only 1-2 floating point additions per random number.