Skip to content

Commit 9242fe6

Browse files
committed
update: bandgap nb prototype (wip)
1 parent fa70d51 commit 9242fe6

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{
2+
"cells": [
3+
{
4+
"metadata": {},
5+
"cell_type": "markdown",
6+
"source": [
7+
"# Bandgap Workflow Example\n",
8+
" This notebook demonstrates how to build and run a bandgap workflow for a material.\n",
9+
"\n",
10+
"## Process Overview\n",
11+
"### 1. Set up the environment and parameters.\n",
12+
"### 2. Load the target material.\n",
13+
"### 3. Import workflow builder and related analyzers.\n",
14+
"### 4. Analyze material to get parameters for the workflow configuration.\n",
15+
"### 5. Create the workflow configuration.\n",
16+
"### 6. Create a job with material and workflow configuration.\n",
17+
"### 7. Log in to get the API token\n",
18+
"### 8. Submit the job to the server.\n",
19+
"### 9. Monitor the job status and retrieve results."
20+
],
21+
"id": "ed24b225263ae3c3"
22+
},
23+
{
24+
"cell_type": "code",
25+
"id": "initial_id",
26+
"metadata": {
27+
"collapsed": true
28+
},
29+
"source": [
30+
"from utils.visualize import visualize_materials as visualize\n",
31+
"from utils.jupyterlite import load_material_from_folder\n",
32+
"\n",
33+
"material = load_material_from_folder(\"/uploads\", \"MoS2_twisted_interface_60_degrees.json\")\n",
34+
"visualize(material)"
35+
],
36+
"outputs": [],
37+
"execution_count": null
38+
},
39+
{
40+
"metadata": {},
41+
"cell_type": "code",
42+
"source": [
43+
"from mat3ra.api import ApiClient\n",
44+
"# Log in to get the API token\n",
45+
"auth_config = await ApiClient().login()"
46+
],
47+
"id": "23626cb27f6e7206",
48+
"outputs": [],
49+
"execution_count": null
50+
},
51+
{
52+
"metadata": {},
53+
"cell_type": "code",
54+
"outputs": [],
55+
"execution_count": null,
56+
"source": [
57+
"from mat3ra.wode.analyzers.electronic import KPointAnalyzer, CutoffAnalyzer, SmearingAnalyzer, BandsAnalyzer\n",
58+
"\n",
59+
"kpoint_analyzer = KPointAnalyzer(material=material)\n",
60+
"cutoff_analyzer = CutoffAnalyzer(material=material)\n",
61+
"smearing_analyzer = SmearingAnalyzer(material=material)\n",
62+
"bands_analyzer = BandsAnalyzer(material=material)\n",
63+
"\n",
64+
"kpoints = kpoint_analyzer.get_kpoints()\n",
65+
"cutoff = cutoff_analyzer.get_cutoff()\n",
66+
"smearing = smearing_analyzer.get_smearing()\n",
67+
"number_of_bands = bands_analyzer.get_number_of_bands()\n",
68+
"\n"
69+
],
70+
"id": "5ead702c417eff62"
71+
},
72+
{
73+
"metadata": {},
74+
"cell_type": "code",
75+
"outputs": [],
76+
"execution_count": null,
77+
"source": [
78+
"from mat3ra.wode.workflow.vasp import create_vasp_workflow\n",
79+
"\n",
80+
"band_gap_workflow = create_vasp_workflow(\n",
81+
" material=material,\n",
82+
" kpoints=kpoints,\n",
83+
" cutoff=cutoff,\n",
84+
" smearing=smearing,\n",
85+
" number_of_bands=number_of_bands)"
86+
],
87+
"id": "68d43f6c797f2fc4"
88+
},
89+
{
90+
"metadata": {},
91+
"cell_type": "code",
92+
"outputs": [],
93+
"execution_count": null,
94+
"source": [
95+
"from mat3ra.wode.compute import ComputeConfiguration, QueueTypes\n",
96+
"compute_config = ComputeConfiguration(\n",
97+
" queue = QueueTypes.OR8,\n",
98+
" nodes = 1,\n",
99+
" cores = 8,\n",
100+
")"
101+
],
102+
"id": "60e880dc581dafe1"
103+
},
104+
{
105+
"metadata": {},
106+
"cell_type": "code",
107+
"outputs": [],
108+
"execution_count": null,
109+
"source": [
110+
"from mat3ra.wode.job import JobConfiguration, create_job\n",
111+
"job_config = JobConfiguration(workflow=band_gap_workflow, material=material, compute = compute_config)\n",
112+
"job = create_job(job_config, auth_config=auth_config)\n",
113+
"job.run()\n",
114+
"job.wait_for_complete()\n",
115+
"# job.check_status()\n",
116+
"# job.get_current_output()\n",
117+
"# AFTER Finished\n",
118+
"job.get_results(PropertyEnum.BANDGAP)"
119+
],
120+
"id": "53c8a2cd99e5c26d"
121+
}
122+
],
123+
"metadata": {
124+
"kernelspec": {
125+
"display_name": "Python 3",
126+
"language": "python",
127+
"name": "python3"
128+
},
129+
"language_info": {
130+
"codemirror_mode": {
131+
"name": "ipython",
132+
"version": 2
133+
},
134+
"file_extension": ".py",
135+
"mimetype": "text/x-python",
136+
"name": "python",
137+
"nbconvert_exporter": "python",
138+
"pygments_lexer": "ipython2",
139+
"version": "2.7.6"
140+
}
141+
},
142+
"nbformat": 4,
143+
"nbformat_minor": 5
144+
}

0 commit comments

Comments
 (0)