Skip to content

Commit f97294e

Browse files
authored
Use dict keys as strings (#13)
* Use dict keys as strings * bug fix * another fix
1 parent b92f4df commit f97294e

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

jobflow_to_pyiron_base_qe.ipynb

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,12 @@
8484
{
8585
"id": "07598344-0f75-433b-8902-bea21a42088c",
8686
"cell_type": "code",
87-
"source": "calculate_qe = job(_calculate_qe, data=[\"energy\", \"volume\", \"structure\"])\ngenerate_structures = job(_generate_structures, data=[\"i\" for i in range(100)])\nplot_energy_volume_curve = job(_plot_energy_volume_curve)\nget_bulk_structure = job(_get_bulk_structure)",
87+
"source": [
88+
"calculate_qe = job(_calculate_qe, data=[\"energy\", \"volume\", \"structure\"])\n",
89+
"generate_structures = job(_generate_structures, data=[f\"s_{i}\" for i in range(100)])\n",
90+
"plot_energy_volume_curve = job(_plot_energy_volume_curve)\n",
91+
"get_bulk_structure = job(_get_bulk_structure)"
92+
],
8893
"metadata": {
8994
"trusted": true
9095
},
@@ -140,7 +145,21 @@
140145
{
141146
"id": "53e979ac-21db-4aa5-ae58-7cfc08dfa87b",
142147
"cell_type": "code",
143-
"source": "job_strain_lst = []\nfor i in range(number_of_strains):\n calc_strain = calculate_qe(\n working_directory=\"strain_\" + str(i),\n input_dict={\n \"structure\": getattr(structure_lst.output, str(i)),\n \"pseudopotentials\": pseudopotentials,\n \"kpts\": (3, 3, 3),\n \"calculation\": \"scf\",\n \"smearing\": 0.02,\n },\n )\n job_strain_lst.append(calc_strain)",
148+
"source": [
149+
"job_strain_lst = []\n",
150+
"for i in range(number_of_strains):\n",
151+
" calc_strain = calculate_qe(\n",
152+
" working_directory=\"strain_\" + str(i),\n",
153+
" input_dict={\n",
154+
" \"structure\": getattr(structure_lst.output, f\"s_{i}\"),\n",
155+
" \"pseudopotentials\": pseudopotentials,\n",
156+
" \"kpts\": (3, 3, 3),\n",
157+
" \"calculation\": \"scf\",\n",
158+
" \"smearing\": 0.02,\n",
159+
" },\n",
160+
" )\n",
161+
" job_strain_lst.append(calc_strain)"
162+
],
144163
"metadata": {
145164
"trusted": true
146165
},

quantum_espresso_workflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def generate_structures(structure, strain_lst):
5858
structure_strain.cell * strain ** (1 / 3), scale_atoms=True
5959
)
6060
structure_lst.append(structure_strain)
61-
return {str(i): atoms_to_json_dict(atoms=s) for i, s in enumerate(structure_lst)}
61+
return {f"s_{i}": atoms_to_json_dict(atoms=s) for i, s in enumerate(structure_lst)}
6262

6363

6464
def plot_energy_volume_curve(volume_lst, energy_lst):
@@ -110,4 +110,4 @@ def atoms_to_json_dict(atoms):
110110
else:
111111
json_dict[key] = value
112112

113-
return json_dict
113+
return json_dict

workflow_qe.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,35 +47,35 @@
4747
{"target": 2, "targetHandle": "structure", "source": 1, "sourceHandle": "structure"},
4848
{"target": 2, "targetHandle": "strain_lst", "source": 18, "sourceHandle": null},
4949
{"target": 3, "targetHandle": "working_directory", "source": 19, "sourceHandle": null},
50-
{"target": 20, "targetHandle": "structure", "source": 2, "sourceHandle": "0"},
50+
{"target": 20, "targetHandle": "structure", "source": 2, "sourceHandle": "s_0"},
5151
{"target": 20, "targetHandle": "pseudopotentials", "source": 14, "sourceHandle": null},
5252
{"target": 20, "targetHandle": "kpts", "source": 15, "sourceHandle": null},
5353
{"target": 20, "targetHandle": "calculation", "source": 21, "sourceHandle": null},
5454
{"target": 20, "targetHandle": "smearing", "source": 17, "sourceHandle": null},
5555
{"target": 3, "targetHandle": "input_dict", "source": 20, "sourceHandle": null},
5656
{"target": 4, "targetHandle": "working_directory", "source": 22, "sourceHandle": null},
57-
{"target": 23, "targetHandle": "structure", "source": 2, "sourceHandle": "1"},
57+
{"target": 23, "targetHandle": "structure", "source": 2, "sourceHandle": "s_1"},
5858
{"target": 23, "targetHandle": "pseudopotentials", "source": 14, "sourceHandle": null},
5959
{"target": 23, "targetHandle": "kpts", "source": 15, "sourceHandle": null},
6060
{"target": 23, "targetHandle": "calculation", "source": 21, "sourceHandle": null},
6161
{"target": 23, "targetHandle": "smearing", "source": 17, "sourceHandle": null},
6262
{"target": 4, "targetHandle": "input_dict", "source": 23, "sourceHandle": null},
6363
{"target": 5, "targetHandle": "working_directory", "source": 24, "sourceHandle": null},
64-
{"target": 25, "targetHandle": "structure", "source": 2, "sourceHandle": "2"},
64+
{"target": 25, "targetHandle": "structure", "source": 2, "sourceHandle": "s_2"},
6565
{"target": 25, "targetHandle": "pseudopotentials", "source": 14, "sourceHandle": null},
6666
{"target": 25, "targetHandle": "kpts", "source": 15, "sourceHandle": null},
6767
{"target": 25, "targetHandle": "calculation", "source": 21, "sourceHandle": null},
6868
{"target": 25, "targetHandle": "smearing", "source": 17, "sourceHandle": null},
6969
{"target": 5, "targetHandle": "input_dict", "source": 25, "sourceHandle": null},
7070
{"target": 6, "targetHandle": "working_directory", "source": 26, "sourceHandle": null},
71-
{"target": 27, "targetHandle": "structure", "source": 2, "sourceHandle": "3"},
71+
{"target": 27, "targetHandle": "structure", "source": 2, "sourceHandle": "s_3"},
7272
{"target": 27, "targetHandle": "pseudopotentials", "source": 14, "sourceHandle": null},
7373
{"target": 27, "targetHandle": "kpts", "source": 15, "sourceHandle": null},
7474
{"target": 27, "targetHandle": "calculation", "source": 21, "sourceHandle": null},
7575
{"target": 27, "targetHandle": "smearing", "source": 17, "sourceHandle": null},
7676
{"target": 6, "targetHandle": "input_dict", "source": 27, "sourceHandle": null},
7777
{"target": 7, "targetHandle": "working_directory", "source": 28, "sourceHandle": null},
78-
{"target": 29, "targetHandle": "structure", "source": 2, "sourceHandle": "4"},
78+
{"target": 29, "targetHandle": "structure", "source": 2, "sourceHandle": "s_4"},
7979
{"target": 29, "targetHandle": "pseudopotentials", "source": 14, "sourceHandle": null},
8080
{"target": 29, "targetHandle": "kpts", "source": 15, "sourceHandle": null},
8181
{"target": 29, "targetHandle": "calculation", "source": 21, "sourceHandle": null},

0 commit comments

Comments
 (0)