Search in sources :

Example 1 with AngleType

use of ffx.potential.parameters.AngleType 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 2 with AngleType

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

the class ForceFieldFilter method parseAngle.

private void parseAngle(String input, String[] tokens) {
    if (tokens.length < 6) {
        logger.log(Level.WARNING, "Invalid ANGLE type:\n{0}", input);
        return;
    }
    int[] atomClasses = new int[3];
    double forceConstant = 0.0;
    int angles = 0;
    double[] bondAngle = null;
    try {
        atomClasses[0] = Integer.parseInt(tokens[1]);
        atomClasses[1] = Integer.parseInt(tokens[2]);
        atomClasses[2] = Integer.parseInt(tokens[3]);
        forceConstant = Double.parseDouble(tokens[4]);
        angles = tokens.length - 5;
        bondAngle = new double[angles];
        for (int i = 0; i < angles; i++) {
            bondAngle[i] = Double.parseDouble(tokens[5 + i]);
        }
    } catch (NumberFormatException e) {
        String message = "Exception parsing ANGLE type:\n" + input + "\n";
        logger.log(Level.SEVERE, message, e);
    }
    double[] newBondAngle = new double[angles];
    System.arraycopy(bondAngle, 0, newBondAngle, 0, angles);
    String forceFieldName = forceField.toString().toUpperCase();
    AngleType angleType;
    if (forceFieldName.contains("OPLS") || forceFieldName.contains("AMBER")) {
        angleType = new AngleType(atomClasses, forceConstant, newBondAngle, AngleType.AngleFunction.HARMONIC);
    } else {
        angleType = new AngleType(atomClasses, forceConstant, newBondAngle, AngleType.AngleFunction.SEXTIC);
    }
    forceField.addForceFieldType(angleType);
}
Also used : AngleType(ffx.potential.parameters.AngleType) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString)

Example 3 with AngleType

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

the class Angle method angleFactory.

public static Angle angleFactory(Bond b1, Bond b2, ForceField forceField) {
    Angle newAngle = new Angle(b1, b2);
    Atom ac = b1.getCommonAtom(b2);
    Atom a1 = b1.get1_2(ac);
    Atom a3 = b2.get1_2(ac);
    int[] c = new int[3];
    c[0] = a1.getAtomType().atomClass;
    c[1] = ac.getAtomType().atomClass;
    c[2] = a3.getAtomType().atomClass;
    String key = AngleType.sortKey(c);
    AngleType angleType = forceField.getAngleType(key);
    if (angleType == null) {
        logger.severe("No AngleType for key: " + key);
        return null;
    }
    newAngle.setAngleType(angleType);
    return newAngle;
}
Also used : AngleType(ffx.potential.parameters.AngleType)

Aggregations

AngleType (ffx.potential.parameters.AngleType)3 BondedUtils.buildBond (ffx.potential.bonded.BondedUtils.buildBond)1 BondType (ffx.potential.parameters.BondType)1 ForceFieldString (ffx.potential.parameters.ForceField.ForceFieldString)1 TorsionType (ffx.potential.parameters.TorsionType)1