Skip to content

Commit

Permalink
making necessary changes to handle LDC at Re=10000
Browse files Browse the repository at this point in the history
  • Loading branch information
hsalehipour committed Oct 11, 2023
1 parent 2871c87 commit 0ddb3a4
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions examples/CFD/cavity3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Use 8 CPU devices
# os.environ["XLA_FLAGS"] = '--xla_force_host_platform_device_count=8'
from src.models import BGKSim, KBCSim
from src.lattice import LatticeD3Q19
from src.lattice import LatticeD3Q19, LatticeD3Q27
from src.utils import *
from jax.config import config
from src.boundary_conditions import *
Expand All @@ -26,25 +26,31 @@
precision = 'f64/f64'
config.update('jax_enable_x64', True)

class Cavity(BGKSim):
class Cavity(KBCSim):
# Note: We have used BGK with D3Q19 (or D3Q27) for Re=(1000, 3200) and KBC with D3Q27 for Re=10,000
def __init__(self, **kwargs):
super().__init__(**kwargs)

def set_boundary_conditions(self):
# Note:
# We have used halfway BB for Re=(1000, 3200) and regularized BC for Re=10,000

# apply inlet equilibrium boundary condition to the top wall
# apply inlet boundary condition to the top wall
moving_wall = self.boundingBoxIndices['top']
vel_wall = np.zeros(moving_wall.shape, dtype=self.precisionPolicy.compute_dtype)
vel_wall[:, 0] = prescribed_vel
self.BCs.append(BounceBackHalfway(tuple(moving_wall.T), self.gridInfo, self.precisionPolicy, vel_wall))
# self.BCs.append(BounceBackHalfway(tuple(moving_wall.T), self.gridInfo, self.precisionPolicy, vel_wall))
self.BCs.append(Regularized(tuple(moving_wall.T), self.gridInfo, self.precisionPolicy, 'velocity', vel_wall))

# concatenate the indices of the left, right, and bottom walls
walls = np.concatenate(
(self.boundingBoxIndices['left'], self.boundingBoxIndices['right'],
self.boundingBoxIndices['front'], self.boundingBoxIndices['back'],
self.boundingBoxIndices['bottom']))
# apply bounce back boundary condition to the walls
self.BCs.append(BounceBackHalfway(tuple(walls.T), self.gridInfo, self.precisionPolicy))
# self.BCs.append(BounceBackHalfway(tuple(walls.T), self.gridInfo, self.precisionPolicy))
vel_wall = np.zeros(walls.shape, dtype=self.precisionPolicy.compute_dtype)
self.BCs.append(Regularized(tuple(walls.T), self.gridInfo, self.precisionPolicy, 'velocity', vel_wall))
return

def output_data(self, **kwargs):
Expand Down Expand Up @@ -78,16 +84,22 @@ def output_data(self, **kwargs):
# live_volume_randering(timestep, u_mag)

if __name__ == '__main__':
lattice = LatticeD3Q19(precision)
# Note:
# We have used BGK with D3Q19 (or D3Q27) for Re=(1000, 3200) and KBC with D3Q27 for Re=10,000
lattice = LatticeD3Q27(precision)

nx = 256
ny = 256
nz = 256

Re = 1000.0
Re = 10000.0
prescribed_vel = 0.06
clength = nx - 2

# characteristic time
tc = prescribed_vel/clength
niter_max = int(500//tc)

visc = prescribed_vel * clength / Re
omega = 1.0 / (3. * visc + 0.5)
print('omega = ', omega)
Expand All @@ -101,9 +113,9 @@ def output_data(self, **kwargs):
'ny': ny,
'nz': nz,
'precision': precision,
'io_rate': 10000,
'print_info_rate': 10000,
'io_rate': int(10//tc),
'print_info_rate': int(10//tc),
'downsampling_factor': 1
}
sim = Cavity(**kwargs)
sim.run(1000000)
sim.run(niter_max)

0 comments on commit 0ddb3a4

Please sign in to comment.