pythonscriptingabaqus

Find all Nearest nodes to Yaxis abaqus python scripting


In the following figure a nodeset is created which contains all the nodes belonging to a face. enter image description here

I would like to present a curve showing the position of the maximum temperature Tmax along the "Y" direction. To do this I started by writing this script to detect the position of Tmax. Then I defined a local coordinate system whose Y direction passes through the node having the maximum temperature Tmax.

path0='1101.odb'
odb=openOdb(path=path0)

nodeset='NODESET-ZCT'
mySet = odb.rootAssembly.instances['PART-1-1'].nodeSets[nodeset]
lastFrame = odb.steps['Step-1'].frames[-1]
TEMP=lastFrame.fieldOutputs['NT11']
mySetTemp = TEMP.getSubset(region=mySet)
mySetTempValues=mySetTemp.values
coords=lastFrame.fieldOutputs['COORD']
mySetCoord = coords.getSubset(region=mySet)
mySetCoordValues=mySetCoord.values

Tmax = 0
for v in mySetTempValues:
    if v.data > Tmax:
        Tmax = v.data
        NodeTmax=v.nodeLabel
print(NodeTmax,Tmax)
#print('Tint_max est =', Tmax)
for var in  mySetCoordValues:
    if var.nodeLabel==NodeTmax:
        COORD_node_Tmax=var.data
print(NodeTmax,Tmax,COORD_node_Tmax)

CSYS_Tmax=odb.rootAssembly.DatumCsysByThreePoints(name='CSYS-Tmax', 
    coordSysType=CARTESIAN, origin=(COORD_node_Tmax[0], 0.0, 0.0), point1=(0.0, 
    0.0, 0.0), point2=(COORD_node_Tmax[0],COORD_node_Tmax[1],COORD_node_Tmax[2]))

My objective is to find all the nodes nearest to the "Y" axis, extract their positions and then represent T=f(Y). I should have a curve like this: enter image description here

Can you help me complete this code?


Solution

  • There is one possible way you could get that curve.
    However, you require threshold distance to identify the nearest nodes to the highest value point.

    1. First get the data as Array along with coordinates:
      You can use writeFieldReport command to output the data in CSV format.
    # Show odb first in the viewport
    viewport.setValues(displayedObject=subodb)
    
    # Set formatting report options to CSV
    num_fmt = NumberFormat(numDigits=6, precision=0, format=SCIENTIFIC)
    session.fieldReportOptions.setValues(printTotal=OFF, printMinMax=OFF, 
        numberFormat=num_fmt, reportFormat=COMMA_SEPARATED_VALUES)
    
    # Get the display group object
    ndset_name = 'NODESET-ZCT'
    import displayGroupOdbToolset as dgo
    
    if odb.rootAssembly.instances['PART-1-1'].nodeSets.has_key(ndset_name):
        nset_name_leaf = 'PART-1-1' + '.' + ndset_name
    elif odb.rootAssembly.nodeSets.has_key(ndset_name):
        nset_name_leaf = ndset_name
    
    node_leaf = dgo.LeafFromNodeSets(nodeSets=(nset_name_leaf,))
    dgrp = session.DisplayGroup(name='node_leaf', leaf=node_leaf)
    
    session.writeFieldReport(fileName='output.csv', append=OFF,
        sortItem='Node Label', odb=subodb, step=0, frame=0, outputPosition=NODAL,
        variable=(('NT11', NODAL), ), displayGroup=dgrp)
    
    1. Read the data and manipulate data:
    dat = numpy.loadtxt('output.csv', delimiter=',', skiprows=1, usecols=(4, 6, 11))
    # 4th column is Node Label, 6 - Y coordinate and 11 is NT11.
    
    # Find max node point and substract y coordinate from all Y-data
    dat[:, 1] = dat[:, 1] - dat[numpy.argmax(dat[:, 2])][1]
    
    # Threshold Y distance to identify the nearest nodes
    delta = 0.6
    dat[dat[:, 1] <= delta]
    # Now you can plot the data as 2nd as X axis and 4th as Y axis.
    

    Please make the appropriate changes in the code while exporting data to CSV.