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

Comparing branches/development/src/nonbonded/Electrostatic.cpp (file contents):
Revision 1710 by gezelter, Fri May 18 21:44:02 2012 UTC vs.
Revision 1721 by gezelter, Thu May 24 14:17:42 2012 UTC

# Line 48 | Line 48
48   #include "utils/simError.h"
49   #include "types/NonBondedInteractionType.hpp"
50   #include "types/FixedChargeAdapter.hpp"
51 + #include "types/FluctuatingChargeAdapter.hpp"
52   #include "types/MultipoleAdapter.hpp"
53   #include "io/Globals.hpp"
54 + #include "nonbonded/SlaterIntegrals.hpp"
55 + #include "utils/PhysicalConstants.hpp"
56  
57 +
58   namespace OpenMD {
59    
60    Electrostatic::Electrostatic(): name_("Electrostatic"), initialized_(false),
# Line 285 | Line 289 | namespace OpenMD {
289  
290      if (fca.isFixedCharge()) {
291        electrostaticAtomData.is_Charge = true;
292 <      electrostaticAtomData.charge = fca.getCharge();
292 >      electrostaticAtomData.fixedCharge = fca.getCharge();
293      }
294  
295      MultipoleAdapter ma = MultipoleAdapter(atomType);
# Line 309 | Line 313 | namespace OpenMD {
313        }
314      }
315      
316 +    FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atomType);
317  
318 +    if (fqa.isFluctuatingCharge()) {
319 +      electrostaticAtomData.is_Fluctuating = true;
320 +      electrostaticAtomData.electronegativity = fqa.getElectronegativity();
321 +      electrostaticAtomData.hardness = fqa.getHardness();
322 +      electrostaticAtomData.slaterN = fqa.getSlaterN();
323 +      electrostaticAtomData.slaterZeta = fqa.getSlaterZeta();
324 +    } else {
325 +      electrostaticAtomData.is_Fluctuating = false;
326 +    }
327 +
328      pair<map<int,AtomType*>::iterator,bool> ret;    
329      ret = ElectrostaticList.insert( pair<int,AtomType*>(atomType->getIdent(),
330                                                          atomType) );
# Line 322 | Line 337 | namespace OpenMD {
337        simError();        
338      }
339      
340 <    ElectrostaticMap[atomType] = electrostaticAtomData;    
340 >    ElectrostaticMap[atomType] = electrostaticAtomData;  
341 >
342 >    // Now, iterate over all known types and add to the mixing map:
343 >    
344 >    map<AtomType*, ElectrostaticAtomData>::iterator it;
345 >    for( it = ElectrostaticMap.begin(); it != ElectrostaticMap.end(); ++it) {
346 >      AtomType* atype2 = (*it).first;
347 >      ElectrostaticAtomData eaData2 = (*it).second;
348 >      if (eaData2.is_Fluctuating && electrostaticAtomData.is_Fluctuating) {
349 >        
350 >        RealType a = electrostaticAtomData.slaterZeta;
351 >        RealType b = eaData2.slaterZeta;
352 >        int m = electrostaticAtomData.slaterN;
353 >        int n = eaData2.slaterN;
354 >
355 >        // Create the spline of the coulombic integral for s-type
356 >        // Slater orbitals.  Add a 2 angstrom safety window to deal
357 >        // with cutoffGroups that have charged atoms longer than the
358 >        // cutoffRadius away from each other.
359 >
360 >        RealType rval;
361 >        RealType dr = (cutoffRadius_ + 2.0) / RealType(np_ - 1);
362 >        vector<RealType> rvals;
363 >        vector<RealType> J1vals;
364 >        vector<RealType> J2vals;
365 >        for (int i = 0; i < np_; i++) {
366 >          rval = RealType(i) * dr;
367 >          rvals.push_back(rval);
368 >          J1vals.push_back( sSTOCoulInt( a, b, m, n, rval * PhysicalConstants::angstromsToBohr ) );
369 >          // may not be necessary if Slater coulomb integral is symmetric
370 >          J2vals.push_back( sSTOCoulInt( b, a, n, m, rval * PhysicalConstants::angstromsToBohr ) );
371 >        }
372 >
373 >        CubicSpline* J1 = new CubicSpline();
374 >        J1->addPoints(rvals, J1vals);
375 >        CubicSpline* J2 = new CubicSpline();
376 >        J2->addPoints(rvals, J2vals);
377 >        
378 >        pair<AtomType*, AtomType*> key1, key2;
379 >        key1 = make_pair(atomType, atype2);
380 >        key2 = make_pair(atype2, atomType);
381 >        
382 >        Jij[key1] = J1;
383 >        Jij[key2] = J2;
384 >      }
385 >    }
386 >
387      return;
388    }
389    
# Line 390 | Line 451 | namespace OpenMD {
451  
452      pair<RealType, RealType> res;
453      
454 +    // splines for coulomb integrals
455 +    CubicSpline* J1;
456 +    CubicSpline* J2;
457 +    
458      if (!initialized_) initialize();
459      
460      ElectrostaticAtomData data1 = ElectrostaticMap[idat.atypes.first];
# Line 406 | Line 471 | namespace OpenMD {
471      bool i_is_Dipole = data1.is_Dipole;
472      bool i_is_SplitDipole = data1.is_SplitDipole;
473      bool i_is_Quadrupole = data1.is_Quadrupole;
474 +    bool i_is_Fluctuating = data1.is_Fluctuating;
475  
476      bool j_is_Charge = data2.is_Charge;
477      bool j_is_Dipole = data2.is_Dipole;
478      bool j_is_SplitDipole = data2.is_SplitDipole;
479      bool j_is_Quadrupole = data2.is_Quadrupole;
480 +    bool j_is_Fluctuating = data2.is_Fluctuating;
481      
482      if (i_is_Charge) {
483 <      q_i = data1.charge;
483 >      q_i = data1.fixedCharge;
484 >
485 >      if (i_is_Fluctuating) {
486 >        q_i += *(idat.flucQ1);
487 >      }
488 >      
489        if (idat.excluded) {
490          *(idat.skippedCharge2) += q_i;
491        }
# Line 451 | Line 523 | namespace OpenMD {
523      }
524  
525      if (j_is_Charge) {
526 <      q_j = data2.charge;
526 >      q_j = data2.fixedCharge;
527 >
528 >      if (i_is_Fluctuating)
529 >        q_j += *(idat.flucQ2);
530 >
531        if (idat.excluded) {
532          *(idat.skippedCharge1) += q_j;
533        }
# Line 489 | Line 565 | namespace OpenMD {
565        duduz_j = V3Zero;
566      }
567      
568 +    if (i_is_Fluctuating && j_is_Fluctuating) {
569 +      J1 = Jij[idat.atypes];
570 +      J2 = Jij[make_pair(idat.atypes.second, idat.atypes.first)];
571 +    }
572 +
573      epot = 0.0;
574      dVdr = V3Zero;
575      
# Line 540 | Line 621 | namespace OpenMD {
621  
622            vterm = preVal * riji * erfcVal;          
623            dudr  = -  *(idat.sw)  * preVal * c2;
624 +          
625 +        }
626  
627 +        
628 +        if (i_is_Fluctuating) {
629 +          if (!idat.excluded)
630 +            *(idat.dVdFQ1) += *(idat.sw) * vterm / q_i;
631 +          else {
632 +            res = J1->getValueAndDerivativeAt( *(idat.rij) );
633 +            *(idat.dVdFQ1) += pre11_ * res.first * q_j;
634 +          }
635 +        }
636 +        if (j_is_Fluctuating) {
637 +          if (!idat.excluded)
638 +            *(idat.dVdFQ2) += *(idat.sw) * vterm / q_j;
639 +          else {
640 +            res = J2->getValueAndDerivativeAt( *(idat.rij) );
641 +            *(idat.dVdFQ2) += pre11_ * res.first * q_i;
642 +          }
643          }
644  
645          vpair += vterm;
# Line 964 | Line 1063 | namespace OpenMD {
1063        }
1064      } else if (summationMethod_ == esm_SHIFTED_FORCE || summationMethod_ == esm_SHIFTED_POTENTIAL) {
1065        if (i_is_Charge) {        
1066 <        chg1 = data.charge;
1066 >        chg1 = data.fixedCharge;
1067          if (screeningMethod_ == DAMPED) {
1068            self = - 0.5 * (c1c_ + alphaPi_) * chg1 * (chg1 + *(sdat.skippedCharge)) * pre11_;
1069          } else {        

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines