Import Export Properties Script Examples#
Download the ExampleModel.fez and EmptyExampleModel_start.fez for this example.
from rs2.modeler.properties.PropertyEnums import *
from rs2.modeler.RS2Modeler import RS2Modeler
from rs2.modeler.properties import *
import os, inspect
import csv
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(lambda: None)))
RS2Modeler.startApplication(port=60095)
modeler = RS2Modeler(port=60095)
model1FilePath = rf"{current_dir}\example_models\ExampleModel.fez"
model2FilePath = rf"{current_dir}\example_models\EmptyExampleModel_start.fez"
model2FileSavePath = rf"{current_dir}\example_models\EmptyExampleModel_final.fez"
model1 = modeler.openFile(model1FilePath)
model2 = modeler.openFile(model2FilePath)
model1Till = model1.getMaterialPropertyByName("Till")
model2Till = model2.getMaterialPropertyByName("till")
# Not all functions are accessible through the setProperties and getProperties methods.
# Consult setProperties and getProperties method definition in documentation to determine properties available.
# Initial Conditions
model1_initial_conditions = model1Till.InitialConditions.getProperties()
model2Till.InitialConditions.setProperties(**model1_initial_conditions)
print("Model 2 Till Initial Conditions")
print(model2Till.InitialConditions.getProperties())
# Stiffness
elasticType = model1Till.Stiffness.getElasticType()
model2Till.Stiffness.setElasticType(elasticType)
# More Stiffness Elasticity Types can be added here
if elasticType == MaterialElasticityTypes.ISOTROPIC:
model1_stiffness = model1Till.Stiffness.Isotropic.getProperties()
model2Till.Stiffness.Isotropic.setProperties(**model1_stiffness)
elif elasticType == MaterialElasticityTypes.TRANSVERSELY_ISOTROPIC:
model1_stiffness = model1Till.Stiffness.TransverselyIsotropic.getProperties()
model2Till.Stiffness.TransverselyIsotropic.setProperties(**model1_stiffness)
elif elasticType == MaterialElasticityTypes.ORTHOTROPIC:
model1_stiffness = model1Till.Stiffness.Orthotropic.getProperties()
model2Till.Stiffness.Orthotropic.setProperties(**model1_stiffness)
elif elasticType == MaterialElasticityTypes.DUNCAN_CHANG_HYPERBOLIC:
model1_stiffness = model1Till.Stiffness.NonLinearHyperbolic.getProperties()
model2Till.Stiffness.NonLinearHyperbolic.setProperties(**model1_stiffness)
elif elasticType == MaterialElasticityTypes.NON_LINEAR_ISOTROPIC:
model1_stiffness = model1Till.Stiffness.NonLinearIsotropic.getProperties()
model2Till.Stiffness.NonLinearIsotropic.setProperties(**model1_stiffness)
elif elasticType == MaterialElasticityTypes.CUSTOM:
model1_stiffness = model1Till.Stiffness.Custom.getProperties()
model2Till.Stiffness.Custom.setProperties(**model1_stiffness)
print("\nModel 2 Till Stiffness")
print(model2Till.Stiffness.Isotropic.getProperties())
# Strength
failureCriterion = model1Till.Strength.getFailureCriterion()
model2Till.Strength.setFailureCriterion(failureCriterion)
# More Strength Failure Criteria Types can be added here
if failureCriterion == StrengthCriteriaTypes.MOHR_COULOMB:
model1_strength = model1Till.Strength.MohrCoulombStrength.getProperties()
model2Till.Strength.MohrCoulombStrength.setProperties(**model1_strength)
elif failureCriterion == StrengthCriteriaTypes.HOEK_BROWN:
model1_strength = model1Till.Strength.HoekBrown.getProperties()
model2Till.Strength.HoekBrown.setProperties(**model1_strength)
print("\nModel 2 Till Strength")
print(model2Till.Strength.MohrCoulombStrength.getProperties())
# Hydraulic
model1_hydraulic = model1Till.Hydraulic.StaticGroundwater.getProperties()
model2Till.Hydraulic.StaticGroundwater.setProperties(**model1_hydraulic)
print("\nModel 2 Till Hydraulic")
print(model2Till.Hydraulic.StaticGroundwater.getProperties())
# Thermal
model1_thermal_conductivity = model1Till.Thermal.Conductivity.ConstantConductivity.getProperties()
model2Till.Thermal.Conductivity.ConstantConductivity.setProperties(**model1_thermal_conductivity)
print("\nModel 2 Till Thermal Conductivity")
print(model2Till.Thermal.Conductivity.ConstantConductivity.getProperties())
model1_thermal_heat_capacity = model1Till.Thermal.HeatCapacity.ConstantHeatCapacity.getProperties()
model2Till.Thermal.HeatCapacity.ConstantHeatCapacity.setProperties(**model1_thermal_heat_capacity)
print("\nModel 2 Till Thermal Heat Capactiy")
print(model2Till.Thermal.HeatCapacity.ConstantHeatCapacity.getProperties())
# Bolt
model1_bolt = model1.getAllBoltProperties()[0]
model2_bolt = model2.getAllBoltProperties()[0]
model1_bolt_properties = model1_bolt.Swellex.getProperties()
model2_bolt.setBoltType(BoltTypes.SWELLEX)
model2_bolt.Swellex.setProperties(**model1_bolt_properties)
print("\nModel 2 Bolt Properties")
print(model2_bolt.Swellex.getProperties())
# Liner
model1_liner = model1.getAllLinerProperties()[0]
model2_liner = model2.getAllLinerProperties()[0]
model1_liner_properties = model1_liner.ReinforcedConcrete.getProperties()
model2_liner.setLinerType(LinerTypes.REINFORCED_CONCRETE)
model2_liner.ReinforcedConcrete.setProperties(**model1_liner_properties)
print("\nModel 2 Liner Properties")
print(model2_liner.ReinforcedConcrete.getProperties())
# Joint
model1_joint = model1.getAllJointProperties()[0]
model2_joint = model2.getAllJointProperties()[0]
model1_joint_properties = model1_joint.MaterialDependent.getProperties()
model2_joint.setSlipCriterion(JointTypes.MATERIAL_DEPENDENT)
model2_joint.MaterialDependent.setProperties(**model1_joint_properties)
print("\nModel 2 Joint Properties")
print(model2_joint.MaterialDependent.getProperties())
# Pile
model1_pile = model1.getAllPileProperties()[0]
model2_pile = model2.getAllPileProperties()[0]
model1_pile_interface_properties = model1_pile.MohrCoulombPile.getProperties()
model2_pile.MohrCoulombPile.setProperties(**model1_pile_interface_properties)
model1_pile_force_displacement_properties = model1_pile.ForceDisplacement.getProperties()
model2_pile.ForceDisplacement.setProperties(**model1_pile_force_displacement_properties)
print("\nModel 2 Pile Interface Properties")
print(model2_pile.MohrCoulombPile.getProperties())
print("\nModel 2 Pile Force Displacement Properties")
print(model2_pile.ForceDisplacement.getProperties())
# Export data to a csv File
combined_material_data = {
"initialConditions": model1_initial_conditions,
"stiffness": model1_stiffness,
"strength": model1_strength,
"hydraulic": model1_hydraulic,
"thermalConductivity": model1_thermal_conductivity,
"thermalHeatCapacity": model1_thermal_heat_capacity,
}
combined_support_data = {
"bolt": model1_bolt_properties,
"liner": model1_liner_properties,
"joint": model1_joint_properties,
"pileInterfaceProperties": model1_pile_interface_properties,
"pileForceDisplacementProperties": model1_pile_force_displacement_properties,
}
flattened_material_data = {}
for category, properties in combined_material_data.items():
for key, value in properties.items():
flattened_material_data[f"{category}_{key}"] = value
with open(rf"{current_dir}\combined_material_properties.csv", "w", newline="") as file:
writer = csv.writer(file)
writer.writerow(["Key", "Value"])
for key, value in flattened_material_data.items():
writer.writerow([key, value])
flattened_support_data = {}
for category, properties in combined_support_data.items():
for key, value in properties.items():
flattened_support_data[f"{category}_{key}"] = value
with open(rf"{current_dir}\combined_support_properties.csv", "w", newline="") as file:
writer = csv.writer(file)
writer.writerow(["Key", "Value"])
for key, value in flattened_support_data.items():
writer.writerow([key, value])
# Import data from csv file to a dictionary
imported_material_data = {}
with open(rf"{current_dir}\combined_material_properties.csv", "r") as file:
reader = csv.reader(file)
next(reader)
for row in reader:
full_key, value = row
category, key = full_key.split("_", 1)
if category not in imported_material_data:
imported_material_data[category] = {}
imported_material_data[category][key] = value
imported_support_data = {}
with open(rf"{current_dir}\combined_support_properties.csv", "r") as file:
reader = csv.reader(file)
next(reader)
for row in reader:
full_key, value = row
category, key = full_key.split("_", 1)
if category not in imported_support_data:
imported_support_data[category] = {}
imported_support_data[category][key] = value
model2.saveAs(model2FileSavePath)
modeler.closeProgram()
Output#
Download .csv results at combined_material_properties.csv and combined_support_properties.csv.
Model 2 Till Initial Conditions
{'InitialElementLoading': <InitialElementLoadingType.FIELD_STRESS_AND_BODY_FORCE: 'INITIAL_MAT_LOADING__BOTH_FIELD_AND_BODY'>, 'AccountForMoistureContentInUnitWeight': False, 'DryUnitWeight': 0.016, 'MoistUnitWeight': 0.018, 'SaturatedUnitWeight': 0.02, 'UnitWeight': 16.0, 'PorosityValue': 0.5, 'InitialWaterCondition': <StaticWaterModes.PORE_WATER_PRESSURE: 'SWM_PWP'>, 'InitialPoreWaterPressure': 0.001, 'InitialRu': 1.0, 'InitialHuType': <HuTypes.CUSTOM: 'HT_CUSTOM'>, 'InitialHu': 1.0, 'InitialTemperatureCondition': <StaticWaterModes.PORE_WATER_PRESSURE: 'SWM_PWP'>, 'InitialTemperature': 0.0}
Model 2 Till Stiffness
{'UseUnloadingCondition': False, 'UnloadingCondition': <UnloadingConditions.MEAN_STRESS: 'UC_MEAN_STRESS'>, 'ElasticParameters': <ElasticParameters.CONSTANT_SHEAR_MODULUS: 'CONSTANT_SHEAR_MODULUS'>, '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}
Model 2 Till Strength
{'MaterialType': <MaterialType.ELASTIC: 'ELASTIC'>, 'PeakTensileStrength': 0.0, 'PeakFrictionAngle': 35.0, 'PeakCohesion': 10.5, 'ResidualTensileStrength': 0.0, 'ResidualFrictionAngle': 35.0, 'ResidualCohesion': 10.5, 'DilationAngle': 0.0, 'ApplySSRShearStrengthReduction': True}
Model 2 Till Hydraulic
{'StaticWaterMode': <StaticWaterModes.DRY: 'SWM_DRY'>, 'StaticPoreWaterPressure': 1.0, 'RuValue': 0.0, 'HuType': <HuTypes.CUSTOM: 'HT_CUSTOM'>, 'HuValue': 1.0}
Model 2 Till Thermal Conductivity
{'UnfrozenConductivity': 0.5, 'FrozenConductivity': 5.0, 'FrozenTemperature': 0.0}
Model 2 Till Thermal Heat Capactiy
{'IncludeLatentHeat': False, 'UnfrozenVolumetricHeatCapacity': 0.5, 'FrozenVolumetricHeatCapacity': 5.0, 'FrozenTemperature': 0.0}
Model 2 Bolt Properties
{'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': <BoltModels.PLASTIC: 'P2_BOLT_PLASTIC'>, 'JointShear': True, 'PreTensioningForce': 0.0, 'ConstantPretensioningForceInInstallStage': True, 'FacePlates': True, 'AddPullOutForce': False, 'PullOutForce': 0.0}
Model 2 Liner Properties
{'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': <MaterialType.ELASTIC: 'ELASTIC'>, 'SlidingGap': False, 'StrainAtLocking': 5.0, 'BeamElementFormulation': <LinerFormulation.TIMOSHENKO: 'P2_LINER_FORMULATION_TIMOSHENKO'>, 'AxialStrainExpansion': 0.0, 'ActivateThermal': False, 'StaticTemperatureMode': <StaticWaterModes.PORE_WATER_PRESSURE: 'SWM_PWP'>, 'StaticTemperature': 0.0, 'Conductivity': 1.0, 'SpecificHeatCapacity': 1.0, 'ThermalExpansion': False, 'ExpansionCoefficient': 1.0, 'StageConcreteProperties': True}
Model 2 Joint Properties
{'InterfaceCoefficient': 0.7, 'DefineStiffness': <DefineStiffness.DEFINE_PARAMETER: 'DEFINE_PARAMETER'>, 'NormalStiffness': 100000.0, 'ShearStiffness': 10000.0, 'StiffnessCoefficient': 1.0, 'ApplyPorePressure': True, 'ApplyAdditionalPressureInsideJoint': True, 'AdditionalPressureType': <AdditionalPressureType.PRESSURE: 'JOINT_ADDITIONAL_PRESSURE_BY_VALUE'>, 'AdditionalPressureInsideJoint': 0.0, 'ApplyPressureToLinerSideOnly': True, 'ApplyStageFactors': True}
Model 2 Pile Interface Properties
{'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}
Model 2 Pile Force Displacement Properties
{'Apply': <PileEndCondition.NONE: 'FP_NONE'>, 'ApplyOn': <PileForceApplicationPoint.TOP: 'FP_TOP'>, 'X': 0.0, 'Y': 0.0}