51 out <<
"Generates QM|MD topology" << endl;
68 {
"H", 1.20}, {
"C", 1.70}, {
"N", 1.55}, {
"O", 1.52},
69 {
"F", 1.47}, {
"P", 1.80}, {
"S", 1.80}, {
"Cl", 1.75},
87 "--guess-bonds was requested, but the topology already contains "
88 "bonds. Guessing additional bonds could duplicate or conflict with "
89 "them; --guess-bonds is only allowed for topologies without bonds.");
92 std::ofstream report(
"guessed_bonds_report.txt");
93 report <<
"# Bonds guessed from atom positions alone, via --guess-bonds\n"
94 <<
"# (van der Waals radii heuristic, restricted to atom pairs "
95 "within the same molecule). Review before using the guessed "
97 <<
"# mol_id atom1_id atom1_name atom2_id atom2_name "
98 "distance[Ang] cutoff[Ang]\n";
120 double cutoff_ang = 0.6 * (it1->second + it2->second);
121 if (distance_ang < cutoff_ang) {
128 report <<
" " << mol.getId() <<
" " << bead1->
getId() <<
" "
131 << (boost::format(
"%1$.3f") % distance_ang).str() <<
" "
132 << (boost::format(
"%1$.3f") % cutoff_ang).str() <<
"\n";
140 cout <<
"\n--guess-bonds: guessed " << guessed_count
141 <<
" bonds from atom positions (van der Waals radii heuristic, "
142 "restricted to atom pairs within the same molecule). Review "
143 "guessed_bonds_report.txt before using them."
147namespace propt = boost::program_options;
157 " coordinates or trajectory");
159 " definition of segments and fragments");
163 propt::value<votca::Index>()->default_value(0),
164 " start from this frame");
166 " start time in simulation");
168 propt::value<votca::Index>()->default_value(1),
169 " number of frames to process");
172 " guess bond connectivity from atom positions for topologies "
173 "without bonds, using VMD's van der Waals radii heuristic restricted "
174 "to atom pairs within the same MD molecule. Fails if the topology "
175 "already contains bonds. All guessed bonds are written to "
176 "guessed_bonds_report.txt; review them, the heuristic can produce "
183 CheckRequired(
"segments",
"Missing segment definition file");
204 string topfile =
OptionsMap()[
"topology"].as<
string>();
205 std::unique_ptr<CSG::TopologyReader> topread =
208 if (topread ==
nullptr) {
209 throw runtime_error(
string(
"Input format not supported: ") +
213 topread->ReadTopology(topfile, mdtopol);
215 cout <<
"Read MD topology from " << topfile <<
": Found "
217 <<
" molecules. " << endl;
225 string trjfile =
OptionsMap()[
"coordinates"].as<
string>();
226 std::unique_ptr<CSG::TrajectoryReader> trjread =
229 if (trjread ==
nullptr) {
230 throw runtime_error(
string(
"Input format not supported: ") +
233 trjread->Open(trjfile);
234 trjread->FirstFrame(mdtopol);
240 string mapfile =
OptionsMap()[
"segments"].as<
string>();
244 <<
"xtp_map : map file '" << mapfile
245 <<
"' already in use. Delete the current mapfile or specify a "
251 cout <<
" Writing template mapfile to " << mapfile << std::endl;
256 std::map<std::string, const CSG::Molecule*> firstmolecule;
258 std::map<std::string, votca::Index> molecule_names;
260 if (!molecule_names.count(mol.getName())) {
261 firstmolecule[mol.getName()] = &mol;
263 molecule_names[mol.getName()]++;
265 for (
const auto& mol : molecule_names) {
266 std::cout <<
"Found " << mol.second <<
" with name " << mol.first
269 for (
const auto& mol : molecule_names) {
271 molecule.
add(
"mdname", mol.first);
274 segment.
add(
"name",
"UPTOYOU_BUTUNIQUE");
275 segment.
add(
"qmcoords_n",
"XYZFILE_GROUNDSTATE");
276 segment.
add(
"multipoles_n",
"MPSFILE_GROUNDSTATE");
277 segment.
add(
"map2md",
"WANTTOMAPTOMDGEOMETRY");
278 segment.
add(
"U_xX_nN_h",
"REORG1_hole");
279 segment.
add(
"U_nX_nN_h",
"REORG2_hole");
280 segment.
add(
"U_xN_xX_h",
"REORG3_hole");
283 std::string atomnames =
"";
285 std::vector<const CSG::Bead*> sortedbeads;
286 sortedbeads.reserve(csgmol->
BeadCount());
288 sortedbeads.push_back(bead);
290 std::sort(sortedbeads.begin(), sortedbeads.end(),
292 return b1->getId() < b2->getId();
295 for (
const CSG::Bead* bead : sortedbeads) {
296 atomnames +=
" " + std::to_string(bead->getResnr()) +
":" +
297 bead->getName() +
":" + std::to_string(bead->getId());
299 fragment.
add(
"name",
"UPTOYOU_BUTUNIQUE");
300 fragment.
add(
"mdatoms", atomnames);
301 fragment.
add(
"qmatoms",
"IDS of QMATOMS i.e 0:C 1:H 2:C");
302 fragment.
add(
"mpoles",
"IDS of MPOLES i.e 0:C 1:H 2:C");
303 fragment.
add(
"weights",
304 "weights for mapping(often atomic mass) i.e. 12 1 12");
305 fragment.
add(
"localframe",
"IDs of up to 3 qmatoms or mpoles i.e. 0 1 2");
306 std::ofstream template_mapfile(mapfile);
307 template_mapfile << mapfile_prop << std::flush;
308 template_mapfile.close();
310 std::cout <<
"MOLECULETYPE " << csgmol->
getName() << std::endl;
311 std::cout <<
"SAMPLECOORDINATES" << std::endl;
312 std::cout <<
"ID NAME COORDINATES[Angstroem] " << std::endl;
313 for (
const CSG::Bead* bead : sortedbeads) {
316 (boost::format(
"%1$i %2$s %3$+1.4f %4$+1.4f %5$+1.4f\n") %
317 bead->getId() % bead->getName() % pos[0] % pos[1] % pos[2])
322 std::cout << std::flush;
328 <<
"xtp_map : map file '" << mapfile <<
"' could not be found."
336 bool beginAt =
false;
337 double time =
OptionsMap()[
"begin"].as<
double>();
338 double startTime = mdtopol.
getTime();
348 for (hasFrame =
true; hasFrame ==
true;
349 hasFrame = trjread->NextFrame(mdtopol)) {
351 if (((mdtopol.
getTime() < startTime) && beginAt) || firstframecounter > 0) {
360 throw runtime_error(
"Time or frame number exceeds trajectory length");
363 cout <<
"Read MD trajectory from " << trjfile <<
": found " << frames_found
364 <<
" frames, starting from frame " << firstFrame << endl;
370 string statefile =
OptionsMap()[
"file"].as<
string>();
373 <<
"xtp_map : state file '" << statefile
374 <<
"' already in use. Delete the current statefile or specify a "
383 for (
votca::Index saved = 0; hasFrame && saved < nFrames;
384 hasFrame = trjread->NextFrame(mdtopol), saved++) {
385 if (mdtopol.
getStep() == laststep) {
404int main(
int argc,
char** argv) {
406 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