~ubuntu-branches/ubuntu/maverick/cdk/maverick

« back to all changes in this revision

Viewing changes to src/org/openscience/cdk/modeling/forcefield/ForceField.java

  • Committer: Bazaar Package Importer
  • Author(s): Paul Cager
  • Date: 2008-04-09 21:17:53 UTC
  • Revision ID: james.westby@ubuntu.com-20080409211753-46lmjw5z8mx5pd8d
Tags: upstream-1.0.2
ImportĀ upstreamĀ versionĀ 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.openscience.cdk.modeling.forcefield;
 
2
 
 
3
import javax.vecmath.GVector;
 
4
 
 
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;
 
9
 
 
10
/**
 
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.
 
13
 *@author     vlabarta
 
14
 *@cdk.module     forcefield
 
15
 *
 
16
 */
 
17
public class ForceField extends GeometricMinimizer{
 
18
        
 
19
        private String potentialFunction="mmff94";
 
20
        
 
21
        boolean sdm_flag=true;
 
22
        boolean cgm_flag=true;
 
23
        boolean nrm_flag=true;
 
24
        
 
25
        //private LoggingTool logger;
 
26
 
 
27
 
 
28
        /**
 
29
         *  Constructor for the ForceField object
 
30
         */
 
31
        public ForceField() {        
 
32
                //logger = new LoggingTool(this);
 
33
        }
 
34
        
 
35
        public ForceField(Molecule molecule) throws Exception {
 
36
                setMolecule(molecule, false);
 
37
                //logger = new LoggingTool(this);
 
38
        }
 
39
 
 
40
 
 
41
        public void setPotentialFunction(String potentialName){
 
42
                potentialFunction=potentialName;
 
43
        }
 
44
        
 
45
        public void setUsedGMMethods(boolean sdm, boolean cgm,boolean nrm){
 
46
               sdm_flag=sdm;
 
47
               cgm_flag=cgm;
 
48
               nrm_flag=nrm;
 
49
        }
 
50
        
 
51
        public void minimize( ) throws Exception{
 
52
                long start, stop;
 
53
                if (!ConnectivityChecker.isConnected(molecule)) {
 
54
                        throw new Exception("CDKError: Molecule is NOT connected,could not layout.");
 
55
                }
 
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());
 
63
                }
 
64
                moleculeCoords.setSize(molecule.getAtomCount() * 3);
 
65
                moleculeCoords.set(ForceFieldTools.getCoordinates3xNVector((AtomContainer)molecule));
 
66
                
 
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);
 
72
 
 
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");
 
79
                //}
 
80
                //      logger.debug("Time for minimization: " + (stop - start)/60000 + " min");
 
81
 
 
82
                //}
 
83
                //logger.debug("Minimization READY");
 
84
                //ForceFieldTools.assignCoordinatesToMolecule(moleculeCoords, (AtomContainer) molecule); 
 
85
        }
 
86
                        
 
87
 
 
88
 
 
89
 
 
90
}
 
91
 
 
92