8 #include "IntraStructureFactorGrid.h" 9 #include <mcMd/simulation/Simulation.h> 10 #include <mcMd/simulation/McMd_mpi.h> 11 #include <util/crystal/PointGroup.h> 12 #include <util/crystal/PointSymmetry.h> 13 #include <util/archives/Serializable_includes.h> 14 #include <util/format/Int.h> 15 #include <util/format/Dbl.h> 51 readDArray< Pair<int> >(in,
"atomTypeIdPairs", atomTypeIdPairs_,
nAtomTypeIdPair_);
52 read<int>(in,
"hMax", hMax_);
53 read<Util::LatticeSystem>(in,
"lattice", lattice_);
56 nWave_ = (2*hMax_ + 1)*(2*hMax_ + 1)*(2*hMax_ + 1);
57 waveIntVectors_.allocate(nWave_);
58 waveVectors_.allocate(nWave_);
67 if (lattice_ == Cubic) {
69 nStar_ = (hMax_ + 1 )*(hMax_ + 2)*(hMax_ + 3)/6;
98 for (h = 0; h <= hMax_; ++h) {
100 for (k = 0; k <= h; ++k) {
102 for (l = 0; l <= k; ++l) {
106 starSizes_[i] = star.
size();
107 for (m = 0; m < star.
size(); ++m) {
108 waveIntVectors_[j] = star[m];
121 }
else if (lattice_ == Tetragonal) {
123 nStar_ = (hMax_ + 1 )*(hMax_ + 1)*(hMax_ + 2)/2;
151 for (h = 0; h <= hMax_; ++h) {
153 for (k = 0; k <= hMax_; ++k) {
155 for (l = 0; l <= k; ++l) {
159 starSizes_[i] = star.
size();
160 for (m = 0; m < star.
size(); ++m) {
161 waveIntVectors_[j] = star[m];
177 for (i = 0; i <
nWave_; ++i) {
185 isInitialized_ =
true;
197 loadDArray< Pair<int> >(ar,
"atomTypeIdPairs", atomTypeIdPairs_,
nAtomType_);
199 ar & waveIntVectors_;
204 loadParameter<int>(ar,
"hMax", hMax_);
205 loadParameter<Util::LatticeSystem>(ar,
"lattice", lattice_);
211 if (nWave_ != (2*hMax_ + 1)*(2*hMax_ + 1)*(2*hMax_ + 1)) {
214 if (nAtomType_ !=
system().simulation().nAtomType()) {
215 UTIL_THROW(
"Inconsistent values of nAtomType_");
218 UTIL_THROW(
"Inconsistent capacity1 for atomTypeIdPairs array");
220 if (waveIntVectors_.capacity() !=
nWave_) {
221 UTIL_THROW(
"Inconsistent capacity for waveIntVector");
225 waveVectors_.allocate(nWave_);
228 isInitialized_ =
true;
246 std::ios_base::openmode mode = std::ios_base::out;
248 mode = std::ios_base::out | std::ios_base::app;
253 isFirstStep_ =
false;
256 for (
int i = 0; i < nStar_; ++i) {
257 int size = starSizes_[i];
261 logFile_ <<
Int(waveIntVectors_[k][n], 5);
263 logFile_ <<
Dbl(waveVectors_[k].abs(), 20, 8);
268 for (
int m = 0; m < size; ++m) {
273 logFile_ << Dbl(avg, 20, 8);
276 logFile_ << std::endl;
278 logFile_ << std::endl;
285 double value, average, size;
298 for (i = 0; i < nStar_; ++i) {
299 size = starSizes_[i];
310 for (m = 0; m < size; ++m) {
315 average = average/double(size);
const int Dimension
Dimensionality of space.
~IntraStructureFactorGrid()
Destructor.
virtual void save(Serializable::OArchive &ar)
Save state to archive.
int nAtomTypeIdPair_
Number of selected atom type pairs.
void allocate(int capacity1, int capacity2)
Allocate memory for a matrix.
virtual void output()
Output structure factors, averaged over stars.
DMatrix< std::complex< double > > fourierModes_
Fourier modes.
Intramolecular contribution to the structure factor S(k)
void openOutputFile(const std::string &filename, std::ofstream &out, std::ios_base::openmode mode=std::ios_base::out) const
Open an output file.
DMatrix< double > structureFactorDelta_
Contribution of current time step to structure factor average.
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.
IntraStructureFactorGrid(System &system)
Constructor.
bool add(Symmetry &symmetry)
Add a new element to the group.
void readOutputFileName(std::istream &in)
Read outputFileName from file.
Saving / output archive for binary ostream.
virtual void sample(long iStep)
Add particles to StructureFactor accumulators.
int nSample_
Number of samples thus far.
A fixed capacity (static) contiguous array with a variable logical size.
#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.
void readInterval(std::istream &in)
Read interval from file, with error checking.
Utility classes for scientific computation.
int & R(int i, int j)
Return an element of the matrix by reference.
Wrapper for an int, for formatted ostream output.
void makeStar(const IntVector &root, FSArray< IntVector, N > &star)
Generate a set of reciprocal vectors that are related by symmetry.
Group of crystal symmetries with no translations.
void sample(long iStep)
Add particle pairs to IntraStructureFactor histogram.
int nWave_
Number of wavevectors.
int speciesId_
Index for molecular species.
int nAtomType_
Number of atom types, copied from Simulation::nAtomType().
Saving archive for binary istream.
std::ofstream outputFile_
Output file stream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
virtual void readParameters(std::istream &in)
Read parameters from file.
virtual void setup()
Set up before a simulation.
void setClassName(const char *className)
Set class name string.
An IntVector is an integer Cartesian vector.
DMatrix< double > structureFactors_
Structure factor accumulators.
FileMaster & fileMaster()
Get the FileMaster by reference.
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.
void makeCompleteGroup()
Generate a complete group from the current elements.
int size() const
Return logical size of this array (i.e., number of elements).
virtual void loadParameters(Serializable::IArchive &ar)
Load state from an archive.
A PointSymmetry represents a crystallographic point group symmetry.