| 35 |
|
* |
| 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). |
| 38 |
> |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |
| 39 |
|
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
| 40 |
|
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
| 41 |
|
*/ |
| 51 |
|
|
| 52 |
|
namespace OpenMD { |
| 53 |
|
|
| 54 |
+ |
|
| 55 |
+ |
DensityPlot::DensityPlot(SimInfo* info, const std::string& filename, |
| 56 |
+ |
const std::string& sele, const std::string& cmSele, |
| 57 |
+ |
RealType len, int nrbins) |
| 58 |
+ |
: StaticAnalyser(info, filename), |
| 59 |
+ |
len_(len), halfLen_(len/2), nRBins_(nrbins), |
| 60 |
+ |
selectionScript_(sele), seleMan_(info), evaluator_(info), |
| 61 |
+ |
cmSelectionScript_(cmSele), cmSeleMan_(info), cmEvaluator_(info) { |
| 62 |
|
|
| 55 |
– |
DensityPlot::DensityPlot(SimInfo* info, const std::string& filename, const std::string& sele, const std::string& cmSele, RealType len, int nrbins) |
| 56 |
– |
: StaticAnalyser(info, filename), selectionScript_(sele), evaluator_(info), seleMan_(info), |
| 57 |
– |
cmSelectionScript_(cmSele), cmEvaluator_(info), cmSeleMan_(info), |
| 58 |
– |
len_(len), nRBins_(nrbins), halfLen_(len/2) { |
| 59 |
– |
|
| 63 |
|
setOutputName(getPrefix(filename) + ".density"); |
| 64 |
< |
|
| 64 |
> |
|
| 65 |
|
deltaR_ = len_ /nRBins_; |
| 66 |
|
histogram_.resize(nRBins_); |
| 67 |
|
density_.resize(nRBins_); |
| 77 |
|
cmEvaluator_.loadScriptString(cmSele); |
| 78 |
|
if (!cmEvaluator_.isDynamic()) { |
| 79 |
|
cmSeleMan_.setSelectionSet(cmEvaluator_.evaluate()); |
| 80 |
< |
} |
| 78 |
< |
|
| 79 |
< |
|
| 80 |
> |
} |
| 81 |
|
} |
| 82 |
|
|
| 83 |
|
void DensityPlot::process() { |
| 92 |
|
reader.readFrame(i); |
| 93 |
|
currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); |
| 94 |
|
|
| 95 |
< |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
| 95 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; |
| 96 |
> |
mol = info_->nextMolecule(mi)) { |
| 97 |
|
//change the positions of atoms which belong to the rigidbodies |
| 98 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
| 98 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
| 99 |
> |
rb = mol->nextRigidBody(rbIter)) { |
| 100 |
|
rb->updateAtoms(); |
| 101 |
|
} |
| 102 |
|
|
| 115 |
|
Mat3x3d hmat = currentSnapshot_->getHmat(); |
| 116 |
|
RealType slabVolume = deltaR_ * hmat(0, 0) * hmat(1, 1); |
| 117 |
|
int k; |
| 118 |
< |
for (StuntDouble* sd = seleMan_.beginSelected(k); sd != NULL; sd = seleMan_.nextSelected(k)) { |
| 118 |
> |
for (StuntDouble* sd = seleMan_.beginSelected(k); sd != NULL; |
| 119 |
> |
sd = seleMan_.nextSelected(k)) { |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
if (!sd->isAtom()) { |
| 123 |
< |
sprintf( painCave.errMsg, "Can not calculate electron density if it is not atom\n"); |
| 123 |
> |
sprintf( painCave.errMsg, |
| 124 |
> |
"Can not calculate electron density if it is not atom\n"); |
| 125 |
|
painCave.severity = OPENMD_ERROR; |
| 126 |
|
painCave.isFatal = 1; |
| 127 |
|
simError(); |
| 171 |
|
} |
| 172 |
|
|
| 173 |
|
int nProcessed = nFrames /step_; |
| 174 |
< |
std::transform(density_.begin(), density_.end(), density_.begin(), std::bind2nd(std::divides<RealType>(), nProcessed)); |
| 174 |
> |
std::transform(density_.begin(), density_.end(), density_.begin(), |
| 175 |
> |
std::bind2nd(std::divides<RealType>(), nProcessed)); |
| 176 |
|
writeDensity(); |
| 177 |
|
|
| 178 |
|
|
| 184 |
|
int i; |
| 185 |
|
Vector3d newOrigin(0.0); |
| 186 |
|
RealType totalMass = 0.0; |
| 187 |
< |
for (StuntDouble* sd = seleMan_.beginSelected(i); sd != NULL; sd = seleMan_.nextSelected(i)) { |
| 187 |
> |
for (StuntDouble* sd = seleMan_.beginSelected(i); sd != NULL; |
| 188 |
> |
sd = seleMan_.nextSelected(i)) { |
| 189 |
|
RealType mass = sd->getMass(); |
| 190 |
|
totalMass += mass; |
| 191 |
|
newOrigin += sd->getPos() * mass; |
| 200 |
|
ofs << "#g(x, y, z)\n"; |
| 201 |
|
ofs << "#selection: (" << selectionScript_ << ")\n"; |
| 202 |
|
ofs << "#cmSelection:(" << cmSelectionScript_ << ")\n"; |
| 203 |
< |
ofs << "#nRBins = " << nRBins_ << "\t maxLen = " << len_ << "\tdeltaR = " << deltaR_ <<"\n"; |
| 203 |
> |
ofs << "#nRBins = " << nRBins_ << "\t maxLen = " |
| 204 |
> |
<< len_ << "\tdeltaR = " << deltaR_ <<"\n"; |
| 205 |
|
for (unsigned int i = 0; i < histogram_.size(); ++i) { |
| 206 |
|
ofs << i*deltaR_ - halfLen_ <<"\t" << density_[i]<< std::endl; |
| 207 |
|
} |
| 208 |
|
} else { |
| 209 |
|
|
| 210 |
< |
sprintf(painCave.errMsg, "DensityPlot: unable to open %s\n", outputFilename_.c_str()); |
| 210 |
> |
sprintf(painCave.errMsg, "DensityPlot: unable to open %s\n", |
| 211 |
> |
outputFilename_.c_str()); |
| 212 |
|
painCave.isFatal = 1; |
| 213 |
|
simError(); |
| 214 |
|
} |