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.
[ ]:
import numpy as np
from landlab import RasterModelGrid
[ ]:
mg = RasterModelGrid((10, 10))
Known coordinates of rectangle:
[ ]:
min_x = 2.5
max_x = 5.0
min_y = 3.5
max_y = 7.5
Define the area inside x and y coordinates:
[ ]:
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:
[ ]:
mg.status_at_node[my_nodes] = mg.BC_NODE_IS_CLOSED
Make a new elevation field for display:
[ ]:
z = mg.add_zeros("topographic__elevation", at="node")
[ ]:
mg.imshow(z, at="node")