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

Comparing trunk/OOPSE-2.0/src/types/MoleculeStamp.cpp (file contents):
Revision 2204 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
Revision 2469 by tim, Fri Dec 2 15:38:03 2005 UTC

# Line 46 | Line 46 | char MoleculeStamp::errMsg[500];
46  
47   #include "types/MoleculeStamp.hpp"
48  
49 < char MoleculeStamp::errMsg[500];
49 > namespace oopse {
50 > MoleculeStamp::MoleculeStamp() {
51 >    DefineParameter(Name, "name");
52 >    
53 >    deprecatedKeywords_.insert("nAtoms");
54 >    deprecatedKeywords_.insert("nBonds");
55 >    deprecatedKeywords_.insert("nBends");
56 >    deprecatedKeywords_.insert("nTorsions");
57 >    deprecatedKeywords_.insert("nRigidBodies");
58 >    deprecatedKeywords_.insert("nCutoffGroups");
59 >    
60 > }
61  
62 < MoleculeStamp::MoleculeStamp(){
52 <  
53 <  n_atoms = 0;
54 <  n_bonds = 0;
55 <  n_bends = 0;
56 <  n_torsions = 0;
57 <  n_rigidbodies = 0;
58 <  n_cutoffgroups = 0;
59 <  n_integrable = 0;
62 > MoleculeStamp::~MoleculeStamp() {
63  
64 <  unhandled = NULL;
62 <  atoms = NULL;
63 <  bonds = NULL;
64 <  bends = NULL;
65 <  torsions = NULL;
66 <  rigidBodies = NULL;
67 <  cutoffGroups = NULL;
64 > }
65  
66 <  have_name = 0;
67 <  have_atoms = 0;
68 <  have_bonds = 0;
69 <  have_bends = 0;
70 <  have_torsions = 0;
71 <  have_rigidbodies = 0;
72 <  have_cutoffgroups = 0;
66 > bool MoleculeStamp::addAtomStamp( AtomStamp* atom) {
67 >    bool ret = addIndexSensitiveStamp(atomStamps_, atom);
68 >    if (!ret) {
69 >        std::cout << "multiple atoms have the same index: " << atom->getIndex() <<" in " << getName()  << " Molecule\n";
70 >    }
71 >    return ret;
72 >    
73 > }
74  
75 + bool MoleculeStamp::addBondStamp( BondStamp* bond) {
76 +    bondStamps_.push_back(bond);
77 +    return true;
78   }
79  
80 < MoleculeStamp::~MoleculeStamp(){
81 <  int i;
82 <  
83 <  if( unhandled != NULL) delete unhandled;
83 <  
84 <  if( rigidBodies != NULL ) {
85 <    for( i=0; i<n_rigidbodies; i++ ) delete rigidBodies[i];
86 <  }
87 <  delete[] rigidBodies;
80 > bool MoleculeStamp::addBendStamp( BendStamp* bend) {
81 >    bendStamps_.push_back(bend);
82 >    return true;
83 > }
84  
85 <  if( cutoffGroups != NULL ) {
86 <    for( i=0; i<n_cutoffgroups; i++ ) delete cutoffGroups[i];
87 <  }
88 <  delete[] cutoffGroups;
93 <  
94 <  if( atoms != NULL ){
95 <    for( i=0; i<n_atoms; i++ ) delete atoms[i];
96 <  }
97 <  delete[] atoms;
98 <  
99 <  if( bonds != NULL ){
100 <    for( i=0; i<n_bonds; i++ ) delete bonds[i];
101 <  }
102 <  delete[] bonds;
103 <  
104 <  if( bends != NULL ){
105 <    for( i=0; i<n_bends; i++ ) delete bends[i];
106 <  }
107 <  delete[] bends;
108 <  
109 <  if( torsions != NULL ){
110 <    for( i=0; i<n_torsions; i++ ) delete torsions[i];
111 <  }
112 <  delete[] torsions;
113 <  
85 > bool MoleculeStamp::addTorsionStamp( TorsionStamp* torsion) {
86 >    torsionStamps_.push_back(torsion);
87 >    return true;
88 > }
89  
90 + bool MoleculeStamp::addRigidBodyStamp( RigidBodyStamp* rigidbody) {
91 +    bool ret = addIndexSensitiveStamp(rigidBodyStamps_, rigidbody);
92 +    if (!ret) {
93 +        std::cout << "multiple rigidbodies have the same index: " << rigidbody->getIndex() <<" in " << getName()  << " Molecule\n";
94 +    }
95 +    return ret;
96 + }
97  
98 <
98 > bool MoleculeStamp::addCutoffGroupStamp( CutoffGroupStamp* cutoffgroup) {
99 >    cutoffGroupStamps_.push_back(cutoffgroup);
100 >    return true;
101   }
102  
103 < char* MoleculeStamp::assignString( char* lhs, char* rhs ){
104 <  
121 <  if( !strcmp( lhs, "name" ) ){
122 <    strcpy( name, rhs );
123 <    have_name = 1;
124 <  }
125 <  else{
126 <    if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs );
127 <    else unhandled->add( lhs, rhs );
128 <    have_extras = 1;
129 <  }
130 <  return NULL;
103 > bool MoleculeStamp::addFragmentStamp( FragmentStamp* fragment) {
104 >    return addIndexSensitiveStamp(fragmentStamps_, fragment);
105   }
106 +    
107 + void MoleculeStamp::validate() {
108 +    DataHolder::validate();
109  
110 < char* MoleculeStamp::assignDouble( char* lhs, double rhs ){
111 <  int i;
110 >    std::vector<AtomStamp*>::iterator ai = std::find(atomStamps_.begin(), atomStamps_.end(), static_cast<AtomStamp*>(NULL));
111 >    if (ai != atomStamps_.end()) {
112 >        std::cout << "Error in Molecule " << getName() << ": atom[" << ai - atomStamps_.begin()<< "] is missing\n";
113 >    }
114  
115 <  if( !strcmp( lhs, "nAtoms" ) ){
116 <    n_atoms = (int)rhs;
115 >     std::vector<RigidBodyStamp*>::iterator ri = std::find(rigidBodyStamps_.begin(), rigidBodyStamps_.end(), static_cast<RigidBodyStamp*>(NULL));
116 >     if (ri != rigidBodyStamps_.end()) {
117 >         std::cout << "Error in Molecule " << getName() << ":rigidBody[" <<  ri - rigidBodyStamps_.begin()<< "] is missing\n";
118 >     }
119      
120 <    if( have_atoms ){
121 <      sprintf( errMsg,
122 <               "MoleculeStamp error, n_atoms already declared"
142 <               " for molecule: %s\n",
143 <               name);
144 <      return strdup( errMsg );
120 >    std::vector<FragmentStamp*>::iterator fi = std::find(fragmentStamps_.begin(), fragmentStamps_.end(), static_cast<FragmentStamp*>(NULL));
121 >    if (fi != fragmentStamps_.end()) {
122 >        std::cout << "Error in Molecule " << getName() << ":fragment[" <<  fi - fragmentStamps_.begin()<< "] is missing\n";
123      }
146    have_atoms = 1;
147    atoms = new AtomStamp*[n_atoms];
148    for( i=0; i<n_atoms; i++ ) atoms[i] = NULL;
149  }
150  
151  else if( !strcmp( lhs, "nBonds" ) ){
152    n_bonds = (int)rhs;
124  
125 <    if( have_bonds ){
126 <      sprintf( errMsg,  
127 <               "MoleculeStamp error, n_bonds already declared for"
128 <               " molecule: %s\n",
129 <               name);
130 <      return strdup( errMsg );
125 >    //make sure index is not out of range
126 >    int natoms = getNAtoms();
127 >    for(int i = 0; i < getNBonds(); ++i) {
128 >        BondStamp* bondStamp = getBondStamp(i);
129 >        if (bondStamp->getA() >=  natoms && bondStamp->getB() >= natoms) {
130 >            std::cout << "Error in Molecule " << getName() <<  ": bond between " << bondStamp->getA() << " and " << bondStamp->getB() << " is invalid\n";
131 >        }
132      }
133 <    have_bonds = 1;
134 <    bonds = new BondStamp*[n_bonds];
135 <    for( i=0; i<n_bonds; i++ ) bonds[i] = NULL;
136 <  }
137 <  
138 <  else if( !strcmp( lhs, "nBends" ) ){
139 <    n_bends = (int)rhs;
133 >    for(int i = 0; i < getNBends(); ++i) {
134 >        BendStamp* bendStamp = getBendStamp(i);
135 >        std::vector<int> bendAtoms =  bendStamp->getMembers();
136 >        std::vector<int>::iterator j =std::find_if(bendAtoms.begin(), bendAtoms.end(), std::bind2nd(std::greater<int>(), natoms-1));
137 >        if (j != bendAtoms.end()) {
138 >            std::cout << "Error in Molecule " << getName();
139 >        }
140  
141 <    if( have_bends ){
142 <      sprintf( errMsg,
143 <               "MoleculeStamp error, n_bends already declared for"
144 <               " molecule: %s\n",
145 <               name);
146 <      return strdup( errMsg );
141 >        if (bendAtoms.size() == 2 && !bendStamp->haveGhostVectorSource()) {
142 >            std::cout << "Error in Molecule " << getName() << ": ghostVectorSouce is missing";
143 >        }
144 >    }    
145 >    for(int i = 0; i < getNBends(); ++i) {
146 >        TorsionStamp* torsionStamp = getTorsionStamp(i);
147 >        std::vector<int> torsionAtoms =  torsionStamp ->getMembers();
148 >        std::vector<int>::iterator j =std::find_if(torsionAtoms.begin(), torsionAtoms.end(), std::bind2nd(std::greater<int>(), natoms-1));
149 >        if (j != torsionAtoms.end()) {
150 >            std::cout << "Error in Molecule " << getName();
151 >        }
152      }
153 <    have_bends = 1;
154 <    bends = new BendStamp*[n_bends];
155 <    for( i=0; i<n_bends; i++ ) bends[i] = NULL;
156 <  }
157 <  
158 <  else if( !strcmp( lhs, "nTorsions" ) ){
159 <    n_torsions = (int)rhs;
153 >    for(int i = 0; i < getNCutoffGroups(); ++i) {
154 >        CutoffGroupStamp* cutoffGroupStamp = getCutoffGroupStamp(i);
155 >        std::vector<int> cutoffGroupAtoms =  cutoffGroupStamp ->getMembers();
156 >        std::vector<int>::iterator j =std::find_if(cutoffGroupAtoms.begin(), cutoffGroupAtoms.end(), std::bind2nd(std::greater<int>(), natoms-1));
157 >        if (j != cutoffGroupAtoms.end()) {
158 >            std::cout << "Error in Molecule " << getName();
159 >        }
160 >    }
161 >        
162 >    atom2Rigidbody.resize(natoms);
163 >    // negative number means atom is a free atom, does not belong to rigidbody
164 >    //every element in atom2Rigidbody has unique negative number at the very beginning
165 >    for(int i = 0; i < atom2Rigidbody.size(); ++i) {
166 >        atom2Rigidbody[i] = -1 - i;
167 >    }
168  
169 <    if( have_torsions ){
170 <      sprintf( errMsg,
171 <               "MoleculeStamp error, n_torsions already declared for"
172 <               " molecule: %s\n",
173 <               name );
174 <      return strdup( errMsg );
169 >    for (int i = 0; i < getNRigidBodies(); ++i) {
170 >        RigidBodyStamp* rbStamp = getRigidBodyStamp(i);
171 >        std::vector<int> members = rbStamp->getMembers();
172 >        for(std::vector<int>::iterator j = members.begin(); j != members.end(); ++j) {
173 >            atom2Rigidbody[*j] = i;                
174 >        }
175      }
176 <    have_torsions = 1;
177 <    torsions = new TorsionStamp*[n_torsions];
178 <    for( i=0; i<n_torsions; i++ ) torsions[i] = NULL;
179 <  }
176 >    //make sure atoms belong to same rigidbody do not bond to each other
177 >    for(int i = 0; i < getNBonds(); ++i) {
178 >        BondStamp* bondStamp = getBondStamp(i);
179 >        if (atom2Rigidbody[bondStamp->getA()] == atom2Rigidbody[bondStamp->getB()])
180 >            std::cout << "Error in Molecule " << getName() << ": "<<"bond between " << bondStamp->getA() << " and " << bondStamp->getB() << "belong to same rigidbody " << atom2Rigidbody[bondStamp->getA()] << "\n";
181 >        }
182 >        
183 >    for(int i = 0; i < getNBends(); ++i) {
184 >        BendStamp* bendStamp = getBendStamp(i);
185 >        std::vector<int> bendAtoms =  bendStamp->getMembers();
186 >        std::vector<int> rigidSet(getNRigidBodies(), 0);
187 >        std::vector<int>::iterator j;
188 >        for( j = bendAtoms.begin(); j != bendAtoms.end(); ++j) {
189 >            int rigidbodyIndex = atom2Rigidbody[*j];
190 >            if (rigidbodyIndex >= 0) {
191 >                ++rigidSet[rigidbodyIndex];
192 >                if (rigidSet[rigidbodyIndex] > 1) {
193 >                    std::cout << "Error in Molecule " << getName() << ": ";
194 >                    //std::cout << "atoms of bend " <<  << "belong to same rigidbody " << rigidbodyIndex << "\n";                    
195 >                }
196 >            }
197 >        }
198 >    }      
199 >    for(int i = 0; i < getNTorsions(); ++i) {
200 >        TorsionStamp* torsionStamp = getTorsionStamp(i);
201 >        std::vector<int> torsionAtoms =  torsionStamp->getMembers();
202 >        std::vector<int> rigidSet(getNRigidBodies(), 0);
203 >        std::vector<int>::iterator j;
204 >        for( j = torsionAtoms.begin(); j != torsionAtoms.end(); ++j) {
205 >            int rigidbodyIndex = atom2Rigidbody[*j];
206 >            if (rigidbodyIndex >= 0) {
207 >                ++rigidSet[rigidbodyIndex];
208 >                if (rigidSet[rigidbodyIndex] > 1) {
209 >                    std::cout << "Error in Molecule " << getName() << ": ";
210 >                    //std::cout << "atoms of torsion " <<  << "belong to same rigidbody " << rigidbodyIndex << "\n";                    
211 >                }
212 >            }
213 >        }
214 >    }
215  
196  else if( !strcmp( lhs, "nRigidBodies" ) ){
197    n_rigidbodies = (int)rhs;
216  
217 <    if( have_rigidbodies ){
218 <      sprintf( errMsg,
219 <               "MoleculeStamp error, n_rigidbodies already declared for"
220 <               " molecule: %s\n",
221 <               name );
222 <      return strdup( errMsg );
217 >    //fill in bond information into atom
218 >    fillBondInfo();
219 >    findBends();
220 >    findTorsions();
221 >
222 >    int nrigidAtoms = 0;
223 >    for (int i = 0; i < getNRigidBodies(); ++i) {
224 >        RigidBodyStamp* rbStamp = getRigidBodyStamp(i);
225 >        nrigidAtoms += rbStamp->getNMembers();
226      }
227 <    have_rigidbodies = 1;
207 <    rigidBodies = new RigidBodyStamp*[n_rigidbodies];
208 <    for( i=0; i<n_rigidbodies; i++ ) rigidBodies[i] = NULL;
209 <  }
227 >    nintegrable_ = getNAtoms()+ getNRigidBodies() - nrigidAtoms;
228  
229 <  else if( !strcmp( lhs, "nCutoffGroups" ) ){
212 <    n_cutoffgroups = (int)rhs;
229 > }
230  
231 <    if( have_cutoffgroups ){
215 <      sprintf( errMsg,
216 <               "MoleculeStamp error, n_cutoffgroups already declared for"
217 <               " molecule: %s\n",
218 <               name );
219 <      return strdup( errMsg );
220 <    }
221 <    have_cutoffgroups = 1;
222 <    cutoffGroups = new CutoffGroupStamp*[n_cutoffgroups];
223 <    for( i=0; i<n_cutoffgroups; i++ ) cutoffGroups[i] = NULL;
224 <  }
225 <  
226 <  else{
227 <    if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs );
228 <    else unhandled->add( lhs, rhs );
229 <    have_extras = 1;
230 <  }
231 <  return NULL;
231 > void MoleculeStamp::fillBondInfo() {
232   }
233  
234 < char*  MoleculeStamp::assignInt( char* lhs, int rhs ){
235 <  int i;
236 <  
237 <  if( !strcmp( lhs, "nAtoms" ) ){
238 <    n_atoms = rhs;
239 <    
240 <    if( have_atoms ){
241 <      sprintf( errMsg,
242 <               "MoleculeStamp error, n_atoms already declared for"
243 <               " molecule: %s\n",
244 <               name);
245 <      return strdup( errMsg );
246 <    }
247 <    have_atoms = 1;
248 <    atoms = new AtomStamp*[n_atoms];
249 <    for( i=0; i<n_atoms; i++ ) atoms[i] = NULL;
250 <  }
251 <  
252 <  else if( !strcmp( lhs, "nBonds" ) ){
253 <    n_bonds = rhs;
234 > void MoleculeStamp::findBends() {
235  
255    if( have_bonds ){
256      sprintf( errMsg,
257               "MoleculeStamp error, n_bonds already declared for"
258               " molecule: %s\n",
259               name);
260      return strdup( errMsg );
261    }
262    have_bonds = 1;
263    bonds = new BondStamp*[n_bonds];
264    for( i=0; i<n_bonds; i++ ) bonds[i] = NULL;
265  }
266  
267  else if( !strcmp( lhs, "nBends" ) ){
268    n_bends = rhs;
269
270    if( have_bends ){
271      sprintf( errMsg,
272               "MoleculeStamp error, n_bends already declared for"
273               " molecule: %s\n",
274               name );
275      return strdup( errMsg );
276    }
277    have_bends = 1;
278    bends = new BendStamp*[n_bends];
279    for( i=0; i<n_bends; i++ ) bends[i] = NULL;
280  }
281  
282  else if( !strcmp( lhs, "nTorsions" ) ){
283    n_torsions = rhs;
284
285    if( have_torsions ){
286      sprintf( errMsg,
287               "MoleculeStamp error, n_torsions already declared for"
288               " molecule: %s\n",
289               name);
290      return strdup( errMsg );
291    }
292    have_torsions = 1;
293    torsions = new TorsionStamp*[n_torsions];
294    for( i=0; i<n_torsions; i++ ) torsions[i] = NULL;
295  }
296
297  else if( !strcmp( lhs, "nRigidBodies" ) ){
298    n_rigidbodies = rhs;
299
300    if( have_rigidbodies ){
301      sprintf( errMsg,
302               "MoleculeStamp error, n_rigidbodies already declared for"
303               " molecule: %s\n",
304               name);
305      return strdup( errMsg );
306    }
307    have_rigidbodies = 1;
308    rigidBodies = new RigidBodyStamp*[n_rigidbodies];
309    for( i=0; i<n_rigidbodies; i++ ) rigidBodies[i] = NULL;
310  }
311  else if( !strcmp( lhs, "nCutoffGroups" ) ){
312    n_cutoffgroups = rhs;
313
314    if( have_cutoffgroups ){
315      sprintf( errMsg,
316               "MoleculeStamp error, n_cutoffgroups already declared for"
317               " molecule: %s\n",
318               name);
319      return strdup( errMsg );
320    }
321    have_cutoffgroups = 1;
322    cutoffGroups = new CutoffGroupStamp*[n_cutoffgroups];
323    for( i=0; i<n_cutoffgroups; i++ ) cutoffGroups[i] = NULL;
324  }
325  else{
326    if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs );
327    else unhandled->add( lhs, rhs );
328    have_extras = 1;
329  }
330  return NULL;
236   }
237  
238 < char* MoleculeStamp::addAtom( AtomStamp* the_atom, int atomIndex ){
334 <  
335 <  if( have_atoms && atomIndex < n_atoms ) atoms[atomIndex] = the_atom;
336 <  else {
337 <    if( have_atoms ){
338 <      sprintf( errMsg, "MoleculeStamp error, %d out of nAtoms range",
339 <               atomIndex );
340 <      return strdup( errMsg );
341 <    }
342 <    else return strdup("MoleculeStamp error, nAtoms not given before"
343 <                       " first atom declaration." );
344 <  }
238 > void MoleculeStamp::findTorsions() {
239  
346  return NULL;
240   }
241  
349 char* MoleculeStamp::addRigidBody( RigidBodyStamp* the_rigidbody,
350                                   int rigidBodyIndex ){
351  
352  if( have_rigidbodies && rigidBodyIndex < n_rigidbodies )
353    rigidBodies[rigidBodyIndex] = the_rigidbody;
354  else {
355    if( have_rigidbodies ){
356      sprintf( errMsg, "MoleculeStamp error, %d out of nRigidBodies range",
357               rigidBodyIndex );
358      return strdup( errMsg );
359    }
360    else return strdup("MoleculeStamp error, nRigidBodies not given before"
361                       " first rigidBody declaration." );
362  }
363  
364  return NULL;
365 }
366
367 char* MoleculeStamp::addCutoffGroup( CutoffGroupStamp* the_cutoffgroup,
368                                     int cutoffGroupIndex ){
369  
370  if( have_cutoffgroups && cutoffGroupIndex < n_cutoffgroups )
371    cutoffGroups[cutoffGroupIndex] = the_cutoffgroup;
372  else {
373    if( have_cutoffgroups ){
374      sprintf( errMsg, "MoleculeStamp error, %d out of nCutoffGroups range",
375               cutoffGroupIndex );
376      return strdup( errMsg );
377    }
378    else return strdup("MoleculeStamp error, nCutoffGroups not given before"
379                       " first CutoffGroup declaration." );
380  }
381  
382  return NULL;
383 }
384
385 char* MoleculeStamp::addBond( BondStamp* the_bond, int bondIndex ){
386  
387  
388  if( have_bonds && bondIndex < n_bonds ) bonds[bondIndex] = the_bond;
389  else{
390    if( have_bonds ){
391      sprintf( errMsg, "MoleculeStamp error, %d out of nBonds range",
392               bondIndex );
393      return strdup( errMsg );
394    }
395    else return strdup("MoleculeStamp error, nBonds not given before"
396                       "first bond declaration." );
397  }
398
399  return NULL;
400 }
401
402 char* MoleculeStamp::addBend( BendStamp* the_bend, int bendIndex ){
403  
404  
405  if( have_bends && bendIndex < n_bends ) bends[bendIndex] = the_bend;
406  else{
407    if( have_bends ){
408      sprintf( errMsg, "MoleculeStamp error, %d out of nBends range",
409               bendIndex );
410      return strdup( errMsg );
411    }
412    else return strdup("MoleculeStamp error, nBends not given before"
413                       "first bend declaration." );
414  }
415
416  return NULL;
417 }
418
419 char* MoleculeStamp::addTorsion( TorsionStamp* the_torsion, int torsionIndex ){
420  
421  
422  if( have_torsions && torsionIndex < n_torsions )
423    torsions[torsionIndex] = the_torsion;
424  else{
425    if( have_torsions ){
426      sprintf( errMsg, "MoleculeStamp error, %d out of nTorsions range",
427               torsionIndex );
428      return strdup( errMsg );
429    }
430    else return strdup("MoleculeStamp error, nTorsions not given before"
431                       "first torsion declaration." );
432  }
433
434  return NULL;
435 }
436
437 char* MoleculeStamp::checkMe( void ){
438  
439  int i;
440  short int no_atom, no_rigidbody, no_cutoffgroup;
441
442  if( !have_name ) return strdup( "MoleculeStamp error. Molecule's name"
443                                  " was not given.\n" );
444  
445  if( !have_atoms ){
446    return strdup( "MoleculeStamp error. Molecule contains no atoms." );
447  }
448  
449  no_rigidbody = 0;
450  for( i=0; i<n_rigidbodies; i++ ){
451    if( rigidBodies[i] == NULL ) no_rigidbody = 1;
452  }
453
454  if( no_rigidbody ){
455    sprintf( errMsg,
456             "MoleculeStamp error. Not all of the RigidBodies were"
457             " declared in molecule \"%s\".\n", name );
458    return strdup( errMsg );
459  }
460
461  no_cutoffgroup = 0;
462  for( i=0; i<n_cutoffgroups; i++ ){
463    if( cutoffGroups[i] == NULL ) no_cutoffgroup = 1;
464  }
465
466  if( no_cutoffgroup ){
467    sprintf( errMsg,
468             "MoleculeStamp error. Not all of the CutoffGroups were"
469             " declared in molecule \"%s\".\n", name );
470    return strdup( errMsg );
471  }
472  
473  no_atom = 0;
474  for( i=0; i<n_atoms; i++ ){
475    if( atoms[i] == NULL ) no_atom = 1;
476  }
477
478  if( no_atom ){
479    sprintf( errMsg,
480             "MoleculeStamp error. Not all of the atoms were"
481             " declared in molecule \"%s\".\n", name );
482    return strdup( errMsg );
483  }
484
485  n_integrable = n_atoms;
486  for (i = 0; i < n_rigidbodies; i++)
487    n_integrable = n_integrable - rigidBodies[i]->getNMembers() + 1; //rigidbody is an integrable object
488  
489  if (n_integrable <= 0 || n_integrable > n_atoms) {
490    sprintf( errMsg,
491             "MoleculeStamp error. n_integrable is either <= 0 or"
492             " greater than n_atoms in molecule \"%s\".\n", name );
493    return strdup( errMsg );
494  }
495
496  return NULL;
497 }  
498
499
242   //Function Name: isBondInSameRigidBody
243   //Return true is both atoms of the bond belong to the same rigid body, otherwise return false
244   bool MoleculeStamp::isBondInSameRigidBody(BondStamp* bond){
# Line 544 | Line 286 | bool MoleculeStamp::isAtomInRigidBody(int atomIndex, i
286    numRb = this->getNRigidBodies();
287    
288    for(int i = 0 ; i < numRb; i++){
289 <    rbStamp = this->getRigidBody(i);
289 >    rbStamp = this->getRigidBodyStamp(i);
290      numAtom = rbStamp->getNMembers();
291      for(int j = 0; j < numAtom; j++)
292 <      if (rbStamp->getMember(j) == atomIndex){
292 >      if (rbStamp->getMemberAt(j) == atomIndex){
293          whichRigidBody = i;
294          consAtomIndex = j;
295          return true;
# Line 570 | Line 312 | std::vector<std::pair<int, int> > MoleculeStamp::getJo
312    int atomIndex2;
313    std::vector<std::pair<int, int> > jointAtomIndexPair;
314    
315 <  rbStamp1 = this->getRigidBody(rb1);
315 >  rbStamp1 = this->getRigidBodyStamp(rb1);
316    natomInRb1 =rbStamp1->getNMembers();
317  
318 <  rbStamp2 = this->getRigidBody(rb2);
318 >  rbStamp2 = this->getRigidBodyStamp(rb2);
319    natomInRb2 =rbStamp2->getNMembers();
320  
321    for(int i = 0; i < natomInRb1; i++){
322 <    atomIndex1 = rbStamp1->getMember(i);
322 >    atomIndex1 = rbStamp1->getMemberAt(i);
323        
324      for(int j= 0; j < natomInRb1; j++){
325 <      atomIndex2 = rbStamp2->getMember(j);
325 >      atomIndex2 = rbStamp2->getMemberAt(j);
326  
327        if(atomIndex1 == atomIndex2){
328          jointAtomIndexPair.push_back(std::make_pair(i, j));
329          break;
330        }
331        
332 <    }//end for(j =0)
332 >    }
333  
334 <  }//end for (i = 0)
334 >  }
335  
336    return jointAtomIndexPair;
337   }
338 +
339 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines