Error : IndexError: arrays used as indices must be of integer (or boolean) type #1520
Unanswered
HarishWathore
asked this question in
Q&A
Replies: 1 comment
-
|
Your boundary conditions are incorrectly defined: Boundary condition must return boolean array. You have mixed content in boundaries. Please check "More details and examples about boundary conditions" in FAQ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am making a PINN for stokes 2nd Problem
Define the PDE function
v = 0.001
U = 1
w = 1
def pde(x, y):
du_dt = dde.grad.jacobian(y, x, i=0, j=1)
du_dyy = dde.grad.hessian(y, x, i=0, j=0)
return du_dt - v * du_dyy
Define the domain
geom = dde.geometry.Interval(0, 5)
timedomain = dde.geometry.TimeDomain(0, 1)
geomtime = dde.geometry.GeometryXTime(geom, timedomain)
Define the Dirichlet boundary condition at the left boundary
def u_left_boundary(x,on_boundary):
return on_boundary and U * np.cos(w * x[1])
Define the Dirichlet boundary condition at the right boundary
def u_right_boundary(x,on_boundary):
return on_boundary and 0.0
Create the Dirichlet boundary condition objects
bc_left = dde.DirichletBC(geomtime, lambda x:0, u_left_boundary, component = 0)
bc_right = dde.DirichletBC(geomtime, lambda x:1, u_right_boundary,component = 1)
def u_initial_condition(x):
return 0.0
Create the initial condition object
ic = dde.IC(geomtime, u_initial_condition, lambda _, on_initial: on_initial, component=0)
bc = [bc_left,bc_right, ic]
data = dde.data.TimePDE(geomtime,pde,bc,num_domain=2540,num_boundary=80,num_initial=160,num_test=2540,)
Error : ---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Cell In[12], line 1
----> 1 data = dde.data.TimePDE(geomtime,pde,bc,num_domain=2540,num_boundary=80,num_initial=160,num_test=2540,)
File ~\AppData\Roaming\Python\Python311\site-packages\deepxde\data\pde.py:322, in TimePDE.init(self, geometryxtime, pde, ic_bcs, num_domain, num_boundary, num_initial, train_distribution, anchors, exclusions, solution, num_test, auxiliary_var_function)
306 def init(
307 self,
308 geometryxtime,
(...)
319 auxiliary_var_function=None,
320 ):
321 self.num_initial = num_initial
--> 322 super().init(
323 geometryxtime,
324 pde,
325 ic_bcs,
326 num_domain,
327 num_boundary,
328 train_distribution=train_distribution,
329 anchors=anchors,
330 exclusions=exclusions,
331 solution=solution,
332 num_test=num_test,
333 auxiliary_var_function=auxiliary_var_function,
334 )
File ~\AppData\Roaming\Python\Python311\site-packages\deepxde\data\pde.py:127, in PDE.init(self, geometry, pde, bcs, num_domain, num_boundary, train_distribution, anchors, exclusions, solution, num_test, auxiliary_var_function)
124 self.test_x, self.test_y = None, None
125 self.train_aux_vars, self.test_aux_vars = None, None
--> 127 self.train_next_batch()
128 self.test()
File ~\AppData\Roaming\Python\Python311\site-packages\deepxde\utils\internal.py:38, in run_if_all_none..decorator..wrapper(self, *args, **kwargs)
36 x = [getattr(self, a) for a in attr]
37 if all(i is None for i in x):
---> 38 return func(self, *args, **kwargs)
39 return x if len(x) > 1 else x[0]
File ~\AppData\Roaming\Python\Python311\site-packages\deepxde\data\pde.py:176, in PDE.train_next_batch(self, batch_size)
173 @run_if_all_none("train_x", "train_y", "train_aux_vars")
174 def train_next_batch(self, batch_size=None):
175 self.train_x_all = self.train_points()
--> 176 self.bc_points() # Generate self.num_bcs and self.train_x_bc
177 if self.bcs and config.hvd is not None:
178 num_bcs = np.array(self.num_bcs)
File ~\AppData\Roaming\Python\Python311\site-packages\deepxde\utils\internal.py:38, in run_if_all_none..decorator..wrapper(self, *args, **kwargs)
36 x = [getattr(self, a) for a in attr]
37 if all(i is None for i in x):
---> 38 return func(self, *args, **kwargs)
39 return x if len(x) > 1 else x[0]
File ~\AppData\Roaming\Python\Python311\site-packages\deepxde\data\pde.py:282, in PDE.bc_points(self)
280 @run_if_all_none("train_x_bc")
281 def bc_points(self):
--> 282 x_bcs = [bc.collocation_points(self.train_x_all) for bc in self.bcs]
283 self.num_bcs = list(map(len, x_bcs))
284 self.train_x_bc = (
285 np.vstack(x_bcs)
286 if x_bcs
287 else np.empty([0, self.train_x_all.shape[-1]], dtype=config.real(np))
288 )
File ~\AppData\Roaming\Python\Python311\site-packages\deepxde\data\pde.py:282, in (.0)
280 @run_if_all_none("train_x_bc")
281 def bc_points(self):
--> 282 x_bcs = [bc.collocation_points(self.train_x_all) for bc in self.bcs]
283 self.num_bcs = list(map(len, x_bcs))
284 self.train_x_bc = (
285 np.vstack(x_bcs)
286 if x_bcs
287 else np.empty([0, self.train_x_all.shape[-1]], dtype=config.real(np))
288 )
File ~\AppData\Roaming\Python\Python311\site-packages\deepxde\icbc\boundary_conditions.py:52, in BC.collocation_points(self, X)
51 def collocation_points(self, X):
---> 52 return self.filter(X)
File ~\AppData\Roaming\Python\Python311\site-packages\deepxde\icbc\boundary_conditions.py:49, in BC.filter(self, X)
48 def filter(self, X):
---> 49 return X[self.on_boundary(X, self.geom.on_boundary(X))]
IndexError: arrays used as indices must be of integer (or boolean) type
Beta Was this translation helpful? Give feedback.
All reactions