{ "cells": [ { "cell_type": "markdown", "id": "4997d777", "metadata": { "papermill": { "duration": 0.010313, "end_time": "2026-03-13T20:18:44.784879", "exception": false, "start_time": "2026-03-13T20:18:44.774566", "status": "completed" }, "tags": [] }, "source": [ "(water_grid_example)=\n", "# Water Grid Script Examples" ] }, { "cell_type": "markdown", "id": "652c41de", "metadata": { "papermill": { "duration": 0.007547, "end_time": "2026-03-13T20:18:44.802756", "exception": false, "start_time": "2026-03-13T20:18:44.795209", "status": "completed" }, "tags": [] }, "source": [ "Download the [blankModel.rs3v3](https://github.com/Rocscience/rs3-scripting/tree/main/docs/example_code/example_models/blankModel.rs3v3) for this example." ] }, { "cell_type": "code", "execution_count": 1, "id": "f3288b4a", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:18:44.826186Z", "iopub.status.busy": "2026-03-13T20:18:44.825161Z", "iopub.status.idle": "2026-03-13T20:18:45.293930Z", "shell.execute_reply": "2026-03-13T20:18:45.291926Z" }, "papermill": { "duration": 0.483057, "end_time": "2026-03-13T20:18:45.295429", "exception": false, "start_time": "2026-03-13T20:18:44.812372", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "from rs3.RS3Modeler import RS3Modeler\n", "from rs3.properties.PropertyEnums import *\n", "from rs3.projectSettings.ProjectSettingEnums import *\n", "import os\n", "import shutil" ] }, { "cell_type": "markdown", "id": "bdd2f737", "metadata": { "papermill": { "duration": 0.013994, "end_time": "2026-03-13T20:18:45.315966", "exception": false, "start_time": "2026-03-13T20:18:45.301972", "status": "completed" }, "tags": [] }, "source": [ "Get the current folder directory." ] }, { "cell_type": "code", "execution_count": 2, "id": "5fceeae1", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:18:45.340031Z", "iopub.status.busy": "2026-03-13T20:18:45.338558Z", "iopub.status.idle": "2026-03-13T20:18:45.347684Z", "shell.execute_reply": "2026-03-13T20:18:45.345548Z" }, "papermill": { "duration": 0.024935, "end_time": "2026-03-13T20:18:45.350200", "exception": false, "start_time": "2026-03-13T20:18:45.325265", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "current_dir = os.path.dirname(os.path.abspath(\"\"))" ] }, { "cell_type": "markdown", "id": "561e8648", "metadata": { "papermill": { "duration": 0.010119, "end_time": "2026-03-13T20:18:45.371076", "exception": false, "start_time": "2026-03-13T20:18:45.360957", "status": "completed" }, "tags": [] }, "source": [ "Specify a port number that is not in use and start the RS3 program." ] }, { "cell_type": "code", "execution_count": 3, "id": "45c4739d", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:18:45.390114Z", "iopub.status.busy": "2026-03-13T20:18:45.388729Z", "iopub.status.idle": "2026-03-13T20:19:28.867224Z", "shell.execute_reply": "2026-03-13T20:19:28.865531Z" }, "papermill": { "duration": 43.489689, "end_time": "2026-03-13T20:19:28.868737", "exception": false, "start_time": "2026-03-13T20:18:45.379048", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2026-03-13 16:18:45,400 - Rocscience.RS3 - INFO - Attempting to start the application at C:\\Program Files\\Rocscience\\RS3\\RS3 and binding server to port 60402...\n" ] } ], "source": [ "port = 60402\n", "RS3Modeler.startApplication(port)" ] }, { "cell_type": "markdown", "id": "160dc133", "metadata": { "papermill": { "duration": 0.004878, "end_time": "2026-03-13T20:19:28.880033", "exception": false, "start_time": "2026-03-13T20:19:28.875155", "status": "completed" }, "tags": [] }, "source": [ "Connect with the RS3 Modeler." ] }, { "cell_type": "code", "execution_count": 4, "id": "1dd1b01b", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:19:28.890381Z", "iopub.status.busy": "2026-03-13T20:19:28.890003Z", "iopub.status.idle": "2026-03-13T20:19:28.898427Z", "shell.execute_reply": "2026-03-13T20:19:28.896828Z" }, "papermill": { "duration": 0.015248, "end_time": "2026-03-13T20:19:28.899643", "exception": false, "start_time": "2026-03-13T20:19:28.884395", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "modeler = RS3Modeler(port)" ] }, { "cell_type": "markdown", "id": "558842a6", "metadata": { "papermill": { "duration": 0.005052, "end_time": "2026-03-13T20:19:28.911059", "exception": false, "start_time": "2026-03-13T20:19:28.906007", "status": "completed" }, "tags": [] }, "source": [ "For the demonstration purposes only, the model is copied for reuse. You may change the model path to your own model path." ] }, { "cell_type": "code", "execution_count": 5, "id": "8e5cba89", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:19:28.923541Z", "iopub.status.busy": "2026-03-13T20:19:28.923203Z", "iopub.status.idle": "2026-03-13T20:19:28.948540Z", "shell.execute_reply": "2026-03-13T20:19:28.946918Z" }, "papermill": { "duration": 0.033627, "end_time": "2026-03-13T20:19:28.949675", "exception": false, "start_time": "2026-03-13T20:19:28.916048", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "blankModelPath = rf\"{current_dir}\\example_models\\blankModel.rs3v3\"\n", "copiedModelPath = rf\"{current_dir}\\example_models\\copiedModel.rs3v3\"\n", "_ = shutil.copy(blankModelPath, copiedModelPath)" ] }, { "cell_type": "markdown", "id": "b6e405e2", "metadata": { "papermill": { "duration": 0.00463, "end_time": "2026-03-13T20:19:28.958474", "exception": false, "start_time": "2026-03-13T20:19:28.953844", "status": "completed" }, "tags": [] }, "source": [ "Open the copied model file." ] }, { "cell_type": "code", "execution_count": 6, "id": "12597746", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:19:28.974168Z", "iopub.status.busy": "2026-03-13T20:19:28.973740Z", "iopub.status.idle": "2026-03-13T20:19:47.679902Z", "shell.execute_reply": "2026-03-13T20:19:47.678515Z" }, "papermill": { "duration": 18.716015, "end_time": "2026-03-13T20:19:47.681187", "exception": false, "start_time": "2026-03-13T20:19:28.965172", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "model = modeler.openFile(copiedModelPath)" ] }, { "cell_type": "markdown", "id": "8178f89d", "metadata": { "papermill": { "duration": 0.006989, "end_time": "2026-03-13T20:19:47.695813", "exception": false, "start_time": "2026-03-13T20:19:47.688824", "status": "completed" }, "tags": [] }, "source": [ "## 1. Turn On Groundwater" ] }, { "cell_type": "code", "execution_count": 7, "id": "21adc968", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:19:47.711570Z", "iopub.status.busy": "2026-03-13T20:19:47.711162Z", "iopub.status.idle": "2026-03-13T20:19:48.434970Z", "shell.execute_reply": "2026-03-13T20:19:48.432872Z" }, "papermill": { "duration": 0.732877, "end_time": "2026-03-13T20:19:48.436747", "exception": false, "start_time": "2026-03-13T20:19:47.703870", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "model.ProjectSettings.Groundwater.setGroundwaterMethod(GroundwaterMethodType.GW_SURFACES)" ] }, { "cell_type": "markdown", "id": "04ac7414", "metadata": { "papermill": { "duration": 0.009759, "end_time": "2026-03-13T20:19:48.453886", "exception": false, "start_time": "2026-03-13T20:19:48.444127", "status": "completed" }, "tags": [] }, "source": [ "## 2. Define Groundwater Grid" ] }, { "cell_type": "markdown", "id": "91094ee0", "metadata": { "papermill": { "duration": 0.011524, "end_time": "2026-03-13T20:19:48.473295", "exception": false, "start_time": "2026-03-13T20:19:48.461771", "status": "completed" }, "tags": [] }, "source": [ "Create a water grid." ] }, { "cell_type": "code", "execution_count": 8, "id": "f538154b", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:19:48.499304Z", "iopub.status.busy": "2026-03-13T20:19:48.497770Z", "iopub.status.idle": "2026-03-13T20:19:49.151895Z", "shell.execute_reply": "2026-03-13T20:19:49.149172Z" }, "papermill": { "duration": 0.667282, "end_time": "2026-03-13T20:19:49.154344", "exception": false, "start_time": "2026-03-13T20:19:48.487062", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "'Water Grid 1'" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "waterGrid1Name = \"Water Grid 1\"\n", "model.createNewWaterGridProperty(waterGrid1Name)\n", "waterGrid1 = model.getWaterGridPropertyByName(waterGrid1Name)\n", "waterGrid1.getName()" ] }, { "cell_type": "code", "execution_count": 9, "id": "ad268f86", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:19:49.184828Z", "iopub.status.busy": "2026-03-13T20:19:49.183599Z", "iopub.status.idle": "2026-03-13T20:19:50.618092Z", "shell.execute_reply": "2026-03-13T20:19:50.613886Z" }, "papermill": { "duration": 1.454664, "end_time": "2026-03-13T20:19:50.620941", "exception": false, "start_time": "2026-03-13T20:19:49.166277", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "waterGrid1.setWaterGridPointSetType(WaterGridPointSetType.TOTAL_HEAD)\n", "waterGrid1.getWaterGridPointSetType()" ] }, { "cell_type": "code", "execution_count": 10, "id": "a9ed9d44", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:19:50.657768Z", "iopub.status.busy": "2026-03-13T20:19:50.656715Z", "iopub.status.idle": "2026-03-13T20:19:51.807506Z", "shell.execute_reply": "2026-03-13T20:19:51.803154Z" }, "papermill": { "duration": 1.174353, "end_time": "2026-03-13T20:19:51.810656", "exception": false, "start_time": "2026-03-13T20:19:50.636303", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "waterGrid1.setInterpolationMethod(GroundwaterInterpolationMethodType.INVERSE_DISTANCE)\n", "waterGrid1.getInterpolationMethod()" ] }, { "cell_type": "markdown", "id": "112ef16d", "metadata": { "papermill": { "duration": 0.021784, "end_time": "2026-03-13T20:19:51.847318", "exception": false, "start_time": "2026-03-13T20:19:51.825534", "status": "completed" }, "tags": [] }, "source": [ "### 2.1 Set Water Grid in 2D Plane" ] }, { "cell_type": "code", "execution_count": 11, "id": "ad16ee45", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:19:51.890365Z", "iopub.status.busy": "2026-03-13T20:19:51.889159Z", "iopub.status.idle": "2026-03-13T20:19:53.157316Z", "shell.execute_reply": "2026-03-13T20:19:53.153340Z" }, "papermill": { "duration": 1.29451, "end_time": "2026-03-13T20:19:53.160104", "exception": false, "start_time": "2026-03-13T20:19:51.865594", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "waterGrid1.setIs3D(False)\n", "waterGrid1.getIs3D()" ] }, { "cell_type": "code", "execution_count": 12, "id": "af6ba1cf", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:19:53.210564Z", "iopub.status.busy": "2026-03-13T20:19:53.209327Z", "iopub.status.idle": "2026-03-13T20:19:54.427973Z", "shell.execute_reply": "2026-03-13T20:19:54.423437Z" }, "papermill": { "duration": 1.250643, "end_time": "2026-03-13T20:19:54.430673", "exception": false, "start_time": "2026-03-13T20:19:53.180030", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "waterGrid1.set2DPlaneType(WaterGridPlane2DType.YZ_PLANE)\n", "waterGrid1.get2DPlaneType()" ] }, { "cell_type": "code", "execution_count": 13, "id": "2dc79260", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:19:54.475343Z", "iopub.status.busy": "2026-03-13T20:19:54.473557Z", "iopub.status.idle": "2026-03-13T20:19:55.581467Z", "shell.execute_reply": "2026-03-13T20:19:55.574918Z" }, "papermill": { "duration": 1.138924, "end_time": "2026-03-13T20:19:55.586294", "exception": false, "start_time": "2026-03-13T20:19:54.447370", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "[(0.0, 10.0, -3.0, -3.0),\n", " (0.0, 20.0, -5.0, -5.0),\n", " (0.0, 20.0, -10.0, -10.0),\n", " (0.0, 10.0, -15.0, -15.0)]" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "waterGrid1.setWaterGridPoints([(0, 10, -3, -3), (0, 20, -5, -5), (0, 20, -10, -10), (0, 10, -15, -15)])\n", "waterGrid1.getWaterGridPoints()" ] }, { "cell_type": "markdown", "id": "ba9be815", "metadata": { "papermill": { "duration": 0.020861, "end_time": "2026-03-13T20:19:55.622551", "exception": false, "start_time": "2026-03-13T20:19:55.601690", "status": "completed" }, "tags": [] }, "source": [ "### 2.2 Set Water Grid in 3D." ] }, { "cell_type": "code", "execution_count": 14, "id": "e0f6b4b8", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:19:55.658707Z", "iopub.status.busy": "2026-03-13T20:19:55.657058Z", "iopub.status.idle": "2026-03-13T20:19:56.750068Z", "shell.execute_reply": "2026-03-13T20:19:56.746165Z" }, "papermill": { "duration": 1.116142, "end_time": "2026-03-13T20:19:56.755108", "exception": false, "start_time": "2026-03-13T20:19:55.638966", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "waterGrid1.setIs3D(True)\n", "waterGrid1.getIs3D()" ] }, { "cell_type": "code", "execution_count": 15, "id": "d27eaa6e", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:19:56.795907Z", "iopub.status.busy": "2026-03-13T20:19:56.795202Z", "iopub.status.idle": "2026-03-13T20:19:57.802273Z", "shell.execute_reply": "2026-03-13T20:19:57.798434Z" }, "papermill": { "duration": 1.0298, "end_time": "2026-03-13T20:19:57.806722", "exception": false, "start_time": "2026-03-13T20:19:56.776922", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "[(0.0, 0.0, 0.0, -3.0),\n", " (30.0, 0.0, 0.0, -3.0),\n", " (30.0, 30.0, 0.0, -3.0),\n", " (0.0, 30.0, 0.0, -3.0)]" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "waterGrid1.setWaterGridPoints([(0, 0, 0, -3), (30, 0, 0, -3), (30, 30, 0, -3), (0, 30, 0, -3)])\n", "waterGrid1.getWaterGridPoints()" ] }, { "cell_type": "markdown", "id": "042f3a9c", "metadata": { "papermill": { "duration": 0.016434, "end_time": "2026-03-13T20:19:57.848589", "exception": false, "start_time": "2026-03-13T20:19:57.832155", "status": "completed" }, "tags": [] }, "source": [ "Save and close the model." ] }, { "cell_type": "code", "execution_count": 16, "id": "bf63ad3c", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:19:57.903114Z", "iopub.status.busy": "2026-03-13T20:19:57.901633Z", "iopub.status.idle": "2026-03-13T20:20:02.470324Z", "shell.execute_reply": "2026-03-13T20:20:02.468435Z" }, "papermill": { "duration": 4.591814, "end_time": "2026-03-13T20:20:02.472305", "exception": false, "start_time": "2026-03-13T20:19:57.880491", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "model.close(True)" ] }, { "cell_type": "markdown", "id": "5324a3e2", "metadata": { "papermill": { "duration": 0.00904, "end_time": "2026-03-13T20:20:02.490074", "exception": false, "start_time": "2026-03-13T20:20:02.481034", "status": "completed" }, "tags": [] }, "source": [ "Close the program." ] }, { "cell_type": "code", "execution_count": 17, "id": "2836c09f", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:20:02.506134Z", "iopub.status.busy": "2026-03-13T20:20:02.505705Z", "iopub.status.idle": "2026-03-13T20:20:07.197498Z", "shell.execute_reply": "2026-03-13T20:20:07.193544Z" }, "papermill": { "duration": 4.702835, "end_time": "2026-03-13T20:20:07.199947", "exception": false, "start_time": "2026-03-13T20:20:02.497112", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "modeler.closeProgram()" ] }, { "cell_type": "markdown", "id": "7b94233d", "metadata": { "papermill": { "duration": 0.00804, "end_time": "2026-03-13T20:20:07.216752", "exception": false, "start_time": "2026-03-13T20:20:07.208712", "status": "completed" }, "tags": [] }, "source": [ "## Full Script" ] }, { "cell_type": "code", "execution_count": 18, "id": "60109e5f", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T20:20:07.232050Z", "iopub.status.busy": "2026-03-13T20:20:07.231613Z", "iopub.status.idle": "2026-03-13T20:21:13.738633Z", "shell.execute_reply": "2026-03-13T20:21:13.737364Z" }, "papermill": { "duration": 66.516918, "end_time": "2026-03-13T20:21:13.739955", "exception": false, "start_time": "2026-03-13T20:20:07.223037", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2026-03-13 16:20:07,238 - Rocscience.RS3 - INFO - Attempting to start the application at C:\\Program Files\\Rocscience\\RS3\\RS3 and binding server to port 60402...\n" ] } ], "source": [ "# Water Grid Script Examples\n", "# Download the [blankModel.rs3v3](https://github.com/Rocscience/rs3-scripting/tree/main/docs/example_code/example_models/blankModel.rs3v3) for this example.\n", "from rs3.RS3Modeler import RS3Modeler\n", "from rs3.properties.PropertyEnums import *\n", "from rs3.projectSettings.ProjectSettingEnums import *\n", "import os\n", "import shutil\n", "# Get the current folder directory.\n", "current_dir = os.path.dirname(os.path.abspath(\"\"))\n", "# Specify a port number that is not in use and start the RS3 program.\n", "port = 60402\n", "RS3Modeler.startApplication(port)\n", "# Connect with the RS3 Modeler.\n", "modeler = RS3Modeler(port)\n", "# For the demonstration purposes only, the model is copied for reuse. You may change the model path to your own model path.\n", "blankModelPath = rf\"{current_dir}\\example_models\\blankModel.rs3v3\"\n", "copiedModelPath = rf\"{current_dir}\\example_models\\copiedModel.rs3v3\"\n", "_ = shutil.copy(blankModelPath, copiedModelPath)\n", "# Open the copied model file.\n", "model = modeler.openFile(copiedModelPath)\n", "\n", "# 1. Turn On Groundwater\n", "model.ProjectSettings.Groundwater.setGroundwaterMethod(GroundwaterMethodType.GW_SURFACES)\n", "\n", "# 2. Define Groundwater Grid\n", "# Create a water grid.\n", "waterGrid1Name = \"Water Grid 1\"\n", "model.createNewWaterGridProperty(waterGrid1Name)\n", "waterGrid1 = model.getWaterGridPropertyByName(waterGrid1Name)\n", "waterGrid1.setWaterGridPointSetType(WaterGridPointSetType.TOTAL_HEAD)\n", "waterGrid1.setInterpolationMethod(GroundwaterInterpolationMethodType.INVERSE_DISTANCE)\n", "# 2.1 Set Water Grid in 2D Plane\n", "waterGrid1.setIs3D(False)\n", "waterGrid1.set2DPlaneType(WaterGridPlane2DType.YZ_PLANE)\n", "waterGrid1.setWaterGridPoints([(0, 10, -3, -3), (0, 20, -5, -5), (0, 20, -10, -10), (0, 10, -15, -15)])\n", "# 2.2 Set Water Grid in 3D.\n", "waterGrid1.setIs3D(True)\n", "waterGrid1.setWaterGridPoints([(0, 0, 0, -3), (30, 0, 0, -3), (30, 30, 0, -3), (0, 30, 0, -3)])\n", "\n", "# Save and close the model.\n", "model.close(True)" ] } ], "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.13.0" }, "papermill": { "default_parameters": {}, "duration": 154.072126, "end_time": "2026-03-13T20:21:16.394239", "environment_variables": {}, "exception": null, "input_path": "C:\\Users\\GraceHu\\source\\repos\\RS3Scripting_Compute\\docs\\example_code\\groundwater\\water_grid_example.ipynb", "output_path": "C:\\Users\\GraceHu\\source\\repos\\RS3Scripting_Compute\\docs\\example_code\\groundwater\\water_grid_example.ipynb", "parameters": {}, "start_time": "2026-03-13T20:18:42.322113", "version": "2.6.0" } }, "nbformat": 4, "nbformat_minor": 5 }