OpenMD 3.2
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
ForceMatrixDecomposition.hpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the following paper when you publish your work:
33 *
34 * [1] Drisko et al., J. Open Source Softw. 9, 7004 (2024).
35 *
36 * Good starting points for code and simulation methodology are:
37 *
38 * [2] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
39 * [3] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
40 * [4] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
41 * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
42 * [6] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
43 * [7] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
44 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
45 * [9] Drisko & Gezelter, J. Chem. Theory Comput. 20, 4986-4997 (2024).
46 */
47
48#ifndef PARALLEL_FORCEMATRIXDECOMPOSITION_HPP
49#define PARALLEL_FORCEMATRIXDECOMPOSITION_HPP
50
51#include "brains/Snapshot.hpp"
53#include "parallel/ForceDecomposition.hpp"
54
55#ifdef IS_MPI
56#include "parallel/Communicator.hpp"
57#endif
58
59using namespace std;
60namespace OpenMD {
61
62 class ForceMatrixDecomposition : public ForceDecomposition {
63 public:
64 ForceMatrixDecomposition(SimInfo* info, InteractionManager* iMan);
65 ~ForceMatrixDecomposition();
66
68 void zeroWorkArrays();
69 void distributeData();
70 void collectIntermediateData();
71 void distributeIntermediateData();
72 void collectSelfData();
73 void collectData();
74
75 // neighbor list routines
76 void buildNeighborList(vector<int>& neighborList, vector<int>& point,
77 vector<Vector3d>& savedPositions);
78
79 // group bookkeeping
80 Vector3d& getGroupVelocityColumn(int cg2);
81
82 // Group->atom bookkeeping
83 vector<int>& getAtomsInGroupRow(int cg1);
84 vector<int>& getAtomsInGroupColumn(int cg2);
85 Vector3d getAtomToGroupVectorRow(int atom1, int cg1);
86 Vector3d getAtomToGroupVectorColumn(int atom2, int cg2);
87 RealType& getMassFactorRow(int atom1);
88 RealType& getMassFactorColumn(int atom2);
89
90 // spatial data
91 Vector3d getIntergroupVector(int cg1, int cg2);
92 Vector3d getInteratomicVector(int atom1, int atom2);
93
94 // atom bookkeeping
95 int& getNAtomsInRow();
96 int getTopologicalDistance(int atom1, int atom2);
97 vector<int>& getExcludesForAtom(int atom1);
98 bool skipAtomPair(int atom1, int atom2, int cg1, int cg2);
99 bool excludeAtomPair(int atom1, int atom2);
100 int getGlobalIDRow(int atom1);
101 int getGlobalIDCol(int atom1);
102 int getGlobalID(int atom1);
103 void addForceToAtomRow(int atom1, Vector3d fg);
104 void addForceToAtomColumn(int atom2, Vector3d fg);
105 Vector3d& getAtomVelocityColumn(int atom2);
106
107 // filling interaction blocks with pointers
108 void fillInteractionData(InteractionData& idat, int atom1, int atom2,
109 bool newAtom1 = true);
110 void unpackInteractionData(InteractionData& idat, int atom1, int atom2);
111 void unpackPrePairData(InteractionData& idat, int atom1, int atom2);
112
113 private:
114 int nLocal_;
115 int nGroups_;
116 vector<int> AtomLocalToGlobal;
117 vector<int> cgLocalToGlobal;
118 vector<RealType> groupCutoff;
119 vector<int> groupToGtype;
120
121#ifdef IS_MPI
122 DataStorage atomRowData;
123 DataStorage atomColData;
124 DataStorage cgRowData;
125 DataStorage cgColData;
126
127 int nAtomsInRow_;
128 int nAtomsInCol_;
129 int nGroupsInRow_;
130 int nGroupsInCol_;
131
132 Communicator<Row> rowComm;
133 Communicator<Column> colComm;
134
135 Plan<int>* AtomPlanIntRow {nullptr};
136 Plan<RealType>* AtomPlanRealRow {nullptr};
137 Plan<Vector3d>* AtomPlanVectorRow {nullptr};
138 Plan<Mat3x3d>* AtomPlanMatrixRow {nullptr};
139 Plan<potVec>* AtomPlanPotRow {nullptr};
140
141 Plan<int>* AtomPlanIntColumn {nullptr};
142 Plan<RealType>* AtomPlanRealColumn {nullptr};
143 Plan<Vector3d>* AtomPlanVectorColumn {nullptr};
144 Plan<Mat3x3d>* AtomPlanMatrixColumn {nullptr};
145 Plan<potVec>* AtomPlanPotColumn {nullptr};
146
147 Plan<int>* cgPlanIntRow {nullptr};
148 Plan<Vector3d>* cgPlanVectorRow {nullptr};
149 Plan<int>* cgPlanIntColumn {nullptr};
150 Plan<Vector3d>* cgPlanVectorColumn {nullptr};
151
152 // work arrays for assembling potential energy
153 vector<potVec> pot_row;
154 vector<potVec> pot_col;
155
156 vector<potVec> expot_row;
157 vector<potVec> expot_col;
158
159 vector<potVec> selepot_row;
160 vector<potVec> selepot_col;
161
162 vector<int> identsRow;
163 vector<int> identsCol;
164
165 vector<int> regionsRow;
166 vector<int> regionsCol;
167
168 vector<AtomType*> atypesRow;
169 vector<AtomType*> atypesCol;
170
171 vector<int> AtomRowToGlobal;
172 vector<int> AtomColToGlobal;
173
174 public:
175 vector<int> cgRowToGlobal;
176 vector<int> cgColToGlobal;
177
178 private:
179 vector<vector<int>> cellListRow_;
180 vector<vector<int>> cellListCol_;
181
182 vector<vector<int>> groupListRow_;
183 vector<vector<int>> groupListCol_;
184
185 vector<RealType> massFactorsRow;
186 vector<RealType> massFactorsCol;
187
188 vector<int> regionRow;
189 vector<int> regionCol;
190#endif
191 };
192} // namespace OpenMD
193
194#endif
bool excludeAtomPair(int atom1, int atom2)
We need to handle the interactions for atoms who are involved in the same rigid body as well as some ...
vector< int > & getAtomsInGroupRow(int cg1)
returns the list of atoms belonging to this group.
bool skipAtomPair(int atom1, int atom2, int cg1, int cg2)
We need to exclude some overcounted interactions that result from the parallel decomposition.
void distributeInitialData()
distributeInitialData is essentially a copy of the older fortran SimulationSetup
void collectSelfData()
Collects information obtained during the post-pair (and embedding functional) loops onto local data s...
InteractionManager is responsible for keeping track of the non-bonded interactions (C++).
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
Definition SimInfo.hpp:96
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
The InteractionData struct.