Files
lammps/lib/colvars/colvarproxy_volmaps.h
Giacomo Fiorin 377c652a83 Update Colvars library to version 2023-05-01
This update consists exclusively of bugfixes or maintenance-related changes.

The following is a list of pull requests in the Colvars repository since the previous update to LAMMPS:

- 532 Add XYZ trajectory reading feature
  https://github.com/Colvars/colvars/pull/532 (@jhenin, @giacomofiorin)

- 531 Delete objects quietly, unless explicitly requested via script (including VMD)
  https://github.com/Colvars/colvars/pull/531 (@giacomofiorin)

- 530 Append newline to log and error messages if not already present
  https://github.com/Colvars/colvars/pull/530 (@giacomofiorin)

- 528 Forward-declare OpenMP lock
  https://github.com/Colvars/colvars/pull/528 (@giacomofiorin)

- 527 Remove unneeded STL container
  https://github.com/Colvars/colvars/pull/527 (@giacomofiorin)

- 526 Allow collecting configuration files and strings before setting up interface
  https://github.com/Colvars/colvars/pull/526 (@giacomofiorin, @jhenin)

- 523 Fallback to linearCombination when customFunction is missing in customColvar
  https://github.com/Colvars/colvars/pull/523 (@HanatoK, @giacomofiorin)

- 522 Use iostream::fail() to check for I/O error
  https://github.com/Colvars/colvars/pull/522 (@jhenin)

- 520 Fix ref count
  https://github.com/Colvars/colvars/pull/520 (@giacomofiorin)

- 513 Set target temperature through a common code path
  https://github.com/Colvars/colvars/pull/513 (@giacomofiorin, @jhenin)

- 509 Safer detection of Windows with recent Microsoft Visual Studio versions
  https://github.com/Colvars/colvars/pull/509 (@akohlmey)

- 508 Update LAMMPS patching method to reflect Lepton availability
  https://github.com/Colvars/colvars/pull/508 (@giacomofiorin)

- 497 Increase the precision of write_multicol
  https://github.com/Colvars/colvars/pull/497 (@HanatoK)

- 496 Only perform MTS automatic enable/disable for timeStepFactor > 1
  https://github.com/Colvars/colvars/pull/496 (@giacomofiorin)

- 493 Remove unused branch of quaternion input function
  https://github.com/Colvars/colvars/pull/493 (@giacomofiorin)

- 489 Ensure there are spaces between the fields in the header
  https://github.com/Colvars/colvars/pull/489 (@HanatoK)

- 487 Use map of output streams, and return references to its elements
  https://github.com/Colvars/colvars/pull/487 (@giacomofiorin, @jhenin)

- 486 Remember first step of moving restraint
  https://github.com/Colvars/colvars/pull/486 (@jhenin)

- 485 Add decoupling option for moving restraints
  https://github.com/Colvars/colvars/pull/485 (@jhenin)

- 483 Update Lepton via patching procedure
  https://github.com/Colvars/colvars/pull/483 (@giacomofiorin)

- 481 Make file-reading operations of input data abstractable
  https://github.com/Colvars/colvars/pull/481 (@giacomofiorin)

Authors: @akohlmey, @giacomofiorin, @HanatoK, @jhenin
2023-05-17 13:29:00 -04:00

129 lines
4.1 KiB
C++

// -*- c++ -*-
#ifndef COLVARPROXY_VOLMAPS_H
#define COLVARPROXY_VOLMAPS_H
/// \brief Container of grid-based objects
class colvarproxy_volmaps {
public:
/// Contructor
colvarproxy_volmaps();
/// Destructor
virtual ~colvarproxy_volmaps();
/// Clear volumetric map data
int reset();
/// \brief Whether this implementation has capability to use volumetric maps
virtual int volmaps_available();
/// Create a slot for a volumetric map not requested yet
int add_volmap_slot(int volmap_id);
/// Request and prepare this volumetric map for use by Colvars
/// \param volmap_id Numeric ID used by the MD engine
/// \returns Index of the map in the colvarproxy arrays
virtual int init_volmap_by_id(int volmap_id);
/// Request and prepare this volumetric map for use by Colvars
/// \param volmap_name Name used by the MD engine
/// \returns Index of the map in the colvarproxy arrays
virtual int init_volmap_by_name(char const *volmap_name);
/// Check that the given volmap ID is valid (return COLVARS_OK if it is)
/// \param volmap_id Numeric ID used by the MD engine
/// \returns Error code
virtual int check_volmap_by_id(int volmap_id);
/// Check that the given volmap name is valid (return COLVARS_OK if it is)
/// \param volmap_name Name used by the MD engine
/// \returns Error code
virtual int check_volmap_by_name(char const *volmap_name);
/// Request and prepare this volumetric map for use by Colvars
int init_volmap_by_name(std::string const &volmap_name);
/// Check that the given volmap name is valid (return COLVARS_OK if it is)
int check_volmap_by_name(std::string const &volmap_name);
/// \brief Used by the CVC destructors
virtual void clear_volmap(int index);
/// Get the numeric ID of the given volumetric map (for the MD program)
virtual int get_volmap_id_from_name(char const *volmap_name);
/// Get the numeric ID of the given volumetric map (for the MD program)
inline int get_volmap_id(int index) const
{
return volmaps_ids[index];
}
/// Read the current value of the volumetric map
inline cvm::real get_volmap_value(int index) const
{
return volmaps_values[index];
}
/// Request that this force is applied to the given volumetric map
inline void apply_volmap_force(int index, cvm::real const &new_force)
{
volmaps_new_colvar_forces[index] += new_force;
}
/// Re-weigh an atomic field (e.g. a colvar) by the value of a volumetric map
/// \param flags Combination of flags
/// \param volmap_id Numeric index of the map (no need to request it)
/// \param atom_begin Iterator pointing to first atom
/// \param atom_end Iterator pointing past the last atom
/// \param value Pointer to location of total to increment
/// \param atom_field Array of atomic field values (if NULL, ones are used)
virtual int compute_volmap(int flags,
int volmap_id,
cvm::atom_iter atom_begin,
cvm::atom_iter atom_end,
cvm::real *value,
cvm::real *atom_field);
/// Flags controlling what computation is done on the map
enum {
volmap_flag_null = 0,
volmap_flag_gradients = 1,
volmap_flag_use_atom_field = (1<<8)
};
/// Compute the root-mean-square of the applied forces
void compute_rms_volmaps_applied_force();
/// Compute the maximum norm among all applied forces
void compute_max_volmaps_applied_force();
protected:
/// \brief Array of numeric IDs of volumetric maps
std::vector<int> volmaps_ids;
/// \brief Keep track of how many times each vol map is used by a
/// separate colvar object
std::vector<size_t> volmaps_refcount;
/// \brief Current values of the vol maps
std::vector<cvm::real> volmaps_values;
/// \brief Forces applied from colvars, to be communicated to the MD
/// integrator
std::vector<cvm::real> volmaps_new_colvar_forces;
/// Root-mean-square of the the applied forces
cvm::real volmaps_rms_applied_force_;
/// Maximum norm among all applied forces
cvm::real volmaps_max_applied_force_;
};
#endif