Пример #1
0
def test_anisotropic_xi_eigenvectors(rnd_data1, rnd_data2, rnd_data3,
                                     rnd_data4, rnd_data5):
    """
    Check whether eigenvectors fulfill the QEVP.
    """
    lc = LocalCoordinates("1")
    myeps = rnd_data1 + complex(0, 1) * rnd_data2
    # ((epsxx, epsxy, epsxz), (epsyx, epsyy, epsyz), (epszx, epszy, epszz)) = \
    #    tuple(myeps)
    m = AnisotropicMaterial(lc, myeps)
    n = rnd_data3
    n = n / np.sqrt(np.sum(n * n, axis=0))
    x = np.zeros((3, 5))
    k = rnd_data4 + complex(0, 1) * rnd_data5
    kpa = k - np.sum(n * k, axis=0) * n
    ((_, _), (Mmatrix, Cmatrix, Kmatrix)) \
        = m.calcXiQEVMatricesNorm(x, n, kpa)
    (eigenvalues, eigenvectors) = m.calcXiEigenvectorsNorm(x, n, kpa)
    #print(eigenvalues)
    should_be_zero = np.ones((4, 3, 5), dtype=complex)
    for j in range(5):
        for k in range(4):
            should_be_zero[k, :, j] = np.dot(
                (Mmatrix[:, :, j] * eigenvalues[k, j]**2 +
                 Cmatrix[:, :, j] * eigenvalues[k, j] + Kmatrix[:, :, j]),
                eigenvectors[k, :, j])
    assert np.allclose(should_be_zero, 0)
Пример #2
0
def test_anisotropic_xi_determinants(rnd_data1, rnd_data2, rnd_data3,
                                     rnd_data4, rnd_data5):
    """
    Check whether xi zeros from polynomial fulfill the QEVP and the
    associated GLEVP. This also verifies whether A6x6 and B6x6 are
    constructed correctly.
    """
    lc = LocalCoordinates("1")
    myeps = rnd_data1 + complex(0, 1) * rnd_data2
    # ((epsxx, epsxy, epsxz), (epsyx, epsyy, epsyz), (epszx, epszy, epszz)) = \
    #    tuple(myeps)
    m = AnisotropicMaterial(lc, myeps)
    n = rnd_data3
    n = n / np.sqrt(np.sum(n * n, axis=0))
    x = np.zeros((3, 5))
    k = rnd_data4 + complex(0, 1) * rnd_data5
    kpa = k - np.sum(n * k, axis=0) * n
    xiarray = m.calcXiNormZeros(x, n, kpa)
    ((Amatrix6x6, Bmatrix6x6), (Mmatrix, Cmatrix, Kmatrix)) \
        = m.calcXiQEVMatricesNorm(x, n, kpa)
    should_be_zero_1 = np.ones((4, 5), dtype=complex)
    should_be_zero_2 = np.ones((4, 5), dtype=complex)
    for j in range(5):
        for xi_num in range(4):
            should_be_zero_1[xi_num, j] = np.linalg.det(
                (Mmatrix[:, :, j] * xiarray[xi_num, j]**2 +
                 Cmatrix[:, :, j] * xiarray[xi_num, j] + Kmatrix[:, :, j]))
            should_be_zero_2[xi_num, j] = np.linalg.det(
                (Amatrix6x6[:, :, j] -
                 Bmatrix6x6[:, :, j] * xiarray[xi_num, j]))
    assert np.allclose(should_be_zero_1, 0)
    assert np.allclose(should_be_zero_2, 0)