{ "cells": [ { "cell_type": "markdown", "id": "aececd27", "metadata": { "papermill": { "duration": 0.002074, "end_time": "2026-03-19T15:19:57.674512", "exception": false, "start_time": "2026-03-19T15:19:57.672438", "status": "completed" }, "tags": [] }, "source": [ "(Import Export Material Properties Example)=\n", "# Import Export Properties Script Examples" ] }, { "cell_type": "markdown", "id": "8f03602b", "metadata": { "papermill": { "duration": 0.000951, "end_time": "2026-03-19T15:19:57.676872", "exception": false, "start_time": "2026-03-19T15:19:57.675921", "status": "completed" }, "tags": [] }, "source": [ "Download the [ExampleModel.fez](https://github.com/Rocscience/rs2-scripting/blob/main/docs/example_code/example_models/ExampleModel.fez) and [EmptyExampleModel_start.fez](https://github.com/Rocscience/rs2-scripting/blob/main/docs/example_code/example_models/EmptyExampleModel_start.fez) for this example." ] }, { "cell_type": "code", "execution_count": 1, "id": "efd68734", "metadata": { "execution": { "iopub.execute_input": "2026-03-19T15:19:57.681792Z", "iopub.status.busy": "2026-03-19T15:19:57.681546Z", "iopub.status.idle": "2026-03-19T15:20:52.273838Z", "shell.execute_reply": "2026-03-19T15:20:52.272734Z" }, "papermill": { "duration": 54.596554, "end_time": "2026-03-19T15:20:52.275135", "exception": false, "start_time": "2026-03-19T15:19:57.678581", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Model 2 Till Initial Conditions\n", "{'InitialElementLoading': , 'AccountForMoistureContentInUnitWeight': False, 'DryUnitWeight': 0.016, 'MoistUnitWeight': 0.018, 'SaturatedUnitWeight': 0.02, 'UnitWeight': 16.0, 'PorosityValue': 0.5, 'InitialWaterCondition': , 'InitialPoreWaterPressure': 0.001, 'InitialRu': 1.0, 'InitialHuType': , 'InitialHu': 1.0, 'InitialTemperatureCondition': , 'InitialTemperature': 0.0}\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Model 2 Till Stiffness\n", "{'UseUnloadingCondition': False, 'UnloadingCondition': , 'ElasticParameters': , 'ShearModulus': 8333.33, 'PoissonsRatio': 0.3, 'YoungsModulus': 20000.0, 'UseResidualYoungsModulus': False, 'ResidualYoungsModulus': 20000.0, 'UnloadingPoissonsRatio': 0.3, 'UnloadingYoungsModulus': 20.0, 'UseUnloadingResidualYoungsModulus': False, 'UnloadingResidualYoungsModulus': 20.0}\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Model 2 Till Strength\n", "{'MaterialType': , 'PeakTensileStrength': 0.0, 'PeakFrictionAngle': 35.0, 'PeakCohesion': 10.5, 'ResidualTensileStrength': 0.0, 'ResidualFrictionAngle': 35.0, 'ResidualCohesion': 10.5, 'DilationAngle': 0.0, 'ApplySSRShearStrengthReduction': True, 'PeakFrictionAngleBlockModel': False, 'PeakCohesionBlockModel': False, 'UsePeakValueForResAngleBlockModel': False, 'UsePeakValueForResCohesionBlockModel': False}\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Model 2 Till Hydraulic\n", "{'StaticWaterMode': , 'StaticPoreWaterPressure': 1.0, 'RuValue': 0.0, 'HuType': , 'HuValue': 1.0}\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Model 2 Till Thermal Conductivity\n", "{'UnfrozenConductivity': 0.5, 'FrozenConductivity': 5.0, 'FrozenTemperature': 0.0}\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Model 2 Till Thermal Heat Capactiy\n", "{'IncludeLatentHeat': False, 'UnfrozenVolumetricHeatCapacity': 0.5, 'FrozenVolumetricHeatCapacity': 5.0, 'FrozenTemperature': 0.0}\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Model 2 Bolt Properties\n", "{'TensileCapacity': 0.1, 'ResidualTensileCapacity': 0.0, 'TributaryArea': 232.5, 'BoltModulusE': 200000.0, 'OutofPlaneSpacing': 1.0, 'MaterialDependent': False, 'BondStrengthCoefficient': 1.0, 'BondShearStiffnessCoefficient': 1.0, 'BondShearStiffness': 100.0, 'BondStrength': 0.17, 'ResidualBondStrength': 0.17, 'BoltModel': , 'JointShear': True, 'PreTensioningForce': 0.0, 'ConstantPretensioningForceInInstallStage': True, 'FacePlates': True, 'AddPullOutForce': False, 'PullOutForce': 0.0}\n", "\n", "Model 2 Liner Properties\n", "{'ConcreteUnitWeight': 0.024, 'IncludeWeightInStressAnalysis': False, 'InitialTemperature': 0.0, 'Reinforcement': True, 'Spacing': 0.6, 'SectionDepth': 0.162, 'Area': 0.00474, 'MomentOfInertia': 2.22e-05, 'YoungsModulus': 200000.0, 'CompressiveStrength': 400.0, 'TensileStrength': 400.0, 'Weight': 37.1, 'Concrete': True, 'Thickness': 0.2, 'ConcreteYoungsModulus': 30000.0, 'PoissonRatio': 0.15, 'ConcreteCompressiveStrength': 40.0, 'ConcreteTensileStrength': 3.0, 'MaterialType': , 'SlidingGap': False, 'StrainAtLocking': 5.0, 'BeamElementFormulation': , 'AxialStrainExpansion': 0.0, 'ActivateThermal': False, 'StaticTemperatureMode': , 'StaticTemperature': 0.0, 'Conductivity': 1.0, 'SpecificHeatCapacity': 1.0, 'ThermalExpansion': False, 'ExpansionCoefficient': 1.0, 'StageConcreteProperties': True}\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Model 2 Joint Properties\n", "{'InterfaceCoefficient': 0.7, 'DefineStiffness': , 'NormalStiffness': 100000.0, 'ShearStiffness': 10000.0, 'StiffnessCoefficient': 1.0, 'ApplyPorePressure': True, 'ApplyAdditionalPressureInsideJoint': True, 'AdditionalPressureType': , 'AdditionalPressureInsideJoint': 0.0, 'ApplyPressureToLinerSideOnly': True, 'ApplyStageFactors': True}\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Model 2 Pile Interface Properties\n", "{'ShearStiffness': 10000.0, 'NormalStiffness': 100000.0, 'FrictionAngle': 30.0, 'ResidualFrictionAngle': 30.0, 'Cohesion': 0.0, 'ResidualCohesion': 0.0, 'UseShearResistanceCutoff': False, 'ShearResistanceCutoff': 0.01, 'Perimeter': 1.0, 'UseBaseResistance': True, 'BaseNormalStiffness': 100000.0, 'BaseForceResistance': 0.1}\n", "\n", "Model 2 Pile Force Displacement Properties\n", "{'Apply': , 'ApplyOn': , 'X': 0.0, 'Y': 0.0}\n" ] } ], "source": [ "from rs2.modeler.properties.PropertyEnums import *\n", "from rs2.modeler.RS2Modeler import RS2Modeler\n", "from rs2.modeler.properties import *\n", "import os\n", "import csv\n", "\n", "current_dir = os.path.dirname(os.path.abspath(\"\"))\n", "RS2Modeler.startApplication(port=60095)\n", "modeler = RS2Modeler(port=60095)\n", "model1FilePath = rf\"{current_dir}\\example_models\\ExampleModel.fez\"\n", "model2FilePath = rf\"{current_dir}\\example_models\\EmptyExampleModel_start.fez\"\n", "model2FileSavePath = rf\"{current_dir}\\example_models\\EmptyExampleModel_final.fez\"\n", "\n", "model1 = modeler.openFile(model1FilePath)\n", "model2 = modeler.openFile(model2FilePath)\n", "\n", "model1Till = model1.getMaterialPropertyByName(\"Till\")\n", "model2Till = model2.getMaterialPropertyByName(\"till\")\n", "\n", "# Not all functions are accessible through the setProperties and getProperties methods. \n", "# Consult setProperties and getProperties method definition in documentation to determine properties available.\n", "\n", "# Initial Conditions\n", "model1_initial_conditions = model1Till.InitialConditions.getProperties()\n", "model2Till.InitialConditions.setProperties(**model1_initial_conditions)\n", "\n", "print(\"Model 2 Till Initial Conditions\")\n", "print(model2Till.InitialConditions.getProperties())\n", "\n", "# Stiffness\n", "elasticType = model1Till.Stiffness.getElasticType()\n", "model2Till.Stiffness.setElasticType(elasticType)\n", "\n", "# More Stiffness Elasticity Types can be added here\n", "if elasticType == MaterialElasticityTypes.ISOTROPIC:\n", " model1_stiffness = model1Till.Stiffness.Isotropic.getProperties()\n", " model2Till.Stiffness.Isotropic.setProperties(**model1_stiffness)\n", "elif elasticType == MaterialElasticityTypes.TRANSVERSELY_ISOTROPIC:\n", " model1_stiffness = model1Till.Stiffness.TransverselyIsotropic.getProperties()\n", " model2Till.Stiffness.TransverselyIsotropic.setProperties(**model1_stiffness)\n", "elif elasticType == MaterialElasticityTypes.ORTHOTROPIC:\n", " model1_stiffness = model1Till.Stiffness.Orthotropic.getProperties()\n", " model2Till.Stiffness.Orthotropic.setProperties(**model1_stiffness)\n", "elif elasticType == MaterialElasticityTypes.DUNCAN_CHANG_HYPERBOLIC:\n", " model1_stiffness = model1Till.Stiffness.NonLinearHyperbolic.getProperties()\n", " model2Till.Stiffness.NonLinearHyperbolic.setProperties(**model1_stiffness)\n", "elif elasticType == MaterialElasticityTypes.NON_LINEAR_ISOTROPIC:\n", " model1_stiffness = model1Till.Stiffness.NonLinearIsotropic.getProperties()\n", " model2Till.Stiffness.NonLinearIsotropic.setProperties(**model1_stiffness)\n", "elif elasticType == MaterialElasticityTypes.CUSTOM:\n", " model1_stiffness = model1Till.Stiffness.Custom.getProperties()\n", " model2Till.Stiffness.Custom.setProperties(**model1_stiffness)\n", "\n", "\n", "print(\"\\nModel 2 Till Stiffness\")\n", "print(model2Till.Stiffness.Isotropic.getProperties())\n", "\n", "# Strength\n", "failureCriterion = model1Till.Strength.getFailureCriterion()\n", "model2Till.Strength.setFailureCriterion(failureCriterion)\n", "\n", "# More Strength Failure Criteria Types can be added here\n", "if failureCriterion == StrengthCriteriaTypes.MOHR_COULOMB:\n", " model1_strength = model1Till.Strength.MohrCoulombStrength.getProperties()\n", " model2Till.Strength.MohrCoulombStrength.setProperties(**model1_strength)\n", "elif failureCriterion == StrengthCriteriaTypes.HOEK_BROWN:\n", " model1_strength = model1Till.Strength.HoekBrown.getProperties()\n", " model2Till.Strength.HoekBrown.setProperties(**model1_strength)\n", "\n", "print(\"\\nModel 2 Till Strength\")\n", "print(model2Till.Strength.MohrCoulombStrength.getProperties())\n", "\n", "# Hydraulic\n", "model1_hydraulic = model1Till.Hydraulic.StaticGroundwater.getProperties()\n", "model2Till.Hydraulic.StaticGroundwater.setProperties(**model1_hydraulic)\n", "\n", "print(\"\\nModel 2 Till Hydraulic\")\n", "print(model2Till.Hydraulic.StaticGroundwater.getProperties())\n", "\n", "# Thermal\n", "model1_thermal_conductivity = model1Till.Thermal.Conductivity.ConstantConductivity.getProperties()\n", "model2Till.Thermal.Conductivity.ConstantConductivity.setProperties(**model1_thermal_conductivity)\n", "\n", "print(\"\\nModel 2 Till Thermal Conductivity\")\n", "print(model2Till.Thermal.Conductivity.ConstantConductivity.getProperties())\n", "\n", "model1_thermal_heat_capacity = model1Till.Thermal.HeatCapacity.ConstantHeatCapacity.getProperties()\n", "model2Till.Thermal.HeatCapacity.ConstantHeatCapacity.setProperties(**model1_thermal_heat_capacity)\n", "\n", "print(\"\\nModel 2 Till Thermal Heat Capactiy\")\n", "print(model2Till.Thermal.HeatCapacity.ConstantHeatCapacity.getProperties())\n", "\n", "# Bolt\n", "model1_bolt = model1.getAllBoltProperties()[0]\n", "model2_bolt = model2.getAllBoltProperties()[0]\n", "\n", "model1_bolt_properties = model1_bolt.Swellex.getProperties()\n", "model2_bolt.setBoltType(BoltTypes.SWELLEX)\n", "model2_bolt.Swellex.setProperties(**model1_bolt_properties)\n", "\n", "print(\"\\nModel 2 Bolt Properties\")\n", "print(model2_bolt.Swellex.getProperties())\n", "\n", "# Liner\n", "model1_liner = model1.getAllLinerProperties()[0]\n", "model2_liner = model2.getAllLinerProperties()[0]\n", "\n", "model1_liner_properties = model1_liner.ReinforcedConcrete.getProperties()\n", "model2_liner.setLinerType(LinerTypes.REINFORCED_CONCRETE)\n", "model2_liner.ReinforcedConcrete.setProperties(**model1_liner_properties)\n", "\n", "print(\"\\nModel 2 Liner Properties\")\n", "print(model2_liner.ReinforcedConcrete.getProperties())\n", "\n", "# Joint\n", "model1_joint = model1.getAllJointProperties()[0]\n", "model2_joint = model2.getAllJointProperties()[0]\n", "\n", "model1_joint_properties = model1_joint.MaterialDependent.getProperties()\n", "model2_joint.setSlipCriterion(JointTypes.MATERIAL_DEPENDENT)\n", "model2_joint.MaterialDependent.setProperties(**model1_joint_properties)\n", "\n", "print(\"\\nModel 2 Joint Properties\")\n", "print(model2_joint.MaterialDependent.getProperties())\n", "\n", "# Pile\n", "model1_pile = model1.getAllPileProperties()[0]\n", "model2_pile = model2.getAllPileProperties()[0]\n", "\n", "model1_pile_interface_properties = model1_pile.MohrCoulombPile.getProperties()\n", "model2_pile.MohrCoulombPile.setProperties(**model1_pile_interface_properties)\n", "\n", "model1_pile_force_displacement_properties = model1_pile.ForceDisplacement.getProperties()\n", "model2_pile.ForceDisplacement.setProperties(**model1_pile_force_displacement_properties)\n", "\n", "print(\"\\nModel 2 Pile Interface Properties\")\n", "print(model2_pile.MohrCoulombPile.getProperties())\n", "print(\"\\nModel 2 Pile Force Displacement Properties\")\n", "print(model2_pile.ForceDisplacement.getProperties())\n", "\n", "# Export data to a csv File\n", "combined_material_data = {\n", " \"initialConditions\": model1_initial_conditions,\n", " \"stiffness\": model1_stiffness,\n", " \"strength\": model1_strength,\n", " \"hydraulic\": model1_hydraulic,\n", " \"thermalConductivity\": model1_thermal_conductivity,\n", " \"thermalHeatCapacity\": model1_thermal_heat_capacity,\n", "}\n", "\n", "combined_support_data = {\n", " \"bolt\": model1_bolt_properties,\n", " \"liner\": model1_liner_properties,\n", " \"joint\": model1_joint_properties,\n", " \"pileInterfaceProperties\": model1_pile_interface_properties,\n", " \"pileForceDisplacementProperties\": model1_pile_force_displacement_properties,\n", "}\n", "\n", "flattened_material_data = {}\n", "for category, properties in combined_material_data.items():\n", " for key, value in properties.items():\n", " flattened_material_data[f\"{category}_{key}\"] = value\n", "\n", "with open(rf\"{current_dir}\\combined_material_properties.csv\", \"w\", newline=\"\") as file:\n", " writer = csv.writer(file)\n", " writer.writerow([\"Key\", \"Value\"])\n", " for key, value in flattened_material_data.items():\n", " writer.writerow([key, value])\n", "\n", "flattened_support_data = {}\n", "for category, properties in combined_support_data.items():\n", " for key, value in properties.items():\n", " flattened_support_data[f\"{category}_{key}\"] = value\n", "\n", "with open(rf\"{current_dir}\\combined_support_properties.csv\", \"w\", newline=\"\") as file:\n", " writer = csv.writer(file)\n", " writer.writerow([\"Key\", \"Value\"])\n", " for key, value in flattened_support_data.items():\n", " writer.writerow([key, value])\n", "\n", "# Import data from csv file to a dictionary\n", "imported_material_data = {}\n", "with open(rf\"{current_dir}\\combined_material_properties.csv\", \"r\") as file:\n", " reader = csv.reader(file)\n", " next(reader)\n", " for row in reader:\n", " full_key, value = row\n", " category, key = full_key.split(\"_\", 1)\n", "\n", " if category not in imported_material_data:\n", " imported_material_data[category] = {}\n", "\n", " imported_material_data[category][key] = value\n", "\n", "imported_support_data = {}\n", "with open(rf\"{current_dir}\\combined_support_properties.csv\", \"r\") as file:\n", " reader = csv.reader(file)\n", " next(reader)\n", " for row in reader:\n", " full_key, value = row\n", " category, key = full_key.split(\"_\", 1)\n", "\n", " if category not in imported_support_data:\n", " imported_support_data[category] = {}\n", "\n", " imported_support_data[category][key] = value\n", "\n", "model2.saveAs(model2FileSavePath)\n", "modeler.closeProgram()" ] } ], "metadata": { "kernelspec": { "display_name": "myenv", "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": 59.039656, "end_time": "2026-03-19T15:20:54.990807", "environment_variables": {}, "exception": null, "input_path": "C:\\Users\\GraceHu\\source\\repos\\RS2_Python_Client_Library\\docs\\example_code\\model\\import_export_properties_script_examples.ipynb", "output_path": "C:\\Users\\GraceHu\\source\\repos\\RS2_Python_Client_Library\\docs\\example_code\\model\\import_export_properties_script_examples.ipynb", "parameters": {}, "start_time": "2026-03-19T15:19:55.951151", "version": "2.6.0" } }, "nbformat": 4, "nbformat_minor": 5 }