Skip to content

Commit

Permalink
Merge pull request #2227 from chc273/fix_c_mod_in_neighobrs
Browse files Browse the repository at this point in the history
Fix c mod in neighobrs
  • Loading branch information
shyuep committed Aug 25, 2021
2 parents 40817cc + c42bee1 commit 9c5dc22
Show file tree
Hide file tree
Showing 3 changed files with 1,523 additions and 1,333 deletions.
32 changes: 32 additions & 0 deletions pymatgen/core/tests/test_structure.py
Expand Up @@ -471,6 +471,38 @@ def test_get_all_neighbors_and_get_neighbors(self):
all_nn = s.get_all_neighbors(0.05)
self.assertEqual([len(nn) for nn in all_nn], [0] * len(s))

# the following test is from issue #2226
poscar = """POSCAR
1.0000000000000000
6.9082208665474800 0.0000000000000005 0.0000000000000011
-0.0000000000000008 14.1745610988433715 0.0000000000000004
0.0000000000000005 -0.0000000000000019 20.0189293405157045
C
14
Direct
1.2615805559557376 1.4846778919841908 0.3162565598606580
-0.7615805559557360 -0.9846778919841882 -0.1837434401393425
1.2615805559557380 -0.4846778919841886 -0.1837434401393425
-0.7615805559557358 0.9846778919841882 0.3162565598606581
-0.2615805559557363 -0.4846778919841892 0.6837434401393432
0.7615805559557360 0.9846778919841881 0.1837434401393430
-0.2653510291469959 0.5275483828607898 0.1211255106369795
0.7653510291469972 -0.0275483828607906 0.6211255106369804
1.2653510291469956 0.5275483828607898 0.3788744893630209
-0.7653510291469972 -0.0275483828607906 -0.1211255106369797
1.2653510291469956 0.4724516171392097 -0.1211255106369793
-0.7653510291469972 0.0275483828607905 0.3788744893630209
-0.2653510291469959 0.4724516171392097 0.6211255106369801
-0.2705230397846415 1.4621722452479102 0.0625618775773844
"""
s = Structure.from_str(poscar, fmt="poscar")
site0 = s.sites[1]
site1 = s.sites[9]
neigh_sites = s.get_neighbors(site0, 2.0)
self.assertTrue(len(neigh_sites) == 1)
neigh_sites = s.get_neighbors(site1, 2.0)
self.assertTrue(len(neigh_sites) == 1)

def test_get_neighbor_list(self):
s = self.struct
c_indices1, c_indices2, c_offsets, c_distances = s.get_neighbor_list(3)
Expand Down

0 comments on commit 9c5dc22

Please sign in to comment.