8 #include "StructureFactorGrid.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> 40 read<int>(in,
"nMode",
nMode_);
44 read<int>(in,
"hMax", hMax_);
45 read<Util::LatticeSystem>(in,
"lattice", lattice_);
48 nWave_ = (2*hMax_ + 1)*(2*hMax_ + 1)*(2*hMax_ + 1);
58 if (lattice_ == Cubic) {
60 nStar_ = (hMax_ + 1 )*(hMax_ + 2)*(hMax_ + 3)/6;
89 for (h = 0; h <= hMax_; ++h) {
91 for (k = 0; k <= h; ++k) {
93 for (l = 0; l <= k; ++l) {
97 starSizes_[i] = star.
size();
98 for (m = 0; m < star.
size(); ++m) {
112 }
else if (lattice_ == Tetragonal) {
114 nStar_ = (hMax_ + 1 )*(hMax_ + 1)*(hMax_ + 2)/2;
142 for (h = 0; h <= hMax_; ++h) {
144 for (k = 0; k <= hMax_; ++k) {
146 for (l = 0; l <= k; ++l) {
150 starSizes_[i] = star.
size();
151 for (m = 0; m < star.
size(); ++m) {
165 }
else if (lattice_ == Orthorhombic) {
167 nStar_ = (hMax_ + 1 )*(hMax_ + 1)*(hMax_ + 1);
195 for (h = 0; h <= hMax_; ++h) {
197 for (k = 0; k <= hMax_; ++k) {
199 for (l = 0; l <= hMax_; ++l) {
203 starSizes_[i] = star.
size();
204 for (m = 0; m < star.
size(); ++m) {
221 for (i = 0; i <
nWave_; ++i) {
222 for (j = 0; j <
nMode_; ++j) {
229 isInitialized_ =
true;
240 loadParameter<int>(ar,
"nMode",
nMode_);
251 loadParameter<int>(ar,
"hMax", hMax_);
252 loadParameter<Util::LatticeSystem>(ar,
"lattice", lattice_);
260 if (nWave_ != (2*hMax_ + 1)*(2*hMax_ + 1)*(2*hMax_ + 1)) {
263 if (nAtomType_ !=
system().simulation().nAtomType()) {
264 UTIL_THROW(
"Inconsistent values of nAtomType_");
266 if (modes_.capacity1() !=
nMode_) {
267 UTIL_THROW(
"Inconsistent capacity1 for modes array");
270 UTIL_THROW(
"Inconsistent capacity2 for modes array");
272 if (waveIntVectors_.capacity() !=
nWave_) {
273 UTIL_THROW(
"Inconsistent capacity for waveIntVector");
280 isInitialized_ =
true;
295 std::ios_base::openmode mode = std::ios_base::out;
297 mode = std::ios_base::out | std::ios_base::app;
308 for (
int i = 0; i < nStar_; ++i) {
309 int size = starSizes_[i];
318 for (
int j = 0; j <
nMode_; ++j) {
319 double average = 0.0;
322 for (
int m = 0; m < size; ++m) {
328 average = average/double(size);
329 logFile_ << Dbl(average, 20, 8);
331 logFile_ << std::endl;
333 logFile_ << std::endl;
340 double value, average, size;
352 for (i = 0; i < nStar_; ++i) {
353 size = starSizes_[i];
358 for (m = 0; m < size; ++m) {
363 for (j = 0; j <
nMode_; ++j) {
378 for (j = 0; j <
nMode_; ++j) {
381 for (m = 0; m < size; ++m) {
386 average = average/double(size);
virtual void setup()
Set up before a simulation.
const int Dimension
Dimensionality of space.
int nSample_
Number of samples thus far.
DArray< Vector > waveVectors_
Array of floating point wave vectors (temporary).
void allocate(int capacity1, int capacity2)
Allocate memory for a matrix.
double volume() const
Return unit cell volume.
void openOutputFile(const std::string &filename, std::ofstream &out, std::ios_base::openmode mode=std::ios_base::out) const
Open an output file.
virtual void loadParameters(Serializable::IArchive &ar)
Load parameters from archive.
int nWave_
Number of wavevectors.
DMatrix< std::complex< double > > fourierModes_
Instantaneous Fourier amplitudes (temporary)
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.
bool add(Symmetry &symmetry)
Add a new element to the group.
void readOutputFileName(std::istream &in)
Read outputFileName from file.
virtual void readParameters(std::istream &in)
Read parameters from file.
DMatrix< double > modes_
Array of mode vectors.
StructureFactorGrid(System &system)
Constructor.
Saving / output archive for binary ostream.
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 loadParameters(Serializable::IArchive &ar)
Load state from an archive.
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.
int nAtomType_
Number of atom types, copied from Simulation::nAtomType().
DMatrix< double > structureFactors_
Structure factor accumulators.
Utility classes for scientific computation.
int & R(int i, int j)
Return an element of the matrix by reference.
DArray< IntVector > waveIntVectors_
Array of Miller index IntVectors for wavevectors.
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.
std::ofstream outputFile_
Output file stream.
int nMode_
Number of mode vectors.
virtual void sample(long iStep)
Add particles to StructureFactor accumulators.
StructureFactor evaluates structure factors in Fourier space.
Boundary & boundary() const
Get the Boundary by reference.
bool isFirstStep_
Is this the first step?
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
void setClassName(const char *className)
Set class name string.
An IntVector is an integer Cartesian vector.
FileMaster & fileMaster()
Get the FileMaster by reference.
const std::string & outputFileName() const
Return outputFileName string.
void allocate(int capacity)
Allocate the underlying C array.
virtual void sample(long iStep)
Add particles to StructureFactor accumulators.
int nAtomType() const
Get the number of atom types.
virtual void save(Serializable::OArchive &ar)
Save state to archive.
void makeCompleteGroup()
Generate a complete group from the current elements.
int size() const
Return logical size of this array (i.e., number of elements).
A PointSymmetry represents a crystallographic point group symmetry.
virtual void output()
Output structure factors, averaged over stars.