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)): diff --git a/src/aiidalab_qe_vibroscopy/app/settings.py b/src/aiidalab_qe_vibroscopy/app/settings.py index 1a3d67c..a2ed646 100644 --- a/src/aiidalab_qe_vibroscopy/app/settings.py +++ b/src/aiidalab_qe_vibroscopy/app/settings.py @@ -143,6 +143,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( [ @@ -167,6 +174,7 @@ def change_supercell(_=None): ], ), self.supercell_widget, + self.symmetry_symprec, ] super().__init__(**kwargs) @@ -208,16 +216,19 @@ def get_panel_value(self): return { "simulation_mode": self.calc_options.value, "supercell_selector": self.supercell, + "symmetry_symprec": self.symmetry_symprec.value, } def set_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) self._sc_x.value, self._sc_y.value, self._sc_z.value = self.supercell def reset(self): """Reset the panel""" self.calc_options.value = 1 self.supercell = [2, 2, 2] + self.symmetry_symprec.value = 1e-5 self._sc_x.value, self._sc_y.value, self._sc_z.value = self.supercell diff --git a/src/aiidalab_qe_vibroscopy/app/workchain.py b/src/aiidalab_qe_vibroscopy/app/workchain.py index 9fcec63..41cd05c 100644 --- a/src/aiidalab_qe_vibroscopy/app/workchain.py +++ b/src/aiidalab_qe_vibroscopy/app/workchain.py @@ -56,6 +56,7 @@ def get_builder(codes, structure, parameters): "supercell_matrix": supercell_matrix, }, "dielectric": {"scf": deepcopy(parameters["advanced"])}, + "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 ee05481..be7cd7d 100644 --- a/src/aiidalab_qe_vibroscopy/workflows/vibroworkchain.py +++ b/src/aiidalab_qe_vibroscopy/workflows/vibroworkchain.py @@ -439,18 +439,24 @@ 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.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": 1e-3} + {"symmetry_tolerance": overrides["symmetry"]["symprec"]} ) elif structure.pbc == (True, True, False): @@ -475,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, @@ -485,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, @@ -517,9 +528,11 @@ 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.symmetry.symprec = orm.Float( + overrides["symmetry"]["symprec"] + ) builder_iraman.phonon.phonopy.parameters = orm.Dict( - {"symmetry_tolerance": 1e-3} + {"symmetry_tolerance": overrides["symmetry"]["symprec"]} ) builder.iraman = builder_iraman @@ -544,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): @@ -574,18 +586,24 @@ 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.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": 1e-3} + {"symmetry_tolerance": overrides["symmetry"]["symprec"]} ) elif structure.pbc == (True, True, False): @@ -610,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, @@ -620,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, @@ -635,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: @@ -659,7 +680,9 @@ 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 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.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 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: