Search in sources :

Example 1 with OpenMM_AmoebaAngleForce_addAngle

use of simtk.openmm.AmoebaOpenMMLibrary.OpenMM_AmoebaAngleForce_addAngle in project ffx by mjschnie.

the class ForceFieldEnergyOpenMM method addAngleForce.

private void addAngleForce() {
    Angle[] angles = super.getAngles();
    if (angles == null || angles.length < 1) {
        return;
    }
    int nAngles = angles.length;
    List<Angle> normalAngles = new ArrayList<>();
    // Sort all normal angles from in-plane angles
    for (int i = 0; i < nAngles; i++) {
        if (angles[i].getAngleMode() == Angle.AngleMode.NORMAL) {
            normalAngles.add(angles[i]);
        }
    }
    nAngles = normalAngles.size();
    if (nAngles < 1) {
        return;
    }
    amoebaAngleForce = OpenMM_AmoebaAngleForce_create();
    for (int i = 0; i < nAngles; i++) {
        Angle angle = normalAngles.get(i);
        int i1 = angle.getAtom(0).getXyzIndex() - 1;
        int i2 = angle.getAtom(1).getXyzIndex() - 1;
        int i3 = angle.getAtom(2).getXyzIndex() - 1;
        int nh = angle.nh;
        OpenMM_AmoebaAngleForce_addAngle(amoebaAngleForce, i1, i2, i3, angle.angleType.angle[nh], OpenMM_KJPerKcal * AngleType.units * angle.angleType.forceConstant);
    }
    if (angles[0].angleType.angleFunction == AngleFunction.SEXTIC) {
        OpenMM_AmoebaAngleForce_setAmoebaGlobalAngleCubic(amoebaAngleForce, AngleType.cubic);
        OpenMM_AmoebaAngleForce_setAmoebaGlobalAngleQuartic(amoebaAngleForce, AngleType.quartic);
        OpenMM_AmoebaAngleForce_setAmoebaGlobalAnglePentic(amoebaAngleForce, AngleType.quintic);
        OpenMM_AmoebaAngleForce_setAmoebaGlobalAngleSextic(amoebaAngleForce, AngleType.sextic);
    }
    OpenMM_System_addForce(system, amoebaAngleForce);
    logger.log(Level.INFO, " Added angles ({0})", nAngles);
}
Also used : Angle(ffx.potential.bonded.Angle) OpenMM_AmoebaAngleForce_addAngle(simtk.openmm.AmoebaOpenMMLibrary.OpenMM_AmoebaAngleForce_addAngle) OpenMM_AmoebaInPlaneAngleForce_addAngle(simtk.openmm.AmoebaOpenMMLibrary.OpenMM_AmoebaInPlaneAngleForce_addAngle) ArrayList(java.util.ArrayList) OpenMM_System_addConstraint(simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint) CoordRestraint(ffx.potential.nonbonded.CoordRestraint)

Aggregations

Angle (ffx.potential.bonded.Angle)1 CoordRestraint (ffx.potential.nonbonded.CoordRestraint)1 ArrayList (java.util.ArrayList)1 OpenMM_AmoebaAngleForce_addAngle (simtk.openmm.AmoebaOpenMMLibrary.OpenMM_AmoebaAngleForce_addAngle)1 OpenMM_AmoebaInPlaneAngleForce_addAngle (simtk.openmm.AmoebaOpenMMLibrary.OpenMM_AmoebaInPlaneAngleForce_addAngle)1 OpenMM_System_addConstraint (simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint)1