Skip to content

Commit

Permalink
Amoeba and ATM Force minor cleanup (openmm#4195)
Browse files Browse the repository at this point in the history
* Amoeba minor cleanup

- Fix variable name in string
- Remove odd space between variable and period that is inconsistently styled

* Replaces random tabs with spaces in ATM Force
  • Loading branch information
bdenhollander authored Aug 18, 2023
1 parent 065e34a commit f2bdcc7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
14 changes: 7 additions & 7 deletions platforms/common/src/CommonKernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7812,19 +7812,19 @@ class CommonCalcATMForceKernel::ForceInfo : public ComputeForceInfo {
class CommonCalcATMForceKernel::ReorderListener : public ComputeContext::ReorderListener {
public:
ReorderListener(ComputeContext& cc, vector<mm_float4>& displVector1, ArrayInterface& displ1,
vector<mm_float4>& displVector0, ArrayInterface& displ0) :
vector<mm_float4>& displVector0, ArrayInterface& displ0) :
cc(cc), displVector1(displVector1), displ1(displ1), displVector0(displVector0), displ0(displ0) {
}
void execute() {
const vector<int>& id = cc.getAtomIndex();
vector<mm_float4> newDisplVectorContext1(cc.getPaddedNumAtoms());
vector<mm_float4> newDisplVectorContext0(cc.getPaddedNumAtoms());
vector<mm_float4> newDisplVectorContext1(cc.getPaddedNumAtoms());
vector<mm_float4> newDisplVectorContext0(cc.getPaddedNumAtoms());
for (int i = 0; i < cc.getNumAtoms(); i++) {
newDisplVectorContext1[i] = displVector1[id[i]];
newDisplVectorContext0[i] = displVector0[id[i]];
newDisplVectorContext0[i] = displVector0[id[i]];
}
displ1.upload(newDisplVectorContext1);
displ0.upload(newDisplVectorContext0);
displ0.upload(newDisplVectorContext0);
}
private:
ComputeContext& cc;
Expand Down Expand Up @@ -7890,7 +7890,7 @@ void CommonCalcATMForceKernel::initKernels(ContextImpl& context, ContextImpl& in
copyStateKernel->addArg(cc0.getPosq());
copyStateKernel->addArg(cc1.getPosq());
copyStateKernel->addArg(displ0);
copyStateKernel->addArg(displ1);
copyStateKernel->addArg(displ1);
if (cc.getUseMixedPrecision()) {
copyStateKernel->addArg(cc.getPosqCorrection());
copyStateKernel->addArg(cc0.getPosqCorrection());
Expand Down Expand Up @@ -7969,7 +7969,7 @@ void CommonCalcATMForceKernel::copyParametersToContext(ContextImpl& context, con
vector<mm_float4> displVectorContext0(cc.getPaddedNumAtoms(), mm_float4(0, 0, 0, 0));
for (int i = 0; i < numParticles; i++) {
displVectorContext1[i] = displVector1[id[i]];
displVectorContext0[i] = displVector0[id[i]];
displVectorContext0[i] = displVector0[id[i]];
}
displ1.upload(displVectorContext1);
displ0.upload(displVectorContext0);
Expand Down
4 changes: 2 additions & 2 deletions platforms/reference/src/ReferenceKernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2969,7 +2969,7 @@ void ReferenceCalcATMForceKernel::initialize(const System& system, const ATMForc
Vec3 displacement1, displacement0;
force.getParticleParameters(i, displacement1, displacement0 );
displ1[i] = displacement1;
displ0[i] = displacement0;
displ0[i] = displacement0;
}
}

Expand Down Expand Up @@ -3029,6 +3029,6 @@ void ReferenceCalcATMForceKernel::copyParametersToContext(ContextImpl& context,
Vec3 displacement1, displacement0;
force.getParticleParameters(i, displacement1, displacement0 );
displ1[i] = displacement1;
displ0[i] = displacement0;
displ0[i] = displacement0;
}
}
14 changes: 7 additions & 7 deletions plugins/amoeba/platforms/common/src/AmoebaCommonKernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void CommonCalcAmoebaMultipoleForceKernel::initialize(const System& system, cons
prevDipolesPolar.initialize(cc, 3*numMultipoles*MaxPrevDIISDipoles, elementSize, "prevDipolesPolar");
prevErrors.initialize(cc, 3*numMultipoles*MaxPrevDIISDipoles, elementSize, "prevErrors");
diisMatrix.initialize(cc, MaxPrevDIISDipoles*MaxPrevDIISDipoles, elementSize, "diisMatrix");
diisCoefficients.initialize(cc, MaxPrevDIISDipoles+1, sizeof(float), "diisMatrix");
diisCoefficients.initialize(cc, MaxPrevDIISDipoles+1, sizeof(float), "diisCoefficients");
syncEvent = cc.createEvent();
hasCreatedEvent = true;
}
Expand Down Expand Up @@ -1748,16 +1748,16 @@ void CommonCalcAmoebaGeneralizedKirkwoodForceKernel::initialize(const System& sy
int paddedNumAtoms = cc.getPaddedNumAtoms();
int elementSize = (cc.getUseDoublePrecision() ? sizeof(double) : sizeof(float));
params.initialize<mm_float2>(cc, paddedNumAtoms, "amoebaGkParams");
bornRadii .initialize(cc, paddedNumAtoms, elementSize, "bornRadii");
field .initialize(cc, 3*paddedNumAtoms, sizeof(long long), "gkField");
bornRadii.initialize(cc, paddedNumAtoms, elementSize, "bornRadii");
field.initialize(cc, 3*paddedNumAtoms, sizeof(long long), "gkField");
bornSum.initialize<long long>(cc, paddedNumAtoms, "bornSum");
bornForce.initialize<long long>(cc, paddedNumAtoms, "bornForce");
inducedDipoleS .initialize(cc, 3*paddedNumAtoms, elementSize, "inducedDipoleS");
inducedDipolePolarS .initialize(cc, 3*paddedNumAtoms, elementSize, "inducedDipolePolarS");
inducedDipoleS.initialize(cc, 3*paddedNumAtoms, elementSize, "inducedDipoleS");
inducedDipolePolarS.initialize(cc, 3*paddedNumAtoms, elementSize, "inducedDipolePolarS");
polarizationType = multipoles->getPolarizationType();
if (polarizationType != AmoebaMultipoleForce::Direct) {
inducedField .initialize(cc, 3*paddedNumAtoms, sizeof(long long), "gkInducedField");
inducedFieldPolar .initialize(cc, 3*paddedNumAtoms, sizeof(long long), "gkInducedFieldPolar");
inducedField.initialize(cc, 3*paddedNumAtoms, sizeof(long long), "gkInducedField");
inducedFieldPolar.initialize(cc, 3*paddedNumAtoms, sizeof(long long), "gkInducedFieldPolar");
}
cc.addAutoclearBuffer(field);
cc.addAutoclearBuffer(bornSum);
Expand Down
14 changes: 7 additions & 7 deletions tests/TestATMForce.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ void test2Particles() {
double epot = state.getPotentialEnergy();
double u0, u1, energy;
atm->getPerturbationEnergy(context, u1, u0, energy);
double epert = u1 - u0;
double epert = u1 - u0;
ASSERT_EQUAL_TOL(lm, context.getParameter(atm->Lambda1()), 1e-6);
ASSERT_EQUAL_TOL(lm, context.getParameter(atm->Lambda2()), 1e-6);
ASSERT_EQUAL_TOL(energy, epot, 1e-6);
ASSERT_EQUAL_TOL(lm*0.5*displ[0]*displ[0], epot, 1e-6);
ASSERT_EQUAL_TOL(0.0, u0, 1e-6);
ASSERT_EQUAL_TOL(0.5*displ[0]*displ[0], u1, 1e-6);
ASSERT_EQUAL_TOL(0.5*displ[0]*displ[0], epert, 1e-6);
ASSERT_EQUAL_TOL(0.5*displ[0]*displ[0], epert, 1e-6);
ASSERT_EQUAL_VEC(Vec3(-lm*displ[0], 0.0, 0.0), state.getForces()[1], 1e-6);
ASSERT_EQUAL_TOL(0.0, state.getEnergyParameterDerivatives().at(ATMForce::Lambda1()), 1e-6);
ASSERT_EQUAL_TOL(0.5*displ[0]*displ[0], state.getEnergyParameterDerivatives().at(ATMForce::Lambda2()), 1e-6);
Expand Down Expand Up @@ -518,11 +518,11 @@ int main(int argc, char* argv[]) {
try {
initializeTests(argc, argv);
test2Particles();
test2Particles2Displacement0();
test2ParticlesSoftCore();
test2ParticlesNonbonded();
testParticlesCustomExpressionLinear();
testParticlesCustomExpressionSoftplus();
test2Particles2Displacement0();
test2ParticlesSoftCore();
test2ParticlesNonbonded();
testParticlesCustomExpressionLinear();
testParticlesCustomExpressionSoftplus();
testLargeSystem();
testMolecules();
testSimulation();
Expand Down

0 comments on commit f2bdcc7

Please sign in to comment.