"platforms/common/vscode:/vscode.git/clone" did not exist on "862e6ac7d8aa80aaafbfb866aaa1263aa8069d96"
Commit 5003591d authored by Peter Eastman's avatar Peter Eastman
Browse files

Simplified reference code for accumulating energies

parent b8c624fa
......@@ -57,17 +57,13 @@ class ReferenceLJCoulomb14 : public ReferenceBondIxn {
@param atomCoordinates atom coordinates
@param parameters six RB parameters
@param forces force array (forces added to current values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
@param totalEnergy if not null, the energy will be added to this
--------------------------------------------------------------------------------------- */
int calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
void calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
RealOpenMM* parameters, RealOpenMM** forces,
RealOpenMM* energiesByBond, RealOpenMM* energiesByAtom ) const;
RealOpenMM* totalEnergy ) const;
};
......
......@@ -73,25 +73,15 @@ ReferenceProperDihedralBond::~ReferenceProperDihedralBond( ){
parameters[1] = ideal bond angle in radians
parameters[2] = multiplicity
@param forces force array (forces added to current values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
@param totalEnergy if not null, the energy will be added to this
--------------------------------------------------------------------------------------- */
int ReferenceProperDihedralBond::calculateBondIxn( int* atomIndices,
void ReferenceProperDihedralBond::calculateBondIxn( int* atomIndices,
RealOpenMM** atomCoordinates,
RealOpenMM* parameters,
RealOpenMM** forces,
RealOpenMM* energiesByBond,
RealOpenMM* energiesByAtom ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceProperDihedralBond::calculateBondIxn";
// ---------------------------------------------------------------------------------------
RealOpenMM* totalEnergy ) const {
static const std::string methodName = "\nReferenceProperDihedralBond::calculateBondIxn";
......@@ -185,7 +175,6 @@ int ReferenceProperDihedralBond::calculateBondIxn( int* atomIndices,
// accumulate energies
updateEnergy( energy, energiesByBond, LastAtomIndex, atomIndices, energiesByAtom );
return ReferenceForce::DefaultReturn;
if (totalEnergy != NULL)
*totalEnergy += energy;
}
......@@ -61,17 +61,13 @@ class ReferenceProperDihedralBond : public ReferenceBondIxn {
parameters[1] = ideal bond angle in radians
parameters[2] = multiplicity
@param forces force array (forces added to current values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
@param totalEnergy if not null, the energy will be added to this
--------------------------------------------------------------------------------------- */
int calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
void calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
RealOpenMM* parameters, RealOpenMM** forces,
RealOpenMM* energiesByBond, RealOpenMM* energiesByAtom ) const;
RealOpenMM* totalEnergy ) const;
};
......
......@@ -71,25 +71,15 @@ ReferenceRbDihedralBond::~ReferenceRbDihedralBond( ){
@param atomCoordinates atom coordinates
@param parameters six RB parameters
@param forces force array (forces added to current values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
@param totalEnergy if not null, the energy will be added to this
--------------------------------------------------------------------------------------- */
int ReferenceRbDihedralBond::calculateBondIxn( int* atomIndices,
void ReferenceRbDihedralBond::calculateBondIxn( int* atomIndices,
RealOpenMM** atomCoordinates,
RealOpenMM* parameters,
RealOpenMM** forces,
RealOpenMM* energiesByBond,
RealOpenMM* energiesByAtom ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceRbDihedralBond::calculateBondIxn";
// ---------------------------------------------------------------------------------------
RealOpenMM* totalEnergy ) const {
static const std::string methodName = "\nReferenceRbDihedralBond::calculateBondIxn";
......@@ -200,7 +190,6 @@ int ReferenceRbDihedralBond::calculateBondIxn( int* atomIndices,
// accumulate energies
updateEnergy( energy, energiesByBond, LastAtomIndex, atomIndices, energiesByAtom );
return ReferenceForce::DefaultReturn;
if (totalEnergy != NULL)
*totalEnergy += energy;
}
......@@ -59,17 +59,13 @@ class ReferenceRbDihedralBond : public ReferenceBondIxn {
@param atomCoordinates atom coordinates
@param parameters six RB parameters
@param forces force array (forces added to current values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
@param totalEnergy if not null, the energy will be added to this
--------------------------------------------------------------------------------------- */
int calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
void calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
RealOpenMM* parameters, RealOpenMM** forces,
RealOpenMM* energiesByBond, RealOpenMM* energiesByAtom ) const;
RealOpenMM* totalEnergy ) const;
};
......
......@@ -259,7 +259,7 @@ void ReferenceFreeEnergyCalcNonbondedSoftcoreForceKernel::executeForces(ContextI
ReferenceFreeEnergyLJCoulomb14Softcore nonbonded14;
if (nonbondedMethod == CutoffNonPeriodic || nonbondedMethod == CutoffPeriodic)
nonbonded14.setUseCutoff(nonbondedCutoff, rfDielectric);
refBondForce.calculateForce(num14, bonded14IndexArray, posData, bonded14ParamArray, forceData, 0, 0, 0, nonbonded14);
refBondForce.calculateForce(num14, bonded14IndexArray, posData, bonded14ParamArray, forceData, 0, nonbonded14);
}
double ReferenceFreeEnergyCalcNonbondedSoftcoreForceKernel::executeEnergy(ContextImpl& context) {
......@@ -289,12 +289,8 @@ double ReferenceFreeEnergyCalcNonbondedSoftcoreForceKernel::executeEnergy(Contex
if (nonbondedMethod == CutoffNonPeriodic || nonbondedMethod == CutoffPeriodic)
nonbonded14.setUseCutoff(nonbondedCutoff, rfDielectric);
RealOpenMM* energyArray = new RealOpenMM[num14];
for (int i = 0; i < num14; ++i)
energyArray[i] = 0;
refBondForce.calculateForce(num14, bonded14IndexArray, posData, bonded14ParamArray, forceData, energyArray, 0, &energy, nonbonded14);
refBondForce.calculateForce(num14, bonded14IndexArray, posData, bonded14ParamArray, forceData, &energy, nonbonded14);
disposeRealArray(forceData, numParticles);
delete[] energyArray;
return energy;
}
......
......@@ -140,23 +140,13 @@ int ReferenceFreeEnergyLJCoulomb14Softcore::getDerivedParameters( RealOpenMM c6,
parameters[1]= c6*c6/c12 (4*epsilon)
parameters[2]= epsfac*q1*q2
@param forces force array (forces added to current values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
@param totalEnergy if not null, the energy will be added to this
--------------------------------------------------------------------------------------- */
int ReferenceFreeEnergyLJCoulomb14Softcore::calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
void ReferenceFreeEnergyLJCoulomb14Softcore::calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
RealOpenMM* parameters, RealOpenMM** forces,
RealOpenMM* energiesByBond,
RealOpenMM* energiesByAtom ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceFreeEnergyLJCoulomb14Softcore::calculateBondIxn";
// ---------------------------------------------------------------------------------------
RealOpenMM* totalEnergy ) const {
static const std::string methodName = "\nReferenceFreeEnergyLJCoulomb14Softcore::calculateBondIxn";
......@@ -193,7 +183,7 @@ int ReferenceFreeEnergyLJCoulomb14Softcore::calculateBondIxn( int* atomIndices,
ReferenceForce::getDeltaR( atomCoordinates[atomBIndex], atomCoordinates[atomAIndex], deltaR[0] );
if (cutoff && deltaR[0][ReferenceForce::RIndex] > cutoffDistance)
return ReferenceForce::DefaultReturn;
return;
RealOpenMM r2 = deltaR[0][ReferenceForce::R2Index];
RealOpenMM inverseR = one/(deltaR[0][ReferenceForce::RIndex]);
......@@ -229,7 +219,8 @@ int ReferenceFreeEnergyLJCoulomb14Softcore::calculateBondIxn( int* atomIndices,
// accumulate energies
updateEnergy( energy, energiesByBond, LastAtomIndex, atomIndices, energiesByAtom );
if (totalEnergy != NULL)
*totalEnergy += energy;
// debug
......@@ -283,8 +274,6 @@ int ReferenceFreeEnergyLJCoulomb14Softcore::calculateBondIxn( int* atomIndices,
//SimTKOpenMMLog::printMessage( message );
}
return ReferenceForce::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
......
......@@ -98,16 +98,13 @@ class ReferenceFreeEnergyLJCoulomb14Softcore : public ReferenceBondIxn {
@param atomCoordinates atom coordinates
@param parameters six RB parameters
@param forces force array (forces added to current values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
@param totalEnergy if not null, the energy will be added to this
--------------------------------------------------------------------------------------- */
int calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
void calculateBondIxn( int* atomIndices, RealOpenMM** atomCoordinates,
RealOpenMM* parameters, RealOpenMM** forces,
RealOpenMM* energiesByBond, RealOpenMM* energiesByAtom ) const;
RealOpenMM* totalEnergy ) const;
/**---------------------------------------------------------------------------------------
......
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