Note
This page was generated from a jupyter notebook.
Setting Boundary Conditions: interior rectangle¶
This tutorial illustrates how to modify the boundary conditions of an interior rectangle in the grid if you know the x and y coordinates of the rectangle.
[1]:
import numpy as np
from landlab import RasterModelGrid
[2]:
mg = RasterModelGrid((10, 10))
Known coordinates of rectangle:
[3]:
min_x = 2.5
max_x = 5.0
min_y = 3.5
max_y = 7.5
Define the area inside x and y coordinates:
[4]:
x_condition = np.logical_and(mg.x_of_node < max_x, mg.x_of_node > min_x)
y_condition = np.logical_and(mg.y_of_node < max_y, mg.y_of_node > min_y)
my_nodes = np.logical_and(x_condition, y_condition)
Define boundaries as CLOSED:
[5]:
mg.status_at_node[my_nodes] = mg.BC_NODE_IS_CLOSED
Make a new elevation field for display:
[6]:
z = mg.add_zeros("topographic__elevation", at="node")
[7]:
mg.imshow(z, at="node")