9 #include <mcMd/simulation/Simulation.h> 10 #include <mcMd/simulation/McMd_mpi.h> 11 #include <mcMd/chemistry/Molecule.h> 12 #include <mcMd/chemistry/Atom.h> 13 #include <simp/boundary/Boundary.h> 14 #include <util/math/Constants.h> 15 #include <util/space/Dimension.h> 16 #include <util/misc/FileMaster.h> 17 #include <util/archives/Serializable_includes.h> 18 #include <util/misc/ioUtil.h> 19 #include <util/format/Int.h> 20 #include <util/format/Dbl.h> 51 atomTypeCoeffs_.
allocate(nAtomType_);
52 readDArray<double>(in,
"atomTypeCoeffs", atomTypeCoeffs_, nAtomType_);
54 read<int>(in,
"nBuffer", nBuffer_);
55 read<int>(in,
"nWave", nWave_);
56 waveIntVectors_.allocate(nWave_);
57 waveVectors_.allocate(nWave_);
59 accumulators_.allocate(nWave_);
60 for (
int i = 0; i < nWave_; ++i) {
61 accumulators_[i].setParam(nBuffer_);
64 readDArray<IntVector>(in,
"waveIntVectors", waveIntVectors_, nWave_);
65 isInitialized_ =
true;
75 atomTypeCoeffs_.
allocate(nAtomType_);
76 loadDArray<double>(ar,
"atomTypeCoeffs", atomTypeCoeffs_, nAtomType_);
77 loadParameter<int>(ar,
"nBuffer", nBuffer_);
78 loadParameter<int>(ar,
"nWave", nWave_);
79 waveIntVectors_.allocate(nWave_);
80 loadDArray<IntVector>(ar,
"waveIntVectors", waveIntVectors_, nWave_);
81 accumulators_.allocate(nWave_);
86 if (nAtomType_ !=
system().simulation().nAtomType()) {
87 UTIL_THROW(
"Inconsistent values of nAtomType");
89 if (nAtomType_ != atomTypeCoeffs_.capacity()) {
90 UTIL_THROW(
"Inconsistent capacity for atomTypeCoeffs");
92 if (nWave_ != waveIntVectors_.capacity()) {
93 UTIL_THROW(
"Inconsistent capacity for waveIntVectors");
97 waveVectors_.allocate(nWave_);
100 isInitialized_ =
true;
114 if (!isInitialized_) {
117 assert (nBuffer_ > 0);
119 for (
int i = 0; i < nWave_; ++i) {
120 accumulators_[i].clear();
130 std::complex<double> expFactor;
134 int nSpecies, iSpecies, i;
139 for (i = 0; i < nWave_; ++i) {
140 fourierModes_[i] = std::complex<double>(0.0, 0.0);
145 for (iSpecies = 0; iSpecies < nSpecies; ++iSpecies) {
147 for ( ; molIter.
notEnd(); ++molIter) {
148 molIter->begin(atomIter);
149 for ( ; atomIter.
notEnd(); ++atomIter) {
150 position = atomIter->position();
151 coeff = atomTypeCoeffs_[atomIter->typeId()];
154 for (i = 0; i < nWave_; ++i) {
156 product = position.
dot(waveVectors_[i]);
158 fourierModes_[i] += (coeff*expFactor);
168 double sqrtV = sqrt(
system().boundary().volume());
169 for (i = 0; i < nWave_; ++i) {
170 accumulators_[i].sample(fourierModes_[i]/sqrtV);
180 void VanHove::makeWaveVectors()
187 for (i = 0; i < nWave_; ++i) {
191 dWave *= waveIntVectors_[i][j];
192 waveVectors_[i] += dWave;
209 for (i = 0; i < nWave_; ++i) {
213 suffix = std::string(
"_");
215 suffix +=
toString(waveIntVectors_[i][j]);
217 suffix += std::string(
".dat");
218 outputFile_ << suffix << std::endl;
223 outputFile_ <<
Int(waveIntVectors_[i][j], 5);
225 outputFile_ <<
Dbl(waveVectors_[i].abs(), 20, 8);
226 outputFile_ << std::endl;
227 accumulators_[i].output(outputFile_);
228 outputFile_ << std::endl;
229 outputFile_ << std::endl;
const int Dimension
Dimensionality of space.
std::string toString(int n)
Return string representation of an integer.
A Vector is a Cartesian vector.
float product(float a, float b)
Product for float Data.
virtual void setup()
Clear accumulators.
void begin(int speciesId, MoleculeIterator &iterator)
Initialize an iterator for molecules of one species in this System.
double dot(const Vector &v) const
Return dot product of this vector and vector v.
An orthorhombic periodic unit cell.
void openOutputFile(const std::string &filename, std::ofstream &out, std::ios_base::openmode mode=std::ios_base::out) const
Open an output file.
static const Vector Zero
Zero Vector = {0.0, 0.0, 0.0}.
virtual void loadParameters(Serializable::IArchive &ar)
Load parameters from archive.
A set of interacting Molecules enclosed by a Boundary.
System & system()
Return reference to parent system.
Wrapper for a double precision number, for formatted ostream output.
virtual void output()
Output results to predefined output file.
Forward iterator for a PArray.
Classes used by all simpatico molecular simulations.
void readOutputFileName(std::istream &in)
Read outputFileName from file.
Forward const iterator for an Array or a C array.
Saving / output archive for binary ostream.
virtual void save(Serializable::OArchive &ar)
Save state to an archive.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Simulation & simulation() const
Get the parent Simulation by reference.
virtual void writeParam(std::ostream &out)
Write all parameters to an output stream.
const Vector & reciprocalBasisVector(int i) const
Return reciprocal lattice basis vector i.
void readInterval(std::istream &in)
Read interval from file, with error checking.
Utility classes for scientific computation.
void sample(long iStep)
Add particle pairs to VanHove histogram.
Wrapper for an int, for formatted ostream output.
Template for Analyzer associated with one System.
bool notEnd() const
Is the current pointer not at the end of the array?
Boundary & boundary() const
Get the Boundary by reference.
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
int nSpecies() const
Get the number of Species in this Simulation.
virtual void readParameters(std::istream &in)
Read parameters from file.
void setClassName(const char *className)
Set class name string.
virtual void loadParameters(Serializable::IArchive &ar)
Load state from an archive.
FileMaster & fileMaster()
Get the FileMaster by reference.
bool isAtInterval(long counter) const
Return true iff counter is a multiple of the interval.
const std::string & outputFileName() const
Return outputFileName string.
void allocate(int capacity)
Allocate the underlying C array.
int nAtomType() const
Get the number of atom types.
bool notEnd() const
Is this not the end of the array?
VanHove(System &system)
Constructor.
static const std::complex< double > Im
Square root of -1.