8 #include "LinearRouseAutoCorr.h" 9 #include <mcMd/simulation/Simulation.h> 10 #include <mcMd/chemistry/Molecule.h> 11 #include <mcMd/chemistry/Atom.h> 12 #include <simp/species/Species.h> 13 #include <simp/boundary/Boundary.h> 14 #include <util/misc/FileMaster.h> 57 read<int>(in,
"speciesId", speciesId_);
58 read<int>(in,
"p", p_);
59 read<int>(in,
"capacity", capacity_);
70 if (speciesId_ >=
system().simulation().nSpecies())
74 nAtom_ = speciesPtr_->
nAtom();
77 int speciesCapacity = speciesPtr_->
capacity();
78 accumulator_.setParam(speciesCapacity, capacity_);
79 data_.allocate(speciesCapacity);
82 isInitialized_ =
true;
92 loadParameter<int>(ar,
"speciesId", speciesId_);
93 loadParameter<int>(ar,
"p", p_);
94 loadParameter<int>(ar,
"capacity", capacity_);
101 int speciesCapacity = speciesPtr_->
capacity();
102 data_.allocate(speciesCapacity);
105 if (speciesId_ < 0) {
111 if (capacity_ <= 0) {
114 if (speciesId_ < 0) {
117 if (speciesId_ >=
system().simulation().nSpecies()) {
120 if (nAtom_ != speciesPtr_->
nAtom()) {
123 if (projector_.capacity() != nAtom_) {
124 UTIL_THROW(
"Inconsistent projector capacity");
126 if (accumulator_.bufferCapacity() != capacity_) {
127 UTIL_THROW(
"Inconsistent accumulator buffer capacity");
130 isInitialized_ =
true;
145 if (!isInitialized_) {
151 if (nAtom_ <= 1)
UTIL_THROW(
"Number of atoms per molecule < 2.");
154 double qMode = acos(-1.0) * double(p_) / double(nAtom_ - 1);
156 for (
int j = 0; j < nAtom_; ++j)
157 projector_[j] = 1.0 /
double(nAtom_);
159 for (
int j = 0; j < nAtom_; ++j)
160 projector_[j] = 1.0 /
double(nAtom_) * cos(qMode*
double(j));
162 projector_[0] -= 0.5/double(nAtom_);
163 projector_[nAtom_ - 1] -= 0.5 / double(nAtom_);
166 accumulator_.setNEnsemble(nMolecule_);
168 accumulator_.clear();
179 Vector r1, r2, dR, atomPos;
183 if (nMolecule_ !=
system().nMolecule(speciesId_)) {
184 UTIL_THROW(
"Number of molecules has changed.");
188 for (i = 0; i < nMolecule_; ++i) {
193 dR.
multiply(atomPos, projector_[0]);
195 for (j = 1; j < nAtom_; j++) {
200 dR.
multiply(atomPos, projector_[j]);
205 accumulator_.sample(data_);
222 accumulator_.output(outputFile_);
virtual void output()
Output results after simulation is completed.
A Vector is a Cartesian vector.
int nAtom() const
Get number of atoms per molecule for this Species.
double distanceSq(const Vector &r1, const Vector &r2) const
Return square distance between positions r1 and r2.
Vector & multiply(const Vector &v, double s)
Multiply a vector v by a scalar s.
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 setup()
Set number of molecules, initialize eigenvector, and clear accumulator.
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.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
void readOutputFileName(std::istream &in)
Read outputFileName from file.
virtual void sample(long iStep)
Evaluate end-to-end vectors of all chains, add to ensemble.
Saving / output archive for binary ostream.
Molecule & molecule(int speciesId, int moleculeId)
Get a specific Molecule in this System, by integer index.
int nMolecule(int speciesId) const
Get the number of molecules of one Species in this System.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from 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.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
void readInterval(std::istream &in)
Read interval from file, with error checking.
Utility classes for scientific computation.
virtual ~LinearRouseAutoCorr()
Destructor.
Template for Analyzer associated with one System.
LinearRouseAutoCorr(System &system)
Constructor.
Boundary & boundary() const
Get the Boundary by reference.
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
virtual void readParameters(std::istream &in)
Read parameters from file.
void setClassName(const char *className)
Set class name string.
const Atom & atom(int localId) const
Get a specific Atom in this Molecule.
int capacity() const
Maximum allowed number of molecules for this Species.
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.
A physical molecule (a set of covalently bonded Atoms).
const Vector & position() const
Get the position Vector by const reference.
Species & species(int i)
Get a specific Species by reference.