-
Notifications
You must be signed in to change notification settings - Fork 5
Prototype: Bandgap Workflow NB #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,192 @@ | ||
| { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line #1. from mat3ra.wode.analyzers.electronic import KPointAnalyzer, CutoffAnalyzer, SmearingAnalyzer, BandsAnalyzer These are called context providers at current, not analyzers, but the concept is similar Reply via ReviewNB
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line #4. workflow = BandStructureWorkflow()
Reply via ReviewNB |
||
| "cells": [ | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "# Bandgap Workflow Example\n", | ||
| " This notebook demonstrates how to build and run a bandgap workflow for a material.\n", | ||
| "\n", | ||
| "## Process Overview\n", | ||
| "### 1. Set up the environment and parameters.\n", | ||
| "### 1. Log in to get the API token\n", | ||
| "### 1. Load the target material.\n", | ||
| "### 1. Import workflow builder and related analyzers.\n", | ||
| "### 1. Analyze material to get parameters for the workflow configuration.\n", | ||
| "### 1. Create the workflow configuration.\n", | ||
| "### 1. Create a job with material and workflow configuration.\n", | ||
| "### 1. Submit the job to the server.\n", | ||
| "### 1. Monitor the job status and retrieve results." | ||
| ], | ||
| "id": "ed24b225263ae3c3" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 1. Set up the environment and parameters", | ||
| "id": "598da5f8c4f507ec" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 2. Log in to get the API token", | ||
| "id": "51105b005c535ca" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "from mat3ra.api import ApiClient\n", | ||
| "# Log in to get the API token\n", | ||
| "auth_config = await ApiClient().login()" | ||
| ], | ||
| "id": "23626cb27f6e7206", | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 3. Load the target material", | ||
| "id": "ba816c64f28f6a3d" | ||
| }, | ||
| { | ||
| "metadata": { | ||
| "collapsed": true | ||
| }, | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "from utils.visualize import visualize_materials as visualize\n", | ||
| "from utils.jupyterlite import load_material_from_folder\n", | ||
| "\n", | ||
| "material = load_material_from_folder(\"/uploads\", \"MoS2_twisted_interface_60_degrees.json\")\n", | ||
| "visualize(material)" | ||
| ], | ||
| "id": "initial_id", | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 4. Import workflow builder and related analyzers", | ||
| "id": "f8d7e25a7c9cc2e" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "from mat3ra.wode.analyzers.electronic import KPointAnalyzer, CutoffAnalyzer, SmearingAnalyzer, BandsAnalyzer\n", | ||
| "\n", | ||
| "kpoint_analyzer = KPointAnalyzer(material=material)\n", | ||
| "cutoff_analyzer = CutoffAnalyzer(material=material)\n", | ||
| "smearing_analyzer = SmearingAnalyzer(material=material)\n", | ||
| "bands_analyzer = BandsAnalyzer(material=material)\n", | ||
| "\n", | ||
| "kpoints = kpoint_analyzer.get_kpoints()\n", | ||
| "cutoff = cutoff_analyzer.get_cutoff()\n", | ||
| "smearing = smearing_analyzer.get_smearing()\n", | ||
| "number_of_bands = bands_analyzer.get_number_of_bands()" | ||
| ], | ||
| "id": "5ead702c417eff62", | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 5. Create workflow and set its parameters", | ||
| "id": "9bdd00f870caaeeb" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "from mat3ra.standata.workflows import Workflows\n", | ||
| "from mat3ra.wode.workflows import Workflow\n", | ||
| "from mat3ra.wode.pseudopotentials import PseudopotentialEnum\n", | ||
| "\n", | ||
| "workflow_config = Workflows.get_by_name_first_match(\"band_structure\")\n", | ||
| "workflow = Workflow.create(workflow_config)\n", | ||
| "workflow.set_kpoints(kpoints)\n", | ||
| "workflow.set_pseudopotential(PseudopotentialEnum.PAW_HSE) # elements will be set automatically based on the material" | ||
| ], | ||
| "id": "68d43f6c797f2fc4", | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 6. Create the job configuration", | ||
| "id": "1f15e054ddb9a08c" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "from mat3ra.wode.compute import ComputeConfiguration, QueueEnum\n", | ||
| "compute_config = ComputeConfiguration(\n", | ||
| " queue = QueueEnum.OR8,\n", | ||
| " nodes = 1,\n", | ||
| " cores = 8,\n", | ||
| ")" | ||
| ], | ||
| "id": "60e880dc581dafe1", | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "markdown", | ||
| "source": "## 7. Submit the job and monitor the status", | ||
| "id": "8d5740e099512107" | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "from mat3ra.wode.job import create_job\n", | ||
| "job = create_job(workflow=workflow, material=material, compute = compute_config, auth_config=auth_config)\n", | ||
| "job.run()\n", | ||
| "job.wait_for_complete()\n", | ||
| "# job.check_status()\n", | ||
| "# job.get_current_output()\n", | ||
| "# AFTER Finished\n", | ||
| "job.get_results(PropertyEnum.BANDGAP)" | ||
| ], | ||
| "id": "53c8a2cd99e5c26d", | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "metadata": {}, | ||
| "cell_type": "code", | ||
| "outputs": [], | ||
| "execution_count": null, | ||
| "source": "", | ||
| "id": "978bb38b10c15976" | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "kernelspec": { | ||
| "display_name": "Python 3", | ||
| "language": "python", | ||
| "name": "python3" | ||
| }, | ||
| "language_info": { | ||
| "codemirror_mode": { | ||
| "name": "ipython", | ||
| "version": 2 | ||
| }, | ||
| "file_extension": ".py", | ||
| "mimetype": "text/x-python", | ||
| "name": "python", | ||
| "nbconvert_exporter": "python", | ||
| "pygments_lexer": "ipython2", | ||
| "version": "2.7.6" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to import compute from
mat3ra.ideand create amat3ra.jodefor job designReply via ReviewNB