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

Comparing trunk/OOPSE-4/src/applications/nanoparticleBuilder/nanoparticleBuilder.cpp (file contents):
Revision 3045 by chuckv, Fri Oct 13 20:16:59 2006 UTC vs.
Revision 3046 by gezelter, Sat Oct 14 20:21:26 2006 UTC

# Line 78 | Line 78 | int main(int argc, char *argv []) {
78    gengetopt_args_info args_info;
79    std::string latticeType;
80    std::string inputFileName;
81  std::string outPrefix;
81    std::string outputFileName;
83  std::string outInitFileName;
82  
85  
86  
83    Lattice *simpleLat;
84    MoLocator* locator;
85    int* numMol;
# Line 91 | Line 87 | int main(int argc, char *argv []) {
87    double latticeConstant;
88    std::vector<double> lc;
89    double mass;                                                                          
94
90    const double rhoConvertConst = 1.661;
91    double density;
92    double particleRadius;
98  
99  
93  
94    Mat3x3d hmat;
95    std::vector<Vector3d> latticePos;
# Line 104 | Line 97 | int main(int argc, char *argv []) {
97    int numMolPerCell;
98    int nShells; /* Number of shells in nanoparticle*/
99  
107  
100    DumpWriter *writer;
101    
102    // Parse Command Line Arguments
103    if (cmdline_parser(argc, argv, &args_info) != 0)
104      exit(1);
105 <  
114 <        
115 <        
105 >        
106    /* get lattice type */
107    latticeType = "FCC";
108  
# Line 131 | Line 121 | int main(int argc, char *argv []) {
121    SimCreator oldCreator;
122    SimInfo* oldInfo = oldCreator.createSim(inputFileName, false);
123    
134  
124    latticeConstant = args_info.latticeCnst_arg;
125    particleRadius = args_info.radius_arg;
126    Globals* simParams = oldInfo->getSimParams();
127    
139      
140  /* create Molocators */
141  locator = new MoLocator(oldInfo->getMoleculeStamp(0), oldInfo->getForceField());
142  
128    /* Create nanoparticle */
129 <  shapedLatticeSpherical nanoParticle(latticeConstant,latticeType,particleRadius);
129 >  shapedLatticeSpherical nanoParticle(latticeConstant, latticeType,
130 >                                      particleRadius);
131    
132    /* Build a lattice and get lattice points for this lattice constant */
133 <  vector<Vector3d> sites = nanoParticle.getPoints();
134 <  vector<Vector3d> orientations = nanoParticle.getPointsOrt();
133 >  vector<Vector3d> sites = nanoParticle.getSites();
134 >  vector<Vector3d> orientations = nanoParticle.getOrientations();
135  
136    std::cout <<"nSites: " << sites.size() << std::endl;
137  
138    /* Get number of lattice sites */
139    int nSites = sites.size();
154
140  
156
157
141    std::vector<Component*> components = simParams->getComponents();
142    std::vector<RealType> molFractions;
143    std::vector<RealType> molecularMasses;
144    std::vector<int> nMol;
145    nComponents = components.size();
163  
146  
165
147   if (nComponents == 1) {
148      molFractions.push_back(1.0);    
149    } else {
150 <    if (args_info.molFraction_given == nComponents) {
151 <      for (int i = 0; i < nComponents; i++) {
152 <        molFractions.push_back(args_info.molFraction_arg[i]);
153 <      }
150 >   if (args_info.molFraction_given == nComponents) {
151 >     for (int i = 0; i < nComponents; i++) {
152 >       molFractions.push_back(args_info.molFraction_arg[i]);
153 >     }
154      } else if (args_info.molFraction_given == nComponents-1) {
155 <      RealType remainingFraction = 1.0;
156 <      for (int i = 0; i < nComponents-1; i++) {
157 <        molFractions.push_back(args_info.molFraction_arg[i]);
158 <        remainingFraction -= molFractions[i];
159 <      }
160 <      molFractions.push_back(remainingFraction);
161 <    } else {    
162 <      sprintf(painCave.errMsg, "nanoparticleBuilder can't figure out molFractions "
163 <              "for all of the components in the <MetaData> block.");
164 <      painCave.isFatal = 1;
165 <      simError();
166 <    }
167 <  }
168 <
155 >     RealType remainingFraction = 1.0;
156 >     for (int i = 0; i < nComponents-1; i++) {
157 >       molFractions.push_back(args_info.molFraction_arg[i]);
158 >       remainingFraction -= molFractions[i];
159 >     }
160 >     molFractions.push_back(remainingFraction);
161 >   } else {    
162 >     sprintf(painCave.errMsg, "nanoparticleBuilder can't figure out molFractions "
163 >             "for all of the components in the <MetaData> block.");
164 >     painCave.isFatal = 1;
165 >     simError();
166 >   }
167 > }
168 >
169   RealType totalFraction = 0.0;
170 <
170 >
171   /* Do some simple sanity checking*/
172  
192
193
173    for (int i = 0; i < nComponents; i++) {
174      if (molFractions.at(i) < 0.0) {
175        sprintf(painCave.errMsg, "One of the requested molFractions was"
# Line 241 | Line 220 | int main(int argc, char *argv []) {
220      simError();
221    }
222      
244
245
246
223    vector<int> ids;
224    for (int i = 0; i < sites.size(); i++) ids.push_back(i);
225    /* Random particle is the default case*/
# Line 317 | Line 293 | int main(int argc, char *argv []) {
293    
294    
295    //create dumpwriter and write out the coordinates
296 <  writer = new DumpWriter(NewInfo,outputFileName);
296 >  writer = new DumpWriter(NewInfo, outputFileName);
297    
298    if (writer == NULL) {
299      sprintf(painCave.errMsg, "Error in creating dumpwrite object ");
# Line 326 | Line 302 | int main(int argc, char *argv []) {
302    }
303    
304    writer->writeDump();
329  std::cout << "new initial configuration file: " << outInitFileName
330            << " is generated." << std::endl;
331
305  
306    // deleting the writer will put the closing at the end of the dump file
307 +
308    delete writer;
309  
310    // cleanup a by calling sim error.....

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines