dirC = np.zeros_like(xPhysBndC) XbndC = np.concatenate((xPhysBndC, yPhysBndC, xNormC, yNormC, dirC), axis=1).astype(data_type) # boundary for x=0, include only the y direction xPhysBndD, yPhysBndD, xNormD, yNormD = geomDomain.getUnifEdgePts( numPtsU, numPtsV, [0, 0, 1, 0]) dirD = np.ones_like(xPhysBndD) XbndD = np.concatenate((xPhysBndD, yPhysBndD, xNormD, yNormD, dirD), axis=1).astype(data_type) # concatenate all the boundaries Xbnd = np.concatenate((XbndA0, XbndA1, XbndB0, XbndB1, XbndC, XbndD), axis=0) # plot the collocation points plot_pts(Xint, Xbnd[:, 0:2]) # define loading YbndA0 = -model_data["inner_pressure"] * XbndA0[:, 2:3] YbndA1 = -model_data["inner_pressure"] * XbndA0[:, 3:4] YbndB0 = -model_data["outer_pressure"] * XbndB0[:, 2:3] YbndB1 = -model_data["outer_pressure"] * XbndB0[:, 3:4] YbndC = np.zeros_like(xPhysBndC).astype(data_type) YbndD = np.zeros_like(xPhysBndD).astype(data_type) Ybnd = np.concatenate((YbndA0, YbndA1, YbndB0, YbndB1, YbndC, YbndD), axis=0) #define the model tf.keras.backend.set_floatx(data_type) l1 = tf.keras.layers.Dense(20, "swish") l2 = tf.keras.layers.Dense(20, "swish") l3 = tf.keras.layers.Dense(20, "swish")
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 xPhysInit, tPhysInit, _, _ = domainGeom.getUnifEdgePts(numPtsU, numPtsV, [1,0,0,0]) Xinit = np.concatenate((xPhysInit, tPhysInit), axis=1).astype(data_type) Yinit = np.zeros_like(Xinit) #plot the collocation points plot_pts(Xint, Xbnd) #define the model tf.keras.backend.set_floatx(data_type) l1 = tf.keras.layers.Dense(30, "tanh") l2 = tf.keras.layers.Dense(30, "tanh") l3 = tf.keras.layers.Dense(30, "tanh") #l4 = tf.keras.layers.Dense(20, "tanh") #l5 = tf.keras.layers.Dense(20, "tanh") l4 = tf.keras.layers.Dense(1, None) train_op = tf.keras.optimizers.Adam() train_op2 = "BFGS-B" num_epoch = 1000 print_epoch = 100 pred_model = Wave1D([l1, l2, l3, l4], train_op, num_epoch, print_epoch)