com.actelion.research.chem.forcefield.mmff.MMFFPositionConstraint Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openchemlib Show documentation
Show all versions of openchemlib Show documentation
Open Source Chemistry Library
package com.actelion.research.chem.forcefield.mmff;
import com.actelion.research.chem.StereoMolecule;
public class MMFFPositionConstraint implements EnergyTerm {
private double[] refPos;
private boolean[] constrained;
private double k;
private double d;
public MMFFPositionConstraint (StereoMolecule mol, double k, double d) {
refPos = new double[3*mol.getAllAtoms()];
constrained = new boolean[mol.getAllAtoms()];
for(int a=0;ad)
prefactor = dist-d;
else
prefactor = 0.0;
energy+=0.5*k*prefactor*prefactor;
}
return energy;
}
@Override
public void getGradient(double[] pos, double[] grad) {
for(int a=0;ad)
prefactor = dist-d;
else
prefactor = 0.0;
grad[a] += prefactor*dx/Math.max(dist, 1E-08);
grad[a+1] += prefactor*dy/Math.max(dist, 1E-08);
grad[a+2] += prefactor*dz/Math.max(dist, 1E-08);
}
}
}