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

Comparing trunk/src/applications/nanoparticleBuilder/nanoparticleBuilder.cpp (file contents):
Revision 875 by chuckv, Thu Jan 19 22:54:23 2006 UTC vs.
Revision 1793 by gezelter, Fri Aug 31 21:16:10 2012 UTC

# Line 6 | Line 6
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
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).          
39 + * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 + * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   #include <cstdlib>
# Line 47 | Line 48
48   #include <string>
49   #include <map>
50   #include <fstream>
51 + #include <algorithm>
52  
53   #include "config.h"
54 <
54 > #include "shapedLatticeSpherical.hpp"
55   #include "nanoparticleBuilderCmd.h"
54 #include "sphericalNanoparticle.hpp"
56   #include "lattice/LatticeFactory.hpp"
57   #include "utils/MoLocator.hpp"
58   #include "lattice/Lattice.hpp"
# Line 64 | Line 65 | using namespace std;
65   #include "utils/StringUtils.hpp"
66  
67   using namespace std;
68 < using namespace oopse;
68 > using namespace OpenMD;
69   void createMdFile(const std::string&oldMdFileName,
70                    const std::string&newMdFileName,
71 <                  int numMol);
71 >                  std::vector<int> numMol);
72  
73   int main(int argc, char *argv []) {
74    
74  //register force fields
75  registerForceFields();
75    registerLattice();
76    
77    gengetopt_args_info args_info;
78    std::string latticeType;
79    std::string inputFileName;
80 <  std::string outPrefix;
82 <  std::string outMdFileName;
83 <  std::string outInitFileName;
80 >  std::string outputFileName;
81  
82 <  
83 <  
87 <  Lattice *simpleLat;
88 <  int numMol;
82 >  MoLocator* locator;
83 >  int nComponents;
84    double latticeConstant;
85    std::vector<double> lc;
91  double mass;
92  const double rhoConvertConst = 1.661;
93  double density;
94  
95  
86  
87 +  RealType particleRadius;
88 +
89    Mat3x3d hmat;
98  MoLocator *locator;
99  sphericalNanoparticle *nanoparticle;
90    std::vector<Vector3d> latticePos;
91    std::vector<Vector3d> latticeOrt;
92 <  int numMolPerCell;
103 <  int nShells; /* Number of shells in nanoparticle*/
104 <  int numSites;
105 <  
92 >
93    DumpWriter *writer;
94    
95    // Parse Command Line Arguments
96    if (cmdline_parser(argc, argv, &args_info) != 0)
97      exit(1);
98 <  
112 <        
113 <        
98 >        
99    /* get lattice type */
100 <  latticeType = UpperCase(args_info.latticetype_arg);
101 <    
100 >  latticeType = "FCC";
101 >
102    /* get input file name */
103    if (args_info.inputs_num)
104      inputFileName = args_info.inputs[0];
105    else {
106 <    std::cerr << "You must specify a input file name.\n" << std::endl;
106 >    sprintf(painCave.errMsg, "No input .md file name was specified "
107 >            "on the command line");
108 >    painCave.isFatal = 1;
109      cmdline_parser_print_help();
110 <    exit(1);
110 >    simError();
111    }
112    
113    /* parse md file and set up the system */
114    SimCreator oldCreator;
115    SimInfo* oldInfo = oldCreator.createSim(inputFileName, false);
116    
117 <  nShells = 0;
131 <  if (args_info.coreShellRadius_given){
132 <    nShells = args_info.coreShellRadius_given;
133 <  }
134 <  
135 <  nComponents = oldInfo->getNMoleculeStamp();
136 <  
137 <  /* Check to see if we have enough components to build that many shells. */
138 <  if (nShells){
139 <    if (oldInfo->getNMoleculeStamp() != nShells) {
140 <      std::cerr << "Not enough components present in MD file to build specified number of shells"
141 <      << std::endl;
142 <      exit(1);
143 <    }
144 <  }
145 <  
146 <  
147 <  //creat lattice
148 <  simpleLat = LatticeFactory::getInstance()->createLattice(latticeType);
149 <  
150 <  if (simpleLat == NULL) {
151 <    std::cerr << "Error in creating lattice" << std::endl;
152 <    exit(1);
153 <  }
154 <  
155 <  numMolPerCell = simpleLat->getNumSitesPerCell();
156 <  
157 <  /*calculate lattice constant (in Angstrom)
158 <  latticeConstant = pow(rhoConvertConst * numMolPerCell * mass / density,
159 <                        1.0 / 3.0);*/
160 <  
161 <  latticeConstant = args_info.latticeCnst_arg;
117 >  latticeConstant = args_info.latticeConstant_arg;
118    particleRadius = args_info.radius_arg;
119 <  particleDiameter = 2.0 * particleRadius;
119 >  Globals* simParams = oldInfo->getSimParams();
120    
121 <  /* set lattice constant */
122 <  lc.push_back(latticeConstant);
123 <  simpleLat->setLatticeConstant(lc);
121 >  /* Create nanoparticle */
122 >  shapedLatticeSpherical nanoParticle(latticeConstant, latticeType,
123 >                                      particleRadius);
124    
125 +  /* Build a lattice and get lattice points for this lattice constant */
126 +  vector<Vector3d> sites = nanoParticle.getSites();
127 +  vector<Vector3d> orientations = nanoParticle.getOrientations();
128 +
129 +
130 +  std::vector<int> vacancyTargets;
131 +  vector<bool> isVacancy;
132    
133 <  /*determine the output file names*/
134 <  if (args_info.output_given){
135 <    outInitFileName = args_info.output_arg;
136 <  }else{
137 <    outInitFileName = getPrefix(inputFileName.c_str()) + ".in";
175 <  }
176 <  
177 <        
178 <  
179 <  
180 <  
181 <  /* create Molocators */
182 <  locator = new MoLocator(oldInfo->getMoleculeStamp(0), oldInfo->getForceField());
183 <  
184 <  /* create a new spherical nanoparticle */
185 <  nanoparticle = new sphericalNanoparticle(particleRadius,latticeConstant);
186 <  /* Build a nanoparticle to see how many sites are there */
187 <  numSites = new int[nComponents]
188 <  int numSites = nanoparticle.getNMol(simpleLat);
189 <  
133 >  Vector3d myLoc;
134 >  RealType myR;
135 >
136 >  for (int i = 0; i < sites.size(); i++)
137 >    isVacancy.push_back(false);
138  
139 <  /* Random particle is the default case*/
140 <  if (!args_info.ShellRadius_given){
141 <    std::cout << "Creating a random nanoparticle" << std::endl;
142 <    /* Check to see if we have enough components */
143 <    if (nComponents != args_info.molFraction_given + 1){
144 <      std::cerr << "Number of components does not equal molFraction occurances." << std::endl;
145 <      exit 1;
139 >  if (args_info.vacancyPercent_given) {
140 >    if (args_info.vacancyPercent_arg < 0.0 || args_info.vacancyPercent_arg > 100.0) {
141 >      sprintf(painCave.errMsg, "vacancyPercent was set to a non-sensical value.");
142 >      painCave.isFatal = 1;
143 >      simError();
144 >    } else {
145 >      RealType vF = args_info.vacancyPercent_arg / 100.0;
146 >      RealType vIR;
147 >      RealType vOR;
148 >      if (args_info.vacancyInnerRadius_given) {
149 >        vIR = args_info.vacancyInnerRadius_arg;
150 >      } else {
151 >        vIR = 0.0;
152 >      }
153 >      if (args_info.vacancyOuterRadius_given) {
154 >        vOR = args_info.vacancyOuterRadius_arg;
155 >      } else {
156 >        vOR = particleRadius;
157 >      }
158 >      if (vIR >= 0.0 && vOR <= particleRadius && vOR >= vIR) {
159 >        
160 >        for (int i = 0; i < sites.size(); i++) {
161 >          myLoc = sites[i];
162 >          myR = myLoc.length();
163 >          if (myR >= vIR && myR <= vOR) {
164 >            vacancyTargets.push_back(i);
165 >          }          
166 >        }
167 >        std::random_shuffle(vacancyTargets.begin(), vacancyTargets.end());
168 >        
169 >        int nTargets = vacancyTargets.size();
170 >        vacancyTargets.resize((int)(vF * nTargets));
171 >        
172 >                  
173 >        sprintf(painCave.errMsg, "Removing %d atoms from randomly-selected\n"
174 >                "\tsites between %lf and %lf.", (int) vacancyTargets.size(),
175 >                vIR, vOR);
176 >        painCave.isFatal = 0;
177 >        simError();
178 >
179 >        isVacancy.clear();
180 >        for (int i = 0; i < sites.size(); i++) {
181 >          bool vac = false;
182 >          for (int j = 0; j < vacancyTargets.size(); j++) {
183 >            if (i == vacancyTargets[j]) vac = true;
184 >          }
185 >          isVacancy.push_back(vac);
186 >        }
187 >              
188 >      } else {
189 >        sprintf(painCave.errMsg, "Something is strange about the vacancy\n"
190 >                "\tinner or outer radii.  Check their values.");
191 >        painCave.isFatal = 1;
192 >        simError();
193 >      }
194      }
195 <    int totComponents = 0;
200 <    for (int i = 0;i<nComponents-2;i++){ /* Figure out Percent for each component */
201 <      numMol[i] = int((double)numSites * args_info.molFraction_arg[i]);
202 <      totComponents += numMol[i];
203 <    }
204 <    numMol[nComponents-1] = numSites - totComponents;
195 >  }
196  
197 <  } else{ /*Handle core-shell with multiple components.*/
198 <    std::cout << "Creating a core-shell nanoparticle." << std::endl;
199 <    if (nComponents != args_info.ShellRadius_given + 1){
200 <      std::cerr << "Number of components does not equal ShellRadius occurances." << std::endl;
201 <      exit 1;
197 >  /* Get number of lattice sites */
198 >  int nSites = sites.size() - vacancyTargets.size();
199 >
200 >  std::vector<Component*> components = simParams->getComponents();
201 >  std::vector<RealType> molFractions;
202 >  std::vector<RealType> shellRadii;
203 >  std::vector<RealType> molecularMasses;
204 >  std::vector<int> nMol;
205 >  std::map<int, int> componentFromSite;
206 >  nComponents = components.size();
207 >
208 >  if (args_info.molFraction_given && args_info.shellRadius_given) {
209 >    sprintf(painCave.errMsg, "Specify either molFraction or shellRadius "
210 >            "arguments, but not both!");
211 >    painCave.isFatal = 1;
212 >    simError();
213 >  }
214 >  
215 >  if (nComponents == 1) {
216 >    molFractions.push_back(1.0);    
217 >    shellRadii.push_back(particleRadius);
218 >  } else if (args_info.molFraction_given) {
219 >    if ((int)args_info.molFraction_given == nComponents) {
220 >      for (int i = 0; i < nComponents; i++) {
221 >        molFractions.push_back(args_info.molFraction_arg[i]);
222 >      }
223 >    } else if ((int)args_info.molFraction_given == nComponents-1) {
224 >      RealType remainingFraction = 1.0;
225 >      for (int i = 0; i < nComponents-1; i++) {
226 >        molFractions.push_back(args_info.molFraction_arg[i]);
227 >        remainingFraction -= molFractions[i];
228 >      }
229 >      molFractions.push_back(remainingFraction);
230 >    } else {    
231 >      sprintf(painCave.errMsg, "nanoparticleBuilder can't figure out molFractions "
232 >              "for all of the components in the <MetaData> block.");
233 >      painCave.isFatal = 1;
234 >      simError();
235 >    }
236 >  } else if ((int)args_info.shellRadius_given) {
237 >    if ((int)args_info.shellRadius_given == nComponents) {
238 >      for (int i = 0; i < nComponents; i++) {
239 >        shellRadii.push_back(args_info.shellRadius_arg[i]);
240 >      }
241 >    } else if ((int)args_info.shellRadius_given == nComponents-1) {
242 >      for (int i = 0; i < nComponents-1; i++) {
243 >        shellRadii.push_back(args_info.shellRadius_arg[i]);
244 >      }
245 >      shellRadii.push_back(particleRadius);
246 >    } else {    
247 >      sprintf(painCave.errMsg, "nanoparticleBuilder can't figure out the\n"
248 >              "\tshell radii for all of the components in the <MetaData> block.");
249 >      painCave.isFatal = 1;
250 >      simError();
251      }
252 +  } else {
253 +    sprintf(painCave.errMsg, "You have a multi-component <MetaData> block,\n"
254 +            "\tbut have not specified either molFraction or shellRadius arguments.");
255 +    painCave.isFatal = 1;
256 +    simError();
257 +  }
258      
259 +  if (args_info.molFraction_given) {
260 +    RealType totalFraction = 0.0;
261      
262 +    /* Do some simple sanity checking*/
263      
264 +    for (int i = 0; i < nComponents; i++) {
265 +      if (molFractions.at(i) < 0.0) {
266 +        sprintf(painCave.errMsg, "One of the requested molFractions was"
267 +                " less than zero!");
268 +        painCave.isFatal = 1;
269 +        simError();
270 +      }
271 +      if (molFractions.at(i) > 1.0) {
272 +        sprintf(painCave.errMsg, "One of the requested molFractions was"
273 +                " greater than one!");
274 +        painCave.isFatal = 1;
275 +        simError();
276 +      }
277 +      totalFraction += molFractions.at(i);
278 +    }
279 +    if (abs(totalFraction - 1.0) > 1e-6) {
280 +      sprintf(painCave.errMsg, "The sum of molFractions was not close enough to 1.0");
281 +      painCave.isFatal = 1;
282 +      simError();
283 +    }
284 +    
285 +    int remaining = nSites;
286 +    for (int i=0; i < nComponents-1; i++) {    
287 +      nMol.push_back(int((RealType)nSites * molFractions.at(i)));
288 +      remaining -= nMol.at(i);
289 +    }
290 +    nMol.push_back(remaining);
291 +    
292 +    // recompute actual mol fractions and perform final sanity check:
293 +    
294 +    int totalMolecules = 0;
295 +    for (int i=0; i < nComponents; i++) {
296 +      molFractions[i] = (RealType)(nMol.at(i))/(RealType)nSites;
297 +      totalMolecules += nMol.at(i);
298 +    }
299 +    
300 +    if (totalMolecules != nSites) {
301 +      sprintf(painCave.errMsg, "Computed total number of molecules is not equal "
302 +              "to the number of lattice sites!");
303 +      painCave.isFatal = 1;
304 +      simError();
305 +    }
306 +  } else {
307 +
308 +    for (int i = 0; i < shellRadii.size(); i++) {
309 +      if (shellRadii.at(i) > particleRadius + 1e-6 ) {
310 +        sprintf(painCave.errMsg, "One of the shellRadius values exceeds the particle Radius.");
311 +        painCave.isFatal = 1;
312 +        simError();
313 +      }
314 +      if (shellRadii.at(i) <= 0.0 ) {
315 +        sprintf(painCave.errMsg, "One of the shellRadius values is smaller than zero!");
316 +        painCave.isFatal = 1;
317 +        simError();
318 +      }
319 +    }
320    }
321  
322 <   //get the orientation of the cell sites
323 <  //for the same type of molecule in same lattice, it will not change
324 <   latticeOrt = simpleLat->getLatticePointsOrt();
322 >  vector<int> ids;          
323 >  if ((int)args_info.molFraction_given){
324 >    sprintf(painCave.errMsg, "Creating a randomized spherical nanoparticle.");
325 >    painCave.isFatal = 0;
326 >    simError();
327 >    /* Random particle is the default case*/
328 >
329 >    for (int i = 0; i < sites.size(); i++)
330 >      if (!isVacancy[i]) ids.push_back(i);
331 >    
332 >    std::random_shuffle(ids.begin(), ids.end());
333 >    
334 >  } else{
335 >    sprintf(painCave.errMsg, "Creating a core-shell spherical nanoparticle.");
336 >    painCave.isFatal = 0;
337 >    simError();
338 >
339 >    RealType smallestSoFar;
340 >    int myComponent = -1;
341 >    nMol.clear();
342 >    nMol.resize(nComponents);
343 >
344 >    for (int i = 0; i < sites.size(); i++) {
345 >      myLoc = sites[i];
346 >      myR = myLoc.length();
347 >      smallestSoFar = particleRadius;      
348 >      if (!isVacancy[i]) {
349 >        for (int j = 0; j < nComponents; j++) {
350 >          if (myR <= shellRadii[j]) {
351 >            if (shellRadii[j] <= smallestSoFar) {
352 >              smallestSoFar = shellRadii[j];
353 >              myComponent = j;
354 >            }
355 >          }
356 >        }
357 >        componentFromSite[i] = myComponent;
358 >        nMol[myComponent]++;
359 >      }
360 >    }      
361 >  }
362    
363 +  outputFileName = args_info.output_arg;
364 +  
365 +  //creat new .md file on fly which corrects the number of molecule    
366 +  createMdFile(inputFileName, outputFileName, nMol);
367    
222  
223  // needed for writing out new md file.
224  
225    outPrefix = getPrefix(inputFileName.c_str()) + "_" + latticeType;
226    outMdFileName = outPrefix + ".md";
227  
228    //creat new .md file on fly which corrects the number of molecule    
229    createMdFile(inputFileName, outMdFileName, numcomponents,numMol);
230  
368    if (oldInfo != NULL)
369      delete oldInfo;
370    
371 <  
372 <  // We need to read in new siminfo object.    
373 <  //parse md file and set up the system
374 <  //SimCreator NewCreator;
238 <  
239 <  SimInfo* NewInfo = oldCreator.createSim(outMdFileName, false);
240 <  
241 <  // This was so much fun the first time, lets do it again.
242 <  
371 >  SimCreator newCreator;
372 >  SimInfo* NewInfo = newCreator.createSim(outputFileName, false);
373 >    
374 >  // Place molecules
375    Molecule* mol;
376    SimInfo::MoleculeIterator mi;
377    mol = NewInfo->beginMolecule(mi);
378  
379 +  int l = 0;
380  
381 <  for(int i = -nx; i < nx; i++) {
382 <     for(int j = -ny; j < ny; j++) {
383 <        for(int k = -nz; k < nz; k++) {
384 <          
385 <           //get the position of the cell sites
386 <           simpleLat->getLatticePointsPos(latticePos, i, j, k);
387 <          
388 <           for(int l = 0; l < numMolPerCell; l++) {
389 < #ifdef HAVE_CGAL              
390 <              if (myGeometry->isInsidePolyhedron(latticePos[l][0],latticePos[l][1],latticePos[l][2])){
391 < #endif                              
392 <                 if (mol != NULL) {
260 <                    locator->placeMol(latticePos[l], latticeOrt[l], mol);
261 <                 } else {
262 <                    std::cerr<<"Error in placing molecule " << std::endl;                    
263 <                 }
264 <                 mol = NewInfo->nextMolecule(mi);
265 < #ifdef HAVE_CGAL                
266 <              }
267 < #endif              
268 <           }
381 >  for (int i = 0; i < nComponents; i++){
382 >    locator = new MoLocator(NewInfo->getMoleculeStamp(i),
383 >                            NewInfo->getForceField());
384 >    
385 >    if (!args_info.molFraction_given) {
386 >      for (int n = 0; n < sites.size(); n++) {
387 >        if (!isVacancy[n]) {
388 >          if (componentFromSite[n] == i) {
389 >            mol = NewInfo->getMoleculeByGlobalIndex(l);
390 >            locator->placeMol(sites[n], orientations[n], mol);
391 >            l++;
392 >          }
393          }
394 <     }
394 >      }
395 >    } else {
396 >      for (int n = 0; n < nMol.at(i); n++) {
397 >        mol = NewInfo->getMoleculeByGlobalIndex(l);
398 >        locator->placeMol(sites[ids[l]], orientations[ids[l]], mol);
399 >        l++;
400 >      }
401 >    }
402    }
403    
273
274  
404    //fill Hmat
405 <  hmat(0, 0)= nx * latticeConstant;
405 >  hmat(0, 0)=  10.0*particleRadius;
406    hmat(0, 1) = 0.0;
407    hmat(0, 2) = 0.0;
408    
409    hmat(1, 0) = 0.0;
410 <  hmat(1, 1) = ny * latticeConstant;
410 >  hmat(1, 1) =  10.0*particleRadius;
411    hmat(1, 2) = 0.0;
412    
413    hmat(2, 0) = 0.0;
414    hmat(2, 1) = 0.0;
415 <  hmat(2, 2) = nz * latticeConstant;
415 >  hmat(2, 2) =  10.0*particleRadius;
416    
417    //set Hmat
418    NewInfo->getSnapshotManager()->getCurrentSnapshot()->setHmat(hmat);
419    
420    
421    //create dumpwriter and write out the coordinates
422 <  NewInfo->setFinalConfigFileName(outInitFileName);
294 <  writer = new DumpWriter(NewInfo);
422 >  writer = new DumpWriter(NewInfo, outputFileName);
423    
424    if (writer == NULL) {
425 <    std::cerr << "error in creating DumpWriter" << std::endl;
426 <    exit(1);
425 >    sprintf(painCave.errMsg, "Error in creating dumpwriter object ");
426 >    painCave.isFatal = 1;
427 >    simError();
428    }
429    
430    writer->writeDump();
431 <  std::cout << "new initial configuration file: " << outInitFileName
432 <            << " is generated." << std::endl;
433 <  
434 <  //delete objects
435 <  
436 <  //delete oldInfo and oldSimSetup
437 <  
438 <  if (NewInfo != NULL)
439 <    delete NewInfo;
440 <  
312 <  if (writer != NULL)
313 <    delete writer;
314 <  delete simpleLat;    
315 <  cmdline_parser_free(&args_info);
431 >
432 >  // deleting the writer will put the closing at the end of the dump file
433 >
434 >  delete writer;
435 >
436 >  // cleanup a by calling sim error.....
437 >  sprintf(painCave.errMsg, "A new OpenMD file called \"%s\" has been "
438 >          "generated.\n", outputFileName.c_str());
439 >  painCave.isFatal = 0;
440 >  simError();
441    return 0;
442   }
443  
444 < void createMdFile(const std::string&oldMdFileName, const std::string&newMdFileName,
445 <                  int components,int &nummol) {
444 > void createMdFile(const std::string&oldMdFileName,
445 >                  const std::string&newMdFileName,
446 >                  std::vector<int> nMol) {
447    ifstream oldMdFile;
448    ofstream newMdFile;
449    const int MAXLEN = 65535;
# Line 326 | Line 452 | void createMdFile(const std::string&oldMdFileName, con
452    //create new .md file based on old .md file
453    oldMdFile.open(oldMdFileName.c_str());
454    newMdFile.open(newMdFileName.c_str());
329  
455    oldMdFile.getline(buffer, MAXLEN);
456 <  
456 >
457 >  int i = 0;
458    while (!oldMdFile.eof()) {
459 <    
459 >
460      //correct molecule number
461      if (strstr(buffer, "nMol") != NULL) {
462 <      sprintf(buffer, "\tnMol = %i;", numMol);                          
463 <      newMdFile << buffer << std::endl;
462 >      if(i<nMol.size()){
463 >        sprintf(buffer, "\tnMol = %i;", nMol.at(i));
464 >        newMdFile << buffer << std::endl;
465 >        i++;
466 >      }
467      } else
468        newMdFile << buffer << std::endl;
469      
# Line 343 | Line 472 | void createMdFile(const std::string&oldMdFileName, con
472    
473    oldMdFile.close();
474    newMdFile.close();
475 +
476 +  if (i != nMol.size()) {
477 +    sprintf(painCave.errMsg, "Couldn't replace the correct number of nMol\n"
478 +            "\tstatements in component blocks.  Make sure that all\n"
479 +            "\tcomponents in the template file have nMol=1");
480 +    painCave.isFatal = 1;
481 +    simError();
482 +  }
483 +    
484   }
485  

Comparing trunk/src/applications/nanoparticleBuilder/nanoparticleBuilder.cpp (property svn:keywords):
Revision 875 by chuckv, Thu Jan 19 22:54:23 2006 UTC vs.
Revision 1793 by gezelter, Fri Aug 31 21:16:10 2012 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines