Files
lammps/lib/colvars/colvarproxy_volmaps.cpp
Giacomo Fiorin 1220bea011 Update Colvars to version 2022-05-09
This update includes one new feature (neural-network based collective
variables), several small enhancements (including an automatic definition of
grid boundaries for angle-based CVs, and a normalization option for
eigenvector-based CVs), bugfixes and documentation improvements.

Usage information for specific features included in the Colvars library
(i.e. not just the library as a whole) is now also reported to the screen or
LAMMPS logfile (as is done already in other LAMMPS classes).

Notable to LAMMPS code development are the removals of duplicated code and of
ambiguously-named preprocessor defines in the Colvars headers.  Since the
last PR, the existing regression tests have also been running automatically
via GitHub Actions.

The following pull requests in the Colvars repository are relevant to LAMMPS:

- 475 Remove fatal error condition
  https://github.com/Colvars/colvars/pull/475 (@jhenin, @giacomofiorin)

- 474 Allow normalizing eigenvector vector components to deal with unit change
  https://github.com/Colvars/colvars/pull/474 (@giacomofiorin, @jhenin)

- 470 Better error handling in the initialization of NeuralNetwork CV
  https://github.com/Colvars/colvars/pull/470 (@HanatoK)

- 468 Add examples of histogram configuration, with and without explicit grid parameters
  https://github.com/Colvars/colvars/pull/468 (@giacomofiorin)

- 464 Fix #463 using more fine-grained features
  https://github.com/Colvars/colvars/pull/464 (@jhenin, @giacomofiorin)

- 447 [RFC] New option "scaledBiasingForce" for colvarbias
  https://github.com/Colvars/colvars/pull/447 (@HanatoK, @jhenin)

- 444 [RFC] Implementation of dense neural network as CV
  https://github.com/Colvars/colvars/pull/444 (@HanatoK, @giacomofiorin, @jhenin)

- 443 Fix explicit gradient dependency of sub-CVs
  https://github.com/Colvars/colvars/pull/443 (@HanatoK, @jhenin)

- 442 Persistent bias count
  https://github.com/Colvars/colvars/pull/442 (@jhenin, @giacomofiorin)

- 437 Return type of bias from scripting interface
  https://github.com/Colvars/colvars/pull/437 (@giacomofiorin)

- 434 More flexible use of boundaries from colvars by grids
  https://github.com/Colvars/colvars/pull/434 (@jhenin)

- 433 Prevent double-free in linearCombination
  https://github.com/Colvars/colvars/pull/433 (@HanatoK)

- 428 More complete documentation for index file format (NDX)
  https://github.com/Colvars/colvars/pull/428 (@giacomofiorin)

- 426 Integrate functional version of backup_file() into base proxy class
  https://github.com/Colvars/colvars/pull/426 (@giacomofiorin)

- 424 Track CVC inheritance when documenting feature usage
  https://github.com/Colvars/colvars/pull/424 (@giacomofiorin)

- 419 Generate citation report while running computations
  https://github.com/Colvars/colvars/pull/419 (@giacomofiorin, @jhenin)

- 415 Rebin metadynamics bias from explicit hills when available
  https://github.com/Colvars/colvars/pull/415 (@giacomofiorin)

- 312 Ignore a keyword if it has content to the left of it (regardless of braces)
  https://github.com/Colvars/colvars/pull/312 (@giacomofiorin)

Authors: @giacomofiorin, @HanatoK, @jhenin
2022-05-10 11:24:54 -04:00

135 lines
3.2 KiB
C++

// -*- c++ -*-
// This file is part of the Collective Variables module (Colvars).
// The original version of Colvars and its updates are located at:
// https://github.com/Colvars/colvars
// Please update all Colvars source files before making any changes.
// If you wish to distribute your changes, please submit them to the
// Colvars repository at GitHub.
#include "colvarmodule.h"
#include "colvarproxy_volmaps.h"
#include "colvarmodule_utils.h"
colvarproxy_volmaps::colvarproxy_volmaps()
{
volmaps_rms_applied_force_ = volmaps_max_applied_force_ = 0.0;
}
colvarproxy_volmaps::~colvarproxy_volmaps() {}
int colvarproxy_volmaps::volmaps_available()
{
return COLVARS_NOT_IMPLEMENTED;
}
int colvarproxy_volmaps::reset()
{
for (size_t i = 0; i < volmaps_ids.size(); i++) {
clear_volmap(i);
}
volmaps_ids.clear();
volmaps_ncopies.clear();
volmaps_values.clear();
volmaps_new_colvar_forces.clear();
return COLVARS_OK;
}
int colvarproxy_volmaps::add_volmap_slot(int volmap_id)
{
volmaps_ids.push_back(volmap_id);
volmaps_ncopies.push_back(1);
volmaps_values.push_back(0.0);
volmaps_new_colvar_forces.push_back(0.0);
return (volmaps_ids.size() - 1);
}
int colvarproxy_volmaps::check_volmap_by_id(int /* volmap_id */)
{
return cvm::error("Error: selecting volumetric maps is not available.\n",
COLVARS_NOT_IMPLEMENTED);
}
int colvarproxy_volmaps::check_volmap_by_name(const char * /* volmap_name */)
{
return cvm::error("Error: selecting volumetric maps by name is not "
"available.\n", COLVARS_NOT_IMPLEMENTED);
}
int colvarproxy_volmaps::init_volmap_by_name(char const * /* volmap_name */)
{
return -1;
}
int colvarproxy_volmaps::init_volmap_by_id(int /* volmap_id */)
{
return -1;
}
int colvarproxy_volmaps::init_volmap_by_name(std::string const &volmap_name)
{
return init_volmap_by_name(volmap_name.c_str());
}
int colvarproxy_volmaps::check_volmap_by_name(std::string const &volmap_name)
{
return check_volmap_by_name(volmap_name.c_str());
}
void colvarproxy_volmaps::clear_volmap(int index)
{
if (((size_t) index) >= volmaps_ids.size()) {
cvm::error("Error: trying to unrequest a volumetric map that was not "
"previously requested.\n", COLVARS_INPUT_ERROR);
}
if (volmaps_ncopies[index] > 0) {
volmaps_ncopies[index] -= 1;
}
}
int colvarproxy_volmaps::get_volmap_id_from_name(char const *volmap_name)
{
// Raise error
colvarproxy_volmaps::check_volmap_by_name(volmap_name);
return -1;
}
int colvarproxy_volmaps::compute_volmap(int /* flags */,
int /* volmap_id */,
cvm::atom_iter /* atom_begin */,
cvm::atom_iter /* atom_end */,
cvm::real * /* value */,
cvm::real * /* atom_field */)
{
return COLVARS_NOT_IMPLEMENTED;
}
void colvarproxy_volmaps::compute_rms_volmaps_applied_force()
{
volmaps_rms_applied_force_ =
compute_norm2_stats<cvm::real, 0, false>(volmaps_new_colvar_forces);
}
void colvarproxy_volmaps::compute_max_volmaps_applied_force()
{
volmaps_max_applied_force_ =
compute_norm2_stats<cvm::real, 1, false>(volmaps_new_colvar_forces);
}