8 #include "IntraStructureFactor.h" 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> 53 readDArray< Pair<int> >(in,
"atomTypeIdPairs", atomTypeIdPairs_,
55 read<int>(in,
"nWave",
nWave_);
57 waveIntVectors_.allocate(
nWave_);
58 readDArray<IntVector>(in,
"waveIntVectors", waveIntVectors_,
nWave_);
61 waveVectors_.allocate(
nWave_);
66 isInitialized_ =
true;
77 loadParameter<int>(ar,
"speciesId",
speciesId_);
80 loadDArray< Pair<int> >(ar,
"atomTypeIdPairs", atomTypeIdPairs_,
82 loadParameter<int>(ar,
"nWave",
nWave_);
85 loadDArray<IntVector>(ar,
"waveIntVectors", waveIntVectors_,
nWave_);
97 waveVectors_.allocate(
nWave_);
98 isInitialized_ =
true;
114 if (!isInitialized_) {
122 for (i = 0; i <
nWave_; ++i) {
138 std::complex<double> rho[2];
139 std::complex<double> expFactor;
149 for (i = 0; i <
nWave_; ++i) {
157 for ( ; molIter.
notEnd(); ++molIter) {
160 for (i = 0; i <
nWave_; ++i) {
161 for (typeId = 0; typeId <=
nAtomType_; ++typeId) {
167 molIter->begin(atomIter);
168 for ( ; atomIter.
notEnd(); ++atomIter) {
169 position = atomIter->position();
170 typeId = atomIter->typeId();
173 for (i = 0; i <
nWave_; ++i) {
174 product = position.
dot(waveVectors_[i]);
183 for (i = 0; i <
nWave_; ++i) {
185 for (k = 0; k < 2; ++k) {
186 typeId = atomTypeIdPairs_[j][k];
193 rho[0] = std::conj(rho[0]);
194 dS = std::real(rho[0]*rho[1])/volume;
210 void IntraStructureFactor::makeWaveVectors()
217 for (i = 0; i <
nWave_; ++i) {
221 dWave *= waveIntVectors_[i][j];
222 waveVectors_[i] += dWave;
240 for (i = 0; i <
nWave_; ++i) {
const int Dimension
Dimensionality of space.
A Vector is a Cartesian vector.
float product(float a, float b)
Product for float Data.
int nAtomTypeIdPair_
Number of selected atom type pairs.
void allocate(int capacity1, int capacity2)
Allocate memory for a matrix.
void begin(int speciesId, MoleculeIterator &iterator)
Initialize an iterator for molecules of one species in this System.
DMatrix< std::complex< double > > fourierModes_
Fourier modes.
double volume() const
Return unit cell volume.
double dot(const Vector &v) const
Return dot product of this vector and vector v.
IntraStructureFactor(System &system)
Constructor.
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}.
DMatrix< double > structureFactorDelta_
Contribution of current time step to structure factor average.
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.
Forward iterator for a PArray.
Classes used by all simpatico molecular simulations.
void readOutputFileName(std::istream &in)
Read outputFileName from file.
virtual void loadParameters(Serializable::IArchive &ar)
Load state from archive.
Forward const iterator for an Array or a C array.
Saving / output archive for binary ostream.
int nSample_
Number of samples thus far.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
virtual void readParameters(std::istream &in)
Read parameters from file.
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.
virtual void setup()
Clear accumulators.
Wrapper for an int, for formatted ostream output.
void sample(long iStep)
Add particle pairs to IntraStructureFactor histogram.
int nWave_
Number of wavevectors.
Template for Analyzer associated with one System.
int speciesId_
Index for molecular species.
int nAtomType_
Number of atom types, copied from Simulation::nAtomType().
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.
std::ofstream outputFile_
Output file stream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
~IntraStructureFactor()
Destructor.
void setClassName(const char *className)
Set class name string.
DMatrix< double > structureFactors_
Structure factor accumulators.
FileMaster & fileMaster()
Get the FileMaster by reference.
void loadInterval(Serializable::IArchive &ar)
Load interval from archive, with error checking.
bool isAtInterval(long counter) const
Return true iff counter is a multiple of the interval.
const std::string & outputFileName() const
Return outputFileName string.
void loadOutputFileName(Serializable::IArchive &ar)
Load output file name from archive.
int nAtomType() const
Get the number of atom types.
bool notEnd() const
Is this not the end of the array?
static const std::complex< double > Im
Square root of -1.
virtual void output()
Output results to predefined output file.
virtual void save(Serializable::OArchive &ar)
Save state to archive.