git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13444 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2015-04-30 14:09:42 +00:00
parent 71df48bd6a
commit f539e43b22
22 changed files with 438 additions and 625 deletions

View File

@ -1,4 +1,4 @@
# library build makefile for colvars module
# library build -*- makefile -*- for colvars module
# which file will be copied to Makefile.lammps
@ -16,11 +16,11 @@ SHELL = /bin/sh
# ------ DEFINITIONS ------
SRC = colvaratoms.cpp colvarbias_abf.cpp colvarbias_alb.cpp colvarbias.cpp \
colvarbias_meta.cpp colvarbias_restraint.cpp colvarcomp_angles.cpp \
colvarcomp_coordnums.cpp colvarcomp.cpp colvarcomp_distances.cpp \
colvarcomp_protein.cpp colvarcomp_rotations.cpp colvar.cpp colvargrid.cpp \
colvarmodule.cpp colvarparse.cpp colvarscript.cpp colvartypes.cpp \
colvarvalue.cpp
colvarbias_histogram.cpp colvarbias_meta.cpp colvarbias_restraint.cpp \
colvarcomp_angles.cpp colvarcomp_coordnums.cpp colvarcomp.cpp \
colvarcomp_distances.cpp colvarcomp_protein.cpp colvarcomp_rotations.cpp \
colvar.cpp colvargrid.cpp colvarmodule.cpp colvarparse.cpp \
colvarscript.cpp colvartypes.cpp colvarvalue.cpp
LIB = libcolvars.a
OBJ = $(SRC:.cpp=.o)
@ -63,6 +63,9 @@ colvarbias_alb.o: colvarbias_alb.cpp colvarmodule.h colvartypes.h \
colvarbias_restraint.h colvarbias.h
colvarbias.o: colvarbias.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarvalue.h colvarbias.h colvar.h colvarparse.h
colvarbias_histogram.o: colvarbias_histogram.cpp colvarmodule.h \
colvartypes.h colvarproxy.h colvarvalue.h colvar.h colvarparse.h \
colvarbias_histogram.h colvarbias.h colvargrid.h
colvarbias_meta.o: colvarbias_meta.cpp colvar.h colvarmodule.h \
colvartypes.h colvarproxy.h colvarvalue.h colvarparse.h \
colvarbias_meta.h colvarbias.h colvargrid.h
@ -93,9 +96,9 @@ colvargrid.o: colvargrid.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarvalue.h colvarparse.h colvar.h colvarcomp.h colvaratoms.h \
colvargrid.h
colvarmodule.o: colvarmodule.cpp colvarmodule.h colvartypes.h \
colvarproxy.h colvarparse.h colvarvalue.h colvar.h colvarbias.h \
colvarbias_alb.h colvarbias_restraint.h colvarbias_meta.h colvargrid.h \
colvarbias_abf.h colvarscript.h
colvarproxy.h colvarvalue.h colvarparse.h colvar.h colvarbias.h \
colvarbias_abf.h colvargrid.h colvarbias_alb.h colvarbias_restraint.h \
colvarbias_histogram.h colvarbias_meta.h colvarscript.h
colvarparse.o: colvarparse.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarvalue.h colvarparse.h
colvarscript.o: colvarscript.cpp colvarscript.h colvarmodule.h \

View File

@ -15,11 +15,11 @@ SHELL = /bin/sh
# ------ DEFINITIONS ------
SRC = colvaratoms.cpp colvarbias_abf.cpp colvarbias_alb.cpp colvarbias.cpp \
colvarbias_meta.cpp colvarbias_restraint.cpp colvarcomp_angles.cpp \
colvarcomp_coordnums.cpp colvarcomp.cpp colvarcomp_distances.cpp \
colvarcomp_protein.cpp colvarcomp_rotations.cpp colvar.cpp colvargrid.cpp \
colvarmodule.cpp colvarparse.cpp colvarscript.cpp colvartypes.cpp \
colvarvalue.cpp
colvarbias_histogram.cpp colvarbias_meta.cpp colvarbias_restraint.cpp \
colvarcomp_angles.cpp colvarcomp_coordnums.cpp colvarcomp.cpp \
colvarcomp_distances.cpp colvarcomp_protein.cpp colvarcomp_rotations.cpp \
colvar.cpp colvargrid.cpp colvarmodule.cpp colvarparse.cpp \
colvarscript.cpp colvartypes.cpp colvarvalue.cpp
LIB = libcolvars.a
OBJ = $(SRC:.cpp=.o)
@ -53,15 +53,18 @@ colvars_standalone: colvars_main.o colvarproxy_standalone.o $(LIB)
# ------ DEPENDENCIES ------
#
colvaratoms.o: colvaratoms.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarparse.h colvarvalue.h colvaratoms.h
colvarvalue.h colvarparse.h colvaratoms.h
colvarbias_abf.o: colvarbias_abf.cpp colvarmodule.h colvartypes.h \
colvarproxy.h colvar.h colvarvalue.h colvarparse.h colvarbias_abf.h \
colvarproxy.h colvarvalue.h colvar.h colvarparse.h colvarbias_abf.h \
colvarbias.h colvargrid.h
colvarbias_alb.o: colvarbias_alb.cpp colvarmodule.h colvartypes.h \
colvarproxy.h colvarbias_alb.h colvar.h colvarvalue.h colvarparse.h \
colvarproxy.h colvarvalue.h colvarbias_alb.h colvar.h colvarparse.h \
colvarbias_restraint.h colvarbias.h
colvarbias.o: colvarbias.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarvalue.h colvarbias.h colvar.h colvarparse.h
colvarbias_histogram.o: colvarbias_histogram.cpp colvarmodule.h \
colvartypes.h colvarproxy.h colvarvalue.h colvar.h colvarparse.h \
colvarbias_histogram.h colvarbias.h colvargrid.h
colvarbias_meta.o: colvarbias_meta.cpp colvar.h colvarmodule.h \
colvartypes.h colvarproxy.h colvarvalue.h colvarparse.h \
colvarbias_meta.h colvarbias.h colvargrid.h
@ -69,10 +72,10 @@ colvarbias_restraint.o: colvarbias_restraint.cpp colvarmodule.h \
colvartypes.h colvarproxy.h colvarvalue.h colvarbias_restraint.h \
colvarbias.h colvar.h colvarparse.h
colvarcomp_angles.o: colvarcomp_angles.cpp colvarmodule.h colvartypes.h \
colvarproxy.h colvar.h colvarvalue.h colvarparse.h colvarcomp.h \
colvarproxy.h colvarvalue.h colvar.h colvarparse.h colvarcomp.h \
colvaratoms.h
colvarcomp_coordnums.o: colvarcomp_coordnums.cpp colvarmodule.h \
colvartypes.h colvarproxy.h colvarparse.h colvarvalue.h colvaratoms.h \
colvartypes.h colvarproxy.h colvarvalue.h colvarparse.h colvaratoms.h \
colvar.h colvarcomp.h
colvarcomp.o: colvarcomp.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarvalue.h colvar.h colvarparse.h colvarcomp.h colvaratoms.h
@ -92,16 +95,16 @@ colvargrid.o: colvargrid.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarvalue.h colvarparse.h colvar.h colvarcomp.h colvaratoms.h \
colvargrid.h
colvarmodule.o: colvarmodule.cpp colvarmodule.h colvartypes.h \
colvarproxy.h colvarparse.h colvarvalue.h colvar.h colvarbias.h \
colvarbias_alb.h colvarbias_restraint.h colvarbias_meta.h colvargrid.h \
colvarbias_abf.h colvarscript.h
colvarproxy.h colvarvalue.h colvarparse.h colvar.h colvarbias.h \
colvarbias_abf.h colvargrid.h colvarbias_alb.h colvarbias_restraint.h \
colvarbias_histogram.h colvarbias_meta.h colvarscript.h
colvarparse.o: colvarparse.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarvalue.h colvarparse.h
colvarscript.o: colvarscript.cpp colvarscript.h colvarmodule.h \
colvartypes.h colvarproxy.h colvarvalue.h colvar.h colvarparse.h \
colvarbias.h
colvartypes.h colvarproxy.h colvarvalue.h colvarbias.h colvar.h \
colvarparse.h
colvartypes.o: colvartypes.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarparse.h colvarvalue.h
colvarvalue.h colvarparse.h
colvarvalue.o: colvarvalue.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarvalue.h

View File

@ -18,11 +18,11 @@ SHELL = /bin/sh
# ------ DEFINITIONS ------
SRC = colvaratoms.cpp colvarbias_abf.cpp colvarbias_alb.cpp colvarbias.cpp \
colvarbias_meta.cpp colvarbias_restraint.cpp colvarcomp_angles.cpp \
colvarcomp_coordnums.cpp colvarcomp.cpp colvarcomp_distances.cpp \
colvarcomp_protein.cpp colvarcomp_rotations.cpp colvar.cpp colvargrid.cpp \
colvarmodule.cpp colvarparse.cpp colvarscript.cpp colvartypes.cpp \
colvarvalue.cpp
colvarbias_histogram.cpp colvarbias_meta.cpp colvarbias_restraint.cpp \
colvarcomp_angles.cpp colvarcomp_coordnums.cpp colvarcomp.cpp \
colvarcomp_distances.cpp colvarcomp_protein.cpp colvarcomp_rotations.cpp \
colvar.cpp colvargrid.cpp colvarmodule.cpp colvarparse.cpp \
colvarscript.cpp colvartypes.cpp colvarvalue.cpp
DIR = Obj_mingw32/
LIB = $(DIR)libcolvars.a
@ -70,6 +70,9 @@ $(DIR)colvarbias_alb.o: colvarbias_alb.cpp colvarmodule.h colvartypes.h \
colvarbias_restraint.h colvarbias.h
$(DIR)colvarbias.o: colvarbias.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarvalue.h colvarbias.h colvar.h colvarparse.h
$(DIR)colvarbias_histogram.o: colvarbias_histogram.cpp colvarmodule.h \
colvartypes.h colvarproxy.h colvarvalue.h colvar.h colvarparse.h \
colvarbias_histogram.h colvarbias.h colvargrid.h
$(DIR)colvarbias_meta.o: colvarbias_meta.cpp colvar.h colvarmodule.h \
colvartypes.h colvarproxy.h colvarvalue.h colvarparse.h \
colvarbias_meta.h colvarbias.h colvargrid.h
@ -100,9 +103,9 @@ $(DIR)colvargrid.o: colvargrid.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarvalue.h colvarparse.h colvar.h colvarcomp.h colvaratoms.h \
colvargrid.h
$(DIR)colvarmodule.o: colvarmodule.cpp colvarmodule.h colvartypes.h \
colvarproxy.h colvarparse.h colvarvalue.h colvar.h colvarbias.h \
colvarbias_alb.h colvarbias_restraint.h colvarbias_meta.h colvargrid.h \
colvarbias_abf.h colvarscript.h
colvarproxy.h colvarvalue.h colvarparse.h colvar.h colvarbias.h \
colvarbias_abf.h colvargrid.h colvarbias_alb.h colvarbias_restraint.h \
colvarbias_histogram.h colvarbias_meta.h colvarscript.h
$(DIR)colvarparse.o: colvarparse.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarvalue.h colvarparse.h
$(DIR)colvarscript.o: colvarscript.cpp colvarscript.h colvarmodule.h \
@ -118,4 +121,3 @@ $(DIR)colvarvalue.o: colvarvalue.cpp colvarmodule.h colvartypes.h colvarproxy.h
clean:
-rm $(DIR)*.o *~ $(LIB)
-rmdir $(DIR)

View File

@ -18,11 +18,11 @@ SHELL = /bin/sh
# ------ DEFINITIONS ------
SRC = colvaratoms.cpp colvarbias_abf.cpp colvarbias_alb.cpp colvarbias.cpp \
colvarbias_meta.cpp colvarbias_restraint.cpp colvarcomp_angles.cpp \
colvarcomp_coordnums.cpp colvarcomp.cpp colvarcomp_distances.cpp \
colvarcomp_protein.cpp colvarcomp_rotations.cpp colvar.cpp colvargrid.cpp \
colvarmodule.cpp colvarparse.cpp colvarscript.cpp colvartypes.cpp \
colvarvalue.cpp
colvarbias_histogram.cpp colvarbias_meta.cpp colvarbias_restraint.cpp \
colvarcomp_angles.cpp colvarcomp_coordnums.cpp colvarcomp.cpp \
colvarcomp_distances.cpp colvarcomp_protein.cpp colvarcomp_rotations.cpp \
colvar.cpp colvargrid.cpp colvarmodule.cpp colvarparse.cpp \
colvarscript.cpp colvartypes.cpp colvarvalue.cpp
DIR = Obj_mingw64/
LIB = $(DIR)libcolvars.a
@ -41,6 +41,7 @@ Makefile.lammps:
$(LIB): $(DIR) $(OBJ)
$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
@cp $(EXTRAMAKE) Makefile.lammps
$(DIR)colvars_standalone: colvars_main.o colvarproxy_standalone.o $(LIB)
$(CXX) -o $@ $(CXXFLAGS) $^
@ -69,6 +70,9 @@ $(DIR)colvarbias_alb.o: colvarbias_alb.cpp colvarmodule.h colvartypes.h \
colvarbias_restraint.h colvarbias.h
$(DIR)colvarbias.o: colvarbias.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarvalue.h colvarbias.h colvar.h colvarparse.h
$(DIR)colvarbias_histogram.o: colvarbias_histogram.cpp colvarmodule.h \
colvartypes.h colvarproxy.h colvarvalue.h colvar.h colvarparse.h \
colvarbias_histogram.h colvarbias.h colvargrid.h
$(DIR)colvarbias_meta.o: colvarbias_meta.cpp colvar.h colvarmodule.h \
colvartypes.h colvarproxy.h colvarvalue.h colvarparse.h \
colvarbias_meta.h colvarbias.h colvargrid.h
@ -99,9 +103,9 @@ $(DIR)colvargrid.o: colvargrid.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarvalue.h colvarparse.h colvar.h colvarcomp.h colvaratoms.h \
colvargrid.h
$(DIR)colvarmodule.o: colvarmodule.cpp colvarmodule.h colvartypes.h \
colvarproxy.h colvarparse.h colvarvalue.h colvar.h colvarbias.h \
colvarbias_alb.h colvarbias_restraint.h colvarbias_meta.h colvargrid.h \
colvarbias_abf.h colvarscript.h
colvarproxy.h colvarvalue.h colvarparse.h colvar.h colvarbias.h \
colvarbias_abf.h colvargrid.h colvarbias_alb.h colvarbias_restraint.h \
colvarbias_histogram.h colvarbias_meta.h colvarscript.h
$(DIR)colvarparse.o: colvarparse.cpp colvarmodule.h colvartypes.h colvarproxy.h \
colvarvalue.h colvarparse.h
$(DIR)colvarscript.o: colvarscript.cpp colvarscript.h colvarmodule.h \

View File

@ -20,9 +20,10 @@ colvar::colvar(std::string const &conf)
(std::string("colvar")+cvm::to_str(cvm::colvars.size()+1)));
if (cvm::colvar_by_name(this->name) != NULL) {
cvm::error("Error: this colvar cannot have the same name, \""+this->name+
cvm::error("Error: this colvar cannot have the same name, \""+this->name+
"\", as another colvar.\n",
INPUT_ERROR);
return;
}
// all tasks disabled by default
@ -1616,7 +1617,7 @@ int colvar::write_output_files()
// ******************** ANALYSIS FUNCTIONS ********************
void colvar::analyse()
void colvar::analyze()
{
if (tasks[task_runave]) {
calc_runave();

View File

@ -361,7 +361,7 @@ public:
/// Read the analysis tasks
int parse_analysis(std::string const &conf);
/// Perform analysis tasks
void analyse();
void analyze();
/// Read the value from a collective variable trajectory file

View File

@ -331,8 +331,6 @@ int cvm::atom_group::parse(std::string const &conf,
} else {
get_keyval(group_conf, "disableForces", noforce, false, colvarparse::parse_silent);
}
get_keyval(group_conf, "weights", weights, weights, colvarparse::parse_silent);
}
// FITTING OPTIONS
@ -380,12 +378,12 @@ int cvm::atom_group::parse(std::string const &conf,
}
std::string ref_pos_col;
double ref_pos_col_value;
double ref_pos_col_value=0.0;
if (get_keyval(group_conf, "refPositionsCol", ref_pos_col, std::string(""), mode)) {
// if provided, use PDB column to select coordinates
bool found = get_keyval(group_conf, "refPositionsColValue", ref_pos_col_value, 0.0, mode);
if (found && !ref_pos_col_value)
if (found && ref_pos_col_value == 0.0)
cvm::error("Error: refPositionsColValue, "
"if provided, must be non-zero.\n");
} else {

View File

@ -139,10 +139,6 @@ public:
/// Allocates and populates the sorted list of atom ids
int create_sorted_ids(void);
/// List of user-defined weights to be used by certain CVCs
std::vector<cvm::real> weights;
/// \brief When updating atomic coordinates, translate them to align with the
/// center of mass of the reference coordinates
bool b_center;

View File

@ -39,15 +39,12 @@ public:
virtual int replica_share();
/// Perform analysis tasks
virtual inline void analyse() {}
virtual void analyze() {}
/// Send forces to the collective variables
void communicate_forces();
/// \brief Constructor
///
/// The constructor of the colvarbias base class is protected, so
/// that it can only be called from inherited classes
colvarbias(std::string const &conf, char const *key);
/// Default constructor
@ -65,9 +62,18 @@ public:
/// Write a label to the trajectory file (comment line)
virtual std::ostream & write_traj_label(std::ostream &os);
/// (Re)initialize the output files (does not write them yet)
virtual int setup_output() { return COLVARS_OK; }
/// Output quantities such as the bias energy to the trajectory file
virtual std::ostream & write_traj(std::ostream &os);
/// Write output files (if defined, e.g. in analysis mode)
virtual int write_output_files()
{
return COLVARS_OK;
}
inline cvm::real get_energy() {
return bias_energy;
}

View File

@ -1,9 +1,5 @@
/// -*- c++ -*-
/********************************************************************************
* Implementation of the ABF and histogram biases *
********************************************************************************/
#include "colvarmodule.h"
#include "colvar.h"
#include "colvarbias_abf.h"
@ -47,7 +43,7 @@ colvarbias_abf::colvarbias_abf(std::string const &conf, char const *key)
// shared ABF
get_keyval(conf, "shared", shared_on, false);
if (shared_on) {
if (!cvm::replica_enabled || cvm::replica_num() <= 1)
if (!cvm::replica_enabled() || cvm::replica_num() <= 1)
cvm::error("Error: shared ABF requires more than one replica.");
else
cvm::log("shared ABF will be applied among "+ cvm::to_str(cvm::replica_num()) + " replicas.\n");
@ -552,202 +548,3 @@ std::istream & colvarbias_abf::read_restart(std::istream& is)
}
return is;
}
/// Histogram "bias" constructor
colvarbias_histogram::colvarbias_histogram(std::string const &conf, char const *key)
: colvarbias(conf, key),
grid(NULL), out_name("")
{
get_keyval(conf, "outputFreq", output_freq, cvm::restart_out_freq);
/// with VMD, this may not be an error
// if ( output_freq == 0 ) {
// cvm::error("User required histogram with zero output frequency");
// }
{
colvar_array_size = 1;
bool colvar_array = false;
if (get_keyval(conf, "sumVectorColvars", colvar_array, colvar_array)) {
size_t i;
for (i = 0; i < colvars.size(); i++) {
if (colvars[i]->value().type() == colvarvalue::type_vector) {
if (colvar_array_size == 1) {
colvar_array_size = colvars[i]->value().size();
} else {
if (colvar_array_size != colvars[i]->value().size()) {
cvm::error("Error: trying to combine vector colvars of different lengths.\n", INPUT_ERROR);
}
}
}
}
}
}
grid = new colvar_grid_count();
{
std::string grid_conf;
if (key_lookup(conf, "grid", grid_conf)) {
grid->parse_params(grid_conf);
} else {
grid->init_from_colvars(colvars);
}
}
bin.assign(colvars.size(), 0);
cvm::log("Finished histogram setup.\n");
}
/// Destructor
colvarbias_histogram::~colvarbias_histogram()
{
if (grid_os.is_open())
grid_os.close();
if (grid) {
delete grid;
grid = NULL;
}
if (cvm::n_histo_biases > 0)
cvm::n_histo_biases -= 1;
}
/// Update the grid
cvm::real colvarbias_histogram::update()
{
if (cvm::debug()) {
cvm::log("Updating histogram bias " + this->name);
}
// At the first timestep, we need to assign out_name since
// output_prefix is unset during the constructor
if (cvm::step_relative() == 0) {
out_name = cvm::output_prefix + "." + this->name + ".dat";
cvm::log("Histogram " + this->name + " will be written to file \"" + out_name + "\"");
}
bin.assign(colvars.size(), 0);
{
// update indices for all scalar values
size_t i;
for (i = 0; i < colvars.size(); i++) {
if (colvars[i]->value().type() == colvarvalue::type_scalar) {
bin[i] = grid->value_to_bin_scalar(colvars[i]->value(), i);
}
}
}
if (colvar_array_size > 1) {
// update indices for all vector/array values
size_t iv, i;
for (iv = 0; iv < colvar_array_size; iv++) {
for (i = 0; i < colvars.size(); i++) {
if (colvars[i]->value().type() == colvarvalue::type_vector) {
bin[i] = grid->value_to_bin_scalar(colvars[i]->value().vector1d_value[iv], i);
}
}
if (grid->index_ok(bin)) {
// Only within bounds of the grid...
grid->incr_count(bin);
}
}
} else {
if (grid->index_ok(bin)) {
// Only within bounds of the grid...
grid->incr_count(bin);
}
}
if (output_freq && (cvm::step_absolute() % output_freq) == 0) {
if (cvm::debug()) cvm::log("Histogram bias trying to write grid to disk");
grid_os.open(out_name.c_str());
if (!grid_os.is_open()) cvm::error("Error opening histogram file " + out_name + " for writing");
grid->write_multicol(grid_os);
grid_os.close();
}
return 0.0; // no bias energy for histogram
}
std::istream & colvarbias_histogram::read_restart(std::istream& is)
{
size_t const start_pos = is.tellg();
cvm::log("Restarting collective variable histogram \""+
this->name+"\".\n");
std::string key, brace, conf;
if ( !(is >> key) || !(key == "histogram") ||
!(is >> brace) || !(brace == "{") ||
!(is >> colvarparse::read_block("configuration", conf)) ) {
cvm::log("Error: in reading restart configuration for histogram \""+
this->name+"\" at position "+
cvm::to_str(is.tellg())+" in stream.\n");
is.clear();
is.seekg(start_pos, std::ios::beg);
is.setstate(std::ios::failbit);
return is;
}
int id = -1;
std::string name = "";
if ( (colvarparse::get_keyval(conf, "name", name, std::string(""), colvarparse::parse_silent)) &&
(name != this->name) )
cvm::error("Error: in the restart file, the "
"\"histogram\" block has a wrong name: different system?\n");
if ( (id == -1) && (name == "") ) {
cvm::error("Error: \"histogram\" block in the restart file "
"has no name.\n");
}
if ( !(is >> key) || !(key == "grid")) {
cvm::error("Error: in reading restart configuration for histogram \""+
this->name+"\" at position "+
cvm::to_str(is.tellg())+" in stream.\n");
is.clear();
is.seekg(start_pos, std::ios::beg);
is.setstate(std::ios::failbit);
return is;
}
if (! grid->read_raw(is)) {
is.clear();
is.seekg(start_pos, std::ios::beg);
is.setstate(std::ios::failbit);
return is;
}
is >> brace;
if (brace != "}") {
cvm::error("Error: corrupt restart information for ABF bias \""+
this->name+"\": no matching brace at position "+
cvm::to_str(is.tellg())+" in the restart file.\n");
is.setstate(std::ios::failbit);
}
return is;
}
std::ostream & colvarbias_histogram::write_restart(std::ostream& os)
{
os << "histogram {\n"
<< " configuration {\n"
<< " name " << this->name << "\n";
os << " }\n";
os << "grid\n";
grid->write_raw(os, 8);
os << "}\n\n";
return os;
}

View File

@ -1,7 +1,4 @@
// -*- c++ -*-
/************************************************************************
* Headers for the ABF and histogram biases *
************************************************************************/
#ifndef COLVARBIAS_ABF_H
#define COLVARBIAS_ABF_H
@ -40,7 +37,7 @@ private:
bool hide_Jacobian;
size_t full_samples;
size_t min_samples;
/// frequency for updating output files (default: same as restartFreq?)
/// frequency for updating output files
int output_freq;
/// Write combined files with a history of all output data?
bool b_history_files;
@ -90,34 +87,5 @@ private:
std::ostream& write_restart(std::ostream&);
};
/// Histogram "bias" (does as the name says)
class colvarbias_histogram : public colvarbias {
public:
colvarbias_histogram(std::string const &conf, char const *key);
~colvarbias_histogram();
cvm::real update();
protected:
/// n-dim histogram
colvar_grid_count *grid;
std::vector<int> bin;
std::string out_name;
int output_freq;
/// If one or more of the variables are \link type_vector \endlink, treat them as arrays of this length
size_t colvar_array_size;
void write_grid();
cvm::ofstream grid_os; /// Stream for writing grid to disk
std::istream& read_restart(std::istream&);
std::ostream& write_restart(std::ostream&);
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -42,6 +42,8 @@ public:
virtual std::ostream & write_restart(std::ostream &os);
virtual int setup_output();
virtual void write_pmf();
class hill;

View File

@ -110,7 +110,7 @@ protected:
/// \brief Number of steps required to reach the target force constant
/// or restraint centers
size_t target_nsteps;
long target_nsteps;
};
/// \brief Harmonic bias restraint

View File

@ -849,12 +849,12 @@ colvar::rmsd::rmsd(std::string const &conf)
}
std::string ref_pos_col;
double ref_pos_col_value;
double ref_pos_col_value=0.0;
if (get_keyval(conf, "refPositionsCol", ref_pos_col, std::string(""))) {
// if provided, use PDB column to select coordinates
bool found = get_keyval(conf, "refPositionsColValue", ref_pos_col_value, 0.0);
if (found && !ref_pos_col_value) {
if (found && ref_pos_col_value==0.0) {
cvm::error("Error: refPositionsColValue, "
"if provided, must be non-zero.\n");
return;
@ -1043,11 +1043,11 @@ colvar::eigenvector::eigenvector(std::string const &conf)
}
std::string file_col;
double file_col_value;
double file_col_value=0.0;
if (get_keyval(conf, "refPositionsCol", file_col, std::string(""))) {
// use PDB flags if column is provided
bool found = get_keyval(conf, "refPositionsColValue", file_col_value, 0.0);
if (found && !file_col_value) {
if (found && file_col_value==0.0) {
cvm::error("Error: refPositionsColValue, "
"if provided, must be non-zero.\n");
return;
@ -1107,11 +1107,11 @@ colvar::eigenvector::eigenvector(std::string const &conf)
}
std::string file_col;
double file_col_value;
double file_col_value=0.0;
if (get_keyval(conf, "vectorCol", file_col, std::string(""))) {
// use PDB flags if column is provided
bool found = get_keyval(conf, "vectorColValue", file_col_value, 0.0);
if (found && !file_col_value) {
if (found && file_col_value==0.0) {
cvm::error("Error: vectorColValue, if provided, must be non-zero.\n");
return;
}
@ -1324,14 +1324,6 @@ void colvar::cartesian::calc_value()
x.vector1d_value[dim*ia + j] = atoms[ia].pos[axes[j]];
}
}
if (atoms.weights.size()) {
for (ia = 0; ia < atoms.size(); ia++) {
for (j = 0; j < dim; j++) {
x.vector1d_value[dim*ia + j] *= atoms.weights[ia];
}
}
}
}
@ -1349,20 +1341,11 @@ void colvar::cartesian::apply_force(colvarvalue const &force)
size_t ia, j;
if (!atoms.noforce) {
cvm::rvector f;
if (atoms.weights.size()) {
for (ia = 0; ia < atoms.size(); ia++) {
for (j = 0; j < dim; j++) {
f[axes[j]] = force.vector1d_value[dim*ia + j] / atoms.weights[ia];
}
atoms[ia].apply_force(f);
}
} else {
for (ia = 0; ia < atoms.size(); ia++) {
for (j = 0; j < dim; j++) {
f[axes[j]] = force.vector1d_value[dim*ia + j];
}
atoms[ia].apply_force(f);
for (ia = 0; ia < atoms.size(); ia++) {
for (j = 0; j < dim; j++) {
f[axes[j]] = force.vector1d_value[dim*ia + j];
}
atoms[ia].apply_force(f);
}
}
}

View File

@ -33,11 +33,11 @@ colvar::orientation::orientation(std::string const &conf)
if (get_keyval(conf, "refPositionsFile", file_name)) {
std::string file_col;
double file_col_value;
double file_col_value=0.0;
if (get_keyval(conf, "refPositionsCol", file_col, std::string(""))) {
// use PDB flags if column is provided
bool found = get_keyval(conf, "refPositionsColValue", file_col_value, 0.0);
if (found && !file_col_value)
if (found && file_col_value==0.0)
cvm::fatal_error("Error: refPositionsColValue, "
"if provided, must be non-zero.\n");
} else {

View File

@ -8,9 +8,10 @@
#include "colvarproxy.h"
#include "colvar.h"
#include "colvarbias.h"
#include "colvarbias_alb.h"
#include "colvarbias_meta.h"
#include "colvarbias_abf.h"
#include "colvarbias_alb.h"
#include "colvarbias_histogram.h"
#include "colvarbias_meta.h"
#include "colvarbias_restraint.h"
#include "colvarscript.h"
@ -523,13 +524,13 @@ int colvarmodule::calc() {
cvm::log("Perform runtime analyses.\n");
cvm::increase_depth();
for (cvi = colvars.begin(); cvi != colvars.end(); cvi++) {
(*cvi)->analyse();
(*cvi)->analyze();
if (cvm::get_error()) {
return COLVARS_ERROR;
}
}
for (bi = biases.begin(); bi != biases.end(); bi++) {
(*bi)->analyse();
(*bi)->analyze();
if (cvm::get_error()) {
return COLVARS_ERROR;
}
@ -627,7 +628,7 @@ int colvarmodule::analyze()
cvi != colvars.end();
cvi++) {
cvm::increase_depth();
(*cvi)->analyse();
(*cvi)->analyze();
cvm::decrease_depth();
}
@ -636,7 +637,7 @@ int colvarmodule::analyze()
bi != biases.end();
bi++) {
cvm::increase_depth();
(*bi)->analyse();
(*bi)->analyze();
cvm::decrease_depth();
}
@ -717,13 +718,15 @@ int colvarmodule::setup_input()
cvm::log(cvm::line_marker);
}
}
return (cvm::get_error() ? COLVARS_ERROR : COLVARS_OK);
return (cvm::get_error() ? COLVARS_ERROR : COLVARS_OK);
}
int colvarmodule::setup_output()
{
int error_code = 0;
// output state file (restart)
restart_out_name = proxy->restart_output_prefix().size() ?
std::string(proxy->restart_output_prefix()+".colvars.state") :
@ -748,7 +751,17 @@ int colvarmodule::setup_output()
std::string(""));
if (cv_traj_freq && cv_traj_name.size()) {
open_traj_file(cv_traj_name);
error_code |= open_traj_file(cv_traj_name);
}
for (std::vector<colvarbias *>::iterator bi = biases.begin();
bi != biases.end();
bi++) {
error_code |= (*bi)->setup_output();
}
if (error_code != COLVARS_OK || cvm::get_error()) {
set_error_bits(FILE_ERROR);
}
return (cvm::get_error() ? COLVARS_ERROR : COLVARS_OK);
@ -828,6 +841,14 @@ int colvarmodule::write_output_files()
}
cvm::decrease_depth();
cvm::increase_depth();
for (std::vector<colvarbias *>::iterator bi = biases.begin();
bi != biases.end();
bi++) {
(*bi)->write_output_files();
}
cvm::decrease_depth();
if (cv_traj_os.is_open()) {
// do not close to avoid problems with multiple NAMD runs
cv_traj_os.flush();
@ -839,8 +860,8 @@ int colvarmodule::write_output_files()
int colvarmodule::read_traj(char const *traj_filename,
size_t traj_read_begin,
size_t traj_read_end)
long traj_read_begin,
long traj_read_end)
{
cvm::log("Opening trajectory file \""+
std::string(traj_filename)+"\".\n");
@ -1204,8 +1225,8 @@ colvarproxy *colvarmodule::proxy = NULL;
// static runtime data
cvm::real colvarmodule::debug_gradients_step_size = 1.0e-03;
int colvarmodule::errorCode = 0;
size_t colvarmodule::it = 0;
size_t colvarmodule::it_restart = 0;
long colvarmodule::it = 0;
long colvarmodule::it_restart = 0;
size_t colvarmodule::restart_out_freq = 0;
size_t colvarmodule::cv_traj_freq = 0;
size_t colvarmodule::depth = 0;

View File

@ -4,7 +4,7 @@
#define COLVARMODULE_H
#ifndef COLVARS_VERSION
#define COLVARS_VERSION "2015-03-15"
#define COLVARS_VERSION "2015-04-22"
#endif
#ifndef COLVARS_DEBUG
@ -122,19 +122,19 @@ public:
}
/// Current step number
static size_t it;
static long it;
/// Starting step number for this run
static size_t it_restart;
static long it_restart;
/// Return the current step number from the beginning of this run
static inline size_t step_relative()
static inline long step_relative()
{
return it - it_restart;
}
/// Return the current step number from the beginning of the whole
/// calculation
static inline size_t step_absolute()
static inline long step_absolute()
{
return it;
}
@ -302,8 +302,8 @@ public:
/// \brief Read a collective variable trajectory (post-processing
/// only, not called at runtime)
int read_traj(char const *traj_filename,
size_t traj_read_begin,
size_t traj_read_end);
long traj_read_begin,
long traj_read_end);
/// Quick conversion of an object to a string
template<typename T> static std::string to_str(T const &x,

View File

@ -227,6 +227,7 @@ size_t colvarparse::dummy_pos = 0;
_get_keyval_scalar_(int);
_get_keyval_scalar_(size_t);
_get_keyval_scalar_(long);
_get_keyval_scalar_string_(std::string);
_get_keyval_scalar_(cvm::real);
_get_keyval_scalar_(cvm::rvector);
@ -238,6 +239,7 @@ _get_keyval_scalar_(colvarvalue);
_get_keyval_vector_(int);
_get_keyval_vector_(size_t);
_get_keyval_vector_(long);
_get_keyval_vector_(std::string);
_get_keyval_vector_(cvm::real);
_get_keyval_vector_(cvm::rvector);

View File

@ -113,6 +113,7 @@ public:
_get_keyval_scalar_proto_(int, (int)0);
_get_keyval_scalar_proto_(size_t, (size_t)0);
_get_keyval_scalar_proto_(long, 0);
_get_keyval_scalar_proto_(std::string, std::string(""));
_get_keyval_scalar_proto_(cvm::real, (cvm::real)0.0);
_get_keyval_scalar_proto_(cvm::rvector, cvm::rvector());
@ -130,6 +131,7 @@ public:
_get_keyval_vector_proto_(int, 0);
_get_keyval_vector_proto_(size_t, 0);
_get_keyval_vector_proto_(long, 0);
_get_keyval_vector_proto_(std::string, std::string(""));
_get_keyval_vector_proto_(cvm::real, 0.0);
_get_keyval_vector_proto_(cvm::rvector, cvm::rvector());

View File

@ -128,7 +128,18 @@ int colvarscript::run(int argc, char const *argv[]) {
}
}
/// TODO Write an output state file? (Useful for testing)
/// Save to an output state file
if (cmd == "save") {
if (argc < 3) {
result = "Missing arguments";
return COLVARSCRIPT_ERROR;
}
proxy->output_prefix_str = argv[2];
int error = 0;
error |= colvars->setup_output();
error |= colvars->write_output_files();
return error ? COLVARSCRIPT_ERROR : COLVARSCRIPT_OK;
}
/// Print the values that would go on colvars.traj
if (cmd == "printframelabels") {

View File

@ -501,7 +501,6 @@ void colvarmodule::rotation::calc_optimal_rotation(std::vector<cvm::atom_pos> co
cvm::quaternion const Q0_new(S_new_eigvec[0]);
cvm::real const DL0 = (dl0_2[comp]) * colvarmodule::debug_gradients_step_size;
cvm::quaternion const q0(Q0);
cvm::quaternion const DQ0(dq0_2[0][comp] * colvarmodule::debug_gradients_step_size,
dq0_2[1][comp] * colvarmodule::debug_gradients_step_size,
dq0_2[2][comp] * colvarmodule::debug_gradients_step_size,