DrBwts
DrBwts

Reputation: 3657

Abaqus Python script & Really Simple GUI interface syntax issues

I've been running a Python scripts successfully in Abaqus for quite some time now.

So I was delighted to find the Really Simple GUI builder (RSGB), or I was until I tried to use it!

The kernel script I'm using is a mature piece of code so I thought it would be a prime candidate to test out in the RSGB.

All that really needed doing (or so I thought) was matching the widget inputs to the variables in the kernel function.

BUT for some unexplainable reason Abaqus declares that I have a syntax error on my function declaration line, see if you can spot it?

def setUp( modName, target, radMax, radMin, Vx, Vy, Vz, hght, wdth, zLen, numSphere ):

The error,

syntaxError:('invlid syntax',('.\RigidPyticle.py',22,86,'def setUp( modName, target, radMax, radMin, Vx, Vy, Vz, hght, wdth, zLen, numSphere )\n'))

I should add that I have checked all my indents & that the variables sent by GUI match those in kernel function. The kernel function itself is the same piece of code that has been functioning perfectly well outside the RSGB framework when run using the Abaqus CLI

Am I missing something really obvious?

(or is it, as I suspect, that Abaqus has got it in for me?)

Partial kernel code listing as I'm not at liberty to disclose all of it:

# -*- coding: mbcs -*-
from part import *
from material import *
from section import *
from assembly import *
from step import *
from interaction import *
from load import *
from mesh import *
from optimization import *
from job import *
from sketch import *
from visualization import *
from connectorBehavior import *
import numpy as np

def setUp( modName, target, radMax, radMin, Vx, Vy, Vz, hght, wdth, zLen, numSphere ):
    # Import target
    mdb.openAuxMdb(target)
    mdb.copyAuxMdbModel(fromName='Model-1', toName='Model-1')
    mdb.copyAuxMdbModel(fromName='Model-1', toName='Model-1')
    mdb.closeAuxMdb()

    # Set up sphere material
    mdb.models['Model-1'].Material(name='Silicon')
    mdb.models['Model-1'].materials['Silicon'].Density(table=((2.33e-09, ), ))
    mdb.models['Model-1'].materials['Silicon'].Elastic(table=((150000.0, 0.17), ))
    mdb.models['Model-1'].HomogeneousSolidSection(material='Silicon', name='SphereSection', thickness=None)

    # Set up spheres
    for sph in range(1, numSphere):
        sphName = 'Sphere-' + str(sph)
        setName = 'SphereSet-' + str(sph)
        rad = radMin + np.random.randint(radMax) * 0.1
        cent = rad / 2.0
        mdb.models['Model-1'].ConstrainedSketch(name='__profile__', sheetSize=5.0)
        mdb.models['Model-1'].sketches['__profile__'].ConstructionLine(point1=(0.0, -2.5), point2=(0.0, 2.5))
        mdb.models['Model-1'].sketches['__profile__'].FixedConstraint(entity=mdb.models['Model-1'].sketches['__profile__'].geometry[2])
        mdb.models['Model-1'].sketches['__profile__'].ArcByCenterEnds(center=(0.0, 0.0), direction=COUNTERCLOCKWISE, point1=(0.0, -cent), point2=(0.0, cent))
        mdb.models['Model-1'].Part(dimensionality=THREE_D, name=sphName, type=DISCRETE_RIGID_SURFACE)
        mdb.models['Model-1'].parts[sphName].BaseShellRevolve(angle=360.0, flipRevolveDirection=OFF, sketch=mdb.models['Model-1'].sketches['__profile__'])
        del mdb.models['Model-1'].sketches['__profile__']

        # Mesh spheres
        mdb.models['Model-1'].parts[sphName].setMeshControls(elemShape=QUAD, regions=mdb.models['Model-1'].parts[sphName].faces.getSequenceFromMask(('[#1 ]', ), ))
        mdb.models['Model-1'].parts[sphName].seedPart(deviationFactor=0.1, minSizeFactor=0.1, size=0.33)
        mdb.models['Model-1'].parts[sphName].generateMesh()

        # Create set
        mdb.models['Model-1'].parts[sphName].Set(faces=mdb.models['Model-1'].parts[sphName].faces.getSequenceFromMask(('[#1 ]', ), ), name=setName)

        # Reference points & inertia
        intName = 'Inertia-' + str(sph)
        refPointName = 'RP-' + str(sph)
        mdb.models['Model-1'].parts[sphName].ReferencePoint(point=(0.0, 0.0, 0.0))
        mdb.models['Model-1'].parts[sphName].Set(name=refPointName, referencePoints=(mdb.models['Model-1'].parts[sphName].referencePoints[5], ))
        mdb.models['Model-1'].parts[sphName].engineeringFeatures.PointMassInertia(alpha=0.0, composite=0.0, i11=6.59e-10, i22=6.59e-10, i33=6.59e-10, mass=9.8888e-10, name=intName, region=mdb.models['Model-1'].parts[sphName].sets[refPointName])


    # Place spheres in assembly

    # Sphere placement routine would be here

    # Predefined velocity, rigid constraints
    for vel in range(1, numSphere):
        sphName = 'Sphere-' + str(vel)
        setName = sphName + '.SphereSet-' + str(vel)
        conName = 'Constraint-' + str(vel)
        velName = 'RP-' + str(vel)
        preFieldName = 'Predefined Field-' + str(vel)
        mdb.models['Model-1'].RigidBody(bodyRegion=mdb.models['Model-1'].rootAssembly.sets[setName], name=conName, refPointRegion=Region(referencePoints=(mdb.models['Model-1'].rootAssembly.instances[sphName].referencePoints[5], )))
        mdb.models['Model-1'].Velocity(distributionType=MAGNITUDE, field='', name=preFieldName, omega=0.0, region=mdb.models['Model-1'].rootAssembly.instances[sphName].sets[velName], velocity1=Vx, velocity2=Vy, velocity3=Vz)

    # General contact algorithm
    mdb.models['Model-1'].ContactProperty('IntProp-1')
    mdb.models['Model-1'].interactionProperties['IntProp-1'].TangentialBehavior(formulation=FRICTIONLESS)
    mdb.models['Model-1'].interactionProperties['IntProp-1'].NormalBehavior(allowSeparation=ON, constraintEnforcementMethod=DEFAULT, pressureOverclosure=HARD)
    mdb.models['Model-1'].ContactExp(createStepName='Initial', name='Int-1')
    mdb.models['Model-1'].interactions['Int-1'].contactPropertyAssignments.appendInStep(assignments=((GLOBAL, SELF, 'IntProp-1'), ), stepName='Initial')

    # Explicit time step
    mdb.models['Model-1'].ExplicitDynamicsStep(name='Step-1', previous='Initial', timePeriod=0.005)
    mdb.models['Model-1'].interactions['Int-1'].includedPairs.setValuesInStep(stepName='Initial', useAllstar=ON)
    return

Upvotes: -1

Views: 2611

Answers (1)

Mike
Mike

Reputation: 191

From my experience you are missing the following module import in order for your script to work properly:

from abaqus import *
from abaqusConstants import *

Upvotes: 0

Related Questions