Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 24 additions & 23 deletions src/Action_Diffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,6 @@ Action::RetType Action_Diffusion::Setup(ActionSetup& setup) {
} else
mprintf("\tImaging disabled.\n");

// Allocate the delta array
delta_.assign( mask_.Nselected() * 3, 0.0 );

// Reserve space for the previous coordinates array
previous_.reserve( mask_.Nselected() * 3 );

Expand Down Expand Up @@ -329,10 +326,14 @@ Action::RetType Action_Diffusion::DoAction(int frameNum, ActionFrame& frm) {
double avgx = 0.0;
double avgy = 0.0;
double avgz = 0.0;
unsigned int idx = 0; // Index into previous_ and delta_
unsigned int idx = 0; // Index into previous_
double fixedXYZ[3];
for (AtomMask::const_iterator at = mask_.begin(); at != mask_.end(); ++at, idx += 3)
{ // Get current and initial coords for this atom.
const double* XYZ = frm.Frm().XYZ(*at);
fixedXYZ[0] = XYZ[0];
fixedXYZ[1] = XYZ[1];
fixedXYZ[2] = XYZ[2];
const double* iXYZ = initial_.XYZ(*at);
// Calculate distance from initial position.
double delx, dely, delz;
Expand All @@ -345,17 +346,17 @@ Action::RetType Action_Diffusion::DoAction(int frameNum, ActionFrame& frm) {
// If the particle moved more than half the box, assume it was imaged
// and adjust the distance of the total movement with respect to the
// original frame.
if (delx > boxcenter_[0]) delta_[idx ] -= frm.Frm().BoxCrd().Param(Box::X);
else if (delx < -boxcenter_[0]) delta_[idx ] += frm.Frm().BoxCrd().Param(Box::X);
if (dely > boxcenter_[1]) delta_[idx+1] -= frm.Frm().BoxCrd().Param(Box::Y);
else if (dely < -boxcenter_[1]) delta_[idx+1] += frm.Frm().BoxCrd().Param(Box::Y);
if (delz > boxcenter_[2]) delta_[idx+2] -= frm.Frm().BoxCrd().Param(Box::Z);
else if (delz < -boxcenter_[2]) delta_[idx+2] += frm.Frm().BoxCrd().Param(Box::Z);
if (delx > boxcenter_[0]) fixedXYZ[0] -= frm.Frm().BoxCrd().Param(Box::X);
else if (delx < -boxcenter_[0]) fixedXYZ[0] += frm.Frm().BoxCrd().Param(Box::X);
if (dely > boxcenter_[1]) fixedXYZ[1] -= frm.Frm().BoxCrd().Param(Box::Y);
else if (dely < -boxcenter_[1]) fixedXYZ[1] += frm.Frm().BoxCrd().Param(Box::Y);
if (delz > boxcenter_[2]) fixedXYZ[2] -= frm.Frm().BoxCrd().Param(Box::Z);
else if (delz < -boxcenter_[2]) fixedXYZ[2] += frm.Frm().BoxCrd().Param(Box::Z);
// Calculate the distance between this "fixed" coordinate
// and the reference (initial) frame.
delx = XYZ[0] + delta_[idx ] - iXYZ[0];
dely = XYZ[1] + delta_[idx+1] - iXYZ[1];
delz = XYZ[2] + delta_[idx+2] - iXYZ[2];
delx = fixedXYZ[0] - iXYZ[0];
dely = fixedXYZ[1] - iXYZ[1];
delz = fixedXYZ[2] - iXYZ[2];
} else if ( imageOpt_.ImagingType() == ImageOption::NONORTHO ) {
// Non-orthorhombic imaging
// Calculate distance to previous frames coordinates.
Expand Down Expand Up @@ -396,16 +397,16 @@ Action::RetType Action_Diffusion::DoAction(int frameNum, ActionFrame& frm) {
}
}
}
// Update the delta for this atom
delta_[idx ] += minCurr[0] - XYZ[0]; // cCart
delta_[idx+1] += minCurr[1] - XYZ[1];
delta_[idx+2] += minCurr[2] - XYZ[2];
// minCurr contains the shortest imaged position from previous coords
fixedXYZ[0] = minCurr[0];
fixedXYZ[1] = minCurr[1];
fixedXYZ[2] = minCurr[2];
}
// Calculate the distance between this "fixed" coordinate
// and the reference (initial) frame.
delx = XYZ[0] + delta_[idx ] - iXYZ[0];
dely = XYZ[1] + delta_[idx+1] - iXYZ[1];
delz = XYZ[2] + delta_[idx+2] - iXYZ[2];
delx = fixedXYZ[0] - iXYZ[0];
dely = fixedXYZ[1] - iXYZ[1];
delz = fixedXYZ[2] - iXYZ[2];
} else {
// No imaging. Calculate distance from current position to initial position.
delx = XYZ[0] - iXYZ[0];
Expand Down Expand Up @@ -437,9 +438,9 @@ Action::RetType Action_Diffusion::DoAction(int frameNum, ActionFrame& frm) {
atom_a_[*at]->Add(frameNum, &fval);
}
// Update the previous coordinate set to match the current coordinates
previous_[idx ] = XYZ[0];
previous_[idx+1] = XYZ[1];
previous_[idx+2] = XYZ[2];
previous_[idx ] = fixedXYZ[0];
previous_[idx+1] = fixedXYZ[1];
previous_[idx+2] = fixedXYZ[2];
} // END loop over selected atoms
// Calc averages
double dNselected = 1.0 / (double)mask_.Nselected();
Expand Down
1 change: 0 additions & 1 deletion src/Action_Diffusion.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class Action_Diffusion : public Action {
DataSet* diffInter_; ///< Hold MSD vs time line intercepts.
DataSet* diffCorrl_; ///< Hold MSD vs time line correlation.
int debug_;
Darray delta_; ///< Hold current distances from initial frame for selected atoms
AtomMask mask_; ///< Selected atoms
DataFile* outputx_;
DataFile* outputy_;
Expand Down
2 changes: 1 addition & 1 deletion src/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Whenever a number that precedes <revision> is incremented, all subsequent
* numbers should be reset to 0.
*/
#define CPPTRAJ_INTERNAL_VERSION "V6.12.2"
#define CPPTRAJ_INTERNAL_VERSION "V6.13.0"
/// PYTRAJ relies on this
#define CPPTRAJ_VERSION_STRING CPPTRAJ_INTERNAL_VERSION
#endif
8 changes: 4 additions & 4 deletions test/Test_Diffusion/DC.dat.save
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Set WAT_O[D] WAT_O[Slope] WAT_O[Intercept] WAT_O[Corr] WAT_O[Label]
1 3.0086 1.8052 0.3773 0.9993 WAT_O_AvgDr
2 3.2638 0.6528 0.1261 0.9993 WAT_O_AvgDx
3 2.7805 0.5561 0.1342 0.9987 WAT_O_AvgDy
4 2.9816 0.5963 0.1171 0.9991 WAT_O_AvgDz
1 3.0108 1.8065 0.3730 0.9993 WAT_O_AvgDr
2 3.2667 0.6533 0.1242 0.9993 WAT_O_AvgDx
3 2.7822 0.5564 0.1329 0.9987 WAT_O_AvgDy
4 2.9836 0.5967 0.1159 0.9991 WAT_O_AvgDz
74 changes: 37 additions & 37 deletions test/Test_Diffusion/Nonortho.agr.save
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,63 @@
@type xy
0.000 0.0000
1.000 2.3161
2.000 4.4277
3.000 6.5507
4.000 8.3064
5.000 10.0601
6.000 11.7059
7.000 13.6213
8.000 15.1883
9.000 17.0717
2.000 4.4288
3.000 6.5496
4.000 8.3059
5.000 10.0595
6.000 11.7056
7.000 13.6259
8.000 15.2001
9.000 17.0681
@ s1 legend "WAT_O[X]"
@target G0.S1
@type xy
0.000 0.0000
1.000 0.7624
2.000 1.4227
3.000 2.1385
4.000 2.6632
5.000 3.2397
2.000 1.4231
3.000 2.1383
4.000 2.6631
5.000 3.2395
6.000 3.7799
7.000 4.4781
8.000 4.9872
9.000 5.5655
7.000 4.4798
8.000 4.9914
9.000 5.5646
@ s2 legend "WAT_O[Y]"
@target G0.S2
@type xy
0.000 0.0000
1.000 0.7638
2.000 1.4841
3.000 2.2502
4.000 2.8063
5.000 3.3556
6.000 3.8485
7.000 4.3937
8.000 4.9555
9.000 5.6009
2.000 1.4845
3.000 2.2497
4.000 2.8061
5.000 3.3553
6.000 3.8484
7.000 4.3951
8.000 4.9591
9.000 5.5997
@ s3 legend "WAT_O[Z]"
@target G0.S3
@type xy
0.000 0.0000
1.000 0.7899
2.000 1.5209
3.000 2.1620
4.000 2.8368
5.000 3.4649
2.000 1.5212
3.000 2.1616
4.000 2.8367
5.000 3.4647
6.000 4.0774
7.000 4.7495
8.000 5.2456
9.000 5.9052
7.000 4.7510
8.000 5.2496
9.000 5.9038
@ s4 legend "WAT_O[A]"
@target G0.S4
@type xy
0.000 0.0000
1.000 1.5219
2.000 2.1042
3.000 2.5594
4.000 2.8821
5.000 3.1718
2.000 2.1045
3.000 2.5592
4.000 2.8820
5.000 3.1717
6.000 3.4214
7.000 3.6907
8.000 3.8972
9.000 4.1318
7.000 3.6913
8.000 3.8987
9.000 4.1314
8 changes: 4 additions & 4 deletions test/Test_Diffusion/Nonortho.dat.save
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Set WAT_O[D] WAT_O[Slope] WAT_O[Intercept] WAT_O[Corr] WAT_O[Label]
1 3.1004 1.8602 0.5538 0.9987 WAT_O_AvgDr
2 3.0437 0.6087 0.1644 0.9989 WAT_O_AvgDx
3 3.0195 0.6039 0.2283 0.9974 WAT_O_AvgDy
4 3.2380 0.6476 0.1610 0.9991 WAT_O_AvgDz
1 3.1011 1.8607 0.5530 0.9987 WAT_O_AvgDr
2 3.0445 0.6089 0.1641 0.9989 WAT_O_AvgDx
3 3.0201 0.6040 0.2281 0.9974 WAT_O_AvgDy
4 3.2387 0.6477 0.1608 0.9991 WAT_O_AvgDz
78 changes: 39 additions & 39 deletions test/Test_Diffusion/WAT_O.agr.save
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,63 @@
@type xy
0.000 0.0000
1.000 2.2649
2.000 4.2297
3.000 5.9000
4.000 7.8899
5.000 9.3842
6.000 10.9382
7.000 12.8945
8.000 14.8844
9.000 16.6205
2.000 4.2294
3.000 5.9011
4.000 7.8844
5.000 9.3786
6.000 10.9408
7.000 12.8919
8.000 14.8926
9.000 16.6393
@ s1 legend "WAT_O[X]"
@target G0.S1
@type xy
0.000 0.0000
1.000 0.7846
2.000 1.5184
3.000 2.1000
4.000 2.8321
5.000 3.4484
6.000 3.9755
7.000 4.6223
8.000 5.3717
9.000 5.9813
2.000 1.5183
3.000 2.1005
4.000 2.8300
5.000 3.4460
6.000 3.9768
7.000 4.6214
8.000 5.3753
9.000 5.9894
@ s2 legend "WAT_O[Y]"
@target G0.S2
@type xy
0.000 0.0000
1.000 0.7319
2.000 1.3339
3.000 1.8401
4.000 2.4787
5.000 2.8731
6.000 3.3699
7.000 4.0099
8.000 4.5213
9.000 5.2075
2.000 1.3338
3.000 1.8404
4.000 2.4768
5.000 2.8712
6.000 3.3703
7.000 4.0089
8.000 4.5234
9.000 5.2127
@ s3 legend "WAT_O[Z]"
@target G0.S3
@type xy
0.000 0.0000
1.000 0.7484
2.000 1.3774
3.000 1.9599
4.000 2.5791
5.000 3.0626
6.000 3.5928
7.000 4.2623
8.000 4.9914
9.000 5.4317
2.000 1.3773
3.000 1.9602
4.000 2.5777
5.000 3.0614
6.000 3.5936
7.000 4.2616
8.000 4.9939
9.000 5.4373
@ s4 legend "WAT_O[A]"
@target G0.S4
@type xy
0.000 0.0000
1.000 1.5050
2.000 2.0566
3.000 2.4290
4.000 2.8089
5.000 3.0634
6.000 3.3073
7.000 3.5909
8.000 3.8580
9.000 4.0768
3.000 2.4292
4.000 2.8079
5.000 3.0625
6.000 3.3077
7.000 3.5905
8.000 3.8591
9.000 4.0791