ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/applications/nanoparticleBuilder/nanorodBuilder.cpp
(Generate patch)

Comparing branches/development/src/applications/nanoparticleBuilder/nanorodBuilder.cpp (file contents):
Revision 1701 by kstocke1, Thu Apr 5 19:37:58 2012 UTC vs.
Revision 1876 by gezelter, Fri May 17 17:10:11 2013 UTC

# Line 35 | Line 35
35   *                                                                      
36   * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37   * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 < * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
39   * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40   * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   *  Created by Kelsey M. Stocker on 2/9/12.
# Line 55 | Line 55
55  
56   #include "config.h"
57   #include "shapedLatticeRod.hpp"
58 + #include "shapedLatticeEllipsoid.hpp"
59   #include "nanorodBuilderCmd.h"
60   #include "lattice/LatticeFactory.hpp"
61   #include "utils/MoLocator.hpp"
# Line 75 | Line 76 | int main(int argc, char *argv []) {
76  
77   int main(int argc, char *argv []) {
78    
78  //register force fields
79  registerForceFields();
79    registerLattice();
80    
81    gengetopt_args_info args_info;
82    std::string latticeType;
83    std::string inputFileName;
84    std::string outputFileName;
86
85    MoLocator* locator;
86    int nComponents;
87    double latticeConstant;
90  std::vector<double> lc;
91
88    RealType rodRadius;
89    RealType rodLength;
94
90    Mat3x3d hmat;
96  std::vector<Vector3d> latticePos;
97  std::vector<Vector3d> latticeOrt;
98
91    DumpWriter *writer;
92    
93    // Parse Command Line Arguments
# Line 125 | Line 117 | int main(int argc, char *argv []) {
117    rodLength = args_info.length_arg;
118    Globals* simParams = oldInfo->getSimParams();
119    
120 <  /* Create nanorod */
121 <  shapedLatticeRod nanoRod(latticeConstant, latticeType,
122 <                           rodRadius, rodLength);
123 <  
124 <  /* Build a lattice and get lattice points for this lattice constant */
125 <  vector<Vector3d> sites = nanoRod.getSites();
126 <  vector<Vector3d> orientations = nanoRod.getOrientations();
120 >  vector<Vector3d> sites;
121 >  vector<Vector3d> orientations;
122 >
123 >  if (args_info.ellipsoid_flag) {
124 >    shapedLatticeEllipsoid nanoEllipsoid(latticeConstant, latticeType,
125 >                                         rodLength, rodRadius);
126 >    sites = nanoEllipsoid.getSites();
127 >    orientations = nanoEllipsoid.getOrientations();
128 >  } else {
129 >    
130 >    /* Create nanorod */
131 >    shapedLatticeRod nanoRod(latticeConstant, latticeType,
132 >                             rodRadius, rodLength);
133 >    /* Build a lattice and get lattice points for this lattice constant */
134 >    sites = nanoRod.getSites();
135 >    orientations = nanoRod.getOrientations();
136 >  }
137 >
138    std::vector<int> vacancyTargets;
139    vector<bool> isVacancy;
140    
141    Vector3d myLoc;
142    RealType myR;
143  
144 <  for (int i = 0; i < sites.size(); i++)
144 >  for (unsigned int i = 0; i < sites.size(); i++)
145      isVacancy.push_back(false);
146 <
146 >  
147    // cerr << "checking vacancyPercent" << "\n";
148    if (args_info.vacancyPercent_given) {
149      // cerr << "vacancyPercent given" << "\n";
# Line 165 | Line 168 | int main(int argc, char *argv []) {
168        }
169        if (vIR >= 0.0 && vOR <= rodRadius && vOR >= vIR) {
170          
171 <        for (int i = 0; i < sites.size(); i++) {
171 >        for (unsigned int i = 0; i < sites.size(); i++) {
172            myLoc = sites[i];
173            myR = myLoc.length();
174            if (myR >= vIR && myR <= vOR) {
# Line 185 | Line 188 | int main(int argc, char *argv []) {
188          simError();
189  
190          isVacancy.clear();
191 <        for (int i = 0; i < sites.size(); i++) {
191 >        for (unsigned int i = 0; i < sites.size(); i++) {
192            bool vac = false;
193 <          for (int j = 0; j < vacancyTargets.size(); j++) {
193 >          for (unsigned int j = 0; j < vacancyTargets.size(); j++) {
194              if (i == vacancyTargets[j]) vac = true;
195            }
196            isVacancy.push_back(vac);
# Line 212 | Line 215 | int main(int argc, char *argv []) {
215    std::vector<Component*> components = simParams->getComponents();
216    std::vector<RealType> molFractions;
217    std::vector<RealType> shellRadii;
215  std::vector<RealType> molecularMasses;
218    std::vector<int> nMol;
219    std::map<int, int> componentFromSite;
220    nComponents = components.size();
# Line 317 | Line 319 | int main(int argc, char *argv []) {
319      }
320    } else {
321  
322 <    for (int i = 0; i < shellRadii.size(); i++) {
322 >    for (unsigned int i = 0; i < shellRadii.size(); i++) {
323        if (shellRadii.at(i) > rodRadius + 1e-6 ) {
324          sprintf(painCave.errMsg, "One of the shellRadius values exceeds the rod Radius.");
325          painCave.isFatal = 1;
# Line 339 | Line 341 | int main(int argc, char *argv []) {
341      simError();
342      /* Random rod is the default case*/
343  
344 <    for (int i = 0; i < sites.size(); i++)
344 >    for (unsigned int i = 0; i < sites.size(); i++)
345        if (!isVacancy[i]) ids.push_back(i);
346      
347      std::random_shuffle(ids.begin(), ids.end());
# Line 349 | Line 351 | int main(int argc, char *argv []) {
351      painCave.isFatal = 0;
352      simError();
353  
354 <    RealType smallestSoFar;
354 >    // RealType smallestSoFar;
355      int myComponent = -1;
356      nMol.clear();
357      nMol.resize(nComponents);
358  
359      // cerr << "shellRadii[0] " << shellRadii[0] << "\n";
360 <    //  cerr << "rodRadius " << rodRadius << "\n";
360 >    // cerr << "rodRadius " << rodRadius << "\n";
361  
362 <    for (int i = 0; i < sites.size(); i++) {
362 >    for (unsigned int i = 0; i < sites.size(); i++) {
363        myLoc = sites[i];
364        myR = myLoc.length();
365 <      smallestSoFar = rodRadius;  
366 <      //cerr << "vac = " << isVacancy[i]<< "\n";
365 >      // smallestSoFar = rodRadius;  
366 >      // cerr << "vac = " << isVacancy[i]<< "\n";
367      
368        if (!isVacancy[i]) {
369  
# Line 389 | Line 391 | int main(int argc, char *argv []) {
391  
392    createMdFile(inputFileName, outputFileName, nMol);
393    
394 <  if (oldInfo != NULL)
393 <    delete oldInfo;
394 >  delete oldInfo;
395    
396    SimCreator newCreator;
397    SimInfo* NewInfo = newCreator.createSim(outputFileName, false);
# Line 401 | Line 402 | int main(int argc, char *argv []) {
402    mol = NewInfo->beginMolecule(mi);
403  
404    int l = 0;
404  int whichSite = 0;
405  
406 <  for (int i = 0; i < nComponents; i++){
406 >  for (unsigned int i = 0; i < nComponents; i++){
407      locator = new MoLocator(NewInfo->getMoleculeStamp(i),
408                              NewInfo->getForceField());
409      
410      //   cerr << "nMol = " << nMol.at(i) << "\n";
411      if (!args_info.molFraction_given) {
412 <      for (int n = 0; n < sites.size(); n++) {
412 >      for (unsigned int n = 0; n < sites.size(); n++) {
413          if (!isVacancy[n]) {
414            if (componentFromSite[n] == i) {
415              mol = NewInfo->getMoleculeByGlobalIndex(l);
# Line 419 | Line 419 | int main(int argc, char *argv []) {
419          }
420        }
421      } else {
422 <      for (int n = 0; n < nMol.at(i); n++) {
422 >      for (unsigned int n = 0; n < nMol.at(i); n++) {
423          mol = NewInfo->getMoleculeByGlobalIndex(l);
424          locator->placeMol(sites[ids[l]], orientations[ids[l]], mol);
425          l++;
# Line 480 | Line 480 | void createMdFile(const std::string&oldMdFileName,
480    newMdFile.open(newMdFileName.c_str());
481    oldMdFile.getline(buffer, MAXLEN);
482  
483 <  int i = 0;
483 >  unsigned int i = 0;
484    while (!oldMdFile.eof()) {
485  
486      //correct molecule number

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines