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

Comparing branches/development/src/nonbonded/InteractionManager.cpp (file contents):
Revision 1502 by gezelter, Sat Oct 2 19:53:32 2010 UTC vs.
Revision 1505 by gezelter, Sun Oct 3 22:18:59 2010 UTC

# Line 231 | Line 231 | namespace OpenMD {
231        }
232      }
233    }
234
235
236  void InteractionManager::doPrePair(AtomType* atype1,
237                                     AtomType* atype2,
238                                     RealType rij,
239                                     RealType &rho_i_at_j,
240                                     RealType &rho_j_at_i) {
241    
242  }
234    
235 <  void InteractionManager::doPreForce(AtomType* atype,
245 <                                      RealType rho,      
246 <                                      RealType &frho,
247 <                                      RealType &dfrhodrho) {
248 <  }
249 <
250 <  void InteractionManager::doSkipCorrection(AtomType* atype1,      
251 <                                            AtomType* atype2,
252 <                                            Vector3d d,
253 <                                            RealType rij,
254 <                                            RealType &skippedCharge1,
255 <                                            RealType &skippedCharge2,
256 <                                            RealType sw,
257 <                                            RealType electroMult,
258 <                                            RealType &pot,
259 <                                            RealType &vpair,
260 <                                            Vector3d &f1,
261 <                                            Mat3x3d eFrame1,
262 <                                            Mat3x3d eFrame2,
263 <                                            Vector3d &t1,
264 <                                            Vector3d &t2) {
265 <  }
266 <  
267 <  void InteractionManager::doSelfCorrection(AtomType* atype,
268 <                                            Mat3x3d eFrame,
269 <                                            RealType skippedCharge,
270 <                                            RealType &pot,
271 <                                            Vector3d &t) {
272 <  }
273 <
274 <  void InteractionManager::do_prepair(int *atid1, int *atid2, RealType *rij, RealType *rho_i_at_j, RealType *rho_j_at_i){
235 >  void InteractionManager::doPrePair(int *atid1, int *atid2, RealType *rij, RealType *rho_i_at_j, RealType *rho_j_at_i){
236      
237      if (!initialized_) initialize();
238 <    AtomType* atype1 = typeMap_[*atid1];
239 <    AtomType* atype2 = typeMap_[*atid2];
238 >          
239 >    DensityData ddat;
240 >
241 >    ddat.atype1 = typeMap_[*atid1];
242 >    ddat.atype2 = typeMap_[*atid2];
243 >    ddat.rij = *rij;
244 >    ddat.rho_i_at_j = *rho_i_at_j;
245 >    ddat.rho_j_at_i = *rho_j_at_i;
246 >
247 >    pair<AtomType*, AtomType*> key = make_pair(ddat.atype1, ddat.atype2);
248 >    set<NonBondedInteraction*>::iterator it;
249 >
250 >    for (it = interactions_[key].begin(); it != interactions_[key].end(); ++it){
251 >      if ((*it)->getFamily() == METALLIC_FAMILY) {
252 >        dynamic_cast<MetallicInteraction*>(*it)->calcDensity(ddat);
253 >      }
254 >    }
255      
280    doPrePair(atype1, atype2, *rij, *rho_i_at_j, *rho_j_at_i);
281    
256      return;    
257    }
258 +  
259 +  void InteractionManager::doPreForce(int *atid, RealType *rho, RealType *frho, RealType *dfrhodrho){
260  
261 <  void InteractionManager::do_preforce(int *atid, RealType *rho, RealType *frho, RealType *dfrhodrho){
261 >    if (!initialized_) initialize();
262 >          
263 >    FunctionalData fdat;
264  
265 <    if (!initialized_) initialize();    
266 <    AtomType* atype = typeMap_[*atid];
265 >    fdat.atype = typeMap_[*atid];
266 >    fdat.rho = *rho;
267 >    fdat.frho = *frho;
268 >    fdat.dfrhodrho = *dfrhodrho;
269  
270 <    doPreForce(atype, *rho, *frho, *dfrhodrho);
270 >    pair<AtomType*, AtomType*> key = make_pair(fdat.atype, fdat.atype);
271 >    set<NonBondedInteraction*>::iterator it;
272      
273 +    for (it = interactions_[key].begin(); it != interactions_[key].end(); ++it){
274 +      if ((*it)->getFamily() == METALLIC_FAMILY) {
275 +        dynamic_cast<MetallicInteraction*>(*it)->calcFunctional(fdat);
276 +      }
277 +    }
278 +    
279      return;    
280    }
281  
282 <  void InteractionManager::do_pair(int *atid1, int *atid2, RealType *d, RealType *r, RealType *r2, RealType *rcut, RealType *sw, RealType *vdwMult,RealType *electroMult, RealType *pot, RealType *vpair, RealType *f1, RealType *eFrame1, RealType *eFrame2, RealType *A1, RealType *A2, RealType *t1, RealType *t2, RealType *rho1, RealType *rho2, RealType *dfrho1, RealType *dfrho2, RealType *fshift1, RealType *fshift2){
283 <
282 >  void InteractionManager::doPair(int *atid1, int *atid2, RealType *d, RealType *r, RealType *r2, RealType *rcut, RealType *sw, RealType *vdwMult,RealType *electroMult, RealType *pot, RealType *vpair, RealType *f1, RealType *eFrame1, RealType *eFrame2, RealType *A1, RealType *A2, RealType *t1, RealType *t2, RealType *rho1, RealType *rho2, RealType *dfrho1, RealType *dfrho2, RealType *fshift1, RealType *fshift2){
283 >    
284      if (!initialized_) initialize();
285 <          
285 >    
286      InteractionData idat;
287 <
287 >    
288      idat.atype1 = typeMap_[*atid1];
289      idat.atype2 = typeMap_[*atid2];
290      idat.d = Vector3d(d);
# Line 344 | Line 331 | namespace OpenMD {
331      return;    
332    }
333  
334 <  void InteractionManager::do_skip_correction(int *atid1, int *atid2, RealType *d, RealType *r, RealType *skippedCharge1, RealType *skippedCharge2, RealType *sw, RealType *electroMult, RealType *pot, RealType *vpair, RealType *f1, RealType *eFrame1, RealType *eFrame2, RealType *t1, RealType *t2){
334 >  void InteractionManager::doSkipCorrection(int *atid1, int *atid2, RealType *d, RealType *r, RealType *skippedCharge1, RealType *skippedCharge2, RealType *sw, RealType *electroMult, RealType *pot, RealType *vpair, RealType *f1, RealType *eFrame1, RealType *eFrame2, RealType *t1, RealType *t2){
335  
336      if (!initialized_) initialize();
350          
351    AtomType* atype1 = typeMap_[*atid1];
352    AtomType* atype2 = typeMap_[*atid2];
353    Vector3d disp(d);
354    Vector3d frc(f1);
355    Vector3d trq1(t1);
356    Vector3d trq2(t2);
357    Mat3x3d eFi(eFrame1);
358    Mat3x3d eFj(eFrame2);
359      
360    doSkipCorrection(atype1, atype2, disp, *r, *skippedCharge1, *skippedCharge2, *sw,
361                     *electroMult, *pot,  *vpair, frc, eFi, eFj, trq1, trq2);
362
363    f1[0] = frc.x();
364    f1[1] = frc.y();
365    f1[2] = frc.z();
337      
338 <    t1[0] = trq1.x();
368 <    t1[1] = trq1.y();
369 <    t1[2] = trq1.z();
338 >    SkipCorrectionData skdat;
339      
340 <    t2[0] = trq2.x();
341 <    t2[1] = trq2.y();
342 <    t2[2] = trq2.z();
340 >    skdat.atype1 = typeMap_[*atid1];
341 >    skdat.atype2 = typeMap_[*atid2];
342 >    skdat.d = Vector3d(d);
343 >    skdat.rij = *r;
344 >    skdat.skippedCharge1 = *skippedCharge1;
345 >    skdat.skippedCharge2 = *skippedCharge2;
346 >    skdat.sw = *sw;
347 >    skdat.electroMult = *electroMult;
348 >    skdat.pot = *pot;
349 >    skdat.vpair = *vpair;
350 >    skdat.f1 = Vector3d(f1);
351 >    skdat.eFrame1 = Mat3x3d(eFrame1);
352 >    skdat.eFrame2 = Mat3x3d(eFrame2);
353 >    skdat.t1 = Vector3d(t1);
354 >    skdat.t2 = Vector3d(t2);
355  
356 <    return;
357 <  }
356 >    pair<AtomType*, AtomType*> key = make_pair(skdat.atype1, skdat.atype2);
357 >    set<NonBondedInteraction*>::iterator it;
358  
359 <  void InteractionManager::do_self_correction(int *atid, RealType *eFrame, RealType *skippedCharge, RealType *pot, RealType *t){
359 >    for (it = interactions_[key].begin(); it != interactions_[key].end(); ++it){
360 >      if ((*it)->getFamily() == ELECTROSTATIC_FAMILY) {
361 >        dynamic_cast<ElectrostaticInteraction*>(*it)->calcSkipCorrection(skdat);
362 >      }
363 >    }
364 >    
365 >    f1[0] = skdat.f1.x();
366 >    f1[1] = skdat.f1.y();
367 >    f1[2] = skdat.f1.z();
368 >    
369 >    t1[0] = skdat.t1.x();
370 >    t1[1] = skdat.t1.y();
371 >    t1[2] = skdat.t1.z();
372 >    
373 >    t2[0] = skdat.t2.x();
374 >    t2[1] = skdat.t2.y();
375 >    t2[2] = skdat.t2.z();
376  
377 +    return;    
378 +  }
379 +
380 +  void InteractionManager::doSelfCorrection(int *atid, RealType *eFrame, RealType *skippedCharge, RealType *pot, RealType *t){
381 +
382      if (!initialized_) initialize();
383 <          
384 <    AtomType* atype = typeMap_[*atid];
385 <    Mat3x3d eFi(eFrame);
386 <    Vector3d trq1(t);
387 <      
388 <    doSelfCorrection(atype, eFi, *skippedCharge, *pot, trq1);
383 >    
384 >    SelfCorrectionData scdat;
385 >    
386 >    scdat.atype = typeMap_[*atid];
387 >    scdat.eFrame = Mat3x3d(eFrame);
388 >    scdat.skippedCharge = *skippedCharge;
389 >    scdat.pot = *pot;
390 >    scdat.t = Vector3d(t);
391  
392 <    t[0] = trq1.x();
393 <    t[1] = trq1.y();
390 <    t[2] = trq1.z();
392 >    pair<AtomType*, AtomType*> key = make_pair(scdat.atype, scdat.atype);
393 >    set<NonBondedInteraction*>::iterator it;
394  
395 <    return;
395 >    for (it = interactions_[key].begin(); it != interactions_[key].end(); ++it){
396 >      if ((*it)->getFamily() == ELECTROSTATIC_FAMILY) {
397 >        dynamic_cast<ElectrostaticInteraction*>(*it)->calcSelfCorrection(scdat);
398 >      }
399 >    }
400 >        
401 >    t[0] = scdat.t.x();
402 >    t[1] = scdat.t.y();
403 >    t[2] = scdat.t.z();
404 >
405 >    return;    
406    }
407  
408 +
409 +  RealType InteractionManager::getSuggestedCutoffRadius(int *atid) {
410 +    if (!initialized_) initialize();
411 +    
412 +    AtomType* atype = typeMap_[*atid];
413 +
414 +    pair<AtomType*, AtomType*> key = make_pair(atype, atype);
415 +    set<NonBondedInteraction*>::iterator it;
416 +    RealType cutoff = 0.0;
417 +    
418 +    for (it = interactions_[key].begin(); it != interactions_[key].end(); ++it)
419 +      cutoff = max(cutoff, (*it)->getSuggestedCutoffRadius(atype, atype));  
420 +    return cutoff;    
421 +  }
422 +
423   } //end namespace OpenMD
424  
425   extern "C" {
# Line 406 | Line 434 | extern "C" {
434    void fortranDoPrePair(int *atid1, int *atid2, RealType *rij,
435                          RealType *rho_i_at_j, RealType *rho_j_at_i) {
436              
437 <    return OpenMD::InteractionManager::Instance()->do_prepair(atid1, atid2, rij,
438 <                                                              rho_i_at_j,  
439 <                                                              rho_j_at_i);
437 >    return OpenMD::InteractionManager::Instance()->doPrePair(atid1, atid2, rij,
438 >                                                             rho_i_at_j,  
439 >                                                             rho_j_at_i);
440    }
441    void fortranDoPreforce(int *atid, RealType *rho, RealType *frho,
442                           RealType *dfrhodrho) {  
443      
444 <    return OpenMD::InteractionManager::Instance()->do_preforce(atid, rho, frho,
445 <                                                               dfrhodrho);    
444 >    return OpenMD::InteractionManager::Instance()->doPreForce(atid, rho, frho,
445 >                                                              dfrhodrho);    
446    }
447    
448    void fortranDoPair(int *atid1, int *atid2, RealType *d, RealType *r,
449 <                     RealType *r2, RealType *rcut, RealType *sw, RealType *vdwMult,
450 <                     RealType *electroMult, RealType *pot, RealType *vpair, RealType *f1,
451 <                     RealType *eFrame1, RealType *eFrame2, RealType *A1, RealType *A2,
452 <                     RealType *t1, RealType *t2,
453 <                     RealType *rho1, RealType *rho2, RealType *dfrho1, RealType *dfrho2,
454 <                     RealType *fshift1, RealType *fshift2){
449 >                     RealType *r2, RealType *rcut, RealType *sw,
450 >                     RealType *vdwMult, RealType *electroMult, RealType *pot,
451 >                     RealType *vpair, RealType *f1, RealType *eFrame1,
452 >                     RealType *eFrame2, RealType *A1, RealType *A2,
453 >                     RealType *t1, RealType *t2, RealType *rho1, RealType *rho2,
454 >                     RealType *dfrho1, RealType *dfrho2, RealType *fshift1,
455 >                     RealType *fshift2){
456      
457 <    return OpenMD::InteractionManager::Instance()->do_pair(atid1, atid2, d, r, r2, rcut,
458 <                                                           sw, vdwMult, electroMult, pot,
459 <                                                           vpair, f1, eFrame1, eFrame2,
460 <                                                           A1, A2, t1, t2, rho1, rho2,
461 <                                                           dfrho1, dfrho2, fshift1, fshift2);
457 >    return OpenMD::InteractionManager::Instance()->doPair(atid1, atid2, d, r,
458 >                                                          r2, rcut, sw,
459 >                                                          vdwMult, electroMult,
460 >                                                          pot, vpair, f1,
461 >                                                          eFrame1, eFrame2,
462 >                                                          A1, A2, t1, t2, rho1,
463 >                                                          rho2, dfrho1, dfrho2,
464 >                                                          fshift1, fshift2);
465    }
466 <
467 <  void fortranDoSkipCorrection(int *atid1, int *atid2, RealType *d, RealType *r,
468 <                               RealType *skippedCharge1, RealType *skippedCharge2,
469 <                               RealType *sw, RealType *electroMult, RealType *pot,
466 >  
467 >  void fortranDoSkipCorrection(int *atid1, int *atid2, RealType *d,
468 >                               RealType *r, RealType *skippedCharge1,
469 >                               RealType *skippedCharge2, RealType *sw,
470 >                               RealType *electroMult, RealType *pot,
471                                 RealType *vpair, RealType *f1,
472                                 RealType *eFrame1, RealType *eFrame2,
473                                 RealType *t1, RealType *t2){
474      
475 <    return OpenMD::InteractionManager::Instance()->do_skip_correction(atid1, atid2, d, r,
476 <                                                                      skippedCharge1,
477 <                                                                      skippedCharge2,
478 <                                                                      sw, electroMult, pot,
479 <                                                                      vpair, f1, eFrame1,
480 <                                                                      eFrame2, t1, t2);
475 >    return OpenMD::InteractionManager::Instance()->doSkipCorrection(atid1,
476 >                                                                    atid2, d,
477 >                                                                    r,
478 >                                                                    skippedCharge1,
479 >                                                                    skippedCharge2,
480 >                                                                    sw, electroMult, pot,
481 >                                                                    vpair, f1, eFrame1,
482 >                                                                    eFrame2, t1, t2);
483    }
484 <
484 >  
485    void fortranDoSelfCorrection(int *atid, RealType *eFrame, RealType *skippedCharge,
486                                 RealType *pot, RealType *t) {
487      
488 <    return OpenMD::InteractionManager::Instance()->do_self_correction(atid, eFrame,
489 <                                                                      skippedCharge,
490 <                                                                      pot, t);
488 >    return OpenMD::InteractionManager::Instance()->doSelfCorrection(atid,
489 >                                                                    eFrame,
490 >                                                                    skippedCharge,
491 >                                                                    pot, t);
492    }
493 <  RealType fortranGetCutoff() {
494 <    return OpenMD::InteractionManager::Instance()->getCutoff();
493 >  RealType fortranGetCutoff(int *atid) {    
494 >    return OpenMD::InteractionManager::Instance()->getSuggestedCutoffRadius(atid);
495    }
496   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines