{ "cells": [ { "cell_type": "markdown", "id": "aececd27", "metadata": { "papermill": { "duration": 0.00474, "end_time": "2026-03-19T15:09:58.844653", "exception": false, "start_time": "2026-03-19T15:09:58.839913", "status": "completed" }, "tags": [] }, "source": [ "(material property stiffness example)=\n", "# Material Stiffness Properties Script Examples" ] }, { "cell_type": "markdown", "id": "8f03602b", "metadata": { "papermill": { "duration": 0.001385, "end_time": "2026-03-19T15:09:58.847982", "exception": false, "start_time": "2026-03-19T15:09:58.846597", "status": "completed" }, "tags": [] }, "source": [ "Download the [ExampleModel.fez](https://github.com/Rocscience/rs2-scripting/blob/main/docs/example_code/example_models/ExampleModel.fez) for this example." ] }, { "cell_type": "code", "execution_count": 1, "id": "efd68734", "metadata": { "execution": { "iopub.execute_input": "2026-03-19T15:09:58.852186Z", "iopub.status.busy": "2026-03-19T15:09:58.851908Z", "iopub.status.idle": "2026-03-19T15:10:11.350997Z", "shell.execute_reply": "2026-03-19T15:10:11.349124Z" }, "papermill": { "duration": 12.503103, "end_time": "2026-03-19T15:10:11.352186", "exception": false, "start_time": "2026-03-19T15:09:58.849083", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Loading Custom Table = [(1.0, 2.0, 0.3), (4.0, 5.0, 0.4)]\n", "Unloading Condition = UnloadingConditions.DEVIATORIC_STRESS\n", "Unloading Custom Table = [(1.0, 2.0, 0.3), (4.0, 5.0, 0.4)]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Isotropic Stage Factor Values\n", "Poisson Ratio Factor = 3.0, Res. Youngs Modulus Factor = 1.0, Shear Modulus Factor = 1.9\n", "\n", "NonLinear Hyperbolic Stage Factor Values\n", "Failure Ratio of RF = 1.0, Bulk Modulus ExpM = 2.0, Atmospheric Pressure = 3.3\n" ] } ], "source": [ "from rs2.modeler.RS2Modeler import RS2Modeler\n", "from rs2.modeler.properties.PropertyEnums import *\n", "import os\n", "\n", "current_dir = os.path.dirname(os.path.abspath(\"\")) \n", "RS2Modeler.startApplication(port=60074)\n", "modeler = RS2Modeler(port=60074)\n", "model = modeler.openFile(rf\"{current_dir}\\example_models\\ExampleModel.fez\")\n", "\n", "material = model.getAllMaterialProperties()[0]\n", "stiffness = material.Stiffness\n", "custom = stiffness.Custom\n", "\n", "custom.setUseConstantPoissonsRatio(False)\n", "custom.setCustomStiffnessLoadingTable(mode=CustomMode.CUSTOM_Q,\n", " table=[(1, 2, 0.3), (4, 5, 0.4)])\n", "\n", "custom.setUseUnloadingCondition(True)\n", "custom.setUnloadingCondition(UnloadingConditions.DEVIATORIC_STRESS)\n", "custom.setUnloadingUseConstantPoissonsRatio(False)\n", "custom.setCustomStiffnessUnloadingTable(mode=CustomMode.CUSTOM_Q,\n", " table=[(1, 2, 0.3), (4, 5, 0.4)])\n", "\n", "# Make sure to define Stiffness Loading and Unloading tables before setting Custom Model and Stiffness Elastic Type to Custom\n", "custom.setCustomMode(CustomMode.CUSTOM_Q)\n", "stiffness.setElasticType(MaterialElasticityTypes.CUSTOM)\n", "\n", "print(f\"Loading Custom Table = {custom.getCustomStiffnessLoadingTable()}\")\n", "print(f\"Unloading Condition = {custom.getUnloadingCondition()}\")\n", "print(f\"Unloading Custom Table = {custom.getCustomStiffnessUnloadingTable()}\")\n", "\n", "# Manipulation of Stiffness Stage Factor Properties for stage 2\n", "# Make sure to your Stiffness Elastic Type isn't Custom before manipulating any stiffness related factor values\n", "material.Stiffness.setElasticType(MaterialElasticityTypes.ISOTROPIC)\n", "material.StageFactors.setStageStrengthStiffnessStageFactors(True)\n", "\n", "definedStageFactors = material.StageFactors.getDefinedStageFactors()\n", "newStageFactor = material.StageFactors.createStageFactor(2)\n", "definedStageFactors[2] = newStageFactor\n", "material.StageFactors.setDefinedStageFactors(definedStageFactors)\n", "\n", "stiffnessStageFactor = material.Stiffness.Isotropic.stageFactorInterface.getDefinedStageFactors()[2]\n", "\n", "stiffnessStageFactor.setPoissonsRatioFactor(3)\n", "stiffnessStageFactor.setResidualYoungsModulusFactor(2.2)\n", "stiffnessStageFactor.setShearModulusFactor(1.9)\n", "\n", "print(\"\\nIsotropic Stage Factor Values\")\n", "print(f\"Poisson Ratio Factor = {stiffnessStageFactor.getPoissonsRatioFactor()}, Res. Youngs Modulus Factor = {stiffnessStageFactor.getYoungsModulusFactor()}, Shear Modulus Factor = {stiffnessStageFactor.getShearModulusFactor()}\")\n", "\n", "nonLinearHyperbolicFactors = material.Stiffness.NonLinearHyperbolic.stageFactorInterface.getDefinedStageFactors()[2]\n", "\n", "nonLinearHyperbolicFactors.setFailureRatioRfFactor(1)\n", "nonLinearHyperbolicFactors.setBulkModulusExpMFactor(2)\n", "nonLinearHyperbolicFactors.setAtmosphericPressureFactor(3.3)\n", "\n", "print(\"\\nNonLinear Hyperbolic Stage Factor Values\")\n", "print(f\"Failure Ratio of RF = {nonLinearHyperbolicFactors.getFailureRatioRfFactor()}, Bulk Modulus ExpM = {nonLinearHyperbolicFactors.getBulkModulusExpMFactor()}, Atmospheric Pressure = {nonLinearHyperbolicFactors.getAtmosphericPressureFactor()}\")\n", "\n", "model.close()\n", "\n", "modeler.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": 17.227848, "end_time": "2026-03-19T15:10:14.769827", "environment_variables": {}, "exception": null, "input_path": "C:\\Users\\GraceHu\\source\\repos\\RS2_Python_Client_Library\\docs\\example_code\\material\\material_stiffness_properties_script_examples.ipynb", "output_path": "C:\\Users\\GraceHu\\source\\repos\\RS2_Python_Client_Library\\docs\\example_code\\material\\material_stiffness_properties_script_examples.ipynb", "parameters": {}, "start_time": "2026-03-19T15:09:57.541979", "version": "2.6.0" } }, "nbformat": 4, "nbformat_minor": 5 }