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