1
package org.openscience.cdk.modeling.forcefield;
3
import javax.vecmath.GVector;
5
import org.openscience.cdk.AtomContainer;
6
import org.openscience.cdk.Molecule;
7
import org.openscience.cdk.graph.ConnectivityChecker;
8
//import org.openscience.cdk.tools.LoggingTool;
11
* To work with the coordinates of the molecule, like get the 3d coordinates of the atoms or
12
* calculate the distance between two atoms.
14
*@cdk.module forcefield
17
public class ForceField extends GeometricMinimizer{
19
private String potentialFunction="mmff94";
21
boolean sdm_flag=true;
22
boolean cgm_flag=true;
23
boolean nrm_flag=true;
25
//private LoggingTool logger;
29
* Constructor for the ForceField object
32
//logger = new LoggingTool(this);
35
public ForceField(Molecule molecule) throws Exception {
36
setMolecule(molecule, false);
37
//logger = new LoggingTool(this);
41
public void setPotentialFunction(String potentialName){
42
potentialFunction=potentialName;
45
public void setUsedGMMethods(boolean sdm, boolean cgm,boolean nrm){
51
public void minimize( ) throws Exception{
53
if (!ConnectivityChecker.isConnected(molecule)) {
54
throw new Exception("CDKError: Molecule is NOT connected,could not layout.");
56
GVector moleculeCoords = new GVector(3);
57
MMFF94EnergyFunction mmff94PF=null;
58
if (potentialFunction=="mmff94"){
59
//logger.debug("SET POTENTIAL FUNCTION TO MMFF94");
60
setMMFF94Tables(molecule);
61
mmff94PF=new MMFF94EnergyFunction((AtomContainer)molecule,getPotentialParameterSet());
62
//logger.debug("PotentialFunction set:"+potentialFunction+", Hashtable:" +getPotentialParameterSet().size());
64
moleculeCoords.setSize(molecule.getAtomCount() * 3);
65
moleculeCoords.set(ForceFieldTools.getCoordinates3xNVector((AtomContainer)molecule));
67
//logger.debug("PotentialFunction set:"+potentialFunction+" Molecule Coords set:"+moleculeCoords.getSize()+" Hashtable:"+getPotentialParameterSet().size());
68
//logger.debug(moleculeCoords.toString());
69
start = System.currentTimeMillis();
70
//logger.debug("Starting minmization at " + start);
71
if (sdm_flag) steepestDescentsMinimization(moleculeCoords,mmff94PF);
73
if (cgm_flag)conjugateGradientMinimization(moleculeCoords, mmff94PF);
74
//conjugateGradientMinimization(moleculeCoords, tpf);
75
stop = System.currentTimeMillis();
76
//logger.debug("Finished minmization at " + stop);
77
//if ((stop - start)/1000 < 60) {
78
//logger.debug("Time for minimization: " + (stop - start)/1000 + " sec");
80
// logger.debug("Time for minimization: " + (stop - start)/60000 + " min");
83
//logger.debug("Minimization READY");
84
//ForceFieldTools.assignCoordinatesToMolecule(moleculeCoords, (AtomContainer) molecule);