Skip to content

Commit

Permalink
Add in stub MDA dihedral casting convention. (#171)
Browse files Browse the repository at this point in the history
* add in stub MDA cast

* fix

* increase amount of testing
  • Loading branch information
hmacdope authored Oct 15, 2024
1 parent 50fd4a9 commit 904b3a6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions distopia/tests/test_distopia.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ def test_dihedrals(self, dtype, positions):
dihedrals = distopia.calc_dihedrals_no_box(a, b, c, d)
# Check calculated values
assert_equal(len(dihedrals), 4, err_msg="calc_dihedrals results have wrong length")
# FIXME: BROKEN assert np.isnan(dihedrals[0]), "Zero length dihedral failed"
# FIXME: BROKEN assert np.isnan(dihedrals[1]), "Straight line dihedral failed"
# FIXME: BROKEN assert_almost_equal(dihedrals[2], np.pi, self.prec, err_msg="180 degree dihedral failed")
assert np.isnan(dihedrals[0]), "Zero length dihedral failed"
assert np.isnan(dihedrals[1]), "Straight line dihedral failed"
assert_almost_equal(dihedrals[2], -np.pi, self.prec, err_msg="180 degree dihedral failed") # np.pi in MDAnalysis
assert_almost_equal(dihedrals[3], -0.50714064, self.prec,
err_msg="arbitrary dihedral angle failed")

Expand Down
5 changes: 5 additions & 0 deletions libdistopia/src/distopia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,11 @@ namespace distopia {
// apply mask to set NAN where x and y are both zero
auto fin = hn::IfThenElse(mask, hn::Set(d, NAN), res);


// check where it is exactly -np.pi and set to np.pi for compliance with mda code
// auto mask2 = hn::Eq(fin, hn::Set(d, -M_PI));
// fin = hn::IfThenElse(mask2, hn::Set(d, M_PI), fin);

return fin;
}

Expand Down
2 changes: 1 addition & 1 deletion libdistopia/test/test_mda_match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ typedef Types<float, double> ScalarTypes;

// constants
constexpr int BOXSIZE = 30;
constexpr int NRESULTS = 10;
constexpr int NRESULTS = 1000;
constexpr int NINDICIES = 5;
constexpr double abs_err = 1.0e-4;

Expand Down

0 comments on commit 904b3a6

Please sign in to comment.