def INCKE(KS, KEl): #STIFF下位程序, 将单元刚度矩阵迭代插入总体刚度矩阵 mn = ref.arrIndexSort(KEl[0])[:,1].T ij = ref.arrIndexSort(KEl[0])[:,0].T KE = KEl[1] map(lambda i: map(lambda j: AINCKE([[mn[i], mn[j]],KS], [[i,j],KE]), ij), ij) return KS
def insKE(KS, lKE): #GKS() sub reduce() function, insert KE of a single element #lKE = [[[LableInElement, NodeLable],[0,91],[1,92], ...], KE] mn = ref.arrIndexSort(lKE[0])[:,1].T ij = ref.arrIndexSort(lKE[0])[:,0].T KE = lKE[1] map(lambda i: map(lambda j: insKEIJ([[mn[i], mn[j]],KS], [[i,j],KE]), ij), ij) return KS
def INCKE(KS, KEl): #STIFF下位程序, 将单元刚度矩阵迭代插入总体刚度矩阵 mn = ref.arrIndexSort(KEl[0])[:, 1].T ij = ref.arrIndexSort(KEl[0])[:, 0].T KE = KEl[1] map( lambda i: map(lambda j: AINCKE([[mn[i], mn[j]], KS], [[i, j], KE]), ij ), ij) return KS
def insKE(KS, lKE): #KS() sub reduce() function, insert KE of a single element #lKE = [[[LableInElement, NodeLable],[0,91],[1,92], ...], KE] mn = ref.arrIndexSort(lKE[0])[:, 1].T ij = ref.arrIndexSort(lKE[0])[:, 0].T KE = lKE[1] map( lambda i: map(lambda j: insKEIJ([[mn[i], mn[j]], KS], [[i, j], KE]), ij ), ij) return KS
def FEM(inputDict): #有限元 HIP = ref.arrIndexSort(inputDict['HIP']) HIP = np.matrix(HIP[:,1:3].reshape(-1,1)) KS = STIFF(inputDict) KS = INSCD(KS, inputDict['BIU']) Solution = np.linalg.solve(KS, HIP) Solution = np.array(Solution.reshape((-1,2))) return Solution
def FEM(inputDict): #有限元 HIP = ref.arrIndexSort(inputDict['HIP']) HIP = np.matrix(HIP[:, 1:3].reshape(-1, 1)) KS = STIFF(inputDict) KS = INSCD(KS, inputDict['BIU']) Solution = np.linalg.solve(KS, HIP) Solution = np.array(Solution.reshape((-1, 2))) return Solution
def STIFF(FEMinput): #生成总体刚度矩阵 IJMH = FEMinput['IJMH'] E = FEMinput['TEVW']['E'] PR = FEMinput['TEVW']['pr'] t = FEMinput['TEVW']['t'] XY = FEMinput['XY'] KS = np.zeros((FEMinput['XY'].shape[0]*2, FEMinput['XY'].shape[0]*2)) XY = ref.arrIndexSort(XY) IJMH = ref.lstIndexSort(IJMH) KEs = map(lambda EN: STE(XY[EN[1][:,1],:], E, PR, t, EN[0], IJMH), IJMH)#单元刚度矩阵List KS = np.matrix(reduce(INCKE, KEs, KS)) return KS
def STIFF(FEMinput): #生成总体刚度矩阵 IJMH = FEMinput['IJMH'] E = FEMinput['TEVW']['E'] PR = FEMinput['TEVW']['pr'] t = FEMinput['TEVW']['t'] XY = FEMinput['XY'] KS = np.zeros((FEMinput['XY'].shape[0] * 2, FEMinput['XY'].shape[0] * 2)) XY = ref.arrIndexSort(XY) IJMH = ref.lstIndexSort(IJMH) KEs = map(lambda EN: STE(XY[EN[1][:, 1], :], E, PR, t, EN[0], IJMH), IJMH) #单元刚度矩阵List KS = np.matrix(reduce(INCKE, KEs, KS)) return KS
def GKS(FEMinput): #Calculate global stiffness matrix IJ = FEMinput['IJ'] E = FEMinput['TEV']['E'] V = FEMinput['TEV']['V'] T = FEMinput['TEV']['T'] XY = FEMinput['XY'] KS = np.zeros((XY.shape[0]*2, XY.shape[0]*2)) XY = ref.arrIndexSort(XY) IJ = ref.lstIndexSort(IJ) KE = KEsquare(E, V, T) KEsl = [KEdcr(KE, EN[0], IJ) for EN in IJ]#List of Element stiffness matrix KS = np.matrix(reduce(insKE, KEsl, KS)) return KS
def GKS(FEMinput): #Calculate global stiffness matrix IJ = FEMinput['IJ'] E = FEMinput['TEV']['E'] V = FEMinput['TEV']['V'] T = FEMinput['TEV']['T'] XY = FEMinput['XY'] KS = np.zeros((XY.shape[0] * 2, XY.shape[0] * 2)) XY = ref.arrIndexSort(XY) IJ = ref.lstIndexSort(IJ) KE = KEsquare(E, V, T) KEsl = [KEdcr(KE, EN[0], IJ) for EN in IJ] #List of Element stiffness matrix KS = np.matrix(reduce(insKE, KEsl, KS)) return KS
def INSCD(KS, BIU): #插入支承条件, 修改总体刚度矩阵 BIU = ref.arrIndexSort(BIU) KS = np.matrix(reduce(INSCDS, BIU, KS)) return KS