"plugins/drude/vscode:/vscode.git/clone" did not exist on "f05e6bbc0e1f555c552d09570f063f29b9c43f2f"
customNonbondedExceptions.cl 1.65 KB
Newer Older
1
2
3
4
/**
 * Compute custom nonbonded exceptions.
 */

5
__kernel void computeCustomNonbondedExceptions(int numAtoms, int numExceptions, __global float4* forceBuffers, __global float* energyBuffer,
6
        __global float4* posq, __global float4* params, __global int4* indices
7
        EXTRA_ARGUMENTS) {
8
9
10
11
12
13
14
15
16
    int index = get_global_id(0);
    float energy = 0.0f;
    while (index < numExceptions) {
        // Look up the data for this exception.

        int4 atoms = indices[index];
        float4 exceptionParams = params[index];
        float4 delta = posq[atoms.y]-posq[atoms.x];
#ifdef USE_PERIODIC
17
18
19
        delta.x -= floor(delta.x/PERIODIC_BOX_SIZE_X+0.5f)*PERIODIC_BOX_SIZE_X;
        delta.y -= floor(delta.y/PERIODIC_BOX_SIZE_Y+0.5f)*PERIODIC_BOX_SIZE_Y;
        delta.z -= floor(delta.z/PERIODIC_BOX_SIZE_Z+0.5f)*PERIODIC_BOX_SIZE_Z;
20
21
22
23
24
#endif
        // Compute the force.

        float r2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z;
#ifdef USE_CUTOFF
25
        if (r2 > CUTOFF_SQUARED) {
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#else
        {
#endif
            float r = sqrt(r2);
            float dEdR;
            COMPUTE_FORCE
            delta.xyz *= -dEdR/r;

            // Record the force on each of the two atoms.

            unsigned int offsetA = atoms.x+atoms.z*numAtoms;
            unsigned int offsetB = atoms.y+atoms.w*numAtoms;
            float4 forceA = forceBuffers[offsetA];
            float4 forceB = forceBuffers[offsetB];
            forceA.xyz -= delta.xyz;
            forceB.xyz += delta.xyz;
            forceBuffers[offsetA] = forceA;
            forceBuffers[offsetB] = forceB;
        }
        index += get_global_size(0);
    }
    energyBuffer[get_global_id(0)] += energy;
}