def test_sub_operator__simple(self): l1, l2 = Lin.rand(), Lin.rand() assert l1 - l2 == l1 - (-l2) # Anyway, axial sub is commutative. assert l1 - l2 == l2 - l1
def test_add_operator__simple(self): l1, l2 = Lin.rand(), Lin.rand() assert l1 + l2 == l1 + (-l2) # Anyway, axial add is commutative. assert l1 + l2 == l2 + l1
def test_pair_equal(self): n, lin = Lin.rand(), Lin.rand() fol = n**lin p = Pair.from_pair(fol, lin) assert p == Pair.from_pair(fol, lin) assert p == Pair.from_pair(fol, -lin) assert p == Pair.from_pair(-fol, lin) assert p == Pair.from_pair(-fol, -lin)
def test_pair_equal(): n, lin = Lin.rand(), Lin.rand() fol = n ** lin p = Pair.from_pair(fol, lin) assert p == Pair.from_pair(fol, lin) assert p == Pair.from_pair(fol, -lin) assert p == Pair.from_pair(-fol, lin) assert p == Pair.from_pair(-fol, -lin)
def test_mutual_rotation(self): l1, l2 = Lin.rand(), Lin.rand() assert l1.transform(l1.H(l2)) == l2
def test_lineation_product_operator(self): l1, l2 = Lin.rand(), Lin.rand() assert l1.cross(l2) == l1**l2
def test_lineation_product(self): l1, l2 = Lin.rand(), Lin.rand() p = l1.cross(l2) assert np.allclose([p.angle(l1), p.angle(l2)], [90, 90])
def test_cross_product(self): l1, l2 = Lin.rand(), Lin.rand() p = l1**l2 assert np.allclose([p.angle(l1), p.angle(l2)], [90, 90])
def test_scalar_product(self): lin = Lin.rand() assert np.allclose(lin * lin, 1)
def test_equality_for_oposite_dir(self): lin = Lin.rand() assert lin == -lin
def test_angle_under_rotation(self): l1, l2 = Lin.rand(), Lin.rand() D = DefGrad.from_axis(Lin(45, 45), 60) assert np.allclose(l1.angle(l2), l1.transform(D).angle(l2.transform(D)))
def test_orthogonality_rotation_matrix(): lin = Lin.rand() a = np.random.randint(180) R = DefGrad.from_axis(lin, a) assert np.allclose(R * R.T, np.eye(3))
def test_lineation_product_operator(self): l1, l2 = Lin.rand(), Lin.rand() assert l1.cross(l2) == l1 ** l2
def test_stress_invariants_under_rotation(): S = Stress.from_comp(xx=4, yy=6, zz=8, xy=1, xz=2) lin = Lin.rand() a = np.random.randint(180) Sr = S.rotate(lin, a) assert np.allclose([S.I1, S.I2, S.I3], [Sr.I1, Sr.I2, Sr.I3])