Update Colvars to version 2021-08-03

This commit is contained in:
Giacomo Fiorin
2021-08-03 18:03:09 -04:00
parent 50e8d7c36b
commit 2a9be42758
48 changed files with 2557 additions and 527 deletions

View File

@ -25,7 +25,8 @@
// COMM = the id of the command (must be a member of colvarscript::command)
// HELP = a one-line description (C string literal) for the command
// HELP = short description (C string literal) for the command; the second line
// is optional, and documents the return value (if any)
// N_ARGS_MIN = the lowest number of arguments allowed
@ -68,6 +69,33 @@ extern "C" {
/// Get the names of all commands (array of strings)
char const ** cvscript_command_names();
/// Get the help summary of the given command
/// \param cmd Name of the command's function (e.g. "cv_units")
char const *cvscript_command_help(char const *cmd);
/// Get description of the return value of a command
/// \param cmd Name of the command's function (e.g. "cv_units")
char const *cvscript_command_rethelp(char const *cmd);
/// Get description of the arguments of a command (excluding prefix)
/// \param cmd Name of the command's function (e.g. "cv_units")
/// \param i Index of the argument; 0 is the first argument after the
/// prefix, e.g. "value" has an index of 0 in the array of arguments:
/// { "cv", "colvar", "xi", "value" }
char const *cvscript_command_arghelp(char const *cmd, int i);
/// Get the full help string of a command
/// \param cmd Name of the command's function (e.g. "cv_units")
char const *cvscript_command_full_help(char const *cmd);
/// Get number of required arguments (excluding prefix)
/// \param cmd Name of the command's function (e.g. "cv_units")
int cvscript_command_n_args_min(char const *cmd);
/// Get number of total arguments (excluding prefix)
/// \param cmd Name of the command's function (e.g. "cv_units")
int cvscript_command_n_args_max(char const *cmd);
}
#endif
@ -135,7 +163,8 @@ CVSCRIPT(cv_delete,
)
CVSCRIPT(cv_frame,
"Get or set current frame number (VMD only)",
"Get or set current frame number (VMD only)\n"
"frame : integer - Frame number",
0, 1,
"frame : integer - Frame number",
char const *arg =
@ -143,7 +172,7 @@ CVSCRIPT(cv_frame,
if (arg == NULL) {
long int f = -1;
if (script->proxy()->get_frame(f) == COLVARS_OK) {
script->set_result_str(cvm::to_str(f));
script->set_result_long_int(f);
return COLVARS_OK;
} else {
script->add_error_msg("Frame number is not available");
@ -161,8 +190,90 @@ CVSCRIPT(cv_frame,
return COLVARS_OK;
)
CVSCRIPT(cv_getatomappliedforces,
"Get the list of forces applied by Colvars to atoms\n"
"forces : array of arrays of floats - Atomic forces",
0, 0,
"",
script->set_result_rvector_vec(*(script->proxy()->get_atom_applied_forces()));
return COLVARS_OK;
)
CVSCRIPT(cv_getatomappliedforcesmax,
"Get the maximum norm of forces applied by Colvars to atoms\n"
"force : float - Maximum atomic force",
0, 0,
"",
script->set_result_real(script->proxy()->max_atoms_applied_force());
return COLVARS_OK;
)
CVSCRIPT(cv_getatomappliedforcesmaxid,
"Get the atom ID with the largest applied force\n"
"id : int - ID of the atom with the maximum atomic force",
0, 0,
"",
script->set_result_int(script->proxy()->max_atoms_applied_force_id());
return COLVARS_OK;
)
CVSCRIPT(cv_getatomappliedforcesrms,
"Get the root-mean-square norm of forces applied by Colvars to atoms\n"
"force : float - RMS atomic force",
0, 0,
"",
script->set_result_real(script->proxy()->rms_atoms_applied_force());
return COLVARS_OK;
)
CVSCRIPT(cv_getatomids,
"Get the list of indices of atoms used in Colvars\n"
"indices : array of ints - Atomic indices",
0, 0,
"",
script->set_result_int_vec(*(script->proxy()->get_atom_ids()));
return COLVARS_OK;
)
CVSCRIPT(cv_getatomcharges,
"Get the list of charges of atoms used in Colvars\n"
"charges : array of floats - Atomic charges",
0, 0,
"",
script->set_result_real_vec(*(script->proxy()->get_atom_charges()));
return COLVARS_OK;
)
CVSCRIPT(cv_getatommasses,
"Get the list of masses of atoms used in Colvars\n"
"masses : array of floats - Atomic masses",
0, 0,
"",
script->set_result_real_vec(*(script->proxy()->get_atom_masses()));
return COLVARS_OK;
)
CVSCRIPT(cv_getatompositions,
"Get the list of cached positions of atoms used in Colvars\n"
"positions : array of arrays of floats - Atomic positions",
0, 0,
"",
script->set_result_rvector_vec(*(script->proxy()->get_atom_positions()));
return COLVARS_OK;
)
CVSCRIPT(cv_getatomtotalforces,
"Get the list of cached total forces of atoms used in Colvars\n"
"forces : array of arrays of floats - Atomic total foces",
0, 0,
"",
script->set_result_rvector_vec(*(script->proxy()->get_atom_total_forces()));
return COLVARS_OK;
)
CVSCRIPT(cv_getconfig,
"Get the module's configuration string read so far",
"Get the module's configuration string read so far\n"
"conf : string - Current configuration string",
0, 0,
"",
script->set_result_str(cvm::main()->get_config());
@ -170,15 +281,17 @@ CVSCRIPT(cv_getconfig,
)
CVSCRIPT(cv_getenergy,
"Get the current Colvars energy",
"Get the current Colvars energy\n"
"E : float - Amount of energy (internal units)",
0, 0,
"",
script->set_result_str(cvm::to_str(cvm::main()->total_bias_energy));
script->set_result_real(cvm::main()->total_bias_energy);
return COLVARS_OK;
)
CVSCRIPT(cv_help,
"Get the help string of the Colvars scripting interface",
"Get the help string of the Colvars scripting interface\n"
"help : string - Help string",
0, 1,
"command : string - Get the help string of this specific command",
unsigned char *const cmdobj =
@ -205,7 +318,8 @@ CVSCRIPT(cv_help,
)
CVSCRIPT(cv_list,
"Return a list of all variables or biases",
"Return a list of all variables or biases\n"
"list : sequence of strings - List of elements",
0, 1,
"param : string - \"colvars\" or \"biases\"; default is \"colvars\"",
std::string res;
@ -235,7 +349,8 @@ CVSCRIPT(cv_list,
)
CVSCRIPT(cv_listcommands,
"Get the list of script functions, prefixed with \"cv_\", \"colvar_\" or \"bias_\"",
"Get the list of script functions, prefixed with \"cv_\", \"colvar_\" or \"bias_\"\n"
"list : sequence of strings - List of commands",
0, 0,
"",
int const n_commands = cvscript_n_commands();
@ -249,6 +364,20 @@ CVSCRIPT(cv_listcommands,
return COLVARS_OK;
)
CVSCRIPT(cv_listindexfiles,
"Get a list of the index files loaded in this session",
0, 0,
"",
int const n_files = script->module()->index_file_names.size();
std::string result;
for (int i = 0; i < n_files; i++) {
if (i > 0) result.append(1, ' ');
result.append(script->module()->index_file_names[i]);
}
script->set_result_str(result);
return COLVARS_OK;
)
CVSCRIPT(cv_load,
"Load data from a state file into all matching colvars and biases",
1, 1,
@ -280,15 +409,16 @@ CVSCRIPT(cv_loadfromstring,
)
CVSCRIPT(cv_molid,
"Get or set the molecule ID on which Colvars is defined (VMD only)",
"Get or set the molecule ID on which Colvars is defined (VMD only)\n"
"molid : integer - Current molecule ID",
0, 1,
"molid : integer - Molecule ID; -1 means undefined",
"molid : integer - New molecule ID; -1 means undefined",
char const *arg =
script->obj_to_str(script->get_module_cmd_arg(0, objc, objv));
if (arg == NULL) {
int molid = -1;
script->proxy()->get_molid(molid);
script->set_result_str(cvm::to_str(molid));
script->set_result_int(molid);
return COLVARS_OK;
} else {
script->add_error_msg("Error: To change the molecule ID in VMD, use cv delete first.");
@ -297,7 +427,8 @@ CVSCRIPT(cv_molid,
)
CVSCRIPT(cv_printframe,
"Return the values that would be written to colvars.traj",
"Return the values that would be written to colvars.traj\n"
"values : string - The values\n",
0, 0,
"",
std::ostringstream os;
@ -307,7 +438,8 @@ CVSCRIPT(cv_printframe,
)
CVSCRIPT(cv_printframelabels,
"Return the labels that would be written to colvars.traj",
"Return the labels that would be written to colvars.traj\n"
"Labels : string - The labels",
0, 0,
"",
std::ostringstream os;
@ -348,14 +480,16 @@ CVSCRIPT(cv_save,
)
CVSCRIPT(cv_savetostring,
"Write the Colvars state to a string and return it",
"Write the Colvars state to a string and return it\n"
"state : string - The saved state",
0, 0,
"",
return script->module()->write_restart_string(script->modify_str_result());
)
CVSCRIPT(cv_units,
"Get or set the current Colvars unit system",
"Get or set the current Colvars unit system\n"
"units : string - The current unit system",
0, 1,
"units : string - The new unit system",
char const *argstr =
@ -390,7 +524,8 @@ CVSCRIPT(cv_update,
)
CVSCRIPT(cv_version,
"Get the Colvars Module version number",
"Get the Colvars Module version number\n"
"version : string - Colvars version",
0, 0,
"",
script->set_result_str(COLVARS_VERSION);