Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/main' into OndrejMichal_…
Browse files Browse the repository at this point in the history
…bug_22810

unit tests: 124 passed, 9 skipped in 156.66s
  • Loading branch information
MichalO committed Apr 1, 2022
2 parents 040c17f + a21e37c commit 4983743
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 7 deletions.
193 changes: 193 additions & 0 deletions RFEM/TypesForSteelDesign/steelBoundaryConditions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
from RFEM.initModel import *
from RFEM.enums import *

class SteelBoundaryConditions():
def __init__(self,
no: int = 1,
user_defined_name: list = [False],
members: str = '',
member_sets : str = '',
intermediate_nodes : bool = False,
different_properties_supports: bool = True,
different_properties_hinges: bool = True,
nodal_supports: list = [
[None, SteelBoundaryConditionsSupportType.SUPPORT_TYPE_FIXED_IN_Y_AND_TORSION, False, True, False, True, False, False, False,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SteelBoundaryConditionsEccentricityTypeZ.ECCENTRICITY_TYPE_USER_VALUE, 0.0, 0.0, 0.0, ""],
[None, SteelBoundaryConditionsSupportType.SUPPORT_TYPE_FIXED_IN_Y_AND_TORSION, False, True, False, True, False, False, False,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SteelBoundaryConditionsEccentricityTypeZ.ECCENTRICITY_TYPE_USER_VALUE, 0.0, 0.0, 0.0, ""]
],
member_hinges: list = [
["Start", False, False, False, False, False, False, False, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ""],
["End", False, False, False, False, False, False, False, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ""]
],
comment: str = '',
params: dict = {}):

"""
Args:
no (int): Boundary Conditions Tag
user_defined_name (list): User Defined Boundary Conditions Name
for user_defined_name[0] == False:
pass
for user_defined_name == True:
user_defined_name[1] = Defined Name
members (str): Assigned Members
member_sets (str): Assigned Member Sets
intermediate_nodes (bool): Intermediate Nodes Option
different_properties_supports (bool): Different Properties Option for Supports
different_properties_hinges (bool): Different Properties Option for Hinges
nodal_supports (list): Nodal Supports Table Definition
nodal_supports[i][0] (int)= Node Sequence No.
nodal_supports[i][1] (enum)= Support Type Enumeration
nodal_supports[i][2] (bool)= Support in X Direction Option
nodal_supports[i][3] (bool)= Support in Y Direction Option
nodal_supports[i][4] (bool)= Support in Z Direction Option
nodal_supports[i][5] (bool)= Restraint About X Option
nodal_supports[i][6] (bool)= Restraint About Y Option
nodal_supports[i][7] (bool)= Restraint About Z Option
nodal_supports[i][8] (bool)= Restraint Warping Option
nodal_supports[i][9] (float)= Rotation Magnitude
nodal_supports[i][10] (float)= Rotation About X Magnitude
nodal_supports[i][11] (float)= Rotation About Y Magnitude
nodal_supports[i][12] (float)= Rotation About Z Magnitude
nodal_supports[i][13] (float)= Support Spring X
nodal_supports[i][14] (float)= Support Spring Y
nodal_supports[i][15] (float)= Support Spring Z
nodal_supports[i][16] (float)= Restraint Spring About X Magnitude
nodal_supports[i][17] (float)= Restraint Spring About Y Magnitude
nodal_supports[i][18] (float)= Restraint Spring About Z Magnitude
nodal_supports[i][19] (float)= Restraint Spring Warping Magnitude
nodal_supports[i][20] (enum)= Eccentricity Type in Z Enumeration
nodal_supports[i][21] (float)= Eccentricity in X Magnitude
nodal_supports[i][22] (float)= Eccentricity in Y Magnitude
nodal_supports[i][23] (float)= Eccentricity in Z Magnitude
nodal_supports[i][24] (str)= Assigned Nodes
member_hinges (list): Member Hinges Table Definition
member_hinges[i][0] = Node Sequence No.
member_hinges[i][1] = Release in X Option
member_hinges[i][2] = Release in Y Option
member_hinges[i][3] = Release in Z Option
member_hinges[i][4] = Release About X Option
member_hinges[i][5] = Release About Y Option
member_hinges[i][6] = Release About Z Option
member_hinges[i][7] = Release Warping Option
member_hinges[i][8] = Release Spring in X Magnitude
member_hinges[i][9] = Release Spring in Y Magnitude
member_hinges[i][10] = Release Spring in Z Magnitude
member_hinges[i][11] = Release Spring About X Magnitude
member_hinges[i][12] = Release Spring About Y Magnitude
member_hinges[i][13] = Release Spring About Z Magnitude
member_hinges[i][14] = Release Spring Warping Magnitude
member_hinges[i][15] = Assigned Nodes
comment (str, optional): Comment
params (dict, optional): Parameters
"""

# Client Model | Types For Steel Design Boundary Conditions
clientObject = Model.clientModel.factory.create('ns0:steel_boundary_conditions')

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

# Boundary Conditions No.
clientObject.no = no

# Boundary Conditions User Defined Name
if user_defined_name[0] == False:
clientObject.user_defined_name_enabled = user_defined_name[0]
else:
clientObject.user_defined_name_enabled = user_defined_name[0]
clientObject.name = user_defined_name[1]

# Intermediate Nodes Option
clientObject.intermediate_nodes = intermediate_nodes

# Boundary Conditions Assigned Members
clientObject.members = ConvertToDlString(members)

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

# Boundary Conditions Nodal Supports
clientObject.nodal_supports = Model.clientModel.factory.create('ns0:steel_boundary_conditions.nodal_supports')

for i,j in enumerate(nodal_supports):
mlvlp = Model.clientModel.factory.create('ns0:steel_boundary_conditions_nodal_supports')
mlvlp.no = i
mlvlp.node_seq_no = nodal_supports[i][0]
mlvlp.support_type = nodal_supports[i][1].name
mlvlp.support_in_x = nodal_supports[i][2]
mlvlp.support_in_y = nodal_supports[i][3]
mlvlp.support_in_z = nodal_supports[i][4]
mlvlp.restraint_about_x = nodal_supports[i][5]
mlvlp.restraint_about_y = nodal_supports[i][6]
mlvlp.restraint_about_z = nodal_supports[i][7]
mlvlp.restraint_warping = nodal_supports[i][8]
mlvlp.rotation = nodal_supports[i][9]
mlvlp.rotation_about_x = nodal_supports[i][10]
mlvlp.rotation_about_y = nodal_supports[i][11]
mlvlp.rotation_about_z = nodal_supports[i][12]
mlvlp.support_spring_in_x = nodal_supports[i][13]
mlvlp.support_spring_in_y = nodal_supports[i][14]
mlvlp.support_spring_in_z = nodal_supports[i][15]
mlvlp.restraint_spring_about_x = nodal_supports[i][16]
mlvlp.restraint_spring_about_y = nodal_supports[i][17]
mlvlp.restraint_spring_about_z = nodal_supports[i][18]
mlvlp.restraint_spring_warping = nodal_supports[i][19]
mlvlp.eccentricity_type_z_type = nodal_supports[i][20].name
mlvlp.eccentricity_x = nodal_supports[i][21]
mlvlp.eccentricity_y = nodal_supports[i][22]
mlvlp.eccentricity_z = nodal_supports[i][23]
mlvlp.nodes = nodal_supports[i][24]

clientObject.nodal_supports.steel_boundary_conditions_nodal_supports.append(mlvlp)

# Boundary Conditions Member Hinges
clientObject.member_hinges = Model.clientModel.factory.create('ns0:steel_boundary_conditions.member_hinges')

for i,j in enumerate(member_hinges):
mlvlp = Model.clientModel.factory.create('ns0:steel_boundary_conditions_member_hinges')
mlvlp.no = i
mlvlp.node_seq_no = member_hinges[i][0]
mlvlp.release_in_x = member_hinges[i][1]
mlvlp.release_in_y = member_hinges[i][2]
mlvlp.release_in_z = member_hinges[i][3]
mlvlp.release_about_x = member_hinges[i][4]
mlvlp.release_about_y = member_hinges[i][5]
mlvlp.release_about_z = member_hinges[i][6]
mlvlp.release_warping = member_hinges[i][7]
mlvlp.release_spring_in_x = member_hinges[i][8]
mlvlp.release_spring_in_y = member_hinges[i][9]
mlvlp.release_spring_in_z = member_hinges[i][10]
mlvlp.release_spring_about_x = member_hinges[i][11]
mlvlp.release_spring_about_y = member_hinges[i][12]
mlvlp.release_spring_about_z = member_hinges[i][13]
mlvlp.release_spring_warping = member_hinges[i][14]
mlvlp.nodes = member_hinges[i][15]

clientObject.member_hinges.steel_boundary_conditions_member_hinges.append(mlvlp)

# Boundary Conditions Different Properties Supports
clientObject.different_properties_supports = different_properties_supports

# Boundary Conditions Different Properties Hinges
clientObject.different_properties_hinges = different_properties_hinges

# Comment
clientObject.comment = comment

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

# Add Steel Boundary Conditions to client model
Model.clientModel.service.set_steel_boundary_conditions(clientObject)

12 changes: 12 additions & 0 deletions RFEM/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,18 @@ class SteelEffectiveLengthsMemberTypeZZ(Enum):
'''
MEMBER_TYPE_BEAM, MEMBER_TYPE_CANTILEVER = range(2)

class SteelBoundaryConditionsSupportType(Enum):
'''
Steel Boundary Conditions Support Type
'''
SUPPORT_TYPE_FIXED_ALL, SUPPORT_TYPE_FIXED_IN_Y, SUPPORT_TYPE_FIXED_IN_Y_AND_TORSION, SUPPORT_TYPE_FIXED_IN_Y_AND_TORSION_AND_WARPING, \
SUPPORT_TYPE_FIXED_IN_Y_AND_WARPING, SUPPORT_TYPE_INDIVIDUALLY, SUPPORT_TYPE_NONE, SUPPORT_TYPE_TORSION, SUPPORT_TYPE_TORSION_AND_WARPING = range(9)

class SteelBoundaryConditionsEccentricityTypeZ(Enum):
'''
Steel Boundary Conditions Eccentricity Type Z Type
'''
ECCENTRICITY_TYPE_AT_LOWER_FLANGE, ECCENTRICITY_TYPE_AT_UPPER_FLANGE, ECCENTRICITY_TYPE_NONE, ECCENTRICITY_TYPE_USER_VALUE = range(4)
class ActionCategoryType(Enum):
'''
Load Case Action Category
Expand Down
10 changes: 3 additions & 7 deletions RFEM/initModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ def __init__(self,
cModel = Client(new, transport=trans)
else:
modelIndex = 0
for i,j in enumerate(modelLs):
if modelLs[i] == model_name:
for i,j in enumerate(modelLs.name):
if modelLs.name[i] == model_name:
modelIndex = i
new = client.service.get_model(modelIndex) + 'wsdl'
cModel = Client(new, transport=trans)
Expand Down Expand Up @@ -186,11 +186,7 @@ def insertSpaces(lst: list):
Add spaces between list of numbers.
Returns list of values.
'''
strLst = ''
for i in lst:
strLst += str(i) + ' '
# remove trailing space
return strLst[:-1]
return ' '.join(str(item) for item in lst)

def Calculate_all(generateXmlSolverInput: bool = False):
'''
Expand Down
46 changes: 46 additions & 0 deletions UnitTests/test_initModel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#########################################################
## This is the unit test template.
## All good practices and requirements related to unit tests
## will be recorded here. Feel free to add whatever you feel
## as important or new to unit tests and testing procedure.
#########################################################

# Name of the test module/file starts with test_...
# Start the unit test by copying the content of this file
# to ensure that the latest requirements are met.

# import only used modules
# avoid wild-card import (from RFEM.enums import *) if possible
import os
import sys
PROJECT_ROOT = os.path.abspath(os.path.join(
os.path.dirname(__file__),
os.pardir)
)
sys.path.append(PROJECT_ROOT)

import pytest
from RFEM.initModel import insertSpaces
# Unused imports are displayed in dark green as one below.
from RFEM.enums import MemberType

# When running tests individually the Model needs to be explicitly initialized.
# If all tests are executed together this expresion is False.
#if Model.clientModel is None:
# Model()

# 'pytestmark' sets same parameters (in this case 'skipif') to all functions in the module or class at once.
#pytestmark = pytest.mark.skipif(CheckIfMethodOrTypeExists(Model...

# Use 'skipif' if you wish to skip individual test function conditionally
#@pytest.mark.skipif(CheckIfMethodOrTypeExists(Model.clientModel,'set_model_settings_and_options', True), reason="set_model_settings_and_options not in RFEM yet")

# Name of the test function starts with test_...
# If no specific need to atomize the testing procedure, pack as much funtionality as possible in one test function.
# Write sepatate test when used method/type is not in RFEM yet, to be able to skip it for example.
def test_insertSpaces():
"""
Test conversion of list to string with spaces between items
"""
assert insertSpaces([1, 2, 3]) == "1 2 3"

69 changes: 69 additions & 0 deletions UnitTests/test_steelBoundaryConditions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import sys
import os
import pytest
PROJECT_ROOT = os.path.abspath(os.path.join(
os.path.dirname(__file__),
os.pardir)
)
sys.path.append(PROJECT_ROOT)

# Import der Bibliotheken
from RFEM.enums import *
from RFEM.initModel import Model, SetAddonStatus, CheckIfMethodOrTypeExists
from RFEM.TypesForSteelDesign.steelBoundaryConditions import *

if Model.clientModel is None:
Model()

@pytest.mark.skipif(CheckIfMethodOrTypeExists(Model.clientModel,'ns0:steel_boundary_conditions', True), reason="Type ns0:steel_boundary_conditions not in RFEM GM yet")

def test_steelEffectiveLengths():

Model.clientModel.service.begin_modification()

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

SteelBoundaryConditions(1, [True, "BCTEST_1"], '1', '', True, True, True,

nodal_supports= [
[None, SteelBoundaryConditionsSupportType.SUPPORT_TYPE_FIXED_IN_Y_AND_TORSION, False, True, False, True, False, False, False,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SteelBoundaryConditionsEccentricityTypeZ.ECCENTRICITY_TYPE_USER_VALUE, 0.0, 0.0, 0.0, ""],

[None, SteelBoundaryConditionsSupportType.SUPPORT_TYPE_FIXED_IN_Y_AND_TORSION, False, True, False, True, False, False, False,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SteelBoundaryConditionsEccentricityTypeZ.ECCENTRICITY_TYPE_USER_VALUE, 0.0, 0.0, 0.0, ""]
],
member_hinges=[
["Start", False, False, False, False, False, False, False, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ""],
["End", False, False, False, False, False, False, False, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ""]
]
)

SteelBoundaryConditions(2, [True, "BCTEST_2"], '', '', True, True, True,

nodal_supports= [
[None, SteelBoundaryConditionsSupportType.SUPPORT_TYPE_FIXED_IN_Y_AND_TORSION, False, True, False, True, False, False, False,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SteelBoundaryConditionsEccentricityTypeZ.ECCENTRICITY_TYPE_USER_VALUE, 0.0, 0.0, 0.0, ""],

[None, SteelBoundaryConditionsSupportType.SUPPORT_TYPE_FIXED_IN_Y_AND_TORSION, False, True, False, True, False, False, False,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SteelBoundaryConditionsEccentricityTypeZ.ECCENTRICITY_TYPE_USER_VALUE, 0.0, 0.0, 0.0, ""],

[None, SteelBoundaryConditionsSupportType.SUPPORT_TYPE_FIXED_IN_Y_AND_TORSION, False, True, False, True, False, False, False,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SteelBoundaryConditionsEccentricityTypeZ.ECCENTRICITY_TYPE_USER_VALUE, 0.0, 0.0, 0.0, ""]
],
member_hinges=[
["Start", False, False, False, False, False, False, False, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ""],
["Inter.", False, False, False, False, False, False, False, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ""],
["End", True, False, False, True, False, False, True, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ""]
]
)

bc_1 = Model.clientModel.service.get_steel_boundary_conditions(1)

assert bc_1.no == 1
assert bc_1.nodal_supports[0][0][0] == 0

bc_2 = Model.clientModel.service.get_steel_boundary_conditions(2)

assert bc_2.member_hinges[0][1][1] == "Inter."

Model.clientModel.service.finish_modification()

0 comments on commit 4983743

Please sign in to comment.