diff --git a/README.md b/README.md
index f7bfea407..3435ed814 100644
--- a/README.md
+++ b/README.md
@@ -79,6 +79,7 @@ Workflow notebooks that run simulations.
| [Surface Energy](other/materials_designer/workflows/surface_energy.ipynb) | Calculate surface formation energy. |
| [Interfacial Energy](other/materials_designer/workflows/interfacial_energy.ipynb) | Calculate interfacial energy γ at a heterostructure. |
| [Valence Band Offset](other/materials_designer/workflows/valence_band_offset.ipynb) | Determine the valence band offset at an interface. |
+| [Valence Band Offset (Bulk Method)](other/materials_designer/workflows/valence_band_offset_bulk.ipynb) | Determine the valence band offset of a periodic superlattice from bulk references. |
### `notebooks_utils` — Python Utility Package
diff --git a/other/materials_designer/workflows/Introduction.ipynb b/other/materials_designer/workflows/Introduction.ipynb
index a0c7cb285..056bc9080 100644
--- a/other/materials_designer/workflows/Introduction.ipynb
+++ b/other/materials_designer/workflows/Introduction.ipynb
@@ -99,12 +99,14 @@
"\n",
"### 8.1. Valence Band Offset\n",
"#### [8.1.1. Valence band offset at an interface.](valence_band_offset.ipynb)\n",
+ "#### [8.1.2. Valence band offset of a periodic superlattice (Bulk Method).](valence_band_offset_bulk.ipynb)\n",
"\n",
"### 8.2. Dielectric Tensor\n",
"#### [8.2.1. Dielectric tensor calculation.](dielectric_tensor.ipynb)\n",
"\n",
"### 8.3. Schottky Barrier\n",
"#### [8.3.1. Schottky barrier heights at a metal/semiconductor interface.](schottky_barrier.ipynb)\n",
+ "#### [8.3.2. Schottky barrier heights of a periodic metal/semiconductor superlattice (Bulk Method).](schottky_barrier_bulk.ipynb)\n",
"\n",
"\n",
"## 9. Custom\n",
diff --git a/other/materials_designer/workflows/schottky_barrier_bulk.ipynb b/other/materials_designer/workflows/schottky_barrier_bulk.ipynb
new file mode 100644
index 000000000..c4bde1b94
--- /dev/null
+++ b/other/materials_designer/workflows/schottky_barrier_bulk.ipynb
@@ -0,0 +1,758 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "0",
+ "metadata": {},
+ "source": [
+ "# Schottky Barrier Height (SBH), Bulk Method\n",
+ "\n",
+ "Calculate the Schottky barrier heights of a periodic metal/semiconductor superlattice with the bulk method, using a DFT workflow on the Mat3ra platform.\n",
+ "\n",
+ "The Fermi level of the metal and the valence band maximum of the semiconductor are each measured from the macroscopically averaged electrostatic potential (ESP) of their own bulk cell, and the superlattice gives the step in the averaged ESP between the centres of the two blocks:\n",
+ "\n",
+ "$$\\Phi_p = \\left[E_F - \\bar{V}\\right]_{\\mathrm{metal}} - \\left[E_{\\mathrm{VBM}} - \\bar{V}\\right]_{\\mathrm{semiconductor}} + \\left[\\bar{V}_{\\mathrm{metal}} - \\bar{V}_{\\mathrm{semiconductor}}\\right]_{\\mathrm{superlattice}}, \\qquad \\Phi_n = E_{\\mathrm{gap}} - \\Phi_p$$\n",
+ "\n",
+ "The bulk cell of each part is built from the interface: one period of the part's crystal along the interface normal, strained as in the interface.\n",
+ "\n",
+ "The result is meaningful when:\n",
+ "\n",
+ "- the interface is a periodic superlattice with no vacuum, and its two interfaces are equivalent;\n",
+ "- each block is at least one bulk cell thick, so that the averaged ESP is flat at its centre (the plot at the end shows it);\n",
+ "- one part holds an element that the other does not, as the blocks are found by element (Si/SiO₂ works, TiO/TiO₂ does not).\n",
+ "\n",
+ "
Usage
\n",
+ "\n",
+ "1. Create and save a metal/semiconductor interface, whose build metadata (`metadata.build`) holds its substrate and film, with `create_interface_with_min_strain_zsl.ipynb`: a superlattice with `INTERFACE_VACUUM = 0.0`, `INTERFACE_DISTANCE` set to the spacing of atomic planes across the interface (for example the mean of the two materials' plane spacings along the normal), and each part at least one layer thick.\n",
+ "1. Set the interface and calculation parameters in cells 1.2 and 1.3 below, including which part of the interface is the semiconductor.\n",
+ "1. Click \"Run\" > \"Run All\" to run all cells.\n",
+ "1. Wait for the job to complete.\n",
+ "1. Scroll down to view the Schottky barrier heights.\n",
+ "\n",
+ "## Summary\n",
+ "\n",
+ "1. Set up the environment and parameters: install packages (JupyterLite only) and configure parameters for the interface, workflow, compute resources, and job.\n",
+ "1. Authenticate and initialize API client: authenticate via browser, initialize the client, then select account and project.\n",
+ "1. Create materials: load an interface from the `../uploads` folder, build the bulk cells of its semiconductor and metal parts from the interface's build metadata (`metadata.build`), strip the interface labels not compatible with Quantum ESPRESSO, and save all three materials to the platform tagged with the interface name.\n",
+ "1. Configure workflow: select application, load the Schottky barrier (Bulk Method) workflow from Standata, set model and computational parameters with a k-grid per material, and preview the workflow.\n",
+ "1. Configure compute: get list of clusters and create compute configuration with selected cluster, queue, and number of processors.\n",
+ "1. Create the job with materials and workflow configuration: assemble the job from materials, workflow, project, and compute configuration.\n",
+ "1. Submit the job and monitor the status: submit the job and wait for completion.\n",
+ "1. Retrieve results: get and display the Schottky barrier heights, the average ESP profiles, and the superlattice ESP with the two block averages."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "1",
+ "metadata": {},
+ "source": [
+ "## 1. Set up the environment and parameters\n",
+ "### 1.1. Install packages (JupyterLite)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "2",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.notebooks_utils.packages import install_packages\n",
+ "\n",
+ "await install_packages(\"made|api_examples\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "3",
+ "metadata": {},
+ "source": [
+ "### 1.2. Set parameters\n",
+ "Provide the INTERFACE_NAME to match the name of the structure in \"uploads\" folder for search. The semiconductor part is the substrate or the film of the interface's build metadata (`metadata.build`); the other part is the metal."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "4",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from datetime import datetime\n",
+ "from mat3ra.ide.compute import QueueName\n",
+ "from mat3ra.made.tools.convert.interface_parts_enum import InterfacePartsEnum\n",
+ "\n",
+ "# 2. Auth and organization parameters\n",
+ "ORGANIZATION_NAME = None\n",
+ "\n",
+ "# 3. Material parameters\n",
+ "FOLDER = \"../uploads\"\n",
+ "INTERFACE_NAME = \"Interface\" # To search for in \"uploads\" folder, account's materials, then Standata\n",
+ "RELAXED_INTERFACE_NAME = None # To search for in \"uploads\" folder, account's materials, then Standata. Defaults to the interface\n",
+ "SEMICONDUCTOR_PART = InterfacePartsEnum.FILM\n",
+ "INTERFACE_SYSTEM_NAME = None # Used as tag to group the materials. Defaults to shorthand from the loaded interface name\n",
+ "\n",
+ "# 4. Workflow parameters\n",
+ "APPLICATION_NAME = \"espresso\"\n",
+ "WORKFLOW_SEARCH_TERM = \"schottky_barrier_bulk.json\"\n",
+ "MY_WORKFLOW_NAME = \"SBH Bulk\"\n",
+ "\n",
+ "# 5. Compute parameters\n",
+ "CLUSTER_NAME = None\n",
+ "QUEUE_NAME = QueueName.D\n",
+ "PPN = 1\n",
+ "\n",
+ "# 6. Job parameters\n",
+ "timestamp = datetime.now().strftime(\"%Y-%m-%d %H:%M\")\n",
+ "POLL_INTERVAL = 60 # seconds"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "5",
+ "metadata": {},
+ "source": [
+ "### 1.3. Set specific SBH parameters\n",
+ "The interface and the metal are metallic, so their SCF uses smearing occupations; the smearing type and width can be set in `ADDITIONAL_PARAMETERS[\"system\"]`.\n",
+ "\n",
+ "The k-grids of the superlattice and of the two bulk cells follow from one k-point density, so all three are sampled alike.\n",
+ "\n",
+ "Semi-local DFT underestimates band gaps, and with them the n-type barrier. Set `BAND_GAP` to a measured or hybrid-functional gap to use it instead of the DFT gap of the semiconductor; it moves only the conduction band, so the p-type barrier stays the DFT value."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "6",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Method parameters\n",
+ "PSEUDOPOTENTIAL_TYPE = \"us\" # \"us\" (ultrasoft), \"nc\" (norm-conserving), \"paw\"\n",
+ "FUNCTIONAL = \"pbe\" # for gga: \"pbe\", \"pbesol\"; for lda: \"pz\"\n",
+ "MODEL_SUBTYPE = \"gga\"\n",
+ "\n",
+ "# K-grid and k-path\n",
+ "KPOINT_DENSITY = 3.5 # points per Å⁻¹ of reciprocal length\n",
+ "KPATH = None # e.g. [{\"point\": \"Γ\", \"steps\": 20}, {\"point\": \"X\", \"steps\": 20}]\n",
+ "\n",
+ "# Set SCF diagonalization, mixing and occupations in QE input\n",
+ "ADDITIONAL_PARAMETERS = {\n",
+ " \"electrons\": {\n",
+ " \"diagonalization\": \"david\", # \"david\" or \"cg\"\n",
+ " \"mixing_beta\": 0.3\n",
+ " },\n",
+ " # \"system\": {\"smearing\": \"mv\", \"degauss\": 0.02},\n",
+ "}\n",
+ "\n",
+ "# Energy cutoffs\n",
+ "ECUTWFC = 40\n",
+ "ECUTRHO = 200\n",
+ "\n",
+ "# Band gap used for the n-type barrier, in eV. None uses the DFT gap of the semiconductor.\n",
+ "BAND_GAP = None"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "7",
+ "metadata": {},
+ "source": [
+ "## 2. Authenticate and initialize API client\n",
+ "### 2.1. Authenticate\n",
+ "Authenticate in the browser and have credentials stored in environment variable \"OIDC_ACCESS_TOKEN\"."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "8",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.notebooks_utils.auth import authenticate\n",
+ "\n",
+ "await authenticate()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "9",
+ "metadata": {},
+ "source": [
+ "### 2.2. Initialize API client"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "10",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.api_client import APIClient\n",
+ "\n",
+ "client = APIClient.authenticate()\n",
+ "client"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "11",
+ "metadata": {},
+ "source": [
+ "### 2.3. Select account"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "12",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "client.list_accounts()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "13",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "selected_account = client.my_account\n",
+ "\n",
+ "if ORGANIZATION_NAME:\n",
+ " selected_account = client.get_account(name=ORGANIZATION_NAME)\n",
+ "\n",
+ "ACCOUNT_ID = selected_account.id\n",
+ "print(f\"✅ Selected account ID: {ACCOUNT_ID}, name: {selected_account.name}\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "14",
+ "metadata": {},
+ "source": [
+ "### 2.4. Select project"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "15",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "projects = client.projects.list({\"isDefault\": True, \"owner._id\": ACCOUNT_ID})\n",
+ "project_id = projects[0][\"_id\"]\n",
+ "print(f\"✅ Using project: {projects[0]['name']} ({project_id})\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "16",
+ "metadata": {},
+ "source": [
+ "## 3. Create materials\n",
+ "### 3.1. Load interface from local folder"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "17",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.notebooks_utils.core.entity.material.api import load_material\n",
+ "from mat3ra.notebooks_utils.ipython.entity.material.visualize import visualize_materials as visualize\n",
+ "\n",
+ "interface = load_material(client, FOLDER, INTERFACE_NAME, ACCOUNT_ID)\n",
+ "relaxed_interface = load_material(client, FOLDER, RELAXED_INTERFACE_NAME, ACCOUNT_ID) if RELAXED_INTERFACE_NAME else interface\n",
+ "\n",
+ "visualize(relaxed_interface, repetitions=[1, 1, 1])\n",
+ "visualize(relaxed_interface, repetitions=[1, 1, 1], rotation=\"-90x\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "18",
+ "metadata": {},
+ "source": [
+ "### 3.2. Create materials from interface parts\n",
+ "The bulk cells of the semiconductor and the metal are built from the build metadata (`metadata.build`) of `INTERFACE_NAME`: one period of each part's crystal along the interface normal, strained as in the interface. With `RELAXED_INTERFACE_NAME` set, the bulk cells keep the unrelaxed interface's strain and height along the normal. Their in-plane cells can differ from the interface's. The interface labels are removed as they are not compatible with Quantum ESPRESSO. The three materials (interface, semiconductor bulk, metal bulk) are named and visualized."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "19",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import re\n",
+ "from mat3ra.made.tools.analyze.interface_material import create_interface_bulk_cell\n",
+ "\n",
+ "interface_shorthand_match = re.match(r\"^(.+?)\\s\", interface.name)\n",
+ "interface_system_name = INTERFACE_SYSTEM_NAME or (\n",
+ " interface_shorthand_match.group(1) if interface_shorthand_match else INTERFACE_NAME\n",
+ ")\n",
+ "metal_part = InterfacePartsEnum.SUBSTRATE if SEMICONDUCTOR_PART == InterfacePartsEnum.FILM else InterfacePartsEnum.FILM\n",
+ "semiconductor_material = create_interface_bulk_cell(interface, SEMICONDUCTOR_PART)\n",
+ "metal_material = create_interface_bulk_cell(interface, metal_part)\n",
+ "interface_material = relaxed_interface.clone()\n",
+ "\n",
+ "interface_material.basis.set_labels_from_list([])\n",
+ "\n",
+ "semiconductor_material.name = f\"{interface_material.name} Semiconductor Bulk\"\n",
+ "metal_material.name = f\"{interface_material.name} Metal Bulk\"\n",
+ "\n",
+ "materials_by_role = {\"interface\": interface_material, \"semiconductor\": semiconductor_material, \"metal\": metal_material}\n",
+ "for role, material in materials_by_role.items():\n",
+ " print(f\" {role}: {material.name}\")\n",
+ "visualize(list(materials_by_role.values()), repetitions=[1, 1, 1], rotation=\"-90x\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "20",
+ "metadata": {},
+ "source": [
+ "### 3.3. Save materials"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "21",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.made.material import Material\n",
+ "from mat3ra.notebooks_utils.core.entity.material.api import get_or_create_material\n",
+ "\n",
+ "saved_materials = {}\n",
+ "for role, material in materials_by_role.items():\n",
+ " saved_response = get_or_create_material(client, material, ACCOUNT_ID)\n",
+ " saved = Material.create(saved_response)\n",
+ " tags = sorted({*(saved_response.get(\"tags\") or []), interface_system_name})\n",
+ " client.materials.update(saved.id, {\"tags\": tags})\n",
+ " saved_materials[role] = saved\n",
+ " print(f\" {role}: {saved.name} ({saved.id}) | tags={tags}\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "22",
+ "metadata": {},
+ "source": [
+ "## 4. Configure workflow\n",
+ "### 4.1. Select application"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "23",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.ade.application import Application\n",
+ "from mat3ra.standata.applications import ApplicationStandata\n",
+ "\n",
+ "app_config = ApplicationStandata.get_by_name_first_match(APPLICATION_NAME)\n",
+ "app = Application(**app_config)\n",
+ "print(f\"Using application: {app.name}\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "24",
+ "metadata": {},
+ "source": [
+ "### 4.2. Load workflow from Standata and preview it"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "25",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.standata.workflows import WorkflowStandata\n",
+ "from mat3ra.wode.workflows import Workflow\n",
+ "from mat3ra.notebooks_utils.ipython.entity.workflow.visualize import visualize_workflow\n",
+ "\n",
+ "workflow_config = WorkflowStandata.filter_by_application(app.name).get_by_name_first_match(WORKFLOW_SEARCH_TERM)\n",
+ "workflow = Workflow.create(workflow_config)\n",
+ "\n",
+ "workflow.name = MY_WORKFLOW_NAME\n",
+ "\n",
+ "visualize_workflow(workflow)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "26",
+ "metadata": {},
+ "source": [
+ "### 4.3. Set model and its parameters (physics)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "27",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.mode import ModelFactory\n",
+ "from mat3ra.standata.model_tree import ModelTreeStandata\n",
+ "\n",
+ "model_config = ModelTreeStandata.get_model_by_parameters(\n",
+ " type=\"dft\", subtype=MODEL_SUBTYPE, functional=FUNCTIONAL\n",
+ ")\n",
+ "model_config[\"method\"] = {\"type\": \"pseudopotential\", \"subtype\": PSEUDOPOTENTIAL_TYPE}\n",
+ "model = ModelFactory.create(model_config)\n",
+ "\n",
+ "for subworkflow in workflow.subworkflows:\n",
+ " if subworkflow.application.name == APPLICATION_NAME:\n",
+ " subworkflow.model = model"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "28",
+ "metadata": {},
+ "source": [
+ "### 4.4. Modify method (computational parameters): k-grid per material, k-path, cutoffs, diagonalization, mixing, and occupations\n",
+ "Each Quantum ESPRESSO subworkflow runs on the material its \"Set Material Index\" unit selects, the superlattice when it has none, and gets the k-grid of that material at `KPOINT_DENSITY`."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "29",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.wode.context.providers import PointsGridDataProvider, PointsPathDataProvider\n",
+ "from mat3ra.notebooks_utils.workflow import apply_planewave_cutoffs, kgrid_from_density, patch_workflow_qe_input\n",
+ "\n",
+ "scf_unit_names = [\"pw_scf\", \"pw_bands\"]\n",
+ "materials = list(materials_by_role.values())\n",
+ "\n",
+ "for subworkflow in workflow.subworkflows:\n",
+ " if subworkflow.application.name != APPLICATION_NAME:\n",
+ " continue\n",
+ " material_index = int(next((unit.value for unit in subworkflow.units if unit.name.startswith(\"Set Material Index\")), 0))\n",
+ " material = materials[material_index]\n",
+ " kgrid = kgrid_from_density(material, KPOINT_DENSITY)\n",
+ " unit = subworkflow.get_unit_by_name(name=\"pw_scf\")\n",
+ " unit.add_context(PointsGridDataProvider(material=material, dimensions=kgrid, isEdited=True).get_context_item_data())\n",
+ " subworkflow.set_unit(unit)\n",
+ " print(f\" {subworkflow.name}: {material.name}, k-grid {kgrid}\")\n",
+ "\n",
+ "if KPATH is not None:\n",
+ " for subworkflow in workflow.subworkflows:\n",
+ " if unit := subworkflow.get_unit_by_name(name=\"pw_bands\"):\n",
+ " unit.add_context(PointsPathDataProvider(path=KPATH, isEdited=True).get_context_item_data())\n",
+ " subworkflow.set_unit(unit)\n",
+ "\n",
+ "if ECUTWFC is not None:\n",
+ " for unit_name in scf_unit_names:\n",
+ " apply_planewave_cutoffs(workflow, ECUTWFC, ECUTRHO, unit_name=unit_name)\n",
+ "\n",
+ "if ADDITIONAL_PARAMETERS:\n",
+ " patch_workflow_qe_input(workflow, ADDITIONAL_PARAMETERS, unit_names=scf_unit_names)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "30",
+ "metadata": {},
+ "source": [
+ "### 4.5. Set the band gap for the n-type barrier"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "31",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.notebooks_utils.workflow import set_assignment_value\n",
+ "\n",
+ "if BAND_GAP is not None:\n",
+ " set_assignment_value(workflow, \"Set Semiconductor Band Gap\", str(BAND_GAP))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "32",
+ "metadata": {},
+ "source": [
+ "### 4.6. Preview final workflow"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "33",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "visualize_workflow(workflow)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "34",
+ "metadata": {},
+ "source": [
+ "## 5. Create the compute configuration\n",
+ "### 5.1. Get list of clusters"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "35",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "clusters = client.clusters.list()\n",
+ "print(f\"Available clusters: {[c['hostname'] for c in clusters]}\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "36",
+ "metadata": {},
+ "source": [
+ "### 5.2. Create compute configuration"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "37",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.ide.compute import Compute\n",
+ "\n",
+ "if CLUSTER_NAME:\n",
+ " cluster = next((c for c in clusters if CLUSTER_NAME in c[\"hostname\"]), None)\n",
+ "else:\n",
+ " cluster = clusters[0]\n",
+ "\n",
+ "compute = Compute(\n",
+ " cluster=cluster,\n",
+ " queue=QUEUE_NAME,\n",
+ " ppn=PPN\n",
+ ")\n",
+ "print(f\"Using cluster: {compute.cluster.hostname}, queue: {QUEUE_NAME}, ppn: {PPN}\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "38",
+ "metadata": {},
+ "source": [
+ "## 6. Create the job\n",
+ "### 6.1. Create job"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "39",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.notebooks_utils.job import create_job\n",
+ "from mat3ra.utils.namespace import dict_to_namespace_recursive\n",
+ "from mat3ra.notebooks_utils.ui import display_JSON\n",
+ "\n",
+ "materials = list(saved_materials.values())\n",
+ "\n",
+ "job_name = f\"{MY_WORKFLOW_NAME} {interface_system_name} {timestamp}\"\n",
+ "workflow.name = job_name\n",
+ "\n",
+ "print(f\"Materials: {[m.id for m in materials]}\")\n",
+ "print(f\"Project: {project_id}\")\n",
+ "\n",
+ "job_response = create_job(\n",
+ " api_client=client,\n",
+ " materials=materials,\n",
+ " workflow=workflow,\n",
+ " project_id=project_id,\n",
+ " owner_id=ACCOUNT_ID,\n",
+ " prefix=job_name,\n",
+ " compute=compute.to_dict(),\n",
+ ")\n",
+ "\n",
+ "job = dict_to_namespace_recursive(job_response)\n",
+ "job_id = job._id\n",
+ "print(\"✅ Job created successfully!\")\n",
+ "print(f\"Job ID: {job_id}\")\n",
+ "\n",
+ "display_JSON(job_response)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "40",
+ "metadata": {},
+ "source": [
+ "## 7. Submit the job and monitor the status"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "41",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "client.jobs.submit(job_id)\n",
+ "print(f\"✅ Job {job_id} submitted successfully!\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "42",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.notebooks_utils.api.job import wait_for_jobs_to_finish_async\n",
+ "\n",
+ "await wait_for_jobs_to_finish_async(client.jobs, [job_id], poll_interval=POLL_INTERVAL)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "43",
+ "metadata": {},
+ "source": [
+ "## 8. Retrieve and visualize results\n",
+ "### 8.1. Schottky barrier heights"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "44",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "job_data = client.jobs.get(job_id)\n",
+ "job_scope = {key: value for item in job_data[\"scopeTrack\"] for key, value in item[\"scope\"][\"global\"].items()}\n",
+ "\n",
+ "print(f\"Valence band maximum (semiconductor): {job_scope['VBM']:.3f} eV\")\n",
+ "print(f\"Band gap: {job_scope['BAND_GAP']:.3f} eV\")\n",
+ "print(f\"p-type Schottky barrier height: {job_scope['SCHOTTKY_BARRIER_P']:.3f} eV\")\n",
+ "print(f\"n-type Schottky barrier height: {job_scope['SCHOTTKY_BARRIER_N']:.3f} eV\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "45",
+ "metadata": {},
+ "source": [
+ "### 8.2. Average ESP profiles"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "46",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.notebooks_utils.ipython.entity.property.visualize import visualize_properties\n",
+ "\n",
+ "avg_esp_results = {}\n",
+ "for subworkflow in job_data[\"workflow\"][\"subworkflows\"]:\n",
+ " for unit in subworkflow[\"units\"]:\n",
+ " if \"average_potential_profile\" in [result[\"name\"] for result in unit.get(\"results\", [])]:\n",
+ " avg_esp_results[subworkflow[\"name\"]] = client.properties.get_for_job(\n",
+ " job_id,\n",
+ " property_name=\"average_potential_profile\",\n",
+ " unit_id=unit[\"flowchartId\"],\n",
+ " )[0]\n",
+ "\n",
+ "for subworkflow_name, avg_esp_data in avg_esp_results.items():\n",
+ " visualize_properties(avg_esp_data, title=subworkflow_name)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "47",
+ "metadata": {},
+ "source": [
+ "### 8.3. Plot the superlattice ESP profile with the block averages\n",
+ "The workflow averages the ESP of the superlattice over one bulk cell at the centre of each block. A block is bulk-like where the macroscopic average is flat on its block average."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "48",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.notebooks_utils.plot import configure_matplotlib_renderer\n",
+ "\n",
+ "configure_matplotlib_renderer()\n",
+ "import matplotlib.pyplot as plt\n",
+ "\n",
+ "interface_profile = avg_esp_results[\"Avg ESP (Interface)\"]\n",
+ "plt.figure(figsize=(10, 6))\n",
+ "plt.plot(interface_profile[\"xDataArray\"], interface_profile[\"yDataSeries\"][1], label=\"Macroscopic Average Potential\", linewidth=2)\n",
+ "for block_name, block_average, color in zip([\"Semiconductor\", \"Metal\"], job_scope[\"AVG_ESP_INTERFACE\"], [\"blue\", \"gold\"]):\n",
+ " plt.axhline(block_average, color=color, linestyle=\":\", linewidth=2, label=f\"{block_name} block average ESP = {block_average:.3f} eV\")\n",
+ "plt.xlabel(\"z-coordinate (A)\", fontsize=12)\n",
+ "plt.ylabel(\"Macroscopic Average Potential (eV)\", fontsize=12)\n",
+ "plt.title(f\"Schottky barrier heights: p-type {job_scope['SCHOTTKY_BARRIER_P']:.3f} eV, n-type {job_scope['SCHOTTKY_BARRIER_N']:.3f} eV\", fontsize=14, fontweight=\"bold\")\n",
+ "plt.legend(loc=\"best\", fontsize=10)\n",
+ "plt.grid(True, alpha=0.3)\n",
+ "plt.tight_layout()\n",
+ "plt.show()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "49",
+ "metadata": {},
+ "source": [
+ "## References\n",
+ "\n",
+ "[1] C. G. Van de Walle and R. M. Martin, \"Theoretical calculations of heterojunction discontinuities in the Si/Ge system\", Phys. Rev. B 34, 5621 (1986). [DOI: 10.1103/PhysRevB.34.5621](https://doi.org/10.1103/PhysRevB.34.5621)\n",
+ "\n",
+ "[2] A. Baldereschi, S. Baroni and R. Resta, \"Band offsets in lattice-matched heterojunctions: a model and first-principles calculations for GaAs/AlAs\", Phys. Rev. Lett. 61, 734 (1988). [DOI: 10.1103/PhysRevLett.61.734](https://doi.org/10.1103/PhysRevLett.61.734)\n",
+ "\n",
+ "[3] P.-Y. Prodhomme, F. Fontaine-Vive, A. Van Der Geest, P. Blaise and J. Even, \"Ab initio calculation of effective work functions for a TiN/HfO2/SiO2/Si transistor stack\", Appl. Phys. Lett. 99, 022101 (2011). [DOI: 10.1063/1.3609869](https://doi.org/10.1063/1.3609869)"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "name": "python",
+ "version": "3.11.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/other/materials_designer/workflows/valence_band_offset_bulk.ipynb b/other/materials_designer/workflows/valence_band_offset_bulk.ipynb
new file mode 100644
index 000000000..67fb03aa3
--- /dev/null
+++ b/other/materials_designer/workflows/valence_band_offset_bulk.ipynb
@@ -0,0 +1,713 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "0",
+ "metadata": {},
+ "source": [
+ "# Valence Band Offset (VBO), Bulk Method\n",
+ "\n",
+ "Calculate the valence band offset of a periodic superlattice of two materials with the bulk method, using a DFT workflow on the Mat3ra platform.\n",
+ "\n",
+ "The valence band maximum of each material is measured from the macroscopically averaged electrostatic potential (ESP) of its own bulk cell, and the superlattice gives the step in the averaged ESP between the centres of the two blocks:\n",
+ "\n",
+ "$$\\Delta E_v = \\left[E_{\\mathrm{VBM}} - \\bar{V}\\right]_{\\mathrm{left}} - \\left[E_{\\mathrm{VBM}} - \\bar{V}\\right]_{\\mathrm{right}} + \\left[\\bar{V}_{\\mathrm{left}} - \\bar{V}_{\\mathrm{right}}\\right]_{\\mathrm{superlattice}}$$\n",
+ "\n",
+ "The offset is positive when the valence band maximum of the left part lies above that of the right part. The bulk cell of each part is built from the interface: one period of the part's crystal along the interface normal, strained as in the interface.\n",
+ "\n",
+ "The result is meaningful when:\n",
+ "\n",
+ "- the interface is a periodic superlattice with no vacuum, and its two interfaces are equivalent;\n",
+ "- each block is at least one bulk cell thick, so that the averaged ESP is flat at its centre (the plot at the end shows it);\n",
+ "- one part holds an element that the other does not, as the blocks are found by element (Si/SiO₂ works, TiO/TiO₂ does not).\n",
+ "\n",
+ "Usage
\n",
+ "\n",
+ "1. Create and save an interface, whose build metadata (`metadata.build`) holds its substrate and film, with `create_interface_with_min_strain_zsl.ipynb`: a superlattice with `INTERFACE_VACUUM = 0.0`, `INTERFACE_DISTANCE` set to the spacing of atomic planes across the interface (for example the mean of the two materials' plane spacings along the normal), and each part at least one layer thick.\n",
+ "1. Set the interface and calculation parameters in cells 1.2 and 1.3 below.\n",
+ "1. Click \"Run\" > \"Run All\" to run all cells.\n",
+ "1. Wait for the job to complete.\n",
+ "1. Scroll down to view the VBO result.\n",
+ "\n",
+ "## Summary\n",
+ "\n",
+ "1. Set up the environment and parameters: install packages (JupyterLite only) and configure parameters for the interface, workflow, compute resources, and job.\n",
+ "1. Authenticate and initialize API client: authenticate via browser, initialize the client, then select account and project.\n",
+ "1. Create materials: load an interface from the `../uploads` folder, build the bulk cells of its left and right parts from the interface's build metadata (`metadata.build`), strip the interface labels not compatible with Quantum ESPRESSO, and save all three materials to the platform tagged with the interface name.\n",
+ "1. Configure workflow: select application, load the VBO (Bulk Method) workflow from Standata, set model and computational parameters with a k-grid per material, and preview the workflow.\n",
+ "1. Configure compute: get list of clusters and create compute configuration with selected cluster, queue, and number of processors.\n",
+ "1. Create the job with materials and workflow configuration: assemble the job from materials, workflow, project, and compute configuration.\n",
+ "1. Submit the job and monitor the status: submit the job and wait for completion.\n",
+ "1. Retrieve results: get and display the valence band offset, the average ESP profiles, and the superlattice ESP with the two block averages."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "1",
+ "metadata": {},
+ "source": [
+ "## 1. Set up the environment and parameters\n",
+ "### 1.1. Install packages (JupyterLite)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "2",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.notebooks_utils.packages import install_packages\n",
+ "\n",
+ "await install_packages(\"made|api_examples\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "3",
+ "metadata": {},
+ "source": [
+ "### 1.2. Set parameters\n",
+ "Provide the INTERFACE_NAME to match the name of the structure in \"uploads\" folder for search. `LEFT_SIDE_PART` and `RIGHT_SIDE_PART` select the substrate or the film of the interface's build metadata (`metadata.build`)."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "4",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from datetime import datetime\n",
+ "from mat3ra.ide.compute import QueueName\n",
+ "from mat3ra.made.tools.convert.interface_parts_enum import InterfacePartsEnum\n",
+ "\n",
+ "# 2. Auth and organization parameters\n",
+ "ORGANIZATION_NAME = None\n",
+ "\n",
+ "# 3. Material parameters\n",
+ "FOLDER = \"../uploads\"\n",
+ "INTERFACE_NAME = \"Interface\" # To search for in \"uploads\" folder, account's materials, then Standata\n",
+ "RELAXED_INTERFACE_NAME = None # To search for in \"uploads\" folder, account's materials, then Standata. Defaults to the interface\n",
+ "LEFT_SIDE_PART = InterfacePartsEnum.SUBSTRATE\n",
+ "RIGHT_SIDE_PART = InterfacePartsEnum.FILM\n",
+ "INTERFACE_SYSTEM_NAME = None # Used as tag to group the materials. Defaults to shorthand from the loaded interface name\n",
+ "\n",
+ "# 4. Workflow parameters\n",
+ "APPLICATION_NAME = \"espresso\"\n",
+ "WORKFLOW_SEARCH_TERM = \"valence_band_offset_bulk.json\"\n",
+ "MY_WORKFLOW_NAME = \"VBO Bulk\"\n",
+ "\n",
+ "# 5. Compute parameters\n",
+ "CLUSTER_NAME = None\n",
+ "QUEUE_NAME = QueueName.D\n",
+ "PPN = 1\n",
+ "\n",
+ "# 6. Job parameters\n",
+ "timestamp = datetime.now().strftime(\"%Y-%m-%d %H:%M\")\n",
+ "POLL_INTERVAL = 60 # seconds"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "5",
+ "metadata": {},
+ "source": [
+ "### 1.3. Set specific VBO parameters\n",
+ "The k-grids of the superlattice and of the two bulk cells follow from one k-point density, so all three are sampled alike."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "6",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Method parameters\n",
+ "PSEUDOPOTENTIAL_TYPE = \"us\" # \"us\" (ultrasoft), \"nc\" (norm-conserving), \"paw\"\n",
+ "FUNCTIONAL = \"pbe\" # for gga: \"pbe\", \"pbesol\"; for lda: \"pz\"\n",
+ "MODEL_SUBTYPE = \"gga\"\n",
+ "\n",
+ "# K-grid and k-path\n",
+ "KPOINT_DENSITY = 3.5 # points per Å⁻¹ of reciprocal length\n",
+ "KPATH = None # e.g. [{\"point\": \"Γ\", \"steps\": 20}, {\"point\": \"X\", \"steps\": 20}]\n",
+ "\n",
+ "# Set SCF diagonalization and mixing in QE input\n",
+ "ADDITIONAL_PARAMETERS = {\"electrons\":\n",
+ " {\n",
+ " \"diagonalization\": \"david\", # \"david\" or \"cg\"\n",
+ " \"mixing_beta\": 0.3\n",
+ " }\n",
+ "}\n",
+ "\n",
+ "# Energy cutoffs\n",
+ "ECUTWFC = 40\n",
+ "ECUTRHO = 200"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "7",
+ "metadata": {},
+ "source": [
+ "## 2. Authenticate and initialize API client\n",
+ "### 2.1. Authenticate\n",
+ "Authenticate in the browser and have credentials stored in environment variable \"OIDC_ACCESS_TOKEN\"."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "8",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.notebooks_utils.auth import authenticate\n",
+ "\n",
+ "await authenticate()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "9",
+ "metadata": {},
+ "source": [
+ "### 2.2. Initialize API client"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "10",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.api_client import APIClient\n",
+ "\n",
+ "client = APIClient.authenticate()\n",
+ "client"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "11",
+ "metadata": {},
+ "source": [
+ "### 2.3. Select account"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "12",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "client.list_accounts()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "13",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "selected_account = client.my_account\n",
+ "\n",
+ "if ORGANIZATION_NAME:\n",
+ " selected_account = client.get_account(name=ORGANIZATION_NAME)\n",
+ "\n",
+ "ACCOUNT_ID = selected_account.id\n",
+ "print(f\"✅ Selected account ID: {ACCOUNT_ID}, name: {selected_account.name}\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "14",
+ "metadata": {},
+ "source": [
+ "### 2.4. Select project"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "15",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "projects = client.projects.list({\"isDefault\": True, \"owner._id\": ACCOUNT_ID})\n",
+ "project_id = projects[0][\"_id\"]\n",
+ "print(f\"✅ Using project: {projects[0]['name']} ({project_id})\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "16",
+ "metadata": {},
+ "source": [
+ "## 3. Create materials\n",
+ "### 3.1. Load interface from local folder"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "17",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.notebooks_utils.core.entity.material.api import load_material\n",
+ "from mat3ra.notebooks_utils.ipython.entity.material.visualize import visualize_materials as visualize\n",
+ "\n",
+ "interface = load_material(client, FOLDER, INTERFACE_NAME, ACCOUNT_ID)\n",
+ "relaxed_interface = load_material(client, FOLDER, RELAXED_INTERFACE_NAME, ACCOUNT_ID) if RELAXED_INTERFACE_NAME else interface\n",
+ "\n",
+ "visualize(relaxed_interface, repetitions=[1, 1, 1])\n",
+ "visualize(relaxed_interface, repetitions=[1, 1, 1], rotation=\"-90x\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "18",
+ "metadata": {},
+ "source": [
+ "### 3.2. Create materials from interface parts\n",
+ "The bulk cell of each part is built from the build metadata (`metadata.build`) of `INTERFACE_NAME`: one period of the part's crystal along the interface normal, strained as in the interface. With `RELAXED_INTERFACE_NAME` set, the bulk cells keep the unrelaxed interface's strain and height along the normal. Each bulk cell's in-plane cell can differ from the interface's. The interface labels are removed as they are not compatible with Quantum ESPRESSO. The three materials (interface, left bulk, right bulk) are named and visualized."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "19",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import re\n",
+ "from mat3ra.made.tools.analyze.interface_material import create_interface_bulk_cell\n",
+ "\n",
+ "interface_shorthand_match = re.match(r\"^(.+?)\\s\", interface.name)\n",
+ "interface_system_name = INTERFACE_SYSTEM_NAME or (\n",
+ " interface_shorthand_match.group(1) if interface_shorthand_match else INTERFACE_NAME\n",
+ ")\n",
+ "left_material = create_interface_bulk_cell(interface, LEFT_SIDE_PART)\n",
+ "right_material = create_interface_bulk_cell(interface, RIGHT_SIDE_PART)\n",
+ "interface_material = relaxed_interface.clone()\n",
+ "\n",
+ "interface_material.basis.set_labels_from_list([])\n",
+ "\n",
+ "left_material.name = f\"{interface_material.name} Left Bulk\"\n",
+ "right_material.name = f\"{interface_material.name} Right Bulk\"\n",
+ "\n",
+ "materials_by_role = {\"interface\": interface_material, \"left\": left_material, \"right\": right_material}\n",
+ "for role, material in materials_by_role.items():\n",
+ " print(f\" {role}: {material.name}\")\n",
+ "visualize(list(materials_by_role.values()), repetitions=[1, 1, 1], rotation=\"-90x\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "20",
+ "metadata": {},
+ "source": [
+ "### 3.3. Save materials"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "21",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.made.material import Material\n",
+ "from mat3ra.notebooks_utils.core.entity.material.api import get_or_create_material\n",
+ "\n",
+ "saved_materials = {}\n",
+ "for role, material in materials_by_role.items():\n",
+ " saved_response = get_or_create_material(client, material, ACCOUNT_ID)\n",
+ " saved = Material.create(saved_response)\n",
+ " tags = sorted({*(saved_response.get(\"tags\") or []), interface_system_name})\n",
+ " client.materials.update(saved.id, {\"tags\": tags})\n",
+ " saved_materials[role] = saved\n",
+ " print(f\" {role}: {saved.name} ({saved.id}) | tags={tags}\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "22",
+ "metadata": {},
+ "source": [
+ "## 4. Configure workflow\n",
+ "### 4.1. Select application"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "23",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.ade.application import Application\n",
+ "from mat3ra.standata.applications import ApplicationStandata\n",
+ "\n",
+ "app_config = ApplicationStandata.get_by_name_first_match(APPLICATION_NAME)\n",
+ "app = Application(**app_config)\n",
+ "print(f\"Using application: {app.name}\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "24",
+ "metadata": {},
+ "source": [
+ "### 4.2. Load workflow from Standata and preview it"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "25",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.standata.workflows import WorkflowStandata\n",
+ "from mat3ra.wode.workflows import Workflow\n",
+ "from mat3ra.notebooks_utils.ipython.entity.workflow.visualize import visualize_workflow\n",
+ "\n",
+ "workflow_config = WorkflowStandata.filter_by_application(app.name).get_by_name_first_match(WORKFLOW_SEARCH_TERM)\n",
+ "workflow = Workflow.create(workflow_config)\n",
+ "\n",
+ "workflow.name = MY_WORKFLOW_NAME\n",
+ "\n",
+ "visualize_workflow(workflow)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "26",
+ "metadata": {},
+ "source": [
+ "### 4.3. Set model and its parameters (physics)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "27",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.mode import ModelFactory\n",
+ "from mat3ra.standata.model_tree import ModelTreeStandata\n",
+ "\n",
+ "model_config = ModelTreeStandata.get_model_by_parameters(\n",
+ " type=\"dft\", subtype=MODEL_SUBTYPE, functional=FUNCTIONAL\n",
+ ")\n",
+ "model_config[\"method\"] = {\"type\": \"pseudopotential\", \"subtype\": PSEUDOPOTENTIAL_TYPE}\n",
+ "model = ModelFactory.create(model_config)\n",
+ "\n",
+ "for subworkflow in workflow.subworkflows:\n",
+ " if subworkflow.application.name == APPLICATION_NAME:\n",
+ " subworkflow.model = model"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "28",
+ "metadata": {},
+ "source": [
+ "### 4.4. Modify method (computational parameters): k-grid per material, k-path, cutoffs, diagonalization, and mixing\n",
+ "Each Quantum ESPRESSO subworkflow runs on the material its \"Set Material Index\" unit selects, the superlattice when it has none, and gets the k-grid of that material at `KPOINT_DENSITY`."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "29",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.wode.context.providers import PointsGridDataProvider, PointsPathDataProvider\n",
+ "from mat3ra.notebooks_utils.workflow import apply_planewave_cutoffs, kgrid_from_density, patch_workflow_qe_input\n",
+ "\n",
+ "scf_unit_names = [\"pw_scf\", \"pw_bands\"]\n",
+ "materials = list(materials_by_role.values())\n",
+ "\n",
+ "for subworkflow in workflow.subworkflows:\n",
+ " if subworkflow.application.name != APPLICATION_NAME:\n",
+ " continue\n",
+ " material_index = int(next((unit.value for unit in subworkflow.units if unit.name.startswith(\"Set Material Index\")), 0))\n",
+ " material = materials[material_index]\n",
+ " kgrid = kgrid_from_density(material, KPOINT_DENSITY)\n",
+ " unit = subworkflow.get_unit_by_name(name=\"pw_scf\")\n",
+ " unit.add_context(PointsGridDataProvider(material=material, dimensions=kgrid, isEdited=True).get_context_item_data())\n",
+ " subworkflow.set_unit(unit)\n",
+ " print(f\" {subworkflow.name}: {material.name}, k-grid {kgrid}\")\n",
+ "\n",
+ "if KPATH is not None:\n",
+ " for subworkflow in workflow.subworkflows:\n",
+ " if unit := subworkflow.get_unit_by_name(name=\"pw_bands\"):\n",
+ " unit.add_context(PointsPathDataProvider(path=KPATH, isEdited=True).get_context_item_data())\n",
+ " subworkflow.set_unit(unit)\n",
+ "\n",
+ "if ECUTWFC is not None:\n",
+ " for unit_name in scf_unit_names:\n",
+ " apply_planewave_cutoffs(workflow, ECUTWFC, ECUTRHO, unit_name=unit_name)\n",
+ "\n",
+ "if ADDITIONAL_PARAMETERS:\n",
+ " patch_workflow_qe_input(workflow, ADDITIONAL_PARAMETERS, unit_names=scf_unit_names)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "30",
+ "metadata": {},
+ "source": [
+ "### 4.5. Preview final workflow"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "31",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "visualize_workflow(workflow)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "32",
+ "metadata": {},
+ "source": [
+ "## 5. Create the compute configuration\n",
+ "### 5.1. Get list of clusters"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "33",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "clusters = client.clusters.list()\n",
+ "print(f\"Available clusters: {[c['hostname'] for c in clusters]}\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "34",
+ "metadata": {},
+ "source": [
+ "### 5.2. Create compute configuration"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "35",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.ide.compute import Compute\n",
+ "\n",
+ "if CLUSTER_NAME:\n",
+ " cluster = next((c for c in clusters if CLUSTER_NAME in c[\"hostname\"]), None)\n",
+ "else:\n",
+ " cluster = clusters[0]\n",
+ "\n",
+ "compute = Compute(\n",
+ " cluster=cluster,\n",
+ " queue=QUEUE_NAME,\n",
+ " ppn=PPN\n",
+ ")\n",
+ "print(f\"Using cluster: {compute.cluster.hostname}, queue: {QUEUE_NAME}, ppn: {PPN}\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "36",
+ "metadata": {},
+ "source": [
+ "## 6. Create the job\n",
+ "### 6.1. Create job"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "37",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.notebooks_utils.job import create_job\n",
+ "from mat3ra.utils.namespace import dict_to_namespace_recursive\n",
+ "from mat3ra.notebooks_utils.ui import display_JSON\n",
+ "\n",
+ "materials = list(saved_materials.values())\n",
+ "\n",
+ "job_name = f\"{MY_WORKFLOW_NAME} {interface_system_name} {timestamp}\"\n",
+ "workflow.name = job_name\n",
+ "\n",
+ "print(f\"Materials: {[m.id for m in materials]}\")\n",
+ "print(f\"Project: {project_id}\")\n",
+ "\n",
+ "job_response = create_job(\n",
+ " api_client=client,\n",
+ " materials=materials,\n",
+ " workflow=workflow,\n",
+ " project_id=project_id,\n",
+ " owner_id=ACCOUNT_ID,\n",
+ " prefix=job_name,\n",
+ " compute=compute.to_dict(),\n",
+ ")\n",
+ "\n",
+ "job = dict_to_namespace_recursive(job_response)\n",
+ "job_id = job._id\n",
+ "print(\"✅ Job created successfully!\")\n",
+ "print(f\"Job ID: {job_id}\")\n",
+ "\n",
+ "display_JSON(job_response)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "38",
+ "metadata": {},
+ "source": [
+ "## 7. Submit the job and monitor the status"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "39",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "client.jobs.submit(job_id)\n",
+ "print(f\"✅ Job {job_id} submitted successfully!\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "40",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.notebooks_utils.api.job import wait_for_jobs_to_finish_async\n",
+ "\n",
+ "await wait_for_jobs_to_finish_async(client.jobs, [job_id], poll_interval=POLL_INTERVAL)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "41",
+ "metadata": {},
+ "source": [
+ "## 8. Retrieve and visualize results\n",
+ "### 8.1. Valence Band Offset and average ESP profiles"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "42",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.prode import PropertyName\n",
+ "from mat3ra.notebooks_utils.ipython.entity.property.visualize import visualize_properties\n",
+ "\n",
+ "job_data = client.jobs.get(job_id)\n",
+ "job_scope = {key: value for item in job_data[\"scopeTrack\"] for key, value in item[\"scope\"][\"global\"].items()}\n",
+ "\n",
+ "vbo_value = client.properties.get_for_job(\n",
+ " job_id,\n",
+ " property_name=PropertyName.scalar.valence_band_offset.value,\n",
+ ")[0]\n",
+ "print(f\"Valence Band Offset (VBO): {float(vbo_value['value']):.3f} eV\")\n",
+ "\n",
+ "avg_esp_results = {}\n",
+ "for subworkflow in job_data[\"workflow\"][\"subworkflows\"]:\n",
+ " for unit in subworkflow[\"units\"]:\n",
+ " if \"average_potential_profile\" in [result[\"name\"] for result in unit.get(\"results\", [])]:\n",
+ " avg_esp_results[subworkflow[\"name\"]] = client.properties.get_for_job(\n",
+ " job_id,\n",
+ " property_name=\"average_potential_profile\",\n",
+ " unit_id=unit[\"flowchartId\"],\n",
+ " )[0]\n",
+ "\n",
+ "for subworkflow_name, avg_esp_data in avg_esp_results.items():\n",
+ " visualize_properties(avg_esp_data, title=subworkflow_name)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "43",
+ "metadata": {},
+ "source": [
+ "### 8.2. Plot the superlattice ESP profile with the block averages\n",
+ "The workflow averages the ESP of the superlattice over one bulk cell at the centre of each block. A block is bulk-like where the macroscopic average is flat on its block average."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "44",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from mat3ra.notebooks_utils.plot import configure_matplotlib_renderer\n",
+ "\n",
+ "configure_matplotlib_renderer()\n",
+ "import matplotlib.pyplot as plt\n",
+ "\n",
+ "interface_profile = avg_esp_results[\"Avg ESP (Interface)\"]\n",
+ "plt.figure(figsize=(10, 6))\n",
+ "plt.plot(interface_profile[\"xDataArray\"], interface_profile[\"yDataSeries\"][1], label=\"Macroscopic Average Potential\", linewidth=2)\n",
+ "for block_name, block_average, color in zip([\"Left\", \"Right\"], job_scope[\"AVG_ESP_INTERFACE\"], [\"gold\", \"blue\"]):\n",
+ " plt.axhline(block_average, color=color, linestyle=\":\", linewidth=2, label=f\"{block_name} block average ESP = {block_average:.3f} eV\")\n",
+ "plt.xlabel(\"z-coordinate (A)\", fontsize=12)\n",
+ "plt.ylabel(\"Macroscopic Average Potential (eV)\", fontsize=12)\n",
+ "plt.title(f\"Valence band offset: {float(vbo_value['value']):.3f} eV\", fontsize=14, fontweight=\"bold\")\n",
+ "plt.legend(loc=\"best\", fontsize=10)\n",
+ "plt.grid(True, alpha=0.3)\n",
+ "plt.tight_layout()\n",
+ "plt.show()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "45",
+ "metadata": {},
+ "source": [
+ "## References\n",
+ "\n",
+ "[1] C. G. Van de Walle and R. M. Martin, \"Theoretical calculations of heterojunction discontinuities in the Si/Ge system\", Phys. Rev. B 34, 5621 (1986). [DOI: 10.1103/PhysRevB.34.5621](https://doi.org/10.1103/PhysRevB.34.5621)\n",
+ "\n",
+ "[2] A. Baldereschi, S. Baroni and R. Resta, \"Band offsets in lattice-matched heterojunctions: a model and first-principles calculations for GaAs/AlAs\", Phys. Rev. Lett. 61, 734 (1988). [DOI: 10.1103/PhysRevLett.61.734](https://doi.org/10.1103/PhysRevLett.61.734)"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "name": "python",
+ "version": "3.11.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/pyproject.toml b/pyproject.toml
index e47864a68..4427f13eb 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -21,7 +21,7 @@ jupyterlite = [
]
utils_standata = [
"mat3ra-utils",
- "mat3ra-standata",
+ "mat3ra-standata @ git+https://github.com/mat3ra/standata.git@0086c44c7792f31ead7f7f9928bc34bf67d3792e", # standata #173; unpin on release
]
api = [
"mat3ra-api-client>=2026.11.4.post0",
@@ -36,7 +36,7 @@ materials = [
"mat3ra-notebooks-utils[utils_standata]",
"pymatgen==2024.4.13",
"pymatgen-analysis-defects<=2024.4.23",
- "mat3ra-made",
+ "mat3ra-made @ git+https://github.com/mat3ra/made.git@47b54d9214d729ffdc6f0b2c99c72b3b6981fd20", # made #308; unpin on release
"mat3ra-periodic-table"
]
workflows = [