12 "Get the current grid bin index (flattened if more than 1d)\n"
13 "bin : integer - Bin index",
16 script->set_result_int(this_bias->current_bin());
22CVSCRIPT(bias_bincount,
23 "Get the number of samples at the given grid bin (1D ABF only for now)\n"
24 "samples : integer - Number of samples",
26 "index : integer - Grid index; defaults to current bin",
27 int index = this_bias->current_bin();
28 char const *indexarg =
29 script->obj_to_str(script->get_bias_cmd_arg(0, objc, objv));
31 std::string
const param(indexarg);
32 if (!(std::istringstream(param) >> index)) {
33 script->add_error_msg(
"bincount: error parsing bin index");
34 return COLVARSCRIPT_ERROR;
37 script->set_result_int(this_bias->bin_count(index));
41CVSCRIPT(bias_local_sample_count,
42 "Get the number of samples around the current bin"
43 "samples : integer - Number of samples",
45 "radius : integer - Sum over radius bins around current bin",
48 script->obj_to_str(script->get_bias_cmd_arg(0, objc, objv));
50 std::string
const param(arg);
51 if (!(std::istringstream(param) >> radius)) {
52 script->add_error_msg(
"local_sample_count: error parsing radius");
53 return COLVARSCRIPT_ERROR;
56 script->set_result_str(
cvm::to_str(this_bias->local_sample_count(radius)));
61 "Get the total number of grid points of this bias (1D ABF only for now)\n"
62 "Bins : integer - Number of grid points",
65 int r = this_bias->bin_num();
67 script->add_error_msg(
"Error: calling bin_num() for bias " +
69 return COLVARSCRIPT_ERROR;
71 script->set_result_int(r);
84 "Get the current energy of this bias\n"
85 "E : float - Energy value",
88 script->set_result_real(this_bias->get_energy());
93 "Get the value of the given feature for this bias\n"
94 "state : 1/0 - State of the given feature",
96 "feature : string - Name of the feature",
97 return script->proc_features(this_bias, objc, objv);
100CVSCRIPT(bias_getconfig,
101 "Return the configuration string of this bias\n"
102 "conf : string - Current configuration string",
105 script->set_result_str(this_bias->get_config());
110 "Get a help summary or the help string of one bias subcommand\n"
111 "help : string - Help string",
113 "command : string - Get the help string of this specific command",
114 unsigned char *
const cmdobj =
115 script->get_colvar_cmd_arg(0, objc, objv);
119 std::string
const cmdstr(script->obj_to_str(cmdobj));
121 script->set_result_str(script->get_command_cmdline_help(colvarscript::use_bias,
123 return cvm::get_error();
125 return COLVARSCRIPT_ERROR;
128 script->set_result_str(script->get_cmdline_help_summary(colvarscript::use_bias));
134 "Load data into this bias",
136 "prefix : string - Read from a file with this name or prefix",
138 script->obj_to_str(script->get_bias_cmd_arg(0, objc, objv));
139 return this_bias->read_state_prefix(std::string(arg));
142CVSCRIPT(bias_loadfromstring,
143 "Load state data into this bias from a string",
145 "buffer : string - String buffer containing the state information",
146 char const *buffer = script->obj_to_str(script->get_bias_cmd_arg(0, objc, objv));
147 return this_bias->read_state_string(buffer);
151 "Save data from this bias into a file with the given prefix",
153 "prefix : string - Prefix for the state file of this bias",
154 std::string
const prefix =
156 return this_bias->write_state_prefix(prefix);
159CVSCRIPT(bias_savetostring,
160 "Save data from this bias into a string and return it\n"
161 "state : string - The bias state",
164 return this_bias->write_state_string(script->modify_str_result());
168 "Set the given feature of this bias to a new value",
170 "feature : string - Name of the feature\n"
171 "value : string - String representation of the new feature value",
172 return script->proc_features(this_bias, objc, objv);
176 "Share bias information with other replicas (multiple-walker scheme)",
179 if (this_bias->replica_share() != COLVARS_OK) {
180 script->add_error_msg(
"Error: calling replica_share() for bias " +
182 return COLVARSCRIPT_ERROR;
188 "Print a string representation of the feature state of this bias\n"
189 "state : string - String representation of the bias features",
192 this_bias->print_state();
197 "Print the type of this bias object\n"
198 "type : string - Type of this bias object (e.g. metadynamics)",
201 script->set_result_str(this_bias->bias_type);
206 "Recompute this bias and return its up-to-date energy\n"
207 "E : float - Energy value",
211 script->set_result_colvarvalue(this_bias->get_energy());
static std::string state_file_prefix(char const *filename)
Strips .colvars.state from filename and checks that it is not empty.
Definition: colvarmodule.cpp:1524
static std::string to_str(char const *s)
Convert to string for output purposes.
Definition: colvarmodule.cpp:2392