def Triangle_2D_3Node_Stiffness(E,mu,t,xy,i,j,m,):
"""
FUNC: this function calculates the element stiffness matrix
for a 2D 3 nodes plane element
PARA: E -Young's modulus
mu -Poisson's ratio
t -thick of plate
xy -locations of nodes, eg.[(x1,y1),(x2,y2),(x3,y3)]
ID -1 for plane stress, 2 for plane strain
"""
(xi,yi),(xj,yj),(xm,ym) = xy_e
A_e = (xi*(yj-ym) + xj*(ym-yi) + xm*(yi-yj))/2
ai, aj, am = xj*ym - xm*yj, xm*yi - xi*ym, xi*yj - xj*yi
bi, bj, bm = yj-ym, ym-yi, yi-yj
ci, cj, cm = xm-xj, xi-xm, xj-xi
B = np.mat([ [bi, 0, bj, 0, bm, 0],
[ 0, ci, 0, cj, 0, cm],
[cj, bi, cj, bj, cm, bm] ])/(2*A)
D = (E/(1-mu**2))*np.mat([ [ 1, mu, 0],
[mu, 1, 0],
[ 0, 0, (1-mu)/2] ])
k_e = t*A*np.transpose(B)*D*B
return k