{ "cells": [ { "cell_type": "markdown", "id": "aececd27", "metadata": { "papermill": { "duration": 0.004588, "end_time": "2026-03-19T15:23:06.899564", "exception": false, "start_time": "2026-03-19T15:23:06.894976", "status": "completed" }, "tags": [] }, "source": [ "(Get Model Units Example)=\n", "# Unit Script Examples" ] }, { "cell_type": "markdown", "id": "8f03602b", "metadata": { "papermill": { "duration": 0.001075, "end_time": "2026-03-19T15:23:06.901988", "exception": false, "start_time": "2026-03-19T15:23:06.900913", "status": "completed" }, "tags": [] }, "source": [ "Download the [SupportResults.fez](https://github.com/Rocscience/rs2-scripting/blob/main/docs/example_code/example_models/SupportResults.fez) and [SupportStructuralResults.fez](https://github.com/Rocscience/rs2-scripting/blob/main/docs/example_code/example_models/SupportStructuralResults.fez) for this example." ] }, { "cell_type": "code", "execution_count": 1, "id": "efd68734", "metadata": { "execution": { "iopub.execute_input": "2026-03-19T15:23:06.905668Z", "iopub.status.busy": "2026-03-19T15:23:06.905393Z", "iopub.status.idle": "2026-03-19T15:23:22.365952Z", "shell.execute_reply": "2026-03-19T15:23:22.363640Z" }, "papermill": { "duration": 15.464451, "end_time": "2026-03-19T15:23:22.367550", "exception": false, "start_time": "2026-03-19T15:23:06.903099", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Interpreter Model Units\n", "\n", "Solid Units :\n", "[('Very Small Area', 'in2'),\n", " ('Very Small Length ', 'in'),\n", " ('Small Length ', 'in'),\n", " ('Length ', 'ft'),\n", " ('One Over Length ', '1/ft'),\n", " ('Volume ', 'ft3'),\n", " ('Area ', 'ft2'),\n", " ('Force ', 'lbs'),\n", " ('Weight ', 'lbs'),\n", " ('Pressure ', 'psf'),\n", " ('Shear Strength ', 'psf'),\n", " ('Bond Strength ', 'lbs/ft'),\n", " ('Joint Stiffness ', 'psf/ft'),\n", " ('Unit Weight ', 'lbs/ft3'),\n", " ('Moment ', 'lbsft'),\n", " ('Hoop Moment ', 'lbsft/ft'),\n", " ('Time ', 's'),\n", " ('Stiffness ', 'lbs/ft'),\n", " ('Velocity ', 'ft/s'),\n", " ('Acceleration ', 'ft/s2'),\n", " ('Sigma ', 'psf'),\n", " ('Stress ', 'psf'),\n", " ('Mass ', 'lbs')]\n", "\n", "Hydro Units :\n", "[('Pore Pressure ', 'psf'),\n", " ('Pressure Head ', 'ft'),\n", " ('Flow Rate ', 'ft3/s'),\n", " ('Discharge Velocity ', 'ft/s'),\n", " ('Permeability ', 'ft/s'),\n", " ('Water Content ', 'ft3/ft3'),\n", " ('MV ', 'ft3/ft3/psf')]\n", "\n", "Thermal Units :\n", "[('Heat', 'J'),\n", " ('Specific Heat Capacity', 'J/lbs/C'),\n", " ('Temperature', 'C'),\n", " ('Latent Heat', 'J/ft3'),\n", " ('Conductivity', 'W/ft/C'),\n", " ('Volumetric Heat Capacity', 'J/ft3/C'),\n", " ('Total Thermal Flux', 'W/ft'),\n", " ('Unit Heat Flux', 'W/ft2'),\n", " ('Heat Transfer', 'J/s/ft2/C')]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Modeler Units\n", "\n", "Solid Units :\n", "[('Very Small Area', 'mm2'),\n", " ('Very Small Length ', 'mm'),\n", " ('Small Length ', 'cm'),\n", " ('Length ', 'm'),\n", " ('One Over Length ', '1/m'),\n", " ('Volume ', 'm3'),\n", " ('Area ', 'm2'),\n", " ('Force ', 'MN'),\n", " ('Weight ', 'MN'),\n", " ('Pressure ', 'MPa'),\n", " ('Shear Strength ', 'MPa'),\n", " ('Bond Strength ', 'MN/m'),\n", " ('Joint Stiffness ', 'MPa/m'),\n", " ('Unit Weight ', 'MN/m3'),\n", " ('Moment ', 'MNm'),\n", " ('Hoop Moment ', 'MNm/m'),\n", " ('Time ', 's'),\n", " ('Stiffness ', 'MN/m'),\n", " ('Velocity ', 'm/s'),\n", " ('Acceleration ', 'm/s2'),\n", " ('Sigma ', 'MPa'),\n", " ('Stress ', 'MPa'),\n", " ('Mass ', 'kt')]\n", "\n", "Hydro Units :\n", "[('Pore Pressure ', 'MPa'),\n", " ('Pressure Head ', 'm'),\n", " ('Flow Rate ', 'm3/s'),\n", " ('Discharge Velocity ', 'm/s'),\n", " ('Permeability ', 'm/s'),\n", " ('Water Content ', 'm3/m3'),\n", " ('MV ', 'm3/m3/MPa')]\n", "\n", "Thermal Units :\n", "[('Heat', 'J'),\n", " ('Specific Heat Capacity', 'J/kt/C'),\n", " ('Temperature', 'C'),\n", " ('Latent Heat', 'J/m3'),\n", " ('Conductivity', 'W/m/C'),\n", " ('Volumetric Heat Capacity', 'J/m3/C'),\n", " ('Total Thermal Flux', 'W/m'),\n", " ('Unit Heat Flux', 'W/m2'),\n", " ('Heat Transfer', 'J/s/m2/C')]\n" ] } ], "source": [ "from rs2.modeler.RS2Modeler import RS2Modeler\n", "from rs2.interpreter.RS2Interpreter import RS2Interpreter\n", "import os\n", "from pprint import pprint\n", "\n", "current_dir = os.path.dirname(os.path.abspath(\"\"))\n", "\n", "RS2Interpreter.startApplication(port=60079)\n", "interpreter = RS2Interpreter(port=60079)\n", "interpreterModel = interpreter.openFile(rf\"{current_dir}\\example_models\\SupportResults.fez\")\n", "interpreterModelUnits = interpreterModel.getUnits()\n", "\n", "print(\"\\nInterpreter Model Units\")\n", "print(\"\\nSolid Units :\")\n", "pprint(interpreterModelUnits.solid_units)\n", "print(\"\\nHydro Units :\")\n", "pprint(interpreterModelUnits.hydro_units)\n", "print(\"\\nThermal Units :\")\n", "pprint(interpreterModelUnits.thermal_units)\n", "\n", "RS2Modeler.startApplication(port=60080)\n", "modeler = RS2Modeler(port=60080)\n", "model = modeler.openFile(rf\"{current_dir}\\example_models\\SupportStructuralResults.fez\")\n", "modelerUnits = model.getUnits()\n", "\n", "print(\"\\nModeler Units\")\n", "print(\"\\nSolid Units :\")\n", "pprint(modelerUnits.solid_units)\n", "print(\"\\nHydro Units :\")\n", "pprint(modelerUnits.hydro_units)\n", "print(\"\\nThermal Units :\")\n", "pprint(modelerUnits.thermal_units)\n", "\n", "model.ResetProperties()\n", "\n", "model.close()\n", "interpreterModel.close()\n", "\n", "modeler.closeProgram()\n", "interpreter.closeProgram()" ] } ], "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": 20.245234, "end_time": "2026-03-19T15:23:25.847471", "environment_variables": {}, "exception": null, "input_path": "C:\\Users\\GraceHu\\source\\repos\\RS2_Python_Client_Library\\docs\\example_code\\model\\unit_script_examples.ipynb", "output_path": "C:\\Users\\GraceHu\\source\\repos\\RS2_Python_Client_Library\\docs\\example_code\\model\\unit_script_examples.ipynb", "parameters": {}, "start_time": "2026-03-19T15:23:05.602237", "version": "2.6.0" } }, "nbformat": 4, "nbformat_minor": 5 }