From b6beb4bb6af175f9e7d315981f6393ab2438cd2b Mon Sep 17 00:00:00 2001 From: Carlo Antonio Pignedoli Date: Wed, 10 Jul 2024 15:12:21 +0000 Subject: [PATCH 1/6] tested ads_GW --- submit_gw_ic.ipynb | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/submit_gw_ic.ipynb b/submit_gw_ic.ipynb index 4ea2cae..c2f110b 100644 --- a/submit_gw_ic.ipynb +++ b/submit_gw_ic.ipynb @@ -73,8 +73,9 @@ " storable=False,\n", " node_class=\"StructureData\",\n", ")\n", - "display(structure_selector)\n", + "\n", "ipw.dlink((structure_selector, \"structure\"), (input_details, \"structure\"))\n", + "display(structure_selector)\n", "\n", "# Code.\n", "resources = awb.ComputationalResourcesWidget(\n", @@ -135,6 +136,15 @@ " style={\"description_width\": \"initial\"},\n", ")\n", "\n", + "# molecule\n", + "molecule = ipw.Text(\n", + " value=\"\",\n", + " placeholder=\"1..2\",\n", + " description=\"Molecule ids:\",\n", + " disabled=False,\n", + " style={\"description_width\": \"initial\"},\n", + ")\n", + "\n", "\n", "# description adsorption height\n", "html_ads_height = ipw.HTML(\n", @@ -181,6 +191,7 @@ " builder.protocol = orm.Str(gw_type.value)\n", "\n", " builder.geometry_mode = orm.Str(geo_mode.value)\n", + " builder.debug = orm.Bool(False)\n", "\n", " builder.options.scf = {\n", " \"max_wallclock_seconds\": resources_scf.walltime_seconds,\n", @@ -245,7 +256,7 @@ " only_one_molecule or input_details.details[\"system_type\"] == \"Molecule\"\n", " )\n", " only_one_molecule = (\n", - " only_one_molecule and len(input_details.details[\"all_molecules\"]) == 1\n", + " only_one_molecule and (len(input_details.details[\"all_molecules\"]) == 1 or len(awb.utils.string_range_to_list(molecule.value)[0]) > 0)\n", " )\n", " msg = \"GW for this system not implemented\"\n", " if only_one_molecule:\n", @@ -281,7 +292,8 @@ "\n", "\n", "structure_selector.observe(update_all, names=\"structure\")\n", - "uks.observe(update_all, names=\"value\")" + "uks.observe(update_all, names=\"value\")\n", + "molecule.observe(update_all, names=\"value\")" ] }, { @@ -315,12 +327,17 @@ "def extract_details_on_adsorbed_molecule(all_atoms):\n", " structure_analyzer = analyze_structure.StructureAnalyzer()\n", " structure_analyzer.structure = all_atoms\n", + " \n", + " molecule_indices = awb.utils.string_range_to_list(molecule.value)[0]\n", " if \"all_molecules\" in structure_analyzer.details:\n", - " molecules_indices = [\n", - " item\n", - " for sublist in structure_analyzer.details[\"all_molecules\"]\n", - " for item in sublist\n", - " ]\n", + " if len(molecule_indices) == 0:\n", + " molecules_indices = [\n", + " item\n", + " for sublist in structure_analyzer.details[\"all_molecules\"]\n", + " for item in sublist\n", + " ]\n", + " if len(molecule_indices) > 0:\n", + " molecule.value = awb.utils.list_to_string_range(molecules_indices)\n", " structure_analyzer.structure = all_atoms[molecules_indices]\n", " return structure_analyzer.details\n", " else:\n", @@ -372,6 +389,7 @@ "display(\n", " output,\n", " description,\n", + " molecule,\n", " ipw.HBox(\n", " [\n", " ipw.VBox(\n", From 5def7ee271ba7d071dc751e930cc45427f202f62 Mon Sep 17 00:00:00 2001 From: Carlo Antonio Pignedoli Date: Fri, 12 Jul 2024 12:08:05 +0000 Subject: [PATCH 2/6] bug fix --- submit_gw_ic.ipynb | 70 ++++++++++--------- .../widgets/search_structures_widget.py | 1 + 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/submit_gw_ic.ipynb b/submit_gw_ic.ipynb index c2f110b..d318ae1 100644 --- a/submit_gw_ic.ipynb +++ b/submit_gw_ic.ipynb @@ -67,8 +67,6 @@ " importers=[\n", " awb.StructureBrowserWidget(title=\"AiiDA database\"),\n", " awb.StructureUploadWidget(title=\"Import from computer\"),\n", - " awb.SmilesWidget(title=\"From SMILES\"),\n", - " cdxml.CdxmlUpload2GnrWidget(title=\"CDXML\"),\n", " ],\n", " storable=False,\n", " node_class=\"StructureData\",\n", @@ -145,6 +143,8 @@ " style={\"description_width\": \"initial\"},\n", ")\n", "\n", + "# error message\n", + "error_msg = ipw.HTML(value=\"\")\n", "\n", "# description adsorption height\n", "html_ads_height = ipw.HTML(\n", @@ -165,6 +165,7 @@ "source": [ "def get_builder_gw():\n", " builder = Cp2kAdsorbedGwIcWorkChain.get_builder()\n", + " builder.metadata.label = \"CP2K_GWIC\" \n", " builder.metadata.description = description.value\n", " builder.code = orm.load_code(resources.value)\n", " builder.geometry_mode = orm.Str(geo_mode.value)\n", @@ -191,6 +192,7 @@ " builder.protocol = orm.Str(gw_type.value)\n", "\n", " builder.geometry_mode = orm.Str(geo_mode.value)\n", + " builder.molecule_atoms = orm.List(awb.utils.string_range_to_list(molecule.value)[0])\n", " builder.debug = orm.Bool(False)\n", "\n", " builder.options.scf = {\n", @@ -247,8 +249,28 @@ "source": [ "output = ipw.Output()\n", "\n", - "\n", - "def update_all(_=None):\n", + "def extract_details_on_adsorbed_molecule(all_atoms):\n", + " structure_analyzer = analyze_structure.StructureAnalyzer()\n", + " structure_analyzer.structure = all_atoms\n", + " molecule_indices = awb.utils.string_range_to_list(molecule.value)[0]\n", + " \n", + " if \"all_molecules\" in structure_analyzer.details:\n", + " if len(molecule_indices) == 0:\n", + " molecule_indices = [\n", + " item\n", + " for sublist in structure_analyzer.details[\"all_molecules\"]\n", + " for item in sublist\n", + " ]\n", + " \n", + " if len(molecule_indices) > 0:\n", + " molecule.value = awb.utils.list_to_string_range(molecule_indices)\n", + " structure_analyzer.structure = all_atoms[molecule_indices]\n", + " return structure_analyzer.details\n", + " else:\n", + " molecule.value=''\n", + " return {}\n", + " \n", + "def check_system(_=None):\n", " btn_submit_gw.btn_submit.disabled = False\n", " # check system\n", " only_one_molecule = input_details.details[\"system_type\"] == \"SlabXY\"\n", @@ -256,20 +278,24 @@ " only_one_molecule or input_details.details[\"system_type\"] == \"Molecule\"\n", " )\n", " only_one_molecule = (\n", - " only_one_molecule and (len(input_details.details[\"all_molecules\"]) == 1 or len(awb.utils.string_range_to_list(molecule.value)[0]) > 0)\n", - " )\n", - " msg = \"GW for this system not implemented\"\n", + " only_one_molecule and len(awb.utils.string_range_to_list(molecule.value)[0]) > 0)\n", + " error_msg.value = \"

Check the molecule indices

\"\n", " if only_one_molecule:\n", " btn_submit_gw.btn_submit.disabled = False\n", - " msg = \"\"\n", + " error_msg.value = \"\" \n", + "def update_all(name=None):\n", + " if name['name']== \"structure\":\n", + " molecule.value=\"\"\n", + " error_msg.value = \"\"\n", + " check_system()\n", + " if structure_selector.structure is not None:\n", + " extract_details_on_adsorbed_molecule(structure_selector.structure)\n", " spins_up.value = awb.utils.list_to_string_range(input_details.details[\"spins_up\"])\n", " spins_down.value = awb.utils.list_to_string_range(\n", " input_details.details[\"spins_down\"]\n", " )\n", " with output:\n", " clear_output()\n", - " print(msg)\n", - "\n", " if uks.value:\n", " to_display = [\n", " gw_type,\n", @@ -293,7 +319,7 @@ "\n", "structure_selector.observe(update_all, names=\"structure\")\n", "uks.observe(update_all, names=\"value\")\n", - "molecule.observe(update_all, names=\"value\")" + "molecule.observe(check_system, names=\"value\")" ] }, { @@ -323,27 +349,6 @@ "resources_estimation_gw.link_to_resources_widget(resources_gw)\n", "resources_estimation_ic.link_to_resources_widget(resources_ic)\n", "\n", - "\n", - "def extract_details_on_adsorbed_molecule(all_atoms):\n", - " structure_analyzer = analyze_structure.StructureAnalyzer()\n", - " structure_analyzer.structure = all_atoms\n", - " \n", - " molecule_indices = awb.utils.string_range_to_list(molecule.value)[0]\n", - " if \"all_molecules\" in structure_analyzer.details:\n", - " if len(molecule_indices) == 0:\n", - " molecules_indices = [\n", - " item\n", - " for sublist in structure_analyzer.details[\"all_molecules\"]\n", - " for item in sublist\n", - " ]\n", - " if len(molecule_indices) > 0:\n", - " molecule.value = awb.utils.list_to_string_range(molecules_indices)\n", - " structure_analyzer.structure = all_atoms[molecules_indices]\n", - " return structure_analyzer.details\n", - " else:\n", - " return {}\n", - "\n", - "\n", "# Link viewer to resources estimation widgets.\n", "ipw.dlink(\n", " (structure_selector, \"structure\"),\n", @@ -389,6 +394,7 @@ "display(\n", " output,\n", " description,\n", + " error_msg,\n", " molecule,\n", " ipw.HBox(\n", " [\n", diff --git a/surfaces_tools/widgets/search_structures_widget.py b/surfaces_tools/widgets/search_structures_widget.py index 2382b15..6660bae 100644 --- a/surfaces_tools/widgets/search_structures_widget.py +++ b/surfaces_tools/widgets/search_structures_widget.py @@ -19,6 +19,7 @@ "CP2K_NEB": "view_neb.ipynb", "CP2K_Replica": "view_replica.ipynb", "ReplicaWorkChain": "view_replica.ipynb", + "CP2K_GWIC": "view_gw_ic.ipynb", } From e4bc6af17d67f65a5fd00c893175a362220e143a Mon Sep 17 00:00:00 2001 From: Carlo Antonio Pignedoli Date: Thu, 18 Jul 2024 09:31:27 +0000 Subject: [PATCH 3/6] bug fix --- submit_gw_ic.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submit_gw_ic.ipynb b/submit_gw_ic.ipynb index d318ae1..2759dd5 100644 --- a/submit_gw_ic.ipynb +++ b/submit_gw_ic.ipynb @@ -181,7 +181,7 @@ " if uks.value:\n", " for i in awb.utils.string_range_to_list(spins_up.value)[0]:\n", " mag_list[i] = 1\n", - " for i in string_range_to_list(spins_down.value)[0]:\n", + " for i in awb.string_range_to_list(spins_down.value)[0]:\n", " mag_list[i] = -1\n", "\n", " builder.multiplicity = orm.Int(multiplicity.value)\n", From 8975e2a59066c469eec3c31a08c292369ad7f143 Mon Sep 17 00:00:00 2001 From: Carlo Antonio Pignedoli Date: Thu, 18 Jul 2024 09:33:55 +0000 Subject: [PATCH 4/6] bug fix --- submit_gw_ic.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submit_gw_ic.ipynb b/submit_gw_ic.ipynb index 2759dd5..2a440fc 100644 --- a/submit_gw_ic.ipynb +++ b/submit_gw_ic.ipynb @@ -181,7 +181,7 @@ " if uks.value:\n", " for i in awb.utils.string_range_to_list(spins_up.value)[0]:\n", " mag_list[i] = 1\n", - " for i in awb.string_range_to_list(spins_down.value)[0]:\n", + " for i in awb.utils.string_range_to_list(spins_down.value)[0]:\n", " mag_list[i] = -1\n", "\n", " builder.multiplicity = orm.Int(multiplicity.value)\n", From 0b44141c6f46c0afc7d3574875c4738a1a6ba453 Mon Sep 17 00:00:00 2001 From: Carlo Antonio Pignedoli Date: Thu, 21 Nov 2024 11:05:36 +0000 Subject: [PATCH 5/6] removed final bugs --- submit_gw_ic.ipynb | 91 +++++++++++++------------------- surfaces_tools/widgets/inputs.py | 16 +++++- 2 files changed, 51 insertions(+), 56 deletions(-) diff --git a/submit_gw_ic.ipynb b/submit_gw_ic.ipynb index 2a440fc..a7a9154 100644 --- a/submit_gw_ic.ipynb +++ b/submit_gw_ic.ipynb @@ -39,7 +39,6 @@ "# Custom imports.\n", "from surfaces_tools.widgets import (\n", " analyze_structure,\n", - " cdxml,\n", " computational_resources,\n", " inputs,\n", ")" @@ -76,7 +75,7 @@ "display(structure_selector)\n", "\n", "# Code.\n", - "resources = awb.ComputationalResourcesWidget(\n", + "code_input_widget = awb.ComputationalResourcesWidget(\n", " description=\"CP2K code:\", default_calc_job_plugin=\"cp2k\"\n", ")" ] @@ -96,19 +95,6 @@ ")\n", "\n", "\n", - "# Multiplicity\n", - "multiplicity = ipw.IntText(value=1, description=\"Multiplicity\", disabled=False)\n", - "# UKS\n", - "uks = ipw.Checkbox(value=False, description=\"UKS\", disabled=False, indent=False)\n", - "\n", - "# spin guess\n", - "spins_up = ipw.Text(\n", - " value=\"\", placeholder=\"1 2 10..13\", description=\"Spins U:\", disabled=False\n", - ")\n", - "\n", - "spins_down = ipw.Text(\n", - " value=\"\", placeholder=\"3 4 14..17\", description=\"Spins D:\", disabled=False\n", - ")\n", "\n", "# geometry mode\n", "geo_mode = ipw.Dropdown(\n", @@ -163,11 +149,25 @@ "metadata": {}, "outputs": [], "source": [ + "ipw.dlink((code_input_widget, \"value\"), (input_details, \"selected_code\"))\n", "def get_builder_gw():\n", + " with output:\n", + " clear_output()\n", + " if not structure_selector.structure_node:\n", + " can_submit, msg = False, \"Select a structure first.\"\n", + " elif not code_input_widget.value:\n", + " can_submit, msg = False, \"Select CP2K code.\"\n", + " else:\n", + " can_submit, msg, parameters = input_details.return_final_dictionary()\n", + "\n", + " if not can_submit:\n", + " with output:\n", + " print(msg)\n", + " return \n", " builder = Cp2kAdsorbedGwIcWorkChain.get_builder()\n", " builder.metadata.label = \"CP2K_GWIC\" \n", " builder.metadata.description = description.value\n", - " builder.code = orm.load_code(resources.value)\n", + " builder.code = orm.load_code(code_input_widget.value)\n", " builder.geometry_mode = orm.Str(geo_mode.value)\n", "\n", " # Override automatic adsorption height.\n", @@ -176,23 +176,16 @@ "\n", " ase_geom = structure_selector.structure\n", "\n", - " # Spin guess.\n", - " mag_list = [0 for t in ase_geom]\n", - " if uks.value:\n", - " for i in awb.utils.string_range_to_list(spins_up.value)[0]:\n", - " mag_list[i] = 1\n", - " for i in awb.utils.string_range_to_list(spins_down.value)[0]:\n", - " mag_list[i] = -1\n", "\n", - " builder.multiplicity = orm.Int(multiplicity.value)\n", "\n", " builder.structure = structure_selector.structure_node\n", - " builder.magnetization_per_site = orm.List(list=mag_list)\n", - "\n", + " #builder.magnetization_per_site = orm.List(list=mag_list)\n", + " builder.dft_params = orm.Dict(parameters[\"dft_params\"])\n", + " builder.sys_params = orm.Dict({'molecule_atoms':awb.utils.string_range_to_list(molecule.value)[0]})\n", " builder.protocol = orm.Str(gw_type.value)\n", "\n", " builder.geometry_mode = orm.Str(geo_mode.value)\n", - " builder.molecule_atoms = orm.List(awb.utils.string_range_to_list(molecule.value)[0])\n", + " #builder.molecule_atoms = orm.List(awb.utils.string_range_to_list(molecule.value)[0])\n", " builder.debug = orm.Bool(False)\n", "\n", " builder.options.scf = {\n", @@ -284,41 +277,27 @@ " btn_submit_gw.btn_submit.disabled = False\n", " error_msg.value = \"\" \n", "def update_all(name=None):\n", + " \n", " if name['name']== \"structure\":\n", + " input_details.gwic = True\n", " molecule.value=\"\"\n", " error_msg.value = \"\"\n", " check_system()\n", " if structure_selector.structure is not None:\n", " extract_details_on_adsorbed_molecule(structure_selector.structure)\n", - " spins_up.value = awb.utils.list_to_string_range(input_details.details[\"spins_up\"])\n", - " spins_down.value = awb.utils.list_to_string_range(\n", - " input_details.details[\"spins_down\"]\n", - " )\n", " with output:\n", " clear_output()\n", - " if uks.value:\n", - " to_display = [\n", - " gw_type,\n", - " geo_mode,\n", - " ipw.HBox([ads_height, html_ads_height]),\n", - " uks,\n", - " spins_up,\n", - " spins_down,\n", - " multiplicity,\n", - " description,\n", - " ]\n", - " else:\n", - " to_display = [\n", + " to_display = [\n", " gw_type,\n", " geo_mode,\n", " ipw.HBox([ads_height, html_ads_height]),\n", - " uks,\n", + " molecule,\n", + " input_details\n", " ]\n", " display(ipw.VBox(to_display))\n", "\n", "\n", "structure_selector.observe(update_all, names=\"structure\")\n", - "uks.observe(update_all, names=\"value\")\n", "molecule.observe(check_system, names=\"value\")" ] }, @@ -367,14 +346,19 @@ ")\n", "\n", "# Link code selector to resources estimation widgets.\n", - "_ = ipw.dlink((resources, \"value\"), (resources_estimation_scf, \"selected_code\"))\n", - "_ = ipw.dlink((resources, \"value\"), (resources_estimation_gw, \"selected_code\"))\n", - "_ = ipw.dlink((resources, \"value\"), (resources_estimation_ic, \"selected_code\"))\n", + "_ = ipw.dlink((code_input_widget, \"value\"), (resources_estimation_scf, \"selected_code\"))\n", + "_ = ipw.dlink((code_input_widget, \"value\"), (resources_estimation_gw, \"selected_code\"))\n", + "_ = ipw.dlink((code_input_widget, \"value\"), (resources_estimation_ic, \"selected_code\"))\n", "\n", "# Link UKS\n", - "_ = ipw.dlink((uks, \"value\"), (resources_estimation_scf, \"uks\"))\n", - "_ = ipw.dlink((uks, \"value\"), (resources_estimation_gw, \"uks\"))\n", - "_ = ipw.dlink((uks, \"value\"), (resources_estimation_ic, \"uks\"))\n", + "_ = ipw.dlink((input_details, \"uks\"), (resources_estimation_scf, \"uks\"))\n", + "_ = ipw.dlink((input_details, \"uks\"), (resources_estimation_gw, \"uks\"))\n", + "_ = ipw.dlink((input_details, \"uks\"), (resources_estimation_ic, \"uks\"))\n", + "\n", + "# Link details\n", + "_ = ipw.dlink((input_details, \"details\"), (resources_estimation_scf,\"details\"))\n", + "_ = ipw.dlink((input_details, \"details\"), (resources_estimation_gw, \"details\"))\n", + "_ = ipw.dlink((input_details, \"details\"), (resources_estimation_ic, \"details\"))\n", "\n", "# Estimate all resources\n", "estimate_nodes_button = ipw.Button(\n", @@ -395,7 +379,6 @@ " output,\n", " description,\n", " error_msg,\n", - " molecule,\n", " ipw.HBox(\n", " [\n", " ipw.VBox(\n", @@ -419,7 +402,7 @@ " ]\n", " ),\n", " estimate_nodes_button,\n", - " resources,\n", + " code_input_widget,\n", " btn_submit_gw,\n", ")" ] diff --git a/surfaces_tools/widgets/inputs.py b/surfaces_tools/widgets/inputs.py index c43e38d..d6b6df6 100644 --- a/surfaces_tools/widgets/inputs.py +++ b/surfaces_tools/widgets/inputs.py @@ -30,7 +30,8 @@ class InputDetails(ipw.VBox): do_cell_opt = tr.Bool() uks = tr.Bool() net_charge = tr.Int() - neb = tr.Bool() # Set by app in case of neb calculation, to be linked to resources. + gwic = tr.Bool() + neb = tr.Bool() # Set by app in case of neb calculation, to be linked to resources. replica = tr.Bool() # Set by app in case of replica chain calculation. phonons = tr.Bool() # Set by app in case of phonons calculation n_replica_trait = ( @@ -66,6 +67,10 @@ def __init__( @tr.default("neb") def _default_neb(self): return False + + @tr.default("gwic") + def _default_gwic(self): + return False @tr.default("phonons") def _default_phonons(self): @@ -81,7 +86,7 @@ def _default_n_proc_replica(self): def _default_n_replica_per_group_trait(self): return 1 - @tr.observe("details", "neb", "replica", "phonons") + @tr.observe("details","gwic", "neb", "replica", "phonons") def _observe_details(self, _=None): self.to_fix = [] self.net_charge = 0 @@ -97,6 +102,8 @@ def _observe_details(self, _=None): sys_type = "Replica" if self.phonons: sys_type = "Phonons" + if self.gwic: + sys_type = "GwIc" else: sys_type = "None" @@ -768,4 +775,9 @@ def smearing_enabled(self): constraints.ConstraintsWidget, PhononsWidget, ], + "GwIc": [ + StructureInfoWidget, + VdwSelectorWidget, + UksSectionWidget, + ], } From 009d4d847c590ca6c7ece7bd3365e110a0429f4a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 11:08:30 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- submit_gw_ic.ipynb | 64 +++++++++++++++++--------------- surfaces_tools/widgets/inputs.py | 6 +-- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/submit_gw_ic.ipynb b/submit_gw_ic.ipynb index a7a9154..3e962b3 100644 --- a/submit_gw_ic.ipynb +++ b/submit_gw_ic.ipynb @@ -37,11 +37,7 @@ "from aiida import orm, plugins\n", "\n", "# Custom imports.\n", - "from surfaces_tools.widgets import (\n", - " analyze_structure,\n", - " computational_resources,\n", - " inputs,\n", - ")" + "from surfaces_tools.widgets import analyze_structure, computational_resources, inputs" ] }, { @@ -95,7 +91,6 @@ ")\n", "\n", "\n", - "\n", "# geometry mode\n", "geo_mode = ipw.Dropdown(\n", " options=[\"ads_geo\", \"gas_opt\"],\n", @@ -150,6 +145,8 @@ "outputs": [], "source": [ "ipw.dlink((code_input_widget, \"value\"), (input_details, \"selected_code\"))\n", + "\n", + "\n", "def get_builder_gw():\n", " with output:\n", " clear_output()\n", @@ -163,9 +160,9 @@ " if not can_submit:\n", " with output:\n", " print(msg)\n", - " return \n", + " return\n", " builder = Cp2kAdsorbedGwIcWorkChain.get_builder()\n", - " builder.metadata.label = \"CP2K_GWIC\" \n", + " builder.metadata.label = \"CP2K_GWIC\"\n", " builder.metadata.description = description.value\n", " builder.code = orm.load_code(code_input_widget.value)\n", " builder.geometry_mode = orm.Str(geo_mode.value)\n", @@ -176,16 +173,16 @@ "\n", " ase_geom = structure_selector.structure\n", "\n", - "\n", - "\n", " builder.structure = structure_selector.structure_node\n", - " #builder.magnetization_per_site = orm.List(list=mag_list)\n", + " # builder.magnetization_per_site = orm.List(list=mag_list)\n", " builder.dft_params = orm.Dict(parameters[\"dft_params\"])\n", - " builder.sys_params = orm.Dict({'molecule_atoms':awb.utils.string_range_to_list(molecule.value)[0]})\n", + " builder.sys_params = orm.Dict(\n", + " {\"molecule_atoms\": awb.utils.string_range_to_list(molecule.value)[0]}\n", + " )\n", " builder.protocol = orm.Str(gw_type.value)\n", "\n", " builder.geometry_mode = orm.Str(geo_mode.value)\n", - " #builder.molecule_atoms = orm.List(awb.utils.string_range_to_list(molecule.value)[0])\n", + " # builder.molecule_atoms = orm.List(awb.utils.string_range_to_list(molecule.value)[0])\n", " builder.debug = orm.Bool(False)\n", "\n", " builder.options.scf = {\n", @@ -242,11 +239,12 @@ "source": [ "output = ipw.Output()\n", "\n", + "\n", "def extract_details_on_adsorbed_molecule(all_atoms):\n", " structure_analyzer = analyze_structure.StructureAnalyzer()\n", " structure_analyzer.structure = all_atoms\n", " molecule_indices = awb.utils.string_range_to_list(molecule.value)[0]\n", - " \n", + "\n", " if \"all_molecules\" in structure_analyzer.details:\n", " if len(molecule_indices) == 0:\n", " molecule_indices = [\n", @@ -254,15 +252,16 @@ " for sublist in structure_analyzer.details[\"all_molecules\"]\n", " for item in sublist\n", " ]\n", - " \n", + "\n", " if len(molecule_indices) > 0:\n", " molecule.value = awb.utils.list_to_string_range(molecule_indices)\n", " structure_analyzer.structure = all_atoms[molecule_indices]\n", " return structure_analyzer.details\n", " else:\n", - " molecule.value=''\n", + " molecule.value = \"\"\n", " return {}\n", - " \n", + "\n", + "\n", "def check_system(_=None):\n", " btn_submit_gw.btn_submit.disabled = False\n", " # check system\n", @@ -271,16 +270,21 @@ " only_one_molecule or input_details.details[\"system_type\"] == \"Molecule\"\n", " )\n", " only_one_molecule = (\n", - " only_one_molecule and len(awb.utils.string_range_to_list(molecule.value)[0]) > 0)\n", - " error_msg.value = \"

Check the molecule indices

\"\n", + " only_one_molecule and len(awb.utils.string_range_to_list(molecule.value)[0]) > 0\n", + " )\n", + " error_msg.value = (\n", + " \"

Check the molecule indices

\"\n", + " )\n", " if only_one_molecule:\n", " btn_submit_gw.btn_submit.disabled = False\n", - " error_msg.value = \"\" \n", + " error_msg.value = \"\"\n", + "\n", + "\n", "def update_all(name=None):\n", - " \n", - " if name['name']== \"structure\":\n", + "\n", + " if name[\"name\"] == \"structure\":\n", " input_details.gwic = True\n", - " molecule.value=\"\"\n", + " molecule.value = \"\"\n", " error_msg.value = \"\"\n", " check_system()\n", " if structure_selector.structure is not None:\n", @@ -288,12 +292,12 @@ " with output:\n", " clear_output()\n", " to_display = [\n", - " gw_type,\n", - " geo_mode,\n", - " ipw.HBox([ads_height, html_ads_height]),\n", - " molecule,\n", - " input_details\n", - " ]\n", + " gw_type,\n", + " geo_mode,\n", + " ipw.HBox([ads_height, html_ads_height]),\n", + " molecule,\n", + " input_details,\n", + " ]\n", " display(ipw.VBox(to_display))\n", "\n", "\n", @@ -356,7 +360,7 @@ "_ = ipw.dlink((input_details, \"uks\"), (resources_estimation_ic, \"uks\"))\n", "\n", "# Link details\n", - "_ = ipw.dlink((input_details, \"details\"), (resources_estimation_scf,\"details\"))\n", + "_ = ipw.dlink((input_details, \"details\"), (resources_estimation_scf, \"details\"))\n", "_ = ipw.dlink((input_details, \"details\"), (resources_estimation_gw, \"details\"))\n", "_ = ipw.dlink((input_details, \"details\"), (resources_estimation_ic, \"details\"))\n", "\n", diff --git a/surfaces_tools/widgets/inputs.py b/surfaces_tools/widgets/inputs.py index d6b6df6..c348efc 100644 --- a/surfaces_tools/widgets/inputs.py +++ b/surfaces_tools/widgets/inputs.py @@ -31,7 +31,7 @@ class InputDetails(ipw.VBox): uks = tr.Bool() net_charge = tr.Int() gwic = tr.Bool() - neb = tr.Bool() # Set by app in case of neb calculation, to be linked to resources. + neb = tr.Bool() # Set by app in case of neb calculation, to be linked to resources. replica = tr.Bool() # Set by app in case of replica chain calculation. phonons = tr.Bool() # Set by app in case of phonons calculation n_replica_trait = ( @@ -67,7 +67,7 @@ def __init__( @tr.default("neb") def _default_neb(self): return False - + @tr.default("gwic") def _default_gwic(self): return False @@ -86,7 +86,7 @@ def _default_n_proc_replica(self): def _default_n_replica_per_group_trait(self): return 1 - @tr.observe("details","gwic", "neb", "replica", "phonons") + @tr.observe("details", "gwic", "neb", "replica", "phonons") def _observe_details(self, _=None): self.to_fix = [] self.net_charge = 0