Skip to content

Commit 8c0a5d5

Browse files
Merge pull request #1389 from Iximiel/feature/scalaeAtomDistribution
2 parents f100869 + 9be0384 commit 8c0a5d5

7 files changed

Lines changed: 349 additions & 53 deletions

File tree

CHANGES/v2.11.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ This page contains changes that will end up in 2.11
55
### Changes relevant for users:
66

77
- When using [MOLINFO](MOLINFO.md) with the `WHOLE` flag, PBCs in the following actions will be reconstructed using a minimum spanning tree based on the coordinates stored in the MOLFILE reference pdb.
8+
- When using the benchmark now it is possible to scale the atom distances in the synthetic atom distribution (the base atomic distance is 1)
89

910
### Changes relevant for developers:
1011

1112
- The inputlines now are parsed using a dictionary instead of an array. This speeds up the parsing of massive input lines.
13+
- Abstracted the AtomDistribution functionality from the benchmark. It can be used in tests or in other
1214
- It is not possible anymore to register lowercase keywords and the developer must always specify the keywords completely as uppercase while parsing in the action constructor. There are no differences for the user, apart the entry in the manual for the DEBUG action: the user can still specify lowercase and mixed case keywords in the input file.
1315
- Some improvements in the management of the plugins:
1416
- Now the plugins have a common directory structure

regtest/tools/rt-make-AtomicDistribution/main.cpp

Lines changed: 92 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void atomsInBoxCheck(
3535
ofs <<header <<" all atoms in box along " <<xyz[j]<<" : "<< (upbound[j]<box[j*3+j]) << "\n";
3636
}
3737
}
38+
3839
void basecheck(std::string_view kind, std::ostream & ofs) {
3940
std::string header= "[baseCheck -"+ std::string(kind) + "-]:";
4041
ofs << header << "\n";
@@ -61,25 +62,49 @@ void replyTrajCheck(std::string_view kind,
6162
std::vector<double> basebox(9);
6263
unsigned nat = atoms.size();
6364
const auto oldNat=nat;
64-
auto rep= std::make_unique<repliedTrajectory>([&]() {
65+
66+
std::unique_ptr<PLMD::AtomDistribution> rep= std::make_unique<repliedTrajectory>([&]() {
6567
auto d = AtomDistribution::getAtomDistribution(kind);
6668
d->frame(atoms,basebox,0,rng);
6769
return d;
6870
}
6971
(),
70-
num[0],
71-
num[1],
72-
num[2],
72+
num[0], num[1], num[2],
7373
nat);
7474

7575
//this must return true
7676
ofs <<header<< " rep->overrideNat(nat)=" <<
7777
rep->overrideNat(nat) <<"\n";
78-
ofs <<header<< " new number of atoms: ( should be " << oldNat*num[0]*num[1]*num[2] << ") : " << nat <<"\n";
78+
ofs << header << " new number of atoms: ( should be " << oldNat*num[0]*num[1]*num[2] << ") : " << nat <<"\n";
7979
atoms.resize(nat);
8080
std::vector<double> box(9);
81-
rep->frame(atoms,box,0,rng);
81+
//the next frame is generated exactly as the "base one"
82+
//so that we can use the same base configuration
83+
Random rng2;
84+
rng2.setSeed(12345);
85+
rep->frame(atoms,box,0,rng2);
8286

87+
ofs << header << "The atoms are replicated correctly:\t";
88+
bool correct = true;
89+
Vector boxX(basebox[0],basebox[1],basebox[2]);
90+
Vector boxY(basebox[3],basebox[4],basebox[5]);
91+
Vector boxZ(basebox[6],basebox[7],basebox[8]);
92+
unsigned j=0;
93+
for (unsigned x=0; x<num[0] && correct; ++x) {
94+
for (unsigned y=0; y<num[1] && correct; ++y) {
95+
for (unsigned z=0; z<num[2] && correct; ++z) {
96+
for (unsigned i=0; i<oldNat && correct; ++i) {
97+
auto tmp = atoms[i] + (x * boxX + y * boxY + z * boxZ);
98+
correct = (abs(tmp[0] - atoms[j][0]) < 1000*PLMD::epsilon)&&
99+
(abs(tmp[1] - atoms[j][1]) < 1000*PLMD::epsilon)&&
100+
(abs(tmp[2] - atoms[j][2]) < 1000*PLMD::epsilon);
101+
++j;
102+
}
103+
}
104+
}
105+
}
106+
107+
ofs << correct << "\n";
83108
atomsInBoxCheck(atoms,box,header,ofs);
84109
ofs << "New box has the correct dimensions:\n";
85110
for (unsigned j=0; j<3; ++j) {
@@ -88,6 +113,58 @@ void replyTrajCheck(std::string_view kind,
88113
}
89114
}
90115

116+
void scaleTrajCheck(std::string_view kind,
117+
const double scale,
118+
std::ostream & ofs) {
119+
std::stringstream ss;
120+
ss << "[scaleTrajCheck -" << kind << "*"<< scale << "-]:";
121+
auto header = ss.str();
122+
ofs << header << "\n";
123+
//reinitialized each time for stability
124+
Random rng;
125+
rng.setSeed(12345);
126+
std::vector<Vector> baseatoms(200);
127+
std::vector<double> basebox(9);
128+
std::unique_ptr<PLMD::AtomDistribution> scaled= std::make_unique<scaledTrajectory>([&]() {
129+
std::unique_ptr<PLMD::AtomDistribution> d;
130+
if (kind == "sphere-reply212") {
131+
d = std::make_unique<repliedTrajectory>(
132+
AtomDistribution::getAtomDistribution("sphere"),
133+
2,1,2,baseatoms.size()/(2*1*2));
134+
} else {
135+
d = AtomDistribution::getAtomDistribution(kind);
136+
}
137+
d->frame(baseatoms,basebox,0,rng);
138+
return d;
139+
}
140+
(),
141+
scale);
142+
143+
std::vector<Vector> atoms(200);
144+
std::vector<double> box(9);
145+
//the next frame is generated exactly as the "base one"
146+
//so that we can use the same base configuration
147+
Random rng2;
148+
rng2.setSeed(12345);
149+
scaled->frame(atoms,box,0,rng2);
150+
151+
ofs << header << "The atoms are scaled correctly:\t";
152+
bool correct = true;
153+
for(unsigned i =0; i< atoms.size() && correct; ++i) {
154+
correct = (abs(scale*baseatoms[i][0] - atoms[i][0]) < 1000*PLMD::epsilon)&&
155+
(abs(scale*baseatoms[i][1] - atoms[i][1]) < 1000*PLMD::epsilon)&&
156+
(abs(scale*baseatoms[i][2] - atoms[i][2]) < 1000*PLMD::epsilon);
157+
158+
}
159+
ofs << correct << "\n";
160+
161+
atomsInBoxCheck(atoms,box,header,ofs);
162+
ofs << "New box has the correct dimensions:\n";
163+
for (unsigned j=0; j<3; ++j) {
164+
ofs <<header <<" correct box dimension " <<xyz[j]<<" : "
165+
<< ((scale*basebox[j*3+j] - box[j*3+j]) < 1000*PLMD::epsilon) << "\n";
166+
}
167+
}
91168

92169
int main() {
93170
std::ofstream ofs("output");
@@ -110,5 +187,14 @@ int main() {
110187
replyTrajCheck("sphere",num,ofs);
111188
ofs << "\n";
112189
}
190+
for (auto num : {
191+
0.5, 3.0, 10.0
192+
}) {
193+
scaleTrajCheck("sphere",num,ofs);
194+
scaleTrajCheck("sc",num,ofs);
195+
scaleTrajCheck("globs",num,ofs);
196+
scaleTrajCheck("sphere-reply212",num,ofs);
197+
ofs << "\n";
198+
}
113199
return 0;
114200
}

regtest/tools/rt-make-AtomicDistribution/output.reference

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Atoms are within box dimensions:
3131
[replyTrajCheck -sphere 1, 2, 3-]:
3232
[replyTrajCheck -sphere 1, 2, 3-]: rep->overrideNat(nat)=true
3333
[replyTrajCheck -sphere 1, 2, 3-]: new number of atoms: ( should be 1200) : 1200
34+
[replyTrajCheck -sphere 1, 2, 3-]:The atoms are replicated correctly: true
3435
Atoms are within box dimensions:
3536
[replyTrajCheck -sphere 1, 2, 3-]: all atoms in box along x : true
3637
[replyTrajCheck -sphere 1, 2, 3-]: all atoms in box along y : true
@@ -43,6 +44,7 @@ New box has the correct dimensions:
4344
[replyTrajCheck -sphere 2, 2, 2-]:
4445
[replyTrajCheck -sphere 2, 2, 2-]: rep->overrideNat(nat)=true
4546
[replyTrajCheck -sphere 2, 2, 2-]: new number of atoms: ( should be 1600) : 1600
47+
[replyTrajCheck -sphere 2, 2, 2-]:The atoms are replicated correctly: true
4648
Atoms are within box dimensions:
4749
[replyTrajCheck -sphere 2, 2, 2-]: all atoms in box along x : true
4850
[replyTrajCheck -sphere 2, 2, 2-]: all atoms in box along y : true
@@ -55,6 +57,7 @@ New box has the correct dimensions:
5557
[replyTrajCheck -sphere 1, 1, 1-]:
5658
[replyTrajCheck -sphere 1, 1, 1-]: rep->overrideNat(nat)=true
5759
[replyTrajCheck -sphere 1, 1, 1-]: new number of atoms: ( should be 200) : 200
60+
[replyTrajCheck -sphere 1, 1, 1-]:The atoms are replicated correctly: true
5861
Atoms are within box dimensions:
5962
[replyTrajCheck -sphere 1, 1, 1-]: all atoms in box along x : true
6063
[replyTrajCheck -sphere 1, 1, 1-]: all atoms in box along y : true
@@ -67,6 +70,7 @@ New box has the correct dimensions:
6770
[replyTrajCheck -sphere 3, 2, 1-]:
6871
[replyTrajCheck -sphere 3, 2, 1-]: rep->overrideNat(nat)=true
6972
[replyTrajCheck -sphere 3, 2, 1-]: new number of atoms: ( should be 1200) : 1200
73+
[replyTrajCheck -sphere 3, 2, 1-]:The atoms are replicated correctly: true
7074
Atoms are within box dimensions:
7175
[replyTrajCheck -sphere 3, 2, 1-]: all atoms in box along x : true
7276
[replyTrajCheck -sphere 3, 2, 1-]: all atoms in box along y : true
@@ -79,6 +83,7 @@ New box has the correct dimensions:
7983
[replyTrajCheck -sphere 3, 4, 7-]:
8084
[replyTrajCheck -sphere 3, 4, 7-]: rep->overrideNat(nat)=true
8185
[replyTrajCheck -sphere 3, 4, 7-]: new number of atoms: ( should be 16800) : 16800
86+
[replyTrajCheck -sphere 3, 4, 7-]:The atoms are replicated correctly: true
8287
Atoms are within box dimensions:
8388
[replyTrajCheck -sphere 3, 4, 7-]: all atoms in box along x : true
8489
[replyTrajCheck -sphere 3, 4, 7-]: all atoms in box along y : true
@@ -91,6 +96,7 @@ New box has the correct dimensions:
9196
[replyTrajCheck -sphere 5, 1, 1-]:
9297
[replyTrajCheck -sphere 5, 1, 1-]: rep->overrideNat(nat)=true
9398
[replyTrajCheck -sphere 5, 1, 1-]: new number of atoms: ( should be 1000) : 1000
99+
[replyTrajCheck -sphere 5, 1, 1-]:The atoms are replicated correctly: true
94100
Atoms are within box dimensions:
95101
[replyTrajCheck -sphere 5, 1, 1-]: all atoms in box along x : true
96102
[replyTrajCheck -sphere 5, 1, 1-]: all atoms in box along y : true
@@ -103,6 +109,7 @@ New box has the correct dimensions:
103109
[replyTrajCheck -sphere 1, 3, 1-]:
104110
[replyTrajCheck -sphere 1, 3, 1-]: rep->overrideNat(nat)=true
105111
[replyTrajCheck -sphere 1, 3, 1-]: new number of atoms: ( should be 600) : 600
112+
[replyTrajCheck -sphere 1, 3, 1-]:The atoms are replicated correctly: true
106113
Atoms are within box dimensions:
107114
[replyTrajCheck -sphere 1, 3, 1-]: all atoms in box along x : true
108115
[replyTrajCheck -sphere 1, 3, 1-]: all atoms in box along y : true
@@ -115,6 +122,7 @@ New box has the correct dimensions:
115122
[replyTrajCheck -sphere 1, 1, 7-]:
116123
[replyTrajCheck -sphere 1, 1, 7-]: rep->overrideNat(nat)=true
117124
[replyTrajCheck -sphere 1, 1, 7-]: new number of atoms: ( should be 1400) : 1400
125+
[replyTrajCheck -sphere 1, 1, 7-]:The atoms are replicated correctly: true
118126
Atoms are within box dimensions:
119127
[replyTrajCheck -sphere 1, 1, 7-]: all atoms in box along x : true
120128
[replyTrajCheck -sphere 1, 1, 7-]: all atoms in box along y : true
@@ -124,3 +132,126 @@ New box has the correct dimensions:
124132
[replyTrajCheck -sphere 1, 1, 7-]: correct box dimension y : true
125133
[replyTrajCheck -sphere 1, 1, 7-]: correct box dimension z : true
126134

135+
[scaleTrajCheck -sphere*0.5-]:
136+
[scaleTrajCheck -sphere*0.5-]:The atoms are scaled correctly: true
137+
Atoms are within box dimensions:
138+
[scaleTrajCheck -sphere*0.5-]: all atoms in box along x : true
139+
[scaleTrajCheck -sphere*0.5-]: all atoms in box along y : true
140+
[scaleTrajCheck -sphere*0.5-]: all atoms in box along z : true
141+
New box has the correct dimensions:
142+
[scaleTrajCheck -sphere*0.5-]: correct box dimension x : true
143+
[scaleTrajCheck -sphere*0.5-]: correct box dimension y : true
144+
[scaleTrajCheck -sphere*0.5-]: correct box dimension z : true
145+
[scaleTrajCheck -sc*0.5-]:
146+
[scaleTrajCheck -sc*0.5-]:The atoms are scaled correctly: true
147+
Atoms are within box dimensions:
148+
[scaleTrajCheck -sc*0.5-]: all atoms in box along x : true
149+
[scaleTrajCheck -sc*0.5-]: all atoms in box along y : true
150+
[scaleTrajCheck -sc*0.5-]: all atoms in box along z : true
151+
New box has the correct dimensions:
152+
[scaleTrajCheck -sc*0.5-]: correct box dimension x : true
153+
[scaleTrajCheck -sc*0.5-]: correct box dimension y : true
154+
[scaleTrajCheck -sc*0.5-]: correct box dimension z : true
155+
[scaleTrajCheck -globs*0.5-]:
156+
[scaleTrajCheck -globs*0.5-]:The atoms are scaled correctly: true
157+
Atoms are within box dimensions:
158+
[scaleTrajCheck -globs*0.5-]: all atoms in box along x : true
159+
[scaleTrajCheck -globs*0.5-]: all atoms in box along y : true
160+
[scaleTrajCheck -globs*0.5-]: all atoms in box along z : true
161+
New box has the correct dimensions:
162+
[scaleTrajCheck -globs*0.5-]: correct box dimension x : true
163+
[scaleTrajCheck -globs*0.5-]: correct box dimension y : true
164+
[scaleTrajCheck -globs*0.5-]: correct box dimension z : true
165+
[scaleTrajCheck -sphere-reply212*0.5-]:
166+
[scaleTrajCheck -sphere-reply212*0.5-]:The atoms are scaled correctly: true
167+
Atoms are within box dimensions:
168+
[scaleTrajCheck -sphere-reply212*0.5-]: all atoms in box along x : true
169+
[scaleTrajCheck -sphere-reply212*0.5-]: all atoms in box along y : true
170+
[scaleTrajCheck -sphere-reply212*0.5-]: all atoms in box along z : true
171+
New box has the correct dimensions:
172+
[scaleTrajCheck -sphere-reply212*0.5-]: correct box dimension x : true
173+
[scaleTrajCheck -sphere-reply212*0.5-]: correct box dimension y : true
174+
[scaleTrajCheck -sphere-reply212*0.5-]: correct box dimension z : true
175+
176+
[scaleTrajCheck -sphere*3-]:
177+
[scaleTrajCheck -sphere*3-]:The atoms are scaled correctly: true
178+
Atoms are within box dimensions:
179+
[scaleTrajCheck -sphere*3-]: all atoms in box along x : true
180+
[scaleTrajCheck -sphere*3-]: all atoms in box along y : true
181+
[scaleTrajCheck -sphere*3-]: all atoms in box along z : true
182+
New box has the correct dimensions:
183+
[scaleTrajCheck -sphere*3-]: correct box dimension x : true
184+
[scaleTrajCheck -sphere*3-]: correct box dimension y : true
185+
[scaleTrajCheck -sphere*3-]: correct box dimension z : true
186+
[scaleTrajCheck -sc*3-]:
187+
[scaleTrajCheck -sc*3-]:The atoms are scaled correctly: true
188+
Atoms are within box dimensions:
189+
[scaleTrajCheck -sc*3-]: all atoms in box along x : true
190+
[scaleTrajCheck -sc*3-]: all atoms in box along y : true
191+
[scaleTrajCheck -sc*3-]: all atoms in box along z : true
192+
New box has the correct dimensions:
193+
[scaleTrajCheck -sc*3-]: correct box dimension x : true
194+
[scaleTrajCheck -sc*3-]: correct box dimension y : true
195+
[scaleTrajCheck -sc*3-]: correct box dimension z : true
196+
[scaleTrajCheck -globs*3-]:
197+
[scaleTrajCheck -globs*3-]:The atoms are scaled correctly: true
198+
Atoms are within box dimensions:
199+
[scaleTrajCheck -globs*3-]: all atoms in box along x : true
200+
[scaleTrajCheck -globs*3-]: all atoms in box along y : true
201+
[scaleTrajCheck -globs*3-]: all atoms in box along z : true
202+
New box has the correct dimensions:
203+
[scaleTrajCheck -globs*3-]: correct box dimension x : true
204+
[scaleTrajCheck -globs*3-]: correct box dimension y : true
205+
[scaleTrajCheck -globs*3-]: correct box dimension z : true
206+
[scaleTrajCheck -sphere-reply212*3-]:
207+
[scaleTrajCheck -sphere-reply212*3-]:The atoms are scaled correctly: true
208+
Atoms are within box dimensions:
209+
[scaleTrajCheck -sphere-reply212*3-]: all atoms in box along x : true
210+
[scaleTrajCheck -sphere-reply212*3-]: all atoms in box along y : true
211+
[scaleTrajCheck -sphere-reply212*3-]: all atoms in box along z : true
212+
New box has the correct dimensions:
213+
[scaleTrajCheck -sphere-reply212*3-]: correct box dimension x : true
214+
[scaleTrajCheck -sphere-reply212*3-]: correct box dimension y : true
215+
[scaleTrajCheck -sphere-reply212*3-]: correct box dimension z : true
216+
217+
[scaleTrajCheck -sphere*10-]:
218+
[scaleTrajCheck -sphere*10-]:The atoms are scaled correctly: true
219+
Atoms are within box dimensions:
220+
[scaleTrajCheck -sphere*10-]: all atoms in box along x : true
221+
[scaleTrajCheck -sphere*10-]: all atoms in box along y : true
222+
[scaleTrajCheck -sphere*10-]: all atoms in box along z : true
223+
New box has the correct dimensions:
224+
[scaleTrajCheck -sphere*10-]: correct box dimension x : true
225+
[scaleTrajCheck -sphere*10-]: correct box dimension y : true
226+
[scaleTrajCheck -sphere*10-]: correct box dimension z : true
227+
[scaleTrajCheck -sc*10-]:
228+
[scaleTrajCheck -sc*10-]:The atoms are scaled correctly: true
229+
Atoms are within box dimensions:
230+
[scaleTrajCheck -sc*10-]: all atoms in box along x : true
231+
[scaleTrajCheck -sc*10-]: all atoms in box along y : true
232+
[scaleTrajCheck -sc*10-]: all atoms in box along z : true
233+
New box has the correct dimensions:
234+
[scaleTrajCheck -sc*10-]: correct box dimension x : true
235+
[scaleTrajCheck -sc*10-]: correct box dimension y : true
236+
[scaleTrajCheck -sc*10-]: correct box dimension z : true
237+
[scaleTrajCheck -globs*10-]:
238+
[scaleTrajCheck -globs*10-]:The atoms are scaled correctly: true
239+
Atoms are within box dimensions:
240+
[scaleTrajCheck -globs*10-]: all atoms in box along x : true
241+
[scaleTrajCheck -globs*10-]: all atoms in box along y : true
242+
[scaleTrajCheck -globs*10-]: all atoms in box along z : true
243+
New box has the correct dimensions:
244+
[scaleTrajCheck -globs*10-]: correct box dimension x : true
245+
[scaleTrajCheck -globs*10-]: correct box dimension y : true
246+
[scaleTrajCheck -globs*10-]: correct box dimension z : true
247+
[scaleTrajCheck -sphere-reply212*10-]:
248+
[scaleTrajCheck -sphere-reply212*10-]:The atoms are scaled correctly: true
249+
Atoms are within box dimensions:
250+
[scaleTrajCheck -sphere-reply212*10-]: all atoms in box along x : true
251+
[scaleTrajCheck -sphere-reply212*10-]: all atoms in box along y : true
252+
[scaleTrajCheck -sphere-reply212*10-]: all atoms in box along z : true
253+
New box has the correct dimensions:
254+
[scaleTrajCheck -sphere-reply212*10-]: correct box dimension x : true
255+
[scaleTrajCheck -sphere-reply212*10-]: correct box dimension y : true
256+
[scaleTrajCheck -sphere-reply212*10-]: correct box dimension z : true
257+

regtest/tools/rt-make-CellLists/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <numeric>
2222

2323
using namespace PLMD;
24+
using atomDst = std::unique_ptr<PLMD::AtomDistribution>;
2425

2526
void test (PLMD::Communicator &comm);
2627
void testIndexes (PLMD::Communicator &comm);
@@ -363,7 +364,7 @@ void test (PLMD::Communicator &comm) {
363364
std::vector<Vector> atoms(5*5*5);
364365
std::vector<double> basebox(9);
365366
unsigned nat = atoms.size();
366-
auto rep= std::make_unique<repliedTrajectory>([&]() {
367+
atomDst rep= std::make_unique<repliedTrajectory>([&]() {
367368
auto d = AtomDistribution::getAtomDistribution("sc");
368369
//getting some base informations
369370
d->frame(atoms,basebox,0,rng);
@@ -433,7 +434,7 @@ void bench (PLMD::Communicator &comm) {
433434
std::vector<Vector> atoms(50000);
434435
std::vector<double> basebox(9);
435436
unsigned nat = atoms.size();
436-
auto rep= std::make_unique<repliedTrajectory>([&]() {
437+
atomDst rep= std::make_unique<repliedTrajectory>([&]() {
437438
auto d = AtomDistribution::getAtomDistribution("cube");
438439
//getting some base informations
439440
d->frame(atoms,basebox,0,rng);

0 commit comments

Comments
 (0)