8 #include "RadiusGyration.h" 9 #include <mcMd/simulation/Simulation.h> 10 #include <mcMd/chemistry/Molecule.h> 11 #include <mcMd/chemistry/Atom.h> 12 #include <simp/boundary/Boundary.h> 13 #include <simp/species/Species.h> 14 #include <util/misc/FileMaster.h> 15 #include <util/archives/Serializable_includes.h> 38 read<int>(in,
"nSamplePerBlock", nSamplePerBlock_);
39 read<int>(in,
"speciesId", speciesId_);
44 if (speciesId_ >=
system().simulation().nSpecies()) {
48 nAtom_ = speciesPtr_->
nAtom();
50 positions_.allocate(nAtom_);
58 isInitialized_ =
true;
67 loadParameter<int>(ar,
"nSamplePerBlock", nSamplePerBlock_);
68 loadParameter<int>(ar,
"speciesId", speciesId_);
75 if (speciesId_ >=
system().simulation().nSpecies()) {
79 if (nAtom_ != speciesPtr_->
nAtom()) {
87 if (nSamplePerBlock_) {
90 isInitialized_ =
true;
104 if (!isInitialized_) {
107 accumulator_.
clear();
129 for (j = 1 ; j < nAtom_; j++) {
133 positions_[j] = positions_[j-1];
135 Rcm += positions_[j];
137 Rcm /= double(nAtom_);
140 for (j = 0 ; j < nAtom_; j++) {
145 dRSq /= double(nMolecule);
146 dRSq /= double(nAtom_);
147 accumulator_.
sample(dRSq, outputFile_);
168 accumulator_.
output(outputFile_);
void clear()
Clear all accumulators, set to empty initial state.
A Vector is a Cartesian vector.
virtual void loadParameters(Serializable::IArchive &ar)
Load state to an archive.
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.
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.
A set of interacting Molecules enclosed by a Boundary.
System & system()
Return reference to parent system.
Classes used by all simpatico molecular simulations.
void readOutputFileName(std::istream &in)
Read outputFileName from file.
RadiusGyration(System &system)
Constructor.
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 setup()
Clear accumulator.
#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.
Template for Analyzer associated with one System.
void output(std::ostream &out) const
Output final statistical properties to file.
void setNSamplePerBlock(int nSamplePerBlock)
Set nSamplePerBlock.
Boundary & boundary() const
Get the Boundary by reference.
Saving archive for binary istream.
void sample(double value)
Add a sampled value to the ensemble.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
int nSamplePerBlock() const
Get number of samples per block average.
Vector & subtract(const Vector &v1, const Vector &v2)
Subtract vector v2 from v1.
virtual void readParameters(std::istream &in)
Read parameters from file, and allocate data array.
void setClassName(const char *className)
Set class name string.
const Atom & atom(int localId) const
Get a specific Atom in this Molecule.
FileMaster & fileMaster()
Get the FileMaster by reference.
virtual void save(Serializable::OArchive &ar)
Save state to archive.
bool isAtInterval(long counter) const
Return true iff counter is a multiple of the interval.
const std::string & outputFileName() const
Return outputFileName string.
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.
double square() const
Return square magnitude of this vector.
virtual void output()
Output results at end of simulation.
virtual void sample(long iStep)
Evaluate squared radii of gyration for all molecules, add to ensemble.