-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e699d2b
commit 4198d5a
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import unittest | ||
from ase.build import bulk | ||
import structuretoolkit as stk | ||
|
||
|
||
class SQSTestCase(unittest.TestCase): | ||
def test_sqs_structures_no_stats(self): | ||
structures_lst = stk.build.sqs_structures( | ||
structure=bulk("Au", cubic=True).repeat([2, 2, 2]), | ||
mole_fractions={"Cu": 0.5, "Au": 0.5}, | ||
weights=None, | ||
objective=0.0, | ||
iterations=1e6, | ||
output_structures=10, | ||
mode="random", | ||
num_threads=None, | ||
prefactors=None, | ||
pair_weights=None, | ||
rtol=None, | ||
atol=None, | ||
which=None, | ||
shell_distances=None, | ||
minimal=True, | ||
similar=True, | ||
return_statistics=False, | ||
) | ||
self.assertEqual(len(structures_lst), 10) | ||
symbols_lst = [s.get_chemical_symbols() for s in structures_lst] | ||
for s in symbols_lst: | ||
self.assertEqual(len(s), 32) | ||
for el in ["Au", "Cu"]: | ||
self.assertAlmostEqual(s.count(el)/len(s), 0.5) | ||
|
||
def test_sqs_structures_with_stats(self): | ||
structures_lst, sro_breakdown, num_iterations, cycle_time = stk.build.sqs_structures( | ||
structure=bulk("Au", cubic=True).repeat([2, 2, 2]), | ||
mole_fractions={"Cu": 0.5, "Au": 0.5}, | ||
weights=None, | ||
objective=0.0, | ||
iterations=1e6, | ||
output_structures=10, | ||
mode="random", | ||
num_threads=None, | ||
prefactors=None, | ||
pair_weights=None, | ||
rtol=None, | ||
atol=None, | ||
which=None, | ||
shell_distances=None, | ||
minimal=True, | ||
similar=True, | ||
return_statistics=True, | ||
) | ||
self.assertEqual(len(structures_lst), 10) | ||
symbols_lst = [s.get_chemical_symbols() for s in structures_lst] | ||
for s in symbols_lst: | ||
self.assertEqual(len(s), 32) | ||
for el in ["Au", "Cu"]: | ||
self.assertAlmostEqual(s.count(el)/len(s), 0.5) | ||
for sro in sro_breakdown: | ||
self.assertEqual(list(sro.keys()), ['Cu-Cu', 'Cu-Au', 'Au-Au']) | ||
self.assertEqual(num_iterations, 1000000.0) | ||
self.assertTrue(cycle_time < 10) |