com.actelion.research.chem.forcefield.mmff.PositionConstraint 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 PositionConstraint implements EnergyTerm {
private double[] refPos;
private boolean[] constrained;
private double k;
private double d;
public PositionConstraint (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);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy