51 out <<
"Generates QM|MD topology" << endl;
77 {
"H", 1.20}, {
"C", 1.70}, {
"N", 1.55}, {
"O", 1.52},
78 {
"F", 1.47}, {
"P", 1.80}, {
"S", 1.80}, {
"Cl", 1.75},
127 "--guess-bonds was requested, but this topology already has real "
128 "bond connectivity of its own -- refusing to guess additional "
129 "bonds on top of real, existing ones, to avoid silently "
130 "double-counting or conflicting with them. This option is only "
131 "for topologies with genuinely NO real bond data at all.");
134 std::ofstream report(
"guessed_bonds_report.txt");
135 report <<
"# Bonds guessed from atom positions alone, via --guess-bonds\n"
136 <<
"# (a simple, van-der-Waals-radii-based heuristic, restricted "
137 "to atom pairs within the same real molecule) -- review this "
138 "report directly before trusting the guessed connectivity for "
140 <<
"# mol_id atom1_id atom1_name atom2_id atom2_name "
141 "distance[Ang] cutoff[Ang]\n";
167 double cutoff_ang = 0.6 * (it1->second + it2->second);
168 if (distance_ang < cutoff_ang) {
178 report <<
" " << mol.getId() <<
" " << bead1->
getId() <<
" "
181 << (boost::format(
"%1$.3f") % distance_ang).str() <<
" "
182 << (boost::format(
"%1$.3f") % cutoff_ang).str() <<
"\n";
190 cout <<
"\n--guess-bonds: guessed " << guessed_count
191 <<
" real bonds from atom positions alone (van-der-Waals-radii "
192 "heuristic, restricted to atom pairs within the same molecule) "
193 "-- see guessed_bonds_report.txt for the full, real, direct "
194 "list. Review this directly before trusting it for anything at "
199namespace propt = boost::program_options;
209 " coordinates or trajectory");
211 " definition of segments and fragments");
215 propt::value<votca::Index>()->default_value(0),
216 " start from this frame");
218 " start time in simulation");
220 propt::value<votca::Index>()->default_value(1),
221 " number of frames to process");
224 " guess real bond connectivity from atom positions alone (a simple, "
225 "van-der-Waals-radii-based heuristic, matching the one VMD itself "
226 "uses for visualization -- restricted to atom pairs within the same "
227 "real MD molecule only) -- ONLY if the loaded topology genuinely "
228 "has no real bond connectivity of its own at all; never used if "
229 "real bonds are already present. Writes a real, direct, inspectable "
230 "report of every guessed bond to guessed_bonds_report.txt -- always "
231 "review this before trusting the guessed connectivity for anything "
232 "at all, since this heuristic can be genuinely wrong (see VMD's own "
233 "developers' documented caveats about it).");
239 CheckRequired(
"segments",
"Missing segment definition file");
260 string topfile =
OptionsMap()[
"topology"].as<
string>();
261 std::unique_ptr<CSG::TopologyReader> topread =
264 if (topread ==
nullptr) {
265 throw runtime_error(
string(
"Input format not supported: ") +
269 topread->ReadTopology(topfile, mdtopol);
271 cout <<
"Read MD topology from " << topfile <<
": Found "
273 <<
" molecules. " << endl;
281 string trjfile =
OptionsMap()[
"coordinates"].as<
string>();
282 std::unique_ptr<CSG::TrajectoryReader> trjread =
285 if (trjread ==
nullptr) {
286 throw runtime_error(
string(
"Input format not supported: ") +
289 trjread->Open(trjfile);
290 trjread->FirstFrame(mdtopol);
296 string mapfile =
OptionsMap()[
"segments"].as<
string>();
300 <<
"xtp_map : map file '" << mapfile
301 <<
"' already in use. Delete the current mapfile or specify a "
307 cout <<
" Writing template mapfile to " << mapfile << std::endl;
312 std::map<std::string, const CSG::Molecule*> firstmolecule;
314 std::map<std::string, votca::Index> molecule_names;
316 if (!molecule_names.count(mol.getName())) {
317 firstmolecule[mol.getName()] = &mol;
319 molecule_names[mol.getName()]++;
321 for (
const auto& mol : molecule_names) {
322 std::cout <<
"Found " << mol.second <<
" with name " << mol.first
325 for (
const auto& mol : molecule_names) {
327 molecule.
add(
"mdname", mol.first);
330 segment.
add(
"name",
"UPTOYOU_BUTUNIQUE");
331 segment.
add(
"qmcoords_n",
"XYZFILE_GROUNDSTATE");
332 segment.
add(
"multipoles_n",
"MPSFILE_GROUNDSTATE");
333 segment.
add(
"map2md",
"WANTTOMAPTOMDGEOMETRY");
334 segment.
add(
"U_xX_nN_h",
"REORG1_hole");
335 segment.
add(
"U_nX_nN_h",
"REORG2_hole");
336 segment.
add(
"U_xN_xX_h",
"REORG3_hole");
339 std::string atomnames =
"";
341 std::vector<const CSG::Bead*> sortedbeads;
342 sortedbeads.reserve(csgmol->
BeadCount());
344 sortedbeads.push_back(bead);
346 std::sort(sortedbeads.begin(), sortedbeads.end(),
348 return b1->getId() < b2->getId();
351 for (
const CSG::Bead* bead : sortedbeads) {
352 atomnames +=
" " + std::to_string(bead->getResnr()) +
":" +
353 bead->getName() +
":" + std::to_string(bead->getId());
355 fragment.
add(
"name",
"UPTOYOU_BUTUNIQUE");
356 fragment.
add(
"mdatoms", atomnames);
357 fragment.
add(
"qmatoms",
"IDS of QMATOMS i.e 0:C 1:H 2:C");
358 fragment.
add(
"mpoles",
"IDS of MPOLES i.e 0:C 1:H 2:C");
359 fragment.
add(
"weights",
360 "weights for mapping(often atomic mass) i.e. 12 1 12");
361 fragment.
add(
"localframe",
"IDs of up to 3 qmatoms or mpoles i.e. 0 1 2");
362 std::ofstream template_mapfile(mapfile);
363 template_mapfile << mapfile_prop << std::flush;
364 template_mapfile.close();
366 std::cout <<
"MOLECULETYPE " << csgmol->
getName() << std::endl;
367 std::cout <<
"SAMPLECOORDINATES" << std::endl;
368 std::cout <<
"ID NAME COORDINATES[Angstroem] " << std::endl;
369 for (
const CSG::Bead* bead : sortedbeads) {
372 (boost::format(
"%1$i %2$s %3$+1.4f %4$+1.4f %5$+1.4f\n") %
373 bead->getId() % bead->getName() % pos[0] % pos[1] % pos[2])
378 std::cout << std::flush;
384 <<
"xtp_map : map file '" << mapfile <<
"' could not be found."
392 bool beginAt =
false;
393 double time =
OptionsMap()[
"begin"].as<
double>();
394 double startTime = mdtopol.
getTime();
404 for (hasFrame =
true; hasFrame ==
true;
405 hasFrame = trjread->NextFrame(mdtopol)) {
407 if (((mdtopol.
getTime() < startTime) && beginAt) || firstframecounter > 0) {
416 throw runtime_error(
"Time or frame number exceeds trajectory length");
419 cout <<
"Read MD trajectory from " << trjfile <<
": found " << frames_found
420 <<
" frames, starting from frame " << firstFrame << endl;
426 string statefile =
OptionsMap()[
"file"].as<
string>();
429 <<
"xtp_map : state file '" << statefile
430 <<
"' already in use. Delete the current statefile or specify a "
439 for (
votca::Index saved = 0; hasFrame && saved < nFrames;
440 hasFrame = trjread->NextFrame(mdtopol), saved++) {
441 if (mdtopol.
getStep() == laststep) {
460int main(
int argc,
char** argv) {
462 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.
std::string getElement() const noexcept
Returns the element type of the bead.
virtual const Eigen::Vector3d & getPos() const
std::string getName() const
Gets the name of the bead.
Index getId() const noexcept
Gets the id of the bead.
base class for all interactions
void setGroup(const std::string &group)
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
static void RegisterPlugins(void)
topology of the whole system
Index MoleculeCount() const
number of molecules in the system
void AddBondedInteraction(Interaction *ic)
Eigen::Vector3d BCShortestConnection(const Eigen::Vector3d &r_i, const Eigen::Vector3d &r_j) const
calculate shortest vector connecting two points
MoleculeContainer & Molecules()
InteractionContainer & BondedInteractions()
static void RegisterPlugins(void)
static void RegisterPlugins(void)
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)
void GuessBonds(CSG::Topology &top)
static const std::map< std::string, double > kBondiVdWRadiusAngstrom