Skip to content

Commit

Permalink
Add more examples (#39)
Browse files Browse the repository at this point in the history
* Add second example

* Add vacancy detection example

* Add example to set point defects
  • Loading branch information
NinadBhat authored Jul 15, 2024
1 parent 891ea44 commit 63de4dd
Show file tree
Hide file tree
Showing 5 changed files with 423 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.pyc
*.pyc
.ipynb_checkpoints
2 changes: 1 addition & 1 deletion examples/1_Getting_Started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"metadata": {},
"source": [
"## Annoate Crystal Structure \n",
"Is identified crystal structures is satisfactory add information to the knowledge graph"
"If identified crystal structures is satisfactory add information to the knowledge graph"
]
},
{
Expand Down
104 changes: 104 additions & 0 deletions examples/2_Setting_Crystal_Structure.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from atomid.annotate import AnnotateCrystal"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Read crystal structure file"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"file_path = \"../tests/data/fcc/Al/no_defect/Al.cif\"\n",
"\n",
"annotate_crystal = AnnotateCrystal()\n",
"\n",
"annotate_crystal.read_crystal_structure_file(file_path)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set Crystal Structure Manually"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"annotate_crystal.set_crystal_structure(\"fcc\")\n",
"annotate_crystal.set_lattice_constant(4.5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Annoate Crystal Structure \n",
"Add information to the knowledge graph"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"annotate_crystal.annotate_crystal_structure()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Write ouput crystal structure file"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"annotate_crystal.write_to_file(\"crystal_kg.ttl\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "atomid-venv",
"language": "python",
"name": "atomid-venv"
},
"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.9.18"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
153 changes: 153 additions & 0 deletions examples/3_Identify_Point_Defects.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from atomid.annotate import AnnotateCrystal"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Read crystal structure file"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"file_path = \"../tests/data/fcc/Al/defect/vacancy/Al_vacancy.cif\"\n",
"\n",
"annotate_crystal_vacancy = AnnotateCrystal()\n",
"\n",
"annotate_crystal_vacancy.read_crystal_structure_file(file_path)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Identify and Annotate Crystal Structure"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[92mCrystal structure: fcc\u001b[0m\n",
"\u001b[92mLattice constant: 4.05\u001b[0m\n"
]
}
],
"source": [
"# Identify the crystal structure\n",
"annotate_crystal_vacancy.identify_crystal_structure()\n",
"\n",
"# Annotate the crystal structure\n",
"annotate_crystal_vacancy.annotate_crystal_structure()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Identify Point defects\n",
"Point defects are identified using the Wigner-Seitz algorithm, which requires a reference file structure for identification."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[92mIdentified defects:\u001b[0m\n",
"\u001b[92mvacancies:\u001b[0m Count: 40 Concentration: 0.01\n"
]
}
],
"source": [
"ref_file = \"../tests/data/fcc/Al/no_defect/Al.cif\"\n",
"\n",
"# Identify point defects using the reference file\n",
"annotate_crystal_vacancy.identify_point_defects(\n",
" reference_data_file=ref_file, ref_format=\"cif\"\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Add information to Knowledge graph"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"annotate_crystal_vacancy.annotate_point_defects()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Write ouput crystal structure file"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"annotate_crystal_vacancy.write_to_file(\"crystal_kg.ttl\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "atomid-venv",
"language": "python",
"name": "atomid-venv"
},
"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.9.18"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit 63de4dd

Please sign in to comment.