customGBEnergyPerParticle.cc 895 Bytes
Newer Older
Peter Eastman's avatar
Peter Eastman committed
1
#define REDUCE_VALUE(NAME, TYPE) {\
2
3
4
    TYPE sum = NAME[index]; \
    for (int i = index+bufferSize; i < totalSize; i += bufferSize) \
        sum += NAME[i]; \
Peter Eastman's avatar
Peter Eastman committed
5
6
    NAME[index] = sum; \
}
7

8
9
10
11
/**
 * Reduce the derivatives computed in the N^2 energy kernel, and compute all per-particle energy terms.
 */

12
13
KERNEL void computePerParticleEnergy(GLOBAL mixed* RESTRICT energyBuffer, GLOBAL const real4* RESTRICT posq,
        GLOBAL mm_long* RESTRICT forceBuffers
14
        PARAMETER_ARGUMENTS) {
15
    mixed energy = 0;
16
    INIT_PARAM_DERIVS
17
    for (int index = GLOBAL_ID; index < NUM_ATOMS; index += GLOBAL_SIZE) {
18
19
        // Reduce the derivatives

20
        REDUCE_DERIVATIVES
21
22
23

        // Now calculate the per-particle energy terms.

24
        real4 pos = posq[index];
25
        real3 force = make_real3(0, 0, 0);
26
27
        COMPUTE_ENERGY
    }
28
    energyBuffer[GLOBAL_ID] += energy;
29
    SAVE_PARAM_DERIVS
30
}