#include <colvarmodule.h>
Public Types | |
| typedef double | real |
| Defining an abstract real number allows to switch precision. | |
| typedef int | residue_id |
| Residue identifier. | |
| typedef int | atom_id |
| Atom identifier (may not be an int in the future to handle implicit parallelization). | |
| typedef rvector | atom_pos |
| Atom position (different type name from rvector, to make possible future PBC-transparent implementations). | |
| typedef std::vector< atom >::iterator | atom_iter |
| typedef std::vector< atom >::const_iterator | atom_const_iter |
Public Member Functions | |
| colvarmodule (char const *config_name, colvarproxy *proxy_in) | |
| Constructor. | |
| ~colvarmodule () | |
| Destructor. | |
| void | init_colvars (std::string const &conf) |
| Initialize collective variables. | |
| void | init_biases (std::string const &conf) |
| Initialize collective variable biases. | |
| void | calc () |
| Calculate collective variables and biases. | |
| std::istream & | read_restart (std::istream &is) |
| Read the input restart file. | |
| std::ostream & | write_restart (std::ostream &os) |
| Write the output restart file. | |
| void | finalise () |
| Deallocate memory and close files. | |
| void | analyse () |
| Perform analysis. | |
| bool | read_traj (char const *cv_traj_filename) |
| Read a collective variable trajectory for analysis. | |
Static Public Member Functions | |
| size_t | step_relative () |
| Return the current step number from the beginning of this run. | |
| size_t | step_absolute () |
| bool | debug () |
| Whether debug output should be enabled (compile-time option). | |
| colvar * | colvar_p (std::string const &name) |
| Get the pointer of a colvar from its name (returns NULL if not found). | |
| template<typename T> | |
| std::string | to_str (T const &x, size_t const &width=0, size_t const &prec=0) |
| Quick conversion of an object to a string. | |
| template<typename T> | |
| std::string | to_str (std::vector< T > const &x, size_t const &width=0, size_t const &prec=0) |
| Quick conversion of a vector of objects to a string. | |
| std::string | wrap_string (std::string const &s, size_t const &nchars) |
| Reduce the number of characters in a string. | |
| real | unit_angstrom () |
| Value of the unit for atomic coordinates with respect to angstroms (used by some variables for hard-coded default values). | |
| real | boltzmann () |
| Boltmann constant. | |
| real | temperature () |
| Temperature of the simulation (K). | |
| void | log (std::string const &message) |
| Print a message to the main log. | |
| void | fatal_error (std::string const &message) |
| Print a message to the main log and exit with error code. | |
| void | exit (std::string const &message) |
| Print a message to the main log and exit normally. | |
| rvector | position_distance (atom_pos const &pos1, atom_pos const &pos2) |
| Get the distance between two atomic positions with pbcs handled correctly. | |
| real | position_dist2 (atom_pos const &pos1, atom_pos const &pos2) |
| Get the square distance between two positions (with periodic boundary conditions handled transparently). | |
| void | select_closest_image (atom_pos &pos, atom_pos const &ref_pos) |
| Get the closest periodic image to a reference position. | |
| void | select_closest_images (std::vector< atom_pos > &pos, atom_pos const &ref_pos) |
| Perform select_closest_image() on a set of atomic positions. | |
| void | load_atoms (char const *filename, std::vector< atom > &atoms, std::string const &pdb_field="O", double const pdb_field_value=0.0) |
| Create atoms from a file. | |
| void | load_coords (char const *filename, std::vector< atom_pos > &pos, std::string const &pdb_field="O", double const pdb_field_value=0.0) |
| Load the coordinates for a group of atoms from a file (usually a PDB); the number of atoms in "filename" must match the number of elements in "pos". | |
| void | increase_depth () |
| Increase the depth (number of indentations in the output). | |
| void | decrease_depth () |
| Decrease the depth (number of indentations in the output). | |
Public Attributes | |
| std::string | cv_traj_read_name |
| Trajectory file name to analyze. | |
| size_t | cv_traj_read_begin |
| Step numbers to analyse in the trajectory. | |
| size_t | cv_traj_read_end |
| Step numbers to analyse in the trajectory. | |
| std::string | restart_out_name |
| Output restart file name. | |
Static Public Attributes | |
| size_t | it = 0 |
| Current step number. | |
| size_t | it_restart = 0 |
| Starting step number for this run. | |
| real | dt = 1.0 |
| Time step of the MD integrator. | |
| real | debug_gradients_step_size = 1.0e-03 |
| Finite difference step size (if there is no dynamics, or if gradients need to be tested independently from the size of dt). | |
| std::string | output_prefix = "" |
| Prefix for all output files for this run. | |
| std::string | input_prefix = "" |
| Prefix for files from a previous run (including restart/output). | |
| std::string | restart_in_name = "" |
| input restart file name (determined from input_prefix) | |
| std::vector< colvar * > | colvars |
| Collective variables array. | |
| std::vector< colvarbias * > | biases |
| Collective variable biases array. | |
| size_t | n_abf_biases = 0 |
| Number of ABF biases initialized (in normal conditions should be 1). | |
| size_t | n_meta_biases = 0 |
| Number of metadynamics biases initialized (in normal conditions should be 1). | |
| size_t | n_harm_biases = 0 |
| Number of harmonic biases initialized (no limit on the number). | |
| size_t | n_histo_biases = 0 |
| Number of histograms initialized (no limit on the number). | |
| size_t const | it_width = 12 |
| Number of characters to represent a time step. | |
| size_t const | cv_prec = 14 |
| Number of digits to represent a collective variables value(s). | |
| size_t const | cv_width = 21 |
| Number of characters to represent a collective variables value(s). | |
| size_t const | en_prec = 14 |
| Number of digits to represent the collective variables energy. | |
| size_t const | en_width = 21 |
| Number of characters to represent the collective variables energy. | |
| std::string const | line_marker |
| Line separator in the log output. | |
| size_t | cv_traj_freq = 0 |
| Frequency for collective variables trajectory output. | |
| bool | b_analysis = false |
| True if only analysis is performed and not a run. | |
| size_t | restart_out_freq = 0 |
| Frequency for saving output restarts. | |
Protected Attributes | |
| std::ifstream | config_s |
| Configuration file. | |
| colvarparse * | parse |
| Configuration file parser object. | |
| std::ofstream | cv_traj_os |
| Collective variables output trajectory file. | |
| std::ofstream | restart_out_os |
| Output restart file. | |
Static Protected Attributes | |
| colvarproxy * | proxy = NULL |
| Pointer to the proxy object, used to retrieve atomic data from the hosting program; it is static in order to be accessible from static functions in the colvarmodule class. | |
| size_t | depth = 0 |
| Counter for the current depth in the object hierarchy (useg e.g. in outpu. | |
Friends | |
| class | colvarproxy |
| class | atom |
| class | atom_group |
Class to control the collective variables calculation. An object (usually one) of this class is spawned from the MD program, containing all i/o routines and general interface.
At initialization, the colvarmodule object creates a proxy object to provide a transparent interface between the MD program and the child objects
Definition at line 47 of file colvarmodule.h.
|
|
Definition at line 89 of file colvarmodule.h. |
|
|
Atom identifier (may not be an int in the future to handle implicit parallelization).
Definition at line 65 of file colvarmodule.h. |
|
|
Definition at line 88 of file colvarmodule.h. |
|
|
Atom position (different type name from rvector, to make possible future PBC-transparent implementations).
Definition at line 78 of file colvarmodule.h. Referenced by colvar::eigenvector::calc_Jacobian_derivative(), colvar::logmsd::calc_Jacobian_derivative(), colvar::rmsd::calc_Jacobian_derivative(), colvar::dihedral::calc_value(), colvar::angle::calc_value(), colvarmodule::atom_group::center_of_geometry(), colvarmodule::atom_group::center_of_mass(), colvarproxy_namd::load_coords(), colvarmodule::atom_group::parse(), colvarproxy_namd::position_dist2(), position_dist2(), colvarproxy_namd::position_distance(), position_distance(), colvarmodule::atom_group::read_positions(), colvarmodule::atom::reset_data(), colvarproxy_namd::select_closest_image(), select_closest_image(), colvarproxy::select_closest_images(), and select_closest_images(). |
|
|
|
Residue identifier.
Definition at line 61 of file colvarmodule.h. |
|
||||||||||||
|
Constructor.
Definition at line 10 of file colvarmodule.C. References b_analysis, colvarproxy::backup_file(), colvarparse::check_keywords(), COLVARS_VERSION, config_s, cv_traj_freq, cv_traj_os, cv_traj_read_begin, cv_traj_read_end, cv_traj_read_name, debug(), debug_gradients_step_size, dt, fatal_error(), colvarparse::getline_nocomments(), init_biases(), init_colvars(), colvarproxy::input_prefix(), it, it_restart, log(), colvarproxy::output_prefix(), output_prefix, parse, proxy, read_restart(), colvarproxy::restart_frequency(), restart_in_name, restart_out_freq, restart_out_name, and colvarproxy::restart_output_prefix(). 00012 {
00013 // pointer to the proxy object
00014 if (proxy == NULL) {
00015 proxy = proxy_in;
00016 parse = new colvarparse();
00017 } else {
00018 cvm::fatal_error ("Error: trying to allocate twice the collective "
00019 "variable module.\n");
00020 }
00021
00022 cvm::log (cvm::line_marker);
00023 cvm::log ("Initializing the collective variables module, version "+
00024 cvm::to_str(COLVARS_VERSION)+".\n");
00025
00026 #if (defined (COLVARS_STANDALONE) || defined (COLVARS_GMXTOOLS))
00027 cvm::log ("Note: this version is not linked to a MD simulation program, "
00028 "and can only be used to analyse data.\n");
00029 #endif
00030
00031 // "it_restart" will be set by the input restart file, if any;
00032 // "it" should be updated by the proxy
00033 it = it_restart = 0;
00034
00035 // open the configfile
00036 config_s.open (config_filename);
00037 if (!config_s)
00038 cvm::fatal_error ("Error: in opening configuration file \""+
00039 std::string (config_filename)+"\".\n");
00040
00041 // read the config file into a string
00042 std::string conf = "";
00043 {
00044 std::string line;
00045 while (colvarparse::getline_nocomments (config_s, line))
00046 conf.append (line+"\n");
00047 // don't need the stream any more
00048 config_s.close();
00049 }
00050
00051 parse->get_keyval (conf, "analysis", b_analysis, false);
00052
00053 #if defined (COLVARS_STANDALONE)
00054 parse->get_keyval (conf, "timeStep", dt, 1.0);
00055 #endif
00056
00057 if (cvm::debug())
00058 parse->get_keyval (conf, "debugGradientsStepSize", debug_gradients_step_size, 1.0e-03,
00059 colvarparse::parse_silent);
00060
00061 parse->get_keyval (conf, "eigenvalueCrossingThreshold",
00062 colvarmodule::rotation::crossing_threshold, 1.0e-04,
00063 colvarparse::parse_silent);
00064
00065 parse->get_keyval (conf, "colvarsTrajFrequency", cv_traj_freq, 100);
00066 parse->get_keyval (conf, "colvarsRestartFrequency", restart_out_freq,
00067 proxy->restart_frequency());
00068
00069 // by default overwrite the existing trajectory file
00070 bool cv_traj_append;
00071 parse->get_keyval (conf, "colvarsTrajAppend", cv_traj_append, false,
00072 colvarparse::parse_silent);
00073
00074 // input restart file
00075 restart_in_name = proxy->input_prefix().size() ?
00076 std::string (proxy->input_prefix()+".colvars.state") :
00077 std::string ("") ;
00078
00079 // output restart file
00080 restart_out_name = proxy->restart_output_prefix().size() ?
00081 std::string (proxy->restart_output_prefix()+".colvars.state") :
00082 std::string ("");
00083
00084 if (restart_out_name.size())
00085 cvm::log ("The restart output state file will be \""+restart_out_name+"\".\n");
00086
00087 output_prefix = proxy->output_prefix();
00088
00089 std::string const cv_traj_name =
00090 (output_prefix.size() ?
00091 std::string (output_prefix+".colvars.traj") :
00092 std::string ("colvars.traj"));
00093 cvm::log ("The trajectory file will be \""+
00094 cv_traj_name+"\".\n");
00095
00096 cvm::log ("The final output state file will be \""+
00097 (output_prefix.size() ?
00098 std::string (output_prefix+".colvars.state") :
00099 std::string ("colvars.state"))+"\".\n");
00100
00101 // parse the options for collective variables
00102 init_colvars (conf);
00103
00104 // parse the options for biases
00105 init_biases (conf);
00106
00107 #if defined (COLVARS_STANDALONE)
00108 if (b_analysis) {
00109 // parse the analysis options (if provided); this should stay after
00110 // the initialization of the colvars and biases
00111 cvm::log (cvm::line_marker);
00112 // read the colvar trajectory from a file
00113 parse->get_keyval (conf, "readTrajectory",
00114 cv_traj_read_name);
00115 parse->get_keyval (conf, "readBegin",
00116 cv_traj_read_begin, 0);
00117 parse->get_keyval (conf, "readEnd",
00118 cv_traj_read_end, 0);
00119 }
00120 #endif
00121
00122 // done with the parsing, check that all keywords are valid
00123 parse->check_keywords (conf, "colvarmodule");
00124 cvm::log (cvm::line_marker);
00125
00126 // read the restart configuration, if available
00127 if (restart_in_name.size()) {
00128 // read the restart file
00129 std::ifstream input_is (restart_in_name.c_str());
00130 if (!input_is.good())
00131 fatal_error ("Error: in opening restart file \""+
00132 std::string (restart_in_name)+"\".\n");
00133 else {
00134 cvm::log ("Restarting from file \""+restart_in_name+"\".\n");
00135 read_restart (input_is);
00136 cvm::log (cvm::line_marker);
00137 }
00138 }
00139
00140
00141 #if (!defined (COLVARS_STANDALONE) && !defined (COLVARS_GMXTOOLS))
00142 // check if it is possible to save output configuration
00143 if ((!output_prefix.size()) && (!restart_out_name.size())) {
00144 cvm::fatal_error ("Error: neither the final output state file or "
00145 "the output restart file could be defined, exiting.\n");
00146 }
00147 #endif
00148
00149 // open trajectory files
00150 if (cv_traj_freq && !cvm::b_analysis) {
00151
00152 if (cvm::debug())
00153 cvm::log ("Opening output file \""+cv_traj_name+"\".\n");
00154
00155 if (cv_traj_append) {
00156 cv_traj_os.open (cv_traj_name.c_str(), std::ios::app);
00157 } else {
00158 proxy->backup_file (cv_traj_name.c_str());
00159 cv_traj_os.open (cv_traj_name.c_str(), std::ios::out);
00160 }
00161 cv_traj_os.setf (std::ios::scientific, std::ios::floatfield);
00162 }
00163
00164 cvm::log ("Collective variables module initialized.\n");
00165 cvm::log (cvm::line_marker);
00166 }
|
|
|
Destructor.
Definition at line 516 of file colvarmodule.C. References finalise(). 00517 {
00518 delete parse;
00519 finalise();
00520 }
|
|
|
Perform analysis.
Definition at line 486 of file colvarmodule.C. References biases, colvars, debug(), decrease_depth(), increase_depth(), it, log(), and step_relative(). 00487 {
00488 if (cvm::debug()) {
00489 cvm::log ("colvarmodule::analyse(), step = "+cvm::to_str (it)+".\n");
00490 }
00491
00492 if (cvm::step_relative() == 0)
00493 cvm::log ("Performing analysis.\n");
00494
00495 // perform colvar-specific analysis
00496 for (std::vector<colvar *>::iterator cvi = colvars.begin();
00497 cvi != colvars.end();
00498 cvi++) {
00499 cvm::increase_depth();
00500 (*cvi)->analyse();
00501 cvm::decrease_depth();
00502 }
00503
00504 // perform bias-specific analysis
00505 for (std::vector<colvarbias *>::iterator bi = biases.begin();
00506 bi != biases.end();
00507 bi++) {
00508 cvm::increase_depth();
00509 (*bi)->analyse();
00510 cvm::decrease_depth();
00511 }
00512
00513 }
|
|
|
Boltmann constant.
Definition at line 387 of file colvarmodule.h. References colvarproxy::boltzmann(), and proxy. Referenced by colvar::update().
|
|
|
Calculate collective variables and biases.
Definition at line 329 of file colvarmodule.C. References colvarproxy::backup_file(), biases, colvars, cv_traj_freq, cv_traj_os, debug(), decrease_depth(), fatal_error(), increase_depth(), it, log(), proxy, restart_out_freq, restart_out_name, restart_out_os, step_relative(), wrap_string(), and write_restart(). Referenced by colvarproxy_namd::calculate(). 00329 {
00330
00331 if (cvm::debug()) {
00332 cvm::log (cvm::line_marker);
00333 cvm::log ("Collective variables module, step no. "+
00334 cvm::to_str (cvm::step_relative())+"\n");
00335 }
00336
00337 // calculate collective variables and their gradients
00338 if (cvm::debug())
00339 cvm::log ("Calculating collective variables.\n");
00340 cvm::increase_depth();
00341 for (std::vector<colvar *>::iterator cvi = colvars.begin();
00342 cvi != colvars.end();
00343 cvi++) {
00344 (*cvi)->calc();
00345 }
00346 cvm::decrease_depth();
00347
00348 // update the biases and communicate their forces to the collective
00349 // variables
00350 if (cvm::debug() && biases.size())
00351 cvm::log ("Updating collective variable biases.\n");
00352 cvm::increase_depth();
00353 for (std::vector<colvarbias *>::iterator bi = biases.begin();
00354 bi != biases.end();
00355 bi++) {
00356 (*bi)->update();
00357 }
00358 cvm::decrease_depth();
00359
00360 // sum the forces from all biases for each collective variable
00361 if (cvm::debug() && biases.size())
00362 cvm::log ("Collecting forces from all biases.\n");
00363 cvm::increase_depth();
00364 for (std::vector<colvar *>::iterator cvi = colvars.begin();
00365 cvi != colvars.end();
00366 cvi++) {
00367 (*cvi)->reset_bias_force();
00368 }
00369 for (std::vector<colvarbias *>::iterator bi = biases.begin();
00370 bi != biases.end();
00371 bi++) {
00372 (*bi)->communicate_forces();
00373 }
00374 cvm::decrease_depth();
00375
00376 if (cvm::b_analysis) {
00377 // perform runtime analysis of colvars and biases
00378 if (cvm::debug() && biases.size())
00379 cvm::log ("Perform runtime analyses.\n");
00380 cvm::increase_depth();
00381 for (std::vector<colvar *>::iterator cvi = colvars.begin();
00382 cvi != colvars.end();
00383 cvi++) {
00384 (*cvi)->analyse();
00385 }
00386 for (std::vector<colvarbias *>::iterator bi = biases.begin();
00387 bi != biases.end();
00388 bi++) {
00389 (*bi)->analyse();
00390 }
00391 cvm::decrease_depth();
00392 }
00393
00394 // sum up the forces for each colvar and integrate any internal
00395 // equation of motion
00396 if (cvm::debug())
00397 cvm::log ("Updating the internal degrees of freedom "
00398 "of colvars (if they have any).\n");
00399 cvm::increase_depth();
00400 for (std::vector<colvar *>::iterator cvi = colvars.begin();
00401 cvi != colvars.end();
00402 cvi++) {
00403 (*cvi)->update();
00404 }
00405 cvm::decrease_depth();
00406
00407 // make collective variables communicate their forces to their
00408 // coupled degrees of freedom (i.e. atoms)
00409 if (cvm::debug())
00410 cvm::log ("Communicating forces from the colvars to the atoms.\n");
00411 cvm::increase_depth();
00412 for (std::vector<colvar *>::iterator cvi = colvars.begin();
00413 cvi != colvars.end();
00414 cvi++) {
00415 if ((*cvi)->tasks[colvar::task_gradients])
00416 (*cvi)->communicate_forces();
00417 }
00418 cvm::decrease_depth();
00419
00420 // write restart file, if needed
00421 if (restart_out_freq && !cvm::b_analysis) {
00422 if ( (cvm::step_relative() > 0) &&
00423 ((cvm::step_relative() % restart_out_freq) == 0) ) {
00424 cvm::log ("Writing the current state to the restart file.\n");
00425 proxy->backup_file (restart_out_name.c_str());
00426 restart_out_os.open (restart_out_name.c_str());
00427 restart_out_os.setf (std::ios::scientific, std::ios::floatfield);
00428 if (!write_restart (restart_out_os))
00429 cvm::fatal_error ("Error: in writing restart file.\n");
00430 restart_out_os.close();
00431 }
00432 }
00433
00434 // write trajectory file, if needed
00435 if (cv_traj_freq) {
00436
00437 if (cvm::debug())
00438 cvm::log ("Writing trajectory file.\n");
00439
00440 // write labels in the traj file every 1000 lines
00441 cvm::increase_depth();
00442 if ((cvm::step_relative() % (cv_traj_freq * 1000)) == 0) {
00443 cv_traj_os << "# " << cvm::wrap_string ("step", cvm::it_width-2)
00444 << " ";
00445 if (cvm::debug())
00446 cv_traj_os.flush();
00447 for (std::vector<colvar *>::iterator cvi = colvars.begin();
00448 cvi != colvars.end();
00449 cvi++) {
00450 (*cvi)->write_traj_label (cv_traj_os);
00451 }
00452 cv_traj_os << "\n";
00453 if (cvm::debug())
00454 cv_traj_os.flush();
00455 }
00456 cvm::decrease_depth();
00457
00458 // write collective variable values to the traj file
00459 cvm::increase_depth();
00460 if ((cvm::step_relative() % cv_traj_freq) == 0) {
00461 cv_traj_os << std::setw (cvm::it_width) << it
00462 << " ";
00463 for (std::vector<colvar *>::iterator cvi = colvars.begin();
00464 cvi != colvars.end();
00465 cvi++) {
00466 (*cvi)->write_traj (cv_traj_os);
00467 }
00468 cv_traj_os << "\n";
00469 if (cvm::debug())
00470 cv_traj_os.flush();
00471 }
00472 cvm::decrease_depth();
00473
00474 if (restart_out_freq) {
00475 // flush the trajectory file if we are at the restart frequency
00476 if ( (cvm::step_relative() > 0) &&
00477 ((cvm::step_relative() % restart_out_freq) == 0) ) {
00478 cvm::log ("Synchronizing trajectory file.\n");
00479 cv_traj_os.flush();
00480 }
00481 }
00482 }
00483 }
|
|
|
Get the pointer of a colvar from its name (returns NULL if not found).
Definition at line 502 of file colvar.h. Referenced by colvarbias::add_colvar(), colvar::calc_acf(), and colvar::parse_analysis(). 00503 {
00504 for (std::vector<colvar *>::iterator cvi = cvm::colvars.begin();
00505 cvi != cvm::colvars.end();
00506 cvi++) {
00507 if ((*cvi)->name == name) {
00508 return (*cvi);
00509 }
00510 }
00511 return NULL;
00512 }
|
|
|
|
Decrease the depth (number of indentations in the output).
Definition at line 679 of file colvarmodule.C. References depth. Referenced by analyse(), calc(), colvar::calc(), colvar::communicate_forces(), init_biases(), init_colvars(), colvarmodule::atom_group::parse(), read_restart(), colvar::update(), and write_restart(). 00680 {
00681 if (depth) depth--;
00682 }
|
|
|
Print a message to the main log and exit normally.
Definition at line 689 of file colvarmodule.C. References colvarproxy::exit(), and proxy.
|
|
|
|
Deallocate memory and close files.
Definition at line 523 of file colvarmodule.C. References colvarproxy::backup_file(), biases, colvars, cv_traj_os, log(), output_prefix, proxy, and write_restart(). Referenced by colvarproxy_namd::calculate(), and ~colvarmodule(). 00524 {
00525 // close files and deallocate stuff
00526
00527 #if (!defined (COLVARS_STANDALONE) && !defined (COLVARS_GMXTOOLS))
00528 {
00529 // if this is a regular run, data must be written to be able to
00530 // restart the simulation
00531 std::string const out_name =
00532 (output_prefix.size() ?
00533 std::string (output_prefix+".colvars.state") :
00534 std::string ("colvars.state"));
00535 cvm::log ("Saving collective variables state to \""+out_name+"\".\n");
00536 proxy->backup_file (out_name.c_str());
00537 std::ofstream out (out_name.c_str());
00538 out.setf (std::ios::scientific, std::ios::floatfield);
00539 this->write_restart (out);
00540 out.close();
00541 }
00542 #endif
00543
00544 for (std::vector<colvar *>::iterator cvi = colvars.begin();
00545 cvi != colvars.end();
00546 cvi++) {
00547 delete *cvi;
00548 }
00549 colvars.clear();
00550
00551 for (std::vector<colvarbias *>::iterator bi = biases.begin();
00552 bi != biases.end();
00553 bi++) {
00554 delete *bi;
00555 }
00556 biases.clear();
00557
00558 if (cv_traj_freq) {
00559 cv_traj_os.close();
00560 }
00561 }
|
|
|
Increase the depth (number of indentations in the output).
Definition at line 674 of file colvarmodule.C. References depth. Referenced by analyse(), calc(), colvar::calc(), colvar::communicate_forces(), init_biases(), init_colvars(), colvarmodule::atom_group::parse(), read_restart(), colvar::update(), and write_restart(). 00675 {
00676 depth++;
00677 }
|
|
|
Initialize collective variable biases. initialize ABF instances initialize harmonic restraints initialize histograms initialize metadynamics instances Definition at line 241 of file colvarmodule.C. References biases, colvarparse::check_keywords(), debug(), decrease_depth(), increase_depth(), colvarparse::key_lookup(), log(), n_abf_biases, n_harm_biases, n_histo_biases, n_meta_biases, and parse. Referenced by colvarmodule(). 00242 {
00243 if (cvm::debug())
00244 cvm::log ("Initializing the collective variables biases.\n");
00245
00246 {
00248 std::string abf_conf = "";
00249 size_t abf_pos = 0;
00250 while (parse->key_lookup (conf, "abf", abf_conf, abf_pos)) {
00251 if (abf_conf.size()) {
00252 cvm::log (cvm::line_marker);
00253 cvm::increase_depth();
00254 biases.push_back (new colvarbias_abf (abf_conf, "abf"));
00255 (biases.back())->check_keywords (abf_conf, "abf");
00256 cvm::decrease_depth();
00257 n_abf_biases++;
00258 } else {
00259 cvm::log ("Warning: \"abf\" keyword found without configuration.\n");
00260 }
00261 abf_conf = "";
00262 }
00263 }
00264
00265 {
00267 std::string harm_conf = "";
00268 size_t harm_pos = 0;
00269 while (parse->key_lookup (conf, "harmonic", harm_conf, harm_pos)) {
00270 if (harm_conf.size()) {
00271 cvm::log (cvm::line_marker);
00272 cvm::increase_depth();
00273 biases.push_back (new colvarbias_harmonic (harm_conf, "harmonic"));
00274 (biases.back())->check_keywords (harm_conf, "harmonic");
00275 cvm::decrease_depth();
00276 n_harm_biases++;
00277 } else {
00278 cvm::log ("Warning: \"harmonic\" keyword found without configuration.\n");
00279 }
00280 harm_conf = "";
00281 }
00282 }
00283
00284 {
00286 std::string histo_conf = "";
00287 size_t histo_pos = 0;
00288 while (parse->key_lookup (conf, "histogram", histo_conf, histo_pos)) {
00289 if (histo_conf.size()) {
00290 cvm::log (cvm::line_marker);
00291 cvm::increase_depth();
00292 biases.push_back (new colvarbias_histogram (histo_conf, "histogram"));
00293 (biases.back())->check_keywords (histo_conf, "histogram");
00294 cvm::decrease_depth();
00295 n_histo_biases++;
00296 } else {
00297 cvm::log ("Warning: \"histogram\" keyword found without configuration.\n");
00298 }
00299 histo_conf = "";
00300 }
00301 }
00302
00303 {
00305 std::string meta_conf = "";
00306 size_t meta_pos = 0;
00307 while (parse->key_lookup (conf, "metadynamics", meta_conf, meta_pos)) {
00308 if (meta_conf.size()) {
00309 cvm::log (cvm::line_marker);
00310 cvm::increase_depth();
00311 biases.push_back (new colvarbias_meta (meta_conf, "metadynamics"));
00312 (biases.back())->check_keywords (meta_conf, "metadynamics");
00313 cvm::decrease_depth();
00314 n_meta_biases++;
00315 } else {
00316 cvm::log ("Warning: \"metadynamics\" keyword found without configuration.\n");
00317 }
00318 meta_conf = "";
00319 }
00320 }
00321
00322 if (biases.size())
00323 cvm::log (cvm::line_marker);
00324 cvm::log ("Collective variables biases initialized, "+
00325 cvm::to_str (biases.size())+" in total.\n");
00326 }
|
|
|
Initialize collective variables.
Definition at line 208 of file colvarmodule.C. References colvarparse::check_keywords(), colvars, debug(), decrease_depth(), fatal_error(), increase_depth(), colvarparse::key_lookup(), log(), and parse. Referenced by colvarmodule(). 00209 {
00210 if (cvm::debug())
00211 cvm::log ("Initializing the collective variables.\n");
00212
00213 std::string colvar_conf = "";
00214 size_t pos = 0;
00215 while (parse->key_lookup (conf, "colvar", colvar_conf, pos)) {
00216
00217 if (colvar_conf.size()) {
00218 cvm::log (cvm::line_marker);
00219 cvm::increase_depth();
00220 colvars.push_back (new colvar (colvar_conf));
00221 (colvars.back())->check_keywords (colvar_conf, "colvar");
00222 cvm::decrease_depth();
00223 } else {
00224 cvm::log ("Warning: \"colvar\" keyword found without any configuration.\n");
00225 }
00226 colvar_conf = "";
00227 }
00228
00229
00230 if (!colvars.size())
00231 cvm::fatal_error ("Error: no collective variables defined.\n");
00232
00233 if (colvars.size())
00234 cvm::log (cvm::line_marker);
00235 cvm::log ("Collective variables initialized, "+
00236 cvm::to_str (colvars.size())+
00237 " in total.\n");
00238 }
|
|
||||||||||||||||||||
|
Create atoms from a file.
Definition at line 421 of file colvarmodule.h. References colvarproxy::load_atoms(), and proxy. Referenced by colvarmodule::atom_group::parse(). 00425 {
00426 proxy->load_atoms (file_name, atoms, pdb_field, pdb_field_value);
00427 }
|
|
||||||||||||||||||||
|
Load the coordinates for a group of atoms from a file (usually a PDB); the number of atoms in "filename" must match the number of elements in "pos".
Definition at line 429 of file colvarmodule.h. References colvarproxy::load_coords(), and proxy. Referenced by colvar::eigenvector::eigenvector(), colvar::orientation::orientation(), and colvarmodule::atom_group::parse(). 00433 {
00434 proxy->load_coords (file_name, pos, pdb_field, pdb_field_value);
00435 }
|
|
|
||||||||||||
|
Get the square distance between two positions (with periodic boundary conditions handled transparently). Note: in the case of periodic boundary conditions, this provides an analytical square distance (while taking the square of position_distance() would produce leads to a cusp) Definition at line 415 of file colvarmodule.h. References atom_pos, colvarproxy::position_dist2(), and proxy. 00417 {
00418 return proxy->position_dist2 (pos1, pos2);
00419 }
|
|
||||||||||||
|
Get the distance between two atomic positions with pbcs handled correctly.
Definition at line 409 of file colvarmodule.h. References atom_pos, colvarproxy::position_distance(), and proxy. Referenced by colvar::min_distance::calc_gradients(), colvar::distance_xy::calc_gradients(), colvar::distance_dir::calc_value(), colvar::min_distance::calc_value(), colvar::distance_xy::calc_value(), colvar::distance_z::calc_value(), colvar::distance::calc_value(), colvar::dihedral::calc_value(), colvar::angle::calc_value(), and colvar::coordnum::switching_function(). 00411 {
00412 return proxy->position_distance (pos1, pos2);
00413 }
|
|
|
Read the input restart file.
Definition at line 169 of file colvarmodule.C. References biases, colvars, decrease_depth(), fatal_error(), increase_depth(), it, it_restart, and parse. Referenced by colvarmodule(). 00170 {
00171 {
00172 // read global restart information
00173 std::string restart_conf;
00174 if (is >> colvarparse::read_block ("configuration", restart_conf)) {
00175 parse->get_keyval (restart_conf, "step",
00176 it_restart, (size_t) 0,
00177 colvarparse::parse_silent);
00178 it = it_restart;
00179 }
00180 is.clear();
00181 }
00182
00183 // colvars restart
00184 cvm::increase_depth();
00185 for (std::vector<colvar *>::iterator cvi = colvars.begin();
00186 cvi != colvars.end();
00187 cvi++) {
00188 if ( !((*cvi)->read_restart (is)) )
00189 cvm::fatal_error ("Error: in reading restart configuration for collective variable \""+
00190 (*cvi)->name+"\".\n");
00191 }
00192
00193 // biases restart
00194 for (std::vector<colvarbias *>::iterator bi = biases.begin();
00195 bi != biases.end();
00196 bi++) {
00197 if (!((*bi)->read_restart (is)))
00198 fatal_error ("ERROR: in reading restart configuration for bias \""+
00199 (*bi)->name+"\".\n");
00200 }
00201 cvm::decrease_depth();
00202
00203 return is;
00204 }
|
|
|
Read a collective variable trajectory for analysis.
Definition at line 565 of file colvarmodule.C. References colvars, cv_traj_read_end, colvarparse::getline_nocomments(), it, and log(). 00566 {
00567 std::ifstream static *traj_s = NULL;
00568
00569 if (!traj_s) {
00570 cvm::log ("Opening trajectory file \""+
00571 std::string (traj_filename)+"\".\n");
00572 traj_s = new std::ifstream (traj_filename);
00573 }
00574
00575 do {
00576
00577 std::string line ("");
00578
00579 do {
00580 if (!colvarparse::getline_nocomments (*traj_s, line)) {
00581 cvm::log ("End of file \""+std::string (traj_filename)+
00582 "\" reached.\n");
00583 traj_s->close();
00584 return false;
00585 }
00586 } while (line.find_first_not_of (colvarparse::white_space) == std::string::npos);
00587
00588 std::istringstream is (line);
00589
00590 if (!(is >> it)) return false;
00591
00592 if ( (it < cv_traj_read_begin) ) {
00593
00594 #if defined (COLVARS_STANDALONE)
00595 if ((it % 1000) == 0)
00596 std::cerr << "Skipping trajectory step " << it
00597 << " \r";
00598 #endif
00599
00600 continue;
00601
00602 } else {
00603
00604 #if defined (COLVARS_STANDALONE)
00605 if ((it % 1000) == 0)
00606 std::cerr << "Reading from trajectory, step = " << it
00607 << " \r";
00608 #endif
00609
00610 if ( (cv_traj_read_end > cv_traj_read_begin) &&
00611 (it > cv_traj_read_end) ) {
00612 #if defined (COLVARS_STANDALONE)
00613 std::cerr << "\n";
00614 #endif
00615 cvm::log ("Reached the end of the trajectory, "
00616 "read_end = "+cvm::to_str (cv_traj_read_end)+"\n");
00617 return false;
00618 }
00619
00620 for (std::vector<colvar *>::iterator cvi = colvars.begin();
00621 cvi != colvars.end();
00622 cvi++) {
00623 if (!(*cvi)->read_traj (is)) {
00624 cvm::log ("Error: in reading colvar \""+(*cvi)->name+
00625 "\" from trajectory file \""+
00626 std::string (traj_filename)+"\".\n");
00627 return false;
00628 }
00629 }
00630
00631 break;
00632 }
00633 } while (true);
00634
00635 return true;
00636 }
|
|
||||||||||||
|
Get the closest periodic image to a reference position.
Definition at line 397 of file colvarmodule.h. References atom_pos, proxy, and colvarproxy::select_closest_image(). Referenced by colvarmodule::atom_group::center_of_geometry(), and colvarmodule::atom_group::center_of_mass(). 00399 {
00400 proxy->select_closest_image (pos, ref_pos);
00401 }
|
|
||||||||||||
|
Perform select_closest_image() on a set of atomic positions. After that, distance vectors can then be calculated directly, without using position_distance() Definition at line 403 of file colvarmodule.h. References atom_pos, proxy, and colvarproxy::select_closest_images(). 00405 {
00406 proxy->select_closest_images (pos, ref_pos);
00407 }
|
|
|
Return the current step number from the beginning of the whole calculation Definition at line 104 of file colvarmodule.h. Referenced by colvarbias_harmonic::update(). 00105 {
00106 return it;
00107 }
|
|
|
Return the current step number from the beginning of this run.
Definition at line 97 of file colvarmodule.h. Referenced by analyse(), calc(), colvar::calc(), colvar::calc_runave(), colvarproxy_namd::calculate(), colvarbias_meta::update(), colvarbias_histogram::update(), and colvarbias_abf::update(). 00098 {
00099 return it - it_restart;
00100 }
|
|
|
Temperature of the simulation (K).
Definition at line 392 of file colvarmodule.h. References proxy, and colvarproxy::temperature(). Referenced by colvar::update(). 00393 {
00394 return proxy->temperature();
00395 }
|
|
||||||||||||||||||||
|
Quick conversion of a vector of objects to a string.
Definition at line 356 of file colvarmodule.h. 00358 {
00359 if (!x.size()) return std::string ("");
00360 std::ostringstream os;
00361 if (prec) {
00362 os.setf (std::ios::scientific, std::ios::floatfield);
00363 }
00364 os << "{ ";
00365 if (width) os.width (width);
00366 if (prec) os.precision (prec);
00367 os << x[0];
00368 for (size_t i = 1; i < x.size(); i++) {
00369 os << ", ";
00370 if (width) os.width (width);
00371 if (prec) os.precision (prec);
00372 os << x[i];
00373 }
00374 os << " }";
00375 return os.str();
00376 }
|
|
||||||||||||||||||||
|
Quick conversion of an object to a string.
Definition at line 343 of file colvarmodule.h. Referenced by colvar::alpha_angles::calc_value(), colvarbias_meta::hill::hill(), colvarmodule::atom_group::parse(), and colvarbias_meta::read_replica_files(). 00345 {
00346 std::ostringstream os;
00347 if (width) os.width (width);
00348 if (prec) {
00349 os.setf (std::ios::scientific, std::ios::floatfield);
00350 os.precision (prec);
00351 }
00352 os << x;
00353 return os.str();
00354 }
|
|
|
Value of the unit for atomic coordinates with respect to angstroms (used by some variables for hard-coded default values).
Definition at line 382 of file colvarmodule.h. References proxy, and colvarproxy::unit_angstrom(). 00383 {
00384 return proxy->unit_angstrom();
00385 }
|
|
||||||||||||
|
Reduce the number of characters in a string.
Definition at line 191 of file colvarmodule.h. Referenced by calc(), colvar::parse_analysis(), and colvar::write_traj_label(). 00193 {
00194 if (!s.size())
00195 return std::string (nchars, ' ');
00196 else
00197 return ( (s.size() <= size_t (nchars)) ?
00198 (s+std::string (nchars-s.size(), ' ')) :
00199 (std::string (s, 0, nchars)) );
00200 }
|
|
|
Write the output restart file.
Definition at line 639 of file colvarmodule.C. References biases, colvars, decrease_depth(), dt, increase_depth(), it, and it_width. Referenced by calc(), and finalise(). 00640 {
00641 os << "configuration {\n"
00642 << " step " << std::setw (it_width)
00643 << it << "\n"
00644 << " dt " << dt << "\n"
00645 << "}\n\n";
00646
00647 cvm::increase_depth();
00648 for (std::vector<colvar *>::iterator cvi = colvars.begin();
00649 cvi != colvars.end();
00650 cvi++) {
00651 (*cvi)->write_restart (os);
00652 }
00653
00654 for (std::vector<colvarbias *>::iterator bi = biases.begin();
00655 bi != biases.end();
00656 bi++) {
00657 (*bi)->write_restart (os);
00658 }
00659 cvm::decrease_depth();
00660
00661 return os;
00662 }
|
|
|
Definition at line 86 of file colvarmodule.h. Referenced by colvar::h_bond::h_bond(). |
|
|
Definition at line 87 of file colvarmodule.h. |
|
|
Definition at line 56 of file colvarmodule.h. |
|
|
True if only analysis is performed and not a run.
Definition at line 714 of file colvarmodule.C. Referenced by colvarmodule(). |
|
|
Collective variable biases array.
Definition at line 698 of file colvarmodule.C. Referenced by analyse(), calc(), finalise(), init_biases(), read_restart(), and write_restart(). |
|
|
Collective variables array.
Definition at line 697 of file colvarmodule.C. Referenced by analyse(), calc(), finalise(), init_colvars(), read_restart(), read_traj(), and write_restart(). |
|
|
Configuration file.
Definition at line 303 of file colvarmodule.h. Referenced by colvarmodule(). |
|
|
Number of digits to represent a collective variables value(s).
Definition at line 726 of file colvarmodule.C. |
|
|
Frequency for collective variables trajectory output.
Definition at line 712 of file colvarmodule.C. Referenced by calc(), and colvarmodule(). |
|
|
Collective variables output trajectory file.
Definition at line 309 of file colvarmodule.h. Referenced by calc(), colvarmodule(), and finalise(). |
|
|
Step numbers to analyse in the trajectory.
Definition at line 293 of file colvarmodule.h. Referenced by colvarmodule(). |
|
|
Step numbers to analyse in the trajectory.
Definition at line 293 of file colvarmodule.h. Referenced by colvarmodule(), and read_traj(). |
|
|
Trajectory file name to analyze.
Definition at line 291 of file colvarmodule.h. Referenced by colvarmodule(). |
|
|
Number of characters to represent a collective variables value(s).
Definition at line 727 of file colvarmodule.C. |
|
|
Finite difference step size (if there is no dynamics, or if gradients need to be tested independently from the size of dt).
Definition at line 708 of file colvarmodule.C. Referenced by colvarmodule(). |
|
|
Counter for the current depth in the object hierarchy (useg e.g. in outpu.
Definition at line 713 of file colvarmodule.C. Referenced by decrease_depth(), increase_depth(), and log(). |
|
|
Time step of the MD integrator.
Definition at line 707 of file colvarmodule.C. Referenced by colvarmodule(), colvarproxy_namd::colvarproxy_namd(), and write_restart(). |
|
|
Number of digits to represent the collective variables energy.
Definition at line 728 of file colvarmodule.C. |
|
|
Number of characters to represent the collective variables energy.
Definition at line 729 of file colvarmodule.C. |
|
|
Prefix for files from a previous run (including restart/output).
Definition at line 720 of file colvarmodule.C. |
|
|
Current step number.
Definition at line 709 of file colvarmodule.C. Referenced by analyse(), calc(), colvarproxy_namd::calculate(), colvarmodule(), read_restart(), read_traj(), and write_restart(). |
|
|
Starting step number for this run.
Definition at line 710 of file colvarmodule.C. Referenced by colvarproxy_namd::calculate(), colvarmodule(), and read_restart(). |
|
|
Number of characters to represent a time step.
Definition at line 725 of file colvarmodule.C. Referenced by write_restart(). |
|
|
Initial value:
"----------------------------------------------------------------------\n"
Definition at line 730 of file colvarmodule.C. |
|
|
Number of ABF biases initialized (in normal conditions should be 1).
Definition at line 699 of file colvarmodule.C. Referenced by init_biases(). |
|
|
Number of harmonic biases initialized (no limit on the number).
Definition at line 700 of file colvarmodule.C. Referenced by init_biases(). |
|
|
Number of histograms initialized (no limit on the number).
Definition at line 701 of file colvarmodule.C. Referenced by init_biases(). |
|
|
Number of metadynamics biases initialized (in normal conditions should be 1).
Definition at line 702 of file colvarmodule.C. Referenced by init_biases(). |
|
|
Prefix for all output files for this run.
Definition at line 719 of file colvarmodule.C. Referenced by colvarmodule(), and finalise(). |
|
|
Configuration file parser object.
Definition at line 306 of file colvarmodule.h. Referenced by colvarmodule(), init_biases(), init_colvars(), and read_restart(). |
|
|
Pointer to the proxy object, used to retrieve atomic data from the hosting program; it is static in order to be accessible from static functions in the colvarmodule class.
Definition at line 703 of file colvarmodule.C. Referenced by boltzmann(), calc(), colvarmodule(), exit(), fatal_error(), finalise(), load_atoms(), load_coords(), log(), position_dist2(), position_distance(), select_closest_image(), select_closest_images(), temperature(), and unit_angstrom(). |
|
|
input restart file name (determined from input_prefix)
Definition at line 721 of file colvarmodule.C. Referenced by colvarmodule(). |
|
|
Frequency for saving output restarts.
Definition at line 711 of file colvarmodule.C. Referenced by calc(), and colvarmodule(). |
|
|
Output restart file name.
Definition at line 298 of file colvarmodule.h. Referenced by calc(), and colvarmodule(). |
|
|
Output restart file.
Definition at line 312 of file colvarmodule.h. Referenced by calc(). |
1.3.9.1