|
1 | 1 | from RSTAB.initModel import clearAttributes, deleteEmptyAttributes, Model, ConvertStrToListOfInt |
2 | | -from RSTAB.enums import ObjectTypes |
3 | | - |
| 2 | +from RSTAB.enums import ObjectTypes, MaterialType, MaterialModel, MaterialDefinitionType |
| 3 | +from RSTAB.enums import MaterialStiffnessModificationType, PoissonRatioEditableGroupType |
4 | 4 |
|
5 | 5 | class Material(): |
6 | 6 | def __init__(self, |
@@ -29,7 +29,153 @@ def __init__(self, |
29 | 29 | clientObject.no = no |
30 | 30 |
|
31 | 31 | # Material Name |
32 | | - clientObject.name = name |
| 32 | + if name: |
| 33 | + clientObject.user_defined_name_enabled = True |
| 34 | + clientObject.name = name |
| 35 | + |
| 36 | + # Comment |
| 37 | + clientObject.comment = comment |
| 38 | + |
| 39 | + # Adding optional parameters via dictionary |
| 40 | + if params: |
| 41 | + for key in params: |
| 42 | + clientObject[key] = params[key] |
| 43 | + |
| 44 | + # Delete None attributes for improved performance |
| 45 | + deleteEmptyAttributes(clientObject) |
| 46 | + |
| 47 | + # Add material to client model |
| 48 | + model.clientModel.service.set_material(clientObject) |
| 49 | + |
| 50 | + @staticmethod |
| 51 | + def UserDefinedMaterial(no: int = 1, |
| 52 | + name: str = 'S235', |
| 53 | + material_type = MaterialType.TYPE_CONCRETE, |
| 54 | + material_model = MaterialModel.MODEL_ISOTROPIC_LINEAR_ELASTIC, |
| 55 | + elasticity_modulus: float = None, |
| 56 | + elasticity_modulus_x: float = None, |
| 57 | + elasticity_modulus_y: float = None, |
| 58 | + elasticity_modulus_z: float = None, |
| 59 | + shear_modulus: float = None, |
| 60 | + shear_modulus_yz: float = None, |
| 61 | + shear_modulus_xz: float = None, |
| 62 | + shear_modulus_xy: float = None, |
| 63 | + poisson_ratio: float = None, |
| 64 | + poisson_ratio_yz: float = None, |
| 65 | + poisson_ratio_xz: float = None, |
| 66 | + poisson_ratio_xy: float = None, |
| 67 | + poisson_ratio_zy: float = None, |
| 68 | + poisson_ratio_zx: float = None, |
| 69 | + poisson_ratio_yx: float = None, |
| 70 | + poisson_ratio_editable_group_type = PoissonRatioEditableGroupType.POISSON_RATIOS_GROUP_MAJOR_3D, |
| 71 | + mass_density: float = None, |
| 72 | + thermal_expansion_coefficient: float = None, |
| 73 | + thermal_expansion_coefficient_x: float = None, |
| 74 | + thermal_expansion_coefficient_y: float = None, |
| 75 | + thermal_expansion_coefficient_z: float = None, |
| 76 | + definition_type = MaterialDefinitionType.E_G_NU, |
| 77 | + stiffness_modification_type = MaterialStiffnessModificationType.STIFFNESS_MODIFICATION_TYPE_DIVISION, |
| 78 | + division_multiplication_factor: float = 1, |
| 79 | + comment: str = '', |
| 80 | + params: dict = None, |
| 81 | + model = Model): |
| 82 | + |
| 83 | + ''' |
| 84 | + Args: |
| 85 | + no (int): Material Tag |
| 86 | + name (str): User Defined Material Name |
| 87 | + material_type (enum): Material Type Enumeration |
| 88 | + material_model (enum): Material Model Enumeration |
| 89 | + elasticity_modulus (float): Elasticity Modulus |
| 90 | + elasticity_modulus_x (float): X-Direction Elasticity Modulus |
| 91 | + elasticity_modulus_y (float): Y-Direction Elasticity Modulus |
| 92 | + elasticity_modulus_z (float): Z-Direction Elasticity Modulus |
| 93 | + shear_modulus (float): Shear Modulus |
| 94 | + shear_modulus_yz (float): YZ-Direction Shear Modulus |
| 95 | + shear_modulus_xz (float): XZ-Direction Shear Modulus |
| 96 | + shear_modulus_xy (float): XY-Direction Shear Modulus |
| 97 | + poisson_ratio (float): Poisson Ratio |
| 98 | + poisson_ratio_yz (float): YZ-Direction Poisson Ratio |
| 99 | + poisson_ratio_xz (float): XZ-Direction Poisson Ratio |
| 100 | + poisson_ratio_xy (float): XY-Direction Poisson Ratio |
| 101 | + poisson_ratio_zy (float): ZY-Direction Poisson Ratio |
| 102 | + poisson_ratio_zx (float): ZX-Direction Poisson Ratio |
| 103 | + poisson_ratio_yx (float): YX-Direction Poisson Ratio |
| 104 | + poisson_ratio_editable_group_type (enum): Poisson Ratio Editable Group Type Enumeration |
| 105 | + mass_density (float): Mass Density |
| 106 | + thermal_expansion_coefficient (float): Thermal Expansion Coefficient |
| 107 | + thermal_expansion_coefficient_x (float): X-Direction Thermal Expansion Coefficient |
| 108 | + thermal_expansion_coefficient_y (float): Y-Direction Thermal Expansion Coefficient |
| 109 | + thermal_expansion_coefficient_z (float): Z-Direction Thermal Expansion Coefficient |
| 110 | + definition_type (enum): Material Definition Type Enumeration |
| 111 | + stiffness_modification_type (enum): Material Stiffness Modification Type Enumeration |
| 112 | + division_multiplication_factor (float): Division Multiplication Factor |
| 113 | + comment (str, optional): Comments |
| 114 | + params (dict, optional): Any WS Parameter relevant to the object and its value in form of a dictionary |
| 115 | + model (RSTAB Class, optional): Model to be edited |
| 116 | + ''' |
| 117 | + |
| 118 | + # Client model | Material |
| 119 | + clientObject = model.clientModel.factory.create('ns0:material') |
| 120 | + |
| 121 | + # Clears object atributes | Sets all atributes to None |
| 122 | + clearAttributes(clientObject) |
| 123 | + |
| 124 | + # Material No. |
| 125 | + clientObject.no = no |
| 126 | + |
| 127 | + clientObject.user_defined = True |
| 128 | + |
| 129 | + # Material Name |
| 130 | + if name: |
| 131 | + clientObject.user_defined_name_enabled = True |
| 132 | + clientObject.name = name |
| 133 | + |
| 134 | + # Material Type |
| 135 | + clientObject.material_type = material_type.name |
| 136 | + |
| 137 | + # Material Model |
| 138 | + clientObject.material_model = material_model.name |
| 139 | + |
| 140 | + # Basic Material Properties |
| 141 | + clientObject.temperature = model.clientModel.factory.create('ns0:material.temperature') |
| 142 | + |
| 143 | + mbp = model.clientModel.factory.create('ns0:material_temperature_row') |
| 144 | + mbp.no = 1 |
| 145 | + mbp.row = model.clientModel.factory.create('ns0:material_temperature') |
| 146 | + clearAttributes(mbp.row) |
| 147 | + mbp.row.poisson_ratio_editable_group_type = poisson_ratio_editable_group_type.name |
| 148 | + mbp.row.elasticity_modulus_global = elasticity_modulus |
| 149 | + mbp.row.elasticity_modulus_y = elasticity_modulus_y |
| 150 | + mbp.row.elasticity_modulus_x = elasticity_modulus_x |
| 151 | + mbp.row.elasticity_modulus_z = elasticity_modulus_z |
| 152 | + mbp.row.shear_modulus_global = shear_modulus |
| 153 | + mbp.row.shear_modulus_yz = shear_modulus_yz |
| 154 | + mbp.row.shear_modulus_xz = shear_modulus_xz |
| 155 | + mbp.row.shear_modulus_xy = shear_modulus_xy |
| 156 | + mbp.row.poisson_ratio_global = poisson_ratio |
| 157 | + mbp.row.poisson_ratio_yz = poisson_ratio_yz |
| 158 | + mbp.row.poisson_ratio_xz = poisson_ratio_xz |
| 159 | + mbp.row.poisson_ratio_xy = poisson_ratio_xy |
| 160 | + mbp.row.poisson_ratio_zy = poisson_ratio_zy |
| 161 | + mbp.row.poisson_ratio_zx = poisson_ratio_zx |
| 162 | + mbp.row.poisson_ratio_yx = poisson_ratio_yx |
| 163 | + mbp.row.mass_density = mass_density |
| 164 | + mbp.row.thermal_expansion_coefficient_global = thermal_expansion_coefficient |
| 165 | + mbp.row.thermal_expansion_coefficient_x = thermal_expansion_coefficient_x |
| 166 | + mbp.row.thermal_expansion_coefficient_y = thermal_expansion_coefficient_y |
| 167 | + mbp.row.thermal_expansion_coefficient_z = thermal_expansion_coefficient_z |
| 168 | + mbp.row.division_multiplication_factor = division_multiplication_factor |
| 169 | + |
| 170 | + clientObject.temperature.material_temperature.append(mbp) |
| 171 | + |
| 172 | + # Definition Type |
| 173 | + clientObject.definition_type = definition_type.name |
| 174 | + |
| 175 | + # Stiffness Modification |
| 176 | + if stiffness_modification_type: |
| 177 | + clientObject.stiffness_modification = True |
| 178 | + clientObject.stiffness_modification_type = stiffness_modification_type.name |
33 | 179 |
|
34 | 180 | # Comment |
35 | 181 | clientObject.comment = comment |
|
0 commit comments