def boundary_conditions(self, hx, hy): where = (hx == hy) self.set_node( where, NTEquilibriumVelocity( multifield((0.01 * (hx - self.gy / 2)**2, 0.0), where))) where = ((hx == 5) & (hy == 7)) self.set_node(where, NTEquilibriumDensity(DynamicValue(0.1 * S.gx))) # Interpolated time series. data = np.linspace(0, 50, 10) where = ((hx == 5) & (hy == 8)) self.set_node( where, NTEquilibriumDensity( DynamicValue(0.1 * S.gx * LinearlyInterpolatedTimeSeries(data, 40)))) # Same underlying data, but different time step. where = ((hx == 5) & (hy == 9)) self.set_node( where, NTEquilibriumDensity( DynamicValue(0.1 * S.gx * LinearlyInterpolatedTimeSeries(data, 30)))) self.set_node((hx > 10) & (hy < 5), NTFullBBWall)
def boundary_conditions(self, hx, hy, hz): wall_map = np.array([ [[0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1], # There was a bug once that caused the # middle node here to be marked # PropagationOnly. [0, 0, 1, 1, 1], [0, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]], [[0, 0, 0, 1, 1], [0, 0, 0, 1, 1], [0, 0, 1, 1, 1], [0, 1, 1, 1, 1], [0, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]], [[0, 0, 1, 1, 1], [0, 1, 1, 1, 1], [0, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]], dtype=np.bool) wall_map = np.pad(wall_map, (1, 1), mode='constant', constant_values=0) self.set_node(wall_map, NTFullBBWall) self.set_node(np.logical_not(wall_map) & (hz == 0), NTEquilibriumDensity(1.0))
def boundary_conditions(self, hx, hy, hz): # Channel walls. wall_map = ((hx == 0) | (hx == self.gx - 1)) self.set_node(wall_map, self.wall_bc) h = self.config.H * 2 / 3 buf_len = CubeChannelGeometry.buf_nz(self.config) # For BBL, the number of nodes has to be extended by 1 in every # direction other than wall-normal due to the effective wall location, # i.e. due to the fact that a sequence of N BBL nodes corresponds to # a solid body N-2 across. ext = 1 if self.wall_bc.location == -0.5 else 0 # Cube. cube_map = ((hx > 0) & (hx <= h) & (hz >= buf_len + 3 * h - ext) & (hz < buf_len + 4 * h + ext) & (hy >= 2.7 * h - ext) & (hy < 3.7 * h + ext)) self.set_node(cube_map, self.wall_bc) # Outlet. outlet_map = (hz == self.gz - 1) & np.logical_not(wall_map) self.set_node( outlet_map, NTEquilibriumDensity(1.0, orientation=D3Q19.vec_to_dir([0, 0, -1])))
def boundary_conditions(self, hx, hy): # set walls walls = (hx == -2) # set to all false y_wall = np.random.randint(0, 2) if y_wall == 0: print("y wall") walls = (hy == 0) | (hy == self.gy - 1) | walls # x bottom #x_wall = np.random.randint(0,2) #if x_wall == 1: # walls = (hx == self.gx - 1) | walls self.set_node(walls, self.bc) self.set_node((hx == 0) & np.logical_not(walls), NTEquilibriumVelocity(self.vel)) # set open boundarys self.set_node((hx == self.gx - 1) & np.logical_not(walls), NTEquilibriumDensity(1)) boundary = self.make_boundary(hx) self.set_node(boundary, self.bc) # save geometry (boundary, velocity, pressure) solid = np.array(boundary | walls, dtype=np.float32) solid = np.expand_dims(solid, axis=-1) velocity = np.concatenate(2 * [np.zeros_like(solid, dtype=np.float32)], axis=-1) velocity[:, 0] = self.vel pressure = np.array((hx == self.gx - 1) & np.logical_not(walls), dtype=np.float32) pressure = np.expand_dims(pressure, axis=-1) geometry = np.concatenate([solid, velocity, pressure], axis=-1) np.save(self.config.checkpoint_file + "_geometry", geometry)
def boundary_conditions(self, hx, hy): self.set_node( (hx == 5) & (hy == 0), NTEquilibriumDensity( DynamicValue(LinearlyInterpolatedTimeSeries(sin_timeseries, 8)))) self.set_node( (hx == 6) & (hy == 0), NTEquilibriumDensity( DynamicValue( LinearlyInterpolatedTimeSeries(cos_timeseries, 1.61)))) self.set_node( (hx == 7) & (hy == 0), NTEquilibriumDensity( DynamicValue( 2.0 * LinearlyInterpolatedTimeSeries(sin_timeseries, 4))))
def boundary_conditions(self, hx, hy): walls = (hy == 0) | (hy == self.gy - 1) self.set_node(walls, self.bc) H = self.config.lat_ny hhy = S.gy - self.bc.location self.set_node( (hx == 0) & np.logical_not(walls), NTEquilibriumVelocity( DynamicValue(4.0 * self.max_v / H**2 * hhy * (H - hhy), 0.0))) self.set_node((hx == self.gx - 1) & np.logical_not(walls), NTEquilibriumDensity(1)) L = self.config.vox_size model = self.load_vox_file(self.config.vox_filename) model = np.pad(model, ((L / 2, L / 2), (L, 6 * L)), 'constant', constant_values=False) self.set_node(model, self.bc) # save boundary geometry_array = model.astype(np.uint8) geometry_array = geometry_array[1:-1, L / 2 + 1:5 * L / 2 + 1] geometry_array = np.expand_dims(geometry_array, axis=-1) np.save(self.config.output + "_boundary", geometry_array)
def boundary_conditions(self, hx, hy, hz): wall_map = (hx == 0) | (hx == self.gx - 1) | (hy == 0) | (hy == self.gy - 1) self.set_node(wall_map, self.wall_bc) self.set_node((hz == 0) & np.logical_not(wall_map), NTEquilibriumVelocity((0.0, 0.0, 0.1))) self.set_node((hx == self.gx - 1) & np.logical_not(wall_map), NTEquilibriumDensity(1)) L = self.config.vox_size model = self.load_vox_file(self.config.vox_filename) model = np.pad(model, ((L, 8 * L / 4), (L / 2, L / 2), (L / 2, L / 2)), 'constant', constant_values=False) np.save(self.config.output + "_boundary", model) self.set_node(model, self.wall_bc)
def boundary_conditions(self, hx, hy): #walls = (hy == 0) | (hy == self.gy - 1) walls = (hy == -2) self.set_node(walls, self.bc) #hhy = S.gy - self.bc.location self.set_node((hx == 0) & np.logical_not(walls), NTEquilibriumVelocity((self.max_v, 0.0))) self.set_node((hx == self.gx - 1) & np.logical_not(walls), NTEquilibriumDensity(1)) l = L / 4 # Full bounce-back. For N box nodes, effective size is N+1. if self.bc.location == 0.5: eff_D = D - 1 # Half-way bounce-back. For N box nodes, effective size is N-2. else: eff_D = D + 2 box = ((hx > l - eff_D / 2.0) & (hx <= l + eff_D / 2.0) & (hy > (H - eff_D) / 2.0) & (hy <= (H + eff_D) / 2.0)) self.set_node(box, self.bc)
def boundary_conditions(self, hx, hy): # set walls walls = (hx == -2) # set to all false y_wall = np.random.randint(0,2) if y_wall == 0: walls = (hy == 0) | walls # x bottom x_wall = np.random.randint(0,2) if x_wall == 1: walls = (hx == self.gx - 1) | walls self.set_node(walls, self.bc) self.set_node((hx == 0) & np.logical_not(walls), NTEquilibriumVelocity(self.vel)) # set open boundarys self.set_node((hx == self.gx - 1) & np.logical_not(walls), NTEquilibriumDensity(1)) boundary = self.make_boundary(hx) self.set_node(boundary, self.bc)
def boundary_conditions(self, hx, hy, hz): self.set_node((hx == 0) | (hy == 0) | (hz == 0) | (hz == self.gz - 1) | (hx == self.gx - 1) | (hy == self.gy - 1), NTEquilibriumDensity(1.0))