Skip to content
This repository has been archived by the owner on Sep 27, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into marvinbernhardt-postupd-ibi
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinbernhardt authored Aug 2, 2021
2 parents 5dc23c4 + fd5c7df commit d5b784c
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 131 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,23 @@ Version 2022-dev
- switched molecule stable_vector to boost deque (#667)
- convert maps to unique_ptrs (#653)
- add iterative integral equation (iie) method (#675)
- fix issues with IHNC (newton-mod) Integral equation method (#683)
- fix issues with IHNC (newton-mod) Integral equation method (#683,
#700)
- fix links in documentation (#686, #687, #688)
- use ndim vector instead of std::vector (#689)
- adapted tokenizer api (#693)
- made membervariable format consistent (#694)
- add ability to run ibi as a postupd method (#696)
- removed unused functions (#702)

Version 2021.1 (released XX.03.21)
Version 2021.2 (released XX.07.21)
==================================

Version 2021.1 (released 18.07.21)
==================================

- format code with clang-12 and drop gmx2020 builds (#691)
- fix pos scaling (ang2nm) in lammps data reader (#697)

Version 2021 (released 13.03.21)
================================
Expand Down
22 changes: 0 additions & 22 deletions include/votca/csg/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,6 @@ class Topology {
Residue &CreateResidue(std::string name);
Residue &CreateResidue(std::string name, Index id);

/**
* \brief Create molecules based on the residue.
*
* This function scans the topology and creates molecules based on the resiude
* id. All beads with the same resid are put Index one molecule.
*/
void CreateMoleculesByResidue();

/**
* \brief put the whole topology in one molecule
* \param name name of the new molecule
*
* This function creates one big molecule for all beads in the topology.
*/
void CreateOneBigMolecule(std::string name);

/**
* \brief create molecules based on blocks of atoms
* \param[in] name molecule name
Expand Down Expand Up @@ -252,12 +236,6 @@ class Topology {
*/
void ClearMoleculeList() { molecules_.clear(); }

/**
* \brief adds all the beads+molecules+residues from other topology
* \param top topology to add
*/
void Add(Topology *top);

/**
* \brief copy topology data of different topology
* \param top topology to copy from
Expand Down
2 changes: 1 addition & 1 deletion share/scripts/inverse/potential_to_gromacs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ zero=0
if [[ $tabtype = "non-bonded" ]]; then
tablend="$(csg_get_property --allow-empty cg.inverse.gromacs.table_end)"
mdp="$(csg_get_property cg.inverse.gromacs.mdp)"
method="$(csg_get_property cg.inverse.method)"
if [[ -f ${mdp} ]]; then
echo "Found setting file '$mdp' now trying to check options in there"
rlist=$(get_simulation_setting rlist)
Expand All @@ -100,6 +99,7 @@ if [[ $tabtype = "non-bonded" ]]; then
die "${0##*/}: Error table is shorter then what mdp file ($mdp) needs, increase cg.inverse.gromacs.table_end in setting file.\nrlist ($rlist) + tabext ($tabext) > cg.inverse.gromacs.table_end ($tablend)"
max="$(csg_get_interaction_property max)"
rvdw="$(get_simulation_setting rvdw)"
method="$(csg_get_property cg.inverse.method)"
# with IIE methods, the RDF can be longer than the potential
if [[ $method -ne "iie" ]]; then
csg_calc "$max" ">" "$rvdw" && die "${0##*/}: rvdw ($rvdw) is smaller than max ($max)"
Expand Down
93 changes: 46 additions & 47 deletions src/libcsg/modules/io/lammpsdatareader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

// Standard includes
#include <string>
#include <vector>

// VOTCA includes
Expand All @@ -39,8 +40,8 @@ using namespace std;
/*****************************************************************************
* Internal Helper Functions *
*****************************************************************************/
vector<string> TrimCommentsFrom_(vector<string> fields) {
vector<string> tempFields;
std::vector<std::string> TrimCommentsFrom_(std::vector<std::string> fields) {
std::vector<std::string> tempFields;
for (const auto &field : fields) {
if (field.at(0) == '#') {
break;
Expand Down Expand Up @@ -120,9 +121,8 @@ bool LAMMPSDataReader::NextFrame(Topology &top) {
tools::getline(fl_, line);
while (!fl_.eof()) {

tools::Tokenizer tok(line, " ");
vector<string> fields = tok.ToVector();
fields = TrimCommentsFrom_(fields);
std::vector<std::string> fields =
TrimCommentsFrom_(tools::Tokenizer(line, " ").ToVector());
// If not check the size of the vector and parse according
// to the number of fields
if (fields.size() == 1) {
Expand Down Expand Up @@ -166,7 +166,7 @@ void LAMMPSDataReader::RenameMolecule(Molecule &mol) const {
}
}

bool LAMMPSDataReader::MatchOneFieldLabel_(vector<string> fields,
bool LAMMPSDataReader::MatchOneFieldLabel_(std::vector<std::string> fields,
Topology &top) {

if (fields.at(0) == "Masses") {
Expand All @@ -192,7 +192,7 @@ bool LAMMPSDataReader::MatchOneFieldLabel_(vector<string> fields,
return true;
}

bool LAMMPSDataReader::MatchTwoFieldLabels_(vector<string> fields,
bool LAMMPSDataReader::MatchTwoFieldLabels_(std::vector<std::string> fields,
Topology &top) {

string label = fields.at(0) + " " + fields.at(1);
Expand Down Expand Up @@ -221,7 +221,7 @@ bool LAMMPSDataReader::MatchTwoFieldLabels_(vector<string> fields,
return true;
}

bool LAMMPSDataReader::MatchThreeFieldLabels_(vector<string> fields) {
bool LAMMPSDataReader::MatchThreeFieldLabels_(std::vector<std::string> fields) {
string label = fields.at(1) + " " + fields.at(2);
if (label == "atom types") {
ReadNumTypes_(fields, "atom");
Expand All @@ -239,7 +239,7 @@ bool LAMMPSDataReader::MatchThreeFieldLabels_(vector<string> fields) {
return true;
}

bool LAMMPSDataReader::MatchFourFieldLabels_(vector<string> fields,
bool LAMMPSDataReader::MatchFourFieldLabels_(std::vector<std::string> fields,
Topology &top) {
string label = fields.at(2) + " " + fields.at(3);
if (label == "xlo xhi") {
Expand All @@ -258,9 +258,9 @@ void LAMMPSDataReader::InitializeAtomAndBeadTypes_() {

Index index = 0;
tools::Elements elements;
for (auto mass : data_["Masses"]) {
for (const auto &mass : data_["Masses"]) {
// Determine the mass associated with the atom
double mass_atom_bead = stod(mass.at(1));
double mass_atom_bead = std::stod(mass.at(1));
string baseName;
if (elements.isMassAssociatedWithElement(mass_atom_bead, 0.01)) {
baseName = elements.getEleShortClosestInMass(mass_atom_bead, 0.01);
Expand All @@ -275,15 +275,15 @@ void LAMMPSDataReader::InitializeAtomAndBeadTypes_() {
}
}

void LAMMPSDataReader::ReadBox_(vector<string> fields, Topology &top) {
void LAMMPSDataReader::ReadBox_(std::vector<std::string> fields,
Topology &top) {
Eigen::Matrix3d m = Eigen::Matrix3d::Zero();
m(0, 0) = stod(fields.at(1)) - stod(fields.at(0));
m(0, 0) = std::stod(fields.at(1)) - std::stod(fields.at(0));

for (Index i = 1; i < 3; ++i) {
string line;
tools::getline(fl_, line);
tools::Tokenizer tok(line, " ");
fields = tok.ToVector();
fields = tools::Tokenizer(line, " ").ToVector();
if (fields.size() != 4) {
throw runtime_error("invalid box format in the lammps data file");
}
Expand All @@ -293,55 +293,53 @@ void LAMMPSDataReader::ReadBox_(vector<string> fields, Topology &top) {
top.setBox(m * tools::conv::ang2nm);
}

void LAMMPSDataReader::SortIntoDataGroup_(string tag) {
string line;
void LAMMPSDataReader::SortIntoDataGroup_(std::string tag) {
std::string line;
tools::getline(fl_, line);
tools::getline(fl_, line);

vector<vector<string>> group;
string data_elem;
std::vector<std::vector<std::string>> group;
while (!line.empty()) {
tools::Tokenizer tok(line, " ");
vector<string> fields = tok.ToVector();
group.push_back(fields);
group.push_back(tools::Tokenizer(line, " ").ToVector());
tools::getline(fl_, line);
}

data_[tag] = group;
}

void LAMMPSDataReader::ReadNumTypes_(vector<string> fields, string type) {
numberOfDifferentTypes_[type] = stoi(fields.at(0));
void LAMMPSDataReader::ReadNumTypes_(std::vector<std::string> fields,
string type) {
numberOfDifferentTypes_[type] = std::stoi(fields.at(0));
}

void LAMMPSDataReader::ReadNumOfAtoms_(vector<string> fields, Topology &top) {
void LAMMPSDataReader::ReadNumOfAtoms_(std::vector<std::string> fields,
Topology &top) {
numberOf_["atoms"] = stoi(fields.at(0));
if (!topology_ && numberOf_["atoms"] != top.BeadCount()) {
std::runtime_error("Number of beads in topology and trajectory differ");
}
}

void LAMMPSDataReader::ReadNumOfBonds_(vector<string> fields) {
void LAMMPSDataReader::ReadNumOfBonds_(std::vector<std::string> fields) {
numberOf_["bonds"] = stoi(fields.at(0));
}

void LAMMPSDataReader::ReadNumOfAngles_(vector<string> fields) {
void LAMMPSDataReader::ReadNumOfAngles_(std::vector<std::string> fields) {
numberOf_["angles"] = stoi(fields.at(0));
}

void LAMMPSDataReader::ReadNumOfDihedrals_(vector<string> fields) {
void LAMMPSDataReader::ReadNumOfDihedrals_(std::vector<std::string> fields) {
numberOf_["dihedrals"] = stoi(fields.at(0));
}

void LAMMPSDataReader::ReadNumOfImpropers_(vector<string> fields) {
void LAMMPSDataReader::ReadNumOfImpropers_(std::vector<std::string> fields) {
numberOf_["impropers"] = stoi(fields.at(0));
}

LAMMPSDataReader::lammps_format LAMMPSDataReader::determineDataFileFormat_(
string line) {

tools::Tokenizer tok(line, " ");
vector<string> fields = tok.ToVector();
std::vector<std::string> fields = tools::Tokenizer(line, " ").ToVector();
lammps_format format;
if (fields.size() == 5 || fields.size() == 8) {
format = style_atomic;
Expand All @@ -360,10 +358,9 @@ LAMMPSDataReader::lammps_format LAMMPSDataReader::determineDataFileFormat_(
void LAMMPSDataReader::ReadAtoms_(Topology &top) {

if (data_.count("Masses") == 0) {
string err =
throw runtime_error(
"You are attempting to read in the atom block before the masses, or "
"you have failed to include the masses in the data file.";
throw runtime_error(err);
"you have failed to include the masses in the data file.");
}

string line;
Expand All @@ -381,10 +378,10 @@ void LAMMPSDataReader::ReadAtoms_(Topology &top) {
chargeRead = true;
}

map<Index, string> sorted_file;
std::map<Index, string> sorted_file;
Index startingIndex;
Index startingIndexMolecule = 0;
istringstream issfirst(line);
std::istringstream issfirst(line);
issfirst >> startingIndex;
if (moleculeRead) {
issfirst >> startingIndexMolecule;
Expand All @@ -396,7 +393,7 @@ void LAMMPSDataReader::ReadAtoms_(Topology &top) {
Index atomId = 0;
Index moleculeId = 0;
while (!line.empty()) {
istringstream iss(line);
std::istringstream iss(line);
iss >> atomId;
if (moleculeRead) {
iss >> moleculeId;
Expand Down Expand Up @@ -455,13 +452,14 @@ void LAMMPSDataReader::ReadAtoms_(Topology &top) {
mol = molecules_[moleculeId];
}

double mass = stod(data_["Masses"].at(atomTypeId).at(1));
double mass = std::stod(data_["Masses"].at(atomTypeId).at(1));

if (Index(data_.at("Masses").size()) <= atomTypeId) {
string err =
"The atom block contains an atom of type " + to_string(atomTypeId) +
std::string err =
"The atom block contains an atom of type " +
std::to_string(atomTypeId) +
" however, the masses are only specified for atoms up to type " +
to_string(data_.at("Masses").size() - 1);
std::to_string(data_.at("Masses").size() - 1);
throw runtime_error(err);
}

Expand Down Expand Up @@ -496,7 +494,7 @@ void LAMMPSDataReader::ReadAtoms_(Topology &top) {
}

Eigen::Vector3d xyz_pos(x, y, z);
b->setPos(xyz_pos);
b->setPos(xyz_pos * tools::conv::ang2nm);
}

if (top.BeadCount() != numberOf_["atoms"]) {
Expand Down Expand Up @@ -554,18 +552,19 @@ void LAMMPSDataReader::ReadBonds_(Topology &top) {
}

if (bond_count != numberOf_["bonds"]) {
string err =
std::string err =
"The number of bonds read in is not equivalent to the "
"number of bonds indicated to exist in the lammps data file. \n"
"Number of bonds that should exist " +
to_string(numberOf_["bonds"]) + "\nNumber of bonds that were read in " +
to_string(bond_count) + "\n";
std::to_string(numberOf_["bonds"]) +
"\nNumber of bonds that were read in " + std::to_string(bond_count) +
"\n";
throw runtime_error(err);
}
}

void LAMMPSDataReader::ReadAngles_(Topology &top) {
string line;
std::string line;
tools::getline(fl_, line);
tools::getline(fl_, line);
boost::trim(line);
Expand All @@ -579,7 +578,7 @@ void LAMMPSDataReader::ReadAngles_(Topology &top) {
while (!line.empty()) {

if (topology_) {
istringstream iss(line);
std::istringstream iss(line);
iss >> angleId;
iss >> angleTypeId;
iss >> atom1Id;
Expand Down
Loading

0 comments on commit d5b784c

Please sign in to comment.