36 |
|
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
|
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
|
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
< |
* [4] Vardeman & Gezelter, in progress (2009). |
39 |
> |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
40 |
> |
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
|
*/ |
42 |
|
|
43 |
|
/** |
76 |
|
#include "antlr/NoViableAltForCharException.hpp" |
77 |
|
#include "antlr/NoViableAltException.hpp" |
78 |
|
|
79 |
+ |
#include "types/DirectionalAdapter.hpp" |
80 |
+ |
#include "types/MultipoleAdapter.hpp" |
81 |
+ |
#include "types/EAMAdapter.hpp" |
82 |
+ |
#include "types/SuttonChenAdapter.hpp" |
83 |
+ |
#include "types/PolarizableAdapter.hpp" |
84 |
+ |
#include "types/FixedChargeAdapter.hpp" |
85 |
+ |
#include "types/FluctuatingChargeAdapter.hpp" |
86 |
+ |
|
87 |
|
#ifdef IS_MPI |
88 |
|
#include "mpi.h" |
89 |
|
#include "math/ParallelRandNumGen.hpp" |
422 |
|
//create the molecules |
423 |
|
createMolecules(info); |
424 |
|
|
425 |
+ |
//find the storage layout |
426 |
+ |
|
427 |
+ |
int storageLayout = computeStorageLayout(info); |
428 |
+ |
|
429 |
+ |
cerr << "computed Storage Layout = " << storageLayout << "\n"; |
430 |
+ |
|
431 |
|
//allocate memory for DataStorage(circular reference, need to |
432 |
|
//break it) |
433 |
< |
info->setSnapshotManager(new SimSnapshotManager(info)); |
433 |
> |
info->setSnapshotManager(new SimSnapshotManager(info, storageLayout)); |
434 |
|
|
435 |
|
//set the global index of atoms, rigidbodies and cutoffgroups |
436 |
|
//(only need to be set once, the global index will never change |
666 |
|
|
667 |
|
} //end for(int i=0) |
668 |
|
} |
669 |
+ |
|
670 |
+ |
int SimCreator::computeStorageLayout(SimInfo* info) { |
671 |
+ |
|
672 |
+ |
Globals* simParams = info->getSimParams(); |
673 |
+ |
int nRigidBodies = info->getNGlobalRigidBodies(); |
674 |
+ |
set<AtomType*> atomTypes = info->getSimulatedAtomTypes(); |
675 |
+ |
set<AtomType*>::iterator i; |
676 |
+ |
bool hasDirectionalAtoms = false; |
677 |
+ |
bool hasFixedCharge = false; |
678 |
+ |
bool hasMultipoles = false; |
679 |
+ |
bool hasPolarizable = false; |
680 |
+ |
bool hasFluctuatingCharge = false; |
681 |
+ |
bool hasMetallic = false; |
682 |
+ |
int storageLayout = 0; |
683 |
+ |
storageLayout |= DataStorage::dslPosition; |
684 |
+ |
storageLayout |= DataStorage::dslVelocity; |
685 |
+ |
storageLayout |= DataStorage::dslForce; |
686 |
+ |
|
687 |
+ |
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
688 |
+ |
|
689 |
+ |
DirectionalAdapter da = DirectionalAdapter( (*i) ); |
690 |
+ |
MultipoleAdapter ma = MultipoleAdapter( (*i) ); |
691 |
+ |
EAMAdapter ea = EAMAdapter( (*i) ); |
692 |
+ |
SuttonChenAdapter sca = SuttonChenAdapter( (*i) ); |
693 |
+ |
PolarizableAdapter pa = PolarizableAdapter( (*i) ); |
694 |
+ |
FixedChargeAdapter fca = FixedChargeAdapter( (*i) ); |
695 |
+ |
FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter( (*i) ); |
696 |
+ |
|
697 |
+ |
if (da.isDirectional()){ |
698 |
+ |
hasDirectionalAtoms = true; |
699 |
+ |
} |
700 |
+ |
if (ma.isMultipole()){ |
701 |
+ |
hasMultipoles = true; |
702 |
+ |
} |
703 |
+ |
if (ea.isEAM() || sca.isSuttonChen()){ |
704 |
+ |
hasMetallic = true; |
705 |
+ |
} |
706 |
+ |
if ( fca.isFixedCharge() ){ |
707 |
+ |
hasFixedCharge = true; |
708 |
+ |
} |
709 |
+ |
if ( fqa.isFluctuatingCharge() ){ |
710 |
+ |
hasFluctuatingCharge = true; |
711 |
+ |
} |
712 |
+ |
if ( pa.isPolarizable() ){ |
713 |
+ |
hasPolarizable = true; |
714 |
+ |
} |
715 |
+ |
} |
716 |
|
|
717 |
+ |
if (nRigidBodies > 0 || hasDirectionalAtoms) { |
718 |
+ |
storageLayout |= DataStorage::dslAmat; |
719 |
+ |
if(storageLayout & DataStorage::dslVelocity) { |
720 |
+ |
storageLayout |= DataStorage::dslAngularMomentum; |
721 |
+ |
} |
722 |
+ |
if (storageLayout & DataStorage::dslForce) { |
723 |
+ |
storageLayout |= DataStorage::dslTorque; |
724 |
+ |
} |
725 |
+ |
} |
726 |
+ |
if (hasMultipoles) { |
727 |
+ |
storageLayout |= DataStorage::dslElectroFrame; |
728 |
+ |
} |
729 |
+ |
if (hasFixedCharge || hasFluctuatingCharge) { |
730 |
+ |
storageLayout |= DataStorage::dslSkippedCharge; |
731 |
+ |
} |
732 |
+ |
if (hasMetallic) { |
733 |
+ |
storageLayout |= DataStorage::dslDensity; |
734 |
+ |
storageLayout |= DataStorage::dslFunctional; |
735 |
+ |
storageLayout |= DataStorage::dslFunctionalDerivative; |
736 |
+ |
} |
737 |
+ |
if (hasPolarizable) { |
738 |
+ |
storageLayout |= DataStorage::dslElectricField; |
739 |
+ |
} |
740 |
+ |
if (hasFluctuatingCharge){ |
741 |
+ |
storageLayout |= DataStorage::dslFlucQPosition; |
742 |
+ |
if(storageLayout & DataStorage::dslVelocity) { |
743 |
+ |
storageLayout |= DataStorage::dslFlucQVelocity; |
744 |
+ |
} |
745 |
+ |
if (storageLayout & DataStorage::dslForce) { |
746 |
+ |
storageLayout |= DataStorage::dslFlucQForce; |
747 |
+ |
} |
748 |
+ |
} |
749 |
+ |
|
750 |
+ |
if (simParams->getOutputParticlePotential()) { |
751 |
+ |
storageLayout |= DataStorage::dslParticlePot; |
752 |
+ |
} |
753 |
+ |
|
754 |
+ |
return storageLayout; |
755 |
+ |
} |
756 |
+ |
|
757 |
|
void SimCreator::setGlobalIndex(SimInfo *info) { |
758 |
|
SimInfo::MoleculeIterator mi; |
759 |
|
Molecule::AtomIterator ai; |