Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/abacusagent/modules/submodules/vacancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def abacus_cal_vacancy_formation_energy(
A dictionary containing:
- "vacancy_formation_energy": Calculated vacancy formation energy.
- "work_path": Path to the work path of vacancy formation energy calculation.
- "supercell_job_relax_converge": If the supercell relax calculation is converged.
- "original_stru_job_relax_converge": If the relax calculation of original structure is converged.
- "defect_supercell_job_relax_converge": If the defect supercell relax calculation is converged.
"""
try:
Expand Down
4 changes: 2 additions & 2 deletions src/abacusagent/modules/tool_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ def abacus_vacancy_formation_energy(
Returns:
A dictionary containing:
- "vacancy_formation_energy": Calculated vacancy formation energy.
- "supercell_job_relax_converge": If the supercell relax calculation is converged.
- "original_stru_job_relax_converge": If the relax calculation of original structure is converged.
- "defect_supercell_job_relax_converge": If the defect supercell relax calculation is converged.
"""
dftu_param = transform_dftu_param(dftu_param) if dftu_param is not None else None
Expand Down Expand Up @@ -931,7 +931,7 @@ def abacus_vacancy_formation_energy(
vacancy_relax_precision)

return {'vacancy_formation_energy': vacancy_outputs.get('vac_formation_energy', None),
'supercell_job_relax_converge': vacancy_outputs.get('supercell_job_relax_converge', None),
'original_stru_job_relax_converge': vacancy_outputs.get('original_stru_job_relax_converge', None),
'defect_supercell_job_relax_converge': vacancy_outputs.get('defect_supercell_job_relax_converge', None),}

@mcp.tool()
Expand Down
6 changes: 3 additions & 3 deletions src/abacusagent/modules/vacancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def abacus_cal_vacancy_formation_energy(
Returns:
A dictionary containing:
- "vacancy_formation_energy": Calculated vacancy formation energy.
- "supercell_jobpath": Path to the supercell calculation job directory.
- "defect_supercell_jobpath": Path to the defect supercell calculation job directory.
- "vacancy_element_crys_jobpath": Path to the most stable crystal structure calculation job directory.
- "work_path": Path to the work path of vacancy formation energy calculation.
- "original_stru_job_relax_converge": If the relax calculation of original structure is converged.
- "defect_supercell_job_relax_converge": If the defect supercell relax calculation is converged.
"""
return _abacus_cal_vacancy_formation_energy(
abacus_inputs_dir,
Expand Down
8 changes: 4 additions & 4 deletions tests/integrate_test/data/ref_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"test_abacus_cal_band_nscf_pw_nspin1":
{
"result": {
"band_gap": 0.5583
"band_gap": 0.55855
}
},
"test_abacus_cal_band_nscf_pw_nspin2":
Expand All @@ -101,7 +101,7 @@
"test_abacus_cal_band_nscf_supercell":
{
"result": {
"band_gap": 0.5583
"band_gap": 0.55855
}
},
"test_abacus_dos_run_species":
Expand Down Expand Up @@ -338,7 +338,7 @@
"test_run_abacus_calculation_vacancy_formation_energy":
{
"result": {
"vac_formation_energy": 1.166700944879949
"vacancy_formation_energy": 1.155605088217726
}
},
"test_abacus_cal_work_function_al110":
Expand All @@ -363,7 +363,7 @@
"test_abacus_cal_vacancy_formation_energy_gamma_tial":
{
"result": {
"vac_formation_energy": 1.166700944879949
"vac_formation_energy": 1.155605088217726
}
},
"test_run_abacus_calculation_dftu_initmag":
Expand Down
5 changes: 3 additions & 2 deletions tests/integrate_test/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[pytest]
markers =
long: marks tests as long time usage (deselect with '-m "not long"')

long: mark tests as long time usage (deselect with '-m "not long"')
smoke: mark tests used in a quick smoke test
tool_wrapper: mark tests for tool wrapper
2 changes: 2 additions & 0 deletions tests/integrate_test/test_bader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
import unittest
import tempfile
import pytest
import inspect
from utils import initilize_test_env, load_test_ref_result, get_path_type
from abacusagent.modules.bader import abacus_badercharge_run
Expand All @@ -25,6 +26,7 @@ def setUp(self):
def tearDown(self):
os.chdir(self.original_cwd)

@pytest.mark.smoke
def test_abacus_badercharge_run_nspin1(self):
"""
Test Bader charge calculation for nspin=1 case.
Expand Down
8 changes: 6 additions & 2 deletions tests/integrate_test/test_band.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
import unittest
import tempfile
import pytest
import inspect
from utils import initilize_test_env, load_test_ref_result, get_path_type
from abacusagent.modules.band import abacus_cal_band
Expand All @@ -28,7 +29,8 @@ def setUp(self):

def tearDown(self):
os.chdir(self.original_cwd)


@pytest.mark.smoke
def test_abacus_cal_band_pyatb_nspin1(self):
"""
Test plot band structure in PYATB mode in nspin=1 case
Expand Down Expand Up @@ -66,7 +68,8 @@ def test_abacus_cal_band_pyatb_nspin2(self):
self.assertIsInstance(band_calc_dir, get_path_type())
self.assertIsInstance(band_picture, get_path_type())
self.assertAlmostEqual(outputs['band_gap'], ref_results['band_gap'], places=4)


@pytest.mark.smoke
def test_abacus_cal_band_nscf_nspin1(self):
"""
Test plot band structure in NSCF mode in nspin=1 case
Expand Down Expand Up @@ -233,6 +236,7 @@ def test_abacus_cal_band_pyatb_pw(self):
outputs = abacus_cal_band(test_work_dir, mode='pyatb')
self.assertEqual(outputs['message'], ref_results['message'])

@pytest.mark.smoke
def test_abacus_cal_band_nscf_pw_nspin1(self):
"""
Test plot band structure in NSCF mode using PW basis in nspin=1 case
Expand Down
3 changes: 3 additions & 0 deletions tests/integrate_test/test_dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
import unittest
import tempfile
import pytest
import inspect
from utils import initilize_test_env, load_test_ref_result, get_path_type
from abacusagent.modules.dos import abacus_dos_run
Expand All @@ -28,6 +29,7 @@ def setUp(self):
def tearDown(self):
os.chdir(self.original_cwd)

@pytest.mark.smoke
def test_abacus_dos_run_species(self):
"""
Test the abacus_dos_run function with PDOS plotting mode set to different species.
Expand Down Expand Up @@ -185,6 +187,7 @@ def test_abacus_dos_run_species_orbital_nspin2(self):
self.assertTrue(outputs['nscf_normal_end'])
self.assertAlmostEqual(outputs['scf_energy'], ref_results['scf_energy'])

@pytest.mark.smoke
def test_abacus_dos_run_pw_nspin1(self):
"""
Test the abacus_dos_run function with nspin=1 case with pw basis
Expand Down
2 changes: 2 additions & 0 deletions tests/integrate_test/test_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
import unittest
import tempfile
import pytest
import inspect
from utils import initilize_test_env, load_test_ref_result, get_path_type
from abacusagent.modules.md import abacus_run_md
Expand All @@ -26,6 +27,7 @@ def setUp(self):
def tearDown(self):
os.chdir(self.original_cwd)

@pytest.mark.smoke
def test_abacus_run_md_nve(self):
"""
Test the abacus_run_md function running molecule dynamics in NVE ensemble.
Expand Down
3 changes: 2 additions & 1 deletion tests/integrate_test/test_phonon.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def setUp(self):

def tearDown(self):
os.chdir(self.original_cwd)


@pytest.mark.smoke
def test_abacus_phonon_dispersion_nspin1(self):
"""
Test the abacus_phonon_dispersion function for Si primitive cell to test nspin=1 case.
Expand Down
18 changes: 10 additions & 8 deletions tests/integrate_test/test_relax.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
import unittest
import tempfile
import pytest
import inspect
from utils import initilize_test_env, load_test_ref_result, get_path_type
from abacusagent.modules.relax import abacus_do_relax
Expand All @@ -23,7 +24,8 @@ def setUp(self):

def tearDown(self):
os.chdir(self.original_cwd)


@pytest.mark.smoke
def test_abacus_do_relax_relax_cell(self):
"""
Test the abacus_do_relax function with relax_cell is True.
Expand All @@ -46,10 +48,10 @@ def test_abacus_do_relax_relax_cell(self):
new_relax_work_path = outputs['new_abacus_inputs_dir']
self.assertIsInstance(relax_work_path, get_path_type())
self.assertIsInstance(new_relax_work_path, get_path_type())
self.assertTrue(outputs['result']['normal_end'])
self.assertTrue(outputs['result']['relax_converge'])
self.assertTrue(outputs['result']['largest_gradient'][-1] <= force_thr_ev)
self.assertTrue(outputs['result']['largest_gradient_stress'][-1] <= stress_thr)
self.assertTrue(outputs['normal_end'])
self.assertTrue(outputs['relax_converge'])
self.assertTrue(outputs['largest_gradient'][-1] <= force_thr_ev)
self.assertTrue(outputs['largest_gradient_stress'][-1] <= stress_thr)

if os.path.exists(relax_work_path):
shutil.rmtree(relax_work_path)
Expand Down Expand Up @@ -80,9 +82,9 @@ def test_abacus_do_relax_not_relax_cell(self):
new_relax_work_path = outputs['new_abacus_inputs_dir']
self.assertIsInstance(relax_work_path, get_path_type())
self.assertIsInstance(new_relax_work_path, get_path_type())
self.assertTrue(outputs['result']['normal_end'])
self.assertTrue(outputs['result']['relax_converge'])
self.assertTrue(outputs['result']['largest_gradient'][-1] <= force_thr_ev)
self.assertTrue(outputs['normal_end'])
self.assertTrue(outputs['relax_converge'])
self.assertTrue(outputs['largest_gradient'][-1] <= force_thr_ev)

if os.path.exists(relax_work_path):
shutil.rmtree(relax_work_path)
Expand Down
2 changes: 2 additions & 0 deletions tests/integrate_test/test_scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
import unittest
import tempfile
import pytest
import inspect
from abacusagent.modules.scf import abacus_calculation_scf
from utils import initilize_test_env, load_test_ref_result
Expand All @@ -24,6 +25,7 @@ def setUp(self):
def tearDown(self):
os.chdir(self.original_cwd)

@pytest.mark.smoke
def test_abacus_calculation_scf(self):
"""
Test the abacus_calculation_scf function.
Expand Down
21 changes: 4 additions & 17 deletions tests/integrate_test/test_tool_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def setUp(self):
def tearDown(self):
os.chdir(self.original_cwd)

@pytest.mark.smoke
def test_run_abacus_calculation_scf(self):
"""
Test the wrapper function of doing SCF calculation.
Expand All @@ -58,9 +59,6 @@ def test_run_abacus_calculation_scf(self):
init_mag=None)
print(outputs)

scf_work_dir = Path(outputs['scf_work_dir']).absolute()
self.assertIsInstance(scf_work_dir, get_path_type())
self.assertTrue(os.path.exists(scf_work_dir))
self.assertTrue(outputs['normal_end'])
self.assertTrue(outputs['converge'])
self.assertAlmostEqual(outputs['energy'], ref_results['energy'], delta=1e-6)
Expand Down Expand Up @@ -95,9 +93,6 @@ def test_run_abacus_calculation_dftu_initmag(self):
init_mag=init_mag)
print(outputs)

scf_work_dir = Path(outputs['scf_work_dir']).absolute()
self.assertIsInstance(scf_work_dir, get_path_type())
self.assertTrue(os.path.exists(scf_work_dir))
self.assertTrue(outputs['normal_end'])
self.assertTrue(outputs['converge'])
self.assertAlmostEqual(outputs['energy'], ref_results['energy'], delta=1e-6)
Expand All @@ -122,8 +117,6 @@ def test_run_abacus_calculation_elf(self):
init_mag=None)
print(outputs)

self.assertIsInstance(outputs['elf_work_path'], get_path_type())
self.assertTrue(os.path.exists(outputs['elf_work_path']))
self.assertIsInstance(outputs['elf_file'], get_path_type())
self.assertTrue(os.path.exists(outputs['elf_file']))

Expand Down Expand Up @@ -221,10 +214,6 @@ def test_run_abacus_calculation_bader_charge(self):
print(outputs)

self.assertIsInstance(outputs['bader_result_csv'], get_path_type())
for act, ref in zip(outputs['net_bader_charges'], ref_results['net_bader_charges']):
self.assertAlmostEqual(act, ref, delta=1e-3)
for act, ref in zip(outputs['atom_labels'], ref_results['atom_labels']):
self.assertEqual(act, ref)

def test_run_abacus_calculation_band(self):
"""
Expand All @@ -249,8 +238,6 @@ def test_run_abacus_calculation_band(self):
relax_method='cg',
fixed_axes=None,
mode='auto',
kpath=None,
high_symm_points=None,
energy_min=-10,
energy_max=10,
insert_point_nums=30)
Expand Down Expand Up @@ -389,9 +376,9 @@ def test_run_abacus_calculation_vacancy_formation_energy(self):

print(outputs)

self.assertTrue(outputs['supercell_job_relax_converge'])
self.assertTrue(outputs['defect_supercell_job_relax_converge'])
self.assertAlmostEqual(outputs['vac_formation_energy'], ref_results['vac_formation_energy'], delta=2)
self.assertTrue(outputs['original_stru_job_relax_converge'])
self.assertTrue(outputs['original_stru_job_relax_converge'])
self.assertAlmostEqual(outputs['vacancy_formation_energy'], ref_results['vacancy_formation_energy'], delta=2)

def test_run_abacus_calculation_work_function(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions tests/integrate_test/test_vacancy_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
initilize_test_env()

@pytest.mark.long
class TestAbacusEos(unittest.TestCase):
class TestAbacusVacFormEner(unittest.TestCase):
def setUp(self):
self.test_dir = tempfile.TemporaryDirectory()
self.addCleanup(self.test_dir.cleanup)
Expand Down Expand Up @@ -44,7 +44,7 @@ def test_abacus_cal_vacancy_formation_energy_gamma_tial(self):

print(outputs)

self.assertTrue(outputs['supercell_job_relax_converge'])
self.assertTrue(outputs['original_stru_job_relax_converge'])
self.assertTrue(outputs['defect_supercell_job_relax_converge'])
self.assertAlmostEqual(outputs['vac_formation_energy'], ref_results['vac_formation_energy'], places=2)

Expand Down
4 changes: 3 additions & 1 deletion tests/integrate_test/test_vibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
import unittest
import tempfile
import pytest
import inspect
from utils import initilize_test_env, load_test_ref_result, get_path_type
from abacusagent.modules.vibration import abacus_vibration_analysis
Expand All @@ -22,7 +23,8 @@ def setUp(self):

def tearDown(self):
os.chdir(self.original_cwd)


@pytest.mark.smoke
def test_abacus_vibration_analysis_h2(self):
"""
Test the abacus_vibration_analysis function for relaxed H2 molecule.
Expand Down
1 change: 1 addition & 0 deletions tests/integrate_test/test_work_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def setUp(self):
def tearDown(self):
os.chdir(self.original_cwd)

@pytest.mark.smoke
def test_abacus_cal_work_function_al110(self):
"""
Calculate the work function of Al(100) surface.
Expand Down