whitespace fixes in colvars library

This commit is contained in:
Axel Kohlmeyer
2013-06-10 14:47:15 +02:00
parent bdf796f136
commit e038893385
27 changed files with 341 additions and 341 deletions

View File

@ -14,7 +14,7 @@
colvar::colvar (std::string const &conf)
{
cvm::log ("Initializing a new collective variable.\n");
get_keyval (conf, "name", this->name,
(std::string ("colvar")+cvm::to_str (cvm::colvars.size()+1)));
@ -26,7 +26,7 @@ colvar::colvar (std::string const &conf)
"\", as another colvar.\n");
}
// all tasks disabled by default
// all tasks disabled by default
for (size_t i = 0; i < task_ntot; i++) {
tasks[i] = false;
}
@ -152,7 +152,7 @@ colvar::colvar (std::string const &conf)
// Decide whether the colvar is periodic
// Used to wrap extended DOF if extendedLagrangian is on
if (cvcs.size() == 1 && (cvcs[0])->b_periodic && (cvcs[0])->sup_np == 1
if (cvcs.size() == 1 && (cvcs[0])->b_periodic && (cvcs[0])->sup_np == 1
&& (cvcs[0])->sup_coeff == 1.0 ) {
this->b_periodic = true;
this->period = (cvcs[0])->period;
@ -307,7 +307,7 @@ colvar::colvar (std::string const &conf)
cvm::log ("Enabling the extended Lagrangian term for colvar \""+
this->name+"\".\n");
enable (task_extended_lagrangian);
xr.type (this->type());
@ -525,10 +525,10 @@ void colvar::enable (colvar::task const &t)
if ( !tasks[task_extended_lagrangian] ) {
enable (task_gradients);
if (!b_Jacobian_force)
if (!b_Jacobian_force)
cvm::fatal_error ("Error: colvar \""+this->name+
"\" does not have Jacobian forces implemented.\n");
if (!b_linear)
if (!b_linear)
cvm::fatal_error ("Error: colvar \""+this->name+
"\" must be defined as a linear combination "
"to calculate the Jacobian force.\n");
@ -669,7 +669,7 @@ colvar::~colvar()
for (size_t i = 0; i < cvcs.size(); i++) {
delete cvcs[i];
}
}
}
@ -699,14 +699,14 @@ void colvar::calc()
for (size_t i = 0; i < cvcs.size(); i++) {
for (size_t ig = 0; ig < cvcs[i]->atom_groups.size(); ig++) {
cvcs[i]->atom_groups[ig]->read_velocities();
}
}
}
}
if (tasks[task_system_force]) {
for (size_t i = 0; i < cvcs.size(); i++) {
for (size_t ig = 0; ig < cvcs[i]->atom_groups.size(); ig++) {
cvcs[i]->atom_groups[ig]->read_system_forces();
}
}
}
}
@ -731,7 +731,7 @@ void colvar::calc()
( ((cvcs[i])->sup_np != 1) ?
std::pow ((cvcs[i])->value().real_value, (cvcs[i])->sup_np) :
(cvcs[i])->value().real_value );
}
}
} else {
// only linear combination allowed
@ -745,7 +745,7 @@ void colvar::calc()
cvm::to_str ((cvcs[i])->value(),
cvm::cv_width, cvm::cv_prec)+".\n");
x += (cvcs[i])->sup_coeff * (cvcs[i])->value();
}
}
}
if (cvm::debug())
@ -766,9 +766,9 @@ void colvar::calc()
// if requested, propagate (via chain rule) the gradients above
// to the atoms used to define the roto-translation
for (size_t ig = 0; ig < cvcs[i]->atom_groups.size(); ig++) {
if (cvcs[i]->atom_groups[ig]->b_fit_gradients)
if (cvcs[i]->atom_groups[ig]->b_fit_gradients)
cvcs[i]->atom_groups[ig]->calc_fit_gradients();
}
}
cvm::decrease_depth();
}
@ -805,7 +805,7 @@ void colvar::calc()
for (size_t k = 0; k < cvcs[i]->atom_groups[j]->size(); k++) {
int a = std::lower_bound (atom_ids.begin(), atom_ids.end(),
cvcs[i]->atom_groups[j]->at(k).id) - atom_ids.begin();
atomic_gradients[a] += coeff * cvcs[i]->atom_groups[j]->at(k).grad;
atomic_gradients[a] += coeff * cvcs[i]->atom_groups[j]->at(k).grad;
}
}
}
@ -929,7 +929,7 @@ cvm::real colvar::update()
}
if (tasks[task_Jacobian_force]) {
cvm::increase_depth();
for (size_t i = 0; i < cvcs.size(); i++) {
(cvcs[i])->calc_Jacobian_derivative();
@ -945,8 +945,8 @@ cvm::real colvar::update()
fj *= cvm::boltzmann() * cvm::temperature();
// the instantaneous Jacobian force was not included in the reported system force;
// instead, it is subtracted from the applied force (silent Jacobian correction)
if (! tasks[task_report_Jacobian_force])
// instead, it is subtracted from the applied force (silent Jacobian correction)
if (! tasks[task_report_Jacobian_force])
f -= fj;
}
@ -970,9 +970,9 @@ cvm::real colvar::update()
// leap to v_(i+1/2)
if (tasks[task_langevin]) {
vr -= dt * ext_gamma * vr.real_value;
vr += dt * ext_sigma * cvm::rand_gaussian() / ext_mass;
}
vr += (0.5 * dt) * fr / ext_mass;
vr += dt * ext_sigma * cvm::rand_gaussian() / ext_mass;
}
vr += (0.5 * dt) * fr / ext_mass;
xr += dt * vr;
xr.apply_constraints();
if (this->b_periodic) this->wrap (xr);
@ -993,13 +993,13 @@ cvm::real colvar::update()
void colvar::communicate_forces()
{
if (cvm::debug())
cvm::log ("Communicating forces from colvar \""+this->name+"\".\n");
cvm::log ("Communicating forces from colvar \""+this->name+"\".\n");
if (x.type() == colvarvalue::type_scalar) {
for (size_t i = 0; i < cvcs.size(); i++) {
cvm::increase_depth();
(cvcs[i])->apply_force (f * (cvcs[i])->sup_coeff *
(cvcs[i])->apply_force (f * (cvcs[i])->sup_coeff *
cvm::real ((cvcs[i])->sup_np) *
(std::pow ((cvcs[i])->value().real_value,
(cvcs[i])->sup_np-1)) );
@ -1016,7 +1016,7 @@ void colvar::communicate_forces()
}
if (cvm::debug())
cvm::log ("Done communicating forces from colvar \""+this->name+"\".\n");
cvm::log ("Done communicating forces from colvar \""+this->name+"\".\n");
}
@ -1204,7 +1204,7 @@ std::istream & colvar::read_traj (std::istream &is)
is >> ft;
if (tasks[task_extended_lagrangian]) {
if (tasks[task_extended_lagrangian]) {
is >> fr;
ft_reported = fr;
} else {
@ -1252,7 +1252,7 @@ std::ostream & colvar::write_restart (std::ostream &os) {
os << "}\n\n";
return os;
}
}
std::ostream & colvar::write_traj_label (std::ostream & os)
@ -1422,7 +1422,7 @@ inline void history_add_value (size_t const &history_length,
inline void history_incr (std::list< std::list<colvarvalue> > &history,
std::list< std::list<colvarvalue> >::iterator &history_p)
{
if ((++history_p) == history.end())
if ((++history_p) == history.end())
history_p = history.begin();
}
@ -1439,7 +1439,7 @@ void colvar::calc_acf()
// first-step operations
colvar *cfcv = (acf_colvar_name.size() ?
colvar *cfcv = (acf_colvar_name.size() ?
cvm::colvar_p (acf_colvar_name) :
this);
if (cfcv->type() != this->type())
@ -1478,7 +1478,7 @@ void colvar::calc_acf()
} else {
colvar *cfcv = (acf_colvar_name.size() ?
colvar *cfcv = (acf_colvar_name.size() ?
cvm::colvar_p (acf_colvar_name) :
this);
@ -1543,7 +1543,7 @@ void colvar::calc_vel_acf (std::list<colvarvalue> &v_list,
// inner products of previous velocities with current (acf_i and
// vs_i are updated)
colvarvalue::inner_opt (v, vs_i, v_list.end(), acf_i);
colvarvalue::inner_opt (v, vs_i, v_list.end(), acf_i);
acf_nframes++;
}
@ -1563,7 +1563,7 @@ void colvar::calc_coor_acf (std::list<colvarvalue> &x_list,
*(acf_i++) += x.norm2();
colvarvalue::inner_opt (x, xs_i, x_list.end(), acf_i);
colvarvalue::inner_opt (x, xs_i, x_list.end(), acf_i);
acf_nframes++;
}
@ -1585,7 +1585,7 @@ void colvar::calc_p2coor_acf (std::list<colvarvalue> &x_list,
// value of P2(0) = 1
*(acf_i++) += 1.0;
colvarvalue::p2leg_opt (x, xs_i, x_list.end(), acf_i);
colvarvalue::p2leg_opt (x, xs_i, x_list.end(), acf_i);
acf_nframes++;
}

View File

@ -215,7 +215,7 @@ protected:
cvm::real ext_gamma;
/// Amplitude of Gaussian white noise for Langevin extended dynamics
cvm::real ext_sigma;
/// \brief Harmonic restraint force
colvarvalue fr;
@ -380,7 +380,7 @@ protected:
colvarvalue x_old;
/// Time series of values and velocities used in correlation
/// functions
/// functions
std::list< std::list<colvarvalue> > acf_x_history, acf_v_history;
/// Time series of values and velocities used in correlation
/// functions (pointers)x

View File

@ -26,8 +26,8 @@ cvm::atom_group::atom_group (std::string const &conf,
cvm::atom_group::atom_group (std::vector<cvm::atom> const &atoms)
: b_dummy (false), b_center (false), b_rotate (false),
ref_pos_group (NULL), b_fit_gradients (false),
: b_dummy (false), b_center (false), b_rotate (false),
ref_pos_group (NULL), b_fit_gradients (false),
noforce (false)
{
this->reserve (atoms.size());
@ -43,8 +43,8 @@ cvm::atom_group::atom_group (std::vector<cvm::atom> const &atoms)
cvm::atom_group::atom_group()
: b_dummy (false), b_center (false), b_rotate (false),
ref_pos_group (NULL), b_fit_gradients (false),
: b_dummy (false), b_center (false), b_rotate (false),
ref_pos_group (NULL), b_fit_gradients (false),
noforce (false)
{
total_mass = 0.0;
@ -253,7 +253,7 @@ void cvm::atom_group::parse (std::string const &conf,
}
}
for (std::vector<cvm::atom>::iterator a1 = this->begin();
for (std::vector<cvm::atom>::iterator a1 = this->begin();
a1 != this->end(); a1++) {
std::vector<cvm::atom>::iterator a2 = a1;
++a2;
@ -272,10 +272,10 @@ void cvm::atom_group::parse (std::string const &conf,
if (get_keyval (group_conf, "dummyAtom", dummy_atom_pos, cvm::atom_pos(), mode)) {
b_dummy = true;
this->total_mass = 1.0;
} else
} else
b_dummy = false;
if (b_dummy && (this->size()))
if (b_dummy && (this->size()))
cvm::fatal_error ("Error: cannot set up group \""+
std::string (key)+"\" as a dummy atom "
"and provide it with atom definitions.\n");
@ -347,7 +347,7 @@ void cvm::atom_group::parse (std::string const &conf,
std::string ref_pos_col;
double ref_pos_col_value;
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);
@ -505,7 +505,7 @@ void cvm::atom_group::calc_apply_roto_translation()
}
}
void cvm::atom_group::apply_translation (cvm::rvector const &t)
void cvm::atom_group::apply_translation (cvm::rvector const &t)
{
if (b_dummy) return;
@ -515,7 +515,7 @@ void cvm::atom_group::apply_translation (cvm::rvector const &t)
}
}
void cvm::atom_group::apply_rotation (cvm::rotation const &rot)
void cvm::atom_group::apply_rotation (cvm::rotation const &rot)
{
if (b_dummy) return;
@ -636,11 +636,11 @@ void cvm::atom_group::calc_fit_gradients()
}
if (b_rotate) {
// add the rotation matrix contribution to the gradients
cvm::rotation const rot_inv = rot.inverse();
cvm::atom_pos const cog = this->center_of_geometry();
for (size_t i = 0; i < this->size(); i++) {
cvm::atom_pos const pos_orig = rot_inv.rotate ((b_center ? ((*this)[i].pos - cog) : ((*this)[i].pos)));
@ -804,7 +804,7 @@ void cvm::atom_group::apply_force (cvm::rvector const &force)
for (cvm::atom_iter ai = this->begin();
ai != this->end(); ai++) {
ai->apply_force ((ai->mass/this->total_mass) * force);
}
}
}
}

View File

@ -8,7 +8,7 @@
/// \brief Stores numeric id, mass and all mutable data for an atom,
/// mostly used by a \link cvc \endlink
///
///
/// This class may be used (although not necessarily) to keep atomic
/// data (id, mass, position and collective variable derivatives)
/// altogether. There may be multiple instances with identical
@ -47,7 +47,7 @@ public:
/// \brief Gradient of a scalar collective variable with respect
/// to this atom
///
///
/// This can only handle a scalar collective variable (i.e. when
/// the \link colvarvalue::real_value \endlink member is used
/// from the \link colvarvalue \endlink class), which is also the
@ -138,7 +138,7 @@ public:
/// Allocates and populates the sorted list of atom ids
void create_sorted_ids (void);
/// \brief When updating atomic coordinates, translate them to align with the
/// center of mass of the reference coordinates
@ -175,7 +175,7 @@ public:
/// \brief If b_center or b_rotate is true, use this group to
/// define the transformation (default: this group itself)
atom_group *ref_pos_group;
/// Total mass of the atom group
cvm::real total_mass;
@ -199,7 +199,7 @@ public:
/// \brief Initialize the group after a temporary vector of atoms
atom_group (std::vector<cvm::atom> const &atoms);
/// \brief Add an atom to this group
/// \brief Add an atom to this group
void add_atom (cvm::atom const &a);
/// \brief Default constructor
@ -216,7 +216,7 @@ public:
void calc_apply_roto_translation();
/// \brief Save center of geometry fo ref positions,
/// then subtract it
/// then subtract it
void center_ref_pos();
/// \brief Move all positions

View File

@ -60,7 +60,7 @@ void colvarbias::add_colvar (std::string const &cv_name)
cvp->enable (colvar::task_gradients);
if (cvm::debug())
cvm::log ("Applying this bias to collective variable \""+
cvp->name+"\".\n");
cvp->name+"\".\n");
colvars.push_back (cvp);
colvar_forces.push_back (colvarvalue (cvp->type()));
} else {
@ -80,7 +80,7 @@ void colvarbias::communicate_forces()
}
colvars[i]->add_bias_force (colvar_forces[i]);
}
}
}
void colvarbias::change_configuration(std::string const &conf)
@ -99,7 +99,7 @@ cvm::real colvarbias::energy_difference(std::string const &conf)
std::ostream & colvarbias::write_traj_label (std::ostream &os)
{
os << " ";
if (b_output_energy)
if (b_output_energy)
os << " E_"
<< cvm::wrap_string (this->name, cvm::en_width-2);
return os;
@ -109,7 +109,7 @@ std::ostream & colvarbias::write_traj_label (std::ostream &os)
std::ostream & colvarbias::write_traj (std::ostream &os)
{
os << " ";
if (b_output_energy)
if (b_output_energy)
os << " "
<< bias_energy;
return os;
@ -120,7 +120,7 @@ std::ostream & colvarbias::write_traj (std::ostream &os)
colvarbias_harmonic::colvarbias_harmonic (std::string const &conf,
char const *key)
: colvarbias (conf, key),
: colvarbias (conf, key),
target_nsteps (0),
target_nstages (0)
{
@ -349,7 +349,7 @@ cvm::real colvarbias_harmonic::update()
if (target_equil_steps == 0 || cvm::step_absolute() % target_nsteps >= target_equil_steps) {
// Start averaging after equilibration period, if requested
// Square distance normalized by square colvar width
cvm::real dist_sq = 0.0;
for (size_t i = 0; i < colvars.size(); i++) {
@ -367,7 +367,7 @@ cvm::real colvarbias_harmonic::update()
cvm::log ("Lambda= " + cvm::to_str (lambda) + " dA/dLambda= "
+ cvm::to_str (restraint_FE / cvm::real(target_nsteps - target_equil_steps)));
// ...and move on to the next one
if (stage < target_nstages) {
@ -395,7 +395,7 @@ cvm::real colvarbias_harmonic::update()
if (cvm::debug())
cvm::log ("Done updating the harmonic bias \""+this->name+"\".\n");
// Force and energy calculation
for (size_t i = 0; i < colvars.size(); i++) {
colvar_forces[i] =
@ -449,7 +449,7 @@ std::istream & colvarbias_harmonic::read_restart (std::istream &is)
return is;
}
// int id = -1;
// int id = -1;
std::string name = "";
// if ( ( (colvarparse::get_keyval (conf, "id", id, -1, colvarparse::parse_silent)) &&
// (id != this->id) ) ||
@ -545,18 +545,18 @@ std::ostream & colvarbias_harmonic::write_traj_label (std::ostream &os)
{
os << " ";
if (b_output_energy)
if (b_output_energy)
os << " E_"
<< cvm::wrap_string (this->name, cvm::en_width-2);
if (b_output_centers)
if (b_output_centers)
for (size_t i = 0; i < colvars.size(); i++) {
size_t const this_cv_width = (colvars[i]->value()).output_width (cvm::cv_width);
os << " x0_"
<< cvm::wrap_string (colvars[i]->name, this_cv_width-3);
}
if (b_output_acc_work)
if (b_output_acc_work)
os << " W_"
<< cvm::wrap_string (this->name, cvm::en_width-2);
@ -568,19 +568,19 @@ std::ostream & colvarbias_harmonic::write_traj (std::ostream &os)
{
os << " ";
if (b_output_energy)
if (b_output_energy)
os << " "
<< std::setprecision (cvm::en_prec) << std::setw (cvm::en_width)
<< bias_energy;
if (b_output_centers)
if (b_output_centers)
for (size_t i = 0; i < colvars.size(); i++) {
os << " "
<< std::setprecision (cvm::cv_prec) << std::setw (cvm::cv_width)
<< colvar_centers[i];
}
if (b_output_acc_work)
if (b_output_acc_work)
os << " "
<< std::setprecision (cvm::en_prec) << std::setw (cvm::en_width)
<< acc_work;

View File

@ -14,7 +14,7 @@ public:
/// Name of this bias
std::string name;
/// Add a new collective variable to this bias
void add_colvar (std::string const &cv_name);
@ -35,7 +35,7 @@ public:
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);
@ -161,7 +161,7 @@ protected:
/// \brief Exponent for varying the force constant
cvm::real force_k_exp;
/// \brief Intermediate quantity to compute the restraint free energy
/// (in TI, would be the accumulating FE derivative)
cvm::real restraint_FE;

View File

@ -15,7 +15,7 @@ colvarbias_abf::colvarbias_abf (std::string const &conf, char const *key)
{
if (cvm::temperature() == 0.0)
cvm::log ("WARNING: ABF should not be run without a thermostat or at 0 Kelvin!\n");
// ************* parsing general ABF options ***********************
get_keyval (conf, "applyBias", apply_bias, true);
@ -32,7 +32,7 @@ colvarbias_abf::colvarbias_abf (std::string const &conf, char const *key)
}
get_keyval (conf, "fullSamples", full_samples, 200);
if ( full_samples <= 1 ) full_samples = 1;
if ( full_samples <= 1 ) full_samples = 1;
min_samples = full_samples / 2;
// full_samples - min_samples >= 1 is guaranteed
@ -79,7 +79,7 @@ colvarbias_abf::colvarbias_abf (std::string const &conf, char const *key)
}
// Here we could check for orthogonality of the Cartesian coordinates
// and make it just a warning if some parameter is set?
// and make it just a warning if some parameter is set?
}
bin.assign (colvars.size(), 0);
@ -96,7 +96,7 @@ colvarbias_abf::colvarbias_abf (std::string const &conf, char const *key)
if ( input_prefix.size() > 0 ) {
read_gradients_samples ();
}
cvm::log ("Finished ABF setup.\n");
}
@ -128,7 +128,7 @@ cvm::real colvarbias_abf::update()
if (cvm::debug()) cvm::log ("Updating ABF bias " + this->name);
if (cvm::step_relative() == 0) {
// At first timestep, do only:
// initialization stuff (file operations relying on n_abf_biases
// compute current value of colvars
@ -161,7 +161,7 @@ cvm::real colvarbias_abf::update()
}
// save bin for next timestep
force_bin = bin;
force_bin = bin;
// Reset biasing forces from previous timestep
for (size_t i=0; i<colvars.size(); i++) {
@ -179,7 +179,7 @@ cvm::real colvarbias_abf::update()
fact = ( count < min_samples) ? 0.0 :
(cvm::real (count - min_samples)) / (cvm::real (full_samples - min_samples));
}
const cvm::real * grad = &(gradients->value (bin));
if ( fact != 0.0 ) {
@ -253,7 +253,7 @@ void colvarbias_abf::read_gradients_samples ()
samples_in_name = input_prefix[i] + ".count";
gradients_in_name = input_prefix[i] + ".grad";
// For user-provided files, the per-bias naming scheme may not apply
std::ifstream is;
cvm::log ("Reading sample count from " + samples_in_name + " and gradients from " + gradients_in_name);
@ -275,7 +275,7 @@ void colvarbias_abf::read_gradients_samples ()
std::ostream & colvarbias_abf::write_restart (std::ostream& os)
{
std::ios::fmtflags flags (os.flags ());
std::ios::fmtflags flags (os.flags ());
os.setf(std::ios::fmtflags (0), std::ios::floatfield); // default floating-point format
os << "abf {\n"
@ -328,7 +328,7 @@ std::istream & colvarbias_abf::read_restart (std::istream& is)
if ( name == "" ) {
cvm::fatal_error ("Error: \"abf\" block in the restart file has no name.\n");
}
if ( !(is >> key) || !(key == "samples")) {
cvm::log ("Error: in reading restart configuration for ABF bias \""+
this->name+"\" at position "+
@ -384,7 +384,7 @@ colvarbias_histogram::colvarbias_histogram (std::string const &conf, char const
bin.assign (colvars.size(), 0);
out_name = cvm::output_prefix + "." + this->name + ".dat";
cvm::log ("Histogram will be written to file " + out_name);
cvm::log ("Histogram will be written to file " + out_name);
cvm::log ("Finished histogram setup.\n");
}
@ -458,7 +458,7 @@ std::istream & colvarbias_histogram::read_restart (std::istream& is)
cvm::fatal_error ("Error: \"histogram\" block in the restart file "
"has no name.\n");
}
if ( !(is >> key) || !(key == "grid")) {
cvm::log ("Error: in reading restart configuration for histogram \""+
this->name+"\" at position "+

View File

@ -84,7 +84,7 @@ private:
std::vector<int> bin;
std::string out_name;
int output_freq;
int output_freq;
void write_grid ();
std::ofstream grid_os; /// Stream for writing grid to disk

View File

@ -54,7 +54,7 @@ colvarbias_meta::colvarbias_meta (std::string const &conf, char const *key)
get_keyval (conf, "multipleReplicas", b_replicas, false);
if (b_replicas)
comm = multiple_replicas;
else
else
comm = single_replica;
}
@ -114,7 +114,7 @@ colvarbias_meta::colvarbias_meta (std::string const &conf, char const *key)
"when using more than one replica.\n");
get_keyval (conf, "replicasRegistry",
replicas_registry_file,
replicas_registry_file,
(this->name+".replicas.registry.txt"));
get_keyval (conf, "replicaUpdateFrequency",
@ -172,7 +172,7 @@ colvarbias_meta::colvarbias_meta (std::string const &conf, char const *key)
// if this replica was not included yet, we should generate a
// new record for it: but first, we write this replica's files,
// for the others to read
// open the "hills" buffer file
replica_hills_os.open (replica_hills_file.c_str());
if (!replica_hills_os.good())
@ -189,7 +189,7 @@ colvarbias_meta::colvarbias_meta (std::string const &conf, char const *key)
// if we're running without grids, use a growing list of "hills" files
// otherwise, just one state file and one "hills" file as buffer
std::ofstream list_os (replica_list_file.c_str(),
std::ofstream list_os (replica_list_file.c_str(),
(use_grids ? std::ios::trunc : std::ios::app));
if (! list_os.good())
cvm::fatal_error ("Error: in opening file \""+
@ -233,7 +233,7 @@ colvarbias_meta::colvarbias_meta (std::string const &conf, char const *key)
cvm::log("Well-tempered metadynamics is used.\n");
cvm::log("The bias temperature is "+cvm::to_str(bias_temperature)+".\n");
}
if (cvm::debug())
cvm::log ("Done initializing the metadynamics bias \""+this->name+"\""+
((comm != single_replica) ? ", replica \""+replica_id+"\"" : "")+".\n");
@ -270,7 +270,7 @@ colvarbias_meta::~colvarbias_meta()
// Hill management member functions
// **********************************************************************
std::list<colvarbias_meta::hill>::const_iterator
std::list<colvarbias_meta::hill>::const_iterator
colvarbias_meta::create_hill (colvarbias_meta::hill const &h)
{
hill_iter const hills_end = hills.end();
@ -328,7 +328,7 @@ colvarbias_meta::delete_hill (hill_iter &h)
}
if (hills_traj_os.good()) {
// output to the trajectory
// output to the trajectory
hills_traj_os << "# DELETED this hill: "
<< (hills.back()).output_traj()
<< "\n";
@ -463,9 +463,9 @@ cvm::real colvarbias_meta::update()
cvm::real const hills_energy_sum_here = hills_energy->value(curr_bin);
cvm::real const exp_weight = std::exp(-hills_energy_sum_here/(bias_temperature*cvm::boltzmann()));
create_hill (hill ((hill_weight*exp_weight), colvars, hill_width));
} else {
} else {
create_hill (hill (hill_weight, colvars, hill_width));
}
}
break;
case multiple_replicas:
@ -474,9 +474,9 @@ cvm::real colvarbias_meta::update()
cvm::real const hills_energy_sum_here = hills_energy->value(curr_bin);
cvm::real const exp_weight = std::exp(-hills_energy_sum_here/(bias_temperature*cvm::boltzmann()));
create_hill (hill ((hill_weight*exp_weight), colvars, hill_width, replica_id));
} else {
} else {
create_hill (hill (hill_weight, colvars, hill_width, replica_id));
}
}
if (replica_hills_os.good()) {
replica_hills_os << hills.back();
} else {
@ -595,11 +595,11 @@ cvm::real colvarbias_meta::update()
calc_hills_force (ic, new_hills_begin, hills.end(), colvar_forces);
}
if (cvm::debug())
if (cvm::debug())
cvm::log ("Hills energy = "+cvm::to_str (bias_energy)+
", hills forces = "+cvm::to_str (colvar_forces)+".\n");
if (cvm::debug())
if (cvm::debug())
cvm::log ("Metadynamics bias \""+this->name+"\""+
((comm != single_replica) ? ", replica \""+replica_id+"\"" : "")+
": adding the forces from the other replicas.\n");
@ -615,7 +615,7 @@ cvm::real colvarbias_meta::update()
replicas[ir]->hills.end(),
colvar_forces);
}
if (cvm::debug())
if (cvm::debug())
cvm::log ("Hills energy = "+cvm::to_str (bias_energy)+
", hills forces = "+cvm::to_str (colvar_forces)+".\n");
}
@ -645,7 +645,7 @@ void colvarbias_meta::calc_hills (colvarbias_meta::hill_iter h_first,
}
for (hill_iter h = h_first; h != h_last; h++) {
// compute the gaussian exponent
cvm::real cv_sqdev = 0.0;
for (size_t i = 0; i < colvars.size(); i++) {
@ -688,8 +688,8 @@ void colvarbias_meta::calc_hills_force (size_t const &i,
if (h->value() == 0.0) continue;
colvarvalue const &center = h->centers[i];
cvm::real const half_width = 0.5 * h->widths[i];
forces[i].real_value +=
( h->weight() * h->value() * (0.5 / (half_width*half_width)) *
forces[i].real_value +=
( h->weight() * h->value() * (0.5 / (half_width*half_width)) *
(colvars[i]->dist2_lgrad (x, center)).real_value );
}
break;
@ -997,7 +997,7 @@ void colvarbias_meta::read_replica_files()
}
// (re)read the state file if necessary
if ( (! (replicas[ir])->has_data) ||
if ( (! (replicas[ir])->has_data) ||
(! (replicas[ir])->replica_state_file_in_sync) ) {
cvm::log ("Metadynamics bias \""+this->name+"\""+
@ -1017,11 +1017,11 @@ void colvarbias_meta::read_replica_files()
}
is.close();
}
// now read the hills added after writing the state file
if ((replicas[ir])->replica_hills_file.size()) {
if (cvm::debug())
if (cvm::debug())
cvm::log ("Metadynamics bias \""+this->name+"\""+
": checking for new hills from replica \""+
(replicas[ir])->replica_id+"\" in the file \""+
@ -1068,7 +1068,7 @@ void colvarbias_meta::read_replica_files()
"\" at position "+
cvm::to_str ((replicas[ir])->replica_hills_file_pos)+".\n");
// test whether this is the end of the file
// test whether this is the end of the file
is.seekg (0, std::ios::end);
if (is.tellg() > (replicas[ir])->replica_hills_file_pos+1) {
(replicas[ir])->update_status++;
@ -1112,7 +1112,7 @@ std::istream & colvarbias_meta::read_restart (std::istream& is)
size_t const start_pos = is.tellg();
if (comm == single_replica) {
// if using a multiple replicas scheme, output messages
// if using a multiple replicas scheme, output messages
// are printed before and after calling this function
cvm::log ("Restarting metadynamics bias \""+this->name+"\""+
".\n");
@ -1122,7 +1122,7 @@ std::istream & colvarbias_meta::read_restart (std::istream& is)
!(is >> brace) || !(brace == "{") ||
!(is >> colvarparse::read_block ("configuration", conf)) ) {
if (comm == single_replica)
if (comm == single_replica)
cvm::log ("Error: in reading restart configuration for metadynamics bias \""+
this->name+"\""+
((comm != single_replica) ? ", replica \""+replica_id+"\"" : "")+
@ -1243,7 +1243,7 @@ std::istream & colvarbias_meta::read_restart (std::istream& is)
is.clear();
is.seekg (hills_energy_gradients_pos, std::ios::beg);
grids_from_restart_file = false;
if (!rebin_grids) {
if (!rebin_grids) {
if (hills_energy_backup == NULL)
cvm::fatal_error ("Error: couldn't read the free energy gradients grid for metadynamics bias \""+
this->name+"\""+
@ -1287,7 +1287,7 @@ std::istream & colvarbias_meta::read_restart (std::istream& is)
// read the hills explicitly written (if there are any)
while (read_hill (is)) {
if (cvm::debug())
if (cvm::debug())
cvm::log ("Read a previously saved hill under the "
"metadynamics bias \""+
this->name+"\", created at step "+
@ -1368,7 +1368,7 @@ std::istream & colvarbias_meta::read_restart (std::istream& is)
hills.erase (hills.begin(), old_hills_end);
hills_off_grid.erase (hills_off_grid.begin(), old_hills_off_grid_end);
}
has_data = true;
if (comm != single_replica) {
@ -1376,7 +1376,7 @@ std::istream & colvarbias_meta::read_restart (std::istream& is)
}
return is;
}
}
std::istream & colvarbias_meta::read_hill (std::istream &is)
@ -1408,7 +1408,7 @@ std::istream & colvarbias_meta::read_hill (std::istream &is)
std::vector<colvarvalue> h_centers (colvars.size());
for (size_t i = 0; i < colvars.size(); i++) {
h_centers[i].type ((colvars[i]->value()).type());
h_centers[i].type ((colvars[i]->value()).type());
}
{
// it is safer to read colvarvalue objects one at a time;
@ -1425,7 +1425,7 @@ std::istream & colvarbias_meta::read_hill (std::istream &is)
get_keyval (data, "widths", h_widths,
std::vector<cvm::real> (colvars.size(), (std::sqrt (2.0 * PI) / 2.0)),
parse_silent);
std::string h_replica = "";
if (comm != single_replica) {
get_keyval (data, "replicaID", h_replica, replica_id, parse_silent);
@ -1521,7 +1521,7 @@ std::ostream & colvarbias_meta::write_restart (std::ostream& os)
}
return os;
}
}
void colvarbias_meta::write_pmf()
@ -1531,7 +1531,7 @@ void colvarbias_meta::write_pmf()
pmf->create();
std::string fes_file_name_prefix (cvm::output_prefix);
if ((cvm::n_meta_biases > 1) || (cvm::n_abf_biases > 0)) {
// if this is not the only free energy integrator, append
// this bias's name, to distinguish it from the output of the other
@ -1602,7 +1602,7 @@ void colvarbias_meta::write_replica_state_file()
cvm::fatal_error ("Error: in opening file \""+
replica_state_file+"\" for writing.\n");
rep_state_os.setf (std::ios::scientific, std::ios::floatfield);
rep_state_os.setf (std::ios::scientific, std::ios::floatfield);
rep_state_os << "\n"
<< "metadynamics {\n"
<< " configuration {\n"
@ -1676,7 +1676,7 @@ std::string colvarbias_meta::hill::output_traj()
<< std::setw (cvm::en_width) << W << "\n";
return os.str();
}
}
std::ostream & operator << (std::ostream &os, colvarbias_meta::hill const &h)

View File

@ -33,7 +33,7 @@ public:
/// Destructor
virtual ~colvarbias_meta();
virtual cvm::real update();
virtual std::istream & read_restart (std::istream &is);
@ -84,7 +84,7 @@ protected:
std::istream & read_hill (std::istream &is);
/// \brief step present in a state file
///
///
/// When using grids and reading state files containing them
/// (multiple replicas), this is used to check whether a hill is
/// newer or older than the grids
@ -147,10 +147,10 @@ protected:
/// time steps, appending the step number to each file
bool dump_fes_save;
/// \brief Whether to use well-tempered metadynamics
bool well_tempered;
/// \brief Whether to use well-tempered metadynamics
bool well_tempered;
/// \brief Biasing temperature in well-tempered metadynamics
/// \brief Biasing temperature in well-tempered metadynamics
cvm::real bias_temperature;
/// \brief Try to read the restart information by allocating new
@ -282,7 +282,7 @@ public:
centers[i] = cv[i]->value();
widths[i] = cv[i]->width * hill_width;
}
if (cvm::debug())
if (cvm::debug())
cvm::log ("New hill, applied to "+cvm::to_str (cv.size())+
" collective variables, with centers "+
cvm::to_str (centers)+", widths "+
@ -322,7 +322,7 @@ public:
/// Destructor
inline ~hill()
{}
/// Get the energy
inline cvm::real energy()
{

View File

@ -39,7 +39,7 @@ colvar::cvc::cvc (std::string const &conf)
}
void colvar::cvc::parse_group (std::string const &conf,
void colvar::cvc::parse_group (std::string const &conf,
char const *group_key,
cvm::atom_group &group,
bool optional)
@ -120,7 +120,7 @@ void colvar::cvc::debug_gradients (cvm::atom_group &group)
for (size_t id = 0; id < 3; id++) {
// (re)read original positions
group.read_positions();
// change one coordinate
// change one coordinate
group[ia].pos[id] += cvm::debug_gradients_step_size;
// (re)do the fit (if defined)
if (group.b_center || group.b_rotate) {

View File

@ -4,7 +4,7 @@
// Declaration of colvar::cvc base class and derived ones.
//
// Future cvc's could be declared on additional header files.
// After the declaration of a new derived class, its metric
// After the declaration of a new derived class, its metric
// functions must be reimplemented as well.
// If the new cvc has no symmetry or periodicity,
// this can be done straightforwardly by using the macro:
@ -50,7 +50,7 @@
/// 2. add a call to the parser in colvar.C, within the function colvar::colvar() \par
/// 3. declare the class in colvarcomp.h \par
/// 4. implement the class in one of the files colvarcomp_*.C
///
///
/// </b>
/// The cvm::atom and cvm::atom_group classes are available to
/// transparently communicate with the simulation program. However,
@ -68,7 +68,7 @@ public:
std::string name;
/// \brief Description of the type of collective variable
///
///
/// Normally this string is set by the parent \link colvar \endlink
/// object within its constructor, when all \link cvc \endlink
/// objects are initialized; therefore the main "config string"
@ -104,7 +104,7 @@ public:
/// \brief Within the constructor, make a group parse its own
/// options from the provided configuration string
void parse_group (std::string const &conf,
void parse_group (std::string const &conf,
char const *group_key,
cvm::atom_group &group,
bool optional = false);
@ -174,7 +174,7 @@ public:
/// \brief Square distance between x1 and x2 (can be redefined to
/// transparently implement constraints, symmetries and
/// periodicities)
///
///
/// colvar::cvc::dist2() and the related functions are
/// declared as "const" functions, but not "static", because
/// additional parameters defining the metrics (e.g. the
@ -192,7 +192,7 @@ public:
/// to provide a gradient which is compatible with the constraint,
/// i.e. already deprived of its component normal to the constraint
/// hypersurface.
///
///
/// Finally, another useful application, if you are performing very
/// many operations with these functions, could be to override the
/// \link colvarvalue \endlink member functions and access directly
@ -701,7 +701,7 @@ protected:
/// \brief Compute system force on first site only to avoid unwanted
/// coupling to other colvars (see e.g. Ciccotti et al., 2005)
bool b_1site_force;
public:
/// Initialize by parsing the configuration
@ -769,7 +769,7 @@ public:
static cvm::real switching_function (cvm::real const &r0,
int const &exp_num, int const &exp_den,
cvm::atom &A1, cvm::atom &A2);
template<bool b_gradients>
/// \brief Calculate a coordination number through the function
/// (1-x**n)/(1-x**m), x = |(A1-A2)*(r0_vec)^-|1 \param r0_vec
@ -818,7 +818,7 @@ public:
static cvm::real switching_function (cvm::real const &r0,
int const &exp_num, int const &exp_den,
cvm::atom &A1, cvm::atom &A2);
virtual cvm::real dist2 (colvarvalue const &x1,
colvarvalue const &x2) const;
virtual colvarvalue dist2_lgrad (colvarvalue const &x1,
@ -832,7 +832,7 @@ public:
/// \brief Colvar component: hydrogen bond, defined as the product of
/// a colvar::coordnum and 1/2*(1-cos((180-ang)/ang_tol))
/// (colvarvalue::type_scalar type, range [0:1])
class colvar::h_bond
class colvar::h_bond
: public colvar::cvc
{
protected:
@ -897,7 +897,7 @@ public:
// alpha_dihedrals();
// virtual inline ~alpha_dihedrals() {}
// virtual void calc_value();
// virtual void calc_gradients();
// virtual void calc_gradients();
// virtual void apply_force (colvarvalue const &force);
// virtual cvm::real dist2 (colvarvalue const &x1,
// colvarvalue const &x2) const;
@ -931,7 +931,7 @@ protected:
/// List of hydrogen bonds
std::vector<h_bond *> hb;
/// Contribution of the hb terms
/// Contribution of the hb terms
cvm::real hb_coeff;
public:
@ -1151,7 +1151,7 @@ public:
// metrics functions for cvc implementations
// metrics functions for cvc implementations
// simple definitions of the distance functions; these are useful only
// for optimization (the type check performed in the default
@ -1187,7 +1187,7 @@ public:
\
simple_scalar_dist_functions (distance)
// NOTE: distance_z has explicit functions, see below
// NOTE: distance_z has explicit functions, see below
simple_scalar_dist_functions (distance_xy)
simple_scalar_dist_functions (distance_inv)
simple_scalar_dist_functions (angle)
@ -1243,12 +1243,12 @@ inline void colvar::dihedral::wrap (colvarvalue &x) const
if ((x.real_value - wrap_center) >= 180.0) {
x.real_value -= 360.0;
return;
}
}
if ((x.real_value - wrap_center) < -180.0) {
x.real_value += 360.0;
return;
}
}
return;
}
@ -1288,12 +1288,12 @@ inline void colvar::spin_angle::wrap (colvarvalue &x) const
if ((x.real_value - wrap_center) >= 180.0) {
x.real_value -= 360.0;
return;
}
}
if ((x.real_value - wrap_center) < -180.0) {
x.real_value += 360.0;
return;
}
}
return;
}

View File

@ -77,7 +77,7 @@ void colvar::angle::calc_gradients()
{
cvm::real const cos_theta = (r21*r23)/(r21l*r23l);
cvm::real const dxdcos = -1.0 / std::sqrt (1.0 - cos_theta*cos_theta);
dxdr1 = (180.0/PI) * dxdcos *
(1.0/r21l) * ( r23/r23l + (-1.0) * cos_theta * r21/r21l );
@ -246,7 +246,7 @@ void colvar::dihedral::calc_gradients()
cvm::real rA = A.norm();
cvm::rvector B = cvm::rvector::outer (r23, r34);
cvm::real rB = B.norm();
cvm::rvector C = cvm::rvector::outer (r23, A);
cvm::rvector C = cvm::rvector::outer (r23, A);
cvm::real rC = C.norm();
cvm::real const cos_phi = (A*B)/(rA*rB);

View File

@ -72,7 +72,7 @@ cvm::real colvar::coordnum::switching_function (cvm::rvector const &r0_vec,
colvar::coordnum::coordnum (std::string const &conf)
: distance (conf), b_anisotropic (false), b_group2_center_only (false)
{
{
function_type = "coordnum";
x.type (colvarvalue::type_scalar);
@ -80,7 +80,7 @@ colvar::coordnum::coordnum (std::string const &conf)
if (group1.b_dummy)
cvm::fatal_error ("Error: only group2 is allowed to be a dummy atom\n");
// need to specify this explicitly because the distance() constructor
// has set it to true
b_inverse_gradients = false;
@ -307,7 +307,7 @@ void colvar::h_bond::apply_force (colvarvalue const &force)
colvar::selfcoordnum::selfcoordnum (std::string const &conf)
: distance (conf, false)
{
{
function_type = "selfcoordnum";
x.type (colvarvalue::type_scalar);

View File

@ -113,7 +113,7 @@ void colvar::distance_vec::calc_value()
}
void colvar::distance_vec::calc_gradients()
{
{
// gradients are not stored: a 3x3 matrix for each atom would be
// needed to store just the identity matrix
}
@ -140,7 +140,7 @@ colvar::distance_z::distance_z (std::string const &conf)
// TODO detect PBC from MD engine (in simple cases)
// and then update period in real time
if (period != 0.0)
b_periodic = true;
b_periodic = true;
if ((wrap_center != 0.0) && (period == 0.0)) {
cvm::fatal_error ("Error: wrapAround was defined in a distanceZ component,"
@ -153,7 +153,7 @@ colvar::distance_z::distance_z (std::string const &conf)
atom_groups.push_back (&ref1);
// this group is optional
parse_group (conf, "ref2", ref2, true);
if (ref2.size()) {
atom_groups.push_back (&ref2);
cvm::log ("Using axis joining the centers of mass of groups \"ref\" and \"ref2\"");
@ -700,7 +700,7 @@ colvar::rmsd::rmsd (std::string const &conf)
parse_group (conf, "atoms", atoms);
atom_groups.push_back (&atoms);
if (atoms.b_dummy)
if (atoms.b_dummy)
cvm::fatal_error ("Error: \"atoms\" cannot be a dummy atom.");
if (atoms.ref_pos_group != NULL) {
@ -732,7 +732,7 @@ colvar::rmsd::rmsd (std::string const &conf)
std::string ref_pos_col;
double ref_pos_col_value;
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);
@ -771,7 +771,7 @@ colvar::rmsd::rmsd (std::string const &conf)
}
}
void colvar::rmsd::calc_value()
{
// rotational-translational fit is handled by the atom group
@ -813,9 +813,9 @@ void colvar::rmsd::calc_force_invgrads()
{
atoms.read_system_forces();
ft.real_value = 0.0;
// Note: gradient square norm is 1/N_atoms
for (size_t ia = 0; ia < atoms.size(); ia++) {
ft.real_value += atoms[ia].grad * atoms[ia].system_force;
}
@ -832,7 +832,7 @@ void colvar::rmsd::calc_Jacobian_derivative()
// gradient of the rotation matrix
cvm::matrix2d <cvm::rvector, 3, 3> grad_rot_mat;
// gradients of products of 2 quaternion components
// gradients of products of 2 quaternion components
cvm::rvector g11, g22, g33, g01, g02, g03, g12, g13, g23;
for (size_t ia = 0; ia < atoms.size(); ia++) {
@ -850,15 +850,15 @@ void colvar::rmsd::calc_Jacobian_derivative()
g23 = (atoms.rot.q)[2]*dq[3] + (atoms.rot.q)[3]*dq[2];
// Gradient of the rotation matrix wrt current Cartesian position
grad_rot_mat[0][0] = -2.0 * (g22 + g33);
grad_rot_mat[1][0] = 2.0 * (g12 + g03);
grad_rot_mat[2][0] = 2.0 * (g13 - g02);
grad_rot_mat[0][1] = 2.0 * (g12 - g03);
grad_rot_mat[1][1] = -2.0 * (g11 + g33);
grad_rot_mat[2][1] = 2.0 * (g01 + g23);
grad_rot_mat[0][2] = 2.0 * (g02 + g13);
grad_rot_mat[1][2] = 2.0 * (g23 - g01);
grad_rot_mat[2][2] = -2.0 * (g11 + g22);
grad_rot_mat[0][0] = -2.0 * (g22 + g33);
grad_rot_mat[1][0] = 2.0 * (g12 + g03);
grad_rot_mat[2][0] = 2.0 * (g13 - g02);
grad_rot_mat[0][1] = 2.0 * (g12 - g03);
grad_rot_mat[1][1] = -2.0 * (g11 + g33);
grad_rot_mat[2][1] = 2.0 * (g01 + g23);
grad_rot_mat[0][2] = 2.0 * (g02 + g13);
grad_rot_mat[1][2] = 2.0 * (g23 - g01);
grad_rot_mat[2][2] = -2.0 * (g11 + g22);
cvm::atom_pos &y = ref_pos[ia];
@ -1053,7 +1053,7 @@ colvar::eigenvector::eigenvector (std::string const &conf)
}
}
void colvar::eigenvector::calc_value()
{
x.real_value = 0.0;
@ -1087,7 +1087,7 @@ void colvar::eigenvector::calc_force_invgrads()
{
atoms.read_system_forces();
ft.real_value = 0.0;
for (size_t ia = 0; ia < atoms.size(); ia++) {
ft.real_value += eigenvec_invnorm2 * atoms[ia].grad *
atoms[ia].system_force;
@ -1101,10 +1101,10 @@ void colvar::eigenvector::calc_Jacobian_derivative()
cvm::matrix2d <cvm::rvector, 3, 3> grad_rot_mat;
cvm::quaternion &quat0 = atoms.rot.q;
// gradients of products of 2 quaternion components
// gradients of products of 2 quaternion components
cvm::rvector g11, g22, g33, g01, g02, g03, g12, g13, g23;
cvm::atom_pos x_relative;
cvm::atom_pos x_relative;
cvm::real sum = 0.0;
for (size_t ia = 0; ia < atoms.size(); ia++) {
@ -1126,15 +1126,15 @@ void colvar::eigenvector::calc_Jacobian_derivative()
// Gradient of the inverse rotation matrix wrt current Cartesian position
// (transpose of the gradient of the direct rotation)
grad_rot_mat[0][0] = -2.0 * (g22 + g33);
grad_rot_mat[0][1] = 2.0 * (g12 + g03);
grad_rot_mat[0][2] = 2.0 * (g13 - g02);
grad_rot_mat[1][0] = 2.0 * (g12 - g03);
grad_rot_mat[1][1] = -2.0 * (g11 + g33);
grad_rot_mat[1][2] = 2.0 * (g01 + g23);
grad_rot_mat[2][0] = 2.0 * (g02 + g13);
grad_rot_mat[2][1] = 2.0 * (g23 - g01);
grad_rot_mat[2][2] = -2.0 * (g11 + g22);
grad_rot_mat[0][0] = -2.0 * (g22 + g33);
grad_rot_mat[0][1] = 2.0 * (g12 + g03);
grad_rot_mat[0][2] = 2.0 * (g13 - g02);
grad_rot_mat[1][0] = 2.0 * (g12 - g03);
grad_rot_mat[1][1] = -2.0 * (g11 + g33);
grad_rot_mat[1][2] = 2.0 * (g01 + g23);
grad_rot_mat[2][0] = 2.0 * (g02 + g13);
grad_rot_mat[2][1] = 2.0 * (g23 - g01);
grad_rot_mat[2][2] = -2.0 * (g11 + g22);
for (size_t i = 0; i < 3; i++) {
for (size_t j = 0; j < 3; j++) {
@ -1143,7 +1143,7 @@ void colvar::eigenvector::calc_Jacobian_derivative()
}
}
jd.real_value = sum * std::sqrt (eigenvec_invnorm2);
jd.real_value = sum * std::sqrt (eigenvec_invnorm2);
}

View File

@ -122,7 +122,7 @@ void colvar::alpha_angles::calc_value()
if (theta.size()) {
cvm::real const theta_norm =
cvm::real const theta_norm =
(1.0-hb_coeff) / cvm::real (theta.size());
for (size_t i = 0; i < theta.size(); i++) {
@ -162,7 +162,7 @@ void colvar::alpha_angles::calc_value()
void colvar::alpha_angles::calc_gradients()
{
for (size_t i = 0; i < theta.size(); i++)
for (size_t i = 0; i < theta.size(); i++)
(theta[i])->calc_gradients();
for (size_t i = 0; i < hb.size(); i++)
@ -175,9 +175,9 @@ void colvar::alpha_angles::apply_force (colvarvalue const &force)
if (theta.size()) {
cvm::real const theta_norm =
cvm::real const theta_norm =
(1.0-hb_coeff) / cvm::real (theta.size());
for (size_t i = 0; i < theta.size(); i++) {
cvm::real const t = ((theta[i])->value().real_value-theta_ref)/theta_tol;
@ -185,10 +185,10 @@ void colvar::alpha_angles::apply_force (colvarvalue const &force)
(1.0 - std::pow (t, (int) 4)) );
cvm::real const dfdt =
1.0/(1.0 - std::pow (t, (int) 4)) *
1.0/(1.0 - std::pow (t, (int) 4)) *
( (-2.0 * t) + (-1.0*f)*(-4.0 * std::pow (t, (int) 3)) );
(theta[i])->apply_force (theta_norm *
(theta[i])->apply_force (theta_norm *
dfdt * (1.0/theta_tol) *
force.real_value );
}
@ -216,7 +216,7 @@ void colvar::alpha_angles::apply_force (colvarvalue const &force)
// of this cvc (alpha)
// This is true of all cvcs with sub-cvcs, and those
// that do not calculate explicit gradients
// SO: we need a flag giving the availability of
// SO: we need a flag giving the availability of
// atomic gradients
colvar::dihedPC::dihedPC (std::string const &conf)
: cvc (conf)
@ -260,7 +260,7 @@ colvar::dihedPC::dihedPC (std::string const &conf)
std::string vecFileName;
int vecNumber;
if (get_keyval (conf, "vectorFile", vecFileName, vecFileName)) {
get_keyval (conf, "vectorNumber", vecNumber, 0);
get_keyval (conf, "vectorNumber", vecNumber, 0);
if (vecNumber < 1)
cvm::fatal_error ("A positive value of vectorNumber is required.");

View File

@ -74,7 +74,7 @@ colvar::orientation::orientation (std::string const &conf)
}
colvar::orientation::orientation()
: cvc ()
{
@ -160,7 +160,7 @@ void colvar::orientation_angle::calc_value()
void colvar::orientation_angle::calc_gradients()
{
cvm::real const dxdq0 =
( ((rot.q).q0 * (rot.q).q0 < 1.0) ?
( ((rot.q).q0 * (rot.q).q0 < 1.0) ?
((180.0 / PI) * (-2.0) / std::sqrt (1.0 - ((rot.q).q0 * (rot.q).q0))) :
0.0 );

View File

@ -141,7 +141,7 @@ void colvar_grid_gradient::write_1D_integral (std::ostream &os)
{
cvm::real bin, min, integral;
std::vector<cvm::real> int_vals;
os << "# xi A(xi)\n";
if ( cv.size() != 1 ) {
@ -162,7 +162,7 @@ void colvar_grid_gradient::write_1D_integral (std::ostream &os)
}
for (std::vector<int> ix = new_index(); index_ok (ix); incr (ix), bin += 1.0 ) {
if (samples) {
size_t const samples_here = samples->value (ix);
if (samples_here)

View File

@ -266,11 +266,11 @@ public:
}
{
{
cvm::real nbins = ( upper_boundaries[i].real_value -
lower_boundaries[i].real_value ) / widths[i];
int nbins_round = (int)(nbins+0.5);
if (std::fabs (nbins - cvm::real (nbins_round)) > 1.0E-10) {
cvm::log ("Warning: grid interval ("+
cvm::to_str (lower_boundaries[i], cvm::cv_width, cvm::cv_prec)+" - "+
@ -284,7 +284,7 @@ public:
if (cvm::debug())
cvm::log ("Number of points is "+cvm::to_str ((int) nbins_round)+
" for the colvar no. "+cvm::to_str (i+1)+".\n");
nx_i.push_back (nbins_round);
}
@ -336,7 +336,7 @@ public:
{
return lower_boundaries[i].real_value + widths[i] * (0.5 + i_bin);
}
/// \brief Same as the standard version, but uses different parameters
inline colvarvalue bin_to_value_scalar (int const &i_bin,
colvarvalue const &new_offset,
@ -349,7 +349,7 @@ public:
inline void set_value (std::vector<int> const &ix,
T const &t,
size_t const &imult = 0)
{
{
data[this->address (ix)+imult] = t;
has_data = true;
}
@ -367,7 +367,7 @@ public:
/// \brief Add a constant to all elements (fast loop)
inline void add_constant (T const &t)
{
for (size_t i = 0; i < nt; i++)
for (size_t i = 0; i < nt; i++)
data[i] += t;
has_data = true;
}
@ -375,11 +375,11 @@ public:
/// \brief Multiply all elements by a scalar constant (fast loop)
inline void multiply_constant (cvm::real const &a)
{
for (size_t i = 0; i < nt; i++)
for (size_t i = 0; i < nt; i++)
data[i] *= a;
}
/// \brief Get the bin indices corresponding to the provided values of
/// the colvars
inline std::vector<int> const get_colvars_index (std::vector<colvarvalue> const &values) const
@ -432,7 +432,7 @@ public:
/// \brief Add data from another grid of the same type
///
///
/// Note: this function maps other_grid inside this one regardless
/// of whether it fits or not.
void map_grid (colvar_grid<T> const &other_grid)
@ -482,11 +482,11 @@ public:
if (other_grid.multiplicity() != this->multiplicity())
cvm::fatal_error ("Error: trying to sum togetehr two grids with values of "
"different multiplicity.\n");
if (scale_factor != 1.0)
if (scale_factor != 1.0)
for (size_t i = 0; i < data.size(); i++) {
data[i] += scale_factor * other_grid.data[i];
}
else
else
// skip multiplication if possible
for (size_t i = 0; i < data.size(); i++) {
data[i] += other_grid.data[i];
@ -571,30 +571,30 @@ public:
std::ostream & write_params (std::ostream &os)
{
os << "grid_parameters {\n n_colvars " << nd << "\n";
os << " lower_boundaries ";
for (size_t i = 0; i < nd; i++)
for (size_t i = 0; i < nd; i++)
os << " " << lower_boundaries[i];
os << "\n";
os << " upper_boundaries ";
for (size_t i = 0; i < nd; i++)
for (size_t i = 0; i < nd; i++)
os << " " << upper_boundaries[i];
os << "\n";
os << " widths ";
for (size_t i = 0; i < nd; i++)
for (size_t i = 0; i < nd; i++)
os << " " << widths[i];
os << "\n";
os << " sizes ";
for (size_t i = 0; i < nd; i++)
for (size_t i = 0; i < nd; i++)
os << " " << nx[i];
os << "\n";
os << "}\n";
return os;
}
}
bool parse_params (std::string const &conf)
@ -648,9 +648,9 @@ public:
{
for (size_t i = 0; i < nd; i++) {
if ( (std::sqrt (cv[i]->dist2 (cv[i]->lower_boundary,
lower_boundaries[i])) > 1.0E-10) ||
lower_boundaries[i])) > 1.0E-10) ||
(std::sqrt (cv[i]->dist2 (cv[i]->upper_boundary,
upper_boundaries[i])) > 1.0E-10) ||
upper_boundaries[i])) > 1.0E-10) ||
(std::sqrt (cv[i]->dist2 (cv[i]->width,
widths[i])) > 1.0E-10) ) {
cvm::fatal_error ("Error: restart information for a grid is "
@ -669,11 +669,11 @@ public:
// matter: boundaries should be EXACTLY the same (otherwise,
// map_grid() should be used)
if ( (std::fabs (other_grid.lower_boundaries[i] -
lower_boundaries[i]) > 1.0E-10) ||
lower_boundaries[i]) > 1.0E-10) ||
(std::fabs (other_grid.upper_boundaries[i] -
upper_boundaries[i]) > 1.0E-10) ||
upper_boundaries[i]) > 1.0E-10) ||
(std::fabs (other_grid.widths[i] -
widths[i]) > 1.0E-10) ||
widths[i]) > 1.0E-10) ||
(data.size() != other_grid.data.size()) ) {
cvm::fatal_error ("Error: inconsistency between "
"two grids that are supposed to be equal, "
@ -681,7 +681,7 @@ public:
}
}
}
/// \brief Write the grid data without labels, as they are
/// represented in memory
@ -714,7 +714,7 @@ public:
std::istream & read_raw (std::istream &is)
{
size_t const start_pos = is.tellg();
for (std::vector<int> ix = new_index(); index_ok (ix); incr (ix)) {
for (size_t imult = 0; imult < mult; imult++) {
T new_value;
@ -845,7 +845,7 @@ std::istream & read_multicol (std::istream &is, bool add = false)
if ( !(is >> x) ) end_of_file = true;
bin[i] = value_to_bin_scalar (x, i);
}
if (end_of_file) break;
if (end_of_file) break;
for (size_t imult = 0; imult < mult; imult++) {
is >> new_value[imult];
@ -904,7 +904,7 @@ public:
++(data[this->address (ix)]);
}
/// \brief Get the binned count indexed by ix from the newly read data
/// \brief Get the binned count indexed by ix from the newly read data
inline size_t const & new_count (std::vector<int> const &ix,
size_t const &imult = 0)
{
@ -993,7 +993,7 @@ public:
A0 += data[address (ix)];
grad[n] = 0.5 * (A1 - A0) / widths[n];
}
return grad;
return grad;
}
/// \brief Return the value of the function at ix divided by its

View File

@ -9,7 +9,7 @@
colvarmodule::colvarmodule (char const *config_filename,
colvarproxy *proxy_in)
{
{
// pointer to the proxy object
if (proxy == NULL) {
proxy = proxy_in;
@ -85,7 +85,7 @@ colvarmodule::colvarmodule (char const *config_filename,
std::string (output_prefix+".colvars.state") :
std::string ("colvars.state"))+"\".\n");
cv_traj_name =
cv_traj_name =
(output_prefix.size() ?
std::string (output_prefix+".colvars.traj") :
std::string ("colvars.traj"));
@ -140,7 +140,7 @@ colvarmodule::colvarmodule (char const *config_filename,
}
std::istream & colvarmodule::read_restart (std::istream &is)
std::istream & colvarmodule::read_restart (std::istream &is)
{
{
// read global restart information
@ -197,7 +197,7 @@ void colvarmodule::init_colvars (std::string const &conf)
(colvars.back())->check_keywords (colvar_conf, "colvar");
cvm::decrease_depth();
} else {
cvm::log ("Warning: \"colvar\" keyword found without any configuration.\n");
cvm::log ("Warning: \"colvar\" keyword found without any configuration.\n");
}
colvar_conf = "";
}
@ -352,13 +352,13 @@ void colvarmodule::calc() {
}
// calculate collective variables and their gradients
if (cvm::debug())
if (cvm::debug())
cvm::log ("Calculating collective variables.\n");
cvm::increase_depth();
for (std::vector<colvar *>::iterator cvi = colvars.begin();
cvi != colvars.end();
cvi++) {
(*cvi)->calc();
(*cvi)->calc();
}
cvm::decrease_depth();
@ -370,7 +370,7 @@ void colvarmodule::calc() {
for (std::vector<colvarbias *>::iterator bi = biases.begin();
bi != biases.end();
bi++) {
total_bias_energy += (*bi)->update();
total_bias_energy += (*bi)->update();
}
cvm::decrease_depth();
@ -381,12 +381,12 @@ void colvarmodule::calc() {
for (std::vector<colvar *>::iterator cvi = colvars.begin();
cvi != colvars.end();
cvi++) {
(*cvi)->reset_bias_force();
(*cvi)->reset_bias_force();
}
for (std::vector<colvarbias *>::iterator bi = biases.begin();
bi != biases.end();
bi++) {
(*bi)->communicate_forces();
(*bi)->communicate_forces();
}
cvm::decrease_depth();
@ -398,12 +398,12 @@ void colvarmodule::calc() {
for (std::vector<colvar *>::iterator cvi = colvars.begin();
cvi != colvars.end();
cvi++) {
(*cvi)->analyse();
(*cvi)->analyse();
}
for (std::vector<colvarbias *>::iterator bi = biases.begin();
bi != biases.end();
bi++) {
(*bi)->analyse();
(*bi)->analyse();
}
cvm::decrease_depth();
}
@ -431,7 +431,7 @@ void colvarmodule::calc() {
cvi != colvars.end();
cvi++) {
if ((*cvi)->tasks[colvar::task_gradients])
(*cvi)->communicate_forces();
(*cvi)->communicate_forces();
}
cvm::decrease_depth();
@ -447,7 +447,7 @@ void colvarmodule::calc() {
if (!write_restart (restart_out_os))
cvm::fatal_error ("Error: in writing restart file.\n");
restart_out_os.close();
}
}
}
// write trajectory file, if needed
@ -476,7 +476,7 @@ void colvarmodule::calc() {
if ((cvm::step_absolute() % (cv_traj_freq * 1000)) == 0 || cvm::step_relative() == 0) {
cv_traj_os << "# " << cvm::wrap_string ("step", cvm::it_width-2)
<< " ";
if (cvm::debug())
if (cvm::debug())
cv_traj_os.flush();
for (std::vector<colvar *>::iterator cvi = colvars.begin();
cvi != colvars.end();
@ -489,7 +489,7 @@ void colvarmodule::calc() {
(*bi)->write_traj_label (cv_traj_os);
}
cv_traj_os << "\n";
if (cvm::debug())
if (cvm::debug())
cv_traj_os.flush();
}
cvm::decrease_depth();
@ -515,7 +515,7 @@ void colvarmodule::calc() {
}
cvm::decrease_depth();
if (restart_out_freq) {
if (restart_out_freq) {
// flush the trajectory file if we are at the restart frequency
if ( (cvm::step_relative() > 0) &&
((cvm::step_absolute() % restart_out_freq) == 0) ) {
@ -542,7 +542,7 @@ void colvarmodule::analyze()
cvi != colvars.end();
cvi++) {
cvm::increase_depth();
(*cvi)->analyse();
(*cvi)->analyse();
cvm::decrease_depth();
}
@ -551,7 +551,7 @@ void colvarmodule::analyze()
bi != biases.end();
bi++) {
cvm::increase_depth();
(*bi)->analyse();
(*bi)->analyse();
cvm::decrease_depth();
}
@ -580,7 +580,7 @@ colvarmodule::~colvarmodule()
delete parse;
proxy = NULL;
}
}
void colvarmodule::write_output_files()
@ -605,7 +605,7 @@ void colvarmodule::write_output_files()
(*cvi)->write_output_files();
}
cvm::decrease_depth();
// do not close to avoid problems with multiple NAMD runs
cv_traj_os.flush();
}
@ -646,7 +646,7 @@ bool colvarmodule::read_traj (char const *traj_filename,
continue;
} else {
} else {
if ((it % 1000) == 0)
std::cerr << "Reading from trajectory, step = " << it
@ -747,7 +747,7 @@ void cvm::read_index_file (char const *filename)
while (is.good()) {
char open, close;
std::string group_name;
if ( (is >> open) && (open == '[') &&
if ( (is >> open) && (open == '[') &&
(is >> group_name) &&
(is >> close) && (close == ']') ) {
cvm::index_group_names.push_back (group_name);
@ -893,7 +893,7 @@ std::istream & operator >> (std::istream &is, colvarmodule::quaternion &q)
std::string ("euler")) ) {
// parse the Euler angles
char sep;
cvm::real phi, theta, psi;
if ( !(is >> sep) || !(sep == '(') ||
@ -912,7 +912,7 @@ std::istream & operator >> (std::istream &is, colvarmodule::quaternion &q)
// parse the quaternion components
is.seekg (start_pos, std::ios::beg);
is.seekg (start_pos, std::ios::beg);
char sep;
if ( !(is >> sep) || !(sep == '(') ||
!(is >> q.q0) || !(is >> sep) || !(sep == ',') ||
@ -1023,7 +1023,7 @@ void colvarmodule::rotation::build_matrix (std::vector<cvm::atom_pos> const &pos
C.zx() += pos1[i].z * pos2[i].x;
C.zy() += pos1[i].z * pos2[i].y;
C.zz() += pos1[i].z * pos2[i].z;
}
}
// build the "overlap" matrix, whose eigenvectors are stationary
// points of the RMSD in the space of rotations
@ -1137,7 +1137,7 @@ void colvarmodule::rotation::calc_optimal_rotation
}
}
q_old = q;
if (cvm::debug()) {
if (b_debug_gradients) {
cvm::log ("L0 = "+cvm::to_str (L0, cvm::cv_width, cvm::cv_prec)+
@ -1208,8 +1208,8 @@ void colvarmodule::rotation::calc_optimal_rotation
for (size_t i = 0; i < 4; i++) {
for (size_t j = 0; j < 4; j++) {
dq0_1[p] +=
(Q1[i] * ds_1[i][j] * Q0[j]) / (L0-L1) * Q1[p] +
(Q2[i] * ds_1[i][j] * Q0[j]) / (L0-L2) * Q2[p] +
(Q1[i] * ds_1[i][j] * Q0[j]) / (L0-L1) * Q1[p] +
(Q2[i] * ds_1[i][j] * Q0[j]) / (L0-L2) * Q2[p] +
(Q3[i] * ds_1[i][j] * Q0[j]) / (L0-L3) * Q3[p];
}
}
@ -1258,15 +1258,15 @@ void colvarmodule::rotation::calc_optimal_rotation
for (size_t i = 0; i < 4; i++) {
for (size_t j = 0; j < 4; j++) {
dq0_2[p] +=
(Q1[i] * ds_2[i][j] * Q0[j]) / (L0-L1) * Q1[p] +
(Q2[i] * ds_2[i][j] * Q0[j]) / (L0-L2) * Q2[p] +
(Q1[i] * ds_2[i][j] * Q0[j]) / (L0-L1) * Q1[p] +
(Q2[i] * ds_2[i][j] * Q0[j]) / (L0-L2) * Q2[p] +
(Q3[i] * ds_2[i][j] * Q0[j]) / (L0-L3) * Q3[p];
}
}
}
if (cvm::debug()) {
if (b_debug_gradients) {
matrix2d<cvm::real, 4, 4> S_new;
@ -1281,7 +1281,7 @@ void colvarmodule::rotation::calc_optimal_rotation
// diagonalize the new overlap matrix
for (size_t i = 0; i < 4; i++) {
for (size_t j = 0; j < 4; j++) {
S_new[i][j] +=
S_new[i][j] +=
colvarmodule::debug_gradients_step_size * ds_2[i][j][comp];
}
}

View File

@ -2,16 +2,16 @@
#define COLVARMODULE_H
#ifndef COLVARS_VERSION
#define COLVARS_VERSION "2013-06-05"
#define COLVARS_VERSION "2013-06-07"
#endif
#ifndef COLVARS_DEBUG
#define COLVARS_DEBUG false
#endif
/// \file colvarmodule.h
/// \file colvarmodule.h
/// \brief Collective variables main module
///
///
/// This file declares the main class for defining and manipulating
/// collective variables: there should be only one instance of this
/// class, because several variables are made static (i.e. they are
@ -40,7 +40,7 @@ class colvarproxy;
/// Class to control the collective variables calculation. An object
/// (usually one) of this class is spawned from the MD program,
/// containing all i/o routines and general interface.
///
///
/// At initialization, the colvarmodule object creates a proxy object
/// to provide a transparent interface between the MD program and the
/// child objects
@ -54,7 +54,7 @@ private:
public:
friend class colvarproxy;
/// Defining an abstract real number allows to switch precision
typedef double real;
/// Residue identifier
@ -147,7 +147,7 @@ public:
/// \brief Number of histograms initialized (no limit on the
/// number)
static size_t n_histo_biases;
/// \brief Whether debug output should be enabled (compile-time option)
static inline bool debug()
{
@ -157,7 +157,7 @@ public:
/// \brief Constructor \param config_name Configuration file name
/// \param restart_name (optional) Restart file name
colvarmodule (char const *config_name,
colvarmodule (char const *config_name,
colvarproxy *proxy_in);
/// Destructor
~colvarmodule();
@ -194,16 +194,16 @@ public:
bool read_traj (char const *traj_filename,
size_t traj_read_begin,
size_t traj_read_end);
/// Get the pointer of a colvar from its name (returns NULL if not found)
static colvar * colvar_p (std::string const &name);
/// Quick conversion of an object to a string
template<typename T> static std::string to_str (T const &x,
template<typename T> static std::string to_str (T const &x,
size_t const &width = 0,
size_t const &prec = 0);
/// Quick conversion of a vector of objects to a string
template<typename T> static std::string to_str (std::vector<T> const &x,
template<typename T> static std::string to_str (std::vector<T> const &x,
size_t const &width = 0,
size_t const &prec = 0);
@ -247,10 +247,10 @@ public:
/// \brief Time step of MD integrator (fs)
static real dt();
/// Request calculation of system force from MD engine
static void request_system_force();
/// Print a message to the main log
static void log (std::string const &message);
@ -278,7 +278,7 @@ public:
/// \brief Get the closest periodic image to a reference position
/// \param pos The position to look for the closest periodic image
/// \param ref_pos (optional) The reference position
/// \param ref_pos (optional) The reference position
static void select_closest_image (atom_pos &pos,
atom_pos const &ref_pos);
@ -381,7 +381,7 @@ std::ostream & operator << (std::ostream &os, cvm::rvector const &v);
std::istream & operator >> (std::istream &is, cvm::rvector &v);
template<typename T> std::string cvm::to_str (T const &x,
template<typename T> std::string cvm::to_str (T const &x,
size_t const &width,
size_t const &prec) {
std::ostringstream os;
@ -394,7 +394,7 @@ template<typename T> std::string cvm::to_str (T const &x,
return os.str();
}
template<typename T> std::string cvm::to_str (std::vector<T> const &x,
template<typename T> std::string cvm::to_str (std::vector<T> const &x,
size_t const &width,
size_t const &prec) {
if (!x.size()) return std::string ("");
@ -444,7 +444,7 @@ inline void cvm::request_system_force()
{
proxy->request_system_force (true);
}
inline void cvm::select_closest_image (atom_pos &pos,
atom_pos const &ref_pos)
{

View File

@ -241,11 +241,11 @@ _get_keyval_vector_ (colvarvalue);
bool colvarparse::get_keyval (std::string const &conf,
char const *key,
bool &value,
bool const &def_value,
Parse_Mode const parse_mode)
bool colvarparse::get_keyval (std::string const &conf,
char const *key,
bool &value,
bool const &def_value,
Parse_Mode const parse_mode)
{
std::string data;
bool b_found = false, b_found_any = false;
@ -277,7 +277,7 @@ bool colvarparse::get_keyval (std::string const &conf,
(data == std::string ("false")) ) {
value = false;
} else
cvm::fatal_error ("Error: boolean values only are allowed "
cvm::fatal_error ("Error: boolean values only are allowed "
"for \""+std::string (key)+"\".\n");
if (parse_mode != parse_silent) {
cvm::log ("# "+std::string (key)+" = "+
@ -426,8 +426,8 @@ bool colvarparse::key_lookup (std::string const &conf,
colvarparse::dummy_pos = 0;
// start from the first occurrence of key
size_t pos = conf_lower.find (key, save_pos);
size_t pos = conf_lower.find (key, save_pos);
// iterate over all instances until it finds the isolated keyword
while (true) {
@ -442,7 +442,7 @@ bool colvarparse::key_lookup (std::string const &conf,
if ( std::string ("\n"+white_space+
"}").find (conf[pos-1]) ==
std::string::npos ) {
// none of the valid delimiting characters is on the left of key
// none of the valid delimiting characters is on the left of key
b_isolated_left = false;
}
}
@ -451,7 +451,7 @@ bool colvarparse::key_lookup (std::string const &conf,
if ( std::string ("\n"+white_space+
"{").find (conf[pos+key.size()]) ==
std::string::npos ) {
// none of the valid delimiting characters is on the right of key
// none of the valid delimiting characters is on the right of key
b_isolated_right = false;
}
}
@ -461,7 +461,7 @@ bool colvarparse::key_lookup (std::string const &conf,
bool const b_isolated = (b_isolated_left && b_isolated_right &&
b_not_within_block);
if (b_isolated) {
// found it
break;
@ -490,7 +490,7 @@ bool colvarparse::key_lookup (std::string const &conf,
size_t line_begin = (pl == std::string::npos) ? 0 : pos;
size_t nl = conf.find ("\n", pos);
size_t line_end = (nl == std::string::npos) ? conf.size() : nl;
std::string line (conf, line_begin, (line_end-line_begin));
std::string line (conf, line_begin, (line_end-line_begin));
size_t data_begin = (to_lower_cppstr (line)).find (key) + key.size();
data_begin = line.find_first_not_of (white_space, data_begin+1);
@ -527,9 +527,9 @@ bool colvarparse::key_lookup (std::string const &conf,
line_begin = line_end;
nl = conf.find ('\n', line_begin+1);
if (nl == std::string::npos)
if (nl == std::string::npos)
line_end = conf.size();
else
else
line_end = nl;
line.append (conf, line_begin, (line_end-line_begin));
@ -565,7 +565,7 @@ bool colvarparse::key_lookup (std::string const &conf,
// << "\n";
}
}
save_pos = line_end;
return true;

View File

@ -53,15 +53,15 @@ public:
{}
/// How a keyword is parsed in a string
enum Parse_Mode {
enum Parse_Mode {
/// \brief (default) Read the first instance of a keyword (if
/// any), report its value, and print a warning when there is more
/// than one
parse_normal,
parse_normal,
/// \brief Like parse_normal, but don't send any message to the log
/// (useful e.g. in restart files when such messages are very
/// numerous and redundant)
parse_silent
parse_silent
};
/// \fn get_keyval bool const get_keyval (std::string const &conf,
@ -112,7 +112,7 @@ public:
std::vector<_type_> const &def_values = \
std::vector<_type_> (0, static_cast<_type_>(_def_value_)), \
Parse_Mode const parse_mode = parse_normal)
_get_keyval_vector_proto_ (int, 0);
_get_keyval_vector_proto_ (size_t, 0);
_get_keyval_vector_proto_ (std::string, std::string (""));
@ -169,7 +169,7 @@ public:
/// data (optional) holds the string provided after "key", if any
/// \param save_pos (optional) stores the position of the keyword
/// within "conf", useful when doing multiple calls \param
/// save_delimiters (optional)
/// save_delimiters (optional)
bool key_lookup (std::string const &conf,
char const *key,
std::string &data = dummy_string,

View File

@ -80,7 +80,7 @@ public:
/// \brief Get the closest periodic image to a reference position
/// \param pos The position to look for the closest periodic image
/// \param ref_pos The reference position
/// \param ref_pos The reference position
virtual void select_closest_image (cvm::atom_pos &pos,
cvm::atom_pos const &ref_pos) = 0;

View File

@ -19,7 +19,7 @@ class colvarmodule::rvector {
public:
cvm::real x, y, z;
inline rvector()
: x (0.0), y (0.0), z (0.0)
{}
@ -55,7 +55,7 @@ public:
}
inline cvm::rvector & operator = (cvm::real const &v)
inline cvm::rvector & operator = (cvm::real const &v)
{
x = v;
y = v;
@ -63,28 +63,28 @@ public:
return *this;
}
inline void operator += (cvm::rvector const &v)
inline void operator += (cvm::rvector const &v)
{
x += v.x;
y += v.y;
z += v.z;
}
inline void operator -= (cvm::rvector const &v)
inline void operator -= (cvm::rvector const &v)
{
x -= v.x;
y -= v.y;
z -= v.z;
}
inline void operator *= (cvm::real const &v)
inline void operator *= (cvm::real const &v)
{
x *= v;
y *= v;
z *= v;
}
inline void operator /= (cvm::real const& v)
inline void operator /= (cvm::real const& v)
{
x /= v;
y /= v;
@ -113,57 +113,57 @@ public:
}
static inline cvm::rvector outer (cvm::rvector const &v1, cvm::rvector const &v2)
static inline cvm::rvector outer (cvm::rvector const &v1, cvm::rvector const &v2)
{
return cvm::rvector ( v1.y*v2.z - v2.y*v1.z,
-v1.x*v2.z + v2.x*v1.z,
v1.x*v2.y - v2.x*v1.y);
}
friend inline cvm::rvector operator - (cvm::rvector const &v)
friend inline cvm::rvector operator - (cvm::rvector const &v)
{
return cvm::rvector (-v.x, -v.y, -v.z);
}
friend inline int operator == (cvm::rvector const &v1, cvm::rvector const &v2)
friend inline int operator == (cvm::rvector const &v1, cvm::rvector const &v2)
{
return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z);
}
friend inline int operator != (cvm::rvector const &v1, cvm::rvector const &v2)
friend inline int operator != (cvm::rvector const &v1, cvm::rvector const &v2)
{
return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z);
}
friend inline cvm::rvector operator + (cvm::rvector const &v1, cvm::rvector const &v2)
friend inline cvm::rvector operator + (cvm::rvector const &v1, cvm::rvector const &v2)
{
return cvm::rvector (v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
}
friend inline cvm::rvector operator - (cvm::rvector const &v1, cvm::rvector const &v2)
friend inline cvm::rvector operator - (cvm::rvector const &v1, cvm::rvector const &v2)
{
return cvm::rvector (v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
}
friend inline cvm::real operator * (cvm::rvector const &v1, cvm::rvector const &v2)
friend inline cvm::real operator * (cvm::rvector const &v1, cvm::rvector const &v2)
{
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
}
friend inline cvm::rvector operator * (cvm::real const &a, cvm::rvector const &v)
friend inline cvm::rvector operator * (cvm::real const &a, cvm::rvector const &v)
{
return cvm::rvector (a*v.x, a*v.y, a*v.z);
}
friend inline cvm::rvector operator * (cvm::rvector const &v, cvm::real const &a)
friend inline cvm::rvector operator * (cvm::rvector const &v, cvm::real const &a)
{
return cvm::rvector (a*v.x, a*v.y, a*v.z);
}
friend inline cvm::rvector operator / (cvm::rvector const &v, cvm::real const &a)
friend inline cvm::rvector operator / (cvm::rvector const &v, cvm::real const &a)
{
return cvm::rvector (v.x/a, v.y/a, v.z/a);
}
};
@ -186,7 +186,7 @@ public:
{
return length;
}
/// Default constructor
inline vector1d (T const &t = T())
{
@ -251,7 +251,7 @@ public:
return prod;
}
/// Formatted output
/// Formatted output
friend std::ostream & operator << (std::ostream &os,
vector1d<T, length> const &v)
{
@ -310,7 +310,7 @@ public:
this->alloc();
reset();
}
/// Constructor from a 2-d C array
inline matrix2d (T const **m)
{
@ -380,7 +380,7 @@ public:
// }
// }
/// Formatted output
/// Formatted output
friend std::ostream & operator << (std::ostream &os,
matrix2d<T, outer_length, inner_length> const &m)
{
@ -454,16 +454,16 @@ public:
inline cvm::real zz() const { return array[2][2]; }
/// Constructor from a 2-d C array
inline rmatrix (cvm::real const **m)
: cvm::matrix2d<cvm::real, 3, 3> (m)
inline rmatrix (cvm::real const **m)
: cvm::matrix2d<cvm::real, 3, 3> (m)
{}
/// Default constructor
inline rmatrix()
inline rmatrix()
: cvm::matrix2d<cvm::real, 3, 3>()
{}
/// Constructor component by component
/// Constructor component by component
inline rmatrix (cvm::real const &xxi,
cvm::real const &xyi,
cvm::real const &xzi,
@ -472,7 +472,7 @@ public:
cvm::real const &yzi,
cvm::real const &zxi,
cvm::real const &zyi,
cvm::real const &zzi)
cvm::real const &zzi)
: cvm::matrix2d<cvm::real, 3, 3>()
{
this->xx() = xxi;
@ -488,7 +488,7 @@ public:
/// Destructor
inline ~rmatrix()
{}
{}
/// Return the determinant
inline cvm::real determinant() const
@ -528,7 +528,7 @@ public:
};
inline cvm::rvector operator * (cvm::rmatrix const &m,
cvm::rvector const &r)
{
@ -680,7 +680,7 @@ public:
return std::sqrt (this->norm2());
}
/// Return the conjugate quaternion
/// Return the conjugate quaternion
inline cvm::quaternion conjugate() const
{
return cvm::quaternion (q0, -q1, -q2, -q3);
@ -720,7 +720,7 @@ public:
return cvm::quaternion (0.0, v.x, v.y, v.z);
}
/// Return the vector component
inline cvm::rvector get_vector() const
inline cvm::rvector get_vector() const
{
return cvm::rvector (q1, q2, q3);
}
@ -1002,11 +1002,11 @@ public:
if (q.q0 != 0.0) {
// cvm::real const x = iprod/q.q0;
cvm::real const dspindx = (180.0/PI) * 2.0 * (1.0 / (1.0 + (iprod*iprod)/(q.q0*q.q0)));
return
cvm::quaternion ( dspindx * (iprod * (-1.0) / (q.q0*q.q0)),
return
cvm::quaternion ( dspindx * (iprod * (-1.0) / (q.q0*q.q0)),
dspindx * ((1.0/q.q0) * axis.x),
dspindx * ((1.0/q.q0) * axis.y),
dspindx * ((1.0/q.q0) * axis.z));
@ -1023,11 +1023,11 @@ public:
inline cvm::real cos_theta (cvm::rvector const &axis) const
{
cvm::rvector const q_vec = q.get_vector();
cvm::real const alpha =
cvm::real const alpha =
(180.0/PI) * 2.0 * std::atan2 (axis * q_vec, q.q0);
cvm::real const cos_spin_2 = std::cos (alpha * (PI/180.0) * 0.5);
cvm::real const cos_theta_2 = ( (cos_spin_2 != 0.0) ?
cvm::real const cos_theta_2 = ( (cos_spin_2 != 0.0) ?
(q.q0 / cos_spin_2) :
(0.0) );
// cos(2t) = 2*cos(t)^2 - 1
@ -1044,7 +1044,7 @@ public:
if (q.q0 != 0.0) {
cvm::real const d_cos_theta_dq0 =
cvm::real const d_cos_theta_dq0 =
(4.0 * q.q0 / (cos_spin_2*cos_spin_2)) *
(1.0 - (iprod*iprod)/(q.q0*q.q0) / (1.0 + (iprod*iprod)/(q.q0*q.q0)));
@ -1052,7 +1052,7 @@ public:
(4.0 * q.q0 / (cos_spin_2*cos_spin_2) *
(iprod/q.q0) / (1.0 + (iprod*iprod)/(q.q0*q.q0)));
return cvm::quaternion (d_cos_theta_dq0,
return cvm::quaternion (d_cos_theta_dq0,
d_cos_theta_dqn * axis.x,
d_cos_theta_dqn * axis.y,
d_cos_theta_dqn * axis.z);

View File

@ -28,7 +28,7 @@ void colvarvalue::error_rside
cvm::fatal_error ("Trying to assign a colvar value with type \""+
type_desc[this->value_type]+"\" to one with type \""+
type_desc[vt]+"\".\n");
}
}
void colvarvalue::error_lside
(colvarvalue::Type const &vt) const
@ -36,7 +36,7 @@ void colvarvalue::error_lside
cvm::fatal_error ("Trying to use a colvar value with type \""+
type_desc[vt]+"\" as one of type \""+
type_desc[this->value_type]+"\".\n");
}
}
@ -125,7 +125,7 @@ void colvarvalue::p2leg_opt (colvarvalue const &x,
break;
case colvarvalue::type_vector:
while (xvi != xv_end) {
cvm::real const cosine =
cvm::real const cosine =
((xvi)->rvector_value * x.rvector_value) /
((xvi)->rvector_value.norm() * x.rvector_value.norm());
xvi++;
@ -167,7 +167,7 @@ void colvarvalue::p2leg_opt (colvarvalue const &x,
break;
case colvarvalue::type_vector:
while (xvi != xv_end) {
cvm::real const cosine =
cvm::real const cosine =
((xvi)->rvector_value * x.rvector_value) /
((xvi)->rvector_value.norm() * x.rvector_value.norm());
xvi++;
@ -225,11 +225,11 @@ std::istream & operator >> (std::istream &is, colvarvalue &x)
switch (x.type()) {
case colvarvalue::type_scalar:
is >> x.real_value;
is >> x.real_value;
break;
case colvarvalue::type_vector:
case colvarvalue::type_unitvector:
is >> x.rvector_value;
is >> x.rvector_value;
break;
case colvarvalue::type_quaternion:
is >> x.quaternion_value;

View File

@ -37,7 +37,7 @@
/// the problem, because \link colvarvalue \endlink objects are first
/// initialized in the configuration, and the stream operation will be
/// performed only when reading restart files.
///
///
/// No problem of course with the output streams: \code os << x;
/// \endcode will print a different output according to the value of
/// colvarvalue::value_type, and the width of such output is returned
@ -92,7 +92,7 @@ public:
cvm::quaternion quaternion_value;
/// Current type of this colvarvalue object
Type value_type;
Type value_type;
static inline bool type_checking()
{
@ -146,7 +146,7 @@ public:
case type_scalar:
real_value = x.real_value;
break;
case type_vector:
case type_vector:
case type_unitvector:
rvector_value = x.rvector_value;
break;
@ -254,7 +254,7 @@ public:
/// Ensure that the two types are the same within a binary operator
void static check_types (colvarvalue const &x1, colvarvalue const &x2);
/// Undefined operation
/// Undefined operation
void undef_op() const;
/// Trying to assign this \link colvarvalue \endlink object to
@ -324,7 +324,7 @@ inline void colvarvalue::reset()
case colvarvalue::type_notset:
default:
break;
}
}
}
@ -344,7 +344,7 @@ inline void colvarvalue::apply_constraints()
case colvarvalue::type_notset:
default:
break;
}
}
}
@ -362,7 +362,7 @@ inline cvm::real colvarvalue::norm2() const
case colvarvalue::type_notset:
default:
return 0.0;
}
}
}
@ -383,7 +383,7 @@ inline colvarvalue colvarvalue::inverse() const
case colvarvalue::type_notset:
default:
undef_op();
}
}
return colvarvalue();
}
@ -391,11 +391,11 @@ inline colvarvalue colvarvalue::inverse() const
inline colvarvalue & colvarvalue::operator = (colvarvalue const &x)
{
if (this->value_type != type_notset)
if (this->value_type != x.value_type)
if (this->value_type != x.value_type)
error_lside (x.value_type);
this->value_type = x.value_type;
switch (this->value_type) {
case colvarvalue::type_scalar:
this->real_value = x.real_value;