-
Notifications
You must be signed in to change notification settings - Fork 0
/
visscher_rework.py
146 lines (102 loc) · 3.47 KB
/
visscher_rework.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#%%
import numpy
import time
import scipy.linalg
import os
os.chdir('/home/bbales2/modal')
import pyximport
pyximport.install(reload_support = True)
import polybasisqu
reload(polybasisqu)
from rotations import inv_rotations
# basis polynomials are x^n * y^m * z^l where n + m + l <= N
N = 10
## Dimensions for TF-2
X = 0.007753
Y = 0.009057
Z = 0.013199
#sample mass
#Sample density
density = 4401.695921
def func():
M = numpy.random.rand(6, 6)
C = M.transpose() * M
emin = scipy.linalg.eigh(C)[0][0]
C -= numpy.eye(6) * emin * 1.1
print C
numpy.linalg.cholesky(C)
dp, pv, ddpdX, ddpdY, ddpdZ, dpvdX, dpvdY, dpvdZ = polybasisqu.build(N, X, Y, Z)
cu = numpy.random.rand(3)
print cu
w, x, y, z = inv_rotations.cu2qu(list(cu))
C, _, _, _, _, _ = polybasisqu.buildRot(C, w, x, y, z)
K, M = polybasisqu.buildKM(C, dp, pv, density)
eigs, evecs = scipy.linalg.eigh(K, M, eigvals = (6, 6 + 30 - 1))
return numpy.sqrt(eigs * 1e11) / (numpy.pi * 2000), C, K, M
feigs, C, K_, M_ = func()
def Cvoigt(Ch):
C = numpy.zeros((3, 3, 3, 3))
voigt = [[(0, 0)], [(1, 1)], [(2, 2)], [(1, 2), (2, 1)], [(0, 2), (2, 0)], [(0, 1), (1, 0)]]
for i in range(6):
for j in range(6):
for k, l in voigt[i]:
for n, m in voigt[j]:
C[k, l, n, m] = Ch[i, j]
return C
Cv = Cvoigt(C)
R = 3 * (N + 1) * (N + 2) * (N + 3) / 18
lmns = []
for l in range(0, N + 1):
for m in range(0, N + 1):
for n in range(0, N + 1):
if l + m + n <= N:
lmns.append((l, m, n))
#%%
M = numpy.zeros((R, 3, R, 3))
K = numpy.zeros((R, 3, R, 3))
def f(l0, l1, d):
p = l0 + l1
return numpy.power(d, p + 1) / (p + 1)
def fd(l0, l1, d):
p = l0 + l1 - 1
if l1 == 0:
return 0.0
return l1 * numpy.power(d, p + 1) / (p + 1)
def df(l0, l1, d):
return fd(l1, l0, d)
def dd(l0, l1, d):
p = l0 + l1 - 2
if l0 == 0:
return 0.0
if l1 == 0:
return 0.0
return l1 * l0 * numpy.power(d, p + 1) / (p + 1)
for i in range(3):
for k0, (l0, m0, n0) in enumerate(lmns):
for k1, (l1, m1, n1) in enumerate(lmns):
M[k0, i, k1, i] = density * f(l0, l1, X) * f(m0, m1, Y) * f(n0, n1, Z)
dp = numpy.zeros((R, 3, R, 3))
for k0, (l0, m0, n0) in enumerate(lmns):
for k1, (l1, m1, n1) in enumerate(lmns):
dp[k0, 0, k1, 0] = dd(l0, l1, X) * f(m0, m1, Y) * f(n0, n1, Z)
dp[k0, 1, k1, 0] = fd(l0, l1, X) * df(m0, m1, Y) * f(n0, n1, Z)
dp[k0, 2, k1, 0] = fd(l0, l1, X) * f(m0, m1, Y) * df(n0, n1, Z)
dp[k0, 0, k1, 1] = df(l0, l1, X) * fd(m0, m1, Y) * f(n0, n1, Z)
dp[k0, 1, k1, 1] = f(l0, l1, X) * dd(m0, m1, Y) * f(n0, n1, Z)
dp[k0, 2, k1, 1] = f(l0, l1, X) * fd(m0, m1, Y) * df(n0, n1, Z)
dp[k0, 0, k1, 2] = df(l0, l1, X) * f(m0, m1, Y) * fd(n0, n1, Z)
dp[k0, 1, k1, 2] = f(l0, l1, X) * df(m0, m1, Y) * fd(n0, n1, Z)
dp[k0, 2, k1, 2] = f(l0, l1, X) * f(m0, m1, Y) * dd(n0, n1, Z)
for i in range(3):
for ip in range(3):
for k0, (l0, m0, n0) in enumerate(lmns):
for k1, (l1, m1, n1) in enumerate(lmns):
for j in range(3):
for jp in range(3):
K[k0, i, k1, ip] += Cv[i, j, ip, jp] * dp[k0, j, k1, jp]
K = K.reshape((3 * R, 3 * R))
M = M.reshape((3 * R, 3 * R))
eigs, evecs = scipy.linalg.eigh(K, M, eigvals = (6, 6 + 30 - 1))
fs = numpy.sqrt(eigs * 1e11) / (numpy.pi * 2000)
print feigs
print fs