Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
285 changes: 285 additions & 0 deletions afm_acwf_test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "1f55fd89",
"metadata": {},
"outputs": [],
"source": [
"import typing as t\n",
"\n",
"from aiida import load_profile, orm\n",
"\n",
"from aiida_common_workflows.workflows.afm import AfmCase, AfmWorkflow\n",
"\n",
"_ = load_profile()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "85c0a2ea",
"metadata": {},
"outputs": [],
"source": [
"from aiida_pseudo.groups.family.pseudo import PseudoPotentialFamily\n",
"\n",
"structure = orm.StructureData()\n",
"structure.set_cell(\n",
" [\n",
" [14.9412827110, 0.0, 0.0],\n",
" [0.0, 14.5091262213, 0.0],\n",
" [0.0, 0.0, 10.0820001747],\n",
" ]\n",
")\n",
"structure.set_pbc((False, False, False))\n",
"structure.append_atom(symbols=\"C\", position=(8.2766055186, 6.1177492411, 5.0595246063))\n",
"structure.append_atom(symbols=\"C\", position=(8.8582363932, 7.3839854920, 5.0363959612))\n",
"structure.append_atom(symbols=\"C\", position=(8.0523006568, 8.5208073256, 5.0178902940))\n",
"structure.append_atom(symbols=\"C\", position=(6.6646772714, 8.3913773689, 5.0224782237))\n",
"structure.append_atom(symbols=\"C\", position=(6.0830463468, 7.1251409580, 5.0456056988))\n",
"structure.append_atom(symbols=\"C\", position=(6.8889822232, 5.9883191444, 5.0641114560))\n",
"structure.append_atom(symbols=\"H\", position=(8.9093056269, 5.2253257080, 5.0739448106))\n",
"structure.append_atom(symbols=\"H\", position=(9.9475591624, 7.4856249613, 5.0328185108))\n",
"structure.append_atom(symbols=\"H\", position=(8.5089059407, 9.5148483491, 4.9998780126))\n",
"structure.append_atom(symbols=\"H\", position=(6.0319773431, 9.2838011020, 5.0080584394))\n",
"structure.append_atom(symbols=\"H\", position=(4.9937235476, 7.0235011287, 5.0491811392))\n",
"structure.append_atom(symbols=\"H\", position=(6.4323774593, 4.9942778709, 5.0821221574))\n",
"\n",
"tip = orm.StructureData()\n",
"tip.set_cell(\n",
" [\n",
" [20.0, 0.0, 0.0],\n",
" [0.0, 20.0, 0.0],\n",
" [0.0, 0.0, 20.0],\n",
" ]\n",
")\n",
"tip.set_pbc((False, False, False))\n",
"tip.append_atom(symbols=\"C\", position=(0.0, 0.0, 1.15))\n",
"tip.append_atom(symbols=\"O\", position=(0.0, 0.0, 0.0))\n",
"\n",
"kpoints = orm.KpointsData()\n",
"kpoints.set_kpoints_mesh([1, 1, 1])\n",
"\n",
"pseudo_family = t.cast(PseudoPotentialFamily, orm.load_group(4))\n",
"C_pp = pseudo_family.get_pseudo(\"C\")\n",
"H_pp = pseudo_family.get_pseudo(\"H\")\n",
"O_pp = pseudo_family.get_pseudo(\"O\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "33c626df",
"metadata": {},
"outputs": [],
"source": [
"afm_params = {\n",
" \"PBC\": False,\n",
" \"tip\": \"s\",\n",
" \"klat\": 0.3490127886809,\n",
" \"krad\": 21.913190531846,\n",
" \"gridA\": [14.9412827110, 0.0000000000, 0.0000000000],\n",
" \"gridB\": [0.0000000000, 14.5091262213, 0.0000000000],\n",
" \"gridC\": [0.0000000000, 0.0000000000, 10.0820001747],\n",
" \"sigma\": 0.7,\n",
" \"charge\": 0.0,\n",
" \"r0Probe\": [0.0, 0.0, 2.97],\n",
" \"scanMax\": [14.9412827110, 14.5091262213, 11],\n",
" \"scanMin\": [0.0, 0.0, 8],\n",
" \"scanStep\": [0.1, 0.1, 0.1],\n",
" \"Amplitude\": 1.4,\n",
" \"probeType\": \"O\",\n",
" \"f0Cantilever\": 22352.5,\n",
" \"gridN\": [-1, -1, -1],\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cf33e88a",
"metadata": {},
"outputs": [],
"source": [
"dft_params = {\n",
" \"geom\": {\n",
" \"engines\": {\n",
" \"relax\": {\n",
" \"code\": orm.load_code(\"pw-7.4@localhost\"),\n",
" \"options\": {\n",
" \"resources\": {\n",
" \"num_machines\": 1,\n",
" },\n",
" \"max_wallclock_seconds\": 43200,\n",
" },\n",
" },\n",
" },\n",
" \"protocol\": \"fast\",\n",
" \"relax_type\": \"positions\",\n",
" },\n",
" \"tip\": {\n",
" \"engines\": {\n",
" \"relax\": {\n",
" \"code\": orm.load_code(\"pw-7.4@localhost\"),\n",
" \"options\": {\n",
" \"resources\": {\n",
" \"num_machines\": 1,\n",
" },\n",
" \"max_wallclock_seconds\": 43200,\n",
" },\n",
" }\n",
" },\n",
" \"protocol\": \"fast\",\n",
" \"relax_type\": \"none\",\n",
" },\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2a7ffea1",
"metadata": {},
"outputs": [],
"source": [
"pp_params = {\n",
" \"hartree_potential\": {\n",
" \"engines\": {\n",
" \"pp\": {\n",
" \"code\": orm.load_code(\"pp-7.4@localhost\"),\n",
" \"options\": {\n",
" \"resources\": {\n",
" \"num_machines\": 1,\n",
" },\n",
" \"max_wallclock_seconds\": 43200,\n",
" },\n",
" }\n",
" },\n",
" \"quantity\": \"potential\",\n",
" },\n",
" \"charge_density\": {\n",
" \"engines\": {\n",
" \"pp\": {\n",
" \"code\": orm.load_code(\"pp-7.4@localhost\"),\n",
" \"options\": {\n",
" \"resources\": {\n",
" \"num_machines\": 1,\n",
" },\n",
" \"max_wallclock_seconds\": 43200,\n",
" },\n",
" }\n",
" },\n",
" \"quantity\": \"charge_density\",\n",
" },\n",
"}\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3b7823b7",
"metadata": {},
"outputs": [],
"source": [
"wg = AfmWorkflow.build(\n",
" engine=\"quantum_espresso\",\n",
" case=AfmCase.HARTREE.name,\n",
" structure=structure,\n",
" afm_params=afm_params,\n",
" relax=False,\n",
" dft_params=dft_params,\n",
" pp_params=pp_params,\n",
" tip=tip,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "93b467ba",
"metadata": {},
"outputs": [],
"source": [
"wg"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9baa60aa",
"metadata": {},
"outputs": [],
"source": [
"wg.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b50fa794",
"metadata": {},
"outputs": [],
"source": [
"import base64\n",
"\n",
"from IPython.display import HTML\n",
"\n",
"fd: orm.FolderData\n",
"if wg.outputs.Q0_00K0_35.value:\n",
" fd = wg.outputs.Q0_00K0_35.value\n",
"else:\n",
" node = orm.load_node(wg.pk)\n",
" fd = node.outputs.Q0_00K0_35\n",
"\n",
"imgs = []\n",
"\n",
"png_folder = \"Amp1.40\"\n",
"\n",
"for obj in fd.list_objects(png_folder):\n",
" if obj.name.endswith(\".png\"):\n",
" with fd.open(f\"{png_folder}/{obj.name}\", \"rb\") as handle:\n",
" data = handle.read()\n",
" data64 = base64.b64encode(data).decode(\"utf-8\")\n",
" imgs.append(f\"\"\"\n",
" <img\n",
" src=\"data:image/png;base64,{data64}\"\n",
" style=\"max-width:150px; margin:5px;\"\n",
" />\n",
" \"\"\")\n",
"\n",
"HTML(\"\".join(imgs))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "238f1c3b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "afm",
"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.11.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ requires-python = '>=3.9'
'common_workflows.relax.siesta' = 'aiida_common_workflows.workflows.relax.siesta.workchain:SiestaCommonRelaxWorkChain'
'common_workflows.relax.vasp' = 'aiida_common_workflows.workflows.relax.vasp.workchain:VaspCommonRelaxWorkChain'
'common_workflows.relax.wien2k' = 'aiida_common_workflows.workflows.relax.wien2k.workchain:Wien2kCommonRelaxWorkChain'
'common_workflows.pp.quantum_espresso' = 'aiida_common_workflows.workflows.pp.quantum_espresso.workchain:QuantumEspressoCommonPostProcessWorkChain'

[project.optional-dependencies]
abinit = [
Expand Down
5 changes: 3 additions & 2 deletions src/aiida_common_workflows/common/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for resources common to the entire `aiida-common-workflows` package."""
from .types import ElectronicType, RelaxType, SpinType

__all__ = ('ElectronicType', 'SpinType', 'RelaxType')
from .types import ElectronicType, PostProcessQuantity, RelaxType, SpinType

__all__ = ('ElectronicType', 'PostProcessQuantity', 'RelaxType', 'SpinType')
10 changes: 9 additions & 1 deletion src/aiida_common_workflows/common/types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Module with basic type definitions."""

from enum import Enum

__all__ = ('ElectronicType', 'SpinType', 'RelaxType')
__all__ = ('ElectronicType', 'PostProcessQuantity', 'RelaxType', 'SpinType')


class RelaxType(Enum):
Expand Down Expand Up @@ -33,3 +34,10 @@ class ElectronicType(Enum):
METAL = 'metal'
INSULATOR = 'insulator'
UNKNOWN = 'unknown'


class PostProcessQuantity(Enum):
"""Enumeration of known post-processing quantities."""

POTENTIAL = 'potential'
CHARGE_DENSITY = 'charge_density'
2 changes: 1 addition & 1 deletion src/aiida_common_workflows/plugins/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def WorkflowFactory(entry_point_name: str, load: bool = True) -> t.Union['EntryP
:raises aiida.common.LoadingEntryPointError: entry point could not be loaded
:raises aiida.common.InvalidEntryPointTypeError: if the type of the loaded entry point is invalid.
"""
common_workflow_prefixes = ('common_workflows.relax.', 'common_workflows.bands.')
common_workflow_prefixes = ('common_workflows.relax.', 'common_workflows.bands.', 'common_workflows.pp.')
try:
return plugins.WorkflowFactory(entry_point_name, load)
except exceptions.MissingEntryPointError as exception:
Expand Down
Loading
Loading