从变形的测试对象中提取节点坐标(abaqus-python) [英] Extract nodal coordinates from the deformed testsubject (abaqus-python)

查看:890
本文介绍了从变形的测试对象中提取节点坐标(abaqus-python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个python脚本来从ODB文件(从abaqus)中提取节点坐标。
到目前为止,我想出了下面附带的代码(不要介意我在#后面加上的额外信息,有时只是为了让我可以跟踪自己在做什么)

I am trying to make a python script to extract the nodal coordinates from the ODB file (from abaqus). So far i have come up with the code attached below (don't mind the extra information i put behind the #, sometimes it's just so i can keep track of what i'm doing)

问题是我提取的坐标是来自未变形测试对象的坐标。我需要来自变形测试对象的节点坐标。
有人可以帮助我如何使用python代码获取此信息吗?

The problem is that the coordinates i extract are those from the undeformed test subject. and i need the coordinates of the nodes from the deformed test subject. Can somebody help me with how i reach this information using python code?

from abaqus import *
from abaqusConstants import *
import __main__
import section
import regionToolset
import displayGroupMdbToolset as dgm
import part
import material
import assembly
import step
import interaction
import load
import mesh
import optimization
import job
import sketch
import visualization
import xyPlot
import displayGroupOdbToolset as dgo
import connectorBehavior
import shutil
import os

import sys
from odbAccess import openOdb

for ODBname in os.listdir("D:/r0333338/Documents/MP/nodal_files_genereren/OBD"): # this is where all your ODB files are located #t hier wordt ook de odb file gekozen die geopend zal worden
    SUBname = ODBname[1:3]  # My subject ID is saved in the ODB name - this helps me create the file #woerdt er hier de 3e tot6e letter van de ODBname gepakt ?
    print 'Current File: '+ODBname #voor check welke file er gebruikt wordt #t (ZIT '.odb' hier bij in ?)
    ODBnamefull = 'D:/r0333338/Documents/MP/nodal_files_genereren/OBD/'+ODBname   # Full path to the ODB file, otherwise abaqus tries to find it in default work directory
    odb = openOdb(path=ODBnamefull)  #open the ODB file

    assembly = odb.rootAssembly     #t declareren van assembly?

    session.viewports['Viewport: 1'].odbDisplay.setFrame(step=0, frame=1)
    numNodes = 0   #t num nodes op nul zetten 
    f = open("D:/r0333338/Documents/MP/nodal_files_genereren/ODBoutput/nodal.txt", "w") #indien het bestand al bestaat moet er "a" staan ipv "w"
    for name, instance in assembly.instances.items(): #t 'name' is naam van elke part van in de assembly ?
        n = len(instance.nodes) #t tellen van hoeveelheid nodes
        print 'Number of nodes of instance %s: %d' % (name, n) #moet niet in de file staan, kan eigenlijk weggelaten worden. (maar is een goede check?)
        numNodes = numNodes + n #tellen van totaal aantal nodes (globaal over alle parts) maar is eigenlijk niet nodig?
        f.write( "*Part, name=Part-1" + "\n")#moet erin staan volgens de MatchId regels
        f.write( "*Nodes" + "\n")            #moet erin staan volgens de MatchId regels

        if instance.embeddedSpace == THREE_D: #indien het 3D is
            print ' X Y Z' #moet niet in de file staan, maar is een goede check om te zien waar we zitten
            for node in instance.nodes:
                #print node #printen van node
                f.write( str(node.label) + ";" ) #schrijven van nodenummer
                f.write(str(node.coordinates[0]) + ";" + str(node.coordinates[1]) + ";" + str(node.coordinates[2]) + "\n") #schrijven van coordinaten [X;Y;Z] en enter
        else: #indien het 2D is
            print ' X Y' ';0' #moet niet in de file staan, maar is een goede check om te zien waar we zitten
            for node in instance.nodes:
                #print node #printen van node
                f.write( str(node.label) + ";" )
                f.write(str(node.coordinates[0]) + ";" + str(node.coordinates[1]) + ";" + str(node.coordinates[2]) + "\n") #schrijven van coordinaten [X;Y;Z] en enter
        f.write( "*End Part" ) #moet erin staan volgens de MatchId regels
    f.close()


推荐答案

获取位移字段:

 u=odb.steps['Step-1'].frames[-1].fieldOutputs['U']

然后 u.values 是所有节点值:

 u.values[i].data -> array of (ux,uy,uz)
 u.values[i].nodeLabel  -> node label

然后您就可以像这样抓住原始位置:

then you grab the original position like this:

 instance.getNodeFromLabel(u.values[i].nodeLabel).coordinates

您也可以直接将变形坐标作为字段输出,但是在运行分析时需要请求 COORD 输出。

You can also directly get the deformed coordinate as a field output, but you need to request COORD output when you run the analysis.

这篇关于从变形的测试对象中提取节点坐标(abaqus-python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆