Search in sources :

Example 21 with Atom

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

the class ForceFieldEnergy method checkAtoms.

public void checkAtoms() {
    double[] vel = new double[3];
    double[] accel = new double[3];
    double[] grad = new double[3];
    StringBuilder sb;
    for (int i = 0; i < nAtoms; i++) {
        Atom a = atoms[i];
        if (a.isActive()) {
            sb = new StringBuilder();
            sb.append("Atom: " + a + "\n");
            try {
                sb.append("   XYZ :  " + a.getX() + ", " + a.getY() + ", " + a.getZ() + "\n");
                a.getVelocity(vel);
                sb.append("   Vel:   " + vel[0] + ", " + vel[1] + ", " + vel[2] + "\n");
                a.getVelocity(accel);
                sb.append("   Accel: " + accel[0] + ", " + accel[1] + ", " + accel[2] + "\n");
                a.getXYZGradient(grad);
                sb.append("   Grad:  " + grad[0] + ", " + grad[1] + ", " + grad[2] + "\n");
                sb.append("   Mass:  " + a.getMass() + "\n");
                if (atoms[i].getEsv() != null) {
                    sb.append(atoms[i].getEsv().toString());
                }
            } catch (Exception e) {
            }
            logger.info(sb.toString());
        }
    }
}
Also used : COMRestraint(ffx.potential.nonbonded.COMRestraint) CoordRestraint(ffx.potential.nonbonded.CoordRestraint) NCSRestraint(ffx.potential.nonbonded.NCSRestraint) Atom(ffx.potential.bonded.Atom) EnergyException(ffx.potential.utils.EnergyException)

Example 22 with Atom

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

the class ForceFieldEnergy method setCoordinates.

/**
 * The coordinate array should only contain active atoms.
 *
 * @param coords
 */
protected void setCoordinates(double[] coords) {
    if (coords == null) {
        return;
    }
    int index = 0;
    for (int i = 0; i < nAtoms; i++) {
        Atom a = atoms[i];
        if (a.isActive() && !a.isBackground()) {
            double x = coords[index++];
            double y = coords[index++];
            double z = coords[index++];
            a.moveTo(x, y, z);
        }
    }
}
Also used : COMRestraint(ffx.potential.nonbonded.COMRestraint) CoordRestraint(ffx.potential.nonbonded.CoordRestraint) NCSRestraint(ffx.potential.nonbonded.NCSRestraint) Atom(ffx.potential.bonded.Atom)

Example 23 with Atom

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

the class ForceFieldEnergy method getMass.

/**
 * {@inheritDoc}
 */
@Override
public double[] getMass() {
    int n = getNumberOfVariables();
    double[] mass = new double[n];
    int index = 0;
    for (int i = 0; i < nAtoms; i++) {
        Atom a = atoms[i];
        if (a.isActive()) {
            double m = a.getMass();
            mass[index++] = m;
            mass[index++] = m;
            mass[index++] = m;
        }
    }
    return mass;
}
Also used : COMRestraint(ffx.potential.nonbonded.COMRestraint) CoordRestraint(ffx.potential.nonbonded.CoordRestraint) NCSRestraint(ffx.potential.nonbonded.NCSRestraint) Atom(ffx.potential.bonded.Atom)

Example 24 with Atom

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

the class ForceFieldEnergyOpenMM method setUpHydrogenConstraints.

public void setUpHydrogenConstraints(PointerByReference system) {
    int i;
    int iAtom1;
    int iAtom2;
    // Atom[] atoms = molecularAssembly.getAtomArray();
    Bond[] bonds = super.getBonds();
    logger.info(String.format(" Setting up Hydrogen constraints"));
    if (bonds == null || bonds.length < 1) {
        return;
    }
    int nBonds = bonds.length;
    Atom atom1;
    Atom atom2;
    Atom parentAtom;
    Bond bondForBondLength;
    BondType bondType;
    for (i = 0; i < nBonds; i++) {
        Bond bond = bonds[i];
        atom1 = bond.getAtom(0);
        atom2 = bond.getAtom(1);
        if (atom1.isHydrogen()) {
            parentAtom = atom1.getBonds().get(0).get1_2(atom1);
            bondForBondLength = atom1.getBonds().get(0);
            bondType = bondForBondLength.bondType;
            iAtom1 = atom1.getXyzIndex() - 1;
            iAtom2 = parentAtom.getXyzIndex() - 1;
            OpenMM_System_addConstraint(system, iAtom1, iAtom2, bondForBondLength.bondType.distance * OpenMM_NmPerAngstrom);
        } else if (atom2.isHydrogen()) {
            parentAtom = atom2.getBonds().get(0).get1_2(atom2);
            bondForBondLength = atom2.getBonds().get(0);
            bondType = bondForBondLength.bondType;
            iAtom1 = atom2.getXyzIndex() - 1;
            iAtom2 = parentAtom.getXyzIndex() - 1;
            OpenMM_System_addConstraint(system, iAtom1, iAtom2, bondForBondLength.bondType.distance * OpenMM_NmPerAngstrom);
        }
    }
}
Also used : BondType(ffx.potential.parameters.BondType) Bond(ffx.potential.bonded.Bond) OpenMM_AmoebaBondForce_addBond(simtk.openmm.AmoebaOpenMMLibrary.OpenMM_AmoebaBondForce_addBond) RestraintBond(ffx.potential.bonded.RestraintBond) OpenMM_CustomBondForce_addBond(simtk.openmm.OpenMMLibrary.OpenMM_CustomBondForce_addBond) OpenMM_HarmonicBondForce_addBond(simtk.openmm.OpenMMLibrary.OpenMM_HarmonicBondForce_addBond) OpenMM_System_addConstraint(simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint) CoordRestraint(ffx.potential.nonbonded.CoordRestraint) Atom(ffx.potential.bonded.Atom)

Example 25 with Atom

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

the class ForceFieldEnergyOpenMM method getOpenMMVelocities.

/**
 * getOpenMMVelocities takes in a PointerByReference containing the velocity
 * information of the context. This method creates a Vec3Array that contains
 * the three dimensional information of the velocities of the atoms. This
 * method then adds these values to a new double array v and returns it to
 * the method call
 *
 * @param velocities
 * @param numberOfVariables
 * @return
 */
public double[] getOpenMMVelocities(PointerByReference velocities, int numberOfVariables, double[] v) {
    assert numberOfVariables == getNumberOfVariables();
    if (v == null || v.length < numberOfVariables) {
        v = new double[numberOfVariables];
    }
    Atom[] atoms = molecularAssembly.getAtomArray();
    int nAtoms = atoms.length;
    for (int i = 0; i < nAtoms; i++) {
        int offset = i * 3;
        OpenMM_Vec3 vel = OpenMM_Vec3Array_get(velocities, i);
        v[offset] = vel.x * OpenMM_AngstromsPerNm;
        v[offset + 1] = vel.y * OpenMM_AngstromsPerNm;
        v[offset + 2] = vel.z * OpenMM_AngstromsPerNm;
        Atom atom = atoms[i];
        double[] velocity = { v[offset], v[offset + 1], v[offset + 2] };
        atom.setVelocity(velocity);
    }
    return v;
}
Also used : OpenMM_Vec3(simtk.openmm.OpenMM_Vec3) Atom(ffx.potential.bonded.Atom) OpenMM_System_addConstraint(simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint) CoordRestraint(ffx.potential.nonbonded.CoordRestraint)

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