예제 #1
0
def uel3ntrian(coord, par):
    """Triangular element with 3 nodes

    Parameters
    ----------
    coord : ndarray
      Coordinates for the nodes of the element (3, 2).
    enu : float
      Poisson coefficient (-1, 0.5).
    Emod : float
      Young modulus (>0).

    Returns
    -------
    kl : ndarray
      Local stiffness matrix for the element (6, 6).

    Examples
    --------

    >>> coord = np.array([
    ...         [0, 0],
    ...         [1, 0],
    ...         [0, 1]])
    >>> stiff = uel3ntrian(coord, 1/3, 8/3)
    >>> stiff_ex = 1/2 * np.array([
    ...            [4, 2, -3, -1, -1, -1],
    ...            [2, 4, -1, -1, -1, -3],
    ...            [-3, -1, 3, 0, 0, 1],
    ...            [-1, -1, 0, 1, 1, 0],
    ...            [-1, -1, 0, 1, 1, 0],
    ...            [-1, -3, 1, 0, 0, 3]])
    >>> np.allclose(stiff, stiff_ex)
    True

    """
    Emod = par[0]
    enu = par[1]
    rho = par[2]
    calpha = par[3]
    cbeta = par[4]
    kl = np.zeros([6, 6])
    ml = np.zeros([6, 6])
    cl = np.zeros([6, 6])
    C = fem.umat(enu, Emod, rho)
    XW, XP = gau.gpoints3()
    ngpts = 3
    for i in range(ngpts):
        ri = XP[i, 0]
        si = XP[i, 1]
        alf = XW[i]
        ddet, B = fem.stdm3NT(ri, si, coord)
        N = fem.sha3(ri, si)
        kl = kl + 0.5 * np.dot(np.dot(B.T, C), B) * alf * ddet
        ml = ml + 0.5 * rho * np.dot(N.T, N) * alf * ddet
    cl = calpha * kl + cbeta * ml
    return kl, ml, cl
예제 #2
0
def uel6ntrian(coord, enu, Emod):
    """Triangular element with 6 nodes

    Parameters
    ----------
    coord : ndarray
      Coordinates for the nodes of the element (6, 2).
    enu : float
      Poisson coefficient (-1, 0.5).
    Emod : float
      Young modulus (>0).

    Returns
    -------
    kl : ndarray
      Local stiffness matrix for the element (12, 12).
 
    Examples
    --------
    
    >>> coord = Matrix([
    ...         [0, 0],
    ...         [1, 0],
    ...         [0, 1],
    ...         [0.5, 0],
    ...         [0.5, 0.5],
    ...         [0, 0.5]])
    >>> stiff = uel6ntrian(coord, S(1)/3, S(8)/3)
    >>> stiff_ex = 1/6 * Matrix([
    ...            [12, 6, 3, 1, 1, 1, -12, -4, 0, 0, -4, -4],
    ...            [6, 12, 1, 1, 1, 3, -4, -4, 0, 0, -4, -12],
    ...            [3, 1, 9, 0, 0, -1, -12, -4, 0, 4, 0, 0],
    ...            [1, 1, 0, 3, -1, 0, -4, -4, 4, 0, 0, 0],
    ...            [1, 1, 0, -1, 3, 0, 0, 0, 0, 4, -4, -4],
    ...            [1, 3, -1, 0, 0, 9, 0, 0, 4, 0, -4, -12],
    ...            [-12, -4, -12, -4, 0, 0, 32, 8, -8, -8, 0, 8],
    ...            [-4, -4, -4, -4, 0, 0, 8, 32, -8, -24, 8, 0],
    ...            [0, 0, 0, 4, 0, 4, -8, -8, 32, 8, -24, -8],
    ...            [0, 0, 4, 0, 4, 0, -8, -24, 8, 32, -8, -8],
    ...            [-4, -4, 0, 0, -4, -4, 0, 8, -24, -8, 32, 8],
    ...            [-4, -12, 0, 0, -4, -12, 8, 0, -8, -8, 8, 32]])
    >>> (stiff - stiff_ex).norm()/stiff_ex.norm() < 1e-6
    True
    
    """
    kl = np.zeros([12, 12])
    C = fem.umat(enu, Emod)
    XW, XP = gau.gpoints7()
    ngpts = 7
    for i in range(ngpts):
        ri = XP[i, 0]
        si = XP[i, 1]
        alf = XW[i]
        ddet, B = fem.stdm6NT(ri, si, coord)
        kl = kl + 0.5*B.T*C*B*alf*ddet
    return kl
예제 #3
0
def uel9nquad(coord, par):
    """Quadrilateral element with 4 nodes

    Parameters
    ----------
    coord : ndarray
      Coordinates for the nodes of the element (4, 2).
    enu : float
      Poisson coefficient (-1, 0.5).
    Emod : float
      Young modulus (>0).

    Returns
    -------
    kl : ndarray
      Local stiffness matrix for the element (8, 8).

    Examples
    --------

    >>> coord = np.array([[-1, -1], [1, -1], [1, 1], [-1, 1]])
    >>> stiff = uel4nquad(coord, 1/3, 8/3)
    >>> stiff_ex = 1/6 * np.array([
    ...             [ 8,  3, -5,  0, -4, -3,  1,  0],
    ...             [ 3,  8,  0,  1, -3, -4,  0, -5],
    ...             [-5,  0,  8, -3,  1,  0, -4,  3],
    ...             [ 0,  1, -3,  8,  0, -5,  3, -4],
    ...             [-4, -3,  1,  0,  8,  3, -5,  0],
    ...             [-3, -4,  0, -5,  3,  8,  0,  1],
    ...             [ 1,  0, -4,  3, -5,  0,  8, -3],
    ...             [ 0, -5,  3, -4,  0,  1, -3,  8]])
    >>> np.allclose(stiff, stiff_ex)
    True

    """
    Emod = par[0]
    enu = par[1]
    rho = par[2]
    calpha = par[3]
    cbeta = par[4]
    kl = np.zeros([18, 18])
    ml = np.zeros([18, 18])
    cl = np.zeros([18, 18])
    C = fem.umat(enu, Emod, rho)
    XW, XP = gau.gpoints3x3()
    ngpts = 9
    for i in range(0, ngpts):
        ri = XP[i, 0]
        si = XP[i, 1]
        alf = XW[i]
        ddet, B = fem.stdm9NQ(ri, si, coord)
        N = fem.sha9(ri, si)
        kl = kl + np.dot(np.dot(B.T, C), B) * alf * ddet
        ml = ml + rho * np.dot(N.T, N) * alf * ddet
    cl = calpha * kl + cbeta * ml
    return kl, ml, cl
예제 #4
0
def uel3ntrian(coord, enu, Emod):
    """Triangular element with 3 nodes

    Parameters
    ----------
    coord : ndarray
      Coordinates for the nodes of the element (3, 2).
    enu : float
      Poisson coefficient (-1, 0.5).
    Emod : float
      Young modulus (>0).

    Returns
    -------
    kl : ndarray
      Local stiffness matrix for the element (6, 6).

    Examples
    --------
    
    >>> coord = Matrix([
    ...         [0, 0],
    ...         [1, 0],
    ...         [0, 1]])
    >>> stiff = uel3ntrian(coord, S(1)/3, S(8)/3)
    >>> stiff_ex = 1/2 * Matrix([
    ...            [4, 2, -3, -1, -1, -1],
    ...            [2, 4, -1, -1, -1, -3],
    ...            [-3, -1, 3, 0, 0, 1],
    ...            [-1, -1, 0, 1, 1, 0],
    ...            [-1, -1, 0, 1, 1, 0],
    ...            [-1, -3, 1, 0, 0, 3]])
    >>> (stiff - stiff_ex).norm()/stiff_ex.norm() < 1e-6
    True

    """
    kl = np.zeros([6, 6])
    C = fem.umat(enu, Emod)
    XW, XP = gau.gpoints3()
    ngpts = 3
    for i in range(ngpts):
        ri = XP[i, 0]
        si = XP[i, 1]
        alf = XW[i]
        ddet, B = fem.stdm3NT(ri, si, coord)
        kl = kl + 0.5*B.T*C*B*alf*ddet
    return kl
예제 #5
0
def uel4nquad(coord, enu, Emod):
    """Quadrilateral element with 4 nodes

    Parameters
    ----------
    coord : ndarray
      Coordinates for the nodes of the element (4, 2).
    enu : float
      Poisson coefficient (-1, 0.5).
    Emod : float
      Young modulus (>0).

    Returns
    -------
    kl : ndarray
      Local stiffness matrix for the element (8, 8).

    Examples
    --------
    
    >>> coord = Matrix([[-1, -1], [1, -1], [1, 1], [-1, 1]])
    >>> stiff = uel4nquad(coord, S(1)/3, S(8)/3)
    >>> stiff_ex = 1/6 * Matrix([
    ...             [ 8,  3, -5,  0, -4, -3,  1,  0],
    ...             [ 3,  8,  0,  1, -3, -4,  0, -5],
    ...             [-5,  0,  8, -3,  1,  0, -4,  3],
    ...             [ 0,  1, -3,  8,  0, -5,  3, -4],
    ...             [-4, -3,  1,  0,  8,  3, -5,  0],
    ...             [-3, -4,  0, -5,  3,  8,  0,  1],
    ...             [ 1,  0, -4,  3, -5,  0,  8, -3],
    ...             [ 0, -5,  3, -4,  0,  1, -3,  8]])
    >>> (stiff - stiff_ex).norm()/stiff_ex.norm() < 1e-6
    True

    """
    kl = np.zeros([8, 8])
    C = fem.umat(enu, Emod)
    XW, XP = gau.gpoints2x2()
    ngpts = 4
    for i in range(0, ngpts):
        ri = XP[i, 0]
        si = XP[i, 1]
        alf = XW[i]
        ddet, B = fem.stdm4NQ(ri, si, coord)
        kl = kl + B.T*C*B*alf*ddet
    return kl
예제 #6
0
def locstrain3nT(ul, coord, enu, Emod):
    """
    Plot strain and stress for a linear 3-noded element in the
    natural space

    Parameters
    ----------
    ul : ndarray (float)
      Array with the displacements for the element.
    coord : ndarray (float)
      Coordinates for the nodes of the element.
    enu : float
      Poisson coefficient in the range (-1, 0.5).
    Emod : float
      Young modulus, should be greater than zero.

    """
    r = np.zeros([3, 2])
    eG = np.zeros([3, 3])
    sG = np.zeros([3, 3])
    eps = np.zeros([3, 3])
    e = np.zeros([3])
    s = np.zeros([3])
    C = np.zeros([3, 3])

    r[0, 0] = 0.0
    r[0, 1] = 0.0
    r[1, 0] = 1.0
    r[1, 1] = 0.0
    r[2, 0] = 0.0
    r[2, 1] = 1.0
    C = fe.umat(enu, Emod)
    for i in range(3):
        ri = r[i, 0]
        si = r[i, 1]
        ddet, B = fe.stdm3NT(ri, si, coord)
        eps = B*ul
        sig = C*eps
        eG[:, i] = eps[:]
        sG[:, i] = sig[:]
    grid_x, grid_y = np.mgrid[0:1:100j, 0:1:100j]

    print('Strain field')
    for j in range(3):
        for i in range(3):
            e[i] = eG[j, i]
        plt.figure()
        grid_z0 = griddata(r, e, (grid_x, grid_y), method='linear')
        plt.imshow(grid_z0.T, aspect='equal', extent=(0.0, 1.0, 0.0, 1.0),
                   origin='lower')
        plt.colorbar(orientation='vertical')
        plt.grid()

    print('Stress field')
    for j in range(3):
        for i in range(3):
            s[i] = sG[j, i]
        plt.figure()
        grid_z0 = griddata(r, s, (grid_x, grid_y), method='linear')
        plt.imshow(grid_z0.T, aspect='equal', extent=(0.0, 1.0, 0.0, 1.0),
                   origin='lower')
        plt.colorbar(orientation='vertical')
        plt.grid()
예제 #7
0
def locstrain3nT(ul, coord, enu, Emod):
    """
    Plot strain and stress for a linear 3-noded element in the
    natural space

    Parameters
    ----------
    ul : ndarray (float)
      Array with the displacements for the element.
    coord : ndarray (float)
      Coordinates for the nodes of the element.
    enu : float
      Poisson coefficient in the range (-1, 0.5).
    Emod : float
      Young modulus, should be greater than zero.

    """
    r = np.zeros([3, 2])
    eG = np.zeros([3, 3])
    sG = np.zeros([3, 3])
    eps = np.zeros([3, 3])
    e = np.zeros([3])
    s = np.zeros([3])
    C = np.zeros([3, 3])

    r[0, 0] = 0.0
    r[0, 1] = 0.0
    r[1, 0] = 1.0
    r[1, 1] = 0.0
    r[2, 0] = 0.0
    r[2, 1] = 1.0
    C = fe.umat(enu, Emod)
    for i in range(3):
        ri = r[i, 0]
        si = r[i, 1]
        ddet, B = fe.stdm3NT(ri, si, coord)
        eps = B * ul
        sig = C * eps
        eG[:, i] = eps[:]
        sG[:, i] = sig[:]
    grid_x, grid_y = np.mgrid[0:1:100j, 0:1:100j]

    print('Strain field')
    for j in range(3):
        for i in range(3):
            e[i] = eG[j, i]
        plt.figure()
        grid_z0 = griddata(r, e, (grid_x, grid_y), method='linear')
        plt.imshow(grid_z0.T,
                   aspect='equal',
                   extent=(0.0, 1.0, 0.0, 1.0),
                   origin='lower')
        plt.colorbar(orientation='vertical')
        plt.grid()

    print('Stress field')
    for j in range(3):
        for i in range(3):
            s[i] = sG[j, i]
        plt.figure()
        grid_z0 = griddata(r, s, (grid_x, grid_y), method='linear')
        plt.imshow(grid_z0.T,
                   aspect='equal',
                   extent=(0.0, 1.0, 0.0, 1.0),
                   origin='lower')
        plt.colorbar(orientation='vertical')
        plt.grid()