37 |
|
namespace oopse { |
38 |
|
|
39 |
|
Molecule* MoleculeCreator::createMolecule(ForceField* ff, MoleculeStamp *molStamp, int stampId, int globalIndex) { |
40 |
< |
Molecule* mol = new Molecule(stampId, globalIndex); |
40 |
> |
Molecule* mol = new Molecule(stampId, globalIndex, molStamp->getID()); |
41 |
|
|
42 |
|
//create atoms |
43 |
|
Atom* atom; |
117 |
|
|
118 |
|
atomType = ff->getAtomType(stamp->getType()); |
119 |
|
|
120 |
+ |
if (bondType == NULL) { |
121 |
+ |
sprintf(painCave.errMsg, "Can not find Matching Atom Type for[%s]", |
122 |
+ |
stamp->getType()); |
123 |
+ |
|
124 |
+ |
painCave.isFatal = 1; |
125 |
+ |
simError(); |
126 |
+ |
} |
127 |
+ |
|
128 |
|
//below code still have some kind of hard-coding smell |
129 |
|
if (stamp->haveOrientation()){ |
130 |
|
DirectionalAtom* dAtom; |
160 |
|
Vector3d refCoor; |
161 |
|
AtomStamp* atomStamp; |
162 |
|
|
163 |
< |
nAtoms = stamp->getNMembers(); |
163 |
> |
nAtoms = molStamp->getNMembers(); |
164 |
|
|
165 |
|
RigidBody* rb = new RigidBody(); |
166 |
|
|
171 |
|
atomStamp= molStamp->molStamp->getAtom(rbStamp->getMember(i)); |
172 |
|
rb->addAtom(atom, atomStamp); |
173 |
|
} |
174 |
< |
|
174 |
> |
|
175 |
> |
//after all of the atoms are added, we need to calculate the reference coordinates |
176 |
|
rb->calcRefCoords(); |
177 |
+ |
|
178 |
+ |
//set the local index of this rigid body, global index will be set later |
179 |
|
rb->setLocalIndex(localIndexMan->getNextRigidBodyIndex()); |
180 |
< |
rb->setType(mol->getType() + "_" + itoa(mol.getNRigidBodies())); |
180 |
> |
|
181 |
> |
//the rule for naming rigidbody MoleculeName_RB_Integer |
182 |
> |
//The first part is the name of the molecule |
183 |
> |
//The second part is alway fixed as "RB" |
184 |
> |
//The third part is the index of the rigidbody defined in meta-data file |
185 |
> |
//For example, Butane_RB_0 is a valid rigid body name of butane molecule |
186 |
> |
rb->setType(mol->getType() + "_RB_" + itoa(mol.getNRigidBodies())); |
187 |
|
|
188 |
|
return rb; |
189 |
|
} |
200 |
|
|
201 |
|
bondType = ff->getBondType(atomA, atomB); |
202 |
|
|
203 |
+ |
if (bondType == NULL) { |
204 |
+ |
sprintf(painCave.errMsg, "Can not find Matching Bond Type for[%s, %s]", |
205 |
+ |
atomA->getType().c_str(), |
206 |
+ |
atomB->getType().c_str()); |
207 |
+ |
|
208 |
+ |
painCave.isFatal = 1; |
209 |
+ |
simError(); |
210 |
+ |
} |
211 |
|
return new Bond(atomA, atomB, bondType); |
212 |
|
} |
213 |
|
|
214 |
|
Bend* MoleculeCreator::createBend(ForceField* ff, Molecule* mol, BendStamp* stamp) { |
215 |
< |
BendType* benType; |
215 |
> |
BendType* bendType; |
216 |
|
Atom* atomA; |
217 |
|
Atom* atomB; |
218 |
|
Atom* atomC; |
224 |
|
|
225 |
|
assert( atomA && atomB && atomC); |
226 |
|
|
227 |
< |
benType = ff->getBendType(atomA->getType(), atomB->getType(), atomC->getType()); |
227 |
> |
bendType = ff->getBendType(atomA->getType(), atomB->getType(), atomC->getType()); |
228 |
|
|
229 |
< |
return new Bond(atomA, atomB, benType); |
229 |
> |
if (bendType == NULL) { |
230 |
> |
sprintf(painCave.errMsg, "Can not find Matching Bend Type for[%s, %s, %s]", |
231 |
> |
atomA->getType().c_str(), |
232 |
> |
atomB->getType().c_str(), |
233 |
> |
atomC->getType().c_str()); |
234 |
|
|
235 |
+ |
painCave.isFatal = 1; |
236 |
+ |
simError(); |
237 |
+ |
} |
238 |
+ |
|
239 |
+ |
return new Bond(atomA, atomB, bendType); |
240 |
+ |
|
241 |
|
} |
242 |
|
|
243 |
|
Torsion* MoleculeCreator::createTorsion(ForceField* ff, Molecule* mol, TorsionStamp* stamp) { |
257 |
|
torsionType = ff->getTosionType(atomA->getType(), atomB->getType(), |
258 |
|
atomC->getType(), atomD->getType()); |
259 |
|
|
260 |
+ |
if (torsionType == NULL) { |
261 |
+ |
sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]", |
262 |
+ |
atomA->getType().c_str(), |
263 |
+ |
atomB->getType().c_str(), |
264 |
+ |
atomC->getType().c_str(), |
265 |
+ |
atomD->getType().c_str()); |
266 |
+ |
|
267 |
+ |
painCave.isFatal = 1; |
268 |
+ |
simError(); |
269 |
+ |
} |
270 |
+ |
|
271 |
|
return new Torsion(atomA, atomB, torsionType); |
272 |
|
} |
273 |
|
|