-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_orientations_brent.py
65 lines (45 loc) · 1.69 KB
/
check_orientations_brent.py
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
#%%
import os
import numpy
os.chdir('/home/bbales2/modal')
from rotations import symmetry
from rotations import quaternion
import itertools
import time
# get the equivalent passive rotation in the fundamental zone (active post multiplies symmetry operator)
#%%
q1 = [0.703295, -0.111453, -0.101898, -0.69467299999999998]#0.988, 0.0, 0.006, -0.152]
#q = q / numpy.linalg.norm(q)
#q1 = quaternion.Quaternion(q)
q2 = [0.70376400000000006, -0.69423599999999996, -0.10509, 0.10820899999999999]#-0.425, -0.425, 0.565, 0.565]
#q = q / numpy.linalg.norm(q)
#q2 = quaternion.Quaternion(q)
cubicSym = symmetry.Symmetry.Cubic.quOperators()
orthoSym = symmetry.Symmetry.Orthorhombic.quOperators()
def adj(q):
if q.wxyz[0] < 0.0:
q.wxyz[0] *= -1
q.wxyz[1] *= -1
q.wxyz[2] *= -1
q.wxyz[3] *= -1
return q
def miso((q1, q2)):
q1 = quaternion.Quaternion(numpy.array(q1) / numpy.linalg.norm(q1)).conjugate()
q2 = quaternion.Quaternion(numpy.array(q2) / numpy.linalg.norm(q2)).conjugate()
misot = 180.0
misoa = None
for i in range(len(cubicSym)):
for ii in range(len(orthoSym)):
qa = orthoSym[ii] * q1 * cubicSym[i]
for j in range(len(cubicSym)):
#for jj in range(len(orthoSym)):
qb = q2 * cubicSym[j]
qasb1 = qa.conjugate() * qb
t1 = qasb1.wxyz / numpy.linalg.norm(qasb1.wxyz)
a1 = 2 * numpy.arccos(t1[0]) * 180 / numpy.pi
if a1 < misot:
misot = a1
misoa = qasb1
return misot
# to move q2 back to q1, use all the i, j, k rotations.... Not just miso
print miso((q1, q2))