31 lines
No EOL
1.1 KiB
Python
31 lines
No EOL
1.1 KiB
Python
# Python Preprocessor Script for Abaqus Corrosion Model
|
|
# J. Grogan, D. Gastaldi - Created. 19-07-11
|
|
# Import abaqus modules
|
|
from abaqusConstants import *
|
|
from abaqus import *
|
|
import random
|
|
# Create Model, Assembly and Instance objects
|
|
modelNames=mdb.models.keys()
|
|
corModel=mdb.models[modelNames[0]]
|
|
corAssembly=corModel.rootAssembly
|
|
corInst=corAssembly.instances['Corrode']
|
|
# Create list to store labels of surface elements
|
|
numElems=len(corInst.elements)
|
|
elemList=[0]*numElems*2
|
|
randList=[0]*numElems*2
|
|
corSurf=corAssembly.surfaces['CorSurf']
|
|
random.seed()
|
|
for eachElem in corSurf.elements:
|
|
elemList[eachElem.label]=1
|
|
randList[eachElem.label]=random.weibullvariate(1.,0.14)
|
|
# For each element write surface flag and random number to INC file
|
|
incFile=open(modelNames[0]+'.inc','w')
|
|
incFile.write("*Initial Conditions,type=solution \n")
|
|
j=0
|
|
for eachElem in corInst.elements:
|
|
label=eachElem.label
|
|
incFile.write ("Assembly.Corrode.%i,%i,%f,%i,%i\n"%(label,
|
|
elemList[label],randList[label],0,0))
|
|
j=j+1
|
|
print (float(j)/float(len(corInst.elements)))*100.
|
|
incFile.close() |