Skip to content

Commit 90005b5

Browse files
author
Jessie
committed
removal of excess trial and error
1 parent fab5642 commit 90005b5

File tree

2 files changed

+65
-73
lines changed

2 files changed

+65
-73
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# pre-commit install
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.5.0
5+
rev: v6.0.0
66
hooks:
77
- id: end-of-file-fixer
88
- id: mixed-line-ending
@@ -11,7 +11,7 @@ repos:
1111

1212
- repo: https://github.com/astral-sh/ruff-pre-commit
1313
# Ruff version.
14-
rev: v0.9.2
14+
rev: v0.14.3
1515
hooks:
1616
# Run the linter.
1717
- id: ruff
@@ -20,7 +20,7 @@ repos:
2020
- id: ruff-format
2121

2222
- repo: https://github.com/numpy/numpydoc
23-
rev: v1.6.0
23+
rev: v1.9.0
2424
hooks:
2525
- id: numpydoc-validation
2626
files: ^aiida_mlip/

examples/tutorials/workgraphs/md_workgraph.ipynb

Lines changed: 62 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@
5858
{
5959
"cell_type": "code",
6060
"execution_count": null,
61-
"id": "0360e52f",
61+
"id": "a89ba5dd",
6262
"metadata": {},
6363
"outputs": [],
6464
"source": [
6565
"from aiida.orm import StructureData\n",
6666
"from ase.build import bulk\n",
67-
"from ase.io import read\n",
67+
"from ase.io import read, iread\n",
6868
"\n",
6969
"# structure = StructureData(ase=read(\"Structures/qmof-ffeef76.cif\"))\n",
70-
"structure = StructureData(ase=bulk(\"NaCl\", \"rocksalt\", 5.63))"
70+
"init_structure = StructureData(ase=bulk(\"NaCl\", \"rocksalt\", 5.63))"
7171
]
7272
},
7373
{
@@ -81,17 +81,6 @@
8181
"janus_code = load_code(\"janus@localhost\")"
8282
]
8383
},
84-
{
85-
"cell_type": "markdown",
86-
"id": "65fbe939",
87-
"metadata": {},
88-
"source": [
89-
"Inputs should include the model, code, metadata, and any other keyword arguments expected by the calculation we are running: \n",
90-
"\n",
91-
"to find out try using \"janus md --help\" which reveals that the arch, struct and ensemble is required, for which we shall use NVT. \n",
92-
"The traj output is recorded every 100 steps, which is nested in md_kwargs Dict."
93-
]
94-
},
9584
{
9685
"cell_type": "code",
9786
"execution_count": null,
@@ -107,23 +96,16 @@
10796
" \"device\": Str(\"cpu\"),\n",
10897
" \"metadata\": {\"options\": {\"resources\": {\"num_machines\": 1}}},\n",
10998
" \"ensemble\": Str(\"NVT\"),\n",
110-
" \"struct\": structure,\n",
99+
" \"struct\": init_structure,\n",
111100
" \"md_kwargs\": Dict(\n",
112101
" {\n",
113-
" \"steps\": 400,\n",
102+
" \"steps\": 10,\n",
103+
" \"traj-every\": 2\n",
114104
" }\n",
115105
" )\n",
116106
"}"
117107
]
118108
},
119-
{
120-
"cell_type": "markdown",
121-
"id": "1d661593",
122-
"metadata": {},
123-
"source": [
124-
"We now load the calculations we want to run:"
125-
]
126-
},
127109
{
128110
"cell_type": "code",
129111
"execution_count": null,
@@ -139,10 +121,10 @@
139121
},
140122
{
141123
"cell_type": "markdown",
142-
"id": "37df1f81",
124+
"id": "0de6dd59",
143125
"metadata": {},
144126
"source": [
145-
"Now we can create our WorkGraph. "
127+
"# Single Descriptor"
146128
]
147129
},
148130
{
@@ -161,30 +143,15 @@
161143
")\n"
162144
]
163145
},
164-
{
165-
"cell_type": "markdown",
166-
"id": "18362513",
167-
"metadata": {},
168-
"source": [
169-
"To know the inputs or outputs from the mdcalc, try using:"
170-
]
171-
},
172146
{
173147
"cell_type": "code",
174148
"execution_count": null,
175149
"id": "62f8322b",
176150
"metadata": {},
177151
"outputs": [],
178152
"source": [
179-
"mdCalc.get_description()[\"spec\"][\"outputs\"].keys()"
180-
]
181-
},
182-
{
183-
"cell_type": "markdown",
184-
"id": "d4789f77",
185-
"metadata": {},
186-
"source": [
187-
"Now run the descriptors calc"
153+
"# To find inputs/outputs of mdcalc uncomment following: \n",
154+
"# mdCalc.get_description()[\"spec\"][\"outputs\"].keys()"
188155
]
189156
},
190157
{
@@ -197,18 +164,10 @@
197164
"descriptors_calc = wg.add_task(\n",
198165
" descriptorsCalc,\n",
199166
" name=\"descriptors_calc\",\n",
200-
" struct=md_calc.outputs.traj_output\n",
167+
" struct=md_calc.outputs.final_structure,\n",
201168
")"
202169
]
203170
},
204-
{
205-
"cell_type": "markdown",
206-
"id": "5dd1426a",
207-
"metadata": {},
208-
"source": [
209-
"Pass to process_and_split_data "
210-
]
211-
},
212171
{
213172
"cell_type": "code",
214173
"execution_count": null,
@@ -225,14 +184,6 @@
225184
")\n"
226185
]
227186
},
228-
{
229-
"cell_type": "markdown",
230-
"id": "2bba0462",
231-
"metadata": {},
232-
"source": [
233-
"Visualise the workgraph"
234-
]
235-
},
236187
{
237188
"cell_type": "code",
238189
"execution_count": null,
@@ -244,46 +195,87 @@
244195
]
245196
},
246197
{
247-
"cell_type": "markdown",
248-
"id": "c8b7a99b",
198+
"cell_type": "code",
199+
"execution_count": null,
200+
"id": "85f26ee7",
249201
"metadata": {},
202+
"outputs": [],
250203
"source": [
251-
"We can visual the tasks of the Workgraph and run the tasks"
204+
"wg.tasks"
252205
]
253206
},
254207
{
255208
"cell_type": "code",
256209
"execution_count": null,
257-
"id": "85f26ee7",
210+
"id": "57e26db5",
258211
"metadata": {},
259212
"outputs": [],
260213
"source": [
261-
"wg.tasks"
214+
"# wg.run()"
215+
]
216+
},
217+
{
218+
"cell_type": "markdown",
219+
"id": "abf1c398",
220+
"metadata": {},
221+
"source": [
222+
"# Loop Descriptor"
262223
]
263224
},
264225
{
265226
"cell_type": "code",
266227
"execution_count": null,
267-
"id": "66c58962",
228+
"id": "27bfe04a",
268229
"metadata": {},
269230
"outputs": [],
270231
"source": [
271-
"wg.tasks[\"descriptors_calc\"].outputs"
232+
"from aiida_workgraph import WorkGraph\n",
233+
"\n",
234+
"with WorkGraph(\"MD_Simple\") as wg:\n",
235+
" \n",
236+
" # MD simulation\n",
237+
" md_task = wg.add_task(\n",
238+
" mdCalc,\n",
239+
" name=\"md\",\n",
240+
" **inputs\n",
241+
" )\n",
242+
" \n",
243+
" \n",
244+
" # Descriptors on final structure\n",
245+
" desc_task = wg.add_task(\n",
246+
" descriptorsCalc,\n",
247+
" name=\"descriptors\",\n",
248+
" code=inputs['code'],\n",
249+
" model=inputs['model'],\n",
250+
" arch=inputs['arch'],\n",
251+
" device=inputs['device'],\n",
252+
" metadata=inputs['metadata'],\n",
253+
" calc_per_element=Bool(True),\n",
254+
" struct=md_task.outputs.final_structure\n",
255+
" )\n",
256+
"\n",
257+
"wg.run()"
272258
]
273259
},
274260
{
275261
"cell_type": "code",
276262
"execution_count": null,
277-
"id": "57e26db5",
263+
"id": "c3069b29",
278264
"metadata": {},
279265
"outputs": [],
280266
"source": [
281-
"# wg.run()"
267+
"wg"
282268
]
283269
},
284270
{
285271
"cell_type": "markdown",
286-
"id": "26736d8d",
272+
"id": "4b8e7371",
273+
"metadata": {},
274+
"source": []
275+
},
276+
{
277+
"cell_type": "markdown",
278+
"id": "4fe8d0a7",
287279
"metadata": {},
288280
"source": []
289281
}

0 commit comments

Comments
 (0)