|
58 | 58 | { |
59 | 59 | "cell_type": "code", |
60 | 60 | "execution_count": null, |
61 | | - "id": "0360e52f", |
| 61 | + "id": "a89ba5dd", |
62 | 62 | "metadata": {}, |
63 | 63 | "outputs": [], |
64 | 64 | "source": [ |
65 | 65 | "from aiida.orm import StructureData\n", |
66 | 66 | "from ase.build import bulk\n", |
67 | | - "from ase.io import read\n", |
| 67 | + "from ase.io import read, iread\n", |
68 | 68 | "\n", |
69 | 69 | "# 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))" |
71 | 71 | ] |
72 | 72 | }, |
73 | 73 | { |
|
81 | 81 | "janus_code = load_code(\"janus@localhost\")" |
82 | 82 | ] |
83 | 83 | }, |
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 | | - }, |
95 | 84 | { |
96 | 85 | "cell_type": "code", |
97 | 86 | "execution_count": null, |
|
107 | 96 | " \"device\": Str(\"cpu\"),\n", |
108 | 97 | " \"metadata\": {\"options\": {\"resources\": {\"num_machines\": 1}}},\n", |
109 | 98 | " \"ensemble\": Str(\"NVT\"),\n", |
110 | | - " \"struct\": structure,\n", |
| 99 | + " \"struct\": init_structure,\n", |
111 | 100 | " \"md_kwargs\": Dict(\n", |
112 | 101 | " {\n", |
113 | | - " \"steps\": 400,\n", |
| 102 | + " \"steps\": 10,\n", |
| 103 | + " \"traj-every\": 2\n", |
114 | 104 | " }\n", |
115 | 105 | " )\n", |
116 | 106 | "}" |
117 | 107 | ] |
118 | 108 | }, |
119 | | - { |
120 | | - "cell_type": "markdown", |
121 | | - "id": "1d661593", |
122 | | - "metadata": {}, |
123 | | - "source": [ |
124 | | - "We now load the calculations we want to run:" |
125 | | - ] |
126 | | - }, |
127 | 109 | { |
128 | 110 | "cell_type": "code", |
129 | 111 | "execution_count": null, |
|
139 | 121 | }, |
140 | 122 | { |
141 | 123 | "cell_type": "markdown", |
142 | | - "id": "37df1f81", |
| 124 | + "id": "0de6dd59", |
143 | 125 | "metadata": {}, |
144 | 126 | "source": [ |
145 | | - "Now we can create our WorkGraph. " |
| 127 | + "# Single Descriptor" |
146 | 128 | ] |
147 | 129 | }, |
148 | 130 | { |
|
161 | 143 | ")\n" |
162 | 144 | ] |
163 | 145 | }, |
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 | | - }, |
172 | 146 | { |
173 | 147 | "cell_type": "code", |
174 | 148 | "execution_count": null, |
175 | 149 | "id": "62f8322b", |
176 | 150 | "metadata": {}, |
177 | 151 | "outputs": [], |
178 | 152 | "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()" |
188 | 155 | ] |
189 | 156 | }, |
190 | 157 | { |
|
197 | 164 | "descriptors_calc = wg.add_task(\n", |
198 | 165 | " descriptorsCalc,\n", |
199 | 166 | " name=\"descriptors_calc\",\n", |
200 | | - " struct=md_calc.outputs.traj_output\n", |
| 167 | + " struct=md_calc.outputs.final_structure,\n", |
201 | 168 | ")" |
202 | 169 | ] |
203 | 170 | }, |
204 | | - { |
205 | | - "cell_type": "markdown", |
206 | | - "id": "5dd1426a", |
207 | | - "metadata": {}, |
208 | | - "source": [ |
209 | | - "Pass to process_and_split_data " |
210 | | - ] |
211 | | - }, |
212 | 171 | { |
213 | 172 | "cell_type": "code", |
214 | 173 | "execution_count": null, |
|
225 | 184 | ")\n" |
226 | 185 | ] |
227 | 186 | }, |
228 | | - { |
229 | | - "cell_type": "markdown", |
230 | | - "id": "2bba0462", |
231 | | - "metadata": {}, |
232 | | - "source": [ |
233 | | - "Visualise the workgraph" |
234 | | - ] |
235 | | - }, |
236 | 187 | { |
237 | 188 | "cell_type": "code", |
238 | 189 | "execution_count": null, |
|
244 | 195 | ] |
245 | 196 | }, |
246 | 197 | { |
247 | | - "cell_type": "markdown", |
248 | | - "id": "c8b7a99b", |
| 198 | + "cell_type": "code", |
| 199 | + "execution_count": null, |
| 200 | + "id": "85f26ee7", |
249 | 201 | "metadata": {}, |
| 202 | + "outputs": [], |
250 | 203 | "source": [ |
251 | | - "We can visual the tasks of the Workgraph and run the tasks" |
| 204 | + "wg.tasks" |
252 | 205 | ] |
253 | 206 | }, |
254 | 207 | { |
255 | 208 | "cell_type": "code", |
256 | 209 | "execution_count": null, |
257 | | - "id": "85f26ee7", |
| 210 | + "id": "57e26db5", |
258 | 211 | "metadata": {}, |
259 | 212 | "outputs": [], |
260 | 213 | "source": [ |
261 | | - "wg.tasks" |
| 214 | + "# wg.run()" |
| 215 | + ] |
| 216 | + }, |
| 217 | + { |
| 218 | + "cell_type": "markdown", |
| 219 | + "id": "abf1c398", |
| 220 | + "metadata": {}, |
| 221 | + "source": [ |
| 222 | + "# Loop Descriptor" |
262 | 223 | ] |
263 | 224 | }, |
264 | 225 | { |
265 | 226 | "cell_type": "code", |
266 | 227 | "execution_count": null, |
267 | | - "id": "66c58962", |
| 228 | + "id": "27bfe04a", |
268 | 229 | "metadata": {}, |
269 | 230 | "outputs": [], |
270 | 231 | "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()" |
272 | 258 | ] |
273 | 259 | }, |
274 | 260 | { |
275 | 261 | "cell_type": "code", |
276 | 262 | "execution_count": null, |
277 | | - "id": "57e26db5", |
| 263 | + "id": "c3069b29", |
278 | 264 | "metadata": {}, |
279 | 265 | "outputs": [], |
280 | 266 | "source": [ |
281 | | - "# wg.run()" |
| 267 | + "wg" |
282 | 268 | ] |
283 | 269 | }, |
284 | 270 | { |
285 | 271 | "cell_type": "markdown", |
286 | | - "id": "26736d8d", |
| 272 | + "id": "4b8e7371", |
| 273 | + "metadata": {}, |
| 274 | + "source": [] |
| 275 | + }, |
| 276 | + { |
| 277 | + "cell_type": "markdown", |
| 278 | + "id": "4fe8d0a7", |
287 | 279 | "metadata": {}, |
288 | 280 | "source": [] |
289 | 281 | } |
|
0 commit comments