Search in sources :

Example 71 with Atom

use of ffx.potential.bonded.Atom in project ffx by mjschnie.

the class TitrationUtils method rebuildStrandedProtons.

/**
 * Rebuild stranded titratable protons from ideal geometry. "Stranded
 * protons" are titrating H+ atoms on inactive MultiRes members; when
 * propagating new coordinates to inactive residues, no coords/velocity
 * exist for them.
 */
private static void rebuildStrandedProtons(MultiResidue multiRes) {
    // If inactive residue is a protonated form, move the stranded hydrogen to new coords (based on propagated heavies).
    // Also give the stranded hydrogen a maxwell velocity and remove its accelerations.
    List<Residue> inactives = multiRes.getInactive();
    for (Residue inactive : inactives) {
        List<Atom> resetMe = new ArrayList<>();
        switch(inactive.getName()) {
            case "LYS":
                {
                    Atom HZ3 = (Atom) inactive.getAtomNode("HZ3");
                    Atom NZ = (Atom) inactive.getAtomNode("NZ");
                    Atom CE = (Atom) inactive.getAtomNode("CE");
                    Atom HZ1 = (Atom) inactive.getAtomNode("HZ1");
                    BondedUtils.intxyz(HZ3, NZ, 1.02, CE, 109.5, HZ1, 109.5, -1);
                    resetMe.add(HZ3);
                    break;
                }
            case "ASH":
                {
                    Atom HD2 = (Atom) inactive.getAtomNode("HD2");
                    Atom OD2 = (Atom) inactive.getAtomNode("OD2");
                    Atom CG = (Atom) inactive.getAtomNode("CG");
                    Atom OD1 = (Atom) inactive.getAtomNode("OD1");
                    BondedUtils.intxyz(HD2, OD2, 0.98, CG, 108.7, OD1, 0.0, 0);
                    resetMe.add(HD2);
                    break;
                }
            case "GLH":
                {
                    Atom HE2 = (Atom) inactive.getAtomNode("HE2");
                    Atom OE2 = (Atom) inactive.getAtomNode("OE2");
                    Atom CD = (Atom) inactive.getAtomNode("CD");
                    Atom OE1 = (Atom) inactive.getAtomNode("OE1");
                    BondedUtils.intxyz(HE2, OE2, 0.98, CD, 108.7, OE1, 0.0, 0);
                    resetMe.add(HE2);
                    break;
                }
            case "HIS":
                {
                    Atom HE2 = (Atom) inactive.getAtomNode("HE2");
                    Atom NE2 = (Atom) inactive.getAtomNode("NE2");
                    Atom CD2 = (Atom) inactive.getAtomNode("CD2");
                    Atom CE1 = (Atom) inactive.getAtomNode("CE1");
                    Atom HD1 = (Atom) inactive.getAtomNode("HD1");
                    Atom ND1 = (Atom) inactive.getAtomNode("ND1");
                    Atom CG = (Atom) inactive.getAtomNode("CG");
                    Atom CB = (Atom) inactive.getAtomNode("CB");
                    BondedUtils.intxyz(HE2, NE2, 1.02, CD2, 126.0, CE1, 126.0, 1);
                    BondedUtils.intxyz(HD1, ND1, 1.02, CG, 126.0, CB, 0.0, 0);
                    resetMe.add(HE2);
                    resetMe.add(HD1);
                    break;
                }
            case "HID":
                {
                    Atom HD1 = (Atom) inactive.getAtomNode("HD1");
                    Atom ND1 = (Atom) inactive.getAtomNode("ND1");
                    Atom CG = (Atom) inactive.getAtomNode("CG");
                    Atom CB = (Atom) inactive.getAtomNode("CB");
                    BondedUtils.intxyz(HD1, ND1, 1.02, CG, 126.0, CB, 0.0, 0);
                    resetMe.add(HD1);
                    break;
                }
            case "HIE":
                {
                    Atom HE2 = (Atom) inactive.getAtomNode("HE2");
                    Atom NE2 = (Atom) inactive.getAtomNode("NE2");
                    Atom CD2 = (Atom) inactive.getAtomNode("CD2");
                    Atom CE1 = (Atom) inactive.getAtomNode("CE1");
                    BondedUtils.intxyz(HE2, NE2, 1.02, CD2, 126.0, CE1, 126.0, 1);
                    resetMe.add(HE2);
                    break;
                }
            case "CYS":
                {
                    Atom HG = (Atom) inactive.getAtomNode("HG");
                    Atom SG = (Atom) inactive.getAtomNode("SG");
                    Atom CB = (Atom) inactive.getAtomNode("CB");
                    Atom CA = (Atom) inactive.getAtomNode("CA");
                    BondedUtils.intxyz(HG, SG, 1.34, CB, 96.0, CA, 180.0, 0);
                    resetMe.add(HG);
                    break;
                }
            case "TYR":
                {
                    Atom HH = (Atom) inactive.getAtomNode("HH");
                    Atom OH = (Atom) inactive.getAtomNode("OH");
                    Atom CZ = (Atom) inactive.getAtomNode("CZ");
                    Atom CE2 = (Atom) inactive.getAtomNode("CE2");
                    BondedUtils.intxyz(HH, OH, 0.97, CZ, 108.0, CE2, 0.0, 0);
                    resetMe.add(HH);
                    break;
                }
            default:
        }
        for (Atom a : resetMe) {
            if (heavyStrandedDynamics) {
                // Use of heavy atom dynamics properties is in testing.
                a.setXYZGradient(0, 0, 0);
                double[] heavyVelocity = new double[3];
                double[] heavyAccel = new double[3];
                double[] heavyPrevAccel = new double[3];
                Atom heavy = a.getBonds().get(0).get1_2(a);
                heavy.getVelocity(heavyVelocity);
                heavy.getAcceleration(heavyAccel);
                heavy.getPreviousAcceleration(heavyPrevAccel);
                a.setVelocity(heavyVelocity);
                a.setAcceleration(heavyAccel);
                a.setPreviousAcceleration(heavyPrevAccel);
            } else {
                // PREVIOUSLY: draw vel from maxwell and set accel to zero
                a.setXYZGradient(0, 0, 0);
                a.setVelocity(ExtUtils.maxwellVelocity(a.getMass(), ExtConstants.roomTemperature));
                a.setAcceleration(new double[] { 0, 0, 0 });
                a.setPreviousAcceleration(new double[] { 0, 0, 0 });
            }
        }
    }
}
Also used : MultiResidue(ffx.potential.bonded.MultiResidue) Residue(ffx.potential.bonded.Residue) ArrayList(java.util.ArrayList) Atom(ffx.potential.bonded.Atom)

Example 72 with Atom

use of ffx.potential.bonded.Atom in project ffx by mjschnie.

the class TitrationUtils method renumberAtoms.

public static void renumberAtoms(MolecularAssembly mola) {
    Atom[] atoms = mola.getAtomArray();
    int setter = 0;
    for (Atom atom : atoms) {
        atom.setXyzIndex(setter++);
    }
}
Also used : Atom(ffx.potential.bonded.Atom)

Example 73 with Atom

use of ffx.potential.bonded.Atom in project ffx by mjschnie.

the class NeighborList method getNeighborAtoms.

/**
 * Returns a set of Atoms neighboring those passed in. If their indices are
 * already available, preferentially use getNeighborIndices instead. Is
 * exclusive of passed atoms.
 *
 * @param atomList Atoms to find neighbors of
 * @param maxDist Maximum distance to consider a neighbor
 * @return Set of neighboring Atoms
 */
public Set<Atom> getNeighborAtoms(List<Atom> atomList, double maxDist) {
    // return getNeighborIndices(atomsToIndices(atomList), maxDist).stream().map(i -> atoms[i]).collect(Collectors.toSet());
    Set<Integer> atomIndices = getNeighborIndices(atomsToIndices(atomList), maxDist);
    Set<Atom> atomSet = new HashSet<>();
    for (Integer ai : atomIndices) {
        atomSet.add(atoms[ai]);
    }
    return atomSet;
}
Also used : SharedInteger(edu.rit.pj.reduction.SharedInteger) Atom(ffx.potential.bonded.Atom) HashSet(java.util.HashSet)

Example 74 with Atom

use of ffx.potential.bonded.Atom in project ffx by mjschnie.

the class COMRestraint method computedcomdx.

private void computedcomdx() {
    // double totalMass = 0.0;
    int i = 0;
    while (i < nAtoms) {
        if (polymers != null && polymers.length > 0) {
            for (Polymer polymer : polymers) {
                List<Atom> list = polymer.getAtomList();
                double totalMass = 0.0;
                for (Atom atom : list) {
                    double m = atom.getMass();
                    totalMass += m;
                }
                for (Atom atom : list) {
                    dcomdx[i] = atom.getMass();
                    dcomdx[i] /= totalMass;
                    i++;
                }
            }
        }
        // Loop over each molecule
        for (MSNode molecule : molecules) {
            List<Atom> list = molecule.getAtomList();
            double totalMass = 0.0;
            for (Atom atom : list) {
                double m = atom.getMass();
                totalMass += m;
            }
            for (Atom atom : list) {
                dcomdx[i] = atom.getMass();
                dcomdx[i] /= totalMass;
                i++;
            }
        }
        // Loop over each water
        for (MSNode water : waters) {
            List<Atom> list = water.getAtomList();
            double totalMass = 0.0;
            for (Atom atom : list) {
                double m = atom.getMass();
                totalMass += m;
            }
            for (Atom atom : list) {
                dcomdx[i] = atom.getMass();
                dcomdx[i] /= totalMass;
                i++;
            }
        }
        // Loop over each ion
        for (MSNode ion : ions) {
            List<Atom> list = ion.getAtomList();
            double totalMass = 0.0;
            for (Atom atom : list) {
                double m = atom.getMass();
                totalMass += m;
            }
            for (Atom atom : list) {
                dcomdx[i] = atom.getMass();
                dcomdx[i] /= totalMass;
                i++;
            }
        }
    }
// for (int i = 0; i < nAtoms; i++) {
// Atom a = atoms[i];
// dcomdx[j] = a.getMass() / totalMass;
// }
}
Also used : MSNode(ffx.potential.bonded.MSNode) Polymer(ffx.potential.bonded.Polymer) Atom(ffx.potential.bonded.Atom)

Example 75 with Atom

use of ffx.potential.bonded.Atom in project ffx by mjschnie.

the class COMRestraint method residual.

public double residual(boolean gradient, boolean print) {
    if (lambdaTerm) {
        dEdL = 0.0;
        d2EdL2 = 0.0;
        fill(lambdaGradient, 0.0);
    }
    double residual = 0.0;
    double fx2 = forceConstant * 2.0;
    // boolean computedcomdx = true;
    // fill(currentCOM, 0.0);
    computeCOM(currentCOM, nMolecules);
    computedcomdx();
    for (int i = 0; i < nMolecules; i++) {
        dx[0] = currentCOM[0][i] - initialCOM[0][i];
        dx[1] = currentCOM[1][i] - initialCOM[1][i];
        dx[2] = currentCOM[2][i] - initialCOM[2][i];
        double r2 = rsq(dx);
        residual += r2;
        for (int j = 0; j < nAtoms; j++) {
            if (gradient || lambdaTerm) {
                final double dedx = dx[0] * fx2 * dcomdx[j];
                final double dedy = dx[1] * fx2 * dcomdx[j];
                final double dedz = dx[2] * fx2 * dcomdx[j];
                // Current atomic coordinates.
                Atom atom = atoms[j];
                if (gradient) {
                    atom.addToXYZGradient(lambdaPow * dedx, lambdaPow * dedy, lambdaPow * dedz);
                }
                if (lambdaTerm) {
                    int j3 = i * 3;
                    lambdaGradient[j3] = dLambdaPow * dedx;
                    lambdaGradient[j3 + 1] = dLambdaPow * dedy;
                    lambdaGradient[j3 + 2] = dLambdaPow * dedz;
                }
            }
        }
    }
    if (lambdaTerm) {
        dEdL = dLambdaPow * forceConstant * residual;
        d2EdL2 = d2LambdaPow * forceConstant * residual;
    }
    return forceConstant * residual * lambdaPow;
}
Also used : Atom(ffx.potential.bonded.Atom)

Aggregations

Atom (ffx.potential.bonded.Atom)206 Residue (ffx.potential.bonded.Residue)42 Bond (ffx.potential.bonded.Bond)37 CoordRestraint (ffx.potential.nonbonded.CoordRestraint)34 ArrayList (java.util.ArrayList)33 OpenMM_System_addConstraint (simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint)23 Polymer (ffx.potential.bonded.Polymer)22 IOException (java.io.IOException)22 MSNode (ffx.potential.bonded.MSNode)21 Crystal (ffx.crystal.Crystal)20 Molecule (ffx.potential.bonded.Molecule)19 File (java.io.File)19 MultiResidue (ffx.potential.bonded.MultiResidue)17 MultipoleType (ffx.potential.parameters.MultipoleType)13 MissingHeavyAtomException (ffx.potential.bonded.BondedUtils.MissingHeavyAtomException)12 PointerByReference (com.sun.jna.ptr.PointerByReference)11 MissingAtomTypeException (ffx.potential.bonded.BondedUtils.MissingAtomTypeException)11 AtomType (ffx.potential.parameters.AtomType)11 List (java.util.List)11 MolecularAssembly (ffx.potential.MolecularAssembly)10