-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b21902b
Showing
4 changed files
with
259 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Periodic Boundary Exercise | ||
For this exercise we use [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/eisenforschung/periodic-boundary-exercise/master?filepath=periodic-boundary-exercise.ipynb). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
channels: | ||
- conda-forge | ||
dependencies: | ||
- python | ||
- nglview | ||
- ase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# ngl view for jupyter | ||
jupyter nbextension install nglview --py --sys-prefix | ||
jupyter nbextension enable nglview --py --sys-prefix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,248 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Task \n", | ||
"Your task is to calculate the distance of two carbon atoms in an iron matrix, considering periodic boundaries. " | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Code" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Import required packages " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2018-10-15T13:11:35.806990Z", | ||
"start_time": "2018-10-15T13:11:35.380379Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from ase.build import bulk\n", | ||
"import nglview\n", | ||
"import numpy as np" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Function to display atoms" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2018-10-15T13:11:35.812039Z", | ||
"start_time": "2018-10-15T13:11:35.809040Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"def display_atoms(atoms):\n", | ||
" view = nglview.show_ase(atoms)\n", | ||
" view.add_unitcell()\n", | ||
" view.add_spacefill()\n", | ||
" view.remove_ball_and_stick()\n", | ||
" return view" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Create iron bluk matrix (without periodic boundaries)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2018-10-15T13:11:35.851979Z", | ||
"start_time": "2018-10-15T13:11:35.813910Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"basis = bulk(name='Fe', cubic=True)\n", | ||
"basis_repeated = basis.repeat([5,5,5])\n", | ||
"display_atoms(basis_repeated)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Place carbon substitutionals in iron matrix" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2018-10-15T13:11:35.920721Z", | ||
"start_time": "2018-10-15T13:11:35.853850Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"element_lst = basis_repeated.get_chemical_symbols()\n", | ||
"element_lst[0] = 'C'\n", | ||
"element_lst[-1] = 'C'\n", | ||
"basis_repeated.set_chemical_symbols(element_lst)\n", | ||
"display_atoms(basis_repeated)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Helpful properties" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2018-10-15T13:11:35.946702Z", | ||
"start_time": "2018-10-15T13:11:35.922524Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"basis_repeated.positions" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2018-10-15T13:11:35.959564Z", | ||
"start_time": "2018-10-15T13:11:35.948609Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"basis_repeated.cell" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2018-10-15T13:11:35.973154Z", | ||
"start_time": "2018-10-15T13:11:35.961340Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"basis_repeated.get_chemical_symbols()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2018-10-15T13:11:35.982864Z", | ||
"start_time": "2018-10-15T13:11:35.975066Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"elements_array = np.array(basis_repeated.get_chemical_symbols())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2018-10-15T13:11:35.992908Z", | ||
"start_time": "2018-10-15T13:11:35.984732Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"selection_index = elements_array=='C'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2018-10-15T13:11:36.090524Z", | ||
"start_time": "2018-10-15T13:11:35.994789Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"basis_repeated.positions[selection_index]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python [default]", | ||
"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.5.5" | ||
}, | ||
"toc": { | ||
"base_numbering": 1, | ||
"nav_menu": {}, | ||
"number_sections": true, | ||
"sideBar": true, | ||
"skip_h1_title": false, | ||
"title_cell": "Table of Contents", | ||
"title_sidebar": "Contents", | ||
"toc_cell": false, | ||
"toc_position": {}, | ||
"toc_section_display": true, | ||
"toc_window_display": false | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |