Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions RFEM/TypesForTimberDesign/timberMoistureClass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from RFEM.initModel import Model, clearAttributes, deleteEmptyAttributes, ConvertToDlString
from RFEM.enums import TimberMoistureClassMoistureClass
from RFEM.LoadCasesAndCombinations.loadCasesAndCombinations import LoadCasesAndCombinations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import.


class TimberMoistureClass():
def __init__(self,
no: int = 1,
name: str = '',
members: str = '',
member_sets: str = '',
surfaces: str = '',
surface_sets: str = '',
moisture_class = TimberMoistureClassMoistureClass.TIMBER_MOISTURE_CLASS_TYPE_1,
comment: str = '',
params: dict = None):
"""
Args:
no (int): Timber Moisture Class Tag
name (str): User Defined Moisture Class Name
members (str): Assigned Members
member_sets (str): Assigned Member Sets
surfaces (str): Assigned Surfaces
surface_sets (str): Assigned Surface Sets
moisture_class (enum): Timber Moisture Class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description should be Timber Moisture Class Type Enumeration

comment (str, optional): Comment
params (dict, optional): Any WS Parameter relevant to the object and its value in form of a dictionary
"""

# Client Model | Types For Timber Design Moisture Class
clientObject = Model.clientModel.factory.create('ns0:timber_moisture_class')

# Clears object atributes | Sets all atributes to None
clearAttributes(clientObject)

# Member Service Class
clientObject.no = no

# Assigned Members
clientObject.member = ConvertToDlString(members)

# Assigned Member Sets
clientObject.member_sets = ConvertToDlString(member_sets)

# Assigned Surfaces
clientObject.surfaces = ConvertToDlString(surfaces)

# Assigned Surface Sets
clientObject.surface_sets = ConvertToDlString(surface_sets)

# Moisture Class
clientObject.moisture_class = moisture_class.name

# User Defined Name
if name:
clientObject.user_defined_name_enabled = True
clientObject.name = name

# Comment
clientObject.comment = comment

# Adding optional parameters via dictionary
if params:
for key in params:
clientObject[key] = params[key]

# Delete None attributes for improved performance
deleteEmptyAttributes(clientObject)

# Add Service Class to client model
Model.clientModel.service.set_timber_moisture_class(clientObject)
124 changes: 124 additions & 0 deletions RFEM/TypesForTimberDesign/timberServiceCondition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
from RFEM.initModel import Model, clearAttributes, deleteEmptyAttributes, ConvertToDlString
from RFEM.enums import TimberServiceConditionsMoistureServiceCondition, TimberServiceConditionsTemperature
from RFEM.enums import TimberServiceConditionsTreatment
from RFEM.LoadCasesAndCombinations.loadCasesAndCombinations import LoadCasesAndCombinations

class TimberServiceConditions():
def __init__(self,
no: int = 1,
name: str = '',
members: str = '',
member_sets: str = '',
surfaces: str = '',
surface_sets: str = '',
standard: int = 6336,
moisture_service_condition = TimberServiceConditionsMoistureServiceCondition.TIMBER_MOISTURE_SERVICE_CONDITION_TYPE_DRY,
temperature = TimberServiceConditionsTemperature.TEMPERATURE_TYPE_TEMPERATURE_ZONE_1,
treatment_csa = TimberServiceConditionsTreatment.TREATMENT_TYPE_NONE,
treatment_nds: bool = True,
treatment_gb: bool = False,
service_conditions = [False, False, False, False, False],
comment: str = '',
params: dict = None):
"""
Args:
no (int): Timber Service Conditions Tag
name (str): User Defined Timber Service Condition Name
members (str): Assigned Members
member_sets (str): Assigned Member Sets
surfaces (str): Assigned Surfaces
surface_sets (str): Assigned Surface Sets
standard (int): Code Number
moisture_service_condition (enum): Timber Service Condition
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description should be Timber Moisture Service Condition Type Enumeration

temperature (enum): Timber Service Conditions Temperature
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be good to add Enumeration at the end of description for variable type (enum)

treatment_csa (enum): Timber Service Conditions Treatment
treatment_nds (bool): Member Pressure Treated
treatment_gb (bool): Timber Is Point Impregnated
service_conditions (list): Service Conditions
service_conditions = [outdoor_environment, long_term_high_temperature_of_surface, permanent_load_design_situation,
timber_structures, short_term_construction_or_maintenance]
comment (str, optional): Comment
params (dict, optional): Any WS Parameter relevant to the object and its value in form of a dictionary
"""

# Client Model | Types For Timber Design Service Condition
clientObject = Model.clientModel.factory.create('ns0:timber_service_conditions')

# Clears object atributes | Sets all atributes to None
clearAttributes(clientObject)

# Member Service Class
clientObject.no = no

# Assigned Members
clientObject.member = ConvertToDlString(members)

# Assigned Member Sets
clientObject.member_sets = ConvertToDlString(member_sets)

# Assigned Surfaces
clientObject.surfaces = ConvertToDlString(surfaces)

# Assigned Surface Sets
clientObject.surface_sets = ConvertToDlString(surface_sets)

# Service Condition if Standard CSA - Moisture Service Conditions and Treatment
if standard == 6336:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Common code could be separated to enhance readability and maintainability.

parameters = {
    "current_standard_for_combination_wizard": standard,
    "activate_combination_wizard_and_classification": True,
    "activate_combination_wizard": True,
    "result_combinations_active": True,
    "result_combinations_parentheses_active": False,
    "result_combinations_consider_sub_results": False,
    "combination_name_according_to_action_category": False}),

# Service Condition if Standard CSA - Moisture Service Conditions and Treatment
    if standard == 6336:
        LoadCasesAndCombinations(params = parameters, ....

LoadCasesAndCombinations(params = {"current_standard_for_combination_wizard": standard,
"activate_combination_wizard_and_classification": True,
"activate_combination_wizard": True,
"result_combinations_active": True,
"result_combinations_parentheses_active": False,
"result_combinations_consider_sub_results": False,
"combination_name_according_to_action_category": False}),
clientObject.moisture_service_condition = moisture_service_condition
clientObject.treatment = treatment_csa

# Service Condition if Standard NDS(USA) - Service Moisture Conditions, Treatment and Temperature
if standard == 6579:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'elif' instead of 'if' should be used. Same with line 91. These statements are mutually exclusive.

LoadCasesAndCombinations(params = {"current_standard_for_combination_wizard": standard,
"activate_combination_wizard_and_classification": True,
"activate_combination_wizard": True,
"result_combinations_active": True,
"result_combinations_parentheses_active": False,
"result_combinations_consider_sub_results": False,
"combination_name_according_to_action_category": False}),
clientObject.moisture_service_condition = moisture_service_condition
clientObject.temperature = temperature
clientObject.member_pressure_treated = treatment_nds

# Treatment if Standard GB
if standard == 6514 or standard == 6516:
LoadCasesAndCombinations(params = {"current_standard_for_combination_wizard": standard,
"activate_combination_wizard_and_classification": True,
"activate_combination_wizard": True,
"result_combinations_active": True,
"result_combinations_parentheses_active": False,
"result_combinations_consider_sub_results": False,
"combination_name_according_to_action_category": False}),
clientObject.moisture_service_condition = moisture_service_condition
clientObject.outdoor_environment = service_conditions[0]
clientObject.long_term_high_temperature_of_surface = service_conditions[1]
clientObject.permanent_load_design_situation = service_conditions[2]
clientObject.timber_structures = service_conditions[3]
clientObject.short_term_construction_or_maintenance = service_conditions[4]
clientObject.timber_is_point_impregnated = treatment_gb

# User Defined Name
if name:
clientObject.user_defined_name_enabled = True
clientObject.name = name

# Comment
clientObject.comment = comment

# Adding optional parameters via dictionary
if params:
for key in params:
clientObject[key] = params[key]

# Delete None attributes for improved performance
deleteEmptyAttributes(clientObject)

# Add Service Class to client model
Model.clientModel.service.set_timber_service_conditions(clientObject)
25 changes: 25 additions & 0 deletions RFEM/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -2472,3 +2472,28 @@ class NoteSurfaceReferenceType(Enum):
Note Surface Reference Type Enumeration
'''
OFFSET_TYPE_XY, OFFSET_TYPE_XZ, OFFSET_TYPE_YZ = range(3)

class TimberMoistureClassMoistureClass(Enum):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TimberMoistureClassType is better class name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm with Heet on this one.

'''
Timber Moisture Class
'''
TIMBER_MOISTURE_CLASS_TYPE_1, TIMBER_MOISTURE_CLASS_TYPE_2, TIMBER_MOISTURE_CLASS_TYPE_3 = range(3)

class TimberServiceConditionsMoistureServiceCondition(Enum):
Copy link
Member

@heetrojivadiya heetrojivadiya May 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TimberMoistureServiceConditionType is better class name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm with Heet on this one.

'''
Timber Service Conditions Moisture Service Condition
'''
TIMBER_MOISTURE_SERVICE_CONDITION_TYPE_DRY, TIMBER_MOISTURE_SERVICE_CONDITION_TYPE_MOIST, TIMBER_MOISTURE_SERVICE_CONDITION_TYPE_VERY_DRY, TIMBER_MOISTURE_SERVICE_CONDITION_TYPE_WET = range(4)

class TimberServiceConditionsTemperature(Enum):
'''
Timber Service Conditions Temperature
'''
TEMPERATURE_TYPE_EQUAL_TO_50, TEMPERATURE_TYPE_LESS_OR_EQUAL_100, TEMPERATURE_TYPE_LESS_OR_EQUAL_35, TEMPERATURE_TYPE_RANGE_100_125, TEMPERATURE_TYPE_RANGE_125_150, TEMPERATURE_TYPE_RANGE_35_50, \
TEMPERATURE_TYPE_TEMPERATURE_ZONE_1, TEMPERATURE_TYPE_TEMPERATURE_ZONE_2, TEMPERATURE_TYPE_TEMPERATURE_ZONE_3 = range(9)

class TimberServiceConditionsTreatment(Enum):
'''
Timber Service Conditions Treatment
'''
TREATMENT_TYPE_FIRE_RETARDANT, TREATMENT_TYPE_NONE, TREATMENT_TYPE_PRESERVATIVE = range(3)
60 changes: 60 additions & 0 deletions UnitTests/test_timberMoistureClass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import sys
import os
PROJECT_ROOT = os.path.abspath(os.path.join(
os.path.dirname(__file__),
os.pardir)
)
sys.path.append(PROJECT_ROOT)

from RFEM.enums import AddOn, TimberMoistureClassMoistureClass
from RFEM.initModel import Model, SetAddonStatus, AddOn, GetAddonStatus
from RFEM.BasicObjects.material import Material
from RFEM.BasicObjects.section import Section
from RFEM.BasicObjects.node import Node
from RFEM.BasicObjects.member import Member
from RFEM.TypesForTimberDesign.timberMoistureClass import TimberMoistureClass
from RFEM.LoadCasesAndCombinations.loadCasesAndCombinations import LoadCasesAndCombinations
import pytest

## Important!!
# First Run: Model set to True and Comments in the test set the way they are right now ---> Run
# --> after First Run: In RFEM > Base Data > Standard I > Design | Standard Group > Timber Design: Set to SIA 265
# Second Run: 1. Set Model to False ( Model(True, "Test_Timber_Moisture") --> Model(False, "Test_Timber_Moisture") )
# 2. Uncomment TimberMoistureClass(no = 1, members='1', moisture_class=TimberMoistureClassMoistureClass.TIMBER_MOISTURE_CLASS_TYPE_2)
# 3. Uncomment: tmc1 = Model.clientModel.service.get_timber_moisture_class(1)
# assert tmc1.member == '1'
# assert tmc1.moisture_class == TimberMoistureClassMoistureClass.TIMBER_MOISTURE_CLASS_TYPE_2.name
# ----> Run again

Model(True, "Test_Timber_Moisture")
@pytest.mark.skipif(GetAddonStatus(Model.clientModel, AddOn.timber_design_active) == False, reason="Code has to be set manually")
def test_timberMoistureClass():

Model.clientModel.service.delete_all()
Model.clientModel.service.begin_modification()

SetAddonStatus(Model.clientModel, AddOn.timber_design_active, True)

Node(1, 0, 0, 0)
Node(2, 5, 0, 0)
Material(1, 'KLH (20 mm) | KLH')
Section(1, 'R_M1 0.2/0.5', 1)
Member(1, 1, 2, 0, 1, 1)

LoadCasesAndCombinations(
params = {
"current_standard_for_combination_wizard": 6226,
"activate_combination_wizard_and_classification": True,
"activate_combination_wizard": True,
"result_combinations_active": True,
"result_combinations_parentheses_active": False,
"result_combinations_consider_sub_results": False,
"combination_name_according_to_action_category": False})

# TimberMoistureClass(no = 1, members='1', moisture_class=TimberMoistureClassMoistureClass.TIMBER_MOISTURE_CLASS_TYPE_2)

Model.clientModel.service.finish_modification()

# tmc1 = Model.clientModel.service.get_timber_moisture_class(1)
# assert tmc1.member == '1'
# assert tmc1.moisture_class == TimberMoistureClassMoistureClass.TIMBER_MOISTURE_CLASS_TYPE_2.name
62 changes: 62 additions & 0 deletions UnitTests/test_timberServiceConditionCSA.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import sys
import os
PROJECT_ROOT = os.path.abspath(os.path.join(
os.path.dirname(__file__),
os.pardir)
)
sys.path.append(PROJECT_ROOT)

from RFEM.enums import AddOn, TimberServiceConditionsMoistureServiceCondition, TimberServiceConditionsTreatment
from RFEM.initModel import Model, SetAddonStatus, AddOn, GetAddonStatus
from RFEM.BasicObjects.material import Material
from RFEM.BasicObjects.section import Section
from RFEM.BasicObjects.node import Node
from RFEM.BasicObjects.member import Member
from RFEM.TypesForTimberDesign.timberServiceCondition import TimberServiceConditions
from RFEM.LoadCasesAndCombinations.loadCasesAndCombinations import LoadCasesAndCombinations
import pytest

## Important!!
# First Run: Model set to True and and Comments in the test set the way they are right now ---> Run
# --> after First Run: In RFEM > Base Data > Standard I > Design | Standard Group > Timber Design: Set to CSA 086
# Second Run: 1. Set Model to False ( Model(True, "Test_Timber_Service") --> Model(False, "Test_Timber_Service") )
# 2. Uncomment: TimberServiceConditions(no=1, moisture_service_condition=TimberServiceConditionsMoistureServiceCondition.TIMBER_MOISTURE_SERVICE_CONDITION_TYPE_WET.name, \
# treatment_csa = TimberServiceConditionsTreatment.TREATMENT_TYPE_PRESERVATIVE.name)
# 3. Uncomment: tcs1 = Model.clientModel.service.get_timber_service_conditions(1)
# assert tcs1.moisture_service_condition == "TIMBER_MOISTURE_SERVICE_CONDITION_TYPE_WET"
# assert tcs1.treatment == "TREATMENT_TYPE_PRESERVATIVE"
# ---> Run again !

Model(True, "Test_Timber_Service_CSA")
@pytest.mark.skipif(GetAddonStatus(Model.clientModel, AddOn.timber_design_active) == False, reason="Code has to be set manually")
def test_timberServiceConditionsCSA():

Model.clientModel.service.delete_all()
Model.clientModel.service.begin_modification()

SetAddonStatus(Model.clientModel, AddOn.timber_design_active, True)

Node(1, 0, 0, 0)
Node(2, 5, 0, 0)
Material(1, 'KLH (20 mm) | KLH')
Section(1, 'R_M1 0.2/0.5', 1)
Member(1, 1, 2, 0, 1, 1)

LoadCasesAndCombinations(
params = {
"current_standard_for_combination_wizard": 6336,
"activate_combination_wizard_and_classification": True,
"activate_combination_wizard": True,
"result_combinations_active": True,
"result_combinations_parentheses_active": False,
"result_combinations_consider_sub_results": False,
"combination_name_according_to_action_category": False})

# TimberServiceConditions(no=1, standard = 6336, moisture_service_condition=TimberServiceConditionsMoistureServiceCondition.TIMBER_MOISTURE_SERVICE_CONDITION_TYPE_WET.name, \
# treatment_csa = TimberServiceConditionsTreatment.TREATMENT_TYPE_PRESERVATIVE.name)

Model.clientModel.service.finish_modification()

# tcs1 = Model.clientModel.service.get_timber_service_conditions(1)
# assert tcs1.moisture_service_condition == "TIMBER_MOISTURE_SERVICE_CONDITION_TYPE_WET"
# assert tcs1.treatment == "TREATMENT_TYPE_PRESERVATIVE"
Loading