ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/visitors/AtomVisitor.cpp
(Generate patch)

Comparing trunk/src/visitors/AtomVisitor.cpp (file contents):
Revision 507 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
Revision 992 by chrisfen, Wed Jun 21 18:28:27 2006 UTC

# Line 221 | Line 221 | namespace oopse {
221      return strIter != linearAtomType.end() ? true : false;
222    }
223  
224 +  void LinearAtomVisitor::addGayBerneAtomType(const std::string& atomType){
225 +   linearAtomType.insert(atomType);
226 +  }
227 +
228    void LinearAtomVisitor::visit(DirectionalAtom* datom){
229      std::vector<AtomInfo*> atoms;
230      //we need to convert linear into 4 different atoms
# Line 237 | Line 241 | namespace oopse {
241      AtomData* atomData;
242      GenericData* data;
243      bool haveAtomData;
244 <
244 >    AtomType* atomType;
245      //if atom is not SSD atom, just skip it
246 <    if(!isLinearAtom(datom->getType()))
246 >    if(!isLinearAtom(datom->getType()) || !datom->getAtomType()->isGayBerne())
247        return;
248  
249 +    //setup GayBerne type in fortran side
250 +    data = datom->getAtomType()->getPropertyByName("GayBerne");
251 +    if (data != NULL) {
252 +       GayBerneParamGenericData* gayBerneData = dynamic_cast<GayBerneParamGenericData*>(data);
253 +
254 +       if (gayBerneData != NULL) {
255 +           GayBerneParam gayBerneParam = gayBerneData->getData();
256 +
257 +                          // double halfLen = gayBerneParam.GB_sigma * gayBerneParam.GB_l2b_ratio/2.0;
258 +                          double halfLen = gayBerneParam.GB_l/2.0;
259 +                          c1[2] = -halfLen;
260 +              c2[2] = -halfLen /2;
261 +              c3[2] = halfLen/2;
262 +              c4[2] = halfLen;
263 +                
264 +            }
265 +            
266 +              else {
267 +                    sprintf( painCave.errMsg,
268 +                           "Can not cast GenericData to GayBerneParam\n");
269 +                    painCave.severity = OOPSE_ERROR;
270 +                    painCave.isFatal = 1;
271 +                    simError();          
272 +        }            
273 +    }
274 +
275 +
276      data = datom->getPropertyByName("ATOMDATA");
277      if(data != NULL){
278        atomData = dynamic_cast<AtomData*>(data);  
# Line 339 | Line 370 | namespace oopse {
370      return result;
371    }
372  
373 +  bool GBLipidAtomVisitor::isGBLipidAtom(const std::string& atomType){
374 +    std::set<std::string>::iterator strIter;
375 +    strIter = GBLipidAtomType.find(atomType);
376 +
377 +    return strIter != GBLipidAtomType.end() ? true : false;
378 +  }
379 +
380 +  void GBLipidAtomVisitor::visit(DirectionalAtom* datom){
381 +    std::vector<AtomInfo*> atoms;
382 +    //we need to convert linear into 4 different atoms
383 +    Vector3d c1(0.0, 0.0, -6.25);
384 +    Vector3d c2(0.0, 0.0, -2.1);
385 +    Vector3d c3(0.0, 0.0,  2.1);
386 +    Vector3d c4(0.0, 0.0,  6.25);
387 +    RotMat3x3d rotMatrix;
388 +    RotMat3x3d rotTrans;
389 +    AtomInfo* atomInfo;
390 +    Vector3d pos;
391 +    Vector3d newVec;
392 +    Quat4d q;
393 +    AtomData* atomData;
394 +    GenericData* data;
395 +    bool haveAtomData;
396 +
397 +    //if atom is not GBlipid atom, just skip it
398 +    if(!isGBLipidAtom(datom->getType()))
399 +      return;
400 +
401 +    data = datom->getPropertyByName("ATOMDATA");
402 +    if(data != NULL){
403 +      atomData = dynamic_cast<AtomData*>(data);  
404 +      if(atomData == NULL){
405 +        std::cerr << "can not get Atom Data from " << datom->getType() << std::endl;
406 +        atomData = new AtomData;
407 +        haveAtomData = false;      
408 +      } else {
409 +        haveAtomData = true;
410 +      }
411 +    } else {
412 +      atomData = new AtomData;
413 +      haveAtomData = false;
414 +    }
415 +  
416 +  
417 +    pos = datom->getPos();
418 +    q = datom->getQ();
419 +    rotMatrix = datom->getA();
420 +
421 +    // We need A^T to convert from body-fixed to space-fixed:  
422 +    rotTrans = rotMatrix.transpose();
423 +
424 +    newVec = rotTrans * c1;
425 +    atomInfo = new AtomInfo;
426 +    atomInfo->atomTypeName = "K";
427 +    atomInfo->pos[0] = pos[0] + newVec[0];
428 +    atomInfo->pos[1] = pos[1] + newVec[1];
429 +    atomInfo->pos[2] = pos[2] + newVec[2];
430 +    atomInfo->dipole[0] = 0.0;
431 +    atomInfo->dipole[1] = 0.0;
432 +    atomInfo->dipole[2] = 0.0;
433 +    atomData->addAtomInfo(atomInfo);
434 +
435 +    newVec = rotTrans * c2;
436 +    atomInfo = new AtomInfo;
437 +    atomInfo->atomTypeName = "K";
438 +    atomInfo->pos[0] = pos[0] + newVec[0];
439 +    atomInfo->pos[1] = pos[1] + newVec[1];
440 +    atomInfo->pos[2] = pos[2] + newVec[2];
441 +    atomInfo->dipole[0] = 0.0;
442 +    atomInfo->dipole[1] = 0.0;
443 +    atomInfo->dipole[2] = 0.0;
444 +    atomData->addAtomInfo(atomInfo);
445 +
446 +    newVec = rotTrans * c3;
447 +    atomInfo = new AtomInfo;
448 +    atomInfo->atomTypeName = "K";
449 +    atomInfo->pos[0] = pos[0] + newVec[0];
450 +    atomInfo->pos[1] = pos[1] + newVec[1];
451 +    atomInfo->pos[2] = pos[2] + newVec[2];
452 +    atomInfo->dipole[0] = 0.0;
453 +    atomInfo->dipole[1] = 0.0;
454 +    atomInfo->dipole[2] = 0.0;
455 +    atomData->addAtomInfo(atomInfo);
456 +
457 +    newVec = rotTrans * c4;
458 +    atomInfo = new AtomInfo;
459 +    atomInfo->atomTypeName = "K";
460 +    atomInfo->pos[0] = pos[0] + newVec[0];
461 +    atomInfo->pos[1] = pos[1] + newVec[1];
462 +    atomInfo->pos[2] = pos[2] + newVec[2];
463 +    atomInfo->dipole[0] = 0.0;
464 +    atomInfo->dipole[1] = 0.0;
465 +    atomInfo->dipole[2] = 0.0;
466 +    atomData->addAtomInfo(atomInfo);
467 +
468 +    //add atom data into atom's property
469 +
470 +    if(!haveAtomData){
471 +      atomData->setID("ATOMDATA");
472 +      datom->addProperty(atomData);
473 +    }
474 +
475 +    setVisited(datom);
476 +
477 +  }
478 +
479 +  const std::string GBLipidAtomVisitor::toString(){
480 +    char buffer[65535];
481 +    std::string result;
482 +  
483 +    sprintf(buffer ,"------------------------------------------------------------------\n");
484 +    result += buffer;
485 +
486 +    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
487 +    result += buffer;
488 +
489 +    sprintf(buffer , "Visitor Description: Convert GBlipid into 4 different K atoms\n");
490 +    result += buffer;
491 +
492 +    sprintf(buffer ,"------------------------------------------------------------------\n");
493 +    result += buffer;
494 +
495 +    return result;
496 +  }
497 +
498    //----------------------------------------------------------------------------//
499  
500    void DefaultAtomVisitor::visit(Atom *atom) {
# Line 380 | Line 536 | namespace oopse {
536        return;
537  
538      pos = datom->getPos();
539 <    u = datom->getElectroFrame().getColumn(2);
540 <
539 >    if (datom->getAtomType()->isGayBerne()) {
540 >        u = datom->getA().transpose()*V3Z;        
541 >    } else if (datom->getAtomType()->isMultipole()) {
542 >        u = datom->getElectroFrame().getColumn(2);
543 >    }
544      atomData = new AtomData;
545      atomData->setID("ATOMDATA");
546      atomInfo = new AtomInfo;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines