Small fixes to Colvars library
Primarily a list of small fixes, combined with cosmetic changes and cleanups in several files. 6d0c917 2018-04-29 Fix missing deallocation of output stream object (reported by HanatoK) [Giacomo Fiorin] c92d369 2018-04-17 Do not test for atom group size [Jérôme Hénin] 431e52a 2018-04-06 Allow scripted/custom colvars to be periodic [Jérôme Hénin] 81d391f 2018-04-05 Split colvarcomp constructor into POD constructor + init() function [Giacomo Fiorin] 9b85d5f 2018-03-13 Fix issue with out-of-order atom selections; clarify format for ref positions [Giacomo Fiorin] 0e0ed37 2018-03-07 Support triclinic unit cells in VMD, clean up PBC functions [Giacomo Fiorin] eed97c9 2018-02-24 Obtain integer version number from version string [Giacomo Fiorin] c17f3cd 2018-02-23 Write trajectory labels only when needed [Giacomo Fiorin]
This commit is contained in:
@ -26,7 +26,10 @@
|
||||
|
||||
|
||||
|
||||
colvarproxy_system::colvarproxy_system() {}
|
||||
colvarproxy_system::colvarproxy_system()
|
||||
{
|
||||
reset_pbc_lattice();
|
||||
}
|
||||
|
||||
|
||||
colvarproxy_system::~colvarproxy_system() {}
|
||||
@ -55,10 +58,73 @@ bool colvarproxy_system::total_forces_same_step() const
|
||||
}
|
||||
|
||||
|
||||
cvm::real colvarproxy_system::position_dist2(cvm::atom_pos const &pos1,
|
||||
cvm::atom_pos const &pos2)
|
||||
inline int round_to_integer(cvm::real x)
|
||||
{
|
||||
return (position_distance(pos1, pos2)).norm2();
|
||||
return std::floor(x+0.5);
|
||||
}
|
||||
|
||||
|
||||
void colvarproxy_system::update_pbc_lattice()
|
||||
{
|
||||
// Periodicity is assumed in all directions
|
||||
|
||||
if (boundaries_type == boundaries_unsupported ||
|
||||
boundaries_type == boundaries_non_periodic) {
|
||||
cvm::error("Error: setting PBC lattice with unsupported boundaries.\n",
|
||||
BUG_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
cvm::rvector const v = cvm::rvector::outer(unit_cell_y, unit_cell_z);
|
||||
reciprocal_cell_x = v/(v*unit_cell_x);
|
||||
}
|
||||
{
|
||||
cvm::rvector const v = cvm::rvector::outer(unit_cell_z, unit_cell_x);
|
||||
reciprocal_cell_y = v/(v*unit_cell_y);
|
||||
}
|
||||
{
|
||||
cvm::rvector const v = cvm::rvector::outer(unit_cell_x, unit_cell_y);
|
||||
reciprocal_cell_z = v/(v*unit_cell_z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void colvarproxy_system::reset_pbc_lattice()
|
||||
{
|
||||
unit_cell_x.reset();
|
||||
unit_cell_y.reset();
|
||||
unit_cell_z.reset();
|
||||
reciprocal_cell_x.reset();
|
||||
reciprocal_cell_y.reset();
|
||||
reciprocal_cell_z.reset();
|
||||
}
|
||||
|
||||
|
||||
cvm::rvector colvarproxy_system::position_distance(cvm::atom_pos const &pos1,
|
||||
cvm::atom_pos const &pos2)
|
||||
const
|
||||
{
|
||||
if (boundaries_type == boundaries_unsupported) {
|
||||
cvm::error("Error: unsupported boundary conditions.\n", INPUT_ERROR);
|
||||
}
|
||||
|
||||
cvm::rvector diff = (pos2 - pos1);
|
||||
|
||||
if (boundaries_type == boundaries_non_periodic) return diff;
|
||||
|
||||
cvm::real const x_shift = round_to_integer(reciprocal_cell_x*diff);
|
||||
cvm::real const y_shift = round_to_integer(reciprocal_cell_y*diff);
|
||||
cvm::real const z_shift = round_to_integer(reciprocal_cell_z*diff);
|
||||
|
||||
diff.x -= x_shift*unit_cell_x.x + y_shift*unit_cell_y.x +
|
||||
z_shift*unit_cell_z.x;
|
||||
diff.y -= x_shift*unit_cell_x.y + y_shift*unit_cell_y.y +
|
||||
z_shift*unit_cell_z.y;
|
||||
diff.z -= x_shift*unit_cell_x.z + y_shift*unit_cell_y.z +
|
||||
z_shift*unit_cell_z.z;
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
|
||||
@ -132,7 +198,7 @@ void colvarproxy_atoms::clear_atom(int index)
|
||||
int colvarproxy_atoms::load_atoms(char const *filename,
|
||||
cvm::atom_group &atoms,
|
||||
std::string const &pdb_field,
|
||||
double const)
|
||||
double)
|
||||
{
|
||||
return cvm::error("Error: loading atom identifiers from a file "
|
||||
"is currently not implemented.\n",
|
||||
@ -142,9 +208,9 @@ int colvarproxy_atoms::load_atoms(char const *filename,
|
||||
|
||||
int colvarproxy_atoms::load_coords(char const *filename,
|
||||
std::vector<cvm::atom_pos> &pos,
|
||||
const std::vector<int> &indices,
|
||||
std::vector<int> const &sorted_ids,
|
||||
std::string const &pdb_field,
|
||||
double const)
|
||||
double)
|
||||
{
|
||||
return cvm::error("Error: loading atomic coordinates from a file "
|
||||
"is currently not implemented.\n",
|
||||
@ -661,6 +727,7 @@ int colvarproxy_io::close_output_stream(std::string const &output_name)
|
||||
for ( ; osi != output_files.end(); osi++, osni++) {
|
||||
if (*osni == output_name) {
|
||||
((std::ofstream *) (*osi))->close();
|
||||
delete *osi;
|
||||
output_files.erase(osi);
|
||||
output_stream_names.erase(osni);
|
||||
return COLVARS_OK;
|
||||
@ -729,3 +796,13 @@ size_t colvarproxy::restart_frequency()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int colvarproxy::get_version_from_string(char const *version_string)
|
||||
{
|
||||
std::string const v(version_string);
|
||||
std::istringstream is(v.substr(0, 4) + v.substr(5, 2) + v.substr(8, 2));
|
||||
int newint;
|
||||
is >> newint;
|
||||
return newint;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user