"platforms/cuda-old/sharedTarget/CMakeLists.txt" did not exist on "5f2e5b2e958c0f152703225daf1d2ba89a90cb72"
andersenThermostat.cl 878 Bytes
Newer Older
1
2
3
4
5
6
7
/**
 * Apply the Andersen thermostat to adjust particle velocities.
 */

__kernel void applyAndersenThermostat(float collisionFrequency, float kT, __global float4* velm, __global float2* stepSize, __global float4* random, unsigned int randomIndex) {
    randomIndex += get_global_id(0);
    float collisionProbability = 1.0f-exp(-collisionFrequency*stepSize[0].y);
8
    float randomRange = erf(collisionProbability/sqrt(2.0f));
9
10
11
    for (int index = get_global_id(0); index < NUM_ATOMS; index += get_global_size(0)) {
        float4 velocity = velm[index];
        float4 rand = random[randomIndex];
12
13
        float scale = (rand.w > -randomRange && rand.w < randomRange ? 0.0f : 1.0f);
        float add = (1.0f-scale)*sqrt(kT*velocity.w);
14
15
16
17
18
        velocity.xyz = scale*velocity.xyz + add*rand.xyz;
        velm[index] = velocity;
        randomIndex += get_global_size(0);
    }
}