| 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" | 
| 377 | 
  | 
}     | 
| 378 | 
  | 
 | 
| 379 | 
  | 
Torsion* MoleculeCreator::createTorsion(ForceField* ff, Molecule* mol, TorsionStamp* stamp) { | 
| 379 | 
– | 
    TorsionType* torsionType; | 
| 380 | 
– | 
    Atom* atomA; | 
| 381 | 
– | 
    Atom* atomB; | 
| 382 | 
– | 
    Atom* atomC; | 
| 383 | 
– | 
    Atom* atomD; | 
| 380 | 
  | 
 | 
| 381 | 
< | 
    atomA = mol->getAtomAt(stamp->getA()); | 
| 382 | 
< | 
    atomB = mol->getAtomAt(stamp->getB()); | 
| 383 | 
< | 
    atomC = mol->getAtomAt(stamp->getC()); | 
| 384 | 
< | 
    atomD = mol->getAtomAt(stamp->getD()); | 
| 381 | 
> | 
    Atom* atomA = mol->getAtomAt(stamp->getA()); | 
| 382 | 
> | 
    Atom* atomB = mol->getAtomAt(stamp->getB()); | 
| 383 | 
> | 
    Atom* atomC = mol->getAtomAt(stamp->getC()); | 
| 384 | 
> | 
    Torsion* torsion; | 
| 385 | 
  | 
 | 
| 386 | 
< | 
    assert(atomA && atomB && atomC && atomD); | 
| 387 | 
< | 
     | 
| 392 | 
< | 
    torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(),  | 
| 393 | 
< | 
                                                       atomC->getType(), atomD->getType()); | 
| 386 | 
> | 
    if (stamp->getD() != -1) { | 
| 387 | 
> | 
        Atom* atomD = mol->getAtomAt(stamp->getD()); | 
| 388 | 
  | 
 | 
| 389 | 
< | 
    if (torsionType == NULL) { | 
| 390 | 
< | 
        sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]", | 
| 391 | 
< | 
                   atomA->getType().c_str(), | 
| 392 | 
< | 
                   atomB->getType().c_str(), | 
| 399 | 
< | 
                   atomC->getType().c_str(), | 
| 400 | 
< | 
                   atomD->getType().c_str()); | 
| 389 | 
> | 
        assert(atomA && atomB && atomC && atomD); | 
| 390 | 
> | 
         | 
| 391 | 
> | 
        TorsionType* torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(),  | 
| 392 | 
> | 
                                                           atomC->getType(), atomD->getType()); | 
| 393 | 
  | 
 | 
| 394 | 
< | 
        painCave.isFatal = 1; | 
| 395 | 
< | 
        simError(); | 
| 394 | 
> | 
        if (torsionType == NULL) { | 
| 395 | 
> | 
            sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]", | 
| 396 | 
> | 
                       atomA->getType().c_str(), | 
| 397 | 
> | 
                       atomB->getType().c_str(), | 
| 398 | 
> | 
                       atomC->getType().c_str(), | 
| 399 | 
> | 
                       atomD->getType().c_str()); | 
| 400 | 
> | 
 | 
| 401 | 
> | 
            painCave.isFatal = 1; | 
| 402 | 
> | 
            simError(); | 
| 403 | 
> | 
        } | 
| 404 | 
> | 
         | 
| 405 | 
> | 
        torsion = new Torsion(atomA, atomB, atomC, atomD, torsionType);        | 
| 406 | 
  | 
    } | 
| 407 | 
< | 
     | 
| 408 | 
< | 
    return new Torsion(atomA, atomB, atomC, atomD, torsionType);        | 
| 407 | 
> | 
    else { | 
| 408 | 
> | 
 | 
| 409 | 
> | 
        DirectionalAtom* dAtom = dynamic_cast<DirectionalAtom*>(atomC); | 
| 410 | 
> | 
        if (dAtom == NULL) { | 
| 411 | 
> | 
            sprintf(painCave.errMsg, "Can not cast Atom to DirectionalAtom"); | 
| 412 | 
> | 
            painCave.isFatal = 1; | 
| 413 | 
> | 
            simError(); | 
| 414 | 
> | 
        }         | 
| 415 | 
> | 
 | 
| 416 | 
> | 
        TorsionType* torsionType = ff->getTorsionType(atomA->getType(), atomB->getType(),  | 
| 417 | 
> | 
                                                           atomC->getType(), "GHOST"); | 
| 418 | 
> | 
 | 
| 419 | 
> | 
        if (torsionType == NULL) { | 
| 420 | 
> | 
            sprintf(painCave.errMsg, "Can not find Matching Torsion Type for[%s, %s, %s, %s]", | 
| 421 | 
> | 
                       atomA->getType().c_str(), | 
| 422 | 
> | 
                       atomB->getType().c_str(), | 
| 423 | 
> | 
                       atomC->getType().c_str(), | 
| 424 | 
> | 
                       "GHOST"); | 
| 425 | 
> | 
 | 
| 426 | 
> | 
            painCave.isFatal = 1; | 
| 427 | 
> | 
            simError(); | 
| 428 | 
> | 
        } | 
| 429 | 
> | 
         | 
| 430 | 
> | 
        torsion = new GhostTorsion(atomA, atomB, dAtom, torsionType);                | 
| 431 | 
> | 
    } | 
| 432 | 
> | 
 | 
| 433 | 
> | 
    return torsion; | 
| 434 | 
  | 
}     | 
| 435 | 
  | 
 | 
| 436 | 
  | 
CutoffGroup* MoleculeCreator::createCutoffGroup(Molecule* mol, CutoffGroupStamp* stamp) { |