def change_in_array(x): """ Return an array with integer elements starting from 0 reproducing cyclic nature of the x array. """ val = 0 c = [val] prev = x[0] for i in x[1:]: if i == prev: pass else: val += 1 prev = i c.append(val) return np.array(c)
def threefold(n, h, d, points=True): s = System(hextess(n, points)) ct = [] ct.append(PatternRangeConstraint(min=0, max=1.)) for p in 0, 4*np.pi/3, 2*np.pi/3: x = np.array([d/3**.5*np.cos(p), d/3**.5*np.sin(p), h]) r = euler_matrix(p, np.pi/2, np.pi/4, "rzyz")[:3, :3] for i in "x y z xy xz yz".split(): ct.append(PotentialObjective(derivative=i, x=x, rotation=r, value=0)) for i, v in ("xx", 1), ("yy", 1): ct.append(PotentialObjective(derivative=i, x=x, rotation=r, value=v)) s.rfs, c = s.optimize(ct) return s, c
def get(self, n=12, h=1/8., d=1/4., H=25/8., nmax=1, points=True): s = system.System(electrodes=self.hextess(n, points)) for ei in s: ei.cover_height = H ei.cover_nmax = nmax self.s = s ct = [] ct.append(pattern_constraints.PatternRangeConstraint(min=0, max=1.)) for p in 0, 4*np.pi/3, 2*np.pi/3: x = np.array([d/3**.5*np.cos(p), d/3**.5*np.sin(p), h]) r = transformations.euler_matrix(p, np.pi/2, np.pi/4, "rzyz")[:3, :3] for i in "x y z xy xz yz".split(): ct.append(pattern_constraints.PotentialObjective(derivative=i, x=x, rotation=r, value=0)) for i in "xx yy".split(): ct.append(pattern_constraints.PotentialObjective(derivative=i, x=x, rotation=r, value=2**(-1/3.))) s.rfs, self.c = s.optimize(ct, verbose=False) self.h = h self.x0 = np.array([d/3**.5, 0, h]) self.r = transformations.euler_matrix(0, np.pi/2, np.pi/4, "rzyz")[:3, :3]