Commit 7389f941 authored by spiasko's avatar spiasko
Browse files

ex11 gelöst

parent f88897db
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -64,19 +64,16 @@ ...@@ -64,19 +64,16 @@
"alpha=90\n", "alpha=90\n",
"beta=99.22\n", "beta=99.22\n",
"gamma=90\n", "gamma=90\n",
"thespacegroup=14\n", "thespacegroup='P 21/c'\n",
"print(Spacegroup(thespacegroup))\n", "print(Spacegroup(thespacegroup))\n",
"\n", "\n",
"hfo2 = crystal(symbols=['Hf','O','O'],\n", "hfo2 = crystal(['Hf','O','O'],basis=[(0.276,0.04,0.208),(0.074,0.332,0.347),(0.449,0.758,0.480)], \n",
" basis=[(0.276,0.04,0.208),(0.074,0.332,0.347),(0.449,0.758,0.480)],\n", " spacegroup=thespacegroup, cellpar=[a, b, c, alpha, beta, gamma])"
" spacegroup=thespacegroup, \n",
" cellpar=[a, b, c, alpha, beta, gamma])\n",
"#hfo2.write('hfo2.xyz')"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -92,13 +89,13 @@ ...@@ -92,13 +89,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "173ee9fd9ff14be7a76bdd69a69afbe2", "model_id": "f9c3ef4efca74690a7d6ac1e4a8d450a",
"version_major": 2, "version_major": 2,
"version_minor": 0 "version_minor": 0
}, },
...@@ -133,7 +130,7 @@ ...@@ -133,7 +130,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -152,7 +149,7 @@ ...@@ -152,7 +149,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -208,13 +205,13 @@ ...@@ -208,13 +205,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 25, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "7261855ebc41485c8822834f33016a8d", "model_id": "7ee7ec2cab1844de870258a5a5674dfc",
"version_major": 2, "version_major": 2,
"version_minor": 0 "version_minor": 0
}, },
...@@ -237,29 +234,28 @@ ...@@ -237,29 +234,28 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"cell = ase_to_spgcell(ase_atoms=atoms)\n", "''' \n",
"lattice, scaled_positions, numbers = spglib.find_primitive(cell, symprec=1e-5)\n", "\n",
"reduced = ase_to_spgcell(cell=(lattice, scaled_positions, numbers),inverse=True)" " ..TO DO..\n",
"\n",
"'''"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 28, "execution_count": 10,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "ename": "NameError",
"application/vnd.jupyter.widget-view+json": { "evalue": "name 'reduced' is not defined",
"model_id": "c0b014720e3d4c09b7430432c38b0056", "output_type": "error",
"version_major": 2, "traceback": [
"version_minor": 0 "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
}, "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"text/plain": [ "\u001b[0;32m<ipython-input-10-e82cf4dbf780>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mnglview\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshow_ase\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mreduced\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"NGLWidget()" "\u001b[0;31mNameError\u001b[0m: name 'reduced' is not defined"
] ]
},
"metadata": {},
"output_type": "display_data"
} }
], ],
"source": [ "source": [
...@@ -279,12 +275,11 @@ ...@@ -279,12 +275,11 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"versions = [read(atoms) for atoms in glob('./quartz_alpha*')]\n", "''' \n",
"\n",
" ..TO DO..\n",
"\n", "\n",
"for outer in range(len(versions)-1):\n", "'''"
" for inner in range(outer+1,len(versions)):\n",
" print('Comparing: ',outer,inner)\n",
" print('Equivalent: ',a_equiv_b(versions[outer],versions[inner]))"
] ]
} }
], ],
...@@ -304,7 +299,7 @@ ...@@ -304,7 +299,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.7.1" "version": "3.6.7"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import itertools import itertools
import numpy as np import numpy as np
from numpy.linalg import norm from numpy.linalg import norm
import spglib import spglib
from glob import glob from glob import glob
from ase import Atoms from ase import Atoms
from ase.io import read from ase.io import read
from ase.spacegroup import crystal from ase.spacegroup import crystal
from ase.spacegroup import Spacegroup from ase.spacegroup import Spacegroup
from ase.data import atomic_numbers, atomic_names from ase.data import atomic_numbers, atomic_names
import nglview import nglview
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Crystallographic point groups ## Crystallographic point groups
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
a=5.117 a=5.117
b=5.175 b=5.175
c=5.291 c=5.291
alpha=90 alpha=90
beta=99.22 beta=99.22
gamma=90 gamma=90
thespacegroup=14 thespacegroup='P 21/c'
print(Spacegroup(thespacegroup)) print(Spacegroup(thespacegroup))
hfo2 = crystal(symbols=['Hf','O','O'], hfo2 = crystal(['Hf','O','O'],basis=[(0.276,0.04,0.208),(0.074,0.332,0.347),(0.449,0.758,0.480)],
basis=[(0.276,0.04,0.208),(0.074,0.332,0.347),(0.449,0.758,0.480)], spacegroup=thespacegroup, cellpar=[a, b, c, alpha, beta, gamma])
spacegroup=thespacegroup,
cellpar=[a, b, c, alpha, beta, gamma])
#hfo2.write('hfo2.xyz')
``` ```
%%%% Output: stream %%%% Output: stream
14 P 21/c 14 P 21/c
setting 1 setting 1
centrosymmetric 1 centrosymmetric 1
primitive vectors primitive vectors
1.0000000000 0.0000000000 0.0000000000 1.0000000000 0.0000000000 0.0000000000
0.0000000000 1.0000000000 0.0000000000 0.0000000000 1.0000000000 0.0000000000
0.0000000000 0.0000000000 1.0000000000 0.0000000000 0.0000000000 1.0000000000
reciprocal vectors reciprocal vectors
1 0 0 1 0 0
0 1 0 0 1 0
0 0 1 0 0 1
1 subtranslations 1 subtranslations
0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000
2 symmetry operations (rot+trans) 2 symmetry operations (rot+trans)
1 0 0 0 1 0 0 0 1 0.0000000000 0.0000000000 0.0000000000 1 0 0 0 1 0 0 0 1 0.0000000000 0.0000000000 0.0000000000
-1 0 0 0 1 0 0 0 -1 0.0000000000 0.5000000000 0.5000000000 -1 0 0 0 1 0 0 0 -1 0.0000000000 0.5000000000 0.5000000000
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
bondatoms = [] bondatoms = []
symbols = hfo2.get_chemical_symbols() symbols = hfo2.get_chemical_symbols()
for i in range(len(hfo2)): for i in range(len(hfo2)):
for j in range(i): for j in range(i):
if (symbols[i] == 'Hf' and symbols[j] == 'O' and hfo2.get_distance(i, j) < 2.6): if (symbols[i] == 'Hf' and symbols[j] == 'O' and hfo2.get_distance(i, j) < 2.6):
bondatoms.append((i, j)) bondatoms.append((i, j))
elif (symbols[i] == 'O' and symbols[j] == 'Hf' and hfo2.get_distance(i, j) < 2.6): elif (symbols[i] == 'O' and symbols[j] == 'Hf' and hfo2.get_distance(i, j) < 2.6):
bondatoms.append((i, j)) bondatoms.append((i, j))
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
nglview.show_ase(hfo2) nglview.show_ase(hfo2)
``` ```
%%%% Output: display_data %%%% Output: display_data
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Questions: Questions:
-how many atoms are contained in the unit cell? -how many atoms are contained in the unit cell?
-compute the volume of the unit cell -compute the volume of the unit cell
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## ##
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
def ase_to_spgcell(ase_atoms=None, cell=None, inverse=False): def ase_to_spgcell(ase_atoms=None, cell=None, inverse=False):
if not inverse: if not inverse:
assert ase_atoms is not None assert ase_atoms is not None
return (ase_atoms.get_cell(), return (ase_atoms.get_cell(),
ase_atoms.get_scaled_positions(), ase_atoms.get_scaled_positions(),
ase_atoms.get_atomic_numbers()) ase_atoms.get_atomic_numbers())
else: else:
assert cell is not None assert cell is not None
return Atoms(cell=cell[0], return Atoms(cell=cell[0],
scaled_positions=cell[1], scaled_positions=cell[1],
numbers=cell[2]) numbers=cell[2])
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
def a_equiv_b(a,b): def a_equiv_b(a,b):
"""Function that identifies whether two crystals are equivalent""" """Function that identifies whether two crystals are equivalent"""
# getting symmetry datasets for both crystals # getting symmetry datasets for both crystals
cryst_a = spglib.get_symmetry_dataset(ase_to_spgcell(ase_atoms=a), symprec=1e-5, angle_tolerance=-1.0, hall_number=0) cryst_a = spglib.get_symmetry_dataset(ase_to_spgcell(ase_atoms=a), symprec=1e-5, angle_tolerance=-1.0, hall_number=0)
cryst_b = spglib.get_symmetry_dataset(ase_to_spgcell(ase_atoms=b), symprec=1e-5, angle_tolerance=-1.0, hall_number=0) cryst_b = spglib.get_symmetry_dataset(ase_to_spgcell(ase_atoms=b), symprec=1e-5, angle_tolerance=-1.0, hall_number=0)
samecell = np.allclose(cryst_a['std_lattice'], cryst_b['std_lattice'], atol=1e-5) samecell = np.allclose(cryst_a['std_lattice'], cryst_b['std_lattice'], atol=1e-5)
samenatoms = len(cryst_a['std_positions']) == len(cryst_b['std_positions']) samenatoms = len(cryst_a['std_positions']) == len(cryst_b['std_positions'])
samespg = cryst_a['number'] == cryst_b['number'] samespg = cryst_a['number'] == cryst_b['number']
def test_rotations_translations(cryst_a, cryst_b, repeat): def test_rotations_translations(cryst_a, cryst_b, repeat):
cell = cryst_a['std_lattice'] cell = cryst_a['std_lattice']
pristine = crystal('Mg', [(0, 0., 0.)], pristine = crystal('Mg', [(0, 0., 0.)],
spacegroup=int(cryst_a['number']), spacegroup=int(cryst_a['number']),
cellpar=[cell[0]/repeat[0], cell[1]/repeat[1], cell[2]/repeat[2]]).repeat(repeat) cellpar=[cell[0]/repeat[0], cell[1]/repeat[1], cell[2]/repeat[2]]).repeat(repeat)
sym_set_p = spglib.get_symmetry_dataset(ase_to_spgcell(ase_atoms=pristine), symprec=1e-5, sym_set_p = spglib.get_symmetry_dataset(ase_to_spgcell(ase_atoms=pristine), symprec=1e-5,
angle_tolerance=-1.0, hall_number=0) angle_tolerance=-1.0, hall_number=0)
for _,trans in enumerate(zip(sym_set_p['rotations'], sym_set_p['translations'])): for _,trans in enumerate(zip(sym_set_p['rotations'], sym_set_p['translations'])):
pnew=(np.matmul(trans[0],cryst_a['std_positions'].T).T + trans[1]) % 1.0 pnew=(np.matmul(trans[0],cryst_a['std_positions'].T).T + trans[1]) % 1.0
fulln = np.concatenate([cryst_a['std_types'][:, None], pnew], axis=1) fulln = np.concatenate([cryst_a['std_types'][:, None], pnew], axis=1)
fullb = np.concatenate([cryst_b['std_types'][:, None], cryst_b['std_positions']], axis=1) fullb = np.concatenate([cryst_b['std_types'][:, None], cryst_b['std_positions']], axis=1)
sorted_n = np.array(sorted([ list(row) for row in list(fulln) ])) sorted_n = np.array(sorted([ list(row) for row in list(fulln) ]))
sorted_b = np.array(sorted([ list(row) for row in list(fullb) ])) sorted_b = np.array(sorted([ list(row) for row in list(fullb) ]))
if np.allclose(sorted_n, sorted_b, atol=1e-5): if np.allclose(sorted_n, sorted_b, atol=1e-5):
return True return True
return False return False
if samecell and samenatoms and samespg: if samecell and samenatoms and samespg:
cell = cryst_a['std_lattice'] cell = cryst_a['std_lattice']
rng1 = range(1, int(norm(cell[0])/2.)) rng1 = range(1, int(norm(cell[0])/2.))
rng2 = range(1, int(norm(cell[1])/2.)) rng2 = range(1, int(norm(cell[1])/2.))
rng3 = range(1, int(norm(cell[2])/2.)) rng3 = range(1, int(norm(cell[2])/2.))
for repeat in itertools.product(rng1, rng2, rng3): for repeat in itertools.product(rng1, rng2, rng3):
if test_rotations_translations(cryst_a, cryst_b, repeat): if test_rotations_translations(cryst_a, cryst_b, repeat):
return True return True
return False return False
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Task 1 ## Task 1
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
atoms = read('./quartz_alpha.xyz') atoms = read('./quartz_alpha.xyz')
nglview.show_ase(atoms) nglview.show_ase(atoms)
``` ```
%%%% Output: display_data %%%% Output: display_data
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
cell = ase_to_spgcell(ase_atoms=atoms) '''
lattice, scaled_positions, numbers = spglib.find_primitive(cell, symprec=1e-5)
reduced = ase_to_spgcell(cell=(lattice, scaled_positions, numbers),inverse=True) ..TO DO..
'''
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
nglview.show_ase(reduced) nglview.show_ase(reduced)
``` ```
%%%% Output: display_data %%%% Output: error
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-10-e82cf4dbf780> in <module>
----> 1 nglview.show_ase(reduced)
NameError: name 'reduced' is not defined
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Task 2 ## Task 2
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
versions = [read(atoms) for atoms in glob('./quartz_alpha*')] '''
..TO DO..
for outer in range(len(versions)-1): '''
for inner in range(outer+1,len(versions)):
print('Comparing: ',outer,inner)
print('Equivalent: ',a_equiv_b(versions[outer],versions[inner]))
``` ```
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -58,22 +58,22 @@ ...@@ -58,22 +58,22 @@
} }
], ],
"source": [ "source": [
"a=...\n", "a=5.117\n",
"b=...\n", "b=5.175\n",
"c=...\n", "c=5.291\n",
"alpha=...\n", "alpha=90\n",
"beta=...\n", "beta=99.22\n",
"gamma=...\n", "gamma=90\n",
"thespacegroup=...\n", "thespacegroup='P 21/c'\n",
"print(Spacegroup(thespacegroup))\n", "print(Spacegroup(thespacegroup))\n",
"\n", "\n",
"hfo2 = crystal(['...','...','...'],basis=[(...,...,...),(...,...,...),(...,...,...)], \n", "hfo2 = crystal(['Hf','O','O'],basis=[(0.276,0.04,0.208),(0.074,0.332,0.347),(0.449,0.758,0.480)], \n",
" spacegroup=thespacegroup, cellpar=[a, b, c, alpha, beta, gamma])" " spacegroup=thespacegroup, cellpar=[a, b, c, alpha, beta, gamma])"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -89,13 +89,13 @@ ...@@ -89,13 +89,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "173ee9fd9ff14be7a76bdd69a69afbe2", "model_id": "f9c3ef4efca74690a7d6ac1e4a8d450a",
"version_major": 2, "version_major": 2,
"version_minor": 0 "version_minor": 0
}, },
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -205,13 +205,13 @@ ...@@ -205,13 +205,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 25, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "7261855ebc41485c8822834f33016a8d", "model_id": "7ee7ec2cab1844de870258a5a5674dfc",
"version_major": 2, "version_major": 2,
"version_minor": 0 "version_minor": 0
}, },
...@@ -243,22 +243,19 @@ ...@@ -243,22 +243,19 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 28, "execution_count": 10,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "ename": "NameError",
"application/vnd.jupyter.widget-view+json": { "evalue": "name 'reduced' is not defined",
"model_id": "c0b014720e3d4c09b7430432c38b0056", "output_type": "error",
"version_major": 2, "traceback": [
"version_minor": 0 "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
}, "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"text/plain": [ "\u001b[0;32m<ipython-input-10-e82cf4dbf780>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mnglview\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshow_ase\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mreduced\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"NGLWidget()" "\u001b[0;31mNameError\u001b[0m: name 'reduced' is not defined"
] ]
},
"metadata": {},
"output_type": "display_data"
} }
], ],
"source": [ "source": [
...@@ -302,7 +299,7 @@ ...@@ -302,7 +299,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.7.1" "version": "3.6.7"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import itertools import itertools
import numpy as np import numpy as np
from numpy.linalg import norm from numpy.linalg import norm
import spglib import spglib
from glob import glob from glob import glob
from ase import Atoms from ase import Atoms
from ase.io import read from ase.io import read
from ase.spacegroup import crystal from ase.spacegroup import crystal
from ase.spacegroup import Spacegroup from ase.spacegroup import Spacegroup
from ase.data import atomic_numbers, atomic_names from ase.data import atomic_numbers, atomic_names
import nglview import nglview
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Crystallographic point groups ## Crystallographic point groups
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
a=... a=5.117
b=... b=5.175
c=... c=5.291
alpha=... alpha=90
beta=... beta=99.22
gamma=... gamma=90
thespacegroup=... thespacegroup='P 21/c'
print(Spacegroup(thespacegroup)) print(Spacegroup(thespacegroup))
hfo2 = crystal(['...','...','...'],basis=[(...,...,...),(...,...,...),(...,...,...)], hfo2 = crystal(['Hf','O','O'],basis=[(0.276,0.04,0.208),(0.074,0.332,0.347),(0.449,0.758,0.480)],
spacegroup=thespacegroup, cellpar=[a, b, c, alpha, beta, gamma]) spacegroup=thespacegroup, cellpar=[a, b, c, alpha, beta, gamma])
``` ```
%%%% Output: stream %%%% Output: stream
14 P 21/c 14 P 21/c
setting 1 setting 1
centrosymmetric 1 centrosymmetric 1
primitive vectors primitive vectors
1.0000000000 0.0000000000 0.0000000000 1.0000000000 0.0000000000 0.0000000000
0.0000000000 1.0000000000 0.0000000000 0.0000000000 1.0000000000 0.0000000000
0.0000000000 0.0000000000 1.0000000000 0.0000000000 0.0000000000 1.0000000000
reciprocal vectors reciprocal vectors
1 0 0 1 0 0
0 1 0 0 1 0
0 0 1 0 0 1
1 subtranslations 1 subtranslations
0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000
2 symmetry operations (rot+trans) 2 symmetry operations (rot+trans)
1 0 0 0 1 0 0 0 1 0.0000000000 0.0000000000 0.0000000000 1 0 0 0 1 0 0 0 1 0.0000000000 0.0000000000 0.0000000000
-1 0 0 0 1 0 0 0 -1 0.0000000000 0.5000000000 0.5000000000 -1 0 0 0 1 0 0 0 -1 0.0000000000 0.5000000000 0.5000000000
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
bondatoms = [] bondatoms = []
symbols = hfo2.get_chemical_symbols() symbols = hfo2.get_chemical_symbols()
for i in range(len(hfo2)): for i in range(len(hfo2)):
for j in range(i): for j in range(i):
if (symbols[i] == 'Hf' and symbols[j] == 'O' and hfo2.get_distance(i, j) < 2.6): if (symbols[i] == 'Hf' and symbols[j] == 'O' and hfo2.get_distance(i, j) < 2.6):
bondatoms.append((i, j)) bondatoms.append((i, j))
elif (symbols[i] == 'O' and symbols[j] == 'Hf' and hfo2.get_distance(i, j) < 2.6): elif (symbols[i] == 'O' and symbols[j] == 'Hf' and hfo2.get_distance(i, j) < 2.6):
bondatoms.append((i, j)) bondatoms.append((i, j))
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
nglview.show_ase(hfo2) nglview.show_ase(hfo2)
``` ```
%%%% Output: display_data %%%% Output: display_data
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Questions: Questions:
-how many atoms are contained in the unit cell? -how many atoms are contained in the unit cell?
-compute the volume of the unit cell -compute the volume of the unit cell
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## ##
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
def ase_to_spgcell(ase_atoms=None, cell=None, inverse=False): def ase_to_spgcell(ase_atoms=None, cell=None, inverse=False):
if not inverse: if not inverse:
assert ase_atoms is not None assert ase_atoms is not None
return (ase_atoms.get_cell(), return (ase_atoms.get_cell(),
ase_atoms.get_scaled_positions(), ase_atoms.get_scaled_positions(),
ase_atoms.get_atomic_numbers()) ase_atoms.get_atomic_numbers())