-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotcell.py
More file actions
67 lines (59 loc) · 2.79 KB
/
plotcell.py
File metadata and controls
67 lines (59 loc) · 2.79 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
from matplotlib.patches import RegularPolygon
import numpy as np
from constants import *
import datetime
__all__ = ["plotcell"]
def plotcell(cell, window = "neighbors", neighbors = False):
xcoord = [atom.coord[0] for atom in cell.atoms]
ycoord = [atom.coord[1] for atom in cell.atoms]
margin = latConst
xmax = max(xcoord) + margin
ymax = max(ycoord) + margin
xmin = min(xcoord) - margin
ymin = min(ycoord) - margin
now = datetime.datetime.now()
datestr = str(now.hour) + "-" + str(now.minute) + "-" + str(now.second)
# if cell.Lattice is "custom":
# plt.figure(1,figsize=(8,6))
# ax1 = plt.axes()
# plt.scatter(xcoord, ycoord, s=30, c="r")
# for item in cell.gridxy:
# plt.annotate("["+str(item[1][0])+","+str(item[1][1])+"]", (item[0][0]-0.1,item[0][1]-0.1), size = 6)
# Hex = RegularPolygon((item[0][0],item[0][1]), numVertices=6, radius=latConst,orientation=np.radians(30), facecolor=(1,0,0,0.1*item[2]), edgecolor = (0,0,0,0.1))
# ax1.add_patch(Hex)
# plt.savefig('cell_1_' + datestr + '.pdf', format='pdf')
# plt.figure(2,figsize=(8,6))
if window is "all":
plt.scatter(xcoord, ycoord, s=30, c="b")
plt.xlim((xmin,xmax))
plt.ylim((ymin,ymax))
for atom in cell.atoms:
plt.annotate("["+str(atom.Spaceindexalt[0])+","+str(atom.Spaceindexalt[1])+"]", (atom.coord[0]-0.3, atom.coord[1]+0.2), size=6)
# plt.savefig('cell_2_' + datestr + '.pdf', format='pdf')
plt.figure(3,figsize=(8,6))
plt.scatter(xcoord, ycoord, s=30, c="grey")
plt.xlim((xmin,xmax))
plt.ylim((ymin,ymax))
for atom in cell.atoms:
plt.annotate(str(len(atom.neighbors)), (atom.coord[0]-0.4, atom.coord[1]+0.2), size=6)
# plt.savefig('cell_3_' + datestr + '.pdf', format='pdf')
if window is "all":
plt.figure(4,figsize=(8,6))
plt.scatter(xcoord, ycoord, s=30, c="g")
plt.xlim((xmin,xmax))
plt.ylim((ymin,ymax))
for atom in cell.atoms:
plt.annotate(str(atom.MUCindex[1]), (atom.coord[0]-0.4, atom.coord[1]+0.2), size=6)
# plt.savefig('cell_5_' + datestr + '.pdf', format='pdf')
if neighbors:
plt.figure(5,figsize=(8,6))
plt.scatter(xcoord, ycoord, s=30, c="r")
nxcoord = [atom.coord[0] for atom in cell.neighborCell]
nycoord = [atom.coord[1] for atom in cell.neighborCell]
plt.scatter(nxcoord, nycoord, s=2, c="b")
for atom in cell.neighborCell:
plt.annotate(str(atom.Spaceindex), (atom.coord[0]-0.2, atom.coord[1]+0.2), size=6)
# plt.savefig('cell_4_' + datestr + '.pdf', format='pdf')