50 out <<
"Generates QM|MD topology" << endl;
61namespace propt = boost::program_options;
65 CSG::TrajectoryWriter::RegisterPlugins();
66 CSG::TrajectoryReader::RegisterPlugins();
67 CSG::TopologyReader::RegisterPlugins();
71 " coordinates or trajectory");
73 " definition of segments and fragments");
77 propt::value<votca::Index>()->default_value(0),
78 " start from this frame");
80 " start time in simulation");
82 propt::value<votca::Index>()->default_value(1),
83 " number of frames to process");
110 string topfile =
OptionsMap()[
"topology"].as<
string>();
111 std::unique_ptr<CSG::TopologyReader> topread =
114 if (topread ==
nullptr) {
115 throw runtime_error(
string(
"Input format not supported: ") +
119 topread->ReadTopology(topfile, mdtopol);
121 cout <<
"Read MD topology from " << topfile <<
": Found "
123 <<
" molecules. " << endl;
131 string trjfile =
OptionsMap()[
"coordinates"].as<
string>();
132 std::unique_ptr<CSG::TrajectoryReader> trjread =
135 if (trjread ==
nullptr) {
136 throw runtime_error(
string(
"Input format not supported: ") +
139 trjread->Open(trjfile);
140 trjread->FirstFrame(mdtopol);
142 string mapfile =
OptionsMap()[
"segments"].as<
string>();
144 if (TOOLS::filesystem::FileExists(mapfile)) {
146 <<
"xtp_map : map file '" << mapfile
147 <<
"' already in use. Delete the current mapfile or specify a "
153 cout <<
" Writing template mapfile to " << mapfile << std::endl;
158 std::map<std::string, const CSG::Molecule*> firstmolecule;
160 std::map<std::string, votca::Index> molecule_names;
162 if (!molecule_names.count(mol.getName())) {
163 firstmolecule[mol.getName()] = &mol;
165 molecule_names[mol.getName()]++;
167 for (
const auto& mol : molecule_names) {
168 std::cout <<
"Found " << mol.second <<
" with name " << mol.first
171 for (
const auto& mol : molecule_names) {
173 molecule.
add(
"mdname", mol.first);
176 segment.
add(
"name",
"UPTOYOU_BUTUNIQUE");
177 segment.
add(
"qmcoords_n",
"XYZFILE_GROUNDSTATE");
178 segment.
add(
"multipoles_n",
"MPSFILE_GROUNDSTATE");
179 segment.
add(
"map2md",
"WANTTOMAPTOMDGEOMETRY");
180 segment.
add(
"U_xX_nN_h",
"REORG1_hole");
181 segment.
add(
"U_nX_nN_h",
"REORG2_hole");
182 segment.
add(
"U_xN_xX_h",
"REORG3_hole");
185 std::string atomnames =
"";
187 std::vector<const CSG::Bead*> sortedbeads;
188 sortedbeads.reserve(csgmol->
BeadCount());
190 sortedbeads.push_back(bead);
192 std::sort(sortedbeads.begin(), sortedbeads.end(),
194 return b1->getId() < b2->getId();
197 for (
const CSG::Bead* bead : sortedbeads) {
198 atomnames +=
" " + std::to_string(bead->getResnr()) +
":" +
199 bead->getName() +
":" + std::to_string(bead->getId());
201 fragment.
add(
"name",
"UPTOYOU_BUTUNIQUE");
202 fragment.
add(
"mdatoms", atomnames);
203 fragment.
add(
"qmatoms",
"IDS of QMATOMS i.e 0:C 1:H 2:C");
204 fragment.
add(
"mpoles",
"IDS of MPOLES i.e 0:C 1:H 2:C");
205 fragment.
add(
"weights",
206 "weights for mapping(often atomic mass) i.e. 12 1 12");
207 fragment.
add(
"localframe",
"IDs of up to 3 qmatoms or mpoles i.e. 0 1 2");
208 std::ofstream template_mapfile(mapfile);
209 template_mapfile << mapfile_prop << std::flush;
210 template_mapfile.close();
212 std::cout <<
"MOLECULETYPE " << csgmol->
getName() << std::endl;
213 std::cout <<
"SAMPLECOORDINATES" << std::endl;
214 std::cout <<
"ID NAME COORDINATES[Angstroem] " << std::endl;
215 for (
const CSG::Bead* bead : sortedbeads) {
218 (boost::format(
"%1$i %2$s %3$+1.4f %4$+1.4f %5$+1.4f\n") %
219 bead->getId() % bead->getName() % pos[0] % pos[1] % pos[2])
224 std::cout << std::flush;
228 if (!TOOLS::filesystem::FileExists(mapfile)) {
230 <<
"xtp_map : map file '" << mapfile <<
"' could not be found."
238 bool beginAt =
false;
239 double time =
OptionsMap()[
"begin"].as<
double>();
240 double startTime = mdtopol.
getTime();
250 for (hasFrame =
true; hasFrame ==
true;
251 hasFrame = trjread->NextFrame(mdtopol)) {
253 if (((mdtopol.
getTime() < startTime) && beginAt) || firstframecounter > 0) {
262 throw runtime_error(
"Time or frame number exceeds trajectory length");
265 cout <<
"Read MD trajectory from " << trjfile <<
": found " << frames_found
266 <<
" frames, starting from frame " << firstFrame << endl;
272 string statefile =
OptionsMap()[
"file"].as<
string>();
273 if (TOOLS::filesystem::FileExists(statefile)) {
275 <<
"xtp_map : state file '" << statefile
276 <<
"' already in use. Delete the current statefile or specify a "
285 for (
votca::Index saved = 0; hasFrame && saved < nFrames;
286 hasFrame = trjread->NextFrame(mdtopol), saved++) {
287 if (mdtopol.
getStep() == laststep) {
306int main(
int argc,
char** argv) {
308 return xtpmap.
Exec(argc, argv);
void Run() override
Main body of application.
string ProgramName() override
program name
void ShowHelpText(std::ostream &out) override
void HelpText(ostream &out) override
help text of application without version information
void Initialize() override
Initialize application data.
bool EvaluateOptions() override
Process command line options.
information about molecules
const std::string & getName() const
get the name of the molecule
Index BeadCount() const
get the number of beads in the molecule
const std::vector< Bead * > & Beads() const
topology of the whole system
Index MoleculeCount() const
number of molecules in the system
MoleculeContainer & Molecules()
Topology map(const csg::Topology &top) const
void WriteFrame(const Topology &top)
Container for segments and box and atoms.
FileFormatFactory< TopologyReader > & TopReaderFactory()
FileFormatFactory< TrajectoryReader > & TrjReaderFactory()
Charge transport classes.
void HelpTextHeader(const std::string &tool_name)
int main(int argc, char **argv)