{ "cells": [ { "cell_type": "markdown", "id": "4997d777", "metadata": { "papermill": { "duration": 0.009381, "end_time": "2026-03-13T21:19:55.419186", "exception": false, "start_time": "2026-03-13T21:19:55.409805", "status": "completed" }, "tags": [] }, "source": [ "(joint_example)=\n", "# Joint Script Examples" ] }, { "cell_type": "markdown", "id": "652c41de", "metadata": { "papermill": { "duration": 0.005745, "end_time": "2026-03-13T21:19:55.430457", "exception": false, "start_time": "2026-03-13T21:19:55.424712", "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-13T21:19:55.447316Z", "iopub.status.busy": "2026-03-13T21:19:55.446898Z", "iopub.status.idle": "2026-03-13T21:19:55.720787Z", "shell.execute_reply": "2026-03-13T21:19:55.719426Z" }, "papermill": { "duration": 0.284011, "end_time": "2026-03-13T21:19:55.721946", "exception": false, "start_time": "2026-03-13T21:19:55.437935", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "from rs3.RS3Modeler import RS3Modeler\n", "from rs3.properties.PropertyEnums import *\n", "import os\n", "import shutil" ] }, { "cell_type": "markdown", "id": "bdd2f737", "metadata": { "papermill": { "duration": 0.007734, "end_time": "2026-03-13T21:19:55.736463", "exception": false, "start_time": "2026-03-13T21:19:55.728729", "status": "completed" }, "tags": [] }, "source": [ "Get the current folder directory." ] }, { "cell_type": "code", "execution_count": 2, "id": "5fceeae1", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:19:55.755878Z", "iopub.status.busy": "2026-03-13T21:19:55.755252Z", "iopub.status.idle": "2026-03-13T21:19:55.761229Z", "shell.execute_reply": "2026-03-13T21:19:55.759540Z" }, "papermill": { "duration": 0.018734, "end_time": "2026-03-13T21:19:55.762440", "exception": false, "start_time": "2026-03-13T21:19:55.743706", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "current_dir = os.path.abspath(\"\")" ] }, { "cell_type": "markdown", "id": "561e8648", "metadata": { "papermill": { "duration": 0.006865, "end_time": "2026-03-13T21:19:55.777562", "exception": false, "start_time": "2026-03-13T21:19:55.770697", "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": "570a44f7", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:19:55.794227Z", "iopub.status.busy": "2026-03-13T21:19:55.793858Z", "iopub.status.idle": "2026-03-13T21:20:24.707426Z", "shell.execute_reply": "2026-03-13T21:20:24.706077Z" }, "papermill": { "duration": 28.923757, "end_time": "2026-03-13T21:20:24.708736", "exception": false, "start_time": "2026-03-13T21:19:55.784979", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2026-03-13 17:19:55,800 - Rocscience.RS3 - INFO - Attempting to start the application at C:\\Program Files\\Rocscience\\RS3\\RS3 and binding server to port 60303...\n" ] } ], "source": [ "port = 60303\n", "RS3Modeler.startApplication(port)" ] }, { "cell_type": "markdown", "id": "69d981fa", "metadata": { "papermill": { "duration": 0.006705, "end_time": "2026-03-13T21:20:24.723508", "exception": false, "start_time": "2026-03-13T21:20:24.716803", "status": "completed" }, "tags": [] }, "source": [ "Connect with the RS3 Modeler." ] }, { "cell_type": "code", "execution_count": 4, "id": "b0e80be7", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:24.739477Z", "iopub.status.busy": "2026-03-13T21:20:24.739110Z", "iopub.status.idle": "2026-03-13T21:20:24.965965Z", "shell.execute_reply": "2026-03-13T21:20:24.964503Z" }, "papermill": { "duration": 0.236731, "end_time": "2026-03-13T21:20:24.967881", "exception": false, "start_time": "2026-03-13T21:20:24.731150", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "modeler = RS3Modeler(port)" ] }, { "cell_type": "markdown", "id": "558842a6", "metadata": { "papermill": { "duration": 0.008943, "end_time": "2026-03-13T21:20:24.987586", "exception": false, "start_time": "2026-03-13T21:20:24.978643", "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-13T21:20:25.007640Z", "iopub.status.busy": "2026-03-13T21:20:25.007094Z", "iopub.status.idle": "2026-03-13T21:20:25.033528Z", "shell.execute_reply": "2026-03-13T21:20:25.032094Z" }, "papermill": { "duration": 0.037886, "end_time": "2026-03-13T21:20:25.034993", "exception": false, "start_time": "2026-03-13T21:20:24.997107", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "blankModelPath = rf\"{os.path.dirname(current_dir)}\\example_models\\blankModel.rs3v3\"\n", "copiedModelPath = rf\"{os.path.dirname(current_dir)}\\example_models\\copiedModel.rs3v3\"\n", "_ = shutil.copy(blankModelPath, copiedModelPath)" ] }, { "cell_type": "markdown", "id": "b6e405e2", "metadata": { "papermill": { "duration": 0.007674, "end_time": "2026-03-13T21:20:25.050650", "exception": false, "start_time": "2026-03-13T21:20:25.042976", "status": "completed" }, "tags": [] }, "source": [ "Open the copied model file." ] }, { "cell_type": "code", "execution_count": 6, "id": "12597746", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:25.069720Z", "iopub.status.busy": "2026-03-13T21:20:25.069377Z", "iopub.status.idle": "2026-03-13T21:20:37.588700Z", "shell.execute_reply": "2026-03-13T21:20:37.587545Z" }, "papermill": { "duration": 12.532004, "end_time": "2026-03-13T21:20:37.590224", "exception": false, "start_time": "2026-03-13T21:20:25.058220", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "model = modeler.openFile(copiedModelPath)" ] }, { "cell_type": "markdown", "id": "8178f89d", "metadata": { "papermill": { "duration": 0.008377, "end_time": "2026-03-13T21:20:37.607291", "exception": false, "start_time": "2026-03-13T21:20:37.598914", "status": "completed" }, "tags": [] }, "source": [ "## 1. Create and Get Joint" ] }, { "cell_type": "markdown", "id": "91094ee0", "metadata": { "papermill": { "duration": 0.010452, "end_time": "2026-03-13T21:20:37.625580", "exception": false, "start_time": "2026-03-13T21:20:37.615128", "status": "completed" }, "tags": [] }, "source": [ "Get the first joint in the list." ] }, { "cell_type": "code", "execution_count": 7, "id": "f538154b", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:37.645931Z", "iopub.status.busy": "2026-03-13T21:20:37.645559Z", "iopub.status.idle": "2026-03-13T21:20:37.696481Z", "shell.execute_reply": "2026-03-13T21:20:37.695031Z" }, "papermill": { "duration": 0.062177, "end_time": "2026-03-13T21:20:37.697919", "exception": false, "start_time": "2026-03-13T21:20:37.635742", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "'Joint 1'" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joint1 = model.getAllJointProperties()[0]\n", "joint1.getJointName()" ] }, { "cell_type": "markdown", "id": "592a6630", "metadata": { "papermill": { "duration": 0.007877, "end_time": "2026-03-13T21:20:37.714890", "exception": false, "start_time": "2026-03-13T21:20:37.707013", "status": "completed" }, "tags": [] }, "source": [ "Create a new joint and get the joint by name." ] }, { "cell_type": "code", "execution_count": 8, "id": "749fa49f", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:37.734687Z", "iopub.status.busy": "2026-03-13T21:20:37.734183Z", "iopub.status.idle": "2026-03-13T21:20:37.886148Z", "shell.execute_reply": "2026-03-13T21:20:37.884413Z" }, "papermill": { "duration": 0.165306, "end_time": "2026-03-13T21:20:37.888954", "exception": false, "start_time": "2026-03-13T21:20:37.723648", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "'Joint 2'" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joint2Name = \"Joint 2\"\n", "model.createNewJointProperty(joint2Name)\n", "joint2 = model.getJointPropertyByName(joint2Name)\n", "joint2.getJointName()" ] }, { "cell_type": "markdown", "id": "e099dd78", "metadata": { "papermill": { "duration": 0.00978, "end_time": "2026-03-13T21:20:37.910759", "exception": false, "start_time": "2026-03-13T21:20:37.900979", "status": "completed" }, "tags": [] }, "source": [ "## 2. Set Joint Properties" ] }, { "cell_type": "code", "execution_count": 9, "id": "54e32148", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:37.933244Z", "iopub.status.busy": "2026-03-13T21:20:37.932831Z", "iopub.status.idle": "2026-03-13T21:20:37.989468Z", "shell.execute_reply": "2026-03-13T21:20:37.986912Z" }, "papermill": { "duration": 0.071188, "end_time": "2026-03-13T21:20:37.991864", "exception": false, "start_time": "2026-03-13T21:20:37.920676", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joint1.setConstitutiveModel(JointConstitutiveModelTypes.MOHR_COULOMB)\n", "joint1.getConstitutiveModel()" ] }, { "cell_type": "code", "execution_count": 10, "id": "d08f6b17", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:38.020399Z", "iopub.status.busy": "2026-03-13T21:20:38.019964Z", "iopub.status.idle": "2026-03-13T21:20:38.041740Z", "shell.execute_reply": "2026-03-13T21:20:38.038968Z" }, "papermill": { "duration": 0.03965, "end_time": "2026-03-13T21:20:38.043711", "exception": false, "start_time": "2026-03-13T21:20:38.004061", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{'InitialJointDeformation': True,\n", " 'Permeable': True,\n", " 'ApplySSR': True,\n", " 'ApplyPorePressure': True,\n", " 'ApplyAdditionalPressureInsideJoint': False,\n", " 'AdditionalPressureInsideJoint': 0.0,\n", " 'ApplyStageFactors': False}" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joint1.getProperties()" ] }, { "cell_type": "code", "execution_count": 11, "id": "11b4011f", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:38.064902Z", "iopub.status.busy": "2026-03-13T21:20:38.064526Z", "iopub.status.idle": "2026-03-13T21:20:38.247453Z", "shell.execute_reply": "2026-03-13T21:20:38.244505Z" }, "papermill": { "duration": 0.196486, "end_time": "2026-03-13T21:20:38.249566", "exception": false, "start_time": "2026-03-13T21:20:38.053080", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "joint1.setInitialJointDeformation(False)\n", "joint1.setApplyAdditionalPressureInsideJoint(True)\n", "joint1.setAdditionalPressureType(AdditionalPressureType.PRESSURE)\n", "joint1.setAdditionalPressureInsideJoint(150)" ] }, { "cell_type": "code", "execution_count": 12, "id": "152cbe81", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:38.280340Z", "iopub.status.busy": "2026-03-13T21:20:38.279671Z", "iopub.status.idle": "2026-03-13T21:20:38.315045Z", "shell.execute_reply": "2026-03-13T21:20:38.313796Z" }, "papermill": { "duration": 0.053719, "end_time": "2026-03-13T21:20:38.316608", "exception": false, "start_time": "2026-03-13T21:20:38.262889", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{'DilationAngle': 0.0,\n", " 'NormalStiffness': 100000.0,\n", " 'ShearStiffness': 10000.0,\n", " 'Cohesion': 0.0,\n", " 'FrictionAngle': 35.0,\n", " 'TensileStrength': 0.0,\n", " 'DefineResidualStrength': False,\n", " 'Directional': False,\n", " 'ResidualCohesion': 0.0,\n", " 'ResidualFrictionAngle': 0.0,\n", " 'ResidualTensileStrength': 0.0}" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joint1.MohrCoulomb.getProperties()" ] }, { "cell_type": "code", "execution_count": 13, "id": "5d1a4a77", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:38.338488Z", "iopub.status.busy": "2026-03-13T21:20:38.337891Z", "iopub.status.idle": "2026-03-13T21:20:38.502862Z", "shell.execute_reply": "2026-03-13T21:20:38.501235Z" }, "papermill": { "duration": 0.17809, "end_time": "2026-03-13T21:20:38.504292", "exception": false, "start_time": "2026-03-13T21:20:38.326202", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{'DilationAngle': 0.0,\n", " 'NormalStiffness': 100000.0,\n", " 'ShearStiffness': 10000.0,\n", " 'Cohesion': 0.0,\n", " 'FrictionAngle': 35.0,\n", " 'TensileStrength': 10.0,\n", " 'DefineResidualStrength': True,\n", " 'Directional': False,\n", " 'ResidualCohesion': 0.0,\n", " 'ResidualFrictionAngle': 0.0,\n", " 'ResidualTensileStrength': 5.0}" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joint1.MohrCoulomb.setDefineResidualStrength(True)\n", "joint1.MohrCoulomb.setProperties(TensileStrength=10, ResidualTensileStrength=5)\n", "joint1Properties = joint1.MohrCoulomb.getProperties()\n", "joint1Properties" ] }, { "cell_type": "markdown", "id": "719207a0", "metadata": { "papermill": { "duration": 0.008325, "end_time": "2026-03-13T21:20:38.521199", "exception": false, "start_time": "2026-03-13T21:20:38.512874", "status": "completed" }, "tags": [] }, "source": [ "## 3. Copy Joint Properties" ] }, { "cell_type": "code", "execution_count": 14, "id": "5734fb77", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:38.544083Z", "iopub.status.busy": "2026-03-13T21:20:38.543506Z", "iopub.status.idle": "2026-03-13T21:20:38.581525Z", "shell.execute_reply": "2026-03-13T21:20:38.579054Z" }, "papermill": { "duration": 0.051085, "end_time": "2026-03-13T21:20:38.583724", "exception": false, "start_time": "2026-03-13T21:20:38.532639", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joint2.setConstitutiveModel(JointConstitutiveModelTypes.MOHR_COULOMB)\n", "joint2.getConstitutiveModel()" ] }, { "cell_type": "code", "execution_count": 15, "id": "ab017b80", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:38.614182Z", "iopub.status.busy": "2026-03-13T21:20:38.613099Z", "iopub.status.idle": "2026-03-13T21:20:38.647841Z", "shell.execute_reply": "2026-03-13T21:20:38.646458Z" }, "papermill": { "duration": 0.052101, "end_time": "2026-03-13T21:20:38.649117", "exception": false, "start_time": "2026-03-13T21:20:38.597016", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{'DilationAngle': 0.0,\n", " 'NormalStiffness': 100000.0,\n", " 'ShearStiffness': 10000.0,\n", " 'Cohesion': 0.0,\n", " 'FrictionAngle': 35.0,\n", " 'TensileStrength': 0.0,\n", " 'DefineResidualStrength': False,\n", " 'Directional': False,\n", " 'ResidualCohesion': 0.0,\n", " 'ResidualFrictionAngle': 0.0,\n", " 'ResidualTensileStrength': 0.0}" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joint2.MohrCoulomb.getProperties()" ] }, { "cell_type": "code", "execution_count": 16, "id": "86c2bc42", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:38.672211Z", "iopub.status.busy": "2026-03-13T21:20:38.671573Z", "iopub.status.idle": "2026-03-13T21:20:39.144972Z", "shell.execute_reply": "2026-03-13T21:20:39.143133Z" }, "papermill": { "duration": 0.4875, "end_time": "2026-03-13T21:20:39.146448", "exception": false, "start_time": "2026-03-13T21:20:38.658948", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{'DilationAngle': 0.0,\n", " 'NormalStiffness': 100000.0,\n", " 'ShearStiffness': 10000.0,\n", " 'Cohesion': 0.0,\n", " 'FrictionAngle': 35.0,\n", " 'TensileStrength': 10.0,\n", " 'DefineResidualStrength': True,\n", " 'Directional': False,\n", " 'ResidualCohesion': 0.0,\n", " 'ResidualFrictionAngle': 0.0,\n", " 'ResidualTensileStrength': 5.0}" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joint2.MohrCoulomb.setProperties(**joint1Properties)\n", "joint2.MohrCoulomb.getProperties()" ] }, { "cell_type": "markdown", "id": "5b6f07e6", "metadata": { "papermill": { "duration": 0.009073, "end_time": "2026-03-13T21:20:39.165095", "exception": false, "start_time": "2026-03-13T21:20:39.156022", "status": "completed" }, "tags": [] }, "source": [ "## 4. Set Stage Factors" ] }, { "cell_type": "markdown", "id": "c64ec2e5", "metadata": { "papermill": { "duration": 0.008402, "end_time": "2026-03-13T21:20:39.182569", "exception": false, "start_time": "2026-03-13T21:20:39.174167", "status": "completed" }, "tags": [] }, "source": [ "Turn on the stage factors of joints." ] }, { "cell_type": "code", "execution_count": 17, "id": "c488dd48", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:39.205402Z", "iopub.status.busy": "2026-03-13T21:20:39.205004Z", "iopub.status.idle": "2026-03-13T21:20:39.289616Z", "shell.execute_reply": "2026-03-13T21:20:39.285136Z" }, "papermill": { "duration": 0.098794, "end_time": "2026-03-13T21:20:39.292636", "exception": false, "start_time": "2026-03-13T21:20:39.193842", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "joint1.setApplyStageFactors(True)\n", "joint1.MohrCoulomb.setAllowSlipStartFromStage(3)" ] }, { "cell_type": "markdown", "id": "78cf4674", "metadata": { "papermill": { "duration": 0.014447, "end_time": "2026-03-13T21:20:39.319510", "exception": false, "start_time": "2026-03-13T21:20:39.305063", "status": "completed" }, "tags": [] }, "source": [ "Joints take both constitutive model properties and hydraulic properties. When you create the stage factors for joints, the overall controls are under the Joint class.\n", "\n", "Now, create a stage factor for stage 2 and get the stage factors of hydraulic properties of the joint at stage 2." ] }, { "cell_type": "code", "execution_count": 18, "id": "5ea93281", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:39.344062Z", "iopub.status.busy": "2026-03-13T21:20:39.343587Z", "iopub.status.idle": "2026-03-13T21:20:39.384738Z", "shell.execute_reply": "2026-03-13T21:20:39.383510Z" }, "papermill": { "duration": 0.054009, "end_time": "2026-03-13T21:20:39.385833", "exception": false, "start_time": "2026-03-13T21:20:39.331824", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "joint1.StageFactorInterface.createStageFactor(2)\n", "newJointStageFactor_s2 = joint1.StageFactorInterface.getDefinedStageFactors()[2]" ] }, { "cell_type": "markdown", "id": "838e1e58", "metadata": { "papermill": { "duration": 0.008839, "end_time": "2026-03-13T21:20:39.403670", "exception": false, "start_time": "2026-03-13T21:20:39.394831", "status": "completed" }, "tags": [] }, "source": [ "Get the current stage factor of additional pressure inside joint." ] }, { "cell_type": "code", "execution_count": 19, "id": "6b928a7c", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:39.429064Z", "iopub.status.busy": "2026-03-13T21:20:39.428564Z", "iopub.status.idle": "2026-03-13T21:20:39.452417Z", "shell.execute_reply": "2026-03-13T21:20:39.451110Z" }, "papermill": { "duration": 0.038676, "end_time": "2026-03-13T21:20:39.453876", "exception": false, "start_time": "2026-03-13T21:20:39.415200", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "1.0" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "newJointStageFactor_s2.getAdditionalPressureInsideJointFactor()" ] }, { "cell_type": "markdown", "id": "32b46d31", "metadata": { "papermill": { "duration": 0.010627, "end_time": "2026-03-13T21:20:39.475501", "exception": false, "start_time": "2026-03-13T21:20:39.464874", "status": "completed" }, "tags": [] }, "source": [ "Set stage factor of additional pressure inside joint." ] }, { "cell_type": "code", "execution_count": 20, "id": "a0243a17", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:39.499242Z", "iopub.status.busy": "2026-03-13T21:20:39.498814Z", "iopub.status.idle": "2026-03-13T21:20:39.512046Z", "shell.execute_reply": "2026-03-13T21:20:39.510585Z" }, "papermill": { "duration": 0.027604, "end_time": "2026-03-13T21:20:39.513538", "exception": false, "start_time": "2026-03-13T21:20:39.485934", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "newJointStageFactor_s2.setAdditionalPressureInsideJointFactor(1.5)" ] }, { "cell_type": "markdown", "id": "0b2be899", "metadata": { "papermill": { "duration": 0.009462, "end_time": "2026-03-13T21:20:39.531876", "exception": false, "start_time": "2026-03-13T21:20:39.522414", "status": "completed" }, "tags": [] }, "source": [ "Get stage factors of all stages and check stage factor of additional pressure inside joint at stage 2." ] }, { "cell_type": "code", "execution_count": 21, "id": "19980170", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:39.552823Z", "iopub.status.busy": "2026-03-13T21:20:39.552376Z", "iopub.status.idle": "2026-03-13T21:20:39.569451Z", "shell.execute_reply": "2026-03-13T21:20:39.568180Z" }, "papermill": { "duration": 0.028597, "end_time": "2026-03-13T21:20:39.570543", "exception": false, "start_time": "2026-03-13T21:20:39.541946", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "1.5" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stageFactors_s2 = joint1.StageFactorInterface.getStageFactor(2)\n", "stageFactors_s2.getAdditionalPressureInsideJointFactor()" ] }, { "cell_type": "markdown", "id": "2235df55", "metadata": { "papermill": { "duration": 0.010031, "end_time": "2026-03-13T21:20:39.592698", "exception": false, "start_time": "2026-03-13T21:20:39.582667", "status": "completed" }, "tags": [] }, "source": [ "Similarly, change the stage factor of dilation angle under Mohr Coulomb joint module." ] }, { "cell_type": "code", "execution_count": 22, "id": "9a572b1c", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:39.614935Z", "iopub.status.busy": "2026-03-13T21:20:39.614556Z", "iopub.status.idle": "2026-03-13T21:20:39.625607Z", "shell.execute_reply": "2026-03-13T21:20:39.624197Z" }, "papermill": { "duration": 0.024153, "end_time": "2026-03-13T21:20:39.626795", "exception": false, "start_time": "2026-03-13T21:20:39.602642", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "1.3" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "newMohrCoulombJointStageFactor_s2 = joint1.MohrCoulomb.StageFactorInterface.getDefinedStageFactors()[2]\n", "newMohrCoulombJointStageFactor_s2.setDilationAngleFactor(1.3)\n", "newMohrCoulombJointStageFactor_s2.getDilationAngleFactor()" ] }, { "cell_type": "markdown", "id": "b4857a83", "metadata": { "papermill": { "duration": 0.011891, "end_time": "2026-03-13T21:20:39.647216", "exception": false, "start_time": "2026-03-13T21:20:39.635325", "status": "completed" }, "tags": [] }, "source": [ "Create another stage factor for stage 4 and set the stage factor of additional pressure inside joint." ] }, { "cell_type": "code", "execution_count": 23, "id": "61507c97", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:39.668981Z", "iopub.status.busy": "2026-03-13T21:20:39.668525Z", "iopub.status.idle": "2026-03-13T21:20:39.682180Z", "shell.execute_reply": "2026-03-13T21:20:39.680725Z" }, "papermill": { "duration": 0.026308, "end_time": "2026-03-13T21:20:39.683397", "exception": false, "start_time": "2026-03-13T21:20:39.657089", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "2.1" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joint1.StageFactorInterface.createStageFactor(4)\n", "newJointStageFactor_s4 = joint1.StageFactorInterface.getDefinedStageFactors()[4]\n", "newJointStageFactor_s4.setAdditionalPressureInsideJointFactor(2.1)\n", "newJointStageFactor_s4.getAdditionalPressureInsideJointFactor()" ] }, { "cell_type": "markdown", "id": "de1e5587", "metadata": { "papermill": { "duration": 0.012376, "end_time": "2026-03-13T21:20:39.706698", "exception": false, "start_time": "2026-03-13T21:20:39.694322", "status": "completed" }, "tags": [] }, "source": [ "## 5. Delete Joint Stage Factor" ] }, { "cell_type": "markdown", "id": "ac8d4ff7", "metadata": { "papermill": { "duration": 0.010138, "end_time": "2026-03-13T21:20:39.728180", "exception": false, "start_time": "2026-03-13T21:20:39.718042", "status": "completed" }, "tags": [] }, "source": [ "Get the dictionary of all stage factors." ] }, { "cell_type": "code", "execution_count": 24, "id": "474048ca", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:39.750935Z", "iopub.status.busy": "2026-03-13T21:20:39.750572Z", "iopub.status.idle": "2026-03-13T21:20:39.760442Z", "shell.execute_reply": "2026-03-13T21:20:39.757414Z" }, "papermill": { "duration": 0.025601, "end_time": "2026-03-13T21:20:39.762566", "exception": false, "start_time": "2026-03-13T21:20:39.736965", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{2: ,\n", " 4: }" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jointStageFactors = joint1.StageFactorInterface.getDefinedStageFactors()\n", "jointStageFactors" ] }, { "cell_type": "markdown", "id": "d898ef1b", "metadata": { "papermill": { "duration": 0.015298, "end_time": "2026-03-13T21:20:39.788019", "exception": false, "start_time": "2026-03-13T21:20:39.772721", "status": "completed" }, "tags": [] }, "source": [ "Remove stage factors at stage 4." ] }, { "cell_type": "code", "execution_count": 25, "id": "7b063466", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:39.815972Z", "iopub.status.busy": "2026-03-13T21:20:39.815575Z", "iopub.status.idle": "2026-03-13T21:20:39.823850Z", "shell.execute_reply": "2026-03-13T21:20:39.820447Z" }, "papermill": { "duration": 0.026065, "end_time": "2026-03-13T21:20:39.825900", "exception": false, "start_time": "2026-03-13T21:20:39.799835", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jointStageFactors.pop(4)" ] }, { "cell_type": "markdown", "id": "7af01f16", "metadata": { "papermill": { "duration": 0.009013, "end_time": "2026-03-13T21:20:39.847229", "exception": false, "start_time": "2026-03-13T21:20:39.838216", "status": "completed" }, "tags": [] }, "source": [ "Set the dictionary back and check the defined stage factors. Now only stage 2 has stage factors defined." ] }, { "cell_type": "code", "execution_count": 26, "id": "38cd2bfb", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:39.871832Z", "iopub.status.busy": "2026-03-13T21:20:39.870902Z", "iopub.status.idle": "2026-03-13T21:20:39.933492Z", "shell.execute_reply": "2026-03-13T21:20:39.931981Z" }, "papermill": { "duration": 0.075759, "end_time": "2026-03-13T21:20:39.935004", "exception": false, "start_time": "2026-03-13T21:20:39.859245", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "{2: }" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joint1.StageFactorInterface.setDefinedStageFactors(jointStageFactors)\n", "joint1.StageFactorInterface.getDefinedStageFactors()" ] }, { "cell_type": "markdown", "id": "c9eaf85f", "metadata": { "papermill": { "duration": 0.011597, "end_time": "2026-03-13T21:20:39.961471", "exception": false, "start_time": "2026-03-13T21:20:39.949874", "status": "completed" }, "tags": [] }, "source": [ "## 6. Delete Joint" ] }, { "cell_type": "markdown", "id": "5bc2abf2", "metadata": { "papermill": { "duration": 0.010284, "end_time": "2026-03-13T21:20:39.985795", "exception": false, "start_time": "2026-03-13T21:20:39.975511", "status": "completed" }, "tags": [] }, "source": [ "Delete joint2." ] }, { "cell_type": "code", "execution_count": 27, "id": "60c835b7", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:40.013631Z", "iopub.status.busy": "2026-03-13T21:20:40.013164Z", "iopub.status.idle": "2026-03-13T21:20:40.060253Z", "shell.execute_reply": "2026-03-13T21:20:40.054632Z" }, "papermill": { "duration": 0.063715, "end_time": "2026-03-13T21:20:40.064324", "exception": false, "start_time": "2026-03-13T21:20:40.000609", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "model.deleteJointProperty(joint2Name)" ] }, { "cell_type": "markdown", "id": "26128543", "metadata": { "papermill": { "duration": 0.015252, "end_time": "2026-03-13T21:20:40.097548", "exception": false, "start_time": "2026-03-13T21:20:40.082296", "status": "completed" }, "tags": [] }, "source": [ "Check if joint2 still exist in the joint list." ] }, { "cell_type": "code", "execution_count": 28, "id": "67d78560", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:40.129431Z", "iopub.status.busy": "2026-03-13T21:20:40.128468Z", "iopub.status.idle": "2026-03-13T21:20:40.140217Z", "shell.execute_reply": "2026-03-13T21:20:40.137975Z" }, "papermill": { "duration": 0.030885, "end_time": "2026-03-13T21:20:40.142157", "exception": false, "start_time": "2026-03-13T21:20:40.111272", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Joint 1\n" ] } ], "source": [ "allJoints = model.getAllJointProperties()\n", "for joint in allJoints:\n", " print(joint.getJointName())" ] }, { "cell_type": "markdown", "id": "3852fe39", "metadata": { "papermill": { "duration": 0.009947, "end_time": "2026-03-13T21:20:40.164441", "exception": false, "start_time": "2026-03-13T21:20:40.154494", "status": "completed" }, "tags": [] }, "source": [ "Save and close the model." ] }, { "cell_type": "code", "execution_count": 29, "id": "0cf5fc5d", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:40.191661Z", "iopub.status.busy": "2026-03-13T21:20:40.191024Z", "iopub.status.idle": "2026-03-13T21:20:43.777742Z", "shell.execute_reply": "2026-03-13T21:20:43.776127Z" }, "papermill": { "duration": 3.600769, "end_time": "2026-03-13T21:20:43.779113", "exception": false, "start_time": "2026-03-13T21:20:40.178344", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "model.close(True)" ] }, { "cell_type": "markdown", "id": "a6229b5e", "metadata": { "papermill": { "duration": 0.013597, "end_time": "2026-03-13T21:20:43.806821", "exception": false, "start_time": "2026-03-13T21:20:43.793224", "status": "completed" }, "tags": [] }, "source": [ "Close the program." ] }, { "cell_type": "code", "execution_count": 30, "id": "0d2d180a", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:43.835037Z", "iopub.status.busy": "2026-03-13T21:20:43.834563Z", "iopub.status.idle": "2026-03-13T21:20:48.384890Z", "shell.execute_reply": "2026-03-13T21:20:48.381287Z" }, "papermill": { "duration": 4.569055, "end_time": "2026-03-13T21:20:48.388226", "exception": false, "start_time": "2026-03-13T21:20:43.819171", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "modeler.closeProgram()" ] }, { "cell_type": "markdown", "id": "3d2ee349", "metadata": { "papermill": { "duration": 0.016749, "end_time": "2026-03-13T21:20:48.421927", "exception": false, "start_time": "2026-03-13T21:20:48.405178", "status": "completed" }, "tags": [] }, "source": [ "## Full Script" ] }, { "cell_type": "code", "execution_count": 31, "id": "65499522", "metadata": { "execution": { "iopub.execute_input": "2026-03-13T21:20:48.457238Z", "iopub.status.busy": "2026-03-13T21:20:48.456768Z", "iopub.status.idle": "2026-03-13T21:21:49.969557Z", "shell.execute_reply": "2026-03-13T21:21:49.967469Z" }, "papermill": { "duration": 61.532519, "end_time": "2026-03-13T21:21:49.971591", "exception": false, "start_time": "2026-03-13T21:20:48.439072", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2026-03-13 17:20:48,468 - Rocscience.RS3 - INFO - Attempting to start the application at C:\\Program Files\\Rocscience\\RS3\\RS3 and binding server to port 60303...\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Joint 1\n" ] } ], "source": [ "# Joint 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", "import os\n", "import shutil\n", "# Get the current folder directory.\n", "current_dir = os.path.abspath(\"\")\n", "# Specify a port number that is not in use and start the RS3 program.\n", "port = 60303\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\"{os.path.dirname(current_dir)}\\example_models\\blankModel.rs3v3\"\n", "copiedModelPath = rf\"{os.path.dirname(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. Create and Get Joint\n", "# Get the first joint in the list.\n", "joint1 = model.getAllJointProperties()[0]\n", "# Create a new joint and get the joint by name.\n", "joint2Name = \"Joint 2\"\n", "model.createNewJointProperty(joint2Name)\n", "joint2 = model.getJointPropertyByName(joint2Name)\n", "\n", "# 2. Set Joint Properties\n", "joint1.setConstitutiveModel(JointConstitutiveModelTypes.MOHR_COULOMB)\n", "joint1.setInitialJointDeformation(False)\n", "joint1.setApplyAdditionalPressureInsideJoint(True)\n", "joint1.setAdditionalPressureType(AdditionalPressureType.PRESSURE)\n", "joint1.setAdditionalPressureInsideJoint(150)\n", "joint1.MohrCoulomb.setDefineResidualStrength(True)\n", "joint1.MohrCoulomb.setProperties(TensileStrength=10, ResidualTensileStrength=5)\n", "joint1Properties = joint1.MohrCoulomb.getProperties()\n", "\n", "# 3. Copy Joint Properties\n", "joint2.setConstitutiveModel(JointConstitutiveModelTypes.MOHR_COULOMB)\n", "joint2.MohrCoulomb.setProperties(**joint1Properties)\n", "\n", "# 4. Set Stage Factors\n", "# Turn on the stage factors of joints.\n", "joint1.setApplyStageFactors(True)\n", "joint1.MohrCoulomb.setAllowSlipStartFromStage(3)\n", "\n", "# Joints take both constitutive model properties and hydraulic properties. \n", "# When you create the stage factors for joints, the overall controls are under \n", "# the Joint class.\n", "\n", "# Now, create a stage factor for stage 2 and get the stage factors of hydraulic \n", "# properties of the joint at stage 2.\n", "joint1.StageFactorInterface.createStageFactor(2)\n", "newJointStageFactor_s2 = joint1.StageFactorInterface.getDefinedStageFactors()[2]\n", "# Set stage factor of additional pressure inside joint.\n", "newJointStageFactor_s2.setAdditionalPressureInsideJointFactor(1.5)\n", "# Get stage factors of all stages and check stage factor of additional pressure inside joint at stage 2.\n", "stageFactors_s2 = joint1.StageFactorInterface.getStageFactor(2)\n", "# Similarly, change the stage factor of dilation angle under Mohr Coulomb joint module.\n", "newMohrCoulombJointStageFactor_s2 = joint1.MohrCoulomb.StageFactorInterface.getDefinedStageFactors()[2]\n", "newMohrCoulombJointStageFactor_s2.setDilationAngleFactor(1.3)\n", "# Create another stage factor for stage 4 and set the stage factor of additional pressure inside joint.\n", "joint1.StageFactorInterface.createStageFactor(4)\n", "newJointStageFactor_s4 = joint1.StageFactorInterface.getDefinedStageFactors()[4]\n", "newJointStageFactor_s4.setAdditionalPressureInsideJointFactor(2.1)\n", "\n", "# 5. Delete Joint Stage Factor\n", "# Get the dictionary of all stage factors.\n", "jointStageFactors = joint1.StageFactorInterface.getDefinedStageFactors()\n", "# Remove stage factors at stage 4.\n", "jointStageFactors.pop(4)\n", "# Set the dictionary back and check the defined stage factors. Now only stage 2 has stage factors defined.\n", "joint1.StageFactorInterface.setDefinedStageFactors(jointStageFactors)\n", "\n", "# 6. Delete Joint\n", "# Delete joint2.\n", "model.deleteJointProperty(joint2Name)\n", "# Check if joint2 still exist in the joint list.\n", "allJoints = model.getAllJointProperties()\n", "for joint in allJoints:\n", " print(joint.getJointName())\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": 118.633976, "end_time": "2026-03-13T21:21:52.254586", "environment_variables": {}, "exception": null, "input_path": "C:\\Users\\GraceHu\\source\\repos\\RS3Scripting_Compute\\docs\\example_code\\supports\\joint_example.ipynb", "output_path": "C:\\Users\\GraceHu\\source\\repos\\RS3Scripting_Compute\\docs\\example_code\\supports\\joint_example.ipynb", "parameters": {}, "start_time": "2026-03-13T21:19:53.620610", "version": "2.6.0" } }, "nbformat": 4, "nbformat_minor": 5 }