def Dif_basic_F(S, Coords): E = Element("Q4") N = E.N() G_map = E.G_map() F = np.zeros((len(Coords), 1)) #print(F) x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3] W_ip = [1, 1] for i in range(len(x_ip)): N_l = N(x_ip[i], x_ip[i]) #N local N_T = np.transpose(N_l) B, Jdet = G_map(x_ip[i], x_ip[i], Coords) #print("N_T is ",N_T) S_val = S(x_ip[i], x_ip[i]) #print(S_val) F = F + N_T * S_val * Jdet * W_ip[i] * W_ip[i] #print(F) #reference file file = open('../outputs/f_elemental.txt', 'w') for i in range(4): if i != 0: file.write('\n') file.write(str(F[i])) file.write(" ") file.close() return F
def Dif_basic_K(Coords, k=1): #let k be an optional arguement num_nodes = 4 # number of nodes E = Element("Q4") # K = np.zeros((num_nodes,num_nodes)) # Now to step through K_mat and integrate each element Ke = np.zeros((len(Coords), len(Coords))) x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3] W_ip = [1, 1] for i in range(len(x_ip)): for j in range(len(x_ip)): # now ready to integrate G_m = E.G_map() B, Jdet = G_m(x_ip[i], x_ip[j], Coords) B_T = np.transpose(B) Ke = Ke + B_T.dot(B) * k * Jdet * W_ip[i] * W_ip[j] #print(Ke) #Ke = Ke + ((np.transpose(B)) * k * B * Jdet * W_ip[i] * W_ip[j]) #Ke = Ke + (np.dot(np.transpose(B_val), k*B_val) * abs(J_d_val)*w_ip[i]*w_ip[j]) #file = open('../outputs/K_elemental.txt', 'w') #for i in range(4): # if i != 0: # file.write('\n') # for j in range(4): # file.write(str(K[i, j])) # file.write(" ") #file.close() return Ke
def calcStressStrainElemental(d, A, NodalCoord, Connectivity): #calculate strains in center of element! E = Element("Q4") stress = np.zeros((3, len(Connectivity))) strain = np.zeros((3, len(Connectivity))) for e in range(0, len(Connectivity)): Coord_mat_el = getElementCoordinates(e, NodalCoord, Connectivity) Elemental_disp = getElementDisplacements(e, d, A) gradN, detJ = E.G_map(0, 0, Coord_mat_el) B = get_B_plane_stress(gradN) strain[:, e] = np.dot(B, Elemental_disp)[:, 0] stress[:, e] = strain[:, e] return strain, stress
def ES_K(Coords): num_nodes = 4 # number of nodes E = Element("Q4") # Now to step through K_mat and integrate each element Ke = np.zeros((len(Coords), len(Coords))) x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3] print(len(Coords)) W_ip = [1, 1] for i in range(len(x_ip)): for j in range(len(x_ip)): # now ready to integrate G_m = E.G_map() B, Jdet = G_m(x_ip[i], x_ip[j], Coords)
def getInternalForces(Coord_mat_el,sigma): E = Element("Q4") weights = [1, 1] xIP = [-np.sqrt(3) / 3, np.sqrt(3) / 3] fint_pre = np.zeros((1,8)) count = 0 for i in range(len(xIP)): for j in range(len(xIP)): gradN, detJ = E.G_map(xIP[i], xIP[j], Coord_mat_el) B = get_B_plane_stress(gradN) fint_pre += np.dot(np.transpose(B),sigma[:,count]) * detJ * weights[i] * weights[j] count += 1 return np.transpose(fint_pre)
def getStrainElement(Coord_mat_el, d): E = Element("Q4") xIP = [-np.sqrt(3) / 3, np.sqrt(3) / 3] epsilon = np.zeros((3, 4)) count = 0 for i in range(len(xIP)): for j in range(len(xIP)): gradN, detJ = E.G_map(xIP[i], xIP[j], Coord_mat_el) B = get_B_plane_stress(gradN) val = np.dot(B, d) for k in range(3): epsilon[k, count] = val[k] count += 1 return epsilon
def Dif_basic_K(Coords, k=1): #let k be an optional arguement E = Element("Q4") Ke = np.zeros((len(Coords), len(Coords))) x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3] W_ip = [1, 1] for i in range(len(x_ip)): for j in range(len(x_ip)): # now ready to integrate G_m = E.G_map() B, Jdet = G_m(x_ip[i], x_ip[j], Coords) B_T = np.transpose(B) Ke = Ke + B_T.dot(B) * k * Jdet * W_ip[i] * W_ip[j] return Ke