14 |
|
n_bends = 0; |
15 |
|
n_torsions = 0; |
16 |
|
n_rigidbodies = 0; |
17 |
+ |
n_cutoffgroups = 0; |
18 |
+ |
n_integrable = 0; |
19 |
|
|
20 |
|
unhandled = NULL; |
21 |
|
atoms = NULL; |
23 |
|
bends = NULL; |
24 |
|
torsions = NULL; |
25 |
|
rigidBodies = NULL; |
26 |
+ |
cutoffGroups = NULL; |
27 |
|
|
28 |
|
have_name = 0; |
29 |
|
have_atoms = 0; |
31 |
|
have_bends = 0; |
32 |
|
have_torsions = 0; |
33 |
|
have_rigidbodies = 0; |
34 |
+ |
have_cutoffgroups = 0; |
35 |
|
|
36 |
|
} |
37 |
|
|
43 |
|
if( rigidBodies != NULL ) { |
44 |
|
for( i=0; i<n_rigidbodies; i++ ) delete rigidBodies[i]; |
45 |
|
} |
46 |
+ |
|
47 |
+ |
if( cutoffGroups != NULL ) { |
48 |
+ |
for( i=0; i<n_cutoffgroups; i++ ) delete cutoffGroups[i]; |
49 |
+ |
} |
50 |
|
|
51 |
|
if( atoms != NULL ){ |
52 |
|
for( i=0; i<n_atoms; i++ ) delete atoms[i]; |
89 |
|
if( have_atoms ){ |
90 |
|
sprintf( errMsg, |
91 |
|
"MoleculeStamp error, n_atoms already declared" |
92 |
< |
"for molecule: %s\n", |
92 |
> |
" for molecule: %s\n", |
93 |
|
name); |
94 |
|
return strdup( errMsg ); |
95 |
|
} |
158 |
|
for( i=0; i<n_rigidbodies; i++ ) rigidBodies[i] = NULL; |
159 |
|
} |
160 |
|
|
161 |
+ |
else if( !strcmp( lhs, "nCutoffGroups" ) ){ |
162 |
+ |
n_cutoffgroups = (int)rhs; |
163 |
+ |
|
164 |
+ |
if( have_cutoffgroups ){ |
165 |
+ |
sprintf( errMsg, |
166 |
+ |
"MoleculeStamp error, n_cutoffgroups already declared for" |
167 |
+ |
" molecule: %s\n", |
168 |
+ |
name ); |
169 |
+ |
return strdup( errMsg ); |
170 |
+ |
} |
171 |
+ |
have_cutoffgroups = 1; |
172 |
+ |
cutoffGroups = new CutoffGroupStamp*[n_cutoffgroups]; |
173 |
+ |
for( i=0; i<n_cutoffgroups; i++ ) cutoffGroups[i] = NULL; |
174 |
+ |
} |
175 |
+ |
|
176 |
|
else{ |
177 |
|
if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs ); |
178 |
|
else unhandled->add( lhs, rhs ); |
249 |
|
|
250 |
|
if( have_rigidbodies ){ |
251 |
|
sprintf( errMsg, |
252 |
< |
"RigidBodyStamp error, n_rigidbodies already declared for" |
252 |
> |
"MoleculeStamp error, n_rigidbodies already declared for" |
253 |
|
" molecule: %s\n", |
254 |
|
name); |
255 |
|
return strdup( errMsg ); |
258 |
|
rigidBodies = new RigidBodyStamp*[n_rigidbodies]; |
259 |
|
for( i=0; i<n_rigidbodies; i++ ) rigidBodies[i] = NULL; |
260 |
|
} |
261 |
+ |
else if( !strcmp( lhs, "nCutoffGroups" ) ){ |
262 |
+ |
n_cutoffgroups = rhs; |
263 |
+ |
|
264 |
+ |
if( have_cutoffgroups ){ |
265 |
+ |
sprintf( errMsg, |
266 |
+ |
"MoleculeStamp error, n_cutoffgroups already declared for" |
267 |
+ |
" molecule: %s\n", |
268 |
+ |
name); |
269 |
+ |
return strdup( errMsg ); |
270 |
+ |
} |
271 |
+ |
have_cutoffgroups = 1; |
272 |
+ |
cutoffGroups = new CutoffGroupStamp*[n_cutoffgroups]; |
273 |
+ |
for( i=0; i<n_cutoffgroups; i++ ) cutoffGroups[i] = NULL; |
274 |
+ |
} |
275 |
|
else{ |
276 |
|
if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs ); |
277 |
|
else unhandled->add( lhs, rhs ); |
283 |
|
char* MoleculeStamp::addAtom( AtomStamp* the_atom, int atomIndex ){ |
284 |
|
|
285 |
|
if( have_atoms && atomIndex < n_atoms ) atoms[atomIndex] = the_atom; |
286 |
< |
else{ |
286 |
> |
else { |
287 |
|
if( have_atoms ){ |
288 |
|
sprintf( errMsg, "MoleculeStamp error, %d out of nAtoms range", |
289 |
|
atomIndex ); |
290 |
|
return strdup( errMsg ); |
291 |
|
} |
292 |
|
else return strdup("MoleculeStamp error, nAtoms not given before" |
293 |
< |
"first atom declaration." ); |
293 |
> |
" first atom declaration." ); |
294 |
|
} |
295 |
|
|
296 |
|
return NULL; |
301 |
|
|
302 |
|
if( have_rigidbodies && rigidBodyIndex < n_rigidbodies ) |
303 |
|
rigidBodies[rigidBodyIndex] = the_rigidbody; |
304 |
< |
else{ |
304 |
> |
else { |
305 |
|
if( have_rigidbodies ){ |
306 |
|
sprintf( errMsg, "MoleculeStamp error, %d out of nRigidBodies range", |
307 |
|
rigidBodyIndex ); |
308 |
|
return strdup( errMsg ); |
309 |
|
} |
310 |
|
else return strdup("MoleculeStamp error, nRigidBodies not given before" |
311 |
< |
"first rigidBody declaration." ); |
311 |
> |
" first rigidBody declaration." ); |
312 |
|
} |
313 |
|
|
314 |
|
return NULL; |
315 |
|
} |
316 |
|
|
317 |
+ |
char* MoleculeStamp::addCutoffGroup( CutoffGroupStamp* the_cutoffgroup, |
318 |
+ |
int cutoffGroupIndex ){ |
319 |
+ |
|
320 |
+ |
if( have_cutoffgroups && cutoffGroupIndex < n_cutoffgroups ) |
321 |
+ |
cutoffGroups[cutoffGroupIndex] = the_cutoffgroup; |
322 |
+ |
else { |
323 |
+ |
if( have_cutoffgroups ){ |
324 |
+ |
sprintf( errMsg, "MoleculeStamp error, %d out of nCutoffGroups range", |
325 |
+ |
cutoffGroupIndex ); |
326 |
+ |
return strdup( errMsg ); |
327 |
+ |
} |
328 |
+ |
else return strdup("MoleculeStamp error, nCutoffGroups not given before" |
329 |
+ |
" first CutoffGroup declaration." ); |
330 |
+ |
} |
331 |
+ |
|
332 |
+ |
return NULL; |
333 |
+ |
} |
334 |
+ |
|
335 |
|
char* MoleculeStamp::addBond( BondStamp* the_bond, int bondIndex ){ |
336 |
|
|
337 |
|
|
387 |
|
char* MoleculeStamp::checkMe( void ){ |
388 |
|
|
389 |
|
int i; |
390 |
< |
short int no_atom, no_rigidbody; |
390 |
> |
short int no_atom, no_rigidbody, no_cutoffgroup; |
391 |
|
|
337 |
– |
// Fix for Rigid Bodies!!! Molecules may not have any atoms that |
338 |
– |
// they know about. They might have only rigid bodies (which then |
339 |
– |
// know about the atoms! |
340 |
– |
|
341 |
– |
|
392 |
|
if( !have_name ) return strdup( "MoleculeStamp error. Molecule's name" |
393 |
|
" was not given.\n" ); |
394 |
< |
|
395 |
< |
if( !have_rigidbodies && !have_atoms ){ |
396 |
< |
return strdup( "MoleculeStamp error. Molecule contains no atoms or RigidBodies." ); |
394 |
> |
|
395 |
> |
if( !have_atoms ){ |
396 |
> |
return strdup( "MoleculeStamp error. Molecule contains no atoms." ); |
397 |
|
} |
398 |
|
|
399 |
|
no_rigidbody = 0; |
408 |
|
return strdup( errMsg ); |
409 |
|
} |
410 |
|
|
411 |
+ |
no_cutoffgroup = 0; |
412 |
+ |
for( i=0; i<n_cutoffgroups; i++ ){ |
413 |
+ |
if( cutoffGroups[i] == NULL ) no_cutoffgroup = 1; |
414 |
+ |
} |
415 |
+ |
|
416 |
+ |
if( no_cutoffgroup ){ |
417 |
+ |
sprintf( errMsg, |
418 |
+ |
"MoleculeStamp error. Not all of the CutoffGroups were" |
419 |
+ |
" declared in molecule \"%s\".\n", name ); |
420 |
+ |
return strdup( errMsg ); |
421 |
+ |
} |
422 |
+ |
|
423 |
|
no_atom = 0; |
424 |
|
for( i=0; i<n_atoms; i++ ){ |
425 |
|
if( atoms[i] == NULL ) no_atom = 1; |
432 |
|
return strdup( errMsg ); |
433 |
|
} |
434 |
|
|
435 |
< |
return NULL; |
436 |
< |
} |
437 |
< |
|
438 |
< |
|
439 |
< |
int MoleculeStamp::getTotAtoms() { |
440 |
< |
int total_atoms; |
441 |
< |
int i; |
442 |
< |
|
443 |
< |
total_atoms = n_atoms; |
382 |
< |
|
383 |
< |
if( rigidBodies != NULL ) { |
384 |
< |
for( i=0; i<n_rigidbodies; i++ ) |
385 |
< |
total_atoms += rigidBodies[i]->getNAtoms(); |
435 |
> |
n_integrable = n_atoms; |
436 |
> |
for (i = 0; i < n_rigidbodies; i++) |
437 |
> |
n_integrable = n_integrable - rigidBodies[i]->getNMembers() + 1; //rigidbody is an integrable object |
438 |
> |
|
439 |
> |
if (n_integrable <= 0 || n_integrable > n_atoms) { |
440 |
> |
sprintf( errMsg, |
441 |
> |
"MoleculeStamp error. n_integrable is either <= 0 or" |
442 |
> |
" greater than n_atoms in molecule \"%s\".\n", name ); |
443 |
> |
return strdup( errMsg ); |
444 |
|
} |
445 |
|
|
446 |
< |
return total_atoms; |
447 |
< |
} |
390 |
< |
|
446 |
> |
return NULL; |
447 |
> |
} |