Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem applying pressure based boundary condition using ZouHe #33

Closed
SoumyaShouvik opened this issue Feb 1, 2024 · 1 comment
Closed
Assignees

Comments

@SoumyaShouvik
Copy link

SoumyaShouvik commented Feb 1, 2024

If I want to implement inlet or outlet boundary condition to a specific pressure using ZouHe, it shows a TypeError : mul got incompatible shapes for broadcasting: (998,), (9,). I used nx= 1400, ny= 1000. I tried to apply a specific pressure in left vertical inlet wall ( x=0, y=0:1000 ) . Same problem arrives if I want to apply a specific pressure in right outlet boundary.

Outflow BC

outlet = self.boundingBoxIndices['right']
rho_outlet = np.ones(outlet.shape[0], dtype=self.precisionPolicy.compute_dtype)
self.BCs.append(ZouHe(tuple(outlet.T), self.gridInfo, self.precisionPolicy, 'pressure', rho_outlet))

**** Simulation Parameters for Cylinder ****
Parameter | Value

            Omega | 0.5518611517342236
 Grid Points in X | 1400
 Grid Points in Y | 1000
 Grid Points in Z | 0
   Dimensionality | 2
 Precision Policy | f64/f64
     Lattice Type | D2Q9
  Checkpoint Rate | 0

Checkpoint Directory | ./checkpoints
Downsampling Factor | 1
Print Info Rate | 200
I/O Rate | 100
Compute MLUPS | False
Restore Checkpoint | False
Backend | gpu
Number of Devices | 1
Volumetric Ratio of Solid : 0.502656
Time to create the grid mask: 0.3005838394165039
Time to create the local masks and normal arrays: 11.985322952270508
WARNING: Default initial conditions assumed: density = 1, velocity = 0
To set explicit initial density and velocity, use self.initialize_macroscopic_fields.
jax.errors.SimplifiedTraceback: For simplicity, JAX has removed its internal frames from the traceback of the following exception. Set JAX_TRACEBACK_FILTERING=off to include these.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/mnt/c/RunCodeHere/Projects/XLB/Permeability02_benchmark.py", line 297, in
sim.run(t_max)
File "/mnt/c/RunCodeHere/Projects/XLB/src/base.py", line 905, in run
f, fstar = self.step(f, timestep, return_fpost=self.returnFpost)
File "/mnt/c/RunCodeHere/Projects/XLB/src/base.py", line 841, in step
f_poststreaming = self.apply_bc(f_poststreaming, f_postcollision, timestep, "PostStreaming")
File "/mnt/c/RunCodeHere/Projects/XLB/src/base.py", line 804, in apply_bc
fout = fout.at[bc.indices].set(bc.apply(fout, fin))
File "/mnt/c/RunCodeHere/Projects/XLB/src/boundary_conditions.py", line 781, in apply
feq = self.calculate_equilibrium(fout)
File "/mnt/c/RunCodeHere/Projects/XLB/src/boundary_conditions.py", line 738, in calculate_equilibrium
feq = self.equilibrium(rho, vel)
File "/mnt/c/RunCodeHere/Projects/XLB/src/boundary_conditions.py", line 285, in equilibrium
feq = rho * self.lattice.w * (1.0 + 1.0 * cu + 0.5 * cu**2 - usqr)
File "/home/shouvik/anaconda3/lib/python3.9/site-packages/jax/src/numpy/array_methods.py", line 743, in op
return getattr(self.aval, f"
{name}")(self, *args)
File "/home/shouvik/anaconda3/lib/python3.9/site-packages/jax/_src/numpy/array_methods.py", line 271, in deferring_binary_op
return binary_op(*args)
File "/home/shouvik/anaconda3/lib/python3.9/site-packages/jax/src/numpy/ufuncs.py", line 99, in fn
return lax_fn(x1, x2) if x1.dtype != np.bool
else bool_lax_fn(x1, x2)
TypeError: mul got incompatible shapes for broadcasting: (998,), (9,).

@hsalehipour
Copy link
Collaborator

Hi @SoumyaShouvik. Thanks for raising this issue which was indeed a minor bug in our ZouHe implementation. I just fixed it and you can pull again. Please make sure to use
rho_outlet = np.ones((outlet.shape[0], 1), dtype=self.precisionPolicy.compute_dtype)
instead of:
rho_outlet = np.ones(outlet.shape[0], dtype=self.precisionPolicy.compute_dtype)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants