Example #1
0
  def setUp(self):
    self.SS = np.array([
      [ 5.99159801, -2.24342348,  0.26667281, -0.95466199,  3.98931478, -0.10846981],
      [ 1.86468226, -4.32391908, -7.82738638, -7.45008989,  5.89874777, 0.45820648],
      [-5.92565398,  2.4862829 , -6.02112389,  6.75455965,  4.65183463, 9.96900579],
      [ 0.60378883, -3.72189328, -7.63388446, -5.76559403, -0.3119789 , -1.1527258 ],
      [ 4.56813135, -6.06783828, -6.18341368,  8.06169686, -9.56928844, 9.08114655],
      [-8.25516614,  6.30663846,  7.2084381 , -7.38280703, -5.96279902, 8.9935982 ]])
    self.SS_full = common.ms2ts(self.SS)
    self.TSS = tensors.SymSymR4(self.SS)

    self.W = np.array([[-9.36416517,  2.95527444,  8.70983194],
           [-1.54693052,  8.7905658 , -5.10895168],
           [-8.52740468, -0.7741642 ,  2.89544992]])
    self.W = 0.5 * (self.W - self.W.T)
    self.TW = tensors.Skew(self.W)

    self.S = np.array([[4.1,2.8,-1.2],[3.1,7.1,0.2],[4,2,3]])
    self.S = 0.5*(self.S + self.S.T)
    self.TS = tensors.Symmetric(self.S)

    self.WS = np.array([
      [-8.3567359 , -5.39728818, -8.00844442, -8.33365112, -0.97903364, -8.23943149],
      [-6.97125417,  4.34802055,  7.06281056, -1.57511617,  7.83359933, -9.37625432],
      [-6.0799489 , -6.0309543 ,  3.68575895,  8.84296976,  6.55799427, -9.22029379]])
    self.WS_full = common.wws2ts(self.WS)
    self.TWS = tensors.SkewSymR4(self.WS)
Example #2
0
  def test_symskewsym_skewsymsym(self):
    A1 = tensors.SymSkewR4Sym_SkewSymR4SymR4(self.TWS, self.TS)

    A2_ten = np.einsum('km,mlst', self.S, self.WS_full) - np.einsum('kmst,ml',
        self.WS_full, self.S)
    A2 = tensors.SymSymR4(common.ts2ms(A2_ten))

    self.assertEqual(A1, A2)
Example #3
0
  def setUp(self):
    self.q = rotations.Orientation(30.0, 60.0, 80.0, angle_type = "degrees")
    self.Q = self.q.to_matrix()
    self.v = np.array([1.2,-2.0,3.0])
    self.Tv = tensors.Vector(self.v)

    self.A = np.array([[4.1,2.8,-1.2],[3.1,7.1,0.2],[4,2,3]])
    self.TA = tensors.RankTwo(self.A)

    self.S = np.array([[4.1,2.8,-1.2],[3.1,7.1,0.2],[4,2,3]])
    self.S = 0.5*(self.S + self.S.T)
    self.TS = tensors.Symmetric(self.S)

    self.W = np.array([[4.1,2.8,-1.2],[3.1,7.1,0.2],[4,2,3]])
    self.W = 0.5*(self.W - self.W.T)
    self.TW = tensors.Skew(self.W)

    self.R1 = np.array([[[[ 7.09627147,  9.22330744, -1.36602973],
             [-7.86118175, -1.6342633 , -5.75516189],
             [ 2.61734248,  6.40678382,  3.37981603]],
            [[ 5.65100254, -7.88797059,  7.31396665],
             [-6.35471595,  5.67698069, -8.18795178],
             [ 9.10447016,  8.91183436, -6.65254333]],
            [[ 3.20429862,  2.99308849,  4.0035241 ],
             [-4.02440197, -4.39975872, -4.33542791],
             [ 9.36746226, -2.91156335,  4.51572032]]],
           [[[-9.23675199,  8.63546962,  6.83448027],
             [ 4.35044123,  2.24508666,  9.80054664],
             [ 0.30835223, -4.05208575,  5.68966326]],
            [[ 6.40300092, -8.25998136,  5.63566553],
             [-5.02801101,  5.64005224, -7.39586166],
             [ 5.90893633,  6.02074669,  1.37112738]],
            [[-2.68485216, -4.67660156,  3.52618441],
             [-2.52484812, -0.08561168,  3.39072868],
             [ 9.11295675,  2.63102786, -4.82285415]]],
           [[[ 8.31973154,  4.76081593,  4.38377207],
             [ 6.22896742, -3.83995097,  5.37501029],
             [-0.16770967,  7.9453854 , -4.95548491]],
            [[-5.67884611, -8.44970885, -7.42037867],
             [-5.19908193, -7.87006493,  1.65949787],
             [-3.25934672,  6.27340198,  5.98643056]],
            [[-4.20166968, -2.38276224,  3.04551936],
             [ 3.68445989, -5.84357996,  3.61183543],
             [ 1.54886677,  3.3659842 ,  6.43067337]]]])
    self.TR1 = tensors.RankFour(self.R1)

    self.SS1 = np.array([
      [ 5.99159801, -2.24342348,  0.26667281, -0.95466199,  3.98931478, -0.10846981],
      [ 1.86468226, -4.32391908, -7.82738638, -7.45008989,  5.89874777, 0.45820648],
      [-5.92565398,  2.4862829 , -6.02112389,  6.75455965,  4.65183463, 9.96900579],
      [ 0.60378883, -3.72189328, -7.63388446, -5.76559403, -0.3119789 , -1.1527258 ],
      [ 4.56813135, -6.06783828, -6.18341368,  8.06169686, -9.56928844, 9.08114655],
      [-8.25516614,  6.30663846,  7.2084381 , -7.38280703, -5.96279902, 8.9935982 ]])
    self.SSS1 = ms2ts(self.SS1)
    self.TSS1 = tensors.SymSymR4(self.SS1)
Example #4
0
 def test_tensor_S(self):
   ST = self.model.S_tensor(self.T)
   S = self.model.S(self.T)
   self.assertEqual(ST, tensors.SymSymR4(S))
Example #5
0
 def test_tensor_C(self):
   CT = self.model.C_tensor(self.T)
   C = self.model.C(self.T)
   self.assertEqual(CT, tensors.SymSymR4(C))
Example #6
0
 def test_id_dev(self):
   ot = np.zeros((6,6))
   ot[:3,:3] = 1.0/3.0
   id_t = tensors.SymSymR4(np.eye(6) - ot)
   self.assertEqual(id_t, tensors.SymSymR4.id_dev())
Example #7
0
  def setUp(self):
    self.WS1 = np.array([
      [-8.3567359 , -5.39728818, -8.00844442, -8.33365112, -0.97903364, -8.23943149],
      [-6.97125417,  4.34802055,  7.06281056, -1.57511617,  7.83359933, -9.37625432],
      [-6.0799489 , -6.0309543 ,  3.68575895,  8.84296976,  6.55799427, -9.22029379]])
    self.WS1_full = common.wws2ts(self.WS1)
    self.TWS1 = tensors.SkewSymR4(self.WS1)

    self.WS2 = np.array([
      [-8.80662663,  0.46179936, -5.49454144,  7.91618428,  5.34053953, -6.68997405],
      [ 4.15874971, -4.59781751,  7.43746813,  8.99981425, -0.97692573, 2.5075246 ],
      [ 9.53201007, -8.03524224,  0.94329443, -6.44415877, -9.92911741, 3.51742689]])
    self.WS2_full = common.wws2ts(self.WS2)
    self.TWS2 = tensors.SkewSymR4(self.WS2)

    self.SW = np.array([
      [ 5.43434005, -6.55983214,  0.29737664],
      [-4.77472172, -8.51287287, -3.19380185],
      [ 4.43407952, -6.02555614,  5.87786914],
      [ 1.89488869, -5.65383917,  8.83717547],
      [-7.18030867,  1.56100537, -9.83238641],
      [-4.52369317, -3.07284914, -7.54966999]])
    self.SW_full = common.ws2ts(self.SW)
    self.TSW = tensors.SymSkewR4(self.SW)

    self.SS = np.array([
      [ 5.99159801, -2.24342348,  0.26667281, -0.95466199,  3.98931478, -0.10846981],
      [ 1.86468226, -4.32391908, -7.82738638, -7.45008989,  5.89874777, 0.45820648],
      [-5.92565398,  2.4862829 , -6.02112389,  6.75455965,  4.65183463, 9.96900579],
      [ 0.60378883, -3.72189328, -7.63388446, -5.76559403, -0.3119789 , -1.1527258 ],
      [ 4.56813135, -6.06783828, -6.18341368,  8.06169686, -9.56928844, 9.08114655],
      [-8.25516614,  6.30663846,  7.2084381 , -7.38280703, -5.96279902, 8.9935982 ]])
    self.SS_full = common.ms2ts(self.SS)
    self.TSS = tensors.SymSymR4(self.SS)

    self.R = np.array([[[[-8.03675620e+00,  2.58575052e+00,  2.44069661e+00],
             [ 4.75021663e+00,  1.24463394e+00, -8.69751301e-01],
             [-1.46310894e+00, -1.15053235e+00, -3.75342982e+00]],
            [[-7.64033956e+00,  4.19956720e+00, -4.87644982e+00],
             [ 1.06577507e+00,  8.94272637e+00,  6.57264250e-01],
             [-4.22613258e+00, -5.08830314e+00,  1.57718186e+00]],
            [[-4.02243082e+00, -4.75463781e+00, -8.88662152e+00],
             [-1.30383950e+00, -1.98063574e+00, -3.18963544e+00],
             [-7.52071674e+00,  1.08931933e+00,  2.86988431e+00]]],
           [[[ 5.28621060e+00, -6.83799668e+00,  8.98005935e+00],
             [-7.92741122e+00,  5.75699425e-01,  1.66782544e+00],
             [ 2.60041984e+00, -1.04476986e-02, -6.12424787e+00]],
            [[-3.73727368e+00,  6.59764771e+00, -1.18045587e+00],
             [ 4.08567441e+00,  2.66148943e+00, -6.82495588e-01],
             [-1.64417262e+00,  5.33119298e+00,  8.11045988e-03]],
            [[-5.90193883e+00, -2.63316107e+00,  5.61381825e+00],
             [-6.08591194e+00,  8.77285539e+00, -7.15230533e+00],
             [ 3.15093096e+00,  1.41350149e+00,  1.11702016e+00]]],
           [[[-9.61472764e-01, -1.91492497e+00,  9.48275324e+00],
             [ 6.68841134e+00,  3.23412041e+00, -3.41944541e+00],
             [-9.80203467e+00,  6.58425335e+00, -2.16548636e+00]],
            [[ 6.63950740e+00,  3.91551441e+00, -8.98229111e+00],
             [ 9.84606756e+00, -8.16145090e+00,  8.41929062e-01],
             [-1.93839620e+00,  7.44485127e+00, -2.70832414e+00]],
            [[ 9.79265531e+00, -1.18212395e+00, -5.39433704e+00],
             [ 4.87152614e+00,  9.47287450e+00,  5.53838514e+00],
             [ 9.30443367e+00,  1.27090319e+00,  1.60409739e+00]]]])
    self.TR = tensors.RankFour(self.R)

    self.S = np.array([[4.1,2.8,-1.2],[3.1,7.1,0.2],[4,2,3]])
    self.S = 0.5*(self.S + self.S.T)
    self.TS = tensors.Symmetric(self.S)

    self.scalar = 5.2

    self.G = np.array([[ 9.50640677,  1.79084726, -2.8877036 ],
       [-1.63159958,  2.52866904, -8.71585042],
       [ 5.01859685, -8.7324075 , -0.42919134]])
    self.TG = tensors.RankTwo(self.G)

    self.W = np.array([[-9.36416517,  2.95527444,  8.70983194],
           [-1.54693052,  8.7905658 , -5.10895168],
           [-8.52740468, -0.7741642 ,  2.89544992]])
    self.W = 0.5 * (self.W - self.W.T)
    self.TW = tensors.Skew(self.W)
Example #8
0
 def test_douter(self):
   self.assertEqual(tensors.SymSymR4(common.ts2ms(np.einsum('ij,kl', self.S, self.S2))), tensors.douter(self.TS, self.TS2))
Example #9
0
 def test_id(self):
   id_t = tensors.SymSymR4(np.eye(6))
   self.assertEqual(id_t, tensors.SymSymR4.id())
Example #10
0
 def test_product_sym_sym(self):
   self.assertEqual(tensors.SymSymR4(np.dot(self.SS1, self.SS2)), self.TSS1 * self.TSS2)
Example #11
0
 def test_scalar_mult(self):
   self.assertEqual(tensors.SymSymR4(self.scalar * self.SS1), self.scalar * self.TSS1)
   self.assertEqual(tensors.SymSymR4(self.scalar * self.SS2), self.TSS2 * self.scalar)
   self.assertEqual(tensors.SymSymR4(self.SS1 / self.scalar), self.TSS1 / self.scalar)
Example #12
0
 def test_negate(self):
   self.assertEqual(tensors.SymSymR4(-self.SS1), -self.TSS1)
Example #13
0
 def test_add(self):
   self.assertEqual(tensors.SymSymR4(self.SS1 + self.SS2), self.TSS2 + self.TSS1)
   self.assertEqual(tensors.SymSymR4(self.SS1 - self.SS2), self.TSS1 - self.TSS2)
Example #14
0
def diff_symmetric_symmetric(fn, s0):
    dfn = lambda s: fn(tensors.Symmetric(usym(s))).data

    return tensors.SymSymR4(differentiate(dfn, s0.data))