diff --git a/RFEM/TypesForSolids/solidContact.py b/RFEM/TypesForSolids/solidContact.py index ece207bf..cad321f4 100644 --- a/RFEM/TypesForSolids/solidContact.py +++ b/RFEM/TypesForSolids/solidContact.py @@ -1,11 +1,37 @@ from RFEM.initModel import Model, clearAtributes +from RFEM.enums import SolidContactPerpendicularType, SolidContactParallelType class SolidContact(): def __init__(self, no: int = 1, + perpendicular_contact = SolidContactPerpendicularType.FAILURE_UNDER_TENSION, + parallel_contact = SolidContactParallelType.FULL_FORCE_TRANSMISSION, + contact_parameters = None, + solids = '', comment: str = '', params: dict = None, model = Model): + """ + Solid Contact + + Args: + no (int, optional): Numbers + perpendicular_contact (enum, optional): Contact parpendicualr to surfaces + parallel_contact (enum, optional): Contact paralles to surfaces + contact_parameters (list, optional): Contact parameters. + RIGID_FRICTION: [friction_coefficient] + RIGID_FRICTION_LIMIT: [limit_stress] + ELASTIC_FRICTION: [shear_stiffness, friction_coefficient] + ELASTIC_FRICTION_LIMIT: [shear_stiffness, limit_stress] + ELASTIC_SOLID_BEHAVIOR: [shear_stiffness] + solids (str, optional): Assigned to solids + comment (str, optional): Comment + params (dict, optional): Any WS Parameter relevant to the object and its value in form of a dictionary + model (class, optional): Model instance + + Raises: + ValueError: There are no paramters for given parallel contact. + """ # Client model | Solid Contact clientObject = model.clientModel.factory.create('ns0:solid_contacts') @@ -16,6 +42,31 @@ def __init__(self, # Solid Contact No. clientObject.no = no + # Contact Perpendicular to Surface + clientObject.perpendicular_to_surface = perpendicular_contact.name + + # Contact Paralle to Surface + clientObject.parallel_to_surface = parallel_contact.name + + # Contact Parameters + if parallel_contact == SolidContactParallelType.RIGID_FRICTION: + clientObject.friction_coefficient = contact_parameters[0] + elif parallel_contact == SolidContactParallelType.RIGID_FRICTION_LIMIT: + clientObject.limit_stress = contact_parameters[0] + elif parallel_contact == SolidContactParallelType.ELASTIC_FRICTION: + clientObject.shear_stiffness = contact_parameters[0] + clientObject.friction_coefficient = contact_parameters[1] + elif parallel_contact == SolidContactParallelType.ELASTIC_FRICTION_LIMIT: + clientObject.shear_stiffness = contact_parameters[0] + clientObject.limit_stress = contact_parameters[1] + elif parallel_contact == SolidContactParallelType.ELASTIC_SOLID: + clientObject.shear_stiffness = contact_parameters[0] + elif contact_parameters: + raise ValueError(f'There are no parameters for contact {parallel_contact.name}') + + # Assigned to Solids + clientObject.solids = solids + # Comment clientObject.comment = comment diff --git a/RFEM/TypesForSolids/solidGas.py b/RFEM/TypesForSolids/solidGas.py index 86715fbb..558abef6 100644 --- a/RFEM/TypesForSolids/solidGas.py +++ b/RFEM/TypesForSolids/solidGas.py @@ -3,9 +3,24 @@ class SolidGas(): def __init__(self, no: int = 1, + pressure: float = 100000, + temperature: float = 283.15, + solids: str = '', comment: str = '', params: dict = None, model = Model): + """ + Gas Solids + + Args: + no (int, optional): Number + pressure (float, optional): Preassure in Pascals + temperature (float, optional): Temperature in Kelvins + solids (str, optional): Assigned to solids + comment (str, optional): Comment + params (dict, optional): Any WS Parameter relevant to the object and its value in form of a dictionary + model (class, optional): Model instance + """ # Client model | Solid Gas clientObject = model.clientModel.factory.create('ns0:solid_gas') @@ -16,6 +31,15 @@ def __init__(self, # Solid Gas No. clientObject.no = no + # Solid Gas Pressure + clientObject.pressure = pressure + + # Solid Gas Temperature + clientObject.temperature = temperature + + # Assigned to Solids + clientObject.solids = solids + # Comment clientObject.comment = comment diff --git a/RFEM/TypesForSolids/solidMeshRefinement.py b/RFEM/TypesForSolids/solidMeshRefinement.py index f580c9cc..315e39fe 100644 --- a/RFEM/TypesForSolids/solidMeshRefinement.py +++ b/RFEM/TypesForSolids/solidMeshRefinement.py @@ -3,9 +3,22 @@ class SolidMeshRefinement(): def __init__(self, no: int = 1, + target_length: float = 0.15, + solids: str = '', comment: str = '', params: dict = None, model = Model): + """ + Solids Mesh Refinemet + + Args: + no (int, optional): Number + target_length (float, optional): Target FE length + solids (str, optional): Assigned to solids + comment (str, optional): Comment + params (dict, optional): Any WS Parameter relevant to the object and its value in form of a dictionary + model (class, optional): Model instance + """ # Client model | Solid Mesh Refinement clientObject = model.clientModel.factory.create('ns0:solid_mesh_refinement') @@ -16,6 +29,12 @@ def __init__(self, # Solid Mesh Refinement No. clientObject.no = no + # Target FE length + clientObject.target_length = target_length + + # Assigned to solids + clientObject.solids = solids + # Comment clientObject.comment = comment diff --git a/RFEM/enums.py b/RFEM/enums.py index 8db2420c..a71d3120 100644 --- a/RFEM/enums.py +++ b/RFEM/enums.py @@ -1770,6 +1770,20 @@ class SurfaceEccentricityAlignment(Enum): ''' ALIGN_TOP, ALIGN_MIDDLE, ALIGN_BOTTOM = range(3) +class SolidContactPerpendicularType(Enum): + ''' + Solid Contact Perpendicular To Surfaces + ''' + FULL_FORCE_TRANSMISSION, FAILURE_UNDER_COMPRESSION, FAILURE_UNDER_TENSION = range(3) + + +class SolidContactParallelType(Enum): + ''' + Solid Contact Parallel To Surfaces + ''' + FAILURE_IF_CONTACT_PERPENDICULAR_TO_SURFACES_FAILED, FULL_FORCE_TRANSMISSION, RIGID_FRICTION, RIGID_FRICTION_LIMIT, \ + ELASTIC_FRICTION, ELASTIC_FRICTION_LIMIT, ELASTIC_SOLID = range(7) + class ActionCategoryType(Enum): ''' Load Case Action Category diff --git a/UnitTests/test_TypesForSolids.py b/UnitTests/test_TypesForSolids.py new file mode 100644 index 00000000..b2b2f8ac --- /dev/null +++ b/UnitTests/test_TypesForSolids.py @@ -0,0 +1,76 @@ +import sys +import os +PROJECT_ROOT = os.path.abspath(os.path.join( + os.path.dirname(__file__), + os.pardir) +) +sys.path.append(PROJECT_ROOT) + +import pytest +from RFEM.enums import SolidContactPerpendicularType, SolidContactParallelType +from RFEM.initModel import Model +from RFEM.TypesForSolids.solidGas import SolidGas +from RFEM.TypesForSolids.solidContact import SolidContact +from RFEM.TypesForSolids.solidMeshRefinement import SolidMeshRefinement + +if Model.clientModel is None: + Model() + +def test_types_for_solids(): + + Model.clientModel.service.delete_all() + Model.clientModel.service.begin_modification() + + SolidMeshRefinement(1, 0.23) + + SolidGas(1, 130000, 284) + + SolidContact(1, SolidContactPerpendicularType.FAILURE_UNDER_COMPRESSION, SolidContactParallelType.FAILURE_IF_CONTACT_PERPENDICULAR_TO_SURFACES_FAILED) + SolidContact(2, SolidContactPerpendicularType.FAILURE_UNDER_TENSION, SolidContactParallelType.FULL_FORCE_TRANSMISSION) + # TODO: bug 27938 + SolidContact(3, SolidContactPerpendicularType.FULL_FORCE_TRANSMISSION, SolidContactParallelType.RIGID_FRICTION, [2]) + #SolidContact(4, SolidContactPerpendicularType.FAILURE_UNDER_COMPRESSION, SolidContactParallelType.RIGID_FRICTION_LIMIT, [10000000]) + SolidContact(5, SolidContactPerpendicularType.FAILURE_UNDER_COMPRESSION, SolidContactParallelType.ELASTIC_FRICTION, [510, 0.5]) + #SolidContact(6, SolidContactPerpendicularType.FAILURE_UNDER_COMPRESSION, SolidContactParallelType.ELASTIC_FRICTION_LIMIT, [520, 11000000]) + SolidContact(7, SolidContactPerpendicularType.FAILURE_UNDER_COMPRESSION, SolidContactParallelType.ELASTIC_SOLID, [530]) + with pytest.raises(ValueError): + SolidContact(8, SolidContactPerpendicularType.FAILURE_UNDER_TENSION, SolidContactParallelType.FULL_FORCE_TRANSMISSION, [0.15]) + + Model.clientModel.service.finish_modification() + + solidMeshrefinement = Model.clientModel.service.get_solid_mesh_refinement(1) + assert round(solidMeshrefinement.target_length, 3) == 0.23 + + solidGas = Model.clientModel.service.get_solid_gas(1) + assert solidGas.pressure == 130000 + assert round(solidGas.temperature) == 284 + + contact = Model.clientModel.service.get_solid_contacts(1) + assert contact.perpendicular_to_surface == SolidContactPerpendicularType.FAILURE_UNDER_COMPRESSION.name + assert contact.parallel_to_surface == SolidContactParallelType.FAILURE_IF_CONTACT_PERPENDICULAR_TO_SURFACES_FAILED.name + + contact = Model.clientModel.service.get_solid_contacts(2) + assert contact.perpendicular_to_surface == SolidContactPerpendicularType.FAILURE_UNDER_TENSION.name + assert contact.parallel_to_surface == SolidContactParallelType.FULL_FORCE_TRANSMISSION.name + + contact = Model.clientModel.service.get_solid_contacts(3) + assert contact.parallel_to_surface == SolidContactParallelType.RIGID_FRICTION.name + #assert round(contact.friction_coefficient, 2) == 0.5 + + #contact = Model.clientModel.service.get_solid_contacts(4) + #assert contact.parallel_to_surface == SolidContactParallelType.RIGID_FRICTION_LIMIT.name + #assert round(contact.limit_stress) == 10000000 + + contact = Model.clientModel.service.get_solid_contacts(5) + assert contact.parallel_to_surface == SolidContactParallelType.ELASTIC_FRICTION.name + assert round(contact.shear_stiffness) == 510 + #assert round(contact.friction_coefficient, 2) == 0.2 + + #contact = Model.clientModel.service.get_solid_contacts(6) + #assert contact.parallel_to_surface == SolidContactParallelType.ELASTIC_FRICTION_LIMIT.name + #assert round(contact.shear_stiffness) == 520 + #assert round(contact.limit_stress) == 11000000 + + contact = Model.clientModel.service.get_solid_contacts(7) + assert contact.parallel_to_surface == SolidContactParallelType.ELASTIC_SOLID.name + assert round(contact.shear_stiffness) == 530