使用Python脚本从Abaqus ODB节点集提取HFL Magnitude返回空列表的问题求助
使用Python脚本从Abaqus ODB节点集提取HFL Magnitude返回空列表的问题求助
我最近在写Python脚本,想从Abaqus ODB文件的指定节点集里提取热通量的HFL Magnitude数据,但脚本运行后总是返回空列表。但有意思的是,用几乎完全相同的逻辑提取温度NT11的时候,就能正常拿到数据,完全没问题。
下面是我用来提取HFL的脚本,后面附上了能正常工作的NT11提取脚本,恳请各位帮我排查下问题所在:
提取HFL的脚本
from odbAccess import * import numpy as np # Path to the ODB file path0 = 'E:/Job-TCMT.odb' # Open the ODB file odb = openOdb(path=path0) # Name of the node sets nodeset_1 = 'NODESET-ZCT-1' nodeset_2 = 'NODESET-ZCT-2' # Extract the node sets mySet_1 = odb.rootAssembly.instances['PART-1-1'].nodeSets[nodeset_1] mySet_2 = odb.rootAssembly.instances['PART-1-1'].nodeSets[nodeset_2] # Extract the last frame of the step lastFrame = odb.steps['Step-1'].frames[-1] # Heat flux field (HFL magnitude) HFL = lastFrame.fieldOutputs['HFL'] # Get heat flux values for the two node sets mySetHFL_1 = HFL.getSubset(region=mySet_1) mySetHFL_2 = HFL.getSubset(region=mySet_2) # Retrieve heat flux values for each node set hfl_values_1 = [v.magnitude for v in mySetHFL_1.values] hfl_values_2 = [v.magnitude for v in mySetHFL_2.values] # Combine heat flux values from both sets all_hfl_values = hfl_values_1 + hfl_values_2 # Calculate the average heat flux HFL_moyenne_arith = np.mean(all_hfl_values) # Display the result print('The average heat flux (arithmetic) =', HFL_moyenne_arith) # Close the ODB file odb.close()
能正常工作的NT11提取脚本
from odbAccess import * import numpy as np # Path to the ODB file path0 = 'E:/Job-TCMT.odb' # Open the ODB file odb = openOdb(path=path0) # Name of the node sets nodeset_1 = 'NODESET-ZCT-1' nodeset_2 = 'NODESET-ZCT-2' # Extract the node sets mySet_1 = odb.rootAssembly.instances['PART-1-1'].nodeSets[nodeset_1] mySet_2 = odb.rootAssembly.instances['PART-1-1'].nodeSets[nodeset_2] # Extract the last frame of the step lastFrame = odb.steps['Step-1'].frames[-1] # Temperature field (NT11) TEMP = lastFrame.fieldOutputs['NT11'] # Get temperature values for the two node sets mySetTemp_1 = TEMP.getSubset(region=mySet_1) mySetTemp_2 = TEMP.getSubset(region=mySet_2) # Retrieve temperatures for each node set temp_values_1 = [v.data for v in mySetTemp_1.values] temp_values_2 = [v.data for v in mySetTemp_2.values] # Combine temperatures from both sets all_temp_values = temp_values_1 + temp_values_2 # Calculate the average temperature Tint_moyenne_arith = np.mean(all_temp_values) # Display the result print('The average temperature (arithmetic) =', Tint_moyenne_arith) # Close the ODB file odb.close()
备注:内容来源于stack exchange,提问作者Wahid Tarhouni
相关产品推荐
相关产品推荐

