int Box::changeMolecule(int molIdx) { Real maxTranslation = environment->maxTranslation; Real maxRotation = environment->maxRotation; saveChangedMol(molIdx); //Pick an atom in the molecule about which to rotate int atomIndex = randomReal(0, molecules[molIdx].numOfAtoms); Atom vertex = molecules[molIdx].atoms[atomIndex]; const Real deltaX = randomReal(-maxTranslation, maxTranslation); const Real deltaY = randomReal(-maxTranslation, maxTranslation); const Real deltaZ = randomReal(-maxTranslation, maxTranslation); const Real degreesX = randomReal(-maxRotation, maxRotation); const Real degreesY = randomReal(-maxRotation, maxRotation); const Real degreesZ = randomReal(-maxRotation, maxRotation); moveMolecule(molecules[molIdx], vertex, deltaX, deltaY, deltaZ, degreesX, degreesY, degreesZ); keepMoleculeInBox(molIdx); return molIdx; }
void SimCalcs::intermolecularMove(int molIdx) { Real maxT = sb->maxTranslate; Real maxR = sb->maxRotate; int molStart = sb->moleculeData[MOL_START][molIdx]; int molLen = sb->moleculeData[MOL_LEN][molIdx]; int vertexIdx = (int)randomReal(0, molLen); const Real deltaX = randomReal(-maxT, maxT); const Real deltaY = randomReal(-maxT, maxT); const Real deltaZ = randomReal(-maxT, maxT); const Real rotX = randomReal(-maxR, maxR); const Real rotY = randomReal(-maxR, maxR); const Real rotZ = randomReal(-maxR, maxR); Real** rBCoords = GPUCopy::rollBackCoordinatesPtr(); Real** aCoords = GPUCopy::atomCoordinatesPtr(); Real* bSize = GPUCopy::sizePtr(); int* pIdxes = GPUCopy::primaryIndexesPtr(); int** molData = GPUCopy::moleculeDataPtr(); // Do the move here #pragma acc parallel loop deviceptr(aCoords, rBCoords) \ if (on_gpu) for (int i = 0; i < molLen; i++) { for (int j = 0; j < NUM_DIMENSIONS; j++) { rBCoords[j][i] = aCoords[j][molStart + i]; } if (i == vertexIdx) continue; rotateAtom(molStart + i, molStart + vertexIdx, rotX, rotY, rotZ, aCoords); translateAtom(molStart + i, deltaX, deltaY, deltaZ, aCoords); } #pragma acc parallel loop deviceptr(aCoords, molData, pIdxes, bSize) \ if (on_gpu) for (int i = 0; i < 1; i++) { aCoords[0][molStart + vertexIdx] += deltaX; aCoords[1][molStart + vertexIdx] += deltaY; aCoords[2][molStart + vertexIdx] += deltaZ; keepMoleculeInBox(molIdx, aCoords, molData, pIdxes, bSize); } }