53#include "io/DumpWriter.hpp"
54#include "utils/MoLocator.hpp"
59void createMdFile(
const std::string& oldMdFileName,
60 const std::string& newMdFileName,
int nMol) {
63 const int MAXLEN = 65535;
67 oldMdFile.open(oldMdFileName.c_str());
68 newMdFile.open(newMdFileName.c_str());
69 oldMdFile.getline(buffer, MAXLEN);
71 while (!oldMdFile.eof()) {
73 if (strstr(buffer,
"nMol") != NULL) {
74 snprintf(buffer, MAXLEN,
"\tnMol = %i;", nMol);
75 newMdFile << buffer << std::endl;
77 newMdFile << buffer << std::endl;
80 oldMdFile.getline(buffer, MAXLEN);
87int main(
int argc,
char* argv[]) {
89 std::string inputFileName;
90 std::string outputFileName;
93 RealType latticeConstant(0.0);
99 if (cmdline_parser(argc, argv, &args_info) != 0) exit(1);
103 inputFileName = args_info.
inputs[0];
105 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
106 "No input .omd file name was specified "
107 "on the command line");
108 painCave.isFatal = 1;
109 cmdline_parser_print_help();
117 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
118 "icosahedralBuilder: The number of shells\n"
119 "\tmust be greater than or equal to zero.");
120 painCave.isFatal = 1;
121 cmdline_parser_print_help();
125 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
126 "icosahedralBuilder: The number of shells\n"
127 "\tis required to build a Mackay Icosahedron.");
128 painCave.isFatal = 1;
129 cmdline_parser_print_help();
136 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
137 "icosahedralBuilder: No lattice constant\n"
139 painCave.isFatal = 1;
140 cmdline_parser_print_help();
148 vector<Vector3d> Points;
169 columnAtoms, nShells, twinAtoms, truncatedPlanes);
177 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
178 "icosahedralBuilder: No lattice type given.");
179 painCave.isFatal = 1;
180 cmdline_parser_print_help();
186 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
187 "icosahedralBuilder: Must specify unit cells.");
188 painCave.isFatal = 1;
189 cmdline_parser_print_help();
208 createMdFile(inputFileName, outputFileName, Points.size());
217 SimInfo::MoleculeIterator mi;
228 for (
unsigned int n = 0; n < Points.size(); n++) {
234 location = Points[n] * latticeConstant;
238 location = Points[n] * latticeConstant / sqrt(2.0);
246 for (
int i = 0; i < 3; i++) {
247 boxMax[i] = max(boxMax[i], location[i]);
248 boxMin[i] = min(boxMin[i], location[i]);
252 locator->placeMol(location, orientation, mol);
257 boundingBox(0, 0) = 10.0 * (boxMax[0] - boxMin[0]);
258 boundingBox(1, 1) = 10.0 * (boxMax[1] - boxMin[1]);
259 boundingBox(2, 2) = 10.0 * (boxMax[2] - boxMin[2]);
265 writer =
new DumpWriter(NewInfo, outputFileName);
267 if (writer == NULL) {
268 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
269 "Error in creating dumpwriter object ");
270 painCave.isFatal = 1;
281 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
282 "A new OpenMD file called \"%s\" has been "
284 outputFileName.c_str());
285 painCave.isFatal = 0;
286 painCave.severity = OPENMD_INFO;
Cuboctahedron cluster structure generator.
Decahedron cluster structure generator.
Icosahedron cluster structure generator.
virtual vector< Vector3d > getPoints()
Get the generated points in the cluster.
vector< Vector3d > getPoints()
Get the generated points in the cluster.
Creates the regular decahedron, Ino decahedron, or truncated (Marks) decahedron structures (depending...
virtual vector< Vector3d > getPoints()
Get the generated points in the cluster.
Create the Mackay icosahedron structure.
std::vector< Vector3d > getPoints(int nShells)
Get the generated points in an icosahedron with nShells shells.
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 * getMoleculeByGlobalIndex(int index)
Finds a molecule with a specified global index.
ForceField * getForceField()
Returns the force field.
Molecule * beginMolecule(MoleculeIterator &i)
Returns the first molecule in this SimInfo and intialize the iterator.
MoleculeStamp * getMoleculeStamp(int id)
Returns the molecule stamp.
SnapshotManager * getSnapshotManager()
Returns the snapshot manager.
void setHmat(const Mat3x3d &m)
Sets the H-Matrix.
Snapshot * getCurrentSnapshot()
Returns the pointer of current snapshot.
The header file for the command line option parser generated by GNU Gengetopt version 2....
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
Where the command line options are stored.
unsigned int ico_given
Whether ico was given.
unsigned int latticeConstant_given
Whether latticeConstant was given.
int unitCells_arg
Number of unit cell (Cuboctahedron and Truncated Cube only).
int shells_arg
Nanoparticle shells.
unsigned inputs_num
unamed options number
unsigned int marks_given
Whether marks was given.
unsigned int ino_given
Whether ino was given.
unsigned int cuboctahedron_given
Whether cuboctahedron was given.
unsigned int stone_given
Whether stone was given.
unsigned int lattice_given
Whether lattice was given.
unsigned int shells_given
Whether shells was given.
int columnAtoms_arg
Number of atoms along central column (Decahedron only).
char * output_arg
output file name.
char ** inputs
unamed options (options without names)
unsigned int deca_given
Whether deca was given.
int truncatedPlanes_arg
Number of truncated planes (Curling-stone Decahedra and Truncated Cubes only).
int twinAtoms_arg
Number of atoms along twin boundary (Decahedron only).
unsigned int truncatedCube_given
Whether truncatedCube was given.
double latticeConstant_arg
Lattice spacing in Angstroms for cubic lattice.
unsigned int unitCells_given
Whether unitCells was given.
char * lattice_arg
Lattice Type.