不知火舞的被虐|伊人天伊人天天综合网|博洛尼亚天气|任你懆这里只有精品4|久久美日韩精品久久|掌中之物漫画免费阅读观看|0丨d老妇

ABAQUS的python提取節點接觸壓力和變形后節點坐標?

瀏覽:2810 回答:1

from odbAccess import *

import csv


# 打開ODB文件

odb_path = 'Job-3.odb' # 替換為你的ODB文件路徑

odb = openOdb(path=odb_path)


# 定義接觸對名稱

contact_pair_name = 'CP-1' # 替換為你的接觸對名稱


# 定義輸出文件

output_file = 'contact_stress_data.csv' # 輸出文件路徑


# 打開輸出文件并寫入表頭

with open(output_file, 'w', newline='') as f:

   writer = csv.writer(f)

   writer.writerow(['Frame ID', 'Instance Name', 'Node Label', 'X Coordinate', 'Y Coordinate', 'Z Coordinate', 'Contact Stress (CPRESS)'])


   # 獲取特定分析步

   step_name = 'Step-1'

   if step_name in odb.steps:

       step = odb.steps[step_name]


       # 獲取最后一幀

       last_frame = step.frames[-1]

       frame_id = last_frame.frameId


       # 獲取接觸應力場輸出

       contact_stress_field_name = f'CPRESS  {contact_pair_name}'

       if contact_stress_field_name in last_frame.fieldOutputs:

           contact_stress = last_frame.fieldOutputs[contact_stress_field_name]


           # 創建一個集合來存儲已經提取過的節點

           extracted_nodes = set()


           # 遍歷接觸應力場中的每個值

           for value in contact_stress.values:

               instance_name = value.instance.name # 實例名稱

               node_label = value.nodeLabel # 節點標簽

               stress_value = value.data # 接觸應力值


               # 獲取節點對象

               node = value.instance.nodes[node_label - 1]


               # 獲取節點的變形后坐標

               x, y, z = node.coordinates


               # 創建一個唯一的標識符來區分不同實例中的相同節點

               unique_node_id = (instance_name, node_label)


               # 檢查是否已經提取過這個節點的數據

               if unique_node_id not in extracted_nodes:

                   # 將數據寫入文件

                   writer.writerow([frame_id, instance_name, node_label, x, y, z, stress_value])

                   # 將這個節點添加到已提取的集合中

                   extracted_nodes.add(unique_node_id)

       else:

           print(f"Warning: Contact stress field '{contact_stress_field_name}' not found in the last frame.")

   else:

       print(f"Error: Step '{step_name}' not found in the ODB file.")


# 關閉ODB文件

odb.close()


print(f"接觸應力數據已保存到 {output_file}")

這個程序提取后的節點坐標與在查詢節點時節點的坐標對應不上,接觸應力是一樣的。程序是哪里有問題么?


邀請回答 我來回答

當前暫無回答

回答可獲贈 200金幣

沒解決?試試專家一對一服務

換一批
    App下載
    技術鄰APP
    工程師必備
    • 項目客服
    • 培訓客服
    • 平臺客服

    TOP