29
29
from pymatgen .util .testing import TEST_FILES_DIR , PymatgenTest
30
30
31
31
32
- def get_path (path_str ):
33
- return os .path .join (TEST_FILES_DIR , "surface_tests" , path_str )
34
-
35
-
36
32
class TestSlab (PymatgenTest ):
37
33
def setUp (self ):
38
- zno1 = Structure .from_file (get_path ( " ZnO-wz.cif") , primitive = False )
34
+ zno1 = Structure .from_file (f" { TEST_FILES_DIR } /surface_tests/ ZnO-wz.cif" , primitive = False )
39
35
zno55 = SlabGenerator (zno1 , [1 , 0 , 0 ], 5 , 5 , lll_reduce = False , center_slab = False ).get_slab ()
40
36
41
37
Ti = Structure (
42
38
Lattice .hexagonal (4.6 , 2.82 ),
43
39
["Ti" , "Ti" , "Ti" ],
44
40
[
45
- [0.000000 , 0.000000 , 0.000000 ],
41
+ [0 , 0 , 0 ],
46
42
[0.333333 , 0.666667 , 0.500000 ],
47
43
[0.666667 , 0.333333 , 0.500000 ],
48
44
],
@@ -52,10 +48,10 @@ def setUp(self):
52
48
Lattice .cubic (4.06 ),
53
49
["Ag" , "Ag" , "Ag" , "Ag" ],
54
50
[
55
- [0.000000 , 0.000000 , 0.000000 ],
56
- [0.000000 , 0.500000 , 0.500000 ],
57
- [0.500000 , 0.000000 , 0.500000 ],
58
- [0.500000 , 0.500000 , 0.000000 ],
51
+ [0 , 0 , 0 ],
52
+ [0 , 0.500000 , 0.500000 ],
53
+ [0.500000 , 0 , 0.500000 ],
54
+ [0.500000 , 0.500000 , 0 ],
59
55
],
60
56
)
61
57
@@ -68,7 +64,7 @@ def setUp(self):
68
64
self .agfcc = Ag_fcc
69
65
self .zno1 = zno1
70
66
self .zno55 = zno55
71
- self .nonlaue = non_laue
67
+ self .non_laue = non_laue
72
68
self .h = Structure (Lattice .cubic (3 ), ["H" ], [[0 , 0 , 0 ]])
73
69
self .libcc = Structure (Lattice .cubic (3.51004 ), ["Li" , "Li" ], [[0 , 0 , 0 ], [0.5 , 0.5 , 0.5 ]])
74
70
@@ -235,7 +231,7 @@ def test_symmetrization(self):
235
231
assert symmetric_count == len (slabs )
236
232
237
233
# Check if we can generate symmetric slabs from bulk with no inversion
238
- all_non_laue_slabs = generate_all_slabs (self .nonlaue , 1 , 15 , 15 , symmetrize = True )
234
+ all_non_laue_slabs = generate_all_slabs (self .non_laue , 1 , 15 , 15 , symmetrize = True )
239
235
assert len (all_non_laue_slabs ) > 0
240
236
241
237
def test_get_symmetric_sites (self ):
@@ -393,26 +389,7 @@ def test_get_slab(self):
393
389
and (
394
390
sg .symbol .endswith ("H" )
395
391
or sg .int_number
396
- in [
397
- 143 ,
398
- 144 ,
399
- 145 ,
400
- 147 ,
401
- 149 ,
402
- 150 ,
403
- 151 ,
404
- 152 ,
405
- 153 ,
406
- 154 ,
407
- 156 ,
408
- 157 ,
409
- 158 ,
410
- 159 ,
411
- 162 ,
412
- 163 ,
413
- 164 ,
414
- 165 ,
415
- ]
392
+ in [143 , 144 , 145 , 147 , 149 , 150 , 151 , 152 , 153 , 154 , 156 , 157 , 158 , 159 , 162 , 163 , 164 , 165 ]
416
393
)
417
394
):
418
395
latt = Lattice .hexagonal (5 , 10 )
@@ -484,7 +461,7 @@ def test_get_slabs(self):
484
461
# slabs is of sites in LiFePO4 unit cell - 2 + 1.
485
462
assert len (gen .get_slabs (tol = 1e-4 , ftol = 1e-4 )) == 15
486
463
487
- LiCoO2 = Structure .from_file (get_path ( " icsd_LiCoO2.cif") , primitive = False )
464
+ LiCoO2 = Structure .from_file (f" { TEST_FILES_DIR } /surface_tests/ icsd_LiCoO2.cif" , primitive = False )
488
465
gen = SlabGenerator (LiCoO2 , [0 , 0 , 1 ], 10 , 10 )
489
466
lco = gen .get_slabs (bonds = {("Co" , "O" ): 3 })
490
467
assert len (lco ) == 1
@@ -518,14 +495,14 @@ def test_triclinic_TeI(self):
518
495
# in other Miller indices can cause some ambiguity when choosing a
519
496
# higher tolerance.
520
497
numb_slabs = {(0 , 0 , 1 ): 5 , (0 , 1 , 0 ): 3 , (1 , 0 , 0 ): 7 }
521
- TeI = Structure .from_file (get_path ( " icsd_TeI.cif") , primitive = False )
498
+ TeI = Structure .from_file (f" { TEST_FILES_DIR } /surface_tests/ icsd_TeI.cif" , primitive = False )
522
499
for k , v in numb_slabs .items ():
523
500
trclnc_TeI = SlabGenerator (TeI , k , 10 , 10 )
524
501
TeI_slabs = trclnc_TeI .get_slabs ()
525
502
assert v == len (TeI_slabs )
526
503
527
504
def test_get_orthogonal_c_slab (self ):
528
- TeI = Structure .from_file (get_path ( " icsd_TeI.cif") , primitive = False )
505
+ TeI = Structure .from_file (f" { TEST_FILES_DIR } /surface_tests/ icsd_TeI.cif" , primitive = False )
529
506
trclnc_TeI = SlabGenerator (TeI , (0 , 0 , 1 ), 10 , 10 )
530
507
TeI_slabs = trclnc_TeI .get_slabs ()
531
508
slab = TeI_slabs [0 ]
@@ -534,7 +511,7 @@ def test_get_orthogonal_c_slab(self):
534
511
assert norm_slab .lattice .angles [1 ] == approx (90 )
535
512
536
513
def test_get_orthogonal_c_slab_site_props (self ):
537
- TeI = Structure .from_file (get_path ( " icsd_TeI.cif") , primitive = False )
514
+ TeI = Structure .from_file (f" { TEST_FILES_DIR } /surface_tests/ icsd_TeI.cif" , primitive = False )
538
515
trclnc_TeI = SlabGenerator (TeI , (0 , 0 , 1 ), 10 , 10 )
539
516
TeI_slabs = trclnc_TeI .get_slabs ()
540
517
slab = TeI_slabs [0 ]
@@ -719,7 +696,7 @@ def test_previous_reconstructions(self):
719
696
el = self .Si [0 ].species_string
720
697
721
698
slabs = rec .build_slabs ()
722
- struct = Structure .from_file (get_path ( os . path . join ( " reconstructions" , el + "_" + n + " .cif")) )
699
+ struct = Structure .from_file (f" { TEST_FILES_DIR } /surface_tests/ reconstructions/ { el } _ { n } .cif" )
723
700
assert any (len (m .group_structures ([struct , slab ])) == 1 for slab in slabs )
724
701
725
702
@@ -730,8 +707,8 @@ def setUp(self):
730
707
mglatt = Lattice .from_parameters (3.2 , 3.2 , 5.13 , 90 , 90 , 120 )
731
708
self .Mg = Structure (mglatt , ["Mg" , "Mg" ], [[1 / 3 , 2 / 3 , 1 / 4 ], [2 / 3 , 1 / 3 , 3 / 4 ]])
732
709
self .lifepo4 = self .get_structure ("LiFePO4" )
733
- self .tei = Structure .from_file (get_path ( " icsd_TeI.cif") , primitive = False )
734
- self .LiCoO2 = Structure .from_file (get_path ( " icsd_LiCoO2.cif") , primitive = False )
710
+ self .tei = Structure .from_file (f" { TEST_FILES_DIR } /surface_tests/ icsd_TeI.cif" , primitive = False )
711
+ self .LiCoO2 = Structure .from_file (f" { TEST_FILES_DIR } /surface_tests/ icsd_LiCoO2.cif" , primitive = False )
735
712
736
713
self .p1 = Structure (
737
714
Lattice .from_parameters (3 , 4 , 5 , 31 , 43 , 50 ),
0 commit comments