ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/md_code/InitializeFromFile.cpp
(Generate patch)

Comparing trunk/mdtools/md_code/InitializeFromFile.cpp (file contents):
Revision 162 by mmeineke, Thu Oct 31 21:20:49 2002 UTC vs.
Revision 212 by chuckv, Fri Dec 13 21:17:00 2002 UTC

# Line 13 | Line 13 | InitializeFromFile :: InitializeFromFile( char *in_nam
13  
14  
15   InitializeFromFile :: InitializeFromFile( char *in_name ){
16 + #ifdef IS_MPI
17 +  if (worldRank == 0) {
18 + #endif
19  
20    c_in_file = fopen(in_name, "r");
21    if(c_in_file == NULL){
# Line 23 | Line 26 | InitializeFromFile :: InitializeFromFile( char *in_nam
26    }
27    
28    strcpy( c_in_name, in_name);
29 + #ifdef IS_MPI
30 +  }
31 + strcpy( checkPointMsg, "Infile opened for reading successfully." );
32 +  MPIcheckPoint();
33 + #endif
34    return;  
35   }
36  
37   InitializeFromFile :: ~InitializeFromFile( ){
38 <  
38 > #ifdef IS_MPI
39 >  if (worldRank == 0) {
40 > #endif
41    int error;
42    error = fclose( c_in_file );
43    if( error ){
# Line 35 | Line 45 | InitializeFromFile :: ~InitializeFromFile( ){
45               "Error closing %s\n", c_in_name );
46      simError();
47    }
48 + #ifdef IS_MPI
49 +  }
50 +  strcpy( checkPointMsg, "Infile closed successfully." );
51 +  MPIcheckPoint();
52 + #endif
53 +
54    return;
55   }
56  
57  
58 < void InitializeFromFile :: read_xyz( SimInfo* entry_plug ){
58 > void InitializeFromFile :: read_xyz( SimInfo* the_entry_plug ){
59  
60    int i; // loop counter
61  
62 +  const int BUFFERSIZE = 2000; // size of the read buffer
63    int n_atoms; // the number of atoms
64 <  char read_buffer[2000]; //the line buffer for reading
64 >  char read_buffer[BUFFERSIZE]; //the line buffer for reading
65 > #ifdef IS_MPI
66 >  char send_buffer[BUFFERSIZE];
67 > #endif
68 >
69    char *eof_test; // ptr to see when we reach the end of the file
70 <  char *foo; // the pointer to the current string token
70 >  char *parseErr;
71  
51  double rx, ry, rz; // position place holders
52  double vx, vy, vz; // velocity placeholders
53  double q[4]; // the quaternions
54  double jx, jy, jz; // angular velocity placeholders;
55  double qSqr, qLength; // needed to normalize the quaternion vector.
72  
73 +  entry_plug = the_entry_plug
74 +
75 +
76 + #ifndef IS_MPI
77    eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file);
78    if( eof_test == NULL ){
79 <    std::cerr << "error reading 1st line of" << c_in_name << "\n";
79 >    sprintf( painCave.errMsg,
80 >             "InitializeFromFile error: error reading 1st line of \"%s\"\n",
81 >             c_in_name );
82 >    painCave.isFatal = 1;
83 >    simError();
84    }
85  
86 <  (void)sscanf(read_buffer, "%d", &n_atoms);
86 >  n_atoms = atoi( read_buffer );
87  
88    Atom **atoms = entry_plug->atoms;
89    DirectionalAtom* dAtom;
# Line 96 | Line 120 | void InitializeFromFile :: read_xyz( SimInfo* entry_pl
120        simError();
121      }
122  
99    foo = strtok(read_buffer, " ,;\t");
123      
124 <    // check the atom name to the current atom
125 <
126 <    if( strcmp( foo, atoms[i]->getType() ) ){
104 <      sprintf( painCave.errMsg,
105 <               "Initialize from file error. Atom %s at index %d "
106 <               "in file %s does not"
107 <               " match the BASS atom %s.\n",
108 <               foo, i, c_in_name, atoms[i]->getType() );
124 >    parseErr = parseDumpLine( read_buffer, i );
125 >    if( parseErr != NULL ){
126 >      strcpy( painCave.errMsg, parseErr );
127        painCave.isFatal = 1;
128        simError();
129 <    }
130 <    
113 <    // get the positions
129 >    }    
130 >  }
131  
115    foo = strtok(NULL, " ,;\t");
116    if(foo == NULL){
117      sprintf( painCave.errMsg,
118               "error in reading postition x from %s\n"
119               "natoms  = %d, index = %d\n",
120               c_in_name, n_atoms, i );
121      painCave.isFatal = 1;
122      simError();
123    }
124    (void)sscanf( foo, "%lf", &rx );
125  
126    foo = strtok(NULL, " ,;\t");
127    if(foo == NULL){
128      sprintf( painCave.errMsg,
129               "error in reading postition y from %s\n"
130               "natoms  = %d, index = %d\n",
131               c_in_name, n_atoms, i );
132      painCave.isFatal = 1;
133      simError();
134    }
135    (void)sscanf( foo, "%lf", &ry );
136    
137    foo = strtok(NULL, " ,;\t");
138    if(foo == NULL){
139      sprintf( painCave.errMsg,
140               "error in reading postition z from %s\n"
141               "natoms  = %d, index = %d\n",
142               c_in_name, n_atoms, i );
143      painCave.isFatal = 1;
144      simError();
145    }
146    (void)sscanf( foo, "%lf", &rz );
147    
148    // get the velocities
132  
133 <    foo = strtok(NULL, " ,;\t");
134 <    if(foo == NULL){
133 >  // MPI Section of code..........
134 > #else //IS_MPI
135 >
136 >  int masterIndex;
137 >  int nodeAtomsStart;
138 >  int nodeAtomsEnd;
139 >  int mpiErr;
140 >  int sendError;
141 >
142 >  MPI_Status istatus[MPI_STATUS_SIZE];
143 >
144 >  if (worldRank == 0) {
145 >    eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file);
146 >    if( eof_test == NULL ){
147        sprintf( painCave.errMsg,
148 <               "error in reading velocity x from %s\n"
154 <               "natoms  = %d, index = %d\n",
155 <               c_in_name, n_atoms, i );
148 >               "Error reading 1st line of %d \n ",c_in_name);
149        painCave.isFatal = 1;
150        simError();
151      }
159    (void)sscanf( foo, "%lf", &vx );
152      
153 <    foo = strtok(NULL, " ,;\t");
154 <    if(foo == NULL){
153 >    n_atoms = atoi( read_buffer );
154 >    
155 >    Atom **atoms = entry_plug->atoms;
156 >    DirectionalAtom* dAtom;
157 >
158 >    // Check to see that the number of atoms in the intial configuration file is the
159 >    // same as declared in simBass.
160 >    
161 >    if( n_atoms != entry_plug->mpiSim->getTotAtoms() ){
162        sprintf( painCave.errMsg,
163 <               "error in reading velocity y from %s\n"
164 <               "natoms  = %d, index = %d\n",
165 <               c_in_name, n_atoms, i );
163 >               "Initialize from File error. %s n_atoms, %d, "
164 >               "does not match the BASS file's n_atoms, %d.\n",
165 >               c_in_name, n_atoms, entry_plug->n_atoms );
166        painCave.isFatal = 1;
167        simError();
168      }
170    (void)sscanf( foo, "%lf", &vy );
169      
170 <    foo = strtok(NULL, " ,;\t");
171 <    if(foo == NULL){
170 >    //read and toss the comment line
171 >    
172 >    eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file);
173 >    if(eof_test == NULL){
174        sprintf( painCave.errMsg,
175 <               "error in reading velocity z from %s\n"
176 <               "natoms  = %d, index = %d\n",
177 <               c_in_name, n_atoms, i );
175 >               "error in reading commment in %s\n", c_in_name);
176        painCave.isFatal = 1;
177        simError();
178      }
179 <    (void)sscanf( foo, "%lf", &vz );
179 >  
180 >    // Read Proc 0 share of the xyz file...
181 >    masterIndex = 0;
182 >    for( i=0; i <= entry_plug->mpiSim->getMyAtomEnd(); i++){
183      
184 <    
185 <    // get the quaternions
185 <    
186 <    if( atoms[i]->isDirectional() ){
187 <      
188 <      foo = strtok(NULL, " ,;\t");
189 <      if(foo == NULL){
184 >      eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file);
185 >      if(eof_test == NULL){
186          sprintf(painCave.errMsg,
187 <                "error in reading quaternion 0 from %s\n"
188 <                "natoms  = %d, index = %d\n",
187 >                "error in reading file %s\n"
188 >                "natoms  = %d; index = %d\n"
189 >                "error reading the line from the file.\n",
190                  c_in_name, n_atoms, i );
191          painCave.isFatal = 1;
192          simError();
193        }
194 <      (void)sscanf( foo, "%lf", &q[0] );
195 <      
196 <      foo = strtok(NULL, " ,;\t");
197 <      if(foo == NULL){
201 <        sprintf( painCave.errMsg,
202 <                 "error in reading quaternion 1 from %s\n"
203 <                 "natoms  = %d, index = %d\n",
204 <                 c_in_name, n_atoms, i );
194 >    
195 >      parseErr = parseDumpLine( read_buffer, i );
196 >      if( parseErr != NULL ){
197 >        strcpy( painCave.errMsg, parseErr );
198          painCave.isFatal = 1;
199          simError();
200 <      }
201 <      (void)sscanf( foo, "%lf", &q[1] );
202 <      
203 <      foo = strtok(NULL, " ,;\t");
204 <      if(foo == NULL){
205 <        sprintf( painCave.errMsg,
206 <                 "error in reading quaternion 2 from %s\n"
207 <                 "natoms  = %d, index = %d\n",
208 <                 c_in_name, n_atoms, i );
200 >      }    
201 >      masterIndex++;
202 >    }
203 >  }
204 >
205 >  sprintf(checkPointMsg,
206 >          "Node 0 has successfully read positions from input file.");
207 >  mpiCheckPoint();
208 >
209 >  for (procIndex = 1; procIndex < entryPlug->mpiSim->getNumberProcessors();
210 >         procIndex++){
211 >    if (worldRank == 0) {
212 >
213 >      mpiErr = MPI_Recv(&nodeAtomsStart,1,MPI_INT,procIndex,MPI_ANY_TAG,MPI_COMM_WORLD,
214 >               istatus);
215 >
216 >      mpiErr = MPI_Recv(&nodeAtomsEnd,1,MPI_INT,procIndex,MPI_ANY_TAG,MPI_COMM_WORLD,
217 >               istatus);
218 >      // Make sure where node 0 is reading from, matches where the receiving node
219 >      // expects it to be.
220 >
221 >      if (masterIndex != nodeAtomsStart){
222 >        sendError = 1;
223 >        mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,MPI_ANY_TAG,MPI_COMM_WORLD);
224 >        sprintf(painCave.errMsg,
225 >                "Initialize from file error: atoms start index (%d) for "
226 >                "node %d not equal to master index (%d)",nodeAtomsStart,procIndex,masterIndex );
227          painCave.isFatal = 1;
228          simError();
229        }
230 <      (void)sscanf( foo, "%lf", &q[2] );
230 >      sendError = 0;
231 >      mpiErr = MPI_Send(&sendError,1,MPI_INT,procIndex,MPI_ANY_TAG,MPI_COMM_WORLD);
232        
233 <      foo = strtok(NULL, " ,;\t");
234 <      if(foo == NULL){
235 <        sprintf( painCave.errMsg,
236 <                 "error in reading quaternion 3 from %s\n"
237 <                 "natoms  = %d, index = %d\n",
238 <                 c_in_name, n_atoms, i );
239 <        painCave.isFatal = 1;
240 <        simError();
241 <      }
242 <      (void)sscanf( foo, "%lf", &q[3] );
243 <      
244 <      // get the angular velocities
245 <      
246 <      foo = strtok(NULL, " ,;\t");
247 <      if(foo == NULL){
248 <        sprintf( painCave.errMsg,
249 <                 "error in reading angular momentum jx from %s\n"
250 <                 "natoms  = %d, index = %d\n",
251 <                 c_in_name, n_atoms, i );
252 <        painCave.isFatal = 1;
241 <        simError();
242 <      }
243 <      (void)sscanf( foo, "%lf", &jx );
244 <      
245 <      foo = strtok(NULL, " ,;\t");
246 <      if(foo == NULL){
247 <        sprintf( painCave.errMsg,
248 <                 "error in reading angular momentum jy from %s\n"
249 <                 "natoms  = %d, index = %d\n",
250 <                 c_in_name, n_atoms, i );
251 <        painCave.isFatal = 1;
252 <        simError();
253 <      }
254 <      (void)sscanf( foo, "%lf", &jy );
255 <      
256 <      foo = strtok(NULL, " ,;\t");
257 <      if(foo == NULL){
258 <        sprintf( painCave.errMsg,
259 <                 "error in reading angular momentum jz from %s\n"
260 <                 "natoms  = %d, index = %d\n",
261 <                 c_in_name, n_atoms, i );
262 <        painCave.isFatal = 1;
263 <        simError();
264 <      }
265 <      (void)sscanf( foo, "%lf", &jz );
266 <      
267 <      dAtom = ( DirectionalAtom* )atoms[i];
268 <
269 <      // check that the quaternion vector is normalized
270 <
271 <      qSqr = (q[0] * q[0]) + (q[1] * q[1]) + (q[2] * q[2]) + (q[3] * q[3]);
272 <      
273 <      qLength = sqrt( qSqr );
274 <      q[0] = q[0] / qLength;
275 <      q[1] = q[1] / qLength;
276 <      q[2] = q[2] / qLength;
277 <      q[3] = q[3] / qLength;
278 <      
279 <      dAtom->setQ( q );
280 <      
281 <      // add the angular velocities
233 >      for ( i = nodeAtomStart; i <= nodeAtomEnd, i++){
234 >        eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file);
235 >        if(eof_test == NULL){
236 >          
237 >          sprintf(read_buffer,"ERROR");
238 >          mpiErr = MPI_Send(read_buffer,BUFFERSIZE,MPI_CHAR,procIndex,MPI_ANY_TAG,MPI_COMM_WORLD);
239 >          
240 >          sprintf(painCave.errMsg,
241 >                  "error in reading file %s\n"
242 >                  "natoms  = %d; index = %d\n"
243 >                  "error reading the line from the file.\n",
244 >                  c_in_name, n_atoms, i );
245 >          painCave.isFatal = 1;
246 >          simError();
247 >        }
248 >        
249 >        mpiErr = MPI_Send(read_buffer,BUFFERSIZE,MPI_CHAR,procIndex,MPI_ANY_TAG,MPI_COMM_WORLD);
250 >        mpiErr = MPI_Recv(&sendError,1,MPI_INT,procIndex,MPI_ANY_TAG,MPI_COMM_WORLD,
251 >                          istatus);
252 >        if (sendError) mpiCheckpoint();
253  
254 <      dAtom->setJx( jx );
255 <      dAtom->setJy( jy );
285 <      dAtom->setJz( jz );
254 >        masterIndex++;
255 >      }
256      }
257 +
258 +
259 +    else if(worldRank == procIndex){
260 +      nodeAtomStart = entry_plug->mpiSim->getMyAtomStart();
261 +      nodeAtomEnd = entry_plug->mpiSim->getMyAtomEnd();
262 +      mpiErr = MPI_Send(&nodeAtomsStart,1,MPI_INT,0,MPI_ANY_TAG,MPI_COMM_WORLD);
263 +      mpiErr = MPI_Send(&nodeAtomsEnd,1,MPI_INT,0,MPI_ANY_TAG,MPI_COMM_WORLD);
264 +      
265 +      mpiErr = MPI_Recv(&sendError,1,MPI_INT,0,MPI_ANY_TAG,MPI_COMM_WORLD,
266 +               istatus);
267 +      if (sendError) mpiCheckpoint();
268 +
269 +      for ( i = 0; i < entry_plug->n_atoms, i++){
270 +
271 +        mpiErr = MPI_Recv(&read_buffer,BUFFERSIZE,MPI_CHAR,0,MPI_ANY_TAG,MPI_COMM_WORLD,
272 +                          istatus);
273 +        
274 +        if(!strcmp(read_buffer, "ERROR")) mpiCheckPoint();
275 +        
276 +        parseErr = parseDumpLine( read_buffer, i );
277 +        if( parseErr != NULL ){
278 +          sendError = 1;
279 +          mpiErr = MPI_Send(&sendError,1,MPI_INT,0,MPI_ANY_TAG,MPI_COMM_WORLD);
280 +
281 +
282 +          strcpy( painCave.errMsg, parseErr );
283 +          painCave.isFatal = 1;
284 +          simError();
285 +        }
286 +        sendError = 0;
287 +        mpiErr = MPI_Send(&sendError,1,MPI_INT,0,MPI_ANY_TAG,MPI_COMM_WORLD);
288 +      }
289 +    }
290 +    sprintf(checkPointMsg,"Node %d received initial configuration.",procIndex);
291 +    mpiCheckPoint();
292 +  }
293 +
294 + #endif
295 + }
296 +
297 +
298 + char* IntitializeFromFile::parseDumpLine(char* readLine, int atomIndex){
299 +
300 +  char *foo; // the pointer to the current string token
301 +  
302 +  double rx, ry, rz; // position place holders
303 +  double vx, vy, vz; // velocity placeholders
304 +  double q[4]; // the quaternions
305 +  double jx, jy, jz; // angular velocity placeholders;
306 +  double qSqr, qLength; // needed to normalize the quaternion vector.
307 +  
308 +  Atom **atoms = entry_plug->atoms;
309 +  DirectionalAtom* dAtom;
310 +  
311 +  int n_atoms;
312 +
313 + #ifdef IS_MPI
314 +  n_atoms = entry_plug->mpiSim->getTotAtoms();
315 + #else
316 +  n_atoms = entry_plug->n_atoms;
317 + #endi // is_mpi
318 +
319 +
320 +  // set the string tokenizer
321 +  
322 +  foo = strtok(readLine, " ,;\t");
323 +  
324 +  // check the atom name to the current atom
325 +  
326 +  if( strcmp( foo, atoms[atomIndex]->getType() ) ){
327 +    sprintf( painCave.errMsg,
328 +             "Initialize from file error. Atom %s at index %d "
329 +             "in file %s does not"
330 +             " match the BASS atom %s.\n",
331 +             foo, atomIndex, c_in_name, atoms[atomIndex]->getType() );
332 +    return strdup( painCave.errMsg );
333 +  }
334      
335 <    // add the positions and velocities to the atom
335 >  // get the positions
336 >
337 >  foo = strtok(NULL, " ,;\t");
338 >  if(foo == NULL){
339 >    sprintf( painCave.errMsg,
340 >             "error in reading postition x from %s\n"
341 >             "natoms  = %d, index = %d\n",
342 >             c_in_name, n_atoms, atomIndex );
343 >    return strdup( painCave.errMsg );
344 >  }
345 >  rx = atof( foo );
346 >  
347 >  foo = strtok(NULL, " ,;\t");
348 >  if(foo == NULL){
349 >    sprintf( painCave.errMsg,
350 >             "error in reading postition y from %s\n"
351 >             "natoms  = %d, index = %d\n",
352 >             c_in_name, n_atoms, atomIndex );
353 >    return strdup( painCave.errMsg );
354 >  }
355 >  ry = atof( foo );
356 >    
357 >  foo = strtok(NULL, " ,;\t");
358 >  if(foo == NULL){
359 >    sprintf( painCave.errMsg,
360 >             "error in reading postition z from %s\n"
361 >             "natoms  = %d, index = %d\n",
362 >             c_in_name, n_atoms, atomIndex );
363 >    return strdup( painCave.errMsg );
364 >  }
365 >  rz = atof( foo );    
366 >
367 >
368 >  // get the velocities
369 >
370 >  foo = strtok(NULL, " ,;\t");
371 >  if(foo == NULL){
372 >    sprintf( painCave.errMsg,
373 >             "error in reading velocity x from %s\n"
374 >             "natoms  = %d, index = %d\n",
375 >             c_in_name, n_atoms, atomIndex );
376 >    return strdup( painCave.errMsg );
377 >  }
378 >  vx = atof( foo );
379      
380 <    atoms[i]->setX( rx );
381 <    atoms[i]->setY( ry );
382 <    atoms[i]->setZ( rz );
380 >  foo = strtok(NULL, " ,;\t");
381 >  if(foo == NULL){
382 >    sprintf( painCave.errMsg,
383 >             "error in reading velocity y from %s\n"
384 >             "natoms  = %d, index = %d\n",
385 >             c_in_name, n_atoms, atomIndex );
386 >    return strdup( painCave.errMsg );
387 >  }
388 >  vy = atof( foo );
389      
390 <    atoms[i]->set_vx( vx );
391 <    atoms[i]->set_vy( vy );
392 <    atoms[i]->set_vz( vz );
390 >  foo = strtok(NULL, " ,;\t");
391 >  if(foo == NULL){
392 >    sprintf( painCave.errMsg,
393 >             "error in reading velocity z from %s\n"
394 >             "natoms  = %d, index = %d\n",
395 >             c_in_name, n_atoms, atomIndex );
396 >    return strdup( painCave.errMsg );
397 >  }
398 >  vz = atof( foo );
399      
400 +    
401 +  // get the quaternions
402 +    
403 +  if( atoms[atomIndex]->isDirectional() ){
404 +      
405 +    foo = strtok(NULL, " ,;\t");
406 +    if(foo == NULL){
407 +      sprintf(painCave.errMsg,
408 +              "error in reading quaternion 0 from %s\n"
409 +              "natoms  = %d, index = %d\n",
410 +              c_in_name, n_atoms, atomIndex );
411 +      return strdup( painCave.errMsg );
412 +    }
413 +    q[0] = atof( foo );
414 +      
415 +    foo = strtok(NULL, " ,;\t");
416 +    if(foo == NULL){
417 +      sprintf( painCave.errMsg,
418 +               "error in reading quaternion 1 from %s\n"
419 +               "natoms  = %d, index = %d\n",
420 +               c_in_name, n_atoms, atomIndex );
421 +      return strdup( painCave.errMsg );
422 +    }
423 +    q[1] = atof( foo );
424 +      
425 +    foo = strtok(NULL, " ,;\t");
426 +    if(foo == NULL){
427 +      sprintf( painCave.errMsg,
428 +               "error in reading quaternion 2 from %s\n"
429 +               "natoms  = %d, index = %d\n",
430 +               c_in_name, n_atoms, atomIndex );
431 +      return strdup( painCave.errMsg );
432 +    }
433 +    q[2] = atof( foo );
434 +      
435 +    foo = strtok(NULL, " ,;\t");
436 +    if(foo == NULL){
437 +      sprintf( painCave.errMsg,
438 +               "error in reading quaternion 3 from %s\n"
439 +               "natoms  = %d, index = %d\n",
440 +               c_in_name, n_atoms, atomIndex );
441 +      return strdup( painCave.errMsg );
442 +    }
443 +    q[3] = atof( foo );
444 +      
445 +    // get the angular velocities
446 +      
447 +    foo = strtok(NULL, " ,;\t");
448 +    if(foo == NULL){
449 +      sprintf( painCave.errMsg,
450 +               "error in reading angular momentum jx from %s\n"
451 +               "natoms  = %d, index = %d\n",
452 +               c_in_name, n_atoms, atomIndex );
453 +      return strdup( painCave.errMsg );
454 +    }
455 +    jx = atof( foo );
456 +      
457 +    foo = strtok(NULL, " ,;\t");
458 +    if(foo == NULL){
459 +      sprintf( painCave.errMsg,
460 +               "error in reading angular momentum jy from %s\n"
461 +               "natoms  = %d, index = %d\n",
462 +               c_in_name, n_atoms, atomIndex );
463 +      return strdup( painCave.errMsg );
464 +    }
465 +    jy = atof(foo );
466 +      
467 +    foo = strtok(NULL, " ,;\t");
468 +    if(foo == NULL){
469 +      sprintf( painCave.errMsg,
470 +               "error in reading angular momentum jz from %s\n"
471 +               "natoms  = %d, index = %d\n",
472 +               c_in_name, n_atoms, atomIndex );
473 +      return strdup( painCave.errMsg );
474 +    }
475 +    jz = atof( foo );
476 +      
477 +    dAtom = ( DirectionalAtom* )atoms[atomIndex];
478 +
479 +    // check that the quaternion vector is normalized
480 +
481 +    qSqr = (q[0] * q[0]) + (q[1] * q[1]) + (q[2] * q[2]) + (q[3] * q[3]);
482 +      
483 +    qLength = sqrt( qSqr );
484 +    q[0] = q[0] / qLength;
485 +    q[1] = q[1] / qLength;
486 +    q[2] = q[2] / qLength;
487 +    q[3] = q[3] / qLength;
488 +      
489 +    dAtom->setQ( q );
490 +      
491 +    // add the angular velocities
492 +
493 +    dAtom->setJx( jx );
494 +    dAtom->setJy( jy );
495 +    dAtom->setJz( jz );
496    }
497 +    
498 +  // add the positions and velocities to the atom
499 +    
500 +  atoms[atomIndex]->setX( rx );
501 +  atoms[atomIndex]->setY( ry );
502 +  atoms[atomIndex]->setZ( rz );
503 +    
504 +  atoms[atomIndex]->set_vx( vx );
505 +  atoms[atomIndex]->set_vy( vy );
506 +  atoms[atomIndex]->set_vz( vz );
507 +
508 +  return NULL;
509   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines