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 1066 by tim, Tue Feb 24 16:36:33 2004 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines