Loading...
Searching...
No Matches
mol_sys.cpp
Go to the documentation of this file.
1//-----------------------------------------------------------------------------------
2// d-SEAMS - Deferred Structural Elucidation Analysis for Molecular Simulations
3//
4// Copyright (c) 2018--present d-SEAMS core team
5//
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the MIT License as published by
8// the Open Source Initiative.
9//
10// A copy of the MIT License is included in the LICENSE file of this repository.
11// You should have received a copy of the MIT License along with this program.
12// If not, see <https://opensource.org/licenses/MIT>.
13//-----------------------------------------------------------------------------------
14
15#include <iostream>
16#include <memory>
17#include <mol_sys.hpp>
18
26 //
27 std::vector<molSys::Point<double>> tempPts;
28 std::vector<double> tempBox;
29 //
30 std::vector<double> tempBox1;
31
32 tempPts.swap(yCloud->pts);
33 tempBox.swap(yCloud->box);
34 tempBox1.swap(yCloud->boxLow);
35 yCloud->idIndexMap.clear();
36
37 return *yCloud;
38}
39
44std::unordered_map<int, int> molSys::createIDMolIDmap(
46 std::unordered_map<int, int>
47 idMolIDmap; // atom IDs as keys and mol IDs as values
48 int iatomMolID; // molID of the current iatom
49 int iatomID; // atom ID of the current iatom
50
51 // Loop through the atoms in yCloud
52 for (int iatom = 0; iatom < yCloud->nop; iatom++) {
53 iatomID = yCloud->pts[iatom].atomID; // atom ID
54 iatomMolID = yCloud->pts[iatom].molID; // molecular ID
55 // Update the unordered map
56 idMolIDmap[iatomID] = iatomMolID;
57 } // end of loop through every iatom in pointCloud
58
59 return idMolIDmap;
60}
61
67std::unordered_multimap<int, int> molSys::createMolIDAtomIDMultiMap(
69 std::unordered_multimap<int, int>
70 molIDAtomIDmap; // atom IDs as keys and mol IDs as values
71 int iatomMolID; // molID of the current iatom
72 int iatomID; // atom ID of the current iatom
73
74 // Loop through the atoms in yCloud
75 for (int iatom = 0; iatom < yCloud->nop; iatom++) {
76 iatomID = yCloud->pts[iatom].atomID; // atom ID
77 iatomMolID = yCloud->pts[iatom].molID; // molecular ID
78 // Update the unordered multimap
79 molIDAtomIDmap.emplace(iatomMolID,iatomID);
80 } // end of loop through every iatom in pointCloud
81
82 return molIDAtomIDmap;
83}
84
89std::vector<std::vector<int>> molSys::hAtomMolList(
92 std::vector<std::vector<int>>
93 hMolList; // the first column contains the molecular IDs, and the next
94 // two elements in the row are the hydrogen bond atoms in the
95 // molecule
96 int iMolID; // Current molecular ID
97 int nHatoms; // No. of h atoms found for a particular molID.
98
99 for (int iatom = 0; iatom < oCloud->nop; iatom++) {
100 // Get the molID
101 iMolID = oCloud->pts[iatom].molID;
102
103 hMolList.push_back(std::vector<int>()); // Empty vector for the index iatom
104 // Fill the first element with the molecular ID
105 hMolList[iatom].push_back(iMolID);
106
107 nHatoms = 0; // init (no. of h atoms for the particular molID)
108
109 // Now search through the hydrogen atom pointCloud for this particular molID
110 for (int jatom = 0; jatom < hCloud->nop; jatom++) {
111 if (hCloud->pts[jatom].molID == iMolID) {
112 hMolList[iatom].push_back(jatom); // fill the hatom index
113 nHatoms++;
114 // If the two hydrogens have been found, break out of the loop
115 if (nHatoms == 2) {
116 break;
117 } // end of break
118 } // end of check to see if jatom is part of iMolID
119 } // end of loop through the hydrogen atom pointCloud
120 } // end of looping through every oxygen atom
121
122 return hMolList;
123} // end of function
124
131int molSys::searchMolList(std::vector<std::vector<int>> molList,
132 int molIDtoFind) {
133 int index = -1; // init invalid index
134
135 for (int iatom = 0; iatom < molList.size(); iatom++) {
136 // If the molecular ID is equal, return the index in the array
137 if (molList[iatom][0] == molIDtoFind) {
138 index = iatom;
139 return index;
140 } // end of check
141 } // end of looping through iatom
142
143 return index;
144}
std::vector< std::vector< int > > hAtomMolList(molSys::PointCloud< molSys::Point< double >, double > *hCloud, molSys::PointCloud< molSys::Point< double >, double > *oCloud)
Definition mol_sys.cpp:89
std::unordered_map< int, int > createIDMolIDmap(molSys::PointCloud< molSys::Point< double >, double > *yCloud)
Definition mol_sys.cpp:44
std::unordered_multimap< int, int > createMolIDAtomIDMultiMap(molSys::PointCloud< molSys::Point< double >, double > *yCloud)
Definition mol_sys.cpp:67
int searchMolList(std::vector< std::vector< int > > molList, int molIDtoFind)
Definition mol_sys.cpp:131
std::unordered_map< int, int > idIndexMap
xlo, ylo, zlo
Definition mol_sys.hpp:176
molSys::PointCloud< molSys::Point< double >, double > clearPointCloud(molSys::PointCloud< molSys::Point< double >, double > *yCloud)
//! Function for clearing vectors in PointCloud after multiple usage
Definition mol_sys.cpp:24
The main molecular system handler.
This contains a collection of points; contains information for a particular frame.
Definition mol_sys.hpp:170
This contains per-particle information.
Definition mol_sys.hpp:149