Water Grid Script Examples#

Download the blankModel.rs3v3 for this example.

from rs3.RS3Modeler import RS3Modeler
from rs3.properties.PropertyEnums import *
from rs3.projectSettings.ProjectSettingEnums import *
import os
import shutil

Get the current folder directory.

current_dir = os.path.dirname(os.path.abspath(""))

Specify a port number that is not in use and start the RS3 program.

port = 60402
RS3Modeler.startApplication(port)
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...

Connect with the RS3 Modeler.

modeler = RS3Modeler(port)

For the demonstration purposes only, the model is copied for reuse. You may change the model path to your own model path.

blankModelPath = rf"{current_dir}\example_models\blankModel.rs3v3"
copiedModelPath = rf"{current_dir}\example_models\copiedModel.rs3v3"
_ = shutil.copy(blankModelPath, copiedModelPath)

Open the copied model file.

model = modeler.openFile(copiedModelPath)

1. Turn On Groundwater#

model.ProjectSettings.Groundwater.setGroundwaterMethod(GroundwaterMethodType.GW_SURFACES)

2. Define Groundwater Grid#

Create a water grid.

waterGrid1Name = "Water Grid 1"
model.createNewWaterGridProperty(waterGrid1Name)
waterGrid1 = model.getWaterGridPropertyByName(waterGrid1Name)
waterGrid1.getName()
'Water Grid 1'
waterGrid1.setWaterGridPointSetType(WaterGridPointSetType.TOTAL_HEAD)
waterGrid1.getWaterGridPointSetType()
<WaterGridPointSetType.TOTAL_HEAD: 'TotalHead'>
waterGrid1.setInterpolationMethod(GroundwaterInterpolationMethodType.INVERSE_DISTANCE)
waterGrid1.getInterpolationMethod()
<WaterGridInterpolationMethodType.INVERSE_DISTANCE: 'InverseDistance'>

2.1 Set Water Grid in 2D Plane#

waterGrid1.setIs3D(False)
waterGrid1.getIs3D()
False
waterGrid1.set2DPlaneType(WaterGridPlane2DType.YZ_PLANE)
waterGrid1.get2DPlaneType()
<WaterGridPlane2DType.YZ_PLANE: 'YZ_PLANE'>
waterGrid1.setWaterGridPoints([(0, 10, -3, -3), (0, 20, -5, -5), (0, 20, -10, -10), (0, 10, -15, -15)])
waterGrid1.getWaterGridPoints()
[(0.0, 10.0, -3.0, -3.0),
 (0.0, 20.0, -5.0, -5.0),
 (0.0, 20.0, -10.0, -10.0),
 (0.0, 10.0, -15.0, -15.0)]

2.2 Set Water Grid in 3D.#

waterGrid1.setIs3D(True)
waterGrid1.getIs3D()
True
waterGrid1.setWaterGridPoints([(0, 0, 0, -3), (30, 0, 0, -3), (30, 30, 0, -3), (0, 30, 0, -3)])
waterGrid1.getWaterGridPoints()
[(0.0, 0.0, 0.0, -3.0),
 (30.0, 0.0, 0.0, -3.0),
 (30.0, 30.0, 0.0, -3.0),
 (0.0, 30.0, 0.0, -3.0)]

Save and close the model.

model.close(True)

Close the program.

modeler.closeProgram()

Full Script#

# Water Grid Script Examples
# Download the [blankModel.rs3v3](https://github.com/Rocscience/rs3-scripting/tree/main/docs/example_code/example_models/blankModel.rs3v3) for this example.
from rs3.RS3Modeler import RS3Modeler
from rs3.properties.PropertyEnums import *
from rs3.projectSettings.ProjectSettingEnums import *
import os
import shutil
# Get the current folder directory.
current_dir = os.path.dirname(os.path.abspath(""))
# Specify a port number that is not in use and start the RS3 program.
port = 60402
RS3Modeler.startApplication(port)
# Connect with the RS3 Modeler.
modeler = RS3Modeler(port)
# For the demonstration purposes only, the model is copied for reuse. You may change the model path to your own model path.
blankModelPath = rf"{current_dir}\example_models\blankModel.rs3v3"
copiedModelPath = rf"{current_dir}\example_models\copiedModel.rs3v3"
_ = shutil.copy(blankModelPath, copiedModelPath)
# Open the copied model file.
model = modeler.openFile(copiedModelPath)

# 1. Turn On Groundwater
model.ProjectSettings.Groundwater.setGroundwaterMethod(GroundwaterMethodType.GW_SURFACES)

# 2. Define Groundwater Grid
# Create a water grid.
waterGrid1Name = "Water Grid 1"
model.createNewWaterGridProperty(waterGrid1Name)
waterGrid1 = model.getWaterGridPropertyByName(waterGrid1Name)
waterGrid1.setWaterGridPointSetType(WaterGridPointSetType.TOTAL_HEAD)
waterGrid1.setInterpolationMethod(GroundwaterInterpolationMethodType.INVERSE_DISTANCE)
# 2.1 Set Water Grid in 2D Plane
waterGrid1.setIs3D(False)
waterGrid1.set2DPlaneType(WaterGridPlane2DType.YZ_PLANE)
waterGrid1.setWaterGridPoints([(0, 10, -3, -3), (0, 20, -5, -5), (0, 20, -10, -10), (0, 10, -15, -15)])
# 2.2 Set Water Grid in 3D.
waterGrid1.setIs3D(True)
waterGrid1.setWaterGridPoints([(0, 0, 0, -3), (30, 0, 0, -3), (30, 30, 0, -3), (0, 30, 0, -3)])

# Save and close the model.
model.close(True)
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...