"plugins/drude/platforms/cuda/CMakeLists.txt" did not exist on "ca9cf05f35c01d50c44b0365320d1c180586e8de"
andersenThermostat.cl 1.04 KB
Newer Older
1
2
3
4
/**
 * Apply the Andersen thermostat to adjust particle velocities.
 */

5
__kernel void applyAndersenThermostat(float collisionFrequency, float kT, __global mixed4* velm, __global const mixed2* restrict stepSize, __global const float4* restrict random,
6
        unsigned int randomIndex, __global const int* restrict atomGroups) {
7
8
    float collisionProbability = 1.0f-EXP(-collisionFrequency*stepSize[0].y);
    float randomRange = erf(collisionProbability/SQRT(2.0f));
9
    for (int index = get_global_id(0); index < NUM_ATOMS; index += get_global_size(0)) {
10
        mixed4 velocity = velm[index];
11
12
        float4 selectRand = random[randomIndex+atomGroups[index]];
        float4 velRand = random[randomIndex+index];
13
        real scale = (selectRand.w > -randomRange && selectRand.w < randomRange ? 0 : 1);
14
        real add = (1-scale)*SQRT(kT*velocity.w);
15
16
17
        velocity.x = scale*velocity.x + add*velRand.x;
        velocity.y = scale*velocity.y + add*velRand.y;
        velocity.z = scale*velocity.z + add*velRand.z;
18
19
20
        velm[index] = velocity;
    }
}