模型建立

基本思想就是建立原胞,然后按照基矢量复制基原子,目前支持BCC,FCC,HCP,graphene等结构,但是目前还不能进行晶相的旋转变换,有时间的话之后再写。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import numpy as np 

def bulid_structure(Lattice_Constant, Structure_Type, x, y, z):

if Structure_Type == 'FCC':
basis = np.array([[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0]]) * Lattice_Constant
base_atoms = np.array([[0.0, 0.0, 0.0],
[0.5, 0.5, 0.0],
[0.5, 0.0, 0.5],
[0.0, 0.5, 0.5]]) * Lattice_Constant
elif Structure_Type == 'BCC':
basis = np.array([[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0]]) * Lattice_Constant
base_atoms = np.array([[0.0, 0.0, 0.0],
[0.5, 0.5, 0.5]]) * Lattice_Constant
elif Structure_Type == 'HCP':
basis = np.array([[1.0, 0.0, 0.0],
[0.0, np.sqrt(3), 0.0],
[0.0, 0.0, np.sqrt(8 / 3)]]) * Lattice_Constant
base_atoms = np.array([[0.0, 0.0, 0.0],
[0.5, 0.5 * np.sqrt(3), 0.0],
[0.5, np.sqrt(3) * 5 / 6, 0.5 * np.sqrt(8 / 3)],
[0.0, 1 / 3 * np.sqrt(3), 0.5 * np.sqrt(8 / 3)]]) * Lattice_Constant
elif Structure_Type == 'GRA':
basis = np.array([
[3.0, 0.0, 0.0],
[0.0, np.sqrt(3), 0.0],
[0.0, 0.0, 3.4]
]) * Lattice_Constant
base_atoms = np.array(
[[1/6 , 0.0, 0.0],
[0.5 , 0.0, 0.0],
[0.0, 0.5 , 0.0],
[2/3 , 0.5 , 0.0]]
) * np.array([Lattice_Constant * 3, Lattice_Constant * np.sqrt(3), 0.0])

positions = []
for i in range(x):
for j in range(y):
for k in range(z):
base_position = np.array([i, j, k], dtype=np.float64)
cart_position = np.dot(basis, base_position)
for atom_index in range(len(base_atoms)):
positions.append(cart_position + base_atoms[atom_index])
return np.array(positions)