   checkLastErrorCUDA(__FILE__, __LINE__);
   cudaMemcpy(vars->gpu_hsqr[box], hsqr, imageSize * sizeof(double),
              cudaMemcpyHostToDevice);
+  checkLastErrorCUDA(__FILE__, __LINE__);
+  cudaMemset(vars->gpu_sumRnew[box], 0, imageSize * sizeof(double));
+  checkLastErrorCUDA(__FILE__, __LINE__);
+  cudaMemset(vars->gpu_sumInew[box], 0, imageSize * sizeof(double));
   checkLastErrorCUDA(__FILE__, __LINE__);
 
   dim3 threadsPerBlock(256, 1, 1);

      shared_coords[particleID * 3 + 2]);
    double dotsin, dotcos;
    sincos(dot, &dotsin, &dotcos);
    sumR += gpu_particleCharge[offset_coordinates_index + particleID] * dotsin;
    sumI += gpu_particleCharge[offset_coordinates_index + particleID] * dotcos;
  }

  atomicAdd(&gpu_sumRnew[imageID], sumR);

      shared_kvector[vectorIndex*3+1] + z * shared_kvector[vectorIndex*3+2];
    double dotsin, dotcos;
    sincos(dot, &dotsin, &dotcos);
    double factor = 2.0 * gpu_particleCharge[particleID] * gpu_prefact[vectorIndex] * lambdaCoef * 
      (dotsin * gpu_sumRnew[vectorIndex] - dotcos * gpu_sumInew[vectorIndex]);
      
    forceX += factor * shared_kvector[vectorIndex*3];
