{ "cells": [ { "cell_type": "markdown", "id": "f0f586b0", "metadata": {}, "source": [ "# Voronoi Example\n", "\n", "Grid was taken from `flopy/docs/Notebooks/dis_voronoi_example.py`.\n", "\n", "This notebook shows how `nlmod` can be used to build and visualize models on a voronoi grid.\n", "\n", "This notebook does not describe how to build a Voronoi grid, refer to flopy's documenation for more information on that topic." ] }, { "cell_type": "code", "execution_count": null, "id": "c11597d6", "metadata": {}, "outputs": [], "source": [ "from pathlib import Path\n", "\n", "import pandas as pd\n", "import xarray as xr\n", "\n", "import nlmod" ] }, { "cell_type": "code", "execution_count": null, "id": "98b89fc7", "metadata": {}, "outputs": [], "source": [ "model_ws = Path(\"../../tests/data/mf6output/voronoi\")" ] }, { "cell_type": "markdown", "id": "d9502c1f", "metadata": {}, "source": [ "This rebuilds the original model." ] }, { "cell_type": "code", "execution_count": null, "id": "887c4408", "metadata": {}, "outputs": [], "source": [ "ds = nlmod.grid.modelgrid_to_ds(grbfile=model_ws / \"voronoi.disv.grb\")\n", "ds.attrs[\"exe_name\"] = \"mf6\"\n", "ds.attrs[\"model_name\"] = \"voronoi\"\n", "ds.attrs[\"model_ws\"] = str(model_ws)\n", "ds.attrs[\"mfversion\"] = \"mf6\"\n", "edge_mask = nlmod.grid.mask_model_edge(ds)[\"edge_mask\"]\n", "ds[\"kh\"] = 10.0 * xr.ones_like(ds[\"botm\"])\n", "ds[\"kv\"] = 10.0 * xr.ones_like(ds[\"botm\"])\n", "ds = nlmod.time.set_ds_time(ds, start=\"2020-01-01\", perlen=[1.0])\n", "sim = nlmod.sim.sim(ds)\n", "tdis = nlmod.sim.tdis(ds, sim)\n", "ims = nlmod.sim.ims(sim)\n", "gwf = nlmod.gwf.gwf(ds, sim)\n", "dis = nlmod.gwf.disv(ds, gwf)\n", "npf = nlmod.gwf.npf(ds, gwf)\n", "ghb = nlmod.gwf.ghb(ds, gwf, bhead=10*edge_mask, cond=1e8 * edge_mask)\n", "ic = nlmod.gwf.ic(ds, gwf, starting_head=10.0)\n", "df = pd.DataFrame(index=[\"well1\"], columns=[\"x\", \"y\", \"top\", \"botm\", \"Q\"])\n", "df.loc[\"well1\"] = 1500, 500, 0.0, -10.0, -200.0\n", "wel = nlmod.gwf.wells.wel_from_df(df, ds=ds, gwf=gwf)\n", "oc = nlmod.gwf.oc(ds, gwf)\n", "\n", "# uncomment to build and run the simulation\n", "# nlmod.sim.write_and_run(ds, sim)" ] }, { "cell_type": "markdown", "id": "58f5a68d", "metadata": {}, "source": [ "Plot the model grid and the GHB and WEL locations." ] }, { "cell_type": "code", "execution_count": null, "id": "6951c138", "metadata": {}, "outputs": [], "source": [ "ax = nlmod.plot.modelgrid(ds, linewidth=0.5)\n", "nlmod.plot.data_array(edge_mask.isel(layer=0), ds=ds, cmap=\"Blues\", ax=ax)\n", "ax.plot(df.x, df.y, \"ro\", markersize=5, label=\"well\")\n", "ax.set_xlabel(\"x [m]\")\n", "ax.set_ylabel(\"y [m]\")\n", "ax.legend(loc=(0, 1), frameon=False, ncol=1);" ] }, { "cell_type": "markdown", "id": "9d144112", "metadata": {}, "source": [ "Load the heads" ] }, { "cell_type": "code", "execution_count": null, "id": "3ab4f530", "metadata": {}, "outputs": [], "source": [ "hd = nlmod.gwf.output.get_heads_da(ds)" ] }, { "cell_type": "markdown", "id": "0ff53ae9", "metadata": {}, "source": [ "Plot the results" ] }, { "cell_type": "code", "execution_count": null, "id": "d57d75e9", "metadata": {}, "outputs": [], "source": [ "ax = nlmod.plot.map_array(\n", " hd, ds, xlabel=\"x [km]\", ylabel=\"y [km]\", colorbar_label=\"head [m]\"\n", ")" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }