Skip to content

Commit 8a1543b

Browse files
fwaibldrroe
andauthored
GIST Entropy improvements (#947)
* Speed up six-dimensional entropy calculation in GIST In GIST, the six-dimensional entropy calculation requires the translational and orientational distance to the nearest neighbor (NN). However, if the translational distance is larger than the 6D distance to the current NN, the orientational distance can be skipped safely. This is a significant speedup (about 2x in my test), since the orientational distance contains an arccos. * Increase cpptraj revision to 6.2.2 * Implement exact volume equations for GIST nearest-neighbor entropy. The nearest-neighbor density is approximated by finding the distance to the nearest neighbor of each point, computing a sphere volume from this distance, and comparing this to the volume that is expected from a homogeneous density. In GIST, the sphere volume in rotational space and the combined translation+rotation space was approximated by a Taylor expansion. This patch implements the exact volume in rotational space analytically, and uses a tabulated correction factor for distances up to 10 Angstrom to correct the 6-D volume. The result is a better convergence of the bulk entropy, at the cost of about 3.4% calculation time (Action Post) in my test (a pure water box containg 3333 water molecules, using 10000 frames). The bulk entropy (should be zero) is reduced from 2.3e-4 to 5e-5 kcal/mol/A^3 for dTSsix and from 7.7e-4 to 2.3e-4 for dTSorient. The individual voxel values are almost perfectly correlated to the old results (R^2=0.99996). * Implement generalized nearest neighbor (NN) search. In the old algorithm, neighbors were searched in the respective voxel and in all of its direct neighbors. The new algorithm lets the user choose how many layers of neighboring voxels should be search. The default is 1, which corresponds to the old behavior. There is a tiny difference in how distances of 0 are treated. In the old code, they were omitted. In the new code, there is a constant (GIST_TINY) which is used if the resulting distance is 0. This leads to numerically different values in about 0.01% of the voxels. * Bump version (revision) number to 6.2.3. * Update cpptrajdepend (make depend) after GIST entropy changes * Remove declaration of unused TransEntropy function * Fix command line parsing in GIST In the GIST input, the gridcntr and griddim arguments were previously parsed as positional arguments (but if the keyword was present), rather than being parsed behind the keyword. I.e., gist 0.6 1.0 1.6 50 gridcntr griddim 60 70 gridspacn 0.5 out gist.dat refdens 0.0329 was valid, while gist griddim 50 60 70 gridspacn 0.5 out gist.dat refdens 0.0329 gridcntr 0.6 1.0 1.6 was invalid (because the center values had to go first) This commit changes the parsing to the expected bevavior, i.e., the first example is now invalid and the second is valid. * In GIST, omit entropy for waters if no nearest neighbor is found. Changes: * after the nearest neighbor (NN) search, introduces a check whether the distance is smaller than sqrt(GIST_HUGE) (i.e., a NN has been found). If not, this distance is omitted from the entropy calculation. * fix a bug where some non-border voxels were omitted instead of voxels on the border. (GIST voxels on the border of the grid are supposed to obtain 0 entropy) * don't look for nearest neighbors if we are on the border. Explanation: In GIST, the entropy is calculated per water molecule based on the NN distance, and binned to a grid. With the recent change of the entropy calculation, I removed some checks that: * omit the entropy of waters if no NN distance is found. Instead, a high value (sqrt(GIST_HUGE)) is assigned to the distance. * omit the NN if the distance to it is numerically close to zero. Instead, a small value (GIST_TINY) is then assigned to the distance. The second first behavior is reasonable (omitting the NN means that an arbitrary higher distance is chosen, and GIST_TINY is probably smaller than that arbitrary distance, i.e., closer to the real one. However, the first one is not so reasonable, because sqrt(GIST_HUGE) is probably far off from the real NN distance. Therefore, I re-introduce the old behavior in this case. This is very relevant for the results of the cpptraj tests, since they use very few frames, leading to many cases of high NN distances. * Update GIST tests to new entropy calculation * This adds 2 tests for the new flags oldnnvolume and nnsearchlayers. The .save files for oldnnvolume (Gist6) are just renamed from the previous Gist2 test. The other test .save files are changed to match the new entropy results. * Increase cpptraj version to 6.3.0 * GIST code cleanup and command line checking * Move GistEntropyUtils functions into a GistEntropyUtils namespace * make GIST_HUGE a const double (instead of a macro) * add validDouble and validInteger checks for griddim and gridcntr arguments. Co-authored-by: Daniel R. Roe <[email protected]>
1 parent 87b7175 commit 8a1543b

25 files changed

+255034
-2215
lines changed

src/Action_GIST.cpp

Lines changed: 98 additions & 157 deletions
Large diffs are not rendered by default.

src/Action_GIST.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class Action_GIST : public Action {
3737
typedef std::vector<Farray> Xarray;
3838
typedef std::vector<double> Darray;
3939

40-
inline void TransEntropy(float,float,float,float,float,float,float,int,double&,double&) const;
4140
static inline void Ecalc(double, double, double, NonbondType const&, double&, double&);
4241
void NonbondEnergy_pme(Frame const&);
4342
void NonbondEnergy(Frame const&, Topology const&);
@@ -192,10 +191,12 @@ class Action_GIST : public Action {
192191
unsigned int nMolAtoms_; ///< Number of atoms in a water molecule.+
193192
int NFRAME_; ///< Total # frames analyzed
194193
int max_nwat_; ///< Max number of waters in any voxel
194+
int nNnSearchLayers_; ///< Number of layers of voxels to search for nearest neighbors in the entropy search.
195195
bool doOrder_; ///< If true do the order calc
196196
bool doEij_; ///< If true do the i-j energy calc
197197
bool skipE_; ///< If true skip the nonbond energy calc
198198
bool includeIons_; ///< If true include ions in solute region.
199199
bool skipS_; ///< If true does not calculate entropy
200+
bool exactNnVolume_; ///< If true use the exact volume equation for the NN entropy
200201
};
201202
#endif

0 commit comments

Comments
 (0)