Search in sources :

Example 1 with OpenMM_System_addConstraint

use of simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint 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)

Aggregations

Atom (ffx.potential.bonded.Atom)1 Bond (ffx.potential.bonded.Bond)1 RestraintBond (ffx.potential.bonded.RestraintBond)1 CoordRestraint (ffx.potential.nonbonded.CoordRestraint)1 BondType (ffx.potential.parameters.BondType)1 OpenMM_AmoebaBondForce_addBond (simtk.openmm.AmoebaOpenMMLibrary.OpenMM_AmoebaBondForce_addBond)1 OpenMM_CustomBondForce_addBond (simtk.openmm.OpenMMLibrary.OpenMM_CustomBondForce_addBond)1 OpenMM_HarmonicBondForce_addBond (simtk.openmm.OpenMMLibrary.OpenMM_HarmonicBondForce_addBond)1 OpenMM_System_addConstraint (simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint)1