Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

colvarscript_commands_colvar.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 
00003 // This file is part of the Collective Variables module (Colvars).
00004 // The original version of Colvars and its updates are located at:
00005 // https://github.com/Colvars/colvars
00006 // Please update all Colvars source files before making any changes.
00007 // If you wish to distribute your changes, please submit them to the
00008 // Colvars repository at GitHub.
00009 
00010 
00011 CVSCRIPT(colvar_addforce,
00012          "Apply the given force onto this colvar and return the same\n"
00013          "force : float or array - Applied force; matches colvar dimensionality",
00014          1, 1,
00015          "force : float or array - Applied force; must match colvar dimensionality",
00016          std::string const f_str(script->obj_to_str(script->get_colvar_cmd_arg(0, objc, objv)));
00017          std::istringstream is(f_str);
00018          is.width(cvm::cv_width);
00019          is.precision(cvm::cv_prec);
00020          colvarvalue force(this_colvar->value());
00021          force.is_derivative();
00022          if (force.from_simple_string(is.str()) != COLVARS_OK) {
00023            script->add_error_msg("addforce : error parsing force value");
00024            return COLVARSCRIPT_ERROR;
00025          }
00026          this_colvar->add_bias_force(force);
00027          script->set_result_colvarvalue(force);
00028          return COLVARS_OK;
00029          )
00030 
00031 CVSCRIPT(colvar_communicateforces,
00032          "Communicate bias forces from this colvar to atoms",
00033          0, 0,
00034          "",
00035          this_colvar->communicate_forces();
00036          return COLVARS_OK;
00037          )
00038 
00039 CVSCRIPT(colvar_cvcflags,
00040          "Enable or disable individual components by setting their active flags",
00041          1, 1,
00042          "flags : integer array - Zero/nonzero value disables/enables the CVC",
00043          std::string const flags_str(script->obj_to_str(script->get_colvar_cmd_arg(0, objc, objv)));
00044          std::istringstream is(flags_str);
00045          std::vector<bool> flags;
00046          int flag;
00047          while (is >> flag) {
00048            flags.push_back(flag != 0);
00049          }
00050          int res = this_colvar->set_cvc_flags(flags);
00051          if (res != COLVARS_OK) {
00052            script->add_error_msg("Error setting CVC flags");
00053            return COLVARSCRIPT_ERROR;
00054          }
00055          script->set_result_str("0");
00056          return COLVARS_OK;
00057          )
00058 
00059 CVSCRIPT(colvar_delete,
00060          "Delete this colvar, along with all biases that depend on it",
00061          0, 0,
00062          "",
00063          delete this_colvar;
00064          return COLVARS_OK;
00065          )
00066 
00067 CVSCRIPT(colvar_get,
00068          "Get the value of the given feature for this colvar\n"
00069          "state : 1/0 - State of the given feature",
00070          1, 1,
00071          "feature : string - Name of the feature",
00072          return script->proc_features(this_colvar, objc, objv);
00073          )
00074 
00075 CVSCRIPT(colvar_getappliedforce,
00076          "Return the total of the forces applied to this colvar\n"
00077          "force : float - Applied force; matches the colvar dimensionality",
00078          0, 0,
00079          "",
00080          script->set_result_colvarvalue(this_colvar->applied_force());
00081          return COLVARS_OK;
00082          )
00083 
00084 CVSCRIPT(colvar_resetbiasforce,
00085          "Return the total of the forces applied to this colvar",
00086          0, 0,
00087          "",
00088          this_colvar->reset_bias_force();
00089          return COLVARS_OK;
00090          )
00091 
00092 CVSCRIPT(colvar_getatomgroups,
00093          "Return the atom indices used by this colvar as a list of lists\n"
00094          "groups : array of arrays of ints - Atom indices",
00095          0, 0,
00096          "",
00097          std::string result;
00098          std::vector<std::vector<int> > lists = this_colvar->get_atom_lists();
00099          std::vector<std::vector<int> >::iterator li = lists.begin();
00100          for ( ; li != lists.end(); ++li) {
00101            result += "{";
00102            std::vector<int>::iterator lj = (*li).begin();
00103            for ( ; lj != (*li).end(); ++lj) {
00104              result += cvm::to_str(*lj);
00105              result += " ";
00106            }
00107            result += "} ";
00108          }
00109          script->set_result_str(result);
00110          return COLVARS_OK;
00111          )
00112 
00113 CVSCRIPT(colvar_getatomids,
00114          "Return the list of atom indices used by this colvar\n"
00115          "indices : array of ints - Atom indices",
00116          0, 0,
00117          "",
00118          script->set_result_int_vec(this_colvar->atom_ids);
00119          return COLVARS_OK;
00120          )
00121 
00122 CVSCRIPT(colvar_getconfig,
00123          "Return the configuration string of this colvar\n"
00124          "conf : string - Current configuration string",
00125          0, 0,
00126          "",
00127          script->set_result_str(this_colvar->get_config());
00128          return COLVARS_OK;
00129          )
00130 
00131 CVSCRIPT(colvar_getgradients,
00132          "Return the atomic gradients of this colvar\n"
00133          "gradients : array of arrays of floats - Atomic gradients",
00134          0, 0,
00135          "",
00136          script->set_result_rvector_vec(this_colvar->atomic_gradients);
00137          return COLVARS_OK;
00138          )
00139 
00140 CVSCRIPT(colvar_gettotalforce,
00141          "Return the sum of internal and external forces to this colvar\n"
00142          "force : float - Total force; matches the colvar dimensionality",
00143          0, 0,
00144          "",
00145          script->set_result_colvarvalue(this_colvar->total_force());
00146          return COLVARS_OK;
00147          )
00148 
00149 CVSCRIPT(colvar_getvolmapids,
00150          "Return the list of volumetric map indices used by this colvar",
00151          0, 0,
00152          "",
00153          script->set_result_int_vec(this_colvar->get_volmap_ids());
00154          return COLVARS_OK;
00155          )
00156 
00157 CVSCRIPT(colvar_help,
00158          "Get a help summary or the help string of one colvar subcommand\n"
00159          "help : string - Help string",
00160          0, 1,
00161          "command : string - Get the help string of this specific command",
00162          unsigned char *const cmdobj =
00163            script->get_colvar_cmd_arg(0, objc, objv);
00164          if (this_colvar) {
00165          }
00166          if (cmdobj) {
00167            std::string const cmdstr(script->obj_to_str(cmdobj));
00168            if (cmdstr.size()) {
00169              script->set_result_str(script->get_command_cmdline_help(colvarscript::use_colvar,
00170                                                                      cmdstr));
00171              return cvm::get_error();
00172            } else {
00173              return COLVARSCRIPT_ERROR;
00174            }
00175          } else {
00176            script->set_result_str(script->get_cmdline_help_summary(colvarscript::use_colvar));
00177            return COLVARS_OK;
00178          }
00179          )
00180 
00181 CVSCRIPT(colvar_modifycvcs,
00182          "Modify configuration of individual components by passing string arguments",
00183          1, 1,
00184          "confs : sequence of strings - New configurations; empty strings are skipped",
00185          std::vector<std::string> const confs(script->obj_to_str_vector(script->get_colvar_cmd_arg(0, objc, objv)));
00186          cvm::increase_depth();
00187          int res = this_colvar->update_cvc_config(confs);
00188          cvm::decrease_depth();
00189          if (res != COLVARS_OK) {
00190            script->add_error_msg("Error setting CVC flags");
00191            return COLVARSCRIPT_ERROR;
00192          }
00193          script->set_result_str("0");
00194          return COLVARS_OK;
00195          )
00196 
00197 CVSCRIPT(colvar_run_ave,
00198          "Get the current running average of the value of this colvar\n"
00199          "value : float or array - Averaged value; matches the colvar dimensionality",
00200          0, 0,
00201          "",
00202          script->set_result_colvarvalue(this_colvar->run_ave());
00203          return COLVARS_OK;
00204          )
00205 
00206 CVSCRIPT(colvar_set,
00207          "Set the given feature of this colvar to a new value",
00208          2, 2,
00209          "feature : string - Name of the feature\n"
00210          "value : string - String representation of the new feature value",
00211          return script->proc_features(this_colvar, objc, objv);
00212          )
00213 
00214 CVSCRIPT(colvar_state,
00215          "Print a string representation of the feature state of this colvar\n"
00216          "state : string - The feature state",
00217          0, 0,
00218          "",
00219          this_colvar->print_state();
00220          return COLVARS_OK;
00221          )
00222 
00223 CVSCRIPT(colvar_type,
00224          "Get the type description of this colvar\n"
00225          "type : string - Type description",
00226          0, 0,
00227          "",
00228          script->set_result_str(this_colvar->value().type_desc(this_colvar->value().value_type));
00229          return COLVARS_OK;
00230          )
00231 
00232 CVSCRIPT(colvar_update,
00233          "Recompute this colvar and return its up-to-date value\n"
00234          "value : float or array - Current value; matches the colvar dimensionality",
00235          0, 0,
00236          "",
00237          this_colvar->calc();
00238          this_colvar->update_forces_energy();
00239          script->set_result_colvarvalue(this_colvar->value());
00240          return COLVARS_OK;
00241          )
00242 
00243 CVSCRIPT(colvar_value,
00244          "Get the current value of this colvar\n"
00245          "value : float or array - Current value; matches the colvar dimensionality",
00246          0, 0,
00247          "",
00248          script->set_result_colvarvalue(this_colvar->value());
00249          return COLVARS_OK;
00250          )
00251 
00252 CVSCRIPT(colvar_width,
00253          "Get the width of this colvar\n"
00254          "width : float - Value of the width",
00255          0, 0,
00256          "",
00257          script->set_result_str(cvm::to_str(this_colvar->width, 0,
00258                                             cvm::cv_prec));
00259          return COLVARS_OK;
00260          )

Generated on Fri Oct 4 02:43:47 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002