Search in sources :

Example 1 with PiTorsionType

use of ffx.potential.parameters.PiTorsionType in project ffx by mjschnie.

the class ForceFieldFilter method parsePiTorsion.

private void parsePiTorsion(String input, String[] tokens) {
    if (tokens.length < 4) {
        logger.log(Level.WARNING, "Invalid PITORS type:\n{0}", input);
        return;
    }
    try {
        int[] atomClasses = new int[2];
        atomClasses[0] = Integer.parseInt(tokens[1]);
        atomClasses[1] = Integer.parseInt(tokens[2]);
        double forceConstant = Double.parseDouble(tokens[3]);
        PiTorsionType piTorsionType = new PiTorsionType(atomClasses, forceConstant);
        forceField.addForceFieldType(piTorsionType);
    } catch (NumberFormatException e) {
        String message = "Exception parsing PITORS type:\n" + input + "\n";
        logger.log(Level.SEVERE, message, e);
    }
}
Also used : ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) PiTorsionType(ffx.potential.parameters.PiTorsionType)

Example 2 with PiTorsionType

use of ffx.potential.parameters.PiTorsionType in project ffx by mjschnie.

the class ForceFieldEnergyOpenMM method addPiTorsionForce.

private void addPiTorsionForce() {
    PiOrbitalTorsion[] piOrbitalTorsions = super.getPiOrbitalTorsions();
    if (piOrbitalTorsions == null || piOrbitalTorsions.length < 1) {
        return;
    }
    int nPiOrbitalTorsions = piOrbitalTorsions.length;
    amoebaPiTorsionForce = OpenMM_AmoebaPiTorsionForce_create();
    double units = PiTorsionType.units;
    for (int i = 0; i < nPiOrbitalTorsions; i++) {
        PiOrbitalTorsion piOrbitalTorsion = piOrbitalTorsions[i];
        int a1 = piOrbitalTorsion.getAtom(0).getXyzIndex() - 1;
        int a2 = piOrbitalTorsion.getAtom(1).getXyzIndex() - 1;
        int a3 = piOrbitalTorsion.getAtom(2).getXyzIndex() - 1;
        int a4 = piOrbitalTorsion.getAtom(3).getXyzIndex() - 1;
        int a5 = piOrbitalTorsion.getAtom(4).getXyzIndex() - 1;
        int a6 = piOrbitalTorsion.getAtom(5).getXyzIndex() - 1;
        PiTorsionType type = piOrbitalTorsion.piTorsionType;
        OpenMM_AmoebaPiTorsionForce_addPiTorsion(amoebaPiTorsionForce, a1, a2, a3, a4, a5, a6, OpenMM_KJPerKcal * type.forceConstant * units);
    }
    OpenMM_System_addForce(system, amoebaPiTorsionForce);
    logger.log(Level.INFO, " Added Pi-Orbital Torsions ({0})", nPiOrbitalTorsions);
}
Also used : PiOrbitalTorsion(ffx.potential.bonded.PiOrbitalTorsion) PiTorsionType(ffx.potential.parameters.PiTorsionType) OpenMM_System_addConstraint(simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint) CoordRestraint(ffx.potential.nonbonded.CoordRestraint)

Example 3 with PiTorsionType

use of ffx.potential.parameters.PiTorsionType in project ffx by mjschnie.

the class PiOrbitalTorsion method piOrbitalTorsionFactory.

/**
 * Attempt to create a new PiOrbitalTorsion based on the supplied bond and
 * forceField.
 *
 * @param bond the Bond to create a PiOrbitalTorsion around.
 * @param forceField the ForceField parameters to use.
 * @return a new PiOrbitalToersion, or null.
 */
public static PiOrbitalTorsion piOrbitalTorsionFactory(Bond bond, ForceField forceField) {
    Atom atom1 = bond.getAtom(0);
    Atom atom2 = bond.getAtom(1);
    int[] c = new int[2];
    if (!atom1.isTrigonal() || !atom2.isTrigonal()) {
        return null;
    }
    c[0] = atom1.getAtomType().atomClass;
    c[1] = atom2.getAtomType().atomClass;
    String key = PiTorsionType.sortKey(c);
    PiTorsionType piTorsionType = forceField.getPiTorsionType(key);
    if (piTorsionType == null) {
        return null;
    }
    PiOrbitalTorsion piOrbitalTorsion = new PiOrbitalTorsion(bond);
    piOrbitalTorsion.piTorsionType = piTorsionType;
    return piOrbitalTorsion;
}
Also used : PiTorsionType(ffx.potential.parameters.PiTorsionType)

Aggregations

PiTorsionType (ffx.potential.parameters.PiTorsionType)3 PiOrbitalTorsion (ffx.potential.bonded.PiOrbitalTorsion)1 CoordRestraint (ffx.potential.nonbonded.CoordRestraint)1 ForceFieldString (ffx.potential.parameters.ForceField.ForceFieldString)1 OpenMM_System_addConstraint (simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint)1