diff --git a/src/abacusagent/modules/submodules/work_function.py b/src/abacusagent/modules/submodules/work_function.py index 85ccdc1..1044d65 100644 --- a/src/abacusagent/modules/submodules/work_function.py +++ b/src/abacusagent/modules/submodules/work_function.py @@ -1,3 +1,4 @@ +import os from pathlib import Path from typing import Literal, Optional, Dict, Any, List @@ -38,7 +39,7 @@ def abacus_cal_work_function( work_path = Path(generate_work_path()).absolute() link_abacusjob(src=abacus_inputs_dir,dst=work_path,copy_files=["INPUT", "STRU"], exclude_directories=True) - workfunc_work_dir = prep_abacus_workfunc_calc(work_path, vacuum_direction, dipole_correction) + workfunc_work_dir = prep_abacus_workfunc_calc(work_path, vacuum_direction, dipole_correction, os.path.join(work_path, "workfunc_job")) run_abacus(workfunc_work_dir) diff --git a/tests/test_work_function.py b/tests/test_work_function.py deleted file mode 100644 index 4727d25..0000000 --- a/tests/test_work_function.py +++ /dev/null @@ -1,70 +0,0 @@ -""" -Tests for auxillary functions in work function calculation. -""" -import unittest -import os -from pathlib import Path -import numpy as np -import tempfile -from abacusagent.modules.submodules.work_function import identify_potential_plateaus - -class TestIdentifyPotentialPlateau(unittest.TestCase): - def setUp(self): - self.test_dir = tempfile.TemporaryDirectory() - self.addCleanup(self.test_dir.cleanup) - self.original_cwd = os.getcwd() - self.test_path = Path(self.test_dir.name) - os.chdir(self.test_path) - - def tearDown(self): - os.chdir(self.original_cwd) - - def test_identify_potential_plateau_single_no_cross_pbc(self): - x = np.linspace(0, np.pi*10, 1000) - y = np.where((x < np.pi*4) | (x > np.pi*8), np.cos(x) + 1, 2) - - results = identify_potential_plateaus(y) - results_ref = [(400, 798)] - self.assertEqual(len(results), len(results_ref)) - for i in range(len(results)): - self.assertEqual(results[i], results_ref[i]) - - def test_identify_potential_plateau_single_with_cross_pbc(self): - x = np.linspace(0, np.pi*10, 1000) - y = np.where((x > np.pi*4) & (x < np.pi*8), np.cos(x) + 1, 2) - - results = identify_potential_plateaus(y) - print(results) - - results_ref = [(-200, 399)] - self.assertEqual(len(results), len(results_ref)) - for i in range(len(results)): - self.assertEqual(results[i], results_ref[i]) - - def test_identify_potential_plateau_multiple_no_cross_pbc(self): - x = np.linspace(0, np.pi*10, 1000) - y = np.full_like(x, np.cos(x) + 1) - y[(x > np.pi*0.5) & (x < np.pi*1.5)] = 1 - y[(x > np.pi*4) & (x < np.pi*8) ] = 2 - - results = identify_potential_plateaus(y) - print(results) - - results_ref = [(51, 148), (400, 798)] - self.assertEqual(len(results), len(results_ref)) - for i in range(len(results)): - self.assertEqual(results[i], results_ref[i]) - - def test_identify_potential_plateau_multiple_with_cross_pbc(self): - x = np.linspace(0, np.pi*10, 1000) - y = np.full_like(x, np.cos(x) + 1) - y[(x > np.pi*4.5) & (x < np.pi*5.5)] = 1 - y[(x < np.pi*4) | (x > np.pi*8) ] = 2 - - results = identify_potential_plateaus(y) - print(results) - - results_ref = [(-200, 399), (451, 548)] - self.assertEqual(len(results), len(results_ref)) - for i in range(len(results)): - self.assertEqual(results[i], results_ref[i])