Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
4139d34
changes
MM0hsin Jul 22, 2025
480cdef
Combine Geomopt and descriptors task into one workgraph
MM0hsin Jul 22, 2025
9439af6
Add sample_split.py and refactor to work with geometry.opti.ipynb
MM0hsin Jul 28, 2025
639b6b2
Rename descriptors_filter.ipynb
MM0hsin Jul 28, 2025
66d3f6e
Merge branch 'main' into add_geomopt_fine_tuning
MM0hsin Jul 28, 2025
500376e
changes
MM0hsin Jul 22, 2025
2f5ba0a
Combine Geomopt and descriptors task into one workgraph
MM0hsin Jul 22, 2025
e9f6489
Add sample_split.py and refactor to work with geometry.opti.ipynb
MM0hsin Jul 28, 2025
50ee7af
Rename descriptors_filter.ipynb
MM0hsin Jul 28, 2025
03a9fe1
Add descriptors_outputs to sample_split.py
MM0hsin Aug 4, 2025
0b9c336
Merge branch 'add_geomopt_fine_tuning' of https://github.com/MM0hsin/…
MM0hsin Aug 4, 2025
69d536e
Refactor descriptors_outputs in sample_spit.py
MM0hsin Aug 4, 2025
9ed07fb
Refactor process_and_split_data to accept singlefiledata outputs from…
MM0hsin Aug 5, 2025
0a45562
Refector descriptors_filter.ipynb workgraph
MM0hsin Aug 5, 2025
bb0b78e
Update sample_split.py to include WG function to run Geomopt and Desc…
MM0hsin Aug 12, 2025
278af75
Merge branch 'main' into add_geomopt_fine_tuning
MM0hsin Aug 12, 2025
408c111
Add descriptors_filter_qe.ipynb for QE calculations
MM0hsin Aug 20, 2025
5e893f8
Update descriptors_filter_qe.ipynb to QE task remotely
MM0hsin Sep 4, 2025
4a113c1
Minor tweak for QE task
MM0hsin Sep 4, 2025
7e68ff9
Add training task to descriptors_filter_qe.ipynb
MM0hsin Sep 8, 2025
85a3eaf
Merge branch 'main' into add_geomopt_fine_tuning
MM0hsin Sep 11, 2025
d77a5b7
Add tutorial for setting up an external computer (#214)
MM0hsin Sep 15, 2025
05e24dc
Update aiida-workgraph (#232)
ElliottKasoar Sep 16, 2025
061082d
Apply suggestions from code review
MM0hsin Sep 17, 2025
a94cfd0
Replace opt_kwargs with minimize_kwargs (#180)
MM0hsin Sep 16, 2025
cc510f0
Merge branch 'main' into add_geomopt_fine_tuning
MM0hsin Sep 17, 2025
e27dc23
Address PR comments
MM0hsin Sep 18, 2025
dd437f1
Refactor sample_split.py
MM0hsin Sep 24, 2025
95a94a7
Merge main
MM0hsin Sep 24, 2025
27cbc0f
Update workgraphs to work with new script
MM0hsin Sep 25, 2025
8fb3c92
Address PR comments
MM0hsin Oct 1, 2025
1d64033
Fix UV aiida-pseudo install fail
MM0hsin Oct 2, 2025
5442716
Address PR comments
MM0hsin Oct 20, 2025
cf53576
Address PR comments
MM0hsin Oct 23, 2025
00b6b1d
Address PR comment
MM0hsin Oct 23, 2025
0f1ab70
Remove unnessary notebook outputs
MM0hsin Oct 23, 2025
30b1719
Add aiida_qe optional dependancy
MM0hsin Oct 23, 2025
6b2939a
Add aiida_qe optional dependancy
MM0hsin Oct 23, 2025
c02f4d0
Address PR comments
MM0hsin Oct 23, 2025
355f8b3
Merge branch 'main' into add_geomopt_fine_tuning
MM0hsin Oct 23, 2025
ddfd655
Update examples/tutorials/workgraphs/descriptors_filter.ipynb
alinelena Oct 23, 2025
5919f92
Pushing QE workgraph changes for testing
MM0hsin Oct 24, 2025
374d449
Merge remote-tracking branch 'refs/remotes/upstream/add_geomopt_fine_…
MM0hsin Oct 24, 2025
13e0221
refactor qe workgraph with working inputs
MM0hsin Oct 24, 2025
3752dda
Address PR comments
MM0hsin Oct 27, 2025
887d647
Address wg bug
MM0hsin Oct 31, 2025
10a197d
Fix QE task inputs and address PR comments
MM0hsin Nov 3, 2025
adaea1f
Address PR comments
MM0hsin Nov 5, 2025
843a6fe
Address PR comments
MM0hsin Nov 6, 2025
912b27d
Fix markdown explanation
MM0hsin Nov 7, 2025
0bdcc98
Add link to notebook
MM0hsin Nov 7, 2025
4aea09d
Rename task [skip actions]
MM0hsin Nov 7, 2025
b01659a
Update examples/tutorials/workgraphs/descriptors_filter_qe.ipynb
alinelena Nov 11, 2025
a071a6b
Address PR comments
MM0hsin Nov 11, 2025
042842d
Merge remote-tracking branch 'refs/remotes/upstream/add_geomopt_fine_…
MM0hsin Nov 11, 2025
392850d
Merge branch 'main' into add_geomopt_fine_tuning
MM0hsin Nov 11, 2025
64d3147
Address PR comments
MM0hsin Nov 12, 2025
5f307e9
Address PR comments
MM0hsin Nov 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
395 changes: 395 additions & 0 deletions examples/tutorials/descriptors_filter.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,395 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "c13c1dd7",
"metadata": {},
"source": [
"# Running multiple calculations on a given model\n"
]
},
{
"cell_type": "markdown",
"id": "ca81fa1b",
"metadata": {},
"source": [
"## Aim"
]
},
{
"cell_type": "markdown",
"id": "35ecbb39",
"metadata": {},
"source": [
"This notebook shows how we can run multiple calculations of a given structure"
]
},
{
"cell_type": "markdown",
"id": "5acf0b46",
"metadata": {},
"source": [
"### Setup\n",
"\n",
"The initial setup is very similar to the other tutorials, such as `singlepoint.ipynb`, which goes into more detail about what each step is doing"
]
},
{
"cell_type": "markdown",
"id": "73bfb65e",
"metadata": {},
"source": [
"Load the aiida profile and code:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "79098139",
"metadata": {},
"outputs": [],
"source": [
"from aiida import load_profile\n",
"load_profile()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3bc2cf3b",
"metadata": {},
"outputs": [],
"source": [
"from aiida_mlip.data.model import ModelData\n",
"uri = \"https://github.com/stfc/janus-core/raw/main/tests/models/mace_mp_small.model\"\n",
"model = ModelData.from_uri(uri, architecture=\"mace_mp\", cache_dir=\"mlips\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ae62816f",
"metadata": {},
"outputs": [],
"source": [
"from aiida.orm import load_code\n",
"code = load_code(\"janus@localhost\")"
]
},
{
"cell_type": "markdown",
"id": "65fbe939",
"metadata": {},
"source": [
"Inputs should include the model, code, metadata, and any other keyword arguments expected by the calculation we are running:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1795dd41",
"metadata": {},
"outputs": [],
"source": [
"from aiida.orm import Str, Float, Bool\n",
"inputs = {\n",
" \"code\": code,\n",
" \"model\": model,\n",
" \"arch\": Str(model.architecture),\n",
" \"precision\": Str(\"float64\"),\n",
" \"device\": Str(\"cpu\"),\n",
" \"fmax\": Float(0.1), \n",
" \"opt_cell_lengths\": Bool(False), \n",
" \"opt_cell_fully\": Bool(True), \n",
" \"metadata\": {\"options\": {\"resources\": {\"num_machines\": 1}}},\n",
" }"
]
},
{
"cell_type": "markdown",
"id": "1d661593",
"metadata": {},
"source": [
"We must now choose the calculations to perform:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0e4c78c9",
"metadata": {},
"outputs": [],
"source": [
"from aiida.plugins import CalculationFactory\n",
"geomoptCalc = CalculationFactory(\"mlip.opt\")\n",
"descriptorsCalc = CalculationFactory(\"mlip.descriptors\")"
]
},
{
"cell_type": "markdown",
"id": "37df1f81",
"metadata": {},
"source": [
"Now we can create our WorkGraph. This includes passing in the inputs, checking the amount of structures we have and interating through. Note for this workbook we have decreased the amount of structures to two for the sake of simplicity. In the loop we can call each structure; run geomopt calculation, pass the output file into descriptors calculation, and get the final outputs of all the structures"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "176f1ea0",
"metadata": {},
"outputs": [],
"source": [
"from aiida_workgraph import WorkGraph, Zone\n",
"from aiida.orm import StructureData\n",
"from ase.build import bulk\n",
"from ase.io import read\n",
"from sample_split import descriptors_outputs, process_and_split_data\n",
"\n",
"\n",
"\n",
"num_structs = len(read(\"../../examples/tutorials/structures/lj-traj.xyz\", index=\":\"))\n",
"\n",
"with WorkGraph(\"Calculation Workgraph\") as wg:\n",
" wg.inputs = inputs\n",
" final_structures = {}\n",
"\n",
" for i in range(num_structs - 9):\n",
"\n",
" structure = StructureData(ase=read(\"../../examples/tutorials/structures/lj-traj.xyz\", index=f\"{i}\"))\n",
" \n",
" geomopt_calc = wg.add_task(\n",
" geomoptCalc,\n",
" code = wg.inputs.code,\n",
" model = wg.inputs.model,\n",
" arch = wg.inputs.arch,\n",
" precision = wg.inputs.precision,\n",
" device = wg.inputs.device,\n",
" metadata = wg.inputs.metadata,\n",
" fmax = wg.inputs.fmax,\n",
" opt_cell_lengths = wg.inputs.opt_cell_lengths,\n",
" opt_cell_fully = wg.inputs.opt_cell_fully,\n",
" struct = structure,\n",
" )\n",
"\n",
" descriptors_calc = wg.add_task(\n",
" descriptorsCalc,\n",
" code = wg.inputs.code,\n",
" model = wg.inputs.model,\n",
" arch = wg.inputs.arch,\n",
" precision = wg.inputs.precision,\n",
" device = wg.inputs.device,\n",
" metadata = wg.inputs.metadata,\n",
" struct = geomopt_calc.outputs.final_structure,\n",
" calc_per_element = True\n",
" )\n",
"\n",
" final_structures[f\"structs{i}\"] = descriptors_calc.outputs.xyz_output\n",
" \n",
" wg.outputs.final_structures = final_structures\n",
" \n",
" collect_result = wg.add_task(\n",
" descriptors_outputs,\n",
" structures = final_structures\n",
" )\n",
"\n",
" # split_task = wg.add_task(\n",
" # process_and_split_data,\n",
" # trajectory_path = collect_result.outputs.result\n",
" # config_types = \"\",\n",
" # n_samples = 2,\n",
" # prefix = \"\",\n",
" # scale = 1.0e5,\n",
" # append_mode = False\n",
" # )\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "50a51bfc",
"metadata": {},
"outputs": [],
"source": [
"wg"
]
},
{
"cell_type": "markdown",
"id": "bb77dab0",
"metadata": {},
"source": [
"Now we can run the calculations"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8f2c1fcd",
"metadata": {},
"outputs": [],
"source": [
"wg.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "29175d94",
"metadata": {},
"outputs": [],
"source": [
"print(collect_result.outputs.result)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "531b2e36",
"metadata": {},
"outputs": [],
"source": [
"for _, data in collect_result.outputs.result.value.items():\n",
" print(type(data))"
]
},
{
"cell_type": "markdown",
"id": "9d3f9ddd",
"metadata": {},
"source": [
"# TEST"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b14fe356",
"metadata": {},
"outputs": [],
"source": [
"from aiida.orm import load_node\n",
"from sample_split import descriptors_outputs, process_and_split_data\n",
"from aiida import load_profile\n",
"from aiida_workgraph import WorkGraph, Zone\n",
"\n",
"load_profile()\n",
"\n",
"sfdata = load_node(pk= 15657)\n",
"sfdata1 = load_node(pk= 15661)\n",
"\n",
"structs_out = {\n",
" \"structs0\" : sfdata,\n",
" \"structs1\" : sfdata1,\n",
"}\n",
"\n",
"wg = WorkGraph(\"test\")\n",
"aggr = wg.add_task(descriptors_outputs)\n",
"aggr.set(structs_out)\n",
"\n",
"# split = wg.add_task(\n",
"# process_and_split_data,\n",
"# trajectory_path = aggr.outputs.result,\n",
"# config_types = \"\",\n",
"# n_samples = 2,\n",
"# prefix = \"\",\n",
"# scale = 1.0e5,\n",
"# append_mode = False\n",
"# )\n",
"\n",
"wg.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5a418d4c",
"metadata": {},
"outputs": [],
"source": [
"wg.tasks.descriptors_outputs.outputs.result.value.get_dict()"
]
},
{
"cell_type": "markdown",
"id": "c80ae1d3",
"metadata": {},
"source": [
"In order to pass the outputs from the WorkGraph into sample_split.py we create a list of structures"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "78a87e6f",
"metadata": {},
"outputs": [],
"source": [
"import shutil, os\n",
"from pathlib import Path\n",
"\n",
"descriptors_output = list(wg.outputs.final_structures)\n",
"traj_structs = []\n",
"\n",
"for i in range(len(descriptors_output)):\n",
"\n",
" # create list variable which holds output structs\n",
" singlefiledata = wg.outputs.final_structures[f\"structs{i}\"]\n",
" traj_structs.append(singlefiledata.value)\n",
"\n",
"\n",
"print(traj_structs)"
]
},
{
"cell_type": "markdown",
"id": "5b666c73",
"metadata": {},
"source": [
"Now we can run the split script"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8d4c948c",
"metadata": {},
"outputs": [],
"source": [
"from sample_split import process_and_split_data\n",
"\n",
"\n",
"process_and_split_data(\n",
" trajectory_path = traj_structs,\n",
" config_types = \"\",\n",
" n_samples = 2,\n",
" prefix = \"\",\n",
" scale = 1.0e5,\n",
" append_mode = False\n",
" )\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "aiida-mlip (3.12.2)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading