votca 2024.2-dev
Loading...
Searching...
No Matches
lammpsdatareader.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18#ifndef VOTCA_CSG_LAMMPSDATAREADER_PRIVATE_H
19#define VOTCA_CSG_LAMMPSDATAREADER_PRIVATE_H
20
21// Standard includes
22#include <fstream>
23#include <iostream>
24#include <string>
25
26// VOTCA includes
28
29// Local VOTCA includes
32
33namespace votca {
34namespace csg {
35
36class Molecule;
37
46 public:
55
56 LAMMPSDataReader() = default;
57 ~LAMMPSDataReader() override = default;
58
60 bool ReadTopology(std::string file, Topology &top) override;
61
63 bool Open(const std::string &file) override;
65 bool FirstFrame(Topology &top) override;
67 bool NextFrame(Topology &top) override;
69 void Close() override;
70
71 private:
72 std::ifstream fl_;
73 std::string fname_;
75
76 std::map<std::string, std::vector<std::vector<std::string>>> data_;
77
78 // Index - atom type starting index of 0
79 // .at(0) - element symbol or bead
80 // .at(1) - atom name may be the same as the element symbol or bead depending
81 // on if there is more than one atom type for a given element
82 std::map<Index, std::string> atomtypes_;
83
84 // String is the type .e.g. "atom","bond" etc
85 // Index is the number of different types
86 std::map<std::string, Index> numberOfDifferentTypes_;
87
88 // String is the type .e.g. "atom", "bond" etc
89 // Index is the number of them
90 std::map<std::string, Index> numberOf_;
91
92 // First Index is the molecule id
93 // Second Index is the molecule ptr
94 std::map<Index, Molecule *> molecules_;
95
96 // First Index is the atom id second the molecule id
97 std::map<Index, Index> atomIdToMoleculeId_;
98
99 // First Index is the atom id second the atom index
100 std::map<Index, Index> atomIdToIndex_;
101
102 bool MatchOneFieldLabel_(std::vector<std::string> fields, Topology &top);
103 bool MatchTwoFieldLabels_(std::vector<std::string> fields, Topology &top);
104 bool MatchThreeFieldLabels_(std::vector<std::string> fields);
105 bool MatchFourFieldLabels_(std::vector<std::string> fields, Topology &top);
106
107 void ReadBox_(std::vector<std::string> fields, Topology &top);
108 void SortIntoDataGroup_(std::string tag);
109 void ReadNumTypes_(std::vector<std::string> fields, std::string type);
110
111 void ReadNumOfAtoms_(std::vector<std::string> fields, Topology &top);
112 void ReadNumOfBonds_(std::vector<std::string> fields);
113 void ReadNumOfAngles_(std::vector<std::string> fields);
114 void ReadNumOfDihedrals_(std::vector<std::string> fields);
115 void ReadNumOfImpropers_(std::vector<std::string> fields);
116
117 void ReadAtoms_(Topology &top);
118 void ReadBonds_(Topology &top);
119 void ReadAngles_(Topology &top);
120 void ReadDihedrals_(Topology &top);
121 void SkipImpropers_();
122
123 void RenameMolecules(MoleculeContainer &molecules) const;
124
130 lammps_format determineDataFileFormat_(std::string line);
131
169};
170} // namespace csg
171} // namespace votca
172
173#endif // VOTCA_CSG_LAMMPSDATAREADER_PRIVATE_H
class for reading lammps data files
void ReadNumOfAtoms_(std::vector< std::string > fields, Topology &top)
lammps_format determineDataFileFormat_(std::string line)
void ReadNumOfDihedrals_(std::vector< std::string > fields)
void InitializeAtomAndBeadTypes_()
Determines atom and bead types based on masses in lammps files.
void ReadNumOfAngles_(std::vector< std::string > fields)
bool MatchFourFieldLabels_(std::vector< std::string > fields, Topology &top)
const tools::MolarForceUnit force_unit
const tools::ChargeUnit charge_unit
void RenameMolecules(MoleculeContainer &molecules) const
std::map< std::string, Index > numberOfDifferentTypes_
bool ReadTopology(std::string file, Topology &top) override
open, read and close topology file
void Close() override
close the topology file
const tools::MolarEnergyUnit energy_unit
void ReadBox_(std::vector< std::string > fields, Topology &top)
void ReadNumOfImpropers_(std::vector< std::string > fields)
void SortIntoDataGroup_(std::string tag)
void ReadDihedrals_(Topology &top)
bool FirstFrame(Topology &top) override
read in the first frame of trajectory file
std::map< std::string, std::vector< std::vector< std::string > > > data_
~LAMMPSDataReader() override=default
std::map< std::string, Index > numberOf_
bool NextFrame(Topology &top) override
read in the next frame of trajectory file
const tools::TimeUnit time_unit
std::map< Index, Index > atomIdToIndex_
const tools::MassUnit mass_unit
void ReadNumTypes_(std::vector< std::string > fields, std::string type)
bool MatchOneFieldLabel_(std::vector< std::string > fields, Topology &top)
std::map< Index, Molecule * > molecules_
std::map< Index, std::string > atomtypes_
void ReadNumOfBonds_(std::vector< std::string > fields)
bool MatchThreeFieldLabels_(std::vector< std::string > fields)
std::map< Index, Index > atomIdToMoleculeId_
bool Open(const std::string &file) override
open a trajectory file
const tools::DistanceUnit distance_unit
bool MatchTwoFieldLabels_(std::vector< std::string > fields, Topology &top)
topology of the whole system
Definition topology.h:81
trajectoryreader interface
boost::container::deque< Molecule, void, block_molecule_4x_t > MoleculeContainer
Definition topology.h:67
@ kilocalories_per_mole_angstrom
base class for all analysis tools
Definition basebead.h:33