2-D FEM shape functions
Compute the shape functions at try the interpolation at different “integration” pints within the element.
[1]:
import numpy as np
[2]:
#def shapes():
#
# N1 = ?
# N2 = ?
# N3 = ?
# N4 = ?
# N = np.array([N1, N2, N3, N4])
# return N
[3]:
#hide
def shapes(xi, eta):
#shape functions
N1 = 0.25*(1-xi)*(1-eta)
N2 = 0.25*(1+xi)*(1-eta)
N3 = 0.25*(1+xi)*(1+eta)
N4 = 0.25*(1-xi)*(1+eta)
N = np.array([N1, N2, N3, N4])
# and their derivatives
dNds = np.zeros((2,4))
dNds[0,0] = 0.25*(-1 + eta) #derivative with xi
dNds[1,0] = 0.25*(xi - 1) #derivative with eta
#derivatives of second shape function with local coordinates
dNds[0,1] = 0.25*(1 - eta)
dNds[1,1] = 0.25*(-xi - 1)
#derivatives of third shape function with local coordinates
dNds[0,2] = 0.25*(eta + 1)
dNds[1,2] = 0.25*(xi + 1)
#derivatives of fourth shape function with local coordinates
dNds[0,3] = 0.25*(-eta - 1)
dNds[1,3] = 0.25*(1 - xi)
return N, dNds
[27]:
# pseudo gcoord
GCOORD = np.array([[-1, 1, 1, -1],[-1, -1, 1, 1]])
#print(GCOORD)
# pseudo nodal temperatures
T = np.array([0, 0, 1, 1])
#print(T)
# interpolatin point
xi = 1
eta = 0.3
# shape functions at integration point
N, dNds = shapes(xi,eta)
#interpolation
print(N)
print(sum(dNds[1,:]*T))
print(sum(N*T))
[0. 0.35 0.65 0. ]
0.5
0.65
[9]:
sum(N)
[9]:
1.0
[ ]: