{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Setting Boundary Conditions: interior rectangle\n", "\n", "
\n", "For more Landlab tutorials, click here: https://landlab.readthedocs.io/en/latest/user_guide/tutorials.html\n", "
\n", "\n", "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." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from landlab import RasterModelGrid\n", "import numpy as np\n", "from landlab.plot.imshow import imshow_grid_at_node\n", "from matplotlib.pyplot import show\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mg = RasterModelGrid((10, 10))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Known coordinates of rectangle:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "min_x = 2.5\n", "max_x = 5.\n", "min_y = 3.5\n", "max_y = 7.5" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define the area inside x and y coordinates:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x_condition = np.logical_and(mg.x_of_node < max_x, mg.x_of_node > min_x)\n", "y_condition = np.logical_and(mg.y_of_node < max_y, mg.y_of_node > min_y)\n", "my_nodes = np.logical_and(x_condition, y_condition)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define boundaries as CLOSED:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mg.status_at_node[my_nodes] = mg.BC_NODE_IS_CLOSED" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Make a new elevation field for display:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "z = mg.add_zeros('topographic__elevation', at='node')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "imshow_grid_at_node(mg, z)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Click here for more Landlab tutorials" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.0" } }, "nbformat": 4, "nbformat_minor": 1 }