(vertices, lame, mu)
return K
Local stiffness matrix for two dimensional elasticity on a square element.

    Parameters
    ----------
    lame : Float
        Lame's first parameter
    mu : Float
        shear modulus

    See Also
    --------
    linear_elasticity

    Notes
    -----
    Vertices should be listed in counter-clockwise order::

        [3]----[2]
         |      |
         |      |
        [0]----[1]

    Degrees of freedom are enumerated as follows::

        [x=6,y=7]----[x=4,y=5]
            |            |
            |            |
        [x=0,y=1]----[x=2,y=3]
Local stiffness matrix for two dimensional elasticity on a square element.
Local stiffness matrix for two dimensional elasticity on a square element .
def q12d_local(vertices, lame, mu):
    """Local stiffness matrix for two dimensional elasticity on a square element.

    Parameters
    ----------
    lame : Float
        Lame's first parameter
    mu : Float
        shear modulus

    See Also
    --------
    linear_elasticity

    Notes
    -----
    Vertices should be listed in counter-clockwise order::

        [3]----[2]
         |      |
         |      |
        [0]----[1]

    Degrees of freedom are enumerated as follows::

        [x=6,y=7]----[x=4,y=5]
            |            |
            |            |
        [x=0,y=1]----[x=2,y=3]

    """
    M = lame + 2*mu  # P-wave modulus

    R_11 = np.array([[2, -2, -1, 1],
                     [-2, 2, 1, -1],
                     [-1, 1, 2, -2],
                     [1, -1, -2, 2]]) / 6.0

    R_12 = np.array([[1, 1, -1, -1],
                     [-1, -1, 1, 1],
                     [-1, -1, 1, 1],
                     [1, 1, -1, -1]]) / 4.0

    R_22 = np.array([[2, 1, -1, -2],
                     [1, 2, -2, -1],
                     [-1, -2, 2, 1],
                     [-2, -1, 1, 2]]) / 6.0

    F = sla.inv(np.vstack((vertices[1] - vertices[0], vertices[3] - vertices[0])))

    K = np.zeros((8, 8))  # stiffness matrix

    E = F.T.dot(np.array([[M, 0], [0, mu]])).dot(F)
    K[0::2, 0::2] = E[0, 0] * R_11 + E[0, 1] * R_12 +\
        E[1, 0] * R_12.T + E[1, 1] * R_22

    E = F.T.dot(np.array([[mu, 0], [0, M]])).dot(F)
    K[1::2, 1::2] = E[0, 0] * R_11 + E[0, 1] * R_12 +\
        E[1, 0] * R_12.T + E[1, 1] * R_22

    E = F.T.dot(np.array([[0, mu], [lame, 0]])).dot(F)
    K[1::2, 0::2] = E[0, 0] * R_11 + E[0, 1] * R_12 +\
        E[1, 0] * R_12.T + E[1, 1] * R_22

    K[0::2, 1::2] = K[1::2, 0::2].T

    K /= sla.det(F)
    return K
def q12d_local ( vertices , lame , mu ) : M = lame + 2 * mu # P-wave modulus R_11 = np . array ( [ [ 2 , - 2 , - 1 , 1 ] , [ - 2 , 2 , 1 , - 1 ] , [ - 1 , 1 , 2 , - 2 ] , [ 1 , - 1 , - 2 , 2 ] ] ) / 6.0 R_12 = np . array ( [ [ 1 , 1 , - 1 , - 1 ] , [ - 1 , - 1 , 1 , 1 ] , [ - 1 , - 1 , 1 , 1 ] , [ 1 , 1 , - 1 , - 1 ] ] ) / 4.0 R_22 = np . array ( [ [ 2 , 1 , - 1 , - 2 ] , [ 1 , 2 , - 2 , - 1 ] , [ - 1 , - 2 , 2 , 1 ] , [ - 2 , - 1 , 1 , 2 ] ] ) / 6.0 F = sla . inv ( np . vstack ( ( vertices [ 1 ] - vertices [ 0 ] , vertices [ 3 ] - vertices [ 0 ] ) ) ) K = np . zeros ( ( 8 , 8 ) ) # stiffness matrix E = F . T . dot ( np . array ( [ [ M , 0 ] , [ 0 , mu ] ] ) ) . dot ( F ) K [ 0 : : 2 , 0 : : 2 ] = E [ 0 , 0 ] * R_11 + E [ 0 , 1 ] * R_12 + E [ 1 , 0 ] * R_12 . T + E [ 1 , 1 ] * R_22 E = F . T . dot ( np . array ( [ [ mu , 0 ] , [ 0 , M ] ] ) ) . dot ( F ) K [ 1 : : 2 , 1 : : 2 ] = E [ 0 , 0 ] * R_11 + E [ 0 , 1 ] * R_12 + E [ 1 , 0 ] * R_12 . T + E [ 1 , 1 ] * R_22 E = F . T . dot ( np . array ( [ [ 0 , mu ] , [ lame , 0 ] ] ) ) . dot ( F ) K [ 1 : : 2 , 0 : : 2 ] = E [ 0 , 0 ] * R_11 + E [ 0 , 1 ] * R_12 + E [ 1 , 0 ] * R_12 . T + E [ 1 , 1 ] * R_22 K [ 0 : : 2 , 1 : : 2 ] = K [ 1 : : 2 , 0 : : 2 ] . T K /= sla . det ( F ) return K