lululxvi / deepxde

A library for scientific machine learning and physics-informed learning
https://deepxde.readthedocs.io
GNU Lesser General Public License v2.1
2.64k stars 739 forks source link

diffusion equation in 2D with periodic boundary conditions #148

Closed JuntaoHuang closed 3 years ago

JuntaoHuang commented 3 years ago

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'

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

lululxvi commented 3 years ago

It is a bug. Download the updated source code. Let me know if it works.

JuntaoHuang commented 3 years ago

Thanks for your prompt response! The updated version works well now.