-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgfunctions.py
More file actions
94 lines (76 loc) · 2.74 KB
/
gfunctions.py
File metadata and controls
94 lines (76 loc) · 2.74 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
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
import numpy as np
import os
from Grassmann_ import *
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import colormaps as cmaps
def f(x):
return x * np.sin(x)
def f2(x):
y = np.zeros(x.shape[0])
for i in range(x.shape[0]):
y[i] = x[i][0]*np.sin(x[i][1])
return np.array(y)
def branin_hoo(x, arg):
a = 1
b = 5.1/(4*np.pi**2)
c = 5/np.pi
r = 6
s = 10
t = 1/(8*np.pi)
if arg == 0:
y = np.zeros(x.shape[0])
for i in range(x.shape[0]):
y[i] = a*(x[i, 1] - b*x[i, 0]**2 + c*x[i, 0] - r)**2 + s*(1-t)*np.cos(x[i, 0]) + s +5*x[i, 0]
else:
y = a * (x[1] - b * x[0] ** 2 + c * x[0] - r) ** 2 + s * (1 - t) * np.cos(x[0]) + s +5*x[0]
return y
def STZ_Darius(x, D0, arg):
rank0 = (D0.shape[1])
if arg == 0:
distance = np.zeros(x.shape[0])
for i in range(x.shape[0]):
script = '/Users/dariusalix-williams/Documents/Continuum_Comparison/esim/coord_transforms/eran/simple_shear/shear_energy qs tem.0 energy {:7.4f} {:7.4f}'.format(x[i,0],x[i,1])
os.system(script)
myArray = np.fromfile('/Users/dariusalix-williams/Documents/Continuum_Comparison/esim/coord_transforms/eran/simple_shear/sct_q.out/tem.24', dtype=np.float32)
Array = myArray.reshape(36, 71)
D = Array[1:, 1:]
print()
'''
fig = plt.figure()
ax = fig.add_subplot(111)
pos = ax.imshow(D, cmap=cmaps.parula, interpolation='bicubic', \
origin='lower', )
ax.set_xlabel('x')
ax.set_ylabel('y')
fig.colorbar
print()
'''
u, s, v = svd(D, 0)
rank = (u.shape[1])
distance[i] = gr_dist(u, D0, rank, rank0, 'Grassmann')
print()
else:
script = '/Users/dariusalix-williams/Documents/Continuum_Comparison/esim/coord_transforms/eran/simple_shear/shear_energy qs tem.0 energy {:7.4f} {:7.4f}'.format(
x[0], x[1])
os.system(script)
myArray = np.fromfile(
'/Users/dariusalix-williams/Documents/Continuum_Comparison/esim/coord_transforms/eran/simple_shear/sct_q.out/tem.24',
dtype=np.float32)
Array = myArray.reshape(36, 71)
D = Array[1:, 1:]
'''
print()
fig = plt.figure()
ax = fig.add_subplot(111)
pos = ax.imshow(D, cmap=cmaps.parula, interpolation='bicubic', \
origin='lower', )
ax.set_xlabel('x')
ax.set_ylabel('y')
fig.colorbar
print()
'''
u, s, v = svd(D, 0)
rank = (u.shape[1])
distance = gr_dist(u, D0, rank, rank0, 'Grassmann')
return distance