예제 #1
0
 def test_rotate_tensor_simple(self):
     r = transformations.euler_matrix(0, 0, np.pi/2, "sxyz")[:3, :3]
     d = np.arange(3)
     nptest.assert_almost_equal(d[[1, 0, 2]],
             utils.rotate_tensor(d, r, 1))
     d = np.arange(9).reshape(1,3,3)
     nptest.assert_almost_equal([[[4, -3, 5], [-1, 0, -2], [7, -6, 8]]],
             utils.rotate_tensor(d, r, 2))
예제 #2
0
    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]
예제 #3
0
 def test_rotate_tensor_rot(self):
     r = transformations.euler_matrix(*np.random.random(3))[:3, :3]
     d = np.arange(3**3*5).reshape(5,3,3,3)
     dr = utils.rotate_tensor(d, r, 3)
     drr = utils.rotate_tensor(dr, r.T, 3)
     nptest.assert_almost_equal(d, drr)