for i in range(edof): for j in range(edof): k[i, j] = k[i, j] + (dhdx[i] * dhdx[j] + dhdy[i] * dhdy[j]) * wtx * wty * detjacob # extract system dofs for the element index = feeldof.feeldof(nd, nnel, ndof) # ------------------------- # assemble element matrices # ------------------------- kk = feasmbl1.feasmbl1(kk, k, index) # ------------------------- # apply boundary conditions # ------------------------- kk, ff = feaplyc2.feaplyc2(kk, ff, bcdof, bcval) # ------------------------- # solve the matrix equation # ------------------------- fsol = np.linalg.solve(kk, ff) # ------------------- # analytical solution # ------------------- esol = np.zeros(nnode) for i in range(nnode): x = gcoord[i, 0] y = gcoord[i, 1] esol[i] = 100 * np.sinh(0.31415927 * y) * np.sin( 0.31415927 * x) / np.sinh(3.1415927)
k = felp2dt3.felp2dt3(x, y) # compute element matrix m = felpt2t3.felpt2t3(x, y) # compute element matrix kk = feasmbl1.feasmbl1(kk, k, index) # assemble element matrices mm = feasmbl1.feasmbl1(mm, m, index) # assemble element matrices # ------------------------- # loop for time integration # ------------------------- fsol = np.zeros(sdof) sol[0, 0] = fsol[7] # store time history solution for node 7 sol[1, 0] = fsol[8] # store time history solution for node 8 kk = mm + deltt * kk for it in range(ntime): # start loop for time integration fn = deltt * ff + np.dot(mm, fsol) # compute effective column vector kk, fn = feaplyc2.feaplyc2(kk, fn, bcdof, bcval) # apply boundary condition fsol = np.linalg.solve(kk, fn) # solve the matrix equation sol[0, it + 1] = fsol[7] # store time history solution for node 7 sol[1, it + 1] = fsol[8] # store time history solution for node 8 # ---------------------------------- # plot the solution at nodes 7 and 8 # ---------------------------------- time = np.arange(0, (ntime * deltt) + deltt, deltt) fig, axis = plt.subplots() axis.plot(time, sol[0, :], '*', label='Node 7') axis.plot(time, sol[1, :], '-', label='Node 8') axis.set_xlabel('Time') axis.set_ylabel('Solution at nodes 7 and 8') axis.legend()