From 1c1e7bca550264d0184a78e0fcc15df79504bc50 Mon Sep 17 00:00:00 2001 From: AndresOrtegaGuerrero Date: Thu, 19 Sep 2024 15:00:41 +0000 Subject: [PATCH 1/4] Adding Symprec Widget --- src/aiidalab_qe_vibroscopy/app/settings.py | 11 ++++++++ src/aiidalab_qe_vibroscopy/app/workchain.py | 1 + .../workflows/vibroworkchain.py | 26 +++++++++---------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/aiidalab_qe_vibroscopy/app/settings.py b/src/aiidalab_qe_vibroscopy/app/settings.py index 47d3f05..17c4bba 100644 --- a/src/aiidalab_qe_vibroscopy/app/settings.py +++ b/src/aiidalab_qe_vibroscopy/app/settings.py @@ -144,6 +144,13 @@ def change_supercell(_=None): self.supercell_widget.layout.display = "block" # end Supercell. + self.symmetry_symprec = ipw.FloatText( + value=1e-5, + description="Symmetry tolerance (symprec):", + style={"description_width": "initial"}, + layout={"width": "300px"}, + ) + self.children = [ ipw.VBox( [ @@ -168,6 +175,7 @@ def change_supercell(_=None): ], ), self.supercell_widget, + self.symmetry_symprec, ] super().__init__(**kwargs) @@ -209,14 +217,17 @@ def get_panel_value(self): return { "simulation_mode": self.calc_options.value, "supercell_selector": self.supercell, + "symmetry_symprec": self.symmetry_symprec.value, } def load_panel_value(self, input_dict): """Load a dictionary with the input parameters for the plugin.""" self.calc_options.value = input_dict.get("simulation_mode", 1) self.supercell = input_dict.get("supercell_selector", [2, 2, 2]) + self.symmetry_symprec.value = input_dict.get("symmetry_symprec", 1e-5) def reset(self): """Reset the panel""" self.calc_options.value = 1 self.supercell = [2, 2, 2] + self.symmetry_symprec.value = 1e-5 diff --git a/src/aiidalab_qe_vibroscopy/app/workchain.py b/src/aiidalab_qe_vibroscopy/app/workchain.py index af251aa..f5ee6c6 100644 --- a/src/aiidalab_qe_vibroscopy/app/workchain.py +++ b/src/aiidalab_qe_vibroscopy/app/workchain.py @@ -57,6 +57,7 @@ def get_builder(codes, structure, parameters): "supercell_matrix": supercell_matrix, }, "dielectric": {"scf": scf_overrides}, + "symmetry:": {"symprec": parameters["vibronic"]["symmetry_symprec"]}, } # Update code information with resource configurations diff --git a/src/aiidalab_qe_vibroscopy/workflows/vibroworkchain.py b/src/aiidalab_qe_vibroscopy/workflows/vibroworkchain.py index f907227..94c85b6 100644 --- a/src/aiidalab_qe_vibroscopy/workflows/vibroworkchain.py +++ b/src/aiidalab_qe_vibroscopy/workflows/vibroworkchain.py @@ -431,17 +431,17 @@ def get_builder_from_protocol( if structure.pbc == (True, False, False): builder.phonopy_bands_dict = Dict( dict={ - "symmetry_tolerance": 1e-3, + "symmetry_tolerance": overrides["symmetry"]["symprec"], "band": [0, 0, 0, 1 / 2, 0, 0], "band_points": 100, "band_labels": [GAMMA, "$\\mathrm{X}$"], } ) #change symprec for 1D materials to 1e-3 - builder.phonopy_pdos_dict["symmetry_tolerance"] = 1e-3 - builder.phonopy_thermo_dict["symmetry_tolerance"] = 1e-3 - builder.harmonic.symmetry.symprec = orm.Float(1e-3) - builder.harmonic.phonon.phonopy.parameters = orm.Dict({"symmetry_tolerance": 1e-3}) + builder.phonopy_pdos_dict["symmetry_tolerance"] = overrides["symmetry"]["symprec"] #1e-3 + builder.phonopy_thermo_dict["symmetry_tolerance"] = overrides["symmetry"]["symprec"] # 1e-3 + builder.harmonic.symmetry.symprec = orm.Float(overrides["symmetry"]["symprec"]) + builder.harmonic.phonon.phonopy.parameters = orm.Dict({"symmetry_tolerance": overrides["symmetry"]["symprec"]}) elif structure.pbc == (True, True, False): symmetry_path = determine_symmetry_path(structure) @@ -499,8 +499,8 @@ def get_builder_from_protocol( builder_iraman.dielectric.pop("kpoints_parallel_distance", None) if structure.pbc == (True, False, False): - builder_iraman.symmetry.symprec = orm.Float(1e-3) - builder_iraman.phonon.phonopy.parameters = orm.Dict({"symmetry_tolerance": 1e-3}) + builder_iraman.symmetry.symprec = orm.Float(overrides["symmetry"]["symprec"]) + builder_iraman.phonon.phonopy.parameters = orm.Dict({"symmetry_tolerance": overrides["symmetry"]["symprec"]}) builder.iraman = builder_iraman @@ -553,17 +553,17 @@ def get_builder_from_protocol( if structure.pbc == (True, False, False): builder.phonopy_bands_dict = Dict( dict={ - "symmetry_tolerance": 1e-3, + "symmetry_tolerance": overrides["symmetry"]["symprec"], "band": [0, 0, 0, 1 / 2, 0, 0], "band_points": 100, "band_labels": [GAMMA, "$\\mathrm{X}$"], } ) #change symprec for 1D materials to 1e-3 - builder.phonopy_pdos_dict["symmetry_tolerance"] = 1e-3 - builder.phonopy_thermo_dict["symmetry_tolerance"] = 1e-3 - builder.phonon.symmetry.symprec = orm.Float(1e-3) - builder.phonon.phonopy.parameters = orm.Dict({"symmetry_tolerance": 1e-3}) + builder.phonopy_pdos_dict["symmetry_tolerance"] = overrides["symmetry"]["symprec"] + builder.phonopy_thermo_dict["symmetry_tolerance"] = overrides["symmetry"]["symprec"] + builder.phonon.symmetry.symprec = orm.Float(overrides["symmetry"]["symprec"]) + builder.phonon.phonopy.parameters = orm.Dict({"symmetry_tolerance": overrides["symmetry"]["symprec"]}) elif structure.pbc == (True, True, False): symmetry_path = determine_symmetry_path(structure) @@ -631,7 +631,7 @@ def get_builder_from_protocol( "num_mpiprocs_per_machine": 1, } if structure.pbc == (True, False, False): - builder.phonopy_calc.parameters = orm.Dict({"symmetry_tolerance": 1e-3}) + builder.phonopy_calc.parameters = orm.Dict({"symmetry_tolerance": overrides["symmetry"]["symprec"]}) builder.structure = structure return builder From 2fe138ba03f1e9b6b110e7e99b85414fab4ef93a Mon Sep 17 00:00:00 2001 From: AndresOrtegaGuerrero Date: Sun, 22 Sep 2024 15:59:40 +0000 Subject: [PATCH 2/4] Symprec parameter --- src/aiidalab_qe_vibroscopy/app/workchain.py | 2 +- .../workflows/vibroworkchain.py | 17 +++++++---- tests/conftest.py | 24 ++++++++++++---- tests/test_settings.py | 28 +++++++++++++++++++ .../test_create_builder_default.yml | 5 ++-- 5 files changed, 63 insertions(+), 13 deletions(-) diff --git a/src/aiidalab_qe_vibroscopy/app/workchain.py b/src/aiidalab_qe_vibroscopy/app/workchain.py index 06cc126..41cd05c 100644 --- a/src/aiidalab_qe_vibroscopy/app/workchain.py +++ b/src/aiidalab_qe_vibroscopy/app/workchain.py @@ -56,7 +56,7 @@ def get_builder(codes, structure, parameters): "supercell_matrix": supercell_matrix, }, "dielectric": {"scf": deepcopy(parameters["advanced"])}, - "symmetry:": {"symprec": parameters["vibronic"]["symmetry_symprec"]}, + "symmetry": {"symprec": parameters["vibronic"]["symmetry_symprec"]}, } # Update code information with resource configurations diff --git a/src/aiidalab_qe_vibroscopy/workflows/vibroworkchain.py b/src/aiidalab_qe_vibroscopy/workflows/vibroworkchain.py index 26738a9..be7cd7d 100644 --- a/src/aiidalab_qe_vibroscopy/workflows/vibroworkchain.py +++ b/src/aiidalab_qe_vibroscopy/workflows/vibroworkchain.py @@ -481,8 +481,12 @@ def get_builder_from_protocol( ) else: builder.phonopy_bands_dict = Dict(dict=PhononProperty.BANDS.value) + builder.phonopy_bands_dict["symmetry_tolerance"] = overrides[ + "symmetry" + ]["symprec"] builder.phonopy_pdos_dict = Dict( dict={ + "symmetry_tolerance": overrides["symmetry"]["symprec"], "pdos": "auto", "mesh": 150, # 1000 is too heavy "write_mesh": False, @@ -491,6 +495,7 @@ def get_builder_from_protocol( builder.phonopy_thermo_dict = Dict( dict={ + "symmetry_tolerance": overrides["symmetry"]["symprec"], "tprop": True, "mesh": 200, # 1000 is too heavy "write_mesh": False, @@ -552,9 +557,8 @@ def get_builder_from_protocol( builder_phonon.phonopy.settings = Dict(dict={"keep_phonopy_yaml": True}) # MBO: I do not understand why I have to do this, but it works - symmetry = builder_phonon.pop("symmetry") builder.phonon = builder_phonon - builder.phonon.symmetry = symmetry + builder.phonon.symmetry = overrides["symmetry"] # Adding the bands and pdos inputs. if structure.pbc != (True, True, True): @@ -624,8 +628,12 @@ def get_builder_from_protocol( ) else: builder.phonopy_bands_dict = Dict(dict=PhononProperty.BANDS.value) + builder.phonopy_bands_dict["symmetry_tolerance"] = overrides[ + "symmetry" + ]["symprec"] builder.phonopy_pdos_dict = Dict( dict={ + "symmetry_tolerance": overrides["symmetry"]["symprec"], "pdos": "auto", "mesh": 150, # 1000 is too heavy "write_mesh": False, @@ -634,6 +642,7 @@ def get_builder_from_protocol( builder.phonopy_thermo_dict = Dict( dict={ + "symmetry_tolerance": overrides["symmetry"]["symprec"], "tprop": True, "mesh": 200, # 1000 is too heavy "write_mesh": False, @@ -649,12 +658,10 @@ def get_builder_from_protocol( **kwargs, ) - # MBO: I do not understand why I have to do this, but it works. maybe related with excludes. - symmetry = builder_dielectric.pop("symmetry") if structure.pbc != (True, True, True): builder_dielectric.pop("kpoints_parallel_distance", None) builder.dielectric = builder_dielectric - builder.dielectric.symmetry = symmetry + builder.dielectric.symmetry = overrides["symmetry"] builder.dielectric.property = dielectric_property # Deleting the not needed parts of the builder: diff --git a/tests/conftest.py b/tests/conftest.py index 3f6d75a..f085677 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -48,14 +48,15 @@ def _fixture_code(entry_point_name): def generate_structure_data(): """generate a `StructureData` object.""" - def _generate_structure_data(name="silicon", pbc=(True, True, True)): + def _generate_structure_data(name="silicon"): if name == "silicon": structure = orm.StructureData( cell=[ [3.84737, 0.0, 0.0], [1.923685, 3.331920, 0.0], [1.923685, 1.110640, 3.141364], - ] + ], + pbc=(True, True, True), ) structure.append_atom(position=(0.0, 0.0, 0.0), symbols="Si") structure.append_atom(position=(1.923685, 1.110640, 0.785341), symbols="Si") @@ -65,7 +66,8 @@ def _generate_structure_data(name="silicon", pbc=(True, True, True)): [4.18, 0.0, 0.0], [0.0, 4.18, 0.0], [0.0, 0.0, 2.66], - ] + ], + pbc=(True, True, True), ) structure.append_atom(position=(0.0, 0.0, 0.0), symbols="Si") structure.append_atom(position=(2.09, 2.09, 1.33), symbols="Si") @@ -88,11 +90,23 @@ def _generate_structure_data(name="silicon", pbc=(True, True, True)): ["O", "O", (0, 0, 10.201532881212)], ["Li", "Li", (0, 0, 6.9018028772754)], ] - structure = orm.StructureData(cell=cell) + structure = orm.StructureData(cell=cell, pbc=(True, True, True)) for site in sites: structure.append_atom(position=site[2], symbols=site[0], name=site[1]) - structure.pbc = pbc + + elif name == "2D-xy-arsenic": + cell = [[3.61, 0, 0], [-1.80, 3.13, 0], [0, 0, 21.3]] + structure = orm.StructureData(cell=cell, pbc=(True, True, False)) + structure.append_atom( + position=(1.804, 1.042, 11.352), symbols="As", name="As" + ) + structure.append_atom(position=(0, 2.083, 9.960), symbols="As", name="As") + + elif name == "1D-x-carbon": + cell = [[4.2, 0, 0], [0, 20, 0], [0, 0, 20]] + structure = orm.StructureData(cell=cell, pbc=(True, False, False)) + structure.append_atom(position=(0, 0, 0), symbols="C", name="C") return structure diff --git a/tests/test_settings.py b/tests/test_settings.py index f2ca0f1..88d7db6 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -47,3 +47,31 @@ def test_settings(): parameters = configure_step.settings["vibronic"].get_panel_value() assert parameters["simulation_mode"] == 1 assert parameters["supercell_selector"] == [2, 2, 2] + + +@pytest.mark.usefixtures("sssp") +def test_xy_settings(generate_structure_data): + """Test the settings of the vibroscopy app.""" + + from aiidalab_qe.app.configuration import ConfigureQeAppWorkChainStep + + configure_step = ConfigureQeAppWorkChainStep() + structure = generate_structure_data("2D-xy-arsenic") + configure_step.input_structure = structure + configure_step.workchain_settings.properties["vibronic"].run.value = True + parameters = configure_step.settings["vibronic"].get_panel_value() + assert parameters["supercell_selector"] == [2, 2, 1] + + +@pytest.mark.usefixtures("sssp") +def test_x_settings(generate_structure_data): + """Test the settings of the vibroscopy app.""" + + from aiidalab_qe.app.configuration import ConfigureQeAppWorkChainStep + + configure_step = ConfigureQeAppWorkChainStep() + structure = generate_structure_data("1D-x-carbon") + configure_step.input_structure = structure + configure_step.workchain_settings.properties["vibronic"].run.value = True + parameters = configure_step.settings["vibronic"].get_panel_value() + assert parameters["supercell_selector"] == [2, 1, 1] diff --git a/tests/test_submit/test_create_builder_default.yml b/tests/test_submit/test_create_builder_default.yml index 57ff655..bb9be5f 100644 --- a/tests/test_submit/test_create_builder_default.yml +++ b/tests/test_submit/test_create_builder_default.yml @@ -39,11 +39,11 @@ codes: nodes: 1 ntasks_per_node: 1 pw: - cpus: 10 + cpus: 8 cpus_per_task: 1 max_wallclock_seconds: 43200 nodes: 1 - ntasks_per_node: 10 + ntasks_per_node: 8 parallelization: {} vibronic: simulation_mode: 1 @@ -51,6 +51,7 @@ vibronic: - 2 - 2 - 2 + symmetry_symprec: 1.0e-05 workchain: electronic_type: metal properties: From 3ba1d2e722802f987f45afd0af9bdc6b29601b52 Mon Sep 17 00:00:00 2001 From: AndresOrtegaGuerrero Date: Sun, 22 Sep 2024 16:02:12 +0000 Subject: [PATCH 3/4] pre-commit --- src/aiidalab_qe_vibroscopy/app/result.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/aiidalab_qe_vibroscopy/app/result.py b/src/aiidalab_qe_vibroscopy/app/result.py index e0b532d..36cc7c8 100644 --- a/src/aiidalab_qe_vibroscopy/app/result.py +++ b/src/aiidalab_qe_vibroscopy/app/result.py @@ -94,7 +94,6 @@ def _update_view(self): _bands_plot_view_class.update_layout( yaxis=dict(autorange=True), # Automatically scale the y-axis ) - # the data (bands and pdos) are the first element of the lists phonon_data["bands"] and phonon_data["pdos"]! downloadBandsPdos_widget = DownloadBandsPdosWidget( @@ -209,14 +208,13 @@ def _update_view(self): dielectric_results = DielectricResults(dielectric_data) children_result_widget += (dielectric_results,) tab_titles.append("Dielectric properties") - + # euphonic if ins_data: intensity_maps = EuphonicSuperWidget(fc=ins_data["fc"]) children_result_widget += (intensity_maps,) tab_titles.append("Inelastic Neutrons") - self.result_tabs = ipw.Tab(children=children_result_widget) for title_index in range(len(tab_titles)): From 01dfe7bdeb515b1f66d3e5d684c242f4dcd28d70 Mon Sep 17 00:00:00 2001 From: mikibonacci Date: Mon, 23 Sep 2024 12:23:58 +0000 Subject: [PATCH 4/4] Fixing the test_submit num_cpus (from 10 to 8). --- tests/test_submit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_submit.py b/tests/test_submit.py index a0466a4..f2aa2e0 100644 --- a/tests/test_submit.py +++ b/tests/test_submit.py @@ -37,7 +37,7 @@ def test_create_builder_default( submit_step.codes["dielectric"].value = pw_code.uuid submit_step.codes["phonopy"].value = phonopy_code.uuid - submit_step.codes["pw"].num_cpus.value = 10 + submit_step.codes["pw"].num_cpus.value = 8 submit_step.codes["phonon"].num_cpus.value = 2 submit_step.codes["dielectric"].num_cpus.value = 3