ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/SimSetup.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/SimSetup.cpp (file contents):
Revision 965 by gezelter, Mon Jan 19 21:17:39 2004 UTC vs.
Revision 1035 by tim, Fri Feb 6 21:37:59 2004 UTC

# Line 9 | Line 9
9   #include "parse_me.h"
10   #include "Integrator.hpp"
11   #include "simError.h"
12 + #include "ConjugateMinimizer.hpp"
13  
14   #ifdef IS_MPI
15   #include "mpiBASS.h"
# Line 24 | Line 25
25   #define NPTxyz_ENS     4
26  
27  
28 < #define FF_DUFF 0
29 < #define FF_LJ   1
30 < #define FF_EAM  2
28 > #define FF_DUFF  0
29 > #define FF_LJ    1
30 > #define FF_EAM   2
31 > #define FF_H2O 3
32  
33   using namespace std;
34  
# Line 144 | Line 146 | void SimSetup::createSim(void){
146  
147    makeOutNames();
148  
149 <  // make the integrator
150 <
151 <  makeIntegrator();
152 <
149 >  if (globals->haveMinimizer())
150 >    // make minimizer
151 >    makeMinimizer();
152 >  else
153 >    // make the integrator
154 >    makeIntegrator();
155 >  
156   #ifdef IS_MPI
157    mpiSim->mpiRefresh();
158   #endif
# Line 174 | Line 179 | void SimSetup::makeMolecules(void){
179    bend_set* theBends;
180    torsion_set* theTorsions;
181  
177
182    //init the forceField paramters
183  
184    the_ff->readParams();
# Line 182 | Line 186 | void SimSetup::makeMolecules(void){
186  
187    // init the atoms
188  
189 +  double phi, theta, psi;
190 +  double sux, suy, suz;
191 +  double Axx, Axy, Axz, Ayx, Ayy, Ayz, Azx, Azy, Azz;
192    double ux, uy, uz, u, uSqr;
193  
194    for (k = 0; k < nInfo; k++){
# Line 218 | Line 225 | void SimSetup::makeMolecules(void){
225            info[k].n_oriented++;
226            molInfo.myAtoms[j] = dAtom;
227  
228 <          ux = currentAtom->getOrntX();
229 <          uy = currentAtom->getOrntY();
230 <          uz = currentAtom->getOrntZ();
228 >          // Directional Atoms have standard unit vectors which are oriented
229 >          // in space using the three Euler angles.  We assume the standard
230 >          // unit vector was originally along the z axis below.
231 >
232 >          phi = currentAtom->getEulerPhi() * M_PI / 180.0;
233 >          theta = currentAtom->getEulerTheta() * M_PI / 180.0;
234 >          psi = currentAtom->getEulerPsi()* M_PI / 180.0;
235 >            
236 >          Axx = (cos(phi) * cos(psi)) - (sin(phi) * cos(theta) * sin(psi));
237 >          Axy = (sin(phi) * cos(psi)) + (cos(phi) * cos(theta) * sin(psi));
238 >          Axz = sin(theta) * sin(psi);
239 >          
240 >          Ayx = -(cos(phi) * sin(psi)) - (sin(phi) * cos(theta) * cos(psi));
241 >          Ayy = -(sin(phi) * sin(psi)) + (cos(phi) * cos(theta) * cos(psi));
242 >          Ayz = sin(theta) * cos(psi);
243 >          
244 >          Azx = sin(phi) * sin(theta);
245 >          Azy = -cos(phi) * sin(theta);
246 >          Azz = cos(theta);
247  
248 +          sux = 0.0;
249 +          suy = 0.0;
250 +          suz = 1.0;
251 +
252 +          ux = (Axx * sux) + (Ayx * suy) + (Azx * suz);
253 +          uy = (Axy * sux) + (Ayy * suy) + (Azy * suz);
254 +          uz = (Axz * sux) + (Ayz * suy) + (Azz * suz);
255 +
256            uSqr = (ux * ux) + (uy * uy) + (uz * uz);
257  
258            u = sqrt(uSqr);
# Line 609 | Line 640 | void SimSetup::gatherInfo(void){
640    else if (!strcasecmp(force_field, "EAM")){
641      ffCase = FF_EAM;
642    }
643 +  else if (!strcasecmp(force_field, "WATER")){
644 +    ffCase = FF_H2O;
645 +  }
646    else{
647      sprintf(painCave.errMsg, "SimSetup Error. Unrecognized force field -> %s\n",
648              force_field);
# Line 811 | Line 845 | void SimSetup::gatherInfo(void){
845    for (int i = 0; i < nInfo; i++){
846      info[i].setSeed(seedValue);
847    }
848 <
848 >  
849   #ifdef IS_MPI
850 <  strcpy(checkPointMsg, "Succesfully gathered all information from Bass\n");
850 >  strcpy(checkPointMsg, "Successfully gathered all information from Bass\n");
851    MPIcheckPoint();
852   #endif // is_mpi
853   }
# Line 1110 | Line 1144 | void SimSetup::createFF(void){
1144        the_ff = new EAM_FF();
1145        break;
1146  
1147 +    case FF_H2O:
1148 +      the_ff = new WATER();
1149 +      break;
1150 +
1151      default:
1152        sprintf(painCave.errMsg,
1153                "SimSetup Error. Unrecognized force field in case statement.\n");
# Line 1672 | Line 1710 | void SimSetup::setupZConstraint(SimInfo& theInfo){
1710    //push data into siminfo, therefore, we can retrieve later
1711    theInfo.addProperty(zconsParaData);
1712   }
1713 +
1714 + void SimSetup::makeMinimizer(){
1715 +
1716 +  OOPSEMinimizerBase* myOOPSEMinimizerBase;
1717 +  ObjFunctor1 * objFunc;
1718 +  OutputFunctor* outputFunc;
1719 +  ConcreteNLModel1* nlp;
1720 +  MinimizerParameterSet* param;
1721 +  ConjugateMinimizerBase* minimizer;
1722 +  int dim;
1723 +  
1724 +  for (int i = 0; i < nInfo; i++){
1725 +    //creat
1726 +    myOOPSEMinimizerBase = new OOPSEMinimizerBase(&(info[i]), the_ff);
1727 +
1728 +     info[i].the_integrator = myOOPSEMinimizerBase;
1729 +    //creat the object functor;
1730 +    objFunc = (ObjFunctor1*) new ClassMemObjFunctor1<OOPSEMinimizerBase>
1731 +                                              (myOOPSEMinimizerBase, &OOPSEMinimizerBase::calcGradient);
1732 +
1733 +    //creat output functor;
1734 +    outputFunc =  new ClassMemOutputFunctor<OOPSEMinimizerBase>
1735 +                               (myOOPSEMinimizerBase, &OOPSEMinimizerBase::output);
1736 +
1737 +    //creat nonlinear model
1738 +    dim = myOOPSEMinimizerBase->getDim();    
1739 +    nlp = new ConcreteNLModel1(dim, objFunc);
1740 +
1741 +    nlp->setX(myOOPSEMinimizerBase->getCoor());
1742 +
1743 +    //prepare parameter set for minimizer
1744 +    param = new MinimizerParameterSet();
1745 +    param->setDefaultParameter();
1746 +
1747 +    if (globals->haveMinimizer()){
1748 +      param->setFTol(globals->getMinFTol());
1749 +    }
1750 +
1751 +    if (globals->haveMinGTol()){
1752 +      param->setGTol(globals->getMinGTol());
1753 +    }
1754 +
1755 +    if (globals->haveMinMaxIter()){
1756 +      param->setMaxIteration(globals->getMinMaxIter());
1757 +    }
1758 +
1759 +    if (globals->haveMinWriteFrq()){
1760 +      param->setMaxIteration(globals->getMinMaxIter());
1761 +    }
1762 +
1763 +    if (globals->haveMinWriteFrq()){
1764 +      param->setWriteFrq(globals->getMinWriteFrq());
1765 +    }
1766 +    
1767 +    if (globals->haveMinResetFrq()){
1768 +      param->setResetFrq(globals->getMinResetFrq());
1769 +    }
1770 +
1771 +    if (globals->haveMinLSMaxIter()){
1772 +      param->setLineSearchMaxIteration(globals->getMinLSMaxIter());
1773 +    }    
1774 +
1775 +    if (globals->haveMinLSTol()){
1776 +      param->setLineSearchTol(globals->getMinLSTol());
1777 +    }    
1778 +    
1779 +     //creat the minimizer
1780 +     minimizer = new PRCGMinimizer(nlp, param);
1781 +     minimizer->setLineSearchStrategy(nlp, GoldenSection);
1782 +     minimizer->setOutputFunctor(outputFunc);
1783 +
1784 +     //store the minimizer into simInfo
1785 +     info[i].the_minimizer = minimizer;
1786 +     info[i].has_minimizer = true;
1787 +  }
1788 +
1789 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines