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);
}
}
}
Aggregations