| 52 |
|
|
| 53 |
|
#include "brains/MoleculeCreator.hpp" |
| 54 |
|
#include "primitives/GhostBend.hpp" |
| 55 |
+ |
#include "primitives/GhostTorsion.hpp" |
| 56 |
|
#include "types/DirectionalAtomType.hpp" |
| 57 |
|
#include "types/FixedBondType.hpp" |
| 58 |
|
#include "utils/simError.h" |
| 253 |
|
//The third part is the index of the rigidbody defined in meta-data file |
| 254 |
|
//For example, Butane_RB_0 is a valid rigid body name of butane molecule |
| 255 |
|
/**@todo replace itoa by lexi_cast */ |
| 256 |
< |
rb->setType(mol->getType() + "_RB_" + toString(mol->getNRigidBodies())); |
| 257 |
< |
|
| 256 |
> |
std::string s = OOPSE_itoa(mol->getNRigidBodies(), 10); |
| 257 |
> |
rb->setType(mol->getType() + "_RB_" + s.c_str()); |
| 258 |
> |
|
| 259 |
|
return rb; |
| 260 |
|
} |
| 261 |
|
|
| 378 |
|
} |
| 379 |
|
|
| 380 |
|
Torsion* MoleculeCreator::createTorsion(ForceField* ff, Molecule* mol, TorsionStamp* stamp) { |
| 379 |
– |
TorsionType* torsionType; |
| 380 |
– |
Atom* atomA; |
| 381 |
– |
Atom* atomB; |
| 382 |
– |
Atom* atomC; |
| 383 |
– |
Atom* atomD; |
| 381 |
|
|
| 382 |
< |
atomA = mol->getAtomAt(stamp->getA()); |
| 383 |
< |
atomB = mol->getAtomAt(stamp->getB()); |
| 384 |
< |
atomC = mol->getAtomAt(stamp->getC()); |
| 385 |
< |
atomD = mol->getAtomAt(stamp->getD()); |
| 389 |
< |
|
| 390 |
< |
assert(atomA && atomB && atomC && atomD); |
| 391 |
< |
|
| 392 |
< |
torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(), |
| 393 |
< |
atomC->getType(), atomD->getType()); |
| 382 |
> |
Atom* atomA = mol->getAtomAt(stamp->getA()); |
| 383 |
> |
Atom* atomB = mol->getAtomAt(stamp->getB()); |
| 384 |
> |
Atom* atomC = mol->getAtomAt(stamp->getC()); |
| 385 |
> |
Torsion* torsion; |
| 386 |
|
|
| 387 |
< |
if (torsionType == NULL) { |
| 388 |
< |
sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]", |
| 397 |
< |
atomA->getType().c_str(), |
| 398 |
< |
atomB->getType().c_str(), |
| 399 |
< |
atomC->getType().c_str(), |
| 400 |
< |
atomD->getType().c_str()); |
| 387 |
> |
if (stamp->getD() != -1) { |
| 388 |
> |
Atom* atomD = mol->getAtomAt(stamp->getD()); |
| 389 |
|
|
| 390 |
< |
painCave.isFatal = 1; |
| 391 |
< |
simError(); |
| 390 |
> |
assert(atomA && atomB && atomC && atomD); |
| 391 |
> |
|
| 392 |
> |
TorsionType* torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(), |
| 393 |
> |
atomC->getType(), atomD->getType()); |
| 394 |
> |
|
| 395 |
> |
if (torsionType == NULL) { |
| 396 |
> |
sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]", |
| 397 |
> |
atomA->getType().c_str(), |
| 398 |
> |
atomB->getType().c_str(), |
| 399 |
> |
atomC->getType().c_str(), |
| 400 |
> |
atomD->getType().c_str()); |
| 401 |
> |
|
| 402 |
> |
painCave.isFatal = 1; |
| 403 |
> |
simError(); |
| 404 |
> |
} |
| 405 |
> |
|
| 406 |
> |
torsion = new Torsion(atomA, atomB, atomC, atomD, torsionType); |
| 407 |
|
} |
| 408 |
< |
|
| 409 |
< |
return new Torsion(atomA, atomB, atomC, atomD, torsionType); |
| 408 |
> |
else { |
| 409 |
> |
|
| 410 |
> |
DirectionalAtom* dAtom = dynamic_cast<DirectionalAtom*>(atomC); |
| 411 |
> |
if (dAtom == NULL) { |
| 412 |
> |
sprintf(painCave.errMsg, "Can not cast Atom to DirectionalAtom"); |
| 413 |
> |
painCave.isFatal = 1; |
| 414 |
> |
simError(); |
| 415 |
> |
} |
| 416 |
> |
|
| 417 |
> |
TorsionType* torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(), |
| 418 |
> |
atomC->getType(), "GHOST"); |
| 419 |
> |
|
| 420 |
> |
if (torsionType == NULL) { |
| 421 |
> |
sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]", |
| 422 |
> |
atomA->getType().c_str(), |
| 423 |
> |
atomB->getType().c_str(), |
| 424 |
> |
atomC->getType().c_str(), |
| 425 |
> |
"GHOST"); |
| 426 |
> |
|
| 427 |
> |
painCave.isFatal = 1; |
| 428 |
> |
simError(); |
| 429 |
> |
} |
| 430 |
> |
|
| 431 |
> |
torsion = new GhostTorsion(atomA, atomB, dAtom, torsionType); |
| 432 |
> |
} |
| 433 |
> |
|
| 434 |
> |
return torsion; |
| 435 |
|
} |
| 436 |
|
|
| 437 |
|
CutoffGroup* MoleculeCreator::createCutoffGroup(Molecule* mol, CutoffGroupStamp* stamp) { |