53#include "brains/Register.hpp"
56#include "brains/Thermo.hpp"
58#include "io/DumpWriter.hpp"
61#include "types/FluctuatingChargeAdapter.hpp"
62#include "utils/Constants.hpp"
63#include "utils/simError.h"
69void createMdFile(
const std::string& oldMdFileName,
70 const std::string& newMdFileName, std::vector<int> nMol);
72int main(
int argc,
char* argv[]) {
78 if (cmdline_parser(argc, argv, &args_info) != 0) { exit(1); }
84 strcpy(painCave.errMsg,
"No input file name was specified.\n");
92 strcpy(painCave.errMsg,
"No output file name was specified.\n");
98 double phi = args_info.
rotatePhi_arg * (Constants::PI / 180.0);
100 double psi = args_info.
rotatePsi_arg * (Constants::PI / 180.0);
102 Mat3x3d rotMatrix = Mat3x3d(0.0);
109 Mat3x3d repeatD = Mat3x3d(0.0);
110 repeatD(0, 0) = repeat.
x();
111 repeatD(1, 1) = repeat.
y();
112 repeatD(2, 2) = repeat.
z();
122 Globals* simParams = oldInfo->getSimParams();
123 std::vector<Component*> components = simParams->getComponents();
124 std::vector<int> nMol;
125 for (vector<Component*>::iterator i = components.begin();
126 i != components.end(); ++i) {
127 int nMolOld = (*i)->getNMol();
128 int nMolNew = nMolOld * repeat.
x() * repeat.
y() * repeat.
z();
129 nMol.push_back(nMolNew);
132 createMdFile(dumpFileName, outFileName, nMol);
141 if (writer == NULL) {
142 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
143 "error in creating DumpWriter");
144 painCave.isFatal = 1;
148 SimInfo::MoleculeIterator miter;
149 Molecule::IntegrableObjectIterator iiter;
150 Molecule::RigidBodyIterator rbIter;
168 for (
int i = 0; i < nframes; i++) {
169 cerr <<
"frame = " << i <<
"\n";
170 dumpReader->readFrame(i);
175 newSnap->setTime(oldSnap->getTime());
178 rotHmat = rotMatrix * oldHmat;
179 newHmat = repeatD * rotHmat;
182 newSnap->setThermostat(oldSnap->getThermostat());
183 newSnap->setBarostat(oldSnap->getBarostat());
190 COM = thermo.getCom();
197 for (sd = mol->beginIntegrableObject(iiter); sd != NULL;
198 sd = mol->nextIntegrableObject(iiter)) {
200 relPos = sd->
getPos() - molCOM;
201 oldPos = molCOM - COM;
211 oldPos = sd->
getPos() - COM;
224 for (
int ii = 0; ii < repeat.
x(); ii++) {
225 for (
int jj = 0; jj < repeat.
y(); jj++) {
226 for (
int kk = 0; kk < repeat.
z(); kk++) {
227 Vector3d trans = Vector3d(ii, jj, kk);
229 for (sd = mol->beginIntegrableObject(iiter); sd != NULL;
230 sd = mol->nextIntegrableObject(iiter)) {
233 newPos = rotMatrix * oldPos + trans * oldHmat + translate;
240 Mat3x3d bodyRotMat = sd->
getA();
241 bodyRotMat = bodyRotMat * rotMatrix.
inverse();
242 sdNew->
setA(bodyRotMat);
243 sdNew->
setJ(rotMatrix * sd->
getJ());
247 atype =
static_cast<Atom*
>(sd)->getAtomType();
249 if (fqa.isFluctuatingCharge()) {
268 for (rb = mol->beginRigidBody(rbIter); rb != NULL;
269 rb = mol->nextRigidBody(rbIter)) {
282void createMdFile(
const std::string& oldMdFileName,
283 const std::string& newMdFileName, std::vector<int> nMol) {
286 const int MAXLEN = 65535;
291 oldMdFile.open(oldMdFileName.c_str());
292 newMdFile.open(newMdFileName.c_str());
294 oldMdFile.getline(buffer, MAXLEN);
297 while (!oldMdFile.eof()) {
299 if (strstr(buffer,
"nMol") != NULL) {
300 if (i < nMol.size()) {
301 snprintf(buffer, MAXLEN,
"\tnMol = %i;", nMol.at(i));
302 newMdFile << buffer << std::endl;
306 newMdFile << buffer << std::endl;
308 oldMdFile.getline(buffer, MAXLEN);
314 if (i != nMol.size()) {
315 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
316 "Couldn't replace the correct number of nMol\n"
317 "\tstatements in component blocks.");
318 painCave.isFatal = 1;
AtomType is what OpenMD looks to for unchanging data about an atom.
int getNFrames()
Returns the number of frames in the dump file.
Vector3d getCom()
Returns the current center of mass position of this molecule.
void updateAtoms()
update the positions of atoms belong to this rigidbody
The only responsibility of SimCreator is to parse the meta-data file and create a SimInfo instance ba...
SimInfo * createSim(const std::string &mdFileName, bool loadInitCoords=true)
Setup Simulation.
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
Molecule * beginMolecule(MoleculeIterator &i)
Returns the first molecule in this SimInfo and intialize the iterator.
Molecule * nextMolecule(MoleculeIterator &i)
Returns the next avaliable Molecule based on the iterator.
SnapshotManager * getSnapshotManager()
Returns the snapshot manager.
StuntDouble * getIOIndexToIntegrableObject(int index)
return an integral objects by its global index.
The Snapshot class is a repository storing dynamic data during a Simulation.
Mat3x3d getHmat()
Returns the H-Matrix.
void setHmat(const Mat3x3d &m)
Sets the H-Matrix.
void setID(int id)
Sets the id of this Snapshot.
void wrapVector(Vector3d &v)
Wrapping the vector according to periodic boundary condition.
int getID()
Returns the id of this Snapshot.
Snapshot * getCurrentSnapshot()
Returns the pointer of current snapshot.
SquareMatrix3< Real > inverse() const
Sets the value of this matrix to the inverse of itself.
void setupRotMat(const Vector3< Real > &eulerAngles)
Sets this matrix to a rotation matrix by three euler angles @ param euler.
"Don't move, or you're dead! Stand up! Captain, we've got them!"
void setFlucQVel(RealType cvel)
Sets the current charge velocity of this stuntDouble.
RotMat3x3d getA()
Returns the current rotation matrix of this stuntDouble.
Vector3d getVel()
Returns the current velocity of this stuntDouble.
virtual void setA(const RotMat3x3d &a)
Sets the current rotation matrix of this stuntDouble.
void setFlucQPos(RealType charge)
Sets the current fluctuating charge of this stuntDouble.
Vector3d getPos()
Returns the current position of this stuntDouble.
RealType getFlucQPos()
Returns the current fluctuating charge of this stuntDouble.
void setPos(const Vector3d &pos)
Sets the current position of this stuntDouble.
void setVel(const Vector3d &vel)
Sets the current velocity of this stuntDouble.
Vector3d getJ()
Returns the current angular momentum of this stuntDouble (body -fixed).
bool isAtom()
Tests if this stuntDouble is an atom.
bool isDirectional()
Tests if this stuntDouble is a directional one.
void setJ(const Vector3d &angMom)
Sets the current angular momentum of this stuntDouble (body-fixed).
RealType getFlucQVel()
Returns the current charge velocity of this stuntDouble.
Real & z()
Returns reference of the third element of Vector3.
Real & x()
Returns reference of the first element of Vector3.
Real & y()
Returns reference of the second element of Vector3.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
The header file for the command line option parser generated by GNU Gengetopt version 2....
Where the command line options are stored.
double translateY_arg
translate all y coordinates by some amount (default='0.0').
int repeatY_arg
The number of images to repeat in the y direction (default='0').
unsigned int output_given
Whether output was given.
double translateZ_arg
translate all z coordinates by some amount (default='0.0').
int noCOM_flag
do not use Center of Mass as origin of the box (default=off).
int repeatX_arg
The number of images to repeat in the x direction (default='0').
double rotateTheta_arg
rotate all coordinates Euler angle Theta (default='0.0').
int repairMolecules_arg
rewrap molecules around the molecular center of mass (default='1').
char * output_arg
output file name.
char * input_arg
input dump file.
int repeatZ_arg
The number of images to repeat in the z direction (default='0').
int noWrap_flag
do not rewrap coordinates into the box (default=off).
double rotatePhi_arg
rotate all coordinates Euler angle Phi (default='0.0').
unsigned int input_given
Whether input was given.
double rotatePsi_arg
rotate all coordinates Euler angle Psi (default='0.0').
double translateX_arg
translate all x coordinates by some amount (default='0.0').