Search code examples
pythonabaqus

Extacting stresses along path for several odbs in abaqus


I have modeled 5 models in abaqus. Now I want to open the odbs by Abaqus python script and extract data in different paths. But I can't open the odbs together. How can write to open all the odbs together? I could create paths, but how can I extract the stresses from the same path for my 5 model? Thanks in advance.

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,))  

Solution

  • Abaqus stores some specific type of objects in the Repository. Hence, whenever you create these objects, the name of that object must be unique. Example of Abaqus objects, xy plot, viewports, paths, steps, models, etc..

    Secondly, to use Abaqus specific constants, such as DEFORMED, UNDEFORMED(capital variables), you have to importabaqusConstants ` module.

    I just looked at your code and made few changes.

    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)
    

    After seeing your code, I feel there is lot to learn for you regarding the Abaqus Python scripting (pardon me if I am wrong). To get started, you can read Abaqus Scripting User's Guide and later you can explore Abaqus Scripting Reference Guide.