#include <colvargrid.h>
Inheritance diagram for colvar_grid_scalar:

Public Member Functions | |
| colvar_grid_scalar () | |
| Default constructor. | |
| colvar_grid_scalar (colvar_grid_scalar const &g) | |
| Copy constructor (needed because of the grad pointer). | |
| ~colvar_grid_scalar () | |
| Destructor. | |
| colvar_grid_scalar (std::vector< int > const &nx_i) | |
| Constructor from specific sizes arrays. | |
| colvar_grid_scalar (std::vector< colvar * > &colvars, bool margin=0) | |
| Constructor from a vector of colvars. | |
| void | acc_value (std::vector< int > const &ix, cvm::real const &new_value, size_t const &imult=0) |
| Accumulate the value. | |
| const cvm::real * | gradient_finite_diff (const std::vector< int > &ix0) |
| Return the gradient of the scalar field from finite differences. | |
| virtual cvm::real | value_output (std::vector< int > const &ix, size_t const &imult=0) |
| Return the value of the function at ix divided by its number of samples (if the count grid is defined). | |
| virtual void | value_input (std::vector< int > const &ix, cvm::real const &new_value, size_t const &imult=0, bool add=false) |
| Get the value from a formatted output and transform it into the internal representation (it may have been rescaled or manipulated). | |
| std::istream & | read_restart (std::istream &is) |
| Read the grid from a restart. | |
| std::ostream & | write_restart (std::ostream &os) |
| Write the grid to a restart. | |
| cvm::real | maximum_value () |
| Return the highest value. | |
| cvm::real | minimum_value () |
| Return the lowest value. | |
Public Attributes | |
| colvar_grid_count * | samples |
| Provide the associated sample count by which each binned value should be divided. | |
Definition at line 918 of file colvargrid.h.
|
|
Default constructor.
Definition at line 50 of file colvargrid.C. References cvm. 00051 : colvar_grid<cvm::real>(), samples (NULL), grad (NULL) 00052 {}
|
|
|
Copy constructor (needed because of the grad pointer).
Definition at line 54 of file colvargrid.C. References cvm. 00055 : colvar_grid<cvm::real> (g), samples (NULL), grad (NULL) 00056 { 00057 grad = new cvm::real[nd]; 00058 }
|
|
|
Destructor.
Definition at line 72 of file colvargrid.C. 00073 {
00074 if (grad) {
00075 delete [] grad;
00076 grad = NULL;
00077 }
00078 }
|
|
|
Constructor from specific sizes arrays.
Definition at line 60 of file colvargrid.C. References cvm. 00061 : colvar_grid<cvm::real> (nx_i, 0.0, 1), samples (NULL) 00062 { 00063 grad = new cvm::real[nd]; 00064 }
|
|
||||||||||||
|
Constructor from a vector of colvars.
Definition at line 66 of file colvargrid.C. References cvm. 00067 : colvar_grid<cvm::real> (colvars, 0.0, 1, margin), samples (NULL) 00068 { 00069 grad = new cvm::real[nd]; 00070 }
|
|
||||||||||||||||
|
Accumulate the value.
Definition at line 943 of file colvargrid.h. References colvar_grid< cvm::real >::address(), colvar_grid_count::incr_count(), and samples. Referenced by colvarbias_meta::project_hills(). 00946 {
00947 // only legal value of imult here is 0
00948 data[address (ix)] += new_value;
00949 if (samples)
00950 samples->incr_count (ix);
00951 has_data = true;
00952 }
|
|
|
Return the gradient of the scalar field from finite differences.
Definition at line 955 of file colvargrid.h. References colvar_grid< cvm::real >::address(), colvarmodule::fatal_error(), and colvar_grid< cvm::real >::wrap(). 00956 {
00957 cvm::real A0, A1;
00958 std::vector<int> ix;
00959 if (nd != 2) cvm::fatal_error ("Finite differences available in dimension 2 only.");
00960 for (int n = 0; n < nd; n++) {
00961 ix = ix0;
00962 A0 = data[address (ix)];
00963 ix[n]++; wrap (ix);
00964 A1 = data[address (ix)];
00965 ix[1-n]++; wrap (ix);
00966 A1 += data[address (ix)];
00967 ix[n]--; wrap (ix);
00968 A0 += data[address (ix)];
00969 grad[n] = 0.5 * (A1 - A0) / widths[n];
00970 }
00971 return grad;
00972 }
|
|
|
Return the highest value.
Definition at line 1022 of file colvargrid.h. Referenced by colvarbias_meta::write_pmf(). 01023 {
01024 cvm::real max = data[0];
01025 for (size_t i = 0; i < nt; i++) {
01026 if (data[i] > max) max = data[i];
01027 }
01028 return max;
01029 }
|
|
|
Return the lowest value.
Definition at line 1032 of file colvargrid.h. 01033 {
01034 cvm::real min = data[0];
01035 for (size_t i = 0; i < nt; i++) {
01036 if (data[i] < min) min = data[i];
01037 }
01038 return min;
01039 }
|
|
|
Read the grid from a restart.
Definition at line 80 of file colvargrid.C. References colvarmodule::log(), colvar_grid< cvm::real >::parse_params(), and colvar_grid< cvm::real >::read_raw(). Referenced by colvarbias_meta::read_restart(). 00081 {
00082 size_t const start_pos = is.tellg();
00083 std::string key, conf;
00084 if ((is >> key) && (key == std::string ("grid_parameters"))) {
00085 is.seekg (start_pos, std::ios::beg);
00086 is >> colvarparse::read_block ("grid_parameters", conf);
00087 parse_params (conf);
00088 } else {
00089 cvm::log ("Grid parameters are missing in the restart file, using those from the configuration.\n");
00090 is.seekg (start_pos, std::ios::beg);
00091 }
00092 read_raw (is);
00093 return is;
00094 }
|
|
||||||||||||||||||||
|
Get the value from a formatted output and transform it into the internal representation (it may have been rescaled or manipulated).
Reimplemented from colvar_grid< cvm::real >. Definition at line 993 of file colvargrid.h. References colvar_grid< cvm::real >::address(), colvarmodule::fatal_error(), colvar_grid_count::new_count(), samples, and colvar_grid< T >::value(). 00997 {
00998 if (imult > 0)
00999 cvm::fatal_error ("Error: trying to access a component "
01000 "larger than 1 in a scalar data grid.\n");
01001 if (add) {
01002 if (samples)
01003 data[address (ix)] += new_value * samples->new_count (ix);
01004 else
01005 data[address (ix)] += new_value;
01006 } else {
01007 if (samples)
01008 data[address (ix)] = new_value * samples->value (ix);
01009 else
01010 data[address (ix)] = new_value;
01011 }
01012 has_data = true;
01013 }
|
|
||||||||||||
|
Return the value of the function at ix divided by its number of samples (if the count grid is defined).
Reimplemented from colvar_grid< cvm::real >. Definition at line 976 of file colvargrid.h. References colvar_grid< cvm::real >::address(), colvarmodule::fatal_error(), colvarmodule::real, samples, and colvar_grid< T >::value(). 00978 {
00979 if (imult > 0)
00980 cvm::fatal_error ("Error: trying to access a component "
00981 "larger than 1 in a scalar data grid.\n");
00982 if (samples)
00983 return (samples->value (ix) > 0) ?
00984 (data[address (ix)] / cvm::real (samples->value (ix))) :
00985 0.0;
00986 else
00987 return data[address (ix)];
00988 }
|
|
|
Write the grid to a restart.
Definition at line 96 of file colvargrid.C. References colvar_grid< cvm::real >::write_params(), and colvar_grid< cvm::real >::write_raw(). Referenced by colvarbias_meta::write_replica_state_file(), and colvarbias_meta::write_restart(). 00097 {
00098 write_params (os);
00099 write_raw (os);
00100 return os;
00101 }
|
|
|
Provide the associated sample count by which each binned value should be divided.
Definition at line 924 of file colvargrid.h. Referenced by acc_value(), value_input(), and value_output(). |
1.3.9.1