I am trying to solve a diffusion equation in 2D with periodic boundary conditions, but there is some error. The same strategy works in 1D case.
Traceback (most recent call last):
File "diffusion_2d.py", line 58, in
main()
File "diffusion_2d.py", line 41, in main
num_test=2000,
File "/Users/juntao/Documents/Anaconda/anaconda3/envs/tf/lib/python3.7/site-packages/deepxde/data/pde.py", line 175, in init
num_test=num_test,
File "/Users/juntao/Documents/Anaconda/anaconda3/envs/tf/lib/python3.7/site-packages/deepxde/data/pde.py", line 44, in init
self.train_next_batch()
File "/Users/juntao/Documents/Anaconda/anaconda3/envs/tf/lib/python3.7/site-packages/deepxde/utils.py", line 24, in wrapper
return func(self, *args, **kwargs)
File "/Users/juntao/Documents/Anaconda/anaconda3/envs/tf/lib/python3.7/site-packages/deepxde/data/pde.py", line 90, in train_next_batch
self.train_x = np.vstack((self.bc_points(), self.train_x))
File "/Users/juntao/Documents/Anaconda/anaconda3/envs/tf/lib/python3.7/site-packages/deepxde/data/pde.py", line 135, in bc_points
x_bcs = [bc.collocation_points(self.train_x) for bc in self.bcs]
File "/Users/juntao/Documents/Anaconda/anaconda3/envs/tf/lib/python3.7/site-packages/deepxde/data/pde.py", line 135, in
x_bcs = [bc.collocation_points(self.train_x) for bc in self.bcs]
File "/Users/juntao/Documents/Anaconda/anaconda3/envs/tf/lib/python3.7/site-packages/deepxde/boundary_conditions.py", line 104, in collocation_points
X2 = np.array([self.geom.periodic_point(x, self.component_x) for x in X1])
File "/Users/juntao/Documents/Anaconda/anaconda3/envs/tf/lib/python3.7/site-packages/deepxde/boundary_conditions.py", line 104, in
X2 = np.array([self.geom.periodic_point(x, self.component_x) for x in X1])
File "/Users/juntao/Documents/Anaconda/anaconda3/envs/tf/lib/python3.7/site-packages/deepxde/geometry/timedomain.py", line 141, in periodic_point
xp = self.geometry.periodic_point(x[:-1])
TypeError: periodic_point() missing 1 required positional argument: 'component'
I am trying to solve a diffusion equation in 2D with periodic boundary conditions, but there is some error. The same strategy works in 1D case.
The code is as follows: `def main(): def pde(x, y): dy_x = tf.gradients(y, x)[0] dy_x1, dy_x2, dy_t = dy_x[:, 0:1], dy_x[:, 1:2], dy_x[:, 2:] dy_x1x1 = tf.gradients(dy_x1, x)[0][:, 0:1] dy_x2x2 = tf.gradients(dy_x2, x)[0][:, 1:2] return ( dy_t - dy_x1x1 - dy_x2x2
tf.exp(-x[:, 2:]) (2 np.pi * 2 tf.sin(np.pi * (x[:, 0:1] + x[:, 1:2]))) )
def func(x): return np.sin(np.pi (x[:, 0:1] + x[:, 1:2])) np.exp(-x[:, 2:])
geom = dde.geometry.Rectangle(xmin=[-1, -1], xmax=[1, 1]) timedomain = dde.geometry.TimeDomain(0, 1) geomtime = dde.geometry.GeometryXTime(geom, timedomain)
bcx = dde.PeriodicBC(geomtime, 0, lambda , on_boundary: on_boundary) bcy = dde.PeriodicBC(geomtime, 1, lambda , on_boundary: onboundary) ic = dde.IC(geomtime, func, lambda , on_initial: on_initial) data = dde.data.TimePDE( geomtime, pde, [bc_x, bc_y, ic], num_domain=2000, num_boundary=200, num_initial=200, solution=func, num_test=2000, )
layer_size = [3] + [32] * 3 + [1] activation = "tanh" initializer = "Glorot uniform" net = dde.maps.FNN(layer_size, activation, initializer)
model = dde.Model(data, net)
model.compile("adam", lr=0.001, metrics=["l2 relative error"]) losshistory, train_state = model.train(epochs=10000)
dde.saveplot(losshistory, train_state, issave=True, isplot=True)`