def u_bound_right(x, y): return 0.0 def u_bound_up_down(x, y): return np.zeros_like(x) #define the input and output data set xmin = 0 xmax = 2 ymin = 0 ymax = 1 domainCorners = np.array([[xmin, ymin], [xmin, ymax], [xmax, ymin], [xmax, ymax]]) myQuad = Quadrilateral(domainCorners) numPtsU = 28 numPtsV = 28 xPhys, yPhys = myQuad.getUnifIntPts(numPtsU, numPtsV, [0, 0, 0, 0]) data_type = "float32" Xint = np.concatenate((xPhys, yPhys), axis=1).astype(data_type) Yint = np.zeros_like(Xint) # Generate the training data for the Neumann boundary xPhysNeu, yPhysNeu, xNormNeu, yNormNeu = myQuad.getUnifEdgePts( numPtsU, numPtsV, [1, 0, 1, 1]) XbndNeu = np.concatenate((xPhysNeu, yPhysNeu, xNormNeu, yNormNeu), axis=1).astype(data_type) dwdx_neu, dwdy_neu = deriv_exact_sol(xPhysNeu, yPhysNeu)
def exact_sol(x,y): u = np.sin(kx*np.pi*x)*np.sin(ky*np.pi*y) return u def deriv_exact_sol(x,y): du = kx*np.pi*np.cos(kx*np.pi*x)*np.sin(ky*np.pi*y) dv = ky*np.pi*np.sin(kx*np.pi*x)*np.cos(ky*np.pi*y) return du, dv #define the input and output data set xmin = 0 xmax = 1 ymin = 0 ymax = 1 domainCorners = np.array([[xmin,ymin], [xmin,ymax], [xmax,ymin], [xmax,ymax]]) myQuad = Quadrilateral(domainCorners) numPtsU = 28 numPtsV = 28 xPhys, yPhys = myQuad.getUnifIntPts(numPtsU, numPtsV, [0,0,0,0]) data_type = "float32" Xint = np.concatenate((xPhys,yPhys),axis=1).astype(data_type) Yint = rhs_fun(Xint[:,[0]], Xint[:,[1]]) xPhysBnd, yPhysBnd, _, _s = myQuad.getUnifEdgePts(numPtsU, numPtsV, [1,1,1,1]) Xbnd = np.concatenate((xPhysBnd, yPhysBnd), axis=1).astype(data_type) Ybnd = exact_sol(Xbnd[:,[0]], Xbnd[:,[1]]) #define the model tf.keras.backend.set_floatx(data_type)
(y_temp**2 - self.W**2 / 4)) v_left = -self.pei * (3 * self.nu * y_temp**2 * self.L) u_val = xPhys * u_val + u_left v_val = xPhys * v_val + v_left return u_val, v_val #define the input and output data set beam_length = 8. beam_width = 2. pressure = 2. domainCorners = np.array([[0., 0.], [0, beam_width], [beam_length, 0.], [beam_length, beam_width]]) geomDomain = Quadrilateral(domainCorners) model_data = dict() model_data["E"] = 1e3 model_data["nu"] = 0.25 model_data["state"] = "plane stress" numElemU = 20 numElemV = 10 numGauss = 4 #xPhys, yPhys = myQuad.getRandomIntPts(numPtsU*numPtsV) xPhys, yPhys, Wint = geomDomain.getQuadIntPts(numElemU, numElemV, numGauss) data_type = "float32" Xint = np.concatenate((xPhys, yPhys), axis=1).astype(data_type) Wint = np.array(Wint).astype(data_type)
u_left = self.pei * y_temp * ((2 + self.nu) * (y_temp**2 - self.W**2 / 4)) v_left = -self.pei * (3 * self.nu * y_temp**2 * self.L) u_val = xPhys * u_val + u_left v_val = xPhys * v_val + v_left return u_val, v_val #define the input and output data set beam_length = 8. beam_width = 2. domainCorners = np.array([[0., 0.], [0, beam_width], [beam_length, 0.], [beam_length, beam_width]]) geomDomain = Quadrilateral(domainCorners) numPtsU = 80 numPtsV = 40 #xPhys, yPhys = myQuad.getRandomIntPts(numPtsU*numPtsV) xPhys, yPhys = geomDomain.getUnifIntPts(numPtsU, numPtsV, [0, 0, 0, 0]) data_type = "float32" Xint = np.concatenate((xPhys, yPhys), axis=1).astype(data_type) Yint = np.zeros_like(Xint).astype(data_type) # prepare boundary points in the fromat Xbnd = [Xcoord, Ycoord, dir] and # Ybnd = [trac], where Xcoord, Ycoord are the x and y coordinate of the point, # dir=0 for the x-component of the traction and dir=1 for the y-component of # the traction
if x<alpha*(t-1): u[i] = 2*alpha/np.pi v[i] = 0 elif x<=alpha*t: u[i] = alpha/np.pi * (1-np.cos(np.pi*(t-x/alpha))) v[i] = alpha/np.pi * np.pi * np.sin(np.pi*(t-x/alpha)) return u, v #define the input and output data set xmin = 0 xmax = 4 tmin = 0 tmax = 2 domainCorners = np.array([[xmin,tmin], [xmin,tmax], [xmax,tmin], [xmax,tmax]]) domainGeom = Quadrilateral(domainCorners) numPtsU = 101 numPtsV = 101 xPhys, yPhys = domainGeom.getUnifIntPts(numPtsU,numPtsV,[0,0,0,0]) data_type = "float32" Xint = np.concatenate((xPhys,yPhys),axis=1).astype(data_type) Yint = np.zeros_like(xPhys).astype(data_type) #boundary conditions at x=0 xPhysBnd, tPhysBnd, _, _ = domainGeom.getUnifEdgePts(numPtsU, numPtsV, [0,0,0,1]) Xbnd = np.concatenate((xPhysBnd, tPhysBnd), axis=1).astype(data_type) Ybnd = np.where(tPhysBnd<=1, -np.sin(np.pi*tPhysBnd), 0).astype(data_type) #initial conditions (displacement and velocity) for t=0
def deriv_exact_sol(x, y): dudx = (1 - 2 * x) * (y - y**2) dudy = (x - x**2) * (1 - 2 * y) return dudx, dudy #define the input and output data set xmin = 0 xmax = 1 ymin = 0 ymax = 1 domainCorners = np.array([[xmin, ymin], [xmin, ymax], [xmax, ymin], [xmax, ymax]]) myQuad = Quadrilateral(domainCorners) numPtsU = 80 numPtsV = 80 numElemU = 20 numElemV = 20 numGauss = 4 boundary_weight = 1e4 xPhys, yPhys, Wint = myQuad.getQuadIntPts(numElemU, numElemV, numGauss) data_type = "float32" Xint = np.concatenate((xPhys, yPhys), axis=1).astype(data_type) Wint = Wint.astype(data_type) Yint = rhs_fun(Xint[:, [0]], Xint[:, [1]])