Search code examples
pythonabaqus

Assigning BC in Abaqus


I'm new in Python. I was trying to assign some boundary conditions to some sets in Abaqus by running the following Python script. Unfortunately, I'm having the following error:

TypeError: unsupported operand types(s) for +: 'Assembly' and 'int', line 26, in <module> region = a.sets['layer-1' + '-' + str(a+1)]

Anybody, please help me in this regard....

# Do not delete the following import lines
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 job
import sketch
import visualization
import xyPlot
import displayGroupOdbToolset as dgo
import connectorBehavior

a = 1
for i in range(13):
    session.viewports['Viewport: 1'].assemblyDisplay.setValues(step='Step-1')
    a = mdb.models['NodeSet'].rootAssembly
    region = a.sets['layer-1' + '-' + str(a+1)]
    mdb.models['NodeSet'].TemperatureBC(name='BC' + '-' + str(a+1), createStepName='Step-1', 
        region=region, fixed=OFF, distributionType=UNIFORM, fieldName='', 
        magnitude=1.0, amplitude='Amp' + '-' + str(a+1))
    a= a + 1

Solution

  • I can't run your example code because from abaqus import * raises an error.

    However your problem is that you seem to want to use a as an iteration counter. But in your loop you write a = mdb.models['NodeSet'].rootAssembly, which then assigns an assembly object to the variable a. You can't add a number to an assembly object, so you get the error.

    So try simply changing the variable name of the assmebly object to anything other than a, like Assm for example

    a = 1
    for i in range(13):
        session.viewports['Viewport: 1'].assemblyDisplay.setValues(step='Step-1')
        Assm = mdb.models['NodeSet'].rootAssembly
        region = Assm.sets['layer-1' + '-' + str(a+1)]
        mdb.models['NodeSet'].TemperatureBC(name='BC' + '-' + str(a+1), createStepName='Step-1', 
            region=region, fixed=OFF, distributionType=UNIFORM, fieldName='', 
            magnitude=1.0, amplitude='Amp' + '-' + str(a+1))
        a = a + 1
    

    .