forked from diwadd/Nomad2018
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstructure_visualization.sage
executable file
·101 lines (79 loc) · 2.67 KB
/
structure_visualization.sage
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import numpy as np
import geometry_xyz as gxyz
from sage.plot.plot3d.shapes import *
def draw_structure(vectors, atoms):
S = Sphere(0.1, color='yellow')
S = S + arrow3d((0,0,0), tuple(vectors[0]), width=3)
S = S + arrow3d((0,0,0), tuple(vectors[1]), width=3)
S = S + arrow3d((0,0,0), tuple(vectors[2]), width=3)
for i in range(len(atoms)):
a = atoms[i]
a_r = None
a_c = None
if a.t == "Ga":
a_r = gxyz.ga_r
a_c = gxyz.ga_c
elif a.t == "In":
a_r = gxyz.in_r
a_c = gxyz.in_c
elif a.t == "Al":
a_r = gxyz.al_r
a_c = gxyz.al_c
elif a.t == "O":
a_r = gxyz.o_r
a_c = gxyz.o_c
else:
pass
S = S + Sphere(a_r, color=a_c).translate(a.x ,a.y , a.z)
S.show(aspect_ratio=1)
#save(S,'temp.png', axes=False, aspect_ratio=True)
#os.system('display temp.png')
def draw_structure_around(vectors, atoms, origin, r=5):
o_x = origin.x
o_y = origin.y
o_z = origin.z
S = Sphere(0.1, color='yellow')
S = S + arrow3d((0,0,0), tuple(vectors[0]), width=3)
S = S + arrow3d((0,0,0), tuple(vectors[1]), width=3)
S = S + arrow3d((0,0,0), tuple(vectors[2]), width=3)
for i in range(len(atoms)):
a = atoms[i]
a_r = None
a_c = None
dx = a.x - o_x
dy = a.y - o_y
dz = a.z - o_z
d = np.sqrt(dx*dx + dy*dy + dz*dz)
if d > r:
continue
print("d: {0}".format(d))
if a.t == "Ga":
a_r = gxyz.ga_r
a_c = gxyz.ga_c
elif a.t == "In":
a_r = gxyz.in_r
a_c = gxyz.in_c
elif a.t == "Al":
a_r = gxyz.al_r
a_c = gxyz.al_c
elif a.t == "O":
a_r = gxyz.o_r
a_c = gxyz.o_c
else:
pass
S = S + Sphere(a_r, color=a_c).translate(dx, dy, dz)
S.show(aspect_ratio=1)
vectors, uc_atoms = gxyz.read_geometry_file("/home/tadek/Coding/Kaggle/Nomad2018/train/2/geometry.xyz")
atoms = gxyz.build_structure(vectors,
uc_atoms,
n_x=0,
n_y=0,
n_z=0)
gxyz.check_for_duplicates(atoms)
atoms = gxyz.cut_ball_from_structure(atoms, radious=25)
draw_structure(vectors, atoms)
index = 31
print("uc_atoms[index]: {0}".format(uc_atoms[index].t))
draw_structure_around(vectors, atoms, uc_atoms[index], r=3)
print(vectors)
#parse_all_structures("/home/tadek/Coding/Kaggle/Nomad2018/test/test/*")