def recurseTree(componentNodes, gComponentList, adams, odbName): """ Recursively search assembly tree as represented by CAD metrics file. """ for node in componentNodes: cID = node.attrib.get('ComponentInstanceID') eID = node.attrib.get('FEAElementID').upper() if eID == '': # Name is used for unique name in model-based, not PSOLIDs # This file is updated in model-based before PP to replace # non-unique name with internal Abaqus unique name. eID = node.attrib.get('Name').upper() if adams and eID != odbName: continue aComponentData = ComponentData(cID, eID) # create a new ComponentData mtrl = {} if node.attrib.get('Type') == 'PART': aComponentData.CadType = 'PART' componentMaterial = node.attrib.get('MaterialID') if componentMaterial: material_properties.get_props_from_material_library( [componentMaterial.lower()], mtrl) aComponentData.Allowables = \ allowable_stress_levels.AnalysisMaterialPropertiesAllowables(componentMaterial) allowable_stress_levels.compute_allowable_stress_levels( allowable_stress_levels. MECHANICAL_INFINITE_CYCLES_INDICATOR, mtrl[componentMaterial.lower()], aComponentData.Allowables) # The material library properties are in Pa. The FEA run would be in N, mm, MPa. # Must convert the allowables to MPa; otherwise, the factor of safety would be wrong. allowable_stress_levels.convert_allowables_from_Pa_to_MPa( aComponentData.Allowables) else: # Get direct descending children (in adams asm is treated as merged part) if gConfigurationID == cID: aComponentData.IsConfigurationID = True children = [] for c in node.findall('./Component'): children.append(c.attrib.get('ComponentInstanceID')) componentMaterial = c.attrib.get('MaterialID') if adams: material_properties.get_props_from_material_library( [componentMaterial.lower()], mtrl) aComponentData.Allowables = \ allowable_stress_levels.AnalysisMaterialPropertiesAllowables(componentMaterial) allowable_stress_levels.compute_allowable_stress_levels( allowable_stress_levels. MECHANICAL_INFINITE_CYCLES_INDICATOR, mtrl[componentMaterial.lower()], aComponentData.Allowables) else: aComponentData.Children = children aComponentData.CadType = 'ASSEMBLY' recurseTree(node, gComponentList, adams, odbName) gComponentList[aComponentData.ComponentID] = aComponentData return
def recurseTree(componentNodes, gComponentList, adams, odbName): """ Recursively search assembly tree as represented by CAD metrics file. """ for node in componentNodes: cID = node.attrib.get('ComponentInstanceID') eID = node.attrib.get('FEAElementID').upper() if eID == '': # Name is used for unique name in model-based, not PSOLIDs # This file is updated in model-based before PP to replace # non-unique name with internal Abaqus unique name. eID = node.attrib.get('Name').upper() if adams and eID != odbName: continue aComponentData = ComponentData(cID, eID) # create a new ComponentData mtrl = {} if node.attrib.get('Type') == 'PART': aComponentData.CadType = 'PART' componentMaterial = node.attrib.get('MaterialID') if componentMaterial: material_properties.get_props_from_material_library([componentMaterial.lower()], mtrl) aComponentData.Allowables = \ allowable_stress_levels.AnalysisMaterialPropertiesAllowables(componentMaterial) allowable_stress_levels.compute_allowable_stress_levels( allowable_stress_levels.MECHANICAL_INFINITE_CYCLES_INDICATOR, mtrl[componentMaterial.lower()], aComponentData.Allowables) # The material library properties are in Pa. The FEA run would be in N, mm, MPa. # Must convert the allowables to MPa; otherwise, the factor of safety would be wrong. allowable_stress_levels.convert_allowables_from_Pa_to_MPa(aComponentData.Allowables) else: # Get direct descending children (in adams asm is treated as merged part) if gConfigurationID == cID: aComponentData.IsConfigurationID = True children = [] for c in node.findall('./Component'): children.append(c.attrib.get('ComponentInstanceID')) componentMaterial = c.attrib.get('MaterialID') if adams: material_properties.get_props_from_material_library([componentMaterial.lower()], mtrl) aComponentData.Allowables = \ allowable_stress_levels.AnalysisMaterialPropertiesAllowables(componentMaterial) allowable_stress_levels.compute_allowable_stress_levels( allowable_stress_levels.MECHANICAL_INFINITE_CYCLES_INDICATOR, mtrl[componentMaterial.lower()], aComponentData.Allowables) else: aComponentData.Children = children aComponentData.CadType = 'ASSEMBLY' recurseTree(node, gComponentList, adams, odbName) gComponentList[aComponentData.ComponentID] = aComponentData return
def generateMtrlRef(asminfo, thermalSetXML, rigidParts, rigidPartDensities, conv): logger = logging.getLogger() mtrlRef = {} # Set to contain a dictionary for each material materials = [] logger.info("**********************************************************************************" + '\n') logger.info("Grabbing properties of each material from the material library" + '\n') logger.info('Material properties that will be grabbed are density, modulus of elasticity, poisson\'s ratio,\n') logger.info('ultimate tensile strength, fatigue strength, yield strength\n') # Set of names of material properties to get mtrlProps = ["density", "mechanical__modulus_elastic", "mechanical__ratio_poissons", "mechanical__strength_tensile_ultimate", "mechanical__strength_fatigue", "mechanical__strength_tensile_yield"] if thermalSetXML: logger.info('coefficient of thermal expansion, conductivity, specific heat\n') mtrlProps.extend(["thermal__coefficient_expansion_linear", "thermal__conductivity", "thermal__capacity_specific_heat"]) for child in asminfo.componentsdict.values(): if child.cyphyid == asminfo.root.cyphyid: continue # Ignore root entry rigidPart = False instName = STR.upper(child.cadmodelname) try: for key in rigidParts: if key == instName: rigidPart = True for rigidPartDensityNumAndName in rigidPartDensities: if rigidPartDensityNumAndName[0] == key: rigidDensity = rigidPartDensityNumAndName[1] except: cad_library.exitwitherror('Rigid part definition discrepancy.', -1, 'AbaqusDict.py') if child.is_assembly(): continue material = child.materialname.lower() if material == '': cad_library.exitwitherror('ERROR: Missing material for part ' + str(instName) + ' in metrics xml.', -1, 'AbaqusDict.py') if rigidPart: mtrlRef['RigidMaterial'] = material_properties.AnalysisMaterialProperties('RigidMaterial') mtrlRef['RigidMaterial'].density = rigidDensity mtrlRef['RigidMaterial'].density_unit = "kg/mm^3" mtrlRef['RigidMaterial'].density_defined = True mtrlRef['RigidMaterial'].mechanical__modulus_elastic = 200000 mtrlRef['RigidMaterial'].mechanical__modulus_elastic_unit = "MPa" mtrlRef['RigidMaterial'].mechanical__modulus_elastic_defined = True mtrlRef['RigidMaterial'].mechanical__ratio_poissons = 0.3 mtrlRef['RigidMaterial'].mechanical__ratio_poissons_defined = True mtrlRef['RigidMaterial'].mechanical__strength_tensile_ultimate = 400 mtrlRef['RigidMaterial'].mechanical__strength_tensile_ultimate_unit = "MPa" mtrlRef['RigidMaterial'].mechanical__strength_tensile_ultimate_defined = True mtrlRef['RigidMaterial'].mechanical__strength_fatigue = 200 mtrlRef['RigidMaterial'].mechanical__strength_fatigue_unit = "MPa" mtrlRef['RigidMaterial'].mechanical__strength_fatigue_defined = True mtrlRef['RigidMaterial'].mechanical__strength_tensile_yield = 250 mtrlRef['RigidMaterial'].mechanical__strength_tensile_yield_unit = "MPa" mtrlRef['RigidMaterial'].mechanical__strength_tensile_yield_defined = True else: materials.append(material) logger.info('Grabbing material properties of ' + str(material) + ' for the part ' + str(instName)) logger.info("**********************************************************************************" + '\n') # At this point all materials have been appended to 'materials' material_properties.get_props_from_material_library(materials, mtrlRef) # Make sure all material properties are provided for k in mtrlRef.keys(): m = mtrlRef[k] structprops = [m.density_defined, m.mechanical__modulus_elastic_defined, m.mechanical__ratio_poissons_defined, m.mechanical__strength_tensile_yield_defined, m.mechanical__strength_tensile_ultimate_defined, m.mechanical__strength_fatigue_defined] if not any(structprops): cad_library.exitwitherror('Structural material properties not fully defined for ' + k, -1, 'AbaqusDict.py') if thermalSetXML: thermalprops = [m.thermal__coefficient_expansion_linear_defined, m.thermal__conductivity, m.thermal__capacity_specific_heat] if not any(thermalprops): cad_library.exitwitherror('Thermal material properties not fully define for ' + k, -1, 'AbaqusDict.py') # Convert the extracted properties to units to be used in Abaqus. unit_utils.convert_material_properties_given_conversion_dict(mtrlRef, conv) return mtrlRef
def generateMtrlRef(asminfo, thermalSetXML, rigidParts, rigidPartDensities, conv): logger = logging.getLogger() mtrlRef = {} # Set to contain a dictionary for each material materials = [] logger.info( "**********************************************************************************" + '\n') logger.info( "Grabbing properties of each material from the material library" + '\n') logger.info( 'Material properties that will be grabbed are density, modulus of elasticity, poisson\'s ratio,\n' ) logger.info( 'ultimate tensile strength, fatigue strength, yield strength\n') # Set of names of material properties to get mtrlProps = [ "density", "mechanical__modulus_elastic", "mechanical__ratio_poissons", "mechanical__strength_tensile_ultimate", "mechanical__strength_fatigue", "mechanical__strength_tensile_yield" ] if thermalSetXML: logger.info( 'coefficient of thermal expansion, conductivity, specific heat\n') mtrlProps.extend([ "thermal__coefficient_expansion_linear", "thermal__conductivity", "thermal__capacity_specific_heat" ]) for child in asminfo.componentsdict.values(): if child.cyphyid == asminfo.root.cyphyid: continue # Ignore root entry rigidPart = False instName = STR.upper(child.cadmodelname) try: for key in rigidParts: if key == instName: rigidPart = True for rigidPartDensityNumAndName in rigidPartDensities: if rigidPartDensityNumAndName[0] == key: rigidDensity = rigidPartDensityNumAndName[1] except: cad_library.exitwitherror('Rigid part definition discrepancy.', -1, 'AbaqusDict.py') if child.is_assembly(): continue material = child.materialname.lower() if material == '': cad_library.exitwitherror( 'ERROR: Missing material for part ' + str(instName) + ' in metrics xml.', -1, 'AbaqusDict.py') if rigidPart: mtrlRef[ 'RigidMaterial'] = material_properties.AnalysisMaterialProperties( 'RigidMaterial') mtrlRef['RigidMaterial'].density = rigidDensity mtrlRef['RigidMaterial'].density_unit = "kg/mm^3" mtrlRef['RigidMaterial'].density_defined = True mtrlRef['RigidMaterial'].mechanical__modulus_elastic = 200000 mtrlRef['RigidMaterial'].mechanical__modulus_elastic_unit = "MPa" mtrlRef['RigidMaterial'].mechanical__modulus_elastic_defined = True mtrlRef['RigidMaterial'].mechanical__ratio_poissons = 0.3 mtrlRef['RigidMaterial'].mechanical__ratio_poissons_defined = True mtrlRef[ 'RigidMaterial'].mechanical__strength_tensile_ultimate = 400 mtrlRef[ 'RigidMaterial'].mechanical__strength_tensile_ultimate_unit = "MPa" mtrlRef[ 'RigidMaterial'].mechanical__strength_tensile_ultimate_defined = True mtrlRef['RigidMaterial'].mechanical__strength_fatigue = 200 mtrlRef['RigidMaterial'].mechanical__strength_fatigue_unit = "MPa" mtrlRef[ 'RigidMaterial'].mechanical__strength_fatigue_defined = True mtrlRef['RigidMaterial'].mechanical__strength_tensile_yield = 250 mtrlRef[ 'RigidMaterial'].mechanical__strength_tensile_yield_unit = "MPa" mtrlRef[ 'RigidMaterial'].mechanical__strength_tensile_yield_defined = True else: materials.append(material) logger.info('Grabbing material properties of ' + str(material) + ' for the part ' + str(instName)) logger.info( "**********************************************************************************" + '\n') # At this point all materials have been appended to 'materials' material_properties.get_props_from_material_library(materials, mtrlRef) # Make sure all material properties are provided for k in mtrlRef.keys(): m = mtrlRef[k] structprops = [ m.density_defined, m.mechanical__modulus_elastic_defined, m.mechanical__ratio_poissons_defined, m.mechanical__strength_tensile_yield_defined, m.mechanical__strength_tensile_ultimate_defined, m.mechanical__strength_fatigue_defined ] if not any(structprops): cad_library.exitwitherror( 'Structural material properties not fully defined for ' + k, -1, 'AbaqusDict.py') if thermalSetXML: thermalprops = [ m.thermal__coefficient_expansion_linear_defined, m.thermal__conductivity, m.thermal__capacity_specific_heat ] if not any(thermalprops): cad_library.exitwitherror( 'Thermal material properties not fully define for ' + k, -1, 'AbaqusDict.py') # Convert the extracted properties to units to be used in Abaqus. unit_utils.convert_material_properties_given_conversion_dict(mtrlRef, conv) return mtrlRef