在 abaqus 中为几个 odbs 沿路径提取应力

Extacting stresses along path for several odbs in abaqus

我在 abaqus 中建模了 5 个模型。现在我想通过 Abaqus python 脚本打开 odbs 并提取不同路径中的数据。但是我不能一起打开odbs。怎么写才能把所有的odbs一起打开呢?我可以创建路径,但如何从我的 5 模型的相同路径中提取应力?提前致谢。

import visualization
from abaqus import *
from odbAccess import openOdb
#-----------------------------
l1 = [200.0,200.0]  
height = [1000.0] 
l2 = [200.0,200.0]  
T1 = [20.0,25.0]   
delta_t= [20.0,25.0]
multiplied_list = [element * 4 for element in delta_t]
partition_datum_plane_XY = [750.0,1080.0,1250.0,1786.0]  
#------------------------------

# list of ODB-Files
odb_names = ['Para_Analysis_H_1000_W_200_t1_40_T1_20.odb','Para_Analysis_H_1000_W_200_t1_50_T1_30.odb',
'Para_Analysis_H_1000_W_200_t1_30_T1_15.odb']  # Dummy list 
path='./'
odbs = [1]*len(odb_names); 
vips = [1]*len(odb_names); 
for s,odb_name in enumerate(odb_names):    
    print('\n\nlooping for %s ODB...'%odb_names)     
    vips[s] = session.Viewport(name='Girder Viewport_%d'%(s+1))     
    odbs[s] = session.openOdb(name=odb_name)

    path=session.Path(name='Path-1', type=POINT_LIST, expression=((l1[i], T1[i],partition_datum_plane_XY[0]), 
    (l1[i], T1[i],partition_datum_plane_XY[1]), (l1[i], t1[i],multiplied_list[i]+partition_datum_plane_XY[1]),
    (l1[i], t1[i],partition_datum_plane_XY[2])))
    
    pth=session.path['Path-1']
    vips[s].setValues(displayedObject=odbs[s])
    newXYData=session.XYDataFromPath(name=xyName,path=pth,
    includeIntersections=TRUE,
    shape=UNDEFORMED,
    labelType=TRUE_DISTANCE,
    step=1,
    frame=1,
    variable=(('S',INTEGRATION_POINT,((COMPONENT, 'S11' ),)),))
    session.writeXYReport(fileName='%s.txt'%name, xyData=(newXYData,))  

Abaqus 在 Repository 中存储一些特定类型的对象。因此,无论何时创建这些对象,该对象的名称都必须是唯一的。 Abaqus 对象示例,xy plotviewportspathsstepsmodels 等。

其次,要使用Abaqus特定的常量,比如DEFORMED、UNDEFORMED(capital variables), you have to importabaqusConstants`module.

我刚刚查看了您的代码并做了一些改动。

import odbAccess
from abaqus import *
from abaqusConstants import *
from viewerModules import *
from driverUtils import executeOnCaeStartup

#Variables
l1 = [200.0,200.0,200.0,200.0,200.0]  #Bottom flange length
height = [1000.0,1000.0,1000.0,1000.0,1000.0] #Total height
X_coord=0.0
Y_coord=0.0
Z_coord=0.0

# odb_names --> list of ODB names for which to access the data from
odb_names = ['Para_Analysis_H_1000_W_200_t1_40_T1_20.odb',
             'Para_Analysis_H_1000_W_200_t1_50_T1_30.odb',
             'Para_Analysis_H_1000_W_200_t1_30_T1_15.odb']
viewp = session.currentViewportName
viewport = session.viewports[viewp]
viewport.makeCurrent()
viewport.maximize()

# Creating the paths - You can change the expressions for the pah.
# These paths are specific to session and NOT to ODB. Hence, if you created once, 
# you can use it for any number of ODBs. Path name must be UNIQUE.
for i in range(len(l1)):
    session.Path(name='Path-1-Bottom-Upper-Side_%d'%(i+1), type=POINT_LIST, expression=
    ((l1[i],Y_coord,Z_coord), (l1[i]/2,Y_coord,Z_coord),))

    # session.Path(name='Path-1', type=POINT_LIST, expression=((l1[i], T1[i],partition_datum_plane_XY[0]), 
    #     (l1[i], T1[i],partition_datum_plane_XY[1]), (l1[i], t1[i],multiplied_list[i]+partition_datum_plane_XY[1]),
    #     (l1[i], t1[i],partition_datum_plane_XY[2])))

# Dummy list with length of odb_names list. In this we can store the ODB objects
odbs = [1]*len(odb_names);  count_plots = 0
for s,odb_name in enumerate(odb_names):
    print('\n\nlooping for %s ODB...'%odb_name)
    # Opening the ODB
    odbs[s] = session.openOdb(name=odb_name)

    # Setting the ODB to the viewport in DEFORMED state
    viewport.setValues(displayedObject=odbs[s])
    viewport.odbDisplay.display.setValues(plotState=(DEFORMED,))
    # Setting S11 component of stress tot he viewport
    viewport.odbDisplay.setPrimaryVariable(variableLabel='S', 
       outputPosition=INTEGRATION_POINT, refinement=(COMPONENT,'S11'))
    #--------------------------------------------------------------------
    for i in range(len(l1)):
        count_plots = count_plots + 1
        print('Creating plots | %d'%count_plots)
        # Accessing the path created before
        pth = session.paths['Path-node_%d'%(i+1)]
        # Creating the xy plot.
        xyp = session.XYPlot('XYPlot-S11-%d'%(count_plots))
        chartName = xyp.charts.keys()[0]
        chart = xyp.charts[chartName]
        xy1 = xyPlot.XYDataFromPath(name='xy_data_%d'%(count_plots),path=pth, includeIntersections=True,
           pathStyle=PATH_POINTS, shape=UNDEFORMED,labelType=TRUE_DISTANCE_Z)

        #Plot curve
        c1 = session.Curve(xyData=xy1)
        chart.setValues(curvesToPlot=(c1, ), )
        viewport.setValues(displayedObject=xyp)

看到你的代码后,我觉得关于 Abaqus Python 脚本,你还有很多东西要学(如果我错了请原谅)。首先,您可以阅读 Abaqus Scripting User's Guide,稍后您可以探索 Abaqus Scripting Reference Guide