77
88import numpy as np
99import pytest
10- from jobflow import run_locally
10+ from jobflow import Flow , run_locally
1111from pymatgen .core import Structure
1212from pymatgen .transformations .advanced_transformations import SQSTransformation
13+ from pymatgen .transformations .standard_transformations import (
14+ OrderDisorderedStructureTransformation ,
15+ OxidationStateDecorationTransformation ,
16+ )
1317
14- from atomate2 .common .jobs .transform import SQS
15- from atomate2 .common .schemas .transform import SQSTask
18+ from atomate2 .common .jobs .transform import SQS , Transformer
19+ from atomate2 .common .schemas .transform import SQSTask , TransformTask
1620
1721
1822@pytest .fixture (scope = "module" )
@@ -32,6 +36,43 @@ def simple_alloy() -> Structure:
3236 )
3337
3438
39+ def test_simple_and_advanced ():
40+ # simple disordered zincblende structure
41+ structure = Structure (
42+ 3.8 * np .array ([[0.0 , 0.5 , 0.5 ], [0.5 , 0.0 , 0.5 ], [0.5 , 0.5 , 0.0 ]]),
43+ ["Zn" , {"S" : 0.75 , "Se" : 0.25 }],
44+ [[0.0 , 0.0 , 0.0 ], [0.25 , 0.25 , 0.25 ]],
45+ ).to_conventional ()
46+
47+ oxi_dict = {"Zn" : 2 , "S" : - 2 , "Se" : - 2 }
48+ oxi_job = Transformer (
49+ name = "oxistate" , transformation = OxidationStateDecorationTransformation (oxi_dict )
50+ ).make (structure )
51+
52+ odst_job = Transformer (
53+ name = "odst" , transformation = OrderDisorderedStructureTransformation ()
54+ ).make (oxi_job .output .final_structure , return_ranked_list = 2 )
55+
56+ flow = Flow ([oxi_job , odst_job ])
57+ resp = run_locally (flow )
58+
59+ oxi_state_output = resp [oxi_job .uuid ][1 ].output
60+ assert isinstance (oxi_state_output , TransformTask )
61+
62+ # check correct assignment of oxidation states
63+ assert all (
64+ specie .oxi_state == oxi_dict .get (specie .element .value )
65+ for site in oxi_state_output .final_structure
66+ for specie in site .species
67+ )
68+
69+ odst_output = resp [odst_job .uuid ][1 ].output
70+ # return_ranked_list = 2, so should get 2 output docs
71+ assert len (odst_output ) == 2
72+ assert all (isinstance (doc , TransformTask ) for doc in odst_output )
73+ assert all (doc .final_structure .is_ordered for doc in odst_output )
74+
75+
3576@pytest .mark .skipif (
3677 icet is None , reason = "`icet` must be installed to perform this test."
3778)
0 commit comments