85 |
|
#endif //is_mpi |
86 |
|
|
87 |
|
const int BUFFERSIZE = 2000; // size of the read buffer |
88 |
< |
int n_atoms; // the number of atoms |
88 |
> |
int nTotObjs; // the number of atoms |
89 |
|
char read_buffer[BUFFERSIZE]; //the line buffer for reading |
90 |
|
|
91 |
|
char *eof_test; // ptr to see when we reach the end of the file |
92 |
|
char *parseErr; |
93 |
|
|
94 |
+ |
vector<StuntDouble*> integrableObjects; |
95 |
+ |
|
96 |
|
simnfo = the_simnfo; |
97 |
|
|
98 |
|
|
106 |
|
simError(); |
107 |
|
} |
108 |
|
|
109 |
< |
n_atoms = atoi( read_buffer ); |
109 |
> |
nTotObjs = atoi( read_buffer ); |
110 |
|
|
111 |
< |
if( n_atoms != simnfo->n_atoms ){ |
111 |
> |
if( nTotObjs != simnfo->getTotIntegrableObjects() ){ |
112 |
|
sprintf( painCave.errMsg, |
113 |
|
"Initialize from File error. %s n_atoms, %d, " |
114 |
|
"does not match the BASS file's n_atoms, %d.\n", |
115 |
< |
c_in_name, n_atoms, simnfo->n_atoms ); |
115 |
> |
c_in_name, nTotObjs, simnfo->getTotIntegrableObjects()); |
116 |
|
painCave.isFatal = 1; |
117 |
|
simError(); |
118 |
|
} |
127 |
|
simError(); |
128 |
|
} |
129 |
|
|
128 |
– |
|
129 |
– |
|
130 |
|
parseErr = parseCommentLine( read_buffer, simnfo); |
131 |
|
if( parseErr != NULL ){ |
132 |
|
strcpy( painCave.errMsg, parseErr ); |
136 |
|
|
137 |
|
//parse dump lines |
138 |
|
|
139 |
< |
for( i=0; i < n_atoms; i++){ |
139 |
> |
for( i=0; i < simnfo->n_mol; i++){ |
140 |
|
|
141 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
142 |
< |
if(eof_test == NULL){ |
143 |
< |
sprintf(painCave.errMsg, |
144 |
< |
"error in reading file %s\n" |
145 |
< |
"natoms = %d; index = %d\n" |
146 |
< |
"error reading the line from the file.\n", |
147 |
< |
c_in_name, n_atoms, i ); |
148 |
< |
painCave.isFatal = 1; |
149 |
< |
simError(); |
150 |
< |
} |
141 |
> |
integrableObjects = (simnfo->molecules[i]).getIntegrableObjects(); |
142 |
|
|
143 |
+ |
for(j = 0; j < integrableObjects.size(); j++){ |
144 |
|
|
145 |
< |
parseErr = parseDumpLine( read_buffer, i ); |
146 |
< |
if( parseErr != NULL ){ |
147 |
< |
strcpy( painCave.errMsg, parseErr ); |
148 |
< |
painCave.isFatal = 1; |
149 |
< |
simError(); |
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 file %s\n" |
149 |
> |
"natoms = %d; index = %d\n" |
150 |
> |
"error reading the line from the file.\n", |
151 |
> |
c_in_name, nTotObjs, i ); |
152 |
> |
painCave.isFatal = 1; |
153 |
> |
simError(); |
154 |
> |
} |
155 |
> |
|
156 |
> |
parseErr = parseDumpLine( read_buffer, integrableObjects[j]); |
157 |
> |
if( parseErr != NULL ){ |
158 |
> |
strcpy( painCave.errMsg, parseErr ); |
159 |
> |
painCave.isFatal = 1; |
160 |
> |
simError(); |
161 |
> |
} |
162 |
|
} |
163 |
|
} |
164 |
|
|
161 |
– |
|
165 |
|
// MPI Section of code.......... |
166 |
|
#else //IS_MPI |
167 |
|
|
172 |
|
int haveError; |
173 |
|
|
174 |
|
MPI_Status istatus; |
175 |
< |
int *AtomToProcMap = mpiSim->getAtomToProcMap(); |
175 |
> |
int *MolToProcMap = mpiSim->getMolToProcMap(); |
176 |
> |
int localIndex; |
177 |
> |
int nCurObj; |
178 |
|
|
174 |
– |
|
179 |
|
haveError = 0; |
180 |
|
if (worldRank == 0) { |
181 |
|
|
187 |
|
simError(); |
188 |
|
} |
189 |
|
|
190 |
< |
n_atoms = atoi( read_buffer ); |
190 |
> |
nTotObjs = atoi( read_buffer ); |
191 |
|
|
192 |
< |
// Check to see that the number of atoms in the intial configuration file is the |
192 |
> |
// Check to see that the number of integrable objects in the intial configuration file is the |
193 |
|
// same as declared in simBass. |
194 |
|
|
195 |
< |
if( n_atoms != mpiSim->getTotAtoms() ){ |
195 |
> |
if( nTotObjs != simnfo->getTotIntegrableObjects()){ |
196 |
|
sprintf( painCave.errMsg, |
197 |
|
"Initialize from File error. %s n_atoms, %d, " |
198 |
|
"does not match the BASS file's n_atoms, %d.\n", |
199 |
< |
c_in_name, n_atoms, simnfo->n_atoms ); |
199 |
> |
c_in_name, nTotObjs, simnfo->getTotIntegrableObjects()); |
200 |
|
haveError= 1; |
201 |
|
simError(); |
202 |
|
} |
226 |
|
simError(); |
227 |
|
} |
228 |
|
|
229 |
< |
for (i=0 ; i < mpiSim->getTotAtoms(); i++) { |
229 |
> |
for (i=0 ; i < mpiSim->getTotNmol(); i++) { |
230 |
> |
which_node = MolToProcMap[i]; |
231 |
> |
if(which_node == 0){ |
232 |
> |
//molecules belong to master node |
233 |
|
|
234 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
235 |
< |
if(eof_test == NULL){ |
236 |
< |
sprintf(painCave.errMsg, |
237 |
< |
"error in reading file %s\n" |
238 |
< |
"natoms = %d; index = %d\n" |
239 |
< |
"error reading the line from the file.\n", |
233 |
< |
c_in_name, n_atoms, i ); |
234 |
< |
haveError= 1; |
235 |
< |
simError(); |
234 |
> |
localIndex = mpiSim->getGlobalToLocalMol(i); |
235 |
> |
|
236 |
> |
if(localIndex == -1) { |
237 |
> |
strcpy(painCave.errMsg, "Molecule not found on node 0!"); |
238 |
> |
haveError = 1; |
239 |
> |
simError(); |
240 |
|
} |
241 |
|
|
242 |
< |
if(haveError) nodeZeroError(); |
242 |
> |
integrableObjects = (simnfo->molecules[localIndex]).getIntegrableObjects(); |
243 |
> |
for(j=0; j < integrableObjects.size(); j++){ |
244 |
> |
|
245 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
246 |
> |
if(eof_test == NULL){ |
247 |
> |
sprintf(painCave.errMsg, |
248 |
> |
"error in reading file %s\n" |
249 |
> |
"natoms = %d; index = %d\n" |
250 |
> |
"error reading the line from the file.\n", |
251 |
> |
c_in_name, nTotObjs, i ); |
252 |
> |
haveError= 1; |
253 |
> |
simError(); |
254 |
> |
} |
255 |
> |
|
256 |
> |
if(haveError) nodeZeroError(); |
257 |
|
|
258 |
< |
// Get the Node number which wants this atom: |
259 |
< |
which_node = AtomToProcMap[i]; |
260 |
< |
if (which_node == 0) { |
261 |
< |
parseErr = parseDumpLine( read_buffer, i ); |
262 |
< |
if( parseErr != NULL ){ |
245 |
< |
strcpy( painCave.errMsg, parseErr ); |
246 |
< |
haveError = 1; |
247 |
< |
simError(); |
248 |
< |
} |
249 |
< |
if(haveError) nodeZeroError(); |
258 |
> |
parseDumpLine(read_buffer, integrableObjects[i]); |
259 |
> |
|
260 |
> |
} |
261 |
> |
|
262 |
> |
|
263 |
|
} |
264 |
+ |
else{ |
265 |
+ |
//molecule belongs to slave nodes |
266 |
|
|
267 |
< |
else { |
267 |
> |
MPI_Recv(&nCurObj, 1, MPI_INT, 0, |
268 |
> |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
269 |
> |
|
270 |
> |
for(j=0; j < integrableObjects.size(); j++){ |
271 |
> |
|
272 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
273 |
> |
if(eof_test == NULL){ |
274 |
> |
sprintf(painCave.errMsg, |
275 |
> |
"error in reading file %s\n" |
276 |
> |
"natoms = %d; index = %d\n" |
277 |
> |
"error reading the line from the file.\n", |
278 |
> |
c_in_name, nTotObjs, i ); |
279 |
> |
haveError= 1; |
280 |
> |
simError(); |
281 |
> |
} |
282 |
> |
|
283 |
> |
if(haveError) nodeZeroError(); |
284 |
|
|
285 |
< |
myStatus = 1; |
286 |
< |
MPI_Send(&myStatus, 1, MPI_INT, which_node, |
287 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
288 |
< |
MPI_Send(read_buffer, BUFFERSIZE, MPI_CHAR, which_node, |
258 |
< |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD); |
259 |
< |
MPI_Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, |
260 |
< |
MPI_COMM_WORLD); |
261 |
< |
MPI_Recv(&myStatus, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, |
262 |
< |
MPI_COMM_WORLD, &istatus); |
285 |
> |
MPI_Send(read_buffer, BUFFERSIZE, MPI_CHAR, which_node, |
286 |
> |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD); |
287 |
> |
|
288 |
> |
} |
289 |
|
|
264 |
– |
if(!myStatus) nodeZeroError(); |
290 |
|
} |
291 |
+ |
|
292 |
|
} |
293 |
< |
myStatus = -1; |
294 |
< |
for (j = 1; j < mpiSim->getNumberProcessors(); j++) { |
295 |
< |
MPI_Send( &myStatus, 1, MPI_INT, j, |
296 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
297 |
< |
} |
293 |
> |
|
294 |
> |
} |
295 |
> |
else{ |
296 |
> |
//actions taken at slave nodes |
297 |
> |
for (i=0 ; i < mpiSim->getTotNmol(); i++) { |
298 |
> |
which_node = MolToProcMap[i]; |
299 |
> |
|
300 |
> |
if(which_node == worldRank){ |
301 |
> |
//molecule with global index i belongs to this processor |
302 |
> |
|
303 |
> |
localIndex = mpiSim->getGlobalToLocalMol(i); |
304 |
|
|
305 |
< |
} else { |
305 |
> |
if(localIndex == -1) { |
306 |
> |
sprintf(painCave.errMsg, "Molecule not found on node %d\n", worldRank); |
307 |
> |
haveError = 1; |
308 |
> |
simError(); |
309 |
> |
} |
310 |
|
|
311 |
< |
MPI_Bcast(read_buffer, BUFFERSIZE, MPI_CHAR, 0, MPI_COMM_WORLD); |
311 |
> |
integrableObjects = (simnfo->molecules[localIndex]).getIntegrableObjects(); |
312 |
|
|
313 |
< |
parseErr = parseCommentLine( read_buffer, simnfo); |
313 |
> |
nCurObj = integrableObjects.size(); |
314 |
> |
|
315 |
> |
MPI_Recv(&nCurObj, 1, MPI_INT, 0, |
316 |
> |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
317 |
|
|
318 |
< |
if( parseErr != NULL ){ |
319 |
< |
strcpy( painCave.errMsg, parseErr ); |
320 |
< |
haveError = 1; |
321 |
< |
simError(); |
283 |
< |
} |
318 |
> |
for(j = 0; j < integrableObjects.size(); j++){ |
319 |
> |
|
320 |
> |
MPI_Recv(read_buffer, BUFFERSIZE, MPI_CHAR, 0, |
321 |
> |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD, &istatus); |
322 |
|
|
323 |
+ |
parseErr = parseDumpLine(read_buffer, integrableObjects[j]); |
324 |
|
|
325 |
< |
done = 0; |
326 |
< |
while (!done) { |
325 |
> |
if( parseErr != NULL ){ |
326 |
> |
strcpy( painCave.errMsg, parseErr ); |
327 |
> |
simError(); |
328 |
> |
} |
329 |
|
|
330 |
< |
MPI_Recv(&myStatus, 1, MPI_INT, 0, |
331 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
291 |
< |
|
292 |
< |
if(!myStatus) anonymousNodeDie(); |
293 |
< |
|
294 |
< |
if(myStatus < 0) break; |
295 |
< |
|
296 |
< |
MPI_Recv(read_buffer, BUFFERSIZE, MPI_CHAR, 0, |
297 |
< |
TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD, &istatus); |
298 |
< |
MPI_Recv(&which_atom, 1, MPI_INT, 0, |
299 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); |
300 |
< |
|
301 |
< |
myStatus = 1; |
302 |
< |
parseErr = parseDumpLine( read_buffer, which_atom ); |
303 |
< |
if( parseErr != NULL ){ |
304 |
< |
strcpy( painCave.errMsg, parseErr ); |
305 |
< |
myStatus = 0;; |
306 |
< |
simError(); |
330 |
> |
} |
331 |
> |
|
332 |
|
} |
333 |
< |
|
309 |
< |
MPI_Send( &myStatus, 1, MPI_INT, 0, |
310 |
< |
TAKE_THIS_TAG_INT, MPI_COMM_WORLD); |
311 |
< |
|
333 |
> |
|
334 |
|
} |
313 |
– |
} |
335 |
|
|
336 |
< |
// last thing last, enable fatalities. |
316 |
< |
painCave.isEventLoop = 0; |
317 |
< |
|
318 |
< |
|
319 |
< |
|
336 |
> |
} |
337 |
|
#endif |
338 |
|
} |
339 |
|
|
340 |
< |
char* InitializeFromFile::parseDumpLine(char* readLine, int globalIndex){ |
340 |
> |
char* InitializeFromFile::parseDumpLine(char* readLine, StuntDouble* sd){ |
341 |
|
|
342 |
|
char *foo; // the pointer to the current string token |
343 |
|
|
344 |
|
double pos[3]; // position place holders |
345 |
|
double vel[3]; // velocity placeholders |
346 |
|
double q[4]; // the quaternions |
347 |
< |
double jx, jy, jz; // angular velocity placeholders; |
347 |
> |
double ji[3]; // angular velocity placeholders; |
348 |
|
double qSqr, qLength; // needed to normalize the quaternion vector. |
349 |
|
|
333 |
– |
Atom **atoms = simnfo->atoms; |
334 |
– |
DirectionalAtom* dAtom; |
350 |
|
|
336 |
– |
int n_atoms, atomIndex; |
337 |
– |
|
338 |
– |
#ifdef IS_MPI |
339 |
– |
int j; |
340 |
– |
|
341 |
– |
n_atoms = mpiSim->getTotAtoms(); |
342 |
– |
atomIndex=-1; |
343 |
– |
for (j=0; j < mpiSim->getMyNlocal(); j++) { |
344 |
– |
if (atoms[j]->getGlobalIndex() == globalIndex) atomIndex = j; |
345 |
– |
} |
346 |
– |
if (atomIndex == -1) { |
347 |
– |
sprintf( painCave.errMsg, |
348 |
– |
"Initialize from file error. Atom at index %d " |
349 |
– |
"in file %s does not exist on processor %d .\n", |
350 |
– |
globalIndex, c_in_name, mpiSim->getMyNode() ); |
351 |
– |
return strdup( painCave.errMsg ); |
352 |
– |
} |
353 |
– |
#else |
354 |
– |
n_atoms = simnfo->n_atoms; |
355 |
– |
atomIndex = globalIndex; |
356 |
– |
#endif // is_mpi |
357 |
– |
|
351 |
|
// set the string tokenizer |
352 |
|
|
353 |
|
foo = strtok(readLine, " ,;\t"); |
354 |
|
|
355 |
|
// check the atom name to the current atom |
356 |
|
|
357 |
< |
if( strcmp( foo, atoms[atomIndex]->getType() ) ){ |
357 |
> |
if( strcmp( foo, sd->getType() ) ){ |
358 |
|
sprintf( painCave.errMsg, |
359 |
< |
"Initialize from file error. Atom %s at index %d " |
367 |
< |
"in file %s does not" |
359 |
> |
"Initialize from file error. Does not" |
360 |
|
" match the BASS atom %s.\n", |
361 |
< |
foo, atomIndex, c_in_name, atoms[atomIndex]->getType() ); |
361 |
> |
sd->getType() ); |
362 |
|
return strdup( painCave.errMsg ); |
363 |
|
} |
364 |
|
|
367 |
|
foo = strtok(NULL, " ,;\t"); |
368 |
|
if(foo == NULL){ |
369 |
|
sprintf( painCave.errMsg, |
370 |
< |
"error in reading postition x from %s\n" |
371 |
< |
"natoms = %d, index = %d\n", |
380 |
< |
c_in_name, n_atoms, atomIndex ); |
370 |
> |
"error in reading postition x from %s\n", |
371 |
> |
c_in_name); |
372 |
|
return strdup( painCave.errMsg ); |
373 |
|
} |
374 |
|
pos[0] = atof( foo ); |
376 |
|
foo = strtok(NULL, " ,;\t"); |
377 |
|
if(foo == NULL){ |
378 |
|
sprintf( painCave.errMsg, |
379 |
< |
"error in reading postition y from %s\n" |
380 |
< |
"natoms = %d, index = %d\n", |
390 |
< |
c_in_name, n_atoms, atomIndex ); |
379 |
> |
"error in reading postition y from %s\n", |
380 |
> |
c_in_name); |
381 |
|
return strdup( painCave.errMsg ); |
382 |
|
} |
383 |
|
pos[1] = atof( foo ); |
385 |
|
foo = strtok(NULL, " ,;\t"); |
386 |
|
if(foo == NULL){ |
387 |
|
sprintf( painCave.errMsg, |
388 |
< |
"error in reading postition z from %s\n" |
389 |
< |
"natoms = %d, index = %d\n", |
400 |
< |
c_in_name, n_atoms, atomIndex ); |
388 |
> |
"error in reading postition z from %s\n", |
389 |
> |
c_in_name); |
390 |
|
return strdup( painCave.errMsg ); |
391 |
|
} |
392 |
|
pos[2] = atof( foo ); |
397 |
|
foo = strtok(NULL, " ,;\t"); |
398 |
|
if(foo == NULL){ |
399 |
|
sprintf( painCave.errMsg, |
400 |
< |
"error in reading velocity x from %s\n" |
401 |
< |
"natoms = %d, index = %d\n", |
413 |
< |
c_in_name, n_atoms, atomIndex ); |
400 |
> |
"error in reading velocity x from %s\n", |
401 |
> |
c_in_name ); |
402 |
|
return strdup( painCave.errMsg ); |
403 |
|
} |
404 |
|
vel[0] = atof( foo ); |
406 |
|
foo = strtok(NULL, " ,;\t"); |
407 |
|
if(foo == NULL){ |
408 |
|
sprintf( painCave.errMsg, |
409 |
< |
"error in reading velocity y from %s\n" |
410 |
< |
"natoms = %d, index = %d\n", |
423 |
< |
c_in_name, n_atoms, atomIndex ); |
409 |
> |
"error in reading velocity x from %s\n", |
410 |
> |
c_in_name ); |
411 |
|
return strdup( painCave.errMsg ); |
412 |
|
} |
413 |
|
vel[1] = atof( foo ); |
415 |
|
foo = strtok(NULL, " ,;\t"); |
416 |
|
if(foo == NULL){ |
417 |
|
sprintf( painCave.errMsg, |
418 |
< |
"error in reading velocity z from %s\n" |
419 |
< |
"natoms = %d, index = %d\n", |
433 |
< |
c_in_name, n_atoms, atomIndex ); |
418 |
> |
"error in reading velocity x from %s\n", |
419 |
> |
c_in_name ); |
420 |
|
return strdup( painCave.errMsg ); |
421 |
|
} |
422 |
|
vel[2] = atof( foo ); |
423 |
|
|
424 |
|
|
425 |
+ |
// add the positions and velocities to the atom |
426 |
+ |
|
427 |
+ |
sd->setPos( pos ); |
428 |
+ |
sd->setVel( vel ); |
429 |
+ |
|
430 |
+ |
if (!sd->isDirectional()) |
431 |
+ |
return NULL; |
432 |
+ |
|
433 |
|
// get the quaternions |
434 |
|
|
435 |
< |
if( atoms[atomIndex]->isDirectional() ){ |
435 |
> |
if( sd->isDirectional() ){ |
436 |
|
|
437 |
|
foo = strtok(NULL, " ,;\t"); |
438 |
|
if(foo == NULL){ |
439 |
< |
sprintf(painCave.errMsg, |
440 |
< |
"error in reading quaternion 0 from %s\n" |
441 |
< |
"natoms = %d, index = %d\n", |
448 |
< |
c_in_name, n_atoms, atomIndex ); |
439 |
> |
sprintf( painCave.errMsg, |
440 |
> |
"error in reading velocity x from %s\n", |
441 |
> |
c_in_name ); |
442 |
|
return strdup( painCave.errMsg ); |
443 |
|
} |
444 |
|
q[0] = atof( foo ); |
446 |
|
foo = strtok(NULL, " ,;\t"); |
447 |
|
if(foo == NULL){ |
448 |
|
sprintf( painCave.errMsg, |
449 |
< |
"error in reading quaternion 1 from %s\n" |
450 |
< |
"natoms = %d, index = %d\n", |
458 |
< |
c_in_name, n_atoms, atomIndex ); |
449 |
> |
"error in reading velocity x from %s\n", |
450 |
> |
c_in_name ); |
451 |
|
return strdup( painCave.errMsg ); |
452 |
|
} |
453 |
|
q[1] = atof( foo ); |
455 |
|
foo = strtok(NULL, " ,;\t"); |
456 |
|
if(foo == NULL){ |
457 |
|
sprintf( painCave.errMsg, |
458 |
< |
"error in reading quaternion 2 from %s\n" |
459 |
< |
"natoms = %d, index = %d\n", |
468 |
< |
c_in_name, n_atoms, atomIndex ); |
458 |
> |
"error in reading velocity x from %s\n", |
459 |
> |
c_in_name ); |
460 |
|
return strdup( painCave.errMsg ); |
461 |
|
} |
462 |
|
q[2] = atof( foo ); |
464 |
|
foo = strtok(NULL, " ,;\t"); |
465 |
|
if(foo == NULL){ |
466 |
|
sprintf( painCave.errMsg, |
467 |
< |
"error in reading quaternion 3 from %s\n" |
468 |
< |
"natoms = %d, index = %d\n", |
478 |
< |
c_in_name, n_atoms, atomIndex ); |
467 |
> |
"error in reading velocity x from %s\n", |
468 |
> |
c_in_name ); |
469 |
|
return strdup( painCave.errMsg ); |
470 |
|
} |
471 |
|
q[3] = atof( foo ); |
475 |
|
foo = strtok(NULL, " ,;\t"); |
476 |
|
if(foo == NULL){ |
477 |
|
sprintf( painCave.errMsg, |
478 |
< |
"error in reading angular momentum jx from %s\n" |
479 |
< |
"natoms = %d, index = %d\n", |
490 |
< |
c_in_name, n_atoms, atomIndex ); |
478 |
> |
"error in reading velocity x from %s\n", |
479 |
> |
c_in_name ); |
480 |
|
return strdup( painCave.errMsg ); |
481 |
|
} |
482 |
< |
jx = atof( foo ); |
482 |
> |
ji[0] = atof( foo ); |
483 |
|
|
484 |
|
foo = strtok(NULL, " ,;\t"); |
485 |
|
if(foo == NULL){ |
486 |
|
sprintf( painCave.errMsg, |
487 |
< |
"error in reading angular momentum jy from %s\n" |
488 |
< |
"natoms = %d, index = %d\n", |
500 |
< |
c_in_name, n_atoms, atomIndex ); |
487 |
> |
"error in reading velocity x from %s\n", |
488 |
> |
c_in_name ); |
489 |
|
return strdup( painCave.errMsg ); |
490 |
|
} |
491 |
< |
jy = atof(foo ); |
491 |
> |
ji[1] = atof(foo ); |
492 |
|
|
493 |
|
foo = strtok(NULL, " ,;\t"); |
494 |
|
if(foo == NULL){ |
495 |
|
sprintf( painCave.errMsg, |
496 |
< |
"error in reading angular momentum jz from %s\n" |
497 |
< |
"natoms = %d, index = %d\n", |
510 |
< |
c_in_name, n_atoms, atomIndex ); |
496 |
> |
"error in reading velocity x from %s\n", |
497 |
> |
c_in_name ); |
498 |
|
return strdup( painCave.errMsg ); |
499 |
|
} |
500 |
< |
jz = atof( foo ); |
500 |
> |
ji[2] = atof( foo ); |
501 |
|
|
515 |
– |
dAtom = ( DirectionalAtom* )atoms[atomIndex]; |
502 |
|
|
503 |
|
// check that the quaternion vector is normalized |
504 |
|
|
510 |
|
q[2] = q[2] / qLength; |
511 |
|
q[3] = q[3] / qLength; |
512 |
|
|
513 |
< |
dAtom->setQ( q ); |
513 |
> |
// add quaternion and angular velocities |
514 |
|
|
515 |
< |
// add the angular velocities |
516 |
< |
|
531 |
< |
dAtom->setJx( jx ); |
532 |
< |
dAtom->setJy( jy ); |
533 |
< |
dAtom->setJz( jz ); |
515 |
> |
sd->setQ( q ); |
516 |
> |
sd->setJ( ji ); |
517 |
|
} |
518 |
|
|
536 |
– |
// add the positions and velocities to the atom |
519 |
|
|
538 |
– |
atoms[atomIndex]->setPos( pos ); |
539 |
– |
atoms[atomIndex]->setVel( vel ); |
520 |
|
|
521 |
|
return NULL; |
522 |
|
} |