Commit b53cd947 authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Latest mods

parent ff88ddad
#ifndef OPENMM_BROOKKERNELS_H_
#define OPENMM_BROOKKERNELS_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Authors: Peter Eastman, Mark Friedrichs *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "kernels.h"
#include "SimTKUtilities/SimTKOpenMMRealType.h"
class BrookStochasticDynamics;
class BrookShakeAlgorithm;
namespace OpenMM {
/**
* This kernel is invoked by StandardMMForceField to calculate the forces acting on the system.
*/
class BrookCalcStandardMMForceFieldKernel : public CalcStandardMMForceFieldKernel {
public:
BrookCalcStandardMMForceFieldKernel(std::string name, const Platform& platform) : CalcStandardMMForceFieldKernel(name, platform) {
}
~BrookCalcStandardMMForceFieldKernel();
/**
* Initialize the kernel, setting up the values of all the force field parameters.
*
* @param bondIndices the two atoms connected by each bond term
* @param bondParameters the force parameters (length, k) for each bond term
* @param angleIndices the three atoms connected by each angle term
* @param angleParameters the force parameters (angle, k) for each angle term
* @param periodicTorsionIndices the four atoms connected by each periodic torsion term
* @param periodicTorsionParameters the force parameters (k, phase, periodicity) for each periodic torsion term
* @param rbTorsionIndices the four atoms connected by each Ryckaert-Bellemans torsion term
* @param rbTorsionParameters the coefficients (in order of increasing powers) for each Ryckaert-Bellemans torsion term
* @param bonded14Indices each element contains the indices of two atoms whose nonbonded interactions should be reduced since
* they form a bonded 1-4 pair
* @param lj14Scale the factor by which van der Waals interactions should be reduced for bonded 1-4 pairs
* @param coulomb14Scale the factor by which Coulomb interactions should be reduced for bonded 1-4 pairs
* @param exclusions the i'th element lists the indices of all atoms with which the i'th atom should not interact through
* nonbonded forces. Bonded 1-4 pairs are also included in this list, since they should be omitted from
* the standard nonbonded calculation.
* @param nonbondedParameters the nonbonded force parameters (charge, sigma, epsilon) for each atom
*/
void initialize(const std::vector<std::vector<int> >& bondIndices, const std::vector<std::vector<double> >& bondParameters,
const std::vector<std::vector<int> >& angleIndices, const std::vector<std::vector<double> >& angleParameters,
const std::vector<std::vector<int> >& periodicTorsionIndices, const std::vector<std::vector<double> >& periodicTorsionParameters,
const std::vector<std::vector<int> >& rbTorsionIndices, const std::vector<std::vector<double> >& rbTorsionParameters,
const std::vector<std::vector<int> >& bonded14Indices, double lj14Scale, double coulomb14Scale,
const std::vector<std::set<int> >& exclusions, const std::vector<std::vector<double> >& nonbondedParameters);
/**
* Execute the kernel to calculate the forces.
*
* @param positions a Stream of type Double3 containing the position (x, y, z) of each atom
* @param forces a Stream of type Double3 containing the force (x, y, z) on each atom. On entry, this contains the forces that
* have been calculated so far. The kernel should add its own forces to the values already in the stream.
*/
void executeForces(const Stream& positions, Stream& forces);
/**
* Execute the kernel to calculate the energy.
*
* @param positions a Stream of type Double3 containing the position (x, y, z) of each atom
* @return the potential energy due to the StandardMMForceField
*/
double executeEnergy(const Stream& positions);
private:
int numAtoms, numBonds, numAngles, numPeriodicTorsions, numRBTorsions, num14;
int **bondIndexArray, **angleIndexArray, **periodicTorsionIndexArray, **rbTorsionIndexArray, **exclusionArray, **bonded14IndexArray;
RealOpenMM **bondParamArray, **angleParamArray, **periodicTorsionParamArray, **rbTorsionParamArray, **atomParamArray, **bonded14ParamArray;
};
/**
* This kernel is invoked by GBSAOBCForceField to calculate the forces acting on the system.
*/
class BrookCalcGBSAOBCForceFieldKernel : public CalcGBSAOBCForceFieldKernel {
public:
BrookCalcGBSAOBCForceFieldKernel(std::string name, const Platform& platform) : CalcGBSAOBCForceFieldKernel(name, platform) {
}
/**
* Initialize the kernel, setting up the values of all the force field parameters.
*
* @param bornRadii the initial value of the Born radius for each atom
* @param atomParameters the force parameters (charge, atomic radius, scaling factor) for each atom
* @param solventDielectric the dielectric constant of the solvent
* @param soluteDielectric the dielectric constant of the solute
*/
void initialize(const std::vector<double>& bornRadii, const std::vector<std::vector<double> >& atomParameters,
double solventDielectric, double soluteDielectric);
/**
* Execute the kernel to calculate the forces.
*
* @param positions a Stream of type Double3 containing the position (x, y, z) of each atom
* @param forces a Stream of type Double3 containing the force (x, y, z) on each atom. On entry, this contains the forces that
* have been calculated so far. The kernel should add its own forces to the values already in the stream.
*/
void executeForces(const Stream& positions, Stream& forces);
/**
* Execute the kernel to calculate the energy.
*
* @param positions a Stream of type Double3 containing the position (x, y, z) of each atom
* @return the potential energy due to the GBSAOBCForceField
*/
double executeEnergy(const Stream& positions);
};
/**
* This kernel is invoked by VerletIntegrator to take one time step.
*/
class BrookIntegrateVerletStepKernel : public IntegrateVerletStepKernel {
public:
BrookIntegrateVerletStepKernel(std::string name, const Platform& platform) : IntegrateVerletStepKernel(name, platform) {
}
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses the mass of each atom
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained atoms
*/
void initialize(const std::vector<double>& masses, const std::vector<std::vector<int> >& constraintIndices,
const std::vector<double>& constraintLengths);
/**
* Execute the kernel.
*
* @param positions a Stream of type Double3 containing the position (x, y, z) of each atom
* @param velocities a Stream of type Double3 containing the velocity (x, y, z) of each atom
* @param forces a Stream of type Double3 containing the force (x, y, z) on each atom
* @param stepSize the integration step size
*/
void execute(Stream& positions, Stream& velocities, const Stream& forces, double stepSize);
};
/**
* This kernel is invoked by LangevinIntegrator to take one time step.
*/
class BrookIntegrateLangevinStepKernel : public IntegrateLangevinStepKernel {
public:
BrookIntegrateLangevinStepKernel(std::string name, const Platform& platform) : IntegrateLangevinStepKernel(name, platform),
dynamics(0), shake(0), masses(0), shakeParameters(0), constraintIndices(0) {
}
~BrookIntegrateLangevinStepKernel();
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses the mass of each atom
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained atoms
*/
void initialize(const std::vector<double>& masses, const std::vector<std::vector<int> >& constraintIndices,
const std::vector<double>& constraintLengths);
/**
* Execute the kernel.
*
* @param positions a Stream of type Double3 containing the position (x, y, z) of each atom
* @param velocities a Stream of type Double3 containing the velocity (x, y, z) of each atom
* @param forces a Stream of type Double3 containing the force (x, y, z) on each atom
* @param temperature the temperature of the heat bath
* @param friction the friction coefficient coupling the system to the heat bath
* @param stepSize the integration step size
*/
void execute(Stream& positions, Stream& velocities, const Stream& forces, double temperature, double friction, double stepSize);
private:
BrookStochasticDynamics* dynamics;
BrookShakeAlgorithm* shake;
RealOpenMM* masses;
RealOpenMM** shakeParameters;
int** constraintIndices;
int numConstraints;
double prevTemp, prevFriction, prevStepSize;
};
/**
* This kernel is invoked by BrownianIntegrator to take one time step.
*/
class BrookIntegrateBrownianStepKernel : public IntegrateBrownianStepKernel {
public:
BrookIntegrateBrownianStepKernel(std::string name, const Platform& platform) : IntegrateBrownianStepKernel(name, platform) {
}
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses the mass of each atom
* @param constraintIndices each element contains the indices of two atoms whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained atoms
*/
void initialize(const std::vector<double>& masses, const std::vector<std::vector<int> >& constraintIndices,
const std::vector<double>& constraintLengths);
/**
* Execute the kernel.
*
* @param positions a Stream of type Double3 containing the position (x, y, z) of each atom
* @param velocities a Stream of type Double3 containing the velocity (x, y, z) of each atom
* @param forces a Stream of type Double3 containing the force (x, y, z) on each atom
* @param temperature the temperature of the heat bath
* @param friction the friction coefficient coupling the system to the heat bath
* @param stepSize the integration step size
*/
void execute(Stream& positions, Stream& velocities, const Stream& forces, double temperature, double friction, double stepSize);
};
/**
* This kernel is invoked by AndersenThermostat at the start of each time step to adjust the atom velocities.
*/
class BrookApplyAndersenThermostatKernel : public ApplyAndersenThermostatKernel {
public:
BrookApplyAndersenThermostatKernel(std::string name, const Platform& platform) : ApplyAndersenThermostatKernel(name, platform) {
}
/**
* Initialize the kernel, setting up the values of unchanging parameters.
*
* @param masses the mass of each atom
*/
void initialize(const std::vector<double>& masses);
/**
* Execute the kernel.
*
* @param velocities a Stream of type Double3 containing the velocity (x, y, z) of each atom
* @param temperature the temperature of the heat bath
* @param collisionFrequency the frequency at which atom collide with particles in the heat bath
* @param stepSize the integration step size
*/
void execute(Stream& velocities, double temperature, double collisionFrequency, double stepSize);
};
/**
* This kernel is invoked to calculate the kinetic energy of the system.
*/
class BrookCalcKineticEnergyKernel : public CalcKineticEnergyKernel {
public:
BrookCalcKineticEnergyKernel(std::string name, const Platform& platform) : CalcKineticEnergyKernel(name, platform) {
}
/**
* Initialize the kernel, setting up the atomic masses.
*
* @param masses the mass of each atom
*/
void initialize(const std::vector<double>& masses);
/**
* Execute the kernel.
*
* @param velocities a Stream of type Double3 containing the velocity (x, y, z) of each atom
* @return the kinetic energy of the system
*/
double execute(const Stream& velocities);
private:
std::vector<double> masses;
};
} // namespace OpenMM
#endif /*OPENMM_BROOKKERNELS_H_*/
This diff is collapsed.
#ifndef BrookNonBonded_H_ #ifndef OPENMM_BROOK_NONBONDED_H_
#define BrookNonBonded_H_ #define OPENMM_BROOK_NONBONDED_H_
/* -------------------------------------------------------------------------- * /* -------------------------------------------------------------------------- *
* OpenMM * * OpenMM *
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
#include <vector> #include <vector>
#include <set> #include <set>
#include "BrookFloatStreamImpl.h" #include "BrookFloatStreamInternal.h"
#include "BrookIntStreamImpl.h" #include "BrookIntStreamInternal.h"
#include "BrookPlatform.h" #include "BrookPlatform.h"
#include "BrookCommon.h" #include "BrookCommon.h"
...@@ -54,7 +54,7 @@ class BrookNonBonded : public BrookCommon { ...@@ -54,7 +54,7 @@ class BrookNonBonded : public BrookCommon {
static const int DefaultReturnValue = 0; static const int DefaultReturnValue = 0;
static const int ErrorReturnValue = -1; static const int ErrorReturnValue = -1;
BrookNonBonded( ); BrookNonBonded( );
~BrookNonBonded(); ~BrookNonBonded();
...@@ -250,7 +250,7 @@ class BrookNonBonded : public BrookCommon { ...@@ -250,7 +250,7 @@ class BrookNonBonded : public BrookCommon {
* *
*/ */
BrookFloatStreamImpl* getExclusionStream( void ) const; BrookFloatStreamInternal* getExclusionStream( void ) const;
/** /**
* Get vdw stream * Get vdw stream
...@@ -259,7 +259,7 @@ class BrookNonBonded : public BrookCommon { ...@@ -259,7 +259,7 @@ class BrookNonBonded : public BrookCommon {
* *
*/ */
BrookFloatStreamImpl* getVdwStream( void ) const; BrookFloatStreamInternal* getOuterVdwStream( void ) const;
/** /**
* Get charge stream * Get charge stream
...@@ -268,7 +268,7 @@ class BrookNonBonded : public BrookCommon { ...@@ -268,7 +268,7 @@ class BrookNonBonded : public BrookCommon {
* *
*/ */
BrookFloatStreamImpl* getChargeStream( void ) const; BrookFloatStreamInternal* getChargeStream( void ) const;
/** /**
* Get sigma-eps stream * Get sigma-eps stream
...@@ -277,7 +277,7 @@ class BrookNonBonded : public BrookCommon { ...@@ -277,7 +277,7 @@ class BrookNonBonded : public BrookCommon {
* *
*/ */
BrookFloatStreamImpl* getSigmaStream( void ) const; BrookFloatStreamInternal* getInnerSigmaStream( void ) const;
/** /**
* Get epsilon stream * Get epsilon stream
...@@ -286,7 +286,7 @@ class BrookNonBonded : public BrookCommon { ...@@ -286,7 +286,7 @@ class BrookNonBonded : public BrookCommon {
* *
*/ */
BrookFloatStreamImpl* getEpsilonStream( void ) const; BrookFloatStreamInternal* getInnerEpsilonStream( void ) const;
/** /**
* Get force streams * Get force streams
...@@ -295,7 +295,7 @@ class BrookNonBonded : public BrookCommon { ...@@ -295,7 +295,7 @@ class BrookNonBonded : public BrookCommon {
* *
*/ */
BrookFloatStreamImpl** getForceStreams( void ); BrookFloatStreamInternal** getForceStreams( void );
/** /**
* Return true if force[index] stream is set * Return true if force[index] stream is set
...@@ -320,7 +320,7 @@ class BrookNonBonded : public BrookCommon { ...@@ -320,7 +320,7 @@ class BrookNonBonded : public BrookCommon {
* */ * */
int setup( int numberOfAtoms, const std::vector<std::vector<double> >& nonbondedParameters, int setup( int numberOfAtoms, const std::vector<std::vector<double> >& nonbondedParameters,
const std::vector<std::set<int> >& exclusions, const BrookPlatform& platform ); const std::vector<std::set<int> >& exclusions, const Platform& platform );
/* /*
* Get contents of object * Get contents of object
...@@ -331,7 +331,7 @@ class BrookNonBonded : public BrookCommon { ...@@ -331,7 +331,7 @@ class BrookNonBonded : public BrookCommon {
* *
* */ * */
std::string getContents( int level ) const; std::string getContentsString( int level = 0 ) const;
private: private:
...@@ -339,6 +339,17 @@ class BrookNonBonded : public BrookCommon { ...@@ -339,6 +339,17 @@ class BrookNonBonded : public BrookCommon {
static const int NumberOfForceStreams = 4; static const int NumberOfForceStreams = 4;
// streams indices
enum {
ExclusionStream,
OuterVdwStream,
ChargeStream,
InnerSigmaStream,
InnerEpsilonStream,
LastStreamIndex
};
// atom ceiling // atom ceiling
int _atomSizeCeiling; int _atomSizeCeiling;
...@@ -370,15 +381,23 @@ class BrookNonBonded : public BrookCommon { ...@@ -370,15 +381,23 @@ class BrookNonBonded : public BrookCommon {
int _jStreamHeight; int _jStreamHeight;
int _jStreamSize; int _jStreamSize;
// streams // internal streams
BrookFloatStreamImpl* _exclusionStream; BrookFloatStreamInternal* _nonbondedStreams[LastStreamIndex];
BrookFloatStreamImpl* _vdwStream; BrookFloatStreamInternal* _nonbondedForceStreams[NumberOfForceStreams];
BrookFloatStreamImpl* _chargeStream;
BrookFloatStreamImpl* _sigmaStream;
BrookFloatStreamImpl* _epsilonStream;
BrookFloatStreamImpl* _nonbondedForceStreams[NumberOfForceStreams];
/*
* Setup of stream dimensions for exclusion stream
*
* @param atomStreamSize atom stream size
* @param atomStreamWidth atom stream width
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
* */
int initializeExclusionStreamSize( int atomStreamSize, int atomStreamWidth );
/** /**
* Initialize exclusion stream dimensions and stream * Initialize exclusion stream dimensions and stream
* *
...@@ -416,6 +435,18 @@ class BrookNonBonded : public BrookCommon { ...@@ -416,6 +435,18 @@ class BrookNonBonded : public BrookCommon {
int initializeExclusions( const std::vector<std::set<int> >& exclusionsVector, const Platform& platform ); int initializeExclusions( const std::vector<std::set<int> >& exclusionsVector, const Platform& platform );
/**
* Initialize stream dimensions
*
* @param numberOfAtoms number of atoms
* @param platform platform
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
*/
int initializeStreamSizes( int numberOfAtoms, const Platform& platform );
/** /**
* Initialize stream dimensions and streams * Initialize stream dimensions and streams
* *
...@@ -425,8 +456,36 @@ class BrookNonBonded : public BrookCommon { ...@@ -425,8 +456,36 @@ class BrookNonBonded : public BrookCommon {
* *
*/ */
int initializeStreams( int numberOfAtoms, const Platform& platform ); int initializeStreams( const Platform& platform );
/*
* Setup of j-stream dimensions
*
* @param atomStreamSize atom stream size
* @param atomStreamWidth atom stream width
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
* @throw OpenMMException if jStreamWidth < 1 || innerUnroll < 1
*
* */
int initializeJStreamSize( int atomStreamSize, int atomStreamWidth );
/*
* Setup of outer vdw stream size
*
* @param atomStreamSize atom stream size
* @param atomStreamWidth atom stream width
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
* @throw OpenMMException if jStreamWidth < 1 || innerUnroll < 1
*
* */
int initializeOuterVdwStreamSize( int atomStreamSize, int atomStreamWidth );
/** /**
* Set sigma & epsilon given c6 & c12 (geometric rule) * Set sigma & epsilon given c6 & c12 (geometric rule)
* *
...@@ -453,8 +512,20 @@ class BrookNonBonded : public BrookCommon { ...@@ -453,8 +512,20 @@ class BrookNonBonded : public BrookCommon {
int initializeVdwAndCharge( const std::vector<std::vector<double> >& nonbondedParameters, const Platform& platform ); int initializeVdwAndCharge( const std::vector<std::vector<double> >& nonbondedParameters, const Platform& platform );
/*
* Setup of stream dimensions for partial force streams
*
* @param atomStreamSize atom stream size
* @param atomStreamWidth atom stream width
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
* */
int initializePartialForceStreamSize( int atomStreamSize, int atomStreamWidth );
}; };
} // namespace OpenMM } // namespace OpenMM
#endif /*OPENMM_BROOKKERNELS_H_*/ #endif /* OPENMM_BROOK_NONBONDED_H_ */
This diff is collapsed.
This diff is collapsed.
#ifndef OPENMM_BROOK_REMOVE_CM_MOTION_KERNEL_H_
#define OPENMM_BROOK_REMOVE_CM_MOTION_KERNEL_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright ( c ) 2008 Stanford University and the Authors. *
* Authors: Peter Eastman, Mark Friedrichs *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files ( the "Software" ), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "kernels.h"
namespace OpenMM {
/**
* Brook class for removing center-of-mass motion
*/
class BrookRemoveCMMotionKernel : public RemoveCMMotionKernel {
public:
/**
* BrookRemoveCMMotionKernel constructor
*
* @param name name of the stream to create
* @param platform platform
*
*/
BrookRemoveCMMotionKernel( std::string name, const Platform& platform );
/**
* BrookRemoveCMMotionKernel destructor
*
*/
~BrookRemoveCMMotionKernel();
/**
* Initialize the kernel
*
* @param masses mass of each atom
*
*/
void initialize( const std::vector<double>& masses );
/**
* Execute the kernel.
*
* @param velocities stream of atom velocities
*
*/
void execute( Stream& velocities );
private:
};
} // namespace OpenMM
#endif /* OPENMM_BROOK_REMOVE_CM_MOTION_KERNEL_H_ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/****************************************************************
* This file is part of the gpu acceleration library for gromacs.
* Author: V. Vishal
* Copyright (C) Pande Group, Stanford, 2006
*****************************************************************/
//Harmonic bonds kernel
//Input is a stream of i, j pairs
//parms is float2( b0, kA )
//Output is two streams of forces fi, fj
//Can be optimized as necessary
kernel void kbonds_harmonic(
float xstrwidth, //atom stream width
float2 atoms<>,
float2 parms<>,
float4 posq[][],
out float3 fi<>,
out float3 fj<>
) {
float2 ai, aj;
float3 rij;
float rinv;
ai.y = floor( atoms.x / xstrwidth );
ai.x = atoms.x - ai.y * xstrwidth;
aj.y = floor( atoms.y / xstrwidth );
aj.x = atoms.y - aj.y * xstrwidth;
rij = posq[ai].xyz - posq[aj].xyz; //3
rinv = rsqrt( dot(rij, rij) ); //6
fi = -parms.y * ( 1.0f - parms.x * rinv ) * rij; //6
fj = -fi;
//Total: 15 flops
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment