8 #include "RingRouseAutoCorr.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> 15 #include <util/archives/Serializable_includes.h> 55 read<int>(in,
"speciesId", speciesId_);
56 read<int>(in,
"p", p_);
57 read<int>(in,
"capacity", capacity_);
59 if (speciesId_ < 0)
UTIL_THROW(
"Negative speciesId");
61 if (capacity_ <= 0)
UTIL_THROW(
"Negative capacity");
62 if (speciesId_ >=
system().simulation().nSpecies())
66 int speciesCapacity = speciesPtr_->
capacity();
67 nAtom_ = speciesPtr_->
nAtom();
70 data_.allocate(speciesCapacity);
73 isInitialized_ =
true;
82 loadParameter<int>(ar,
"speciesId", speciesId_);
83 loadParameter<int>(ar,
"p", p_);
84 loadParameter<int>(ar,
"capacity", capacity_);
91 int speciesCapacity = speciesPtr_->
capacity();
92 data_.allocate(speciesCapacity);
101 if (capacity_ <= 0) {
104 if (speciesId_ < 0) {
107 if (speciesId_ >=
system().simulation().nSpecies()) {
110 if (nAtom_ != speciesPtr_->
nAtom()) {
113 if (projector_.capacity() != nAtom_) {
114 UTIL_THROW(
"Inconsistent projector capacity");
116 if (accumulator_.bufferCapacity() != capacity_) {
117 UTIL_THROW(
"Inconsistent accumulator buffer capacity");
120 isInitialized_ =
true;
137 nAtom_ = speciesPtr_->
nAtom();
138 if (nAtom_ <= 0)
UTIL_THROW(
"Number of atoms per molecule < 1.");
146 for (
int j = 0; j < nAtom_; ++j)
147 projector_[j] = 1.0 /
double(nAtom_);
150 qMode = 2.0*acos(-1.0)*double(p_/2)/double(nAtom_);
151 for (
int j = 0; j < nAtom_; ++j)
152 projector_[j] = 1.0 /
double(nAtom_) * cos(qMode*
double(j));
154 qMode = 2.0*acos(-1.0)*double((p_+1)/2)/double(nAtom_);
155 for (
int j = 0; j < nAtom_; ++j)
156 projector_[j] = 1.0 /
double(nAtom_) * sin(qMode*
double(j));
161 accumulator_.setParam(nMolecule_, capacity_);
173 Vector r1, r2, dR, atomPos;
177 if (nMolecule_ !=
system().nMolecule(speciesId_)) {
178 UTIL_THROW(
"Number of molecules has changed.");
182 for (i=0; i < nMolecule_; i++) {
187 dR.
multiply(atomPos, projector_[0]);
189 for (j = 1; j < nAtom_; j++) {
194 dR.
multiply(atomPos, projector_[j]);
199 accumulator_.sample(data_);
218 accumulator_.output(outputFile_);
A Vector is a Cartesian vector.
virtual void sample(long iStep)
Evaluate end-to-end vectors of all chains, add to ensemble.
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.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
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 loadParameters(Serializable::IArchive &ar)
Load parameters from archive.
virtual void output()
Output results to file after simulation is completed.
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.
RingRouseAutoCorr(System &system)
Constructor.
virtual ~RingRouseAutoCorr()
Destructor.
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.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
virtual void setup()
Allocate memory and initialize Rouse mode eigenvector p.
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.
virtual void readParameters(std::istream &in)
Read parameters from file, and allocate data array.
Template for Analyzer associated with one System.
Boundary & boundary() const
Get the Boundary by reference.
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
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.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
Species & species(int i)
Get a specific Species by reference.