-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_of_basis.py
49 lines (36 loc) · 1.27 KB
/
change_of_basis.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
import numpy as np
from bases import bases
basis_BB = bases("TapeTape")
basis_PHI = bases("Phi")
# Define the inner product function
def inner_product_matrix(M, N):
return np.dot(M.flatten(), N.flatten())
# Define Dmat
Dmat = np.diag([1, 1, 1, np.sqrt(2), np.sqrt(2), np.sqrt(2)])
# Define MatIsubCAbasisCisON function
def mat_isub_CA_basis_C_is_ON(C, A):
return np.array([[inner_product_matrix(A[jj], C[ii]) for jj in range(6)] for ii in range(6)])
# Define MatIsubBA function
def mat_isub_BA(A):
return mat_isub_CA_basis_C_is_ON(basis_BB, A)
# Define MatIsubBΦ and MatIsubΦB
MatIsubBΦ = mat_isub_BA(basis_PHI)
MatIsubΦB = np.linalg.inv(MatIsubBΦ)
# Define PHImatOfCmat function
def phi_mat_of_cmat(Cijkl):
return Dmat @ Cijkl @ Dmat
# Define CmatOfPHImat function
def cmat_of_phi_mat(PHImat):
return np.linalg.inv(Dmat) @ PHImat @ np.linalg.inv(Dmat)
# Define TmatOfPHImat function
def tmat_of_phi_mat(PHImat):
return MatIsubBΦ @ PHImat @ MatIsubΦB
# Define PHImatOfTmat function
def phi_mat_of_tmat(Tmat):
return MatIsubΦB @ Tmat @ MatIsubBΦ
# Define TmatOfCmat function
def tmat_of_cmat(Cijkl):
return tmat_of_phi_mat(phi_mat_of_cmat(Cijkl))
# Define CmatOfTmat function
def cmat_of_tmat(Tmat):
return cmat_of_phi_mat(phi_mat_of_tmat(Tmat))