Material Constitutive Models Script Examples#

Download the blankModel.rs3v3 for this example.

from rs3.RS3Modeler import RS3Modeler
from rs3.properties.PropertyEnums 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 = 60202
RS3Modeler.startApplication(port)
2026-03-13 16:22:44,664 - Rocscience.RS3 - INFO - Attempting to start the application at C:\Program Files\Rocscience\RS3\RS3 and binding server to port 60202...

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. Create and Get Material#

Get the first material in the list.

material1 = model.getAllMaterialProperties()[0]
material1.getMaterialName()
'Soil'
newMaterialName = "New Material"
model.createNewMaterialProperty(newMaterialName)
newMaterial = model.getMaterialPropertyByName(newMaterialName)
newMaterial.getMaterialName()
'New Material'

2. Set Constitutive Model#

2.1 Mohr Coulomb#

material1.ConstitutiveModel.setConstitutiveModel(ConstitutiveModelTypes.MOHR_COULOMB)
material1.ConstitutiveModel.getConstitutiveModel()
<ConstitutiveModelTypes.MOHR_COULOMB: 'MOHR_COULOMB'>
mohrCoulomb = material1.ConstitutiveModel.MohrCoulomb
mohrCoulomb.setMaterialType(MaterialType.PLASTIC)
mohrCoulomb.getMaterialType()
<MaterialType.PLASTIC: True>
mohrCoulomb.setElasticType(MaterialElasticityTypes.ORTHOTROPIC)
mohrCoulomb.getElasticType()
<MaterialElasticityTypes.ORTHOTROPIC: 'ORTHOTROPIC'>
mohrCoulomb.OrthotropicStiffness.setDirection1((1, 1, 0))
mohrCoulomb.OrthotropicStiffness.getDirection1()
(1.0, 1.0, 0.0)
mohrCoulomb.OrthotropicStiffness.setUseUnloadingCondition(True)
mohrCoulomb.OrthotropicStiffness.getUseUnloadingCondition()
True
mohrCoulomb.OrthotropicStiffness.getProperties()
{'ShearModulusG12': 8333.33,
 'ShearModulusG13': 8333.33,
 'ShearModulusG23': 8333.33,
 'YoungsModulusE1': 20000.0,
 'YoungsModulusE2': 20000.0,
 'YoungsModulusE3': 20000.0,
 'PoissonsRatioV12': 0.2,
 'PoissonsRatioV13': 0.2,
 'PoissonsRatioV23': 0.2,
 'UnloadingShearModulusG12': 8333.33,
 'UnloadingShearModulusG13': 8333.33,
 'UnloadingShearModulusG23': 8333.33,
 'UnloadingYoungsModulusE1': 20000.0,
 'UnloadingYoungsModulusE2': 20000.0,
 'UnloadingYoungsModulusE3': 20000.0,
 'UnloadingPoissonsRatioV12': 0.2,
 'UnloadingPoissonsRatioV13': 0.2,
 'UnloadingPoissonsRatioV23': 0.2}
mohrCoulomb.OrthotropicStiffness.setProperties(ShearModulusG12=45000, UnloadingShearModulusG12=4000)
mohrCoulomb.OrthotropicStiffness.getProperties()
{'ShearModulusG12': 45000.0,
 'ShearModulusG13': 8333.33,
 'ShearModulusG23': 8333.33,
 'YoungsModulusE1': 20000.0,
 'YoungsModulusE2': 20000.0,
 'YoungsModulusE3': 20000.0,
 'PoissonsRatioV12': 0.2,
 'PoissonsRatioV13': 0.2,
 'PoissonsRatioV23': 0.2,
 'UnloadingShearModulusG12': 4000.0,
 'UnloadingShearModulusG13': 8333.33,
 'UnloadingShearModulusG23': 8333.33,
 'UnloadingYoungsModulusE1': 20000.0,
 'UnloadingYoungsModulusE2': 20000.0,
 'UnloadingYoungsModulusE3': 20000.0,
 'UnloadingPoissonsRatioV12': 0.2,
 'UnloadingPoissonsRatioV13': 0.2,
 'UnloadingPoissonsRatioV23': 0.2}

2.2 Generalized Hoek Brown#

material1.ConstitutiveModel.setConstitutiveModel(ConstitutiveModelTypes.GENERALIZED_HOEK_BROWN)
material1.ConstitutiveModel.getConstitutiveModel()
<ConstitutiveModelTypes.GENERALIZED_HOEK_BROWN: 'GENERALIZED_HOEK_BROWN'>
generalizedHoekBrown = material1.ConstitutiveModel.GeneralizedHoekBrown
generalizedHoekBrown.setUsingGSIMIDCalc(True)
generalizedHoekBrown.setProperties(UCSOfIntactRock=150000, GSI=45)
generalizedHoekBrown.getProperties()
{'UCSOfIntactRock': 150000.0,
 'MbParameter': 1.402560337259652,
 'SParameter': 0.002218084904320257,
 'AParameter': 0.5080857390944207,
 'ResidualMbParameter': 0.0,
 'ResidualSParameter': 0.0,
 'ResidualAParameter': 0.0,
 'GSI': 45.0,
 'Mi': 10.0,
 'D': 0.0,
 'ResidualToPeak': False,
 'ResidualGSI': 50.0,
 'ResidualMi': 10.0,
 'ResidualD': 0.0,
 'DilationParameter': 0.0,
 'TensileCutoff': 0.0,
 'ApplySSRShearStrengthReduction': False}
generalizedHoekBrown.setUsingGSIMIDCalc(False)
generalizedHoekBrown.setProperties(MbParameter=0.8)
generalizedHoekBrown.getProperties()
{'UCSOfIntactRock': 150000.0,
 'MbParameter': 0.8,
 'SParameter': 0.002218084904320257,
 'AParameter': 0.5080857390944207,
 'ResidualMbParameter': 0.0,
 'ResidualSParameter': 0.0,
 'ResidualAParameter': 0.0,
 'GSI': 45.0,
 'Mi': 10.0,
 'D': 0.0,
 'ResidualToPeak': False,
 'ResidualGSI': 50.0,
 'ResidualMi': 10.0,
 'ResidualD': 0.0,
 'DilationParameter': 0.0,
 'TensileCutoff': 0.0,
 'ApplySSRShearStrengthReduction': False}
generalizedHoekBrown.setElasticType(MaterialElasticityTypes.LINEAR_ISOTROPIC)
generalizedHoekBrown.LinearIsotropicStiffness.setPoissonsRatio(0.34)
generalizedHoekBrown.LinearIsotropicStiffness.getPoissonsRatio()
0.34
generalizedHoekBrown.LinearIsotropicStiffness.GeneralizedHoekBrownEstimation.setEstimationMethod(GeneralizedHoekBrownEstimationMethodType.GENERALIZED_HOEK_DIEDERICHS)
generalizedHoekBrown.LinearIsotropicStiffness.GeneralizedHoekBrownEstimation.setUsingEI(False)
generalizedHoekBrown.LinearIsotropicStiffness.GeneralizedHoekBrownEstimation.setMR(350)
generalizedHoekBrown.LinearIsotropicStiffness.GeneralizedHoekBrownEstimation.getMR()
350.0

2.3 Generalized Anisotropic#

material1.ConstitutiveModel.setConstitutiveModel(ConstitutiveModelTypes.GENERALIZED_ANISOTROPIC)
material1.ConstitutiveModel.getConstitutiveModel()
<ConstitutiveModelTypes.GENERALIZED_ANISOTROPIC: 'GENERALIZED_ANISOTROPIC'>

Base material and function points are mandetory fields. They have to be set for model to run.

generalizedAnisotropicFunctionName = "Generalized Anisotropic Function"
model.createNewGeneralizedAnisotropicFunction(generalizedAnisotropicFunctionName)
generalizedAnisotropicFunction = model.getGeneralizedAnisotropicFunctionByName(generalizedAnisotropicFunctionName)

allMaterials = model.getAllMaterialProperties()
generalizedAnisotropicFunction.setBaseMaterial(allMaterials[3].getMaterialName())
generalizedAnisotropicFunction.setDipDipDirectionFunctionPoints([(13.4, 51.2, 1.2, 0.2, allMaterials[4].getMaterialName()), (12.1, 34.4, 0.8, 0.1, allMaterials[5].getMaterialName())])
generalizedAnisotropicFunction.getDipDipDirectionFunctionPoints()
[(13.4, 51.2, 1.2, 0.2, 'Material 5'), (12.1, 34.4, 0.8, 0.1, 'New Material')]

2.4 Jointed Mohr Coulomb#

material1.ConstitutiveModel.setConstitutiveModel(ConstitutiveModelTypes.JOINTED_MOHR_COULOMB)
material1.ConstitutiveModel.getConstitutiveModel()
<ConstitutiveModelTypes.JOINTED_MOHR_COULOMB: 'JOINTED_MOHR_COULOMB'>
jointedMohrCoulomb = material1.ConstitutiveModel.JointedMohrCoulomb
jointOptions = jointedMohrCoulomb.getJointOptions()
jointOptions.setNumberOfJoint(3)
jointOptions.getNumberOfJoint()
3
# Use the index of joints here. The second joint has index 1.
joint2 = jointOptions.getJoint(1)
joint2.setSlipCriterion(MaterialJointSlipCriterionType.HYPERBOLIC_SIMPLE)
joint2.getSlipCriterion()
<MaterialJointSlipCriterionType.HYPERBOLIC_SIMPLE: 'HYPERBOLIC_SIMPLE'>
joint2.SimpleHyperbolic.getProperties()
{'DilationAngle': 0.0,
 'Adhesion': 0.0,
 'FrictionAngle': 20.0,
 'ResidualAdhesion': 0.0,
 'ResidualFrictionAngle': 10.0}
joint2.SimpleHyperbolic.setProperties(DilationAngle=12.5, Adhesion=1.2)
joint2.SimpleHyperbolic.getProperties()
{'DilationAngle': 12.5,
 'Adhesion': 1.2,
 'FrictionAngle': 20.0,
 'ResidualAdhesion': 0.0,
 'ResidualFrictionAngle': 10.0}

2.5 Cam Clay#

material1.ConstitutiveModel.setConstitutiveModel(ConstitutiveModelTypes.CAM_CLAY)
material1.ConstitutiveModel.getConstitutiveModel()
<ConstitutiveModelTypes.CAM_CLAY: 'CAM_CLAY'>
material1.ConstitutiveModel.CamClay.getProperties()
{'ShearModulus': 8333.33,
 'PoissonsRatio': 0.0,
 'CriticalStateSlope': 1.3,
 'Lambda': 0.15,
 'Kappa': 0.025,
 'NParameter': 2.61,
 'Gamma': 0.0,
 'OverconsolidationRatio': 2.0,
 'PreconsolidationStress': 0.0}
material1.ConstitutiveModel.CamClay.setNParameter(1.5)
material1.ConstitutiveModel.CamClay.setShearModulus(6500)
material1.ConstitutiveModel.CamClay.getProperties()
{'ShearModulus': 6500.0,
 'PoissonsRatio': 0.0,
 'CriticalStateSlope': 1.3,
 'Lambda': 0.15,
 'Kappa': 0.025,
 'NParameter': 1.5,
 'Gamma': 0.0,
 'OverconsolidationRatio': 2.0,
 'PreconsolidationStress': 0.0}

Save and close the model.

model.close(True)

Close the program.

modeler.closeProgram()

Full Script#

# Material Constitutive Models 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 *
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 = 60202
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. Create and Get Material
# Get the first material in the list.
material1 = model.getAllMaterialProperties()[0]
material1.getMaterialName()
newMaterialName = "New Material"
model.createNewMaterialProperty(newMaterialName)
newMaterial = model.getMaterialPropertyByName(newMaterialName)

# 2. Set Constitutive Model
# 2.1 Mohr Coulomb
material1.ConstitutiveModel.setConstitutiveModel(ConstitutiveModelTypes.MOHR_COULOMB)
mohrCoulomb = material1.ConstitutiveModel.MohrCoulomb
mohrCoulomb.setMaterialType(MaterialType.PLASTIC)
mohrCoulomb.setElasticType(MaterialElasticityTypes.ORTHOTROPIC)
mohrCoulomb.OrthotropicStiffness.setDirection1((1, 1, 0))
mohrCoulomb.OrthotropicStiffness.setUseUnloadingCondition(True)
mohrCoulomb.OrthotropicStiffness.setProperties(ShearModulusG12=45000, UnloadingShearModulusG12=4000)

# 2.2 Generalized Hoek Brown
material1.ConstitutiveModel.setConstitutiveModel(ConstitutiveModelTypes.GENERALIZED_HOEK_BROWN)
generalizedHoekBrown = material1.ConstitutiveModel.GeneralizedHoekBrown
generalizedHoekBrown.setUsingGSIMIDCalc(True)
generalizedHoekBrown.setProperties(UCSOfIntactRock=150000, GSI=45)
generalizedHoekBrown.setUsingGSIMIDCalc(False)
generalizedHoekBrown.setProperties(MbParameter=0.8)
generalizedHoekBrown.setElasticType(MaterialElasticityTypes.LINEAR_ISOTROPIC)
generalizedHoekBrown.LinearIsotropicStiffness.setPoissonsRatio(0.34)
generalizedHoekBrown.LinearIsotropicStiffness.GeneralizedHoekBrownEstimation.setEstimationMethod(GeneralizedHoekBrownEstimationMethodType.GENERALIZED_HOEK_DIEDERICHS)
generalizedHoekBrown.LinearIsotropicStiffness.GeneralizedHoekBrownEstimation.setUsingEI(False)
generalizedHoekBrown.LinearIsotropicStiffness.GeneralizedHoekBrownEstimation.setMR(350)

# 2.3 Generalized Anisotropic
material1.ConstitutiveModel.setConstitutiveModel(ConstitutiveModelTypes.GENERALIZED_ANISOTROPIC)
# Base material and function points are mandetory fields. They have to be set for model to run.
generalizedAnisotropicFunctionName = "Generalized Anisotropic Function"
model.createNewGeneralizedAnisotropicFunction(generalizedAnisotropicFunctionName)
generalizedAnisotropicFunction = model.getGeneralizedAnisotropicFunctionByName(generalizedAnisotropicFunctionName)
allMaterials = model.getAllMaterialProperties()
generalizedAnisotropicFunction.setBaseMaterial(allMaterials[3].getMaterialName())
generalizedAnisotropicFunction.setDipDipDirectionFunctionPoints([(13.4, 51.2, 1.2, 0.2, allMaterials[4].getMaterialName()), (12.1, 34.4, 0.8, 0.1, allMaterials[5].getMaterialName())])

# 2.4 Jointed Mohr Coulomb
material1.ConstitutiveModel.setConstitutiveModel(ConstitutiveModelTypes.JOINTED_MOHR_COULOMB)
jointedMohrCoulomb = material1.ConstitutiveModel.JointedMohrCoulomb
jointOptions = jointedMohrCoulomb.getJointOptions()
jointOptions.setNumberOfJoint(3)
# Use the index of joints here. The second joint has index 1.
joint2 = jointOptions.getJoint(1)
joint2.setSlipCriterion(MaterialJointSlipCriterionType.HYPERBOLIC_SIMPLE)
joint2.SimpleHyperbolic.setProperties(DilationAngle=12.5, Adhesion=1.2)

# 2.5 Cam Clay
material1.ConstitutiveModel.setConstitutiveModel(ConstitutiveModelTypes.CAM_CLAY)
material1.ConstitutiveModel.CamClay.setNParameter(1.5)
material1.ConstitutiveModel.CamClay.setShearModulus(6500)

# Save and close the model.
model.close(True)
2026-03-13 16:24:04,425 - Rocscience.RS3 - INFO - Attempting to start the application at C:\Program Files\Rocscience\RS3\RS3 and binding server to port 60202...