From df0aaf2471373aa21cbda59dd1c3c9051e8a3715 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Tue, 14 Nov 2023 13:16:22 +0100 Subject: [PATCH] Rename calculators to workflows --- docs/source/materialproperties.md | 20 ++++++++++---------- tests/test_elastic_emt.py | 6 +++--- tests/test_elastic_gpaw.py | 7 +++---- tests/test_elastic_lammps.py | 6 +++--- tests/test_evcurve_abinit.py | 6 +++--- tests/test_evcurve_emt.py | 6 +++--- tests/test_evcurve_gpaw.py | 7 +++---- tests/test_evcurve_lammps.py | 6 +++--- tests/test_evcurve_qe.py | 6 +++--- tests/test_evcurve_siesta.py | 6 +++--- tests/test_phonons_emt.py | 8 ++++---- tests/test_phonons_gpaw.py | 8 ++++---- tests/test_phonons_lammps.py | 8 ++++---- tests/test_quasiharmonic_emt.py | 8 ++++---- tests/test_quasiharmonic_lammps.py | 8 ++++---- 15 files changed, 57 insertions(+), 59 deletions(-) diff --git a/docs/source/materialproperties.md b/docs/source/materialproperties.md index 715adeff..36452ea1 100644 --- a/docs/source/materialproperties.md +++ b/docs/source/materialproperties.md @@ -17,7 +17,7 @@ from gpaw import GPAW, PW import numpy as np -calculator = EnergyVolumeCurveWorkflow( +workflow = EnergyVolumeCurveWorkflow( structure=bulk("Al", a=4.05, cubic=True), num_points=11, fit_type='polynomial', @@ -26,7 +26,7 @@ calculator = EnergyVolumeCurveWorkflow( axes=['x', 'y', 'z'], strains=None, ) -task_dict = calculator.generate_structures() +task_dict = workflow.generate_structures() result_dict = evaluate_with_ase( task_dict=task_dict, ase_calculator=GPAW( @@ -35,7 +35,7 @@ result_dict = evaluate_with_ase( kpts=(3, 3, 3) ) ) -fit_dict = calculator.analyse_structures(output_dict=result_dict) +fit_dict = workflow.analyse_structures(output_dict=result_dict) print(fit_dict) ``` @@ -51,14 +51,14 @@ from gpaw import GPAW, PW import numpy as np -calculator = ElasticMatrixWorkflow( +workflow = ElasticMatrixWorkflow( structure=bulk("Al", a=4.0, cubic=True), num_of_point=5, eps_range=0.05, sqrt_eta=True, fit_order=2 ) -task_dict = calculator.generate_structures() +task_dict = workflow.generate_structures() result_dict = evaluate_with_ase( task_dict=task_dict, ase_calculator=GPAW( @@ -67,7 +67,7 @@ result_dict = evaluate_with_ase( kpts=(3, 3, 3) ) ) -elastic_dict = calculator.analyse_structures(output_dict=result_dict) +elastic_dict = workflow.analyse_structures(output_dict=result_dict) print(elastic_dict) ``` @@ -135,7 +135,7 @@ pes.plot_contourf(show_min_erg_path=True) ``` ### Quasi-Harmonic Approximation ``` -calculator = QuasiHarmonicWorkflow( +workflow = QuasiHarmonicWorkflow( structure=structure, num_points=11, vol_range=0.05, @@ -146,13 +146,13 @@ calculator = QuasiHarmonicWorkflow( primitive_matrix=None, number_of_snapshots=None, ) -structure_dict = calculator.generate_structures() +structure_dict = workflow.generate_structures() result_dict = evaluate_with_lammps( task_dict=structure_dict, potential_dataframe=potential_dataframe, ) -eng_internal_dict, mesh_collect_dict, dos_collect_dict = calculator.analyse_structures(output_dict=result_dict) -tp_collect_dict = calculator.get_thermal_properties(t_min=1, t_max=1500, t_step=50, temperatures=None) +eng_internal_dict, mesh_collect_dict, dos_collect_dict = workflow.analyse_structures(output_dict=result_dict) +tp_collect_dict = workflow.get_thermal_properties(t_min=1, t_max=1500, t_step=50, temperatures=None) temperatures = tp_collect_dict[1.0]['temperatures'] temperature_max = max(temperatures) diff --git a/tests/test_elastic_emt.py b/tests/test_elastic_emt.py index efc6777f..f3399142 100644 --- a/tests/test_elastic_emt.py +++ b/tests/test_elastic_emt.py @@ -9,16 +9,16 @@ class TestElastic(unittest.TestCase): def test_calc_elastic(self): - calculator = ElasticMatrixWorkflow( + workflow = ElasticMatrixWorkflow( structure=bulk("Al", a=4.0, cubic=True), num_of_point=5, eps_range=0.005, sqrt_eta=True, fit_order=2 ) - task_dict = calculator.generate_structures() + task_dict = workflow.generate_structures() result_dict = evaluate_with_ase(task_dict=task_dict, ase_calculator=EMT()) - elastic_dict = calculator.analyse_structures(output_dict=result_dict) + elastic_dict = workflow.analyse_structures(output_dict=result_dict) self.assertTrue(np.isclose(elastic_dict["C"][0, 0], 52.62435421)) self.assertTrue(np.isclose(elastic_dict["C"][0, 1], 32.6743838)) self.assertTrue(np.isclose(elastic_dict["C"][3, 3], 35.58677436)) diff --git a/tests/test_elastic_gpaw.py b/tests/test_elastic_gpaw.py index 6b97e402..da12f1c7 100644 --- a/tests/test_elastic_gpaw.py +++ b/tests/test_elastic_gpaw.py @@ -18,14 +18,14 @@ ) class TestElastic(unittest.TestCase): def test_calc_elastic(self): - calculator = ElasticMatrixWorkflow( + workflow = ElasticMatrixWorkflow( structure=bulk("Al", a=4.0, cubic=True), num_of_point=5, eps_range=0.05, sqrt_eta=True, fit_order=2 ) - task_dict = calculator.generate_structures() + task_dict = workflow.generate_structures() result_dict = evaluate_with_ase( task_dict=task_dict, ase_calculator=GPAW( @@ -34,8 +34,7 @@ def test_calc_elastic(self): kpts=(3, 3, 3) ) ) - elastic_dict = calculator.analyse_structures(output_dict=result_dict) - print(elastic_dict) + elastic_dict = workflow.analyse_structures(output_dict=result_dict) self.assertTrue(np.isclose(elastic_dict["C"][0, 0], 125.66807354, atol=1e-04)) self.assertTrue(np.isclose(elastic_dict["C"][0, 1], 68.41418321, atol=1e-04)) self.assertTrue(np.isclose(elastic_dict["C"][3, 3], 99.29916329, atol=1e-04)) diff --git a/tests/test_elastic_lammps.py b/tests/test_elastic_lammps.py index 403006f7..aa3d4e4a 100644 --- a/tests/test_elastic_lammps.py +++ b/tests/test_elastic_lammps.py @@ -34,19 +34,19 @@ def test_calc_elastic(self): task_dict=task_dict, potential_dataframe=df_pot_selected, ) - calculator = ElasticMatrixWorkflow( + workflow = ElasticMatrixWorkflow( structure=result_dict["structure_with_optimized_positions_and_volume"], num_of_point=5, eps_range=0.005, sqrt_eta=True, fit_order=2 ) - task_dict = calculator.generate_structures() + task_dict = workflow.generate_structures() result_dict = evaluate_with_lammps( task_dict=task_dict, potential_dataframe=df_pot_selected, ) - elastic_dict = calculator.analyse_structures(output_dict=result_dict) + elastic_dict = workflow.analyse_structures(output_dict=result_dict) self.assertTrue(np.isclose(elastic_dict["C"][0, 0], 114.10393023)) self.assertTrue(np.isclose(elastic_dict["C"][0, 1], 60.51098897)) self.assertTrue(np.isclose(elastic_dict["C"][3, 3], 51.23853765)) diff --git a/tests/test_evcurve_abinit.py b/tests/test_evcurve_abinit.py index acca7f28..c5c91739 100644 --- a/tests/test_evcurve_abinit.py +++ b/tests/test_evcurve_abinit.py @@ -34,7 +34,7 @@ def validate_fitdict(fit_dict): ) class TestEvCurve(unittest.TestCase): def test_calc_evcurve(self): - calculator = EnergyVolumeCurveWorkflow( + workflow = EnergyVolumeCurveWorkflow( structure=bulk("Al", a=4.05, cubic=True), num_points=11, fit_type='polynomial', @@ -43,7 +43,7 @@ def test_calc_evcurve(self): axes=['x', 'y', 'z'], strains=None, ) - task_dict = calculator.generate_structures() + task_dict = workflow.generate_structures() result_dict = evaluate_with_ase( task_dict=task_dict, ase_calculator=Abinit( @@ -55,5 +55,5 @@ def test_calc_evcurve(self): v8_legacy_format=False, ) ) - fit_dict = calculator.analyse_structures(output_dict=result_dict) + fit_dict = workflow.analyse_structures(output_dict=result_dict) self.assertTrue(all(validate_fitdict(fit_dict=fit_dict))) diff --git a/tests/test_evcurve_emt.py b/tests/test_evcurve_emt.py index 3a5b2ab2..4c45b0eb 100644 --- a/tests/test_evcurve_emt.py +++ b/tests/test_evcurve_emt.py @@ -9,7 +9,7 @@ class TestEvCurve(unittest.TestCase): def test_calc_evcurve(self): - calculator = EnergyVolumeCurveWorkflow( + workflow = EnergyVolumeCurveWorkflow( structure=bulk("Al", a=4.0, cubic=True), num_points=11, fit_type='polynomial', @@ -18,9 +18,9 @@ def test_calc_evcurve(self): axes=['x', 'y', 'z'], strains=None, ) - task_dict = calculator.generate_structures() + task_dict = workflow.generate_structures() result_dict = evaluate_with_ase(task_dict=task_dict, ase_calculator=EMT()) - fit_dict = calculator.analyse_structures(output_dict=result_dict) + fit_dict = workflow.analyse_structures(output_dict=result_dict) self.assertTrue(np.isclose(fit_dict['volume_eq'], 63.72615218844302)) self.assertTrue(np.isclose(fit_dict['bulkmodul_eq'], 39.544084907317895)) self.assertTrue(np.isclose(fit_dict['b_prime_eq'], 2.2509394023322566)) diff --git a/tests/test_evcurve_gpaw.py b/tests/test_evcurve_gpaw.py index 732e5bda..7c463e6b 100644 --- a/tests/test_evcurve_gpaw.py +++ b/tests/test_evcurve_gpaw.py @@ -19,7 +19,7 @@ ) class TestEvCurve(unittest.TestCase): def test_calc_evcurve(self): - calculator = EnergyVolumeCurveWorkflow( + workflow = EnergyVolumeCurveWorkflow( structure=bulk("Al", a=4.05, cubic=True), num_points=11, fit_type='polynomial', @@ -28,7 +28,7 @@ def test_calc_evcurve(self): axes=['x', 'y', 'z'], strains=None, ) - task_dict = calculator.generate_structures() + task_dict = workflow.generate_structures() result_dict = evaluate_with_ase( task_dict=task_dict, ase_calculator=GPAW( @@ -37,8 +37,7 @@ def test_calc_evcurve(self): kpts=(3, 3, 3) ) ) - fit_dict = calculator.analyse_structures(output_dict=result_dict) - print(fit_dict) + fit_dict = workflow.analyse_structures(output_dict=result_dict) self.assertTrue(np.isclose(fit_dict['volume_eq'], 66.44252286131331, atol=1e-04)) self.assertTrue(np.isclose(fit_dict['bulkmodul_eq'], 72.38919826652857, atol=1e-04)) self.assertTrue(np.isclose(fit_dict['b_prime_eq'], 4.453836551712821, atol=1e-04)) diff --git a/tests/test_evcurve_lammps.py b/tests/test_evcurve_lammps.py index f498e4d8..4a1bf797 100644 --- a/tests/test_evcurve_lammps.py +++ b/tests/test_evcurve_lammps.py @@ -35,7 +35,7 @@ def test_calc_evcurve(self): task_dict=task_dict, potential_dataframe=df_pot_selected, ) - calculator = EnergyVolumeCurveWorkflow( + workflow = EnergyVolumeCurveWorkflow( structure=result_dict["structure_with_optimized_positions_and_volume"], num_points=11, fit_type='polynomial', @@ -44,12 +44,12 @@ def test_calc_evcurve(self): axes=['x', 'y', 'z'], strains=None, ) - task_dict = calculator.generate_structures() + task_dict = workflow.generate_structures() result_dict = evaluate_with_lammps( task_dict=task_dict, potential_dataframe=df_pot_selected, ) - fit_dict = calculator.analyse_structures(output_dict=result_dict) + fit_dict = workflow.analyse_structures(output_dict=result_dict) self.assertTrue(np.isclose(fit_dict['volume_eq'], 66.43019853103964)) self.assertTrue(np.isclose(fit_dict['bulkmodul_eq'], 77.7250135953191)) self.assertTrue(np.isclose(fit_dict['b_prime_eq'], 1.2795467367276832)) diff --git a/tests/test_evcurve_qe.py b/tests/test_evcurve_qe.py index 43d225f3..dde12eb3 100644 --- a/tests/test_evcurve_qe.py +++ b/tests/test_evcurve_qe.py @@ -37,7 +37,7 @@ def validate_fitdict(fit_dict): class TestEvCurve(unittest.TestCase): def test_calc_evcurve(self): pseudopotentials = {"Al": "Al.pbe-n-kjpaw_psl.1.0.0.UPF"} - calculator = EnergyVolumeCurveWorkflow( + workflow = EnergyVolumeCurveWorkflow( structure=bulk("Al", a=4.15, cubic=True), num_points=11, fit_type='polynomial', @@ -46,7 +46,7 @@ def test_calc_evcurve(self): axes=['x', 'y', 'z'], strains=None, ) - task_dict = calculator.generate_structures() + task_dict = workflow.generate_structures() result_dict = evaluate_with_ase( task_dict=task_dict, ase_calculator=Espresso( @@ -56,5 +56,5 @@ def test_calc_evcurve(self): kpts=(3, 3, 3), ) ) - fit_dict = calculator.analyse_structures(output_dict=result_dict) + fit_dict = workflow.analyse_structures(output_dict=result_dict) self.assertTrue(all(validate_fitdict(fit_dict=fit_dict))) diff --git a/tests/test_evcurve_siesta.py b/tests/test_evcurve_siesta.py index 7e4ef446..527af14e 100644 --- a/tests/test_evcurve_siesta.py +++ b/tests/test_evcurve_siesta.py @@ -38,7 +38,7 @@ def validate_fitdict(fit_dict): ) class TestEvCurve(unittest.TestCase): def test_calc_evcurve(self): - calculator = EnergyVolumeCurveWorkflow( + workflow = EnergyVolumeCurveWorkflow( structure=bulk("Al", a=4.15, cubic=True), num_points=11, fit_type='polynomial', @@ -47,7 +47,7 @@ def test_calc_evcurve(self): axes=['x', 'y', 'z'], strains=None, ) - task_dict = calculator.generate_structures() + task_dict = workflow.generate_structures() result_dict = evaluate_with_ase( task_dict=task_dict, ase_calculator=Siesta( @@ -62,5 +62,5 @@ def test_calc_evcurve(self): pseudo_qualifier="", ) ) - fit_dict = calculator.analyse_structures(output_dict=result_dict) + fit_dict = workflow.analyse_structures(output_dict=result_dict) self.assertTrue(all(validate_fitdict(fit_dict=fit_dict))) diff --git a/tests/test_phonons_emt.py b/tests/test_phonons_emt.py index a7295da5..b17e11e2 100644 --- a/tests/test_phonons_emt.py +++ b/tests/test_phonons_emt.py @@ -9,7 +9,7 @@ class TestPhonons(unittest.TestCase): def test_calc_phonons(self): - calculator = PhonopyWorkflow( + workflow = PhonopyWorkflow( structure=bulk("Al", a=4.0, cubic=True), interaction_range=10, factor=VaspToTHz, @@ -18,10 +18,10 @@ def test_calc_phonons(self): primitive_matrix=None, number_of_snapshots=None, ) - task_dict = calculator.generate_structures() + task_dict = workflow.generate_structures() result_dict = evaluate_with_ase(task_dict=task_dict, ase_calculator=EMT()) - mesh_dict, dos_dict = calculator.analyse_structures(output_dict=result_dict) - self.assertEqual((324, 324), calculator.get_hesse_matrix().shape) + mesh_dict, dos_dict = workflow.analyse_structures(output_dict=result_dict) + self.assertEqual((324, 324), workflow.get_hesse_matrix().shape) self.assertTrue('qpoints' in mesh_dict.keys()) self.assertTrue('weights' in mesh_dict.keys()) self.assertTrue('frequencies' in mesh_dict.keys()) diff --git a/tests/test_phonons_gpaw.py b/tests/test_phonons_gpaw.py index 3b4b91f8..273092fd 100644 --- a/tests/test_phonons_gpaw.py +++ b/tests/test_phonons_gpaw.py @@ -18,7 +18,7 @@ ) class TestPhonons(unittest.TestCase): def test_calc_phonons(self): - calculator = PhonopyWorkflow( + workflow = PhonopyWorkflow( structure=bulk("Al", a=4.05, cubic=True), interaction_range=10, factor=VaspToTHz, @@ -27,7 +27,7 @@ def test_calc_phonons(self): primitive_matrix=None, number_of_snapshots=None, ) - task_dict = calculator.generate_structures() + task_dict = workflow.generate_structures() result_dict = evaluate_with_ase( task_dict=task_dict, ase_calculator=GPAW( @@ -36,8 +36,8 @@ def test_calc_phonons(self): kpts=(3, 3, 3) ) ) - mesh_dict, dos_dict = calculator.analyse_structures(output_dict=result_dict) - self.assertEqual((324, 324), calculator.get_hesse_matrix().shape) + mesh_dict, dos_dict = workflow.analyse_structures(output_dict=result_dict) + self.assertEqual((324, 324), workflow.get_hesse_matrix().shape) self.assertTrue('qpoints' in mesh_dict.keys()) self.assertTrue('weights' in mesh_dict.keys()) self.assertTrue('frequencies' in mesh_dict.keys()) diff --git a/tests/test_phonons_lammps.py b/tests/test_phonons_lammps.py index fe21ef72..a7f6f6ec 100644 --- a/tests/test_phonons_lammps.py +++ b/tests/test_phonons_lammps.py @@ -34,7 +34,7 @@ def test_calc_phonons(self): task_dict=task_dict, potential_dataframe=df_pot_selected, ) - calculator = PhonopyWorkflow( + workflow = PhonopyWorkflow( structure=result_dict["structure_with_optimized_positions_and_volume"], interaction_range=10, factor=VaspToTHz, @@ -43,13 +43,13 @@ def test_calc_phonons(self): primitive_matrix=None, number_of_snapshots=None, ) - task_dict = calculator.generate_structures() + task_dict = workflow.generate_structures() result_dict = evaluate_with_lammps( task_dict=task_dict, potential_dataframe=df_pot_selected, ) - mesh_dict, dos_dict = calculator.analyse_structures(output_dict=result_dict) - self.assertEqual((324, 324), calculator.get_hesse_matrix().shape) + mesh_dict, dos_dict = workflow.analyse_structures(output_dict=result_dict) + self.assertEqual((324, 324), workflow.get_hesse_matrix().shape) self.assertTrue('qpoints' in mesh_dict.keys()) self.assertTrue('weights' in mesh_dict.keys()) self.assertTrue('frequencies' in mesh_dict.keys()) diff --git a/tests/test_quasiharmonic_emt.py b/tests/test_quasiharmonic_emt.py index 6a997b2a..6f766fc7 100644 --- a/tests/test_quasiharmonic_emt.py +++ b/tests/test_quasiharmonic_emt.py @@ -9,7 +9,7 @@ class TestPhonons(unittest.TestCase): def test_calc_phonons(self): - calculator = QuasiHarmonicWorkflow( + workflow = QuasiHarmonicWorkflow( structure=bulk("Al", a=4.0, cubic=True), num_points=11, vol_range=0.05, @@ -20,12 +20,12 @@ def test_calc_phonons(self): primitive_matrix=None, number_of_snapshots=None, ) - task_dict = calculator.generate_structures() + task_dict = workflow.generate_structures() result_dict = evaluate_with_ase( task_dict=task_dict, ase_calculator=EMT() ) - eng_internal_dict, mesh_collect_dict, dos_collect_dict = calculator.analyse_structures(output_dict=result_dict) - tp_collect_dict = calculator.get_thermal_properties(t_min=1, t_max=1500, t_step=50, temperatures=None) + eng_internal_dict, mesh_collect_dict, dos_collect_dict = workflow.analyse_structures(output_dict=result_dict) + tp_collect_dict = workflow.get_thermal_properties(t_min=1, t_max=1500, t_step=50, temperatures=None) self.assertEqual(len(eng_internal_dict.keys()), 11) self.assertEqual(len(tp_collect_dict.keys()), 11) diff --git a/tests/test_quasiharmonic_lammps.py b/tests/test_quasiharmonic_lammps.py index f3d80950..30d0688c 100644 --- a/tests/test_quasiharmonic_lammps.py +++ b/tests/test_quasiharmonic_lammps.py @@ -34,7 +34,7 @@ def test_calc_phonons(self): task_dict=task_dict, potential_dataframe=df_pot_selected, ) - calculator = QuasiHarmonicWorkflow( + workflow = QuasiHarmonicWorkflow( structure=result_dict["structure_with_optimized_positions_and_volume"], num_points=11, vol_range=0.05, @@ -45,12 +45,12 @@ def test_calc_phonons(self): primitive_matrix=None, number_of_snapshots=None, ) - task_dict = calculator.generate_structures() + task_dict = workflow.generate_structures() result_dict = evaluate_with_lammps( task_dict=task_dict, potential_dataframe=df_pot_selected, ) - eng_internal_dict, mesh_collect_dict, dos_collect_dict = calculator.analyse_structures(output_dict=result_dict) - tp_collect_dict = calculator.get_thermal_properties(t_min=1, t_max=1500, t_step=50, temperatures=None) + eng_internal_dict, mesh_collect_dict, dos_collect_dict = workflow.analyse_structures(output_dict=result_dict) + tp_collect_dict = workflow.get_thermal_properties(t_min=1, t_max=1500, t_step=50, temperatures=None) self.assertEqual(len(eng_internal_dict.keys()), 11) self.assertEqual(len(tp_collect_dict.keys()), 11)