Search in sources :

Example 1 with TorsionType

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

the class ForceFieldEnergyOpenMM method addTorsionForce.

private void addTorsionForce() {
    Torsion[] torsions = super.getTorsions();
    if (torsions == null || torsions.length < 1) {
        return;
    }
    int nTorsions = torsions.length;
    amoebaTorsionForce = OpenMM_PeriodicTorsionForce_create();
    for (int i = 0; i < nTorsions; i++) {
        Torsion torsion = torsions[i];
        int a1 = torsion.getAtom(0).getXyzIndex() - 1;
        int a2 = torsion.getAtom(1).getXyzIndex() - 1;
        int a3 = torsion.getAtom(2).getXyzIndex() - 1;
        int a4 = torsion.getAtom(3).getXyzIndex() - 1;
        TorsionType torsionType = torsion.torsionType;
        int nTerms = torsionType.phase.length;
        for (int j = 0; j < nTerms; j++) {
            OpenMM_PeriodicTorsionForce_addTorsion(amoebaTorsionForce, a1, a2, a3, a4, j + 1, torsionType.phase[j] * OpenMM_RadiansPerDegree, OpenMM_KJPerKcal * torsion.units * torsionType.amplitude[j]);
        }
    }
    OpenMM_System_addForce(system, amoebaTorsionForce);
    logger.log(Level.INFO, " Added Torsions ({0})", nTorsions);
}
Also used : TorsionTorsionType(ffx.potential.parameters.TorsionTorsionType) ImproperTorsionType(ffx.potential.parameters.ImproperTorsionType) PiTorsionType(ffx.potential.parameters.PiTorsionType) TorsionType(ffx.potential.parameters.TorsionType) Torsion(ffx.potential.bonded.Torsion) OpenMM_AmoebaTorsionTorsionForce_addTorsionTorsion(simtk.openmm.AmoebaOpenMMLibrary.OpenMM_AmoebaTorsionTorsionForce_addTorsionTorsion) TorsionTorsion(ffx.potential.bonded.TorsionTorsion) OpenMM_PeriodicTorsionForce_addTorsion(simtk.openmm.OpenMMLibrary.OpenMM_PeriodicTorsionForce_addTorsion) PiOrbitalTorsion(ffx.potential.bonded.PiOrbitalTorsion) OpenMM_AmoebaPiTorsionForce_addPiTorsion(simtk.openmm.AmoebaOpenMMLibrary.OpenMM_AmoebaPiTorsionForce_addPiTorsion) ImproperTorsion(ffx.potential.bonded.ImproperTorsion) OpenMM_System_addConstraint(simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint) CoordRestraint(ffx.potential.nonbonded.CoordRestraint)

Example 2 with TorsionType

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

the class Torsion method torsionFactory.

/**
 * Attempt to create a new Torsion based on the supplied bonds. There is no
 * error checking to enforce that the bonds make up a linear series of 4
 * bonded atoms.
 *
 * @param bond1 the first Bond.
 * @param middleBond the middle Bond.
 * @param bond3 the last Bond.
 * @param forceField the ForceField parameters to apply.
 * @return a new Torsion, or null.
 */
public static Torsion torsionFactory(Bond bond1, Bond middleBond, Bond bond3, ForceField forceField) {
    Atom atom1 = middleBond.getAtom(0);
    Atom atom2 = middleBond.getAtom(1);
    int[] c = new int[4];
    c[0] = bond1.getOtherAtom(middleBond).getAtomType().atomClass;
    c[1] = atom1.getAtomType().atomClass;
    c[2] = atom2.getAtomType().atomClass;
    c[3] = bond3.getOtherAtom(middleBond).getAtomType().atomClass;
    String key = TorsionType.sortKey(c);
    TorsionType torsionType = forceField.getTorsionType(key);
    if (torsionType == null) {
        c[0] = bond1.getOtherAtom(middleBond).getAtomType().atomClass;
        c[1] = atom1.getAtomType().atomClass;
        c[2] = atom2.getAtomType().atomClass;
        c[3] = 0;
        key = TorsionType.sortKey(c);
        torsionType = forceField.getTorsionType(key);
    }
    if (torsionType == null) {
        c[0] = 0;
        c[1] = atom1.getAtomType().atomClass;
        c[2] = atom2.getAtomType().atomClass;
        c[3] = bond3.getOtherAtom(middleBond).getAtomType().atomClass;
        key = TorsionType.sortKey(c);
        torsionType = forceField.getTorsionType(key);
    }
    if (torsionType == null) {
        c[0] = 0;
        c[1] = atom1.getAtomType().atomClass;
        c[2] = atom2.getAtomType().atomClass;
        c[3] = 0;
        key = TorsionType.sortKey(c);
        torsionType = forceField.getTorsionType(key);
    }
    if (torsionType == null) {
        c[0] = bond1.getOtherAtom(middleBond).getAtomType().atomClass;
        c[1] = atom1.getAtomType().atomClass;
        c[2] = atom2.getAtomType().atomClass;
        c[3] = bond3.getOtherAtom(middleBond).getAtomType().atomClass;
        key = TorsionType.sortKey(c);
        logger.severe(format("No TorsionType for key: %s\n%s\n%s\n%s\n", key, bond1.toString(), middleBond.toString(), bond3.toString()));
        return null;
    }
    Torsion torsion = new Torsion(bond1, middleBond, bond3);
    torsion.torsionType = torsionType;
    torsion.units = forceField.getDouble(ForceField.ForceFieldDouble.TORSIONUNIT, 0.5);
    return torsion;
}
Also used : TorsionType(ffx.potential.parameters.TorsionType)

Example 3 with TorsionType

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

the class MultiTerminus method updateBondedTerms.

private void updateBondedTerms() {
    StringBuilder sb = new StringBuilder();
    sb.append(String.format("Updating bonded terms: \n"));
    List<ROLS> bonds = getBondList();
    for (int i = 0; i < bonds.size(); i++) {
        Bond bond = (Bond) bonds.get(i);
        BondType oldType = bond.bondType;
        int[] c = new int[2];
        c[0] = bond.atoms[0].getAtomType().atomClass;
        c[1] = bond.atoms[1].getAtomType().atomClass;
        String key = BondType.sortKey(c);
        BondType newType = forceField.getBondType(key);
        if (oldType != newType) {
            sb.append(String.format(" Bond: %s --> %s \n", bond.bondType, newType));
            bond.setBondType(newType);
            if (newType.distance < 0.9 * oldType.distance || newType.distance > 1.1 * oldType.distance) {
                logger.info(String.format(" Large bond distance change: %s %s,  %.2f --> %.2f ", bond.atoms[0].describe(Atom.Descriptions.XyzIndex_Name), bond.atoms[1].describe(Atom.Descriptions.XyzIndex_Name), oldType.distance, newType.distance));
            }
        }
    }
    List<ROLS> angles = getAngleList();
    for (int i = 0; i < angles.size(); i++) {
        Angle angle = (Angle) angles.get(i);
        AngleType oldType = angle.angleType;
        if (DEBUG) {
            logger.info(String.format(" %d ( %s %s %s ) ( %d %d %d )", i, angle.atoms[0].describe(Atom.Descriptions.XyzIndex_Name), angle.atoms[1].describe(Atom.Descriptions.XyzIndex_Name), angle.atoms[2].describe(Atom.Descriptions.XyzIndex_Name), angle.atoms[0].getAtomType().atomClass, angle.atoms[1].getAtomType().atomClass, angle.atoms[2].getAtomType().atomClass));
        }
        Angle dummy = Angle.angleFactory(angle.bonds[0], angle.bonds[1], forceField);
        AngleType newType = dummy.angleType;
        if (oldType != newType) {
            sb.append(String.format(" Angle: %s --> %s \n", angle.angleType, dummy.angleType));
            angle.setAngleType(dummy.angleType);
            if (newType.angle[0] < 0.9 * oldType.angle[0] || newType.angle[0] > 1.1 * oldType.angle[0]) {
                logger.info(String.format(" Large angle change: %s %s %s,  %.2f --> %.2f ", angle.atoms[0].describe(Atom.Descriptions.XyzIndex_Name), angle.atoms[1].describe(Atom.Descriptions.XyzIndex_Name), angle.atoms[2].describe(Atom.Descriptions.XyzIndex_Name), oldType.angle[0], newType.angle[0]));
            }
        }
    }
    List<ROLS> torsions = getTorsionList();
    for (int i = 0; i < torsions.size(); i++) {
        Torsion tors = (Torsion) torsions.get(i);
        TorsionType oldType = tors.torsionType;
        Torsion dummy = Torsion.torsionFactory(tors.bonds[0], tors.bonds[1], tors.bonds[2], forceField);
        TorsionType newType = dummy.torsionType;
        if (oldType != newType) {
            sb.append(String.format(" Torsion: %s --> %s \n", tors.torsionType, dummy.torsionType));
            tors.torsionType = dummy.torsionType;
        }
    }
    if (DEBUG) {
        logger.info(sb.toString());
    }
}
Also used : BondType(ffx.potential.parameters.BondType) TorsionType(ffx.potential.parameters.TorsionType) AngleType(ffx.potential.parameters.AngleType) BondedUtils.buildBond(ffx.potential.bonded.BondedUtils.buildBond)

Example 4 with TorsionType

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

the class ForceFieldFilter method parseTorsion.

private void parseTorsion(String input, String[] tokens) {
    if (tokens.length < 5) {
        logger.log(Level.WARNING, "Invalid TORSION type:\n{0}", input);
        return;
    }
    try {
        int[] atomClasses = new int[4];
        atomClasses[0] = Integer.parseInt(tokens[1]);
        atomClasses[1] = Integer.parseInt(tokens[2]);
        atomClasses[2] = Integer.parseInt(tokens[3]);
        atomClasses[3] = Integer.parseInt(tokens[4]);
        int terms = (tokens.length - 5) / 3;
        double[] amplitude = new double[terms];
        double[] phase = new double[terms];
        int[] periodicity = new int[terms];
        int index = 5;
        for (int i = 0; i < terms; i++) {
            amplitude[i] = Double.parseDouble(tokens[index++]);
            phase[i] = Double.parseDouble(tokens[index++]);
            periodicity[i] = Integer.parseInt(tokens[index++]);
            if (torsionScale > 0.0) {
                amplitude[i] = amplitude[i] * torsionScale;
            }
        }
        TorsionType torsionType = new TorsionType(atomClasses, amplitude, phase, periodicity);
        forceField.addForceFieldType(torsionType);
    } catch (NumberFormatException e) {
        String message = "Exception parsing TORSION type:\n" + input + "\n";
        logger.log(Level.SEVERE, message, e);
    }
}
Also used : TorsionTorsionType(ffx.potential.parameters.TorsionTorsionType) TorsionType(ffx.potential.parameters.TorsionType) ImproperTorsionType(ffx.potential.parameters.ImproperTorsionType) PiTorsionType(ffx.potential.parameters.PiTorsionType) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString)

Aggregations

TorsionType (ffx.potential.parameters.TorsionType)4 ImproperTorsionType (ffx.potential.parameters.ImproperTorsionType)2 PiTorsionType (ffx.potential.parameters.PiTorsionType)2 TorsionTorsionType (ffx.potential.parameters.TorsionTorsionType)2 BondedUtils.buildBond (ffx.potential.bonded.BondedUtils.buildBond)1 ImproperTorsion (ffx.potential.bonded.ImproperTorsion)1 PiOrbitalTorsion (ffx.potential.bonded.PiOrbitalTorsion)1 Torsion (ffx.potential.bonded.Torsion)1 TorsionTorsion (ffx.potential.bonded.TorsionTorsion)1 CoordRestraint (ffx.potential.nonbonded.CoordRestraint)1 AngleType (ffx.potential.parameters.AngleType)1 BondType (ffx.potential.parameters.BondType)1 ForceFieldString (ffx.potential.parameters.ForceField.ForceFieldString)1 OpenMM_AmoebaPiTorsionForce_addPiTorsion (simtk.openmm.AmoebaOpenMMLibrary.OpenMM_AmoebaPiTorsionForce_addPiTorsion)1 OpenMM_AmoebaTorsionTorsionForce_addTorsionTorsion (simtk.openmm.AmoebaOpenMMLibrary.OpenMM_AmoebaTorsionTorsionForce_addTorsionTorsion)1 OpenMM_PeriodicTorsionForce_addTorsion (simtk.openmm.OpenMMLibrary.OpenMM_PeriodicTorsionForce_addTorsion)1 OpenMM_System_addConstraint (simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint)1