Add scripts and inp files.
This commit is contained in:
parent
ad937f2602
commit
e19f869a1e
390 changed files with 6580687 additions and 10 deletions
290
JMBBM13a/GeometryGenerators/CP_Generator.py
Normal file
290
JMBBM13a/GeometryGenerators/CP_Generator.py
Normal file
|
@ -0,0 +1,290 @@
|
|||
# GrainGen V3.0
|
||||
# This script generates idealised and representative meshed micro-structure geometries
|
||||
# in 2-D through the Abaqus geometry kernel. - J. Grogan, 25/09/2011
|
||||
#
|
||||
# Import Abaqus and External Modules
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
import random
|
||||
import regionToolset
|
||||
import mesh
|
||||
import step
|
||||
import part
|
||||
import interaction
|
||||
import subprocess
|
||||
randomSeed=[39928822]
|
||||
randomSeed.append(39764)
|
||||
randomSeed.append(19230045)
|
||||
randomSeed.append(452398)
|
||||
randomSeed.append(872315)
|
||||
randomSeed.append(794738)
|
||||
randomSeed.append(224492579)
|
||||
randomSeed.append(96502382)
|
||||
randomSeed.append(4921299)
|
||||
randomSeed.append(3113145)
|
||||
randomSeed.append(36677835)
|
||||
for eachModel in range(0,1):
|
||||
#
|
||||
# Create Model Database
|
||||
VerFile=Mdb(pathName="MStructure")
|
||||
VerModel=VerFile.models['Model-1']
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
#
|
||||
# Assign Model Parameters
|
||||
#
|
||||
# Underlying Geometry
|
||||
xSize=0.1
|
||||
ySize=0.03
|
||||
#
|
||||
# Microstructure Geometry
|
||||
charLength=0.0119# Grain Side Length
|
||||
numX=100
|
||||
numY=100
|
||||
numGrains=120 # Voronoi Only
|
||||
hardRad=0.00 # Voronoi Only
|
||||
#
|
||||
# Other Parametersvgrain vumat
|
||||
grainType='Voronoi' # Options: Square, Hexagon, Voronoi
|
||||
meshSize=0.01
|
||||
analysis='Tension' # Options: Tension, Bending
|
||||
#
|
||||
# Draw Base Part
|
||||
BasePart=VerModel.Part(name='Base', dimensionality=TWO_D_PLANAR,type=DEFORMABLE_BODY)
|
||||
BasePart.DatumPointByCoordinate((0,0,0))
|
||||
BasePart.DatumPointByCoordinate((xSize,0,0))
|
||||
BasePart.DatumPointByCoordinate((0,ySize,0))
|
||||
pdatums=BasePart.datums
|
||||
BasePart.DatumPlaneByThreePoints(point1=pdatums[1], point2=pdatums[2], point3=pdatums[3])
|
||||
BasePart.DatumAxisByTwoPoint(point1=pdatums[1],point2=pdatums[2])
|
||||
partTransform = BasePart.MakeSketchTransform(sketchPlane=pdatums[4], sketchUpEdge=pdatums[5],
|
||||
sketchPlaneSide=SIDE1, sketchOrientation=BOTTOM, origin=(0,0,0))
|
||||
BaseSketch = VerModel.ConstrainedSketch(name='Base',sheetSize=200, transform=partTransform)
|
||||
#
|
||||
BaseSketch.Line(point1=(0.,0.),point2=(xSize,0.))
|
||||
BaseSketch.Line(point1=(xSize,0.),point2=(xSize,ySize))
|
||||
BaseSketch.Line(point1=(xSize,ySize),point2=(0.,ySize))
|
||||
BaseSketch.Line(point1=(0.,ySize),point2=(0.,0.))
|
||||
BasePart.BaseShell(sketch=BaseSketch)
|
||||
BasePart=VerModel.parts['Base']
|
||||
#
|
||||
# Draw Microstructure and Partition Base Part
|
||||
ParSketch=VerModel.ConstrainedSketch(name='Base',sheetSize=200, transform=partTransform)
|
||||
if grainType=='Square':
|
||||
offset=0.
|
||||
for i in range(0,numX):
|
||||
ParSketch.Line(point1=(offset,0.),point2=(offset,numY*charLength))
|
||||
offset=offset+charLength
|
||||
offset=0.
|
||||
for i in range(0,numY):
|
||||
ParSketch.Line(point1=(0.,offset),point2=(numX*charLength,offset))
|
||||
offset=offset+charLength
|
||||
elif grainType=='Hexagon':
|
||||
yLength=sin(radians(30.))*charLength
|
||||
xLength=cos(radians(30.))*charLength
|
||||
offsetX=0.
|
||||
for i in range(0,numX):
|
||||
offsetY=0.
|
||||
for j in range(0,numY):
|
||||
if j%2==0:
|
||||
xPos=offsetX
|
||||
else:
|
||||
xPos=offsetX+xLength
|
||||
ParSketch.Line(point1=(xLength+xPos,-yLength+offsetY),point2=(xLength+xPos,yLength+offsetY))
|
||||
ParSketch.Line(point1=(xLength+xPos,+yLength+offsetY),point2=(xPos,2.*yLength+offsetY))
|
||||
ParSketch.Line(point1=(xLength+xPos,-yLength+offsetY),point2=(xPos,-2.*yLength+offsetY))
|
||||
offsetY=offsetY+3.*yLength
|
||||
offsetX=offsetX+2.*xLength
|
||||
elif grainType=='Voronoi':
|
||||
random.seed(randomSeed[eachModel])
|
||||
qhullin=open('qhullin.dat','w')
|
||||
qhullin.write("%i \n"%(2))
|
||||
qhullin.write("%i \n"%(numGrains*9))
|
||||
xlist=[0.]
|
||||
ylist=[0.]
|
||||
#
|
||||
#Generate Point Seeds - Hardcore Voronoi Method Optional
|
||||
for i in range(0,numGrains):
|
||||
outside=False
|
||||
while outside==False:
|
||||
xcor=random.random()*xSize
|
||||
ycor=random.random()*ySize
|
||||
if hardRad==0.:
|
||||
outside=True
|
||||
break
|
||||
if len(xlist)>1:
|
||||
distold=1000.
|
||||
for i in range(1,len(xlist)):
|
||||
distnew=(xcor-xlist[i])*(xcor-xlist[i])+(ycor-ylist[i])*(ycor-ylist[i])
|
||||
distnew=sqrt(distnew)
|
||||
if distnew<distold:
|
||||
distold=distnew
|
||||
if distold>=hardRad:
|
||||
outside=True
|
||||
else:
|
||||
outside=True
|
||||
xlist.append(xcor)
|
||||
ylist.append(ycor)
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor+ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor+ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor+ySize))
|
||||
qhullin.close()
|
||||
#
|
||||
# Generate tesselation externally and post-process results
|
||||
scales=open('scales.dat','w')
|
||||
scales.write("%18.6f %18.6f \n"%(xSize,ySize))
|
||||
scales.close()
|
||||
retcode=subprocess.call("qhull.exe v Qbb TI qhullin.dat o TO qhullout.dat")
|
||||
retcode=subprocess.call("Voronoi2DPost.exe")
|
||||
FortranFile=open('fortranout.dat')
|
||||
num_cells=int(FortranFile.readline())
|
||||
cordx=[]
|
||||
cordy=[]
|
||||
x1=[]
|
||||
y1=[]
|
||||
x2=[]
|
||||
y2=[]
|
||||
k=0
|
||||
#
|
||||
# Generate Partition Sketch
|
||||
for i in range(0,num_cells):
|
||||
num_verts=int(FortranFile.readline())
|
||||
for j in range(0,num_verts):
|
||||
coords=FortranFile.readline().split(',')
|
||||
cordx.append([])
|
||||
cordy.append([])
|
||||
cordx[j]=float(coords[0])
|
||||
cordy[j]=float(coords[1])
|
||||
for j in range(0,num_verts-1):
|
||||
ParSketch.Line(point1=(cordx[j],cordy[j]),point2=(cordx[j+1],cordy[j+1]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[j]
|
||||
y1[k]=cordy[j]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[j+1]
|
||||
y2[k]=cordy[j+1]
|
||||
k=k+1
|
||||
ParSketch.Line(point1=(cordx[num_verts-1],cordy[num_verts-1]),
|
||||
point2=(cordx[0],cordy[0]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[num_verts-1]
|
||||
y1[k]=cordy[num_verts-1]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[0]
|
||||
y2[k]=cordy[0]
|
||||
k=k+1
|
||||
print i
|
||||
BasePart.PartitionFaceBySketch(faces=BasePart.faces, sketch=ParSketch)
|
||||
#
|
||||
# Generate Sections and Section Assignments
|
||||
labelcount=1
|
||||
regions=BasePart.faces
|
||||
for eachregion in regions:
|
||||
mlabel='Mat'+str(labelcount)
|
||||
VerModel.PEGSection(name=mlabel, material=mlabel, thickness=0.01,
|
||||
wedgeAngle1=0.0, wedgeAngle2=0.0)
|
||||
BasePart.SectionAssignment(region=(eachregion,),
|
||||
sectionName=mlabel, offset=0.0, offsetField='')
|
||||
labelcount=labelcount+1
|
||||
#
|
||||
# Mesh Part
|
||||
BasePart.ReferencePoint(point=(0.0, 0.0, 0.0))
|
||||
if grainType=='Square':
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD, technique=STRUCTURED)
|
||||
elif grainType=='Hexagon':
|
||||
offsetX=0.
|
||||
offsetY=0.
|
||||
ParSketch2=VerModel.ConstrainedSketch(name='Hex',sheetSize=200, transform=partTransform)
|
||||
for i in range(0,2*numX):
|
||||
ParSketch2.Line(point1=(offsetX,0.),point2=(offsetX,2.*charLength*numY))
|
||||
offsetX=offsetX+xLength
|
||||
for i in range(0,numY):
|
||||
ParSketch2.Line(point1=(0.,offsetY),point2=(2.*charLength*numX,offsetY))
|
||||
offsetY=offsetY+3.*yLength
|
||||
BasePart.PartitionFaceBySketch(faces=BasePart.faces, sketch=ParSketch2)
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD, technique=SWEEP)
|
||||
elif grainType=='Voronoi':
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD_DOMINATED, technique=FREE)
|
||||
BasePart.seedPart(size=meshSize)
|
||||
pickedRegions =(BasePart.faces, )
|
||||
elemType1 = mesh.ElemType(elemCode=CPEG8R, elemLibrary=STANDARD)
|
||||
#elemType1 = mesh.ElemType(elemCode=CPEG4R, elemLibrary=STANDARD,hourglassControl=ENHANCED)
|
||||
BasePart.setElementType(regions=pickedRegions, elemTypes=(elemType1,))
|
||||
BasePart.generateMesh()
|
||||
#
|
||||
#Steps
|
||||
VerModel.StaticStep(name='Step-1', previous='Initial',
|
||||
maxNumInc=100000, initialInc=0.03, minInc=1e-07, maxInc=0.15, nlgeom=ON, timePeriod=20.)
|
||||
VerModel.fieldOutputRequests['F-Output-1'].setValues(variables=(
|
||||
'LE', 'RF', 'S', 'U'), timeInterval=0.2, timeMarks=OFF)
|
||||
#
|
||||
#Boundary Conditions
|
||||
VerAssembly.Instance(name='Strut',part=BasePart, dependent=ON)
|
||||
iNodes=VerAssembly.instances['Strut'].nodes
|
||||
toler=0.01*meshSize
|
||||
Left=iNodes.getByBoundingBox(xMin=-toler,xMax=toler,yMin=-toler,yMax=ySize+toler)
|
||||
BLeft=iNodes.getByBoundingBox(xMin=-toler,xMax=toler,yMin=-toler,yMax=toler)
|
||||
Right=iNodes.getByBoundingBox(xMin=xSize-toler,xMax=xSize+toler,yMin=toler,yMax=ySize+toler)
|
||||
BRight=iNodes.getByBoundingBox(xMin=xSize-toler,xMax=xSize+toler,yMin=-toler,yMax=toler)
|
||||
#
|
||||
Lregion=regionToolset.Region(nodes=Left)
|
||||
BLregion=regionToolset.Region(nodes=BLeft)
|
||||
Rregion=regionToolset.Region(nodes=Right)
|
||||
BRregion=regionToolset.Region(nodes=BRight)
|
||||
#
|
||||
VerModel.SmoothStepAmplitude(name='Amp-1', timeSpan=TOTAL, data=(( 0.0, 0.0), (24.00, 1.0)))
|
||||
VerModel.DisplacementBC(name='LeftX', createStepName='Initial',
|
||||
region=Lregion, u1=0.0, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY1', createStepName='Initial',
|
||||
region=BLregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
if analysis=='Tension':
|
||||
VerModel.DisplacementBC(name='Tension', createStepName='Step-1',
|
||||
region=BRregion, u1=0.5*xSize, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY2', createStepName='Initial',
|
||||
region=BRregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.boundaryConditions['Tension'].setValues(amplitude='Amp-1')
|
||||
else:
|
||||
VerModel.DisplacementBC(name='Bending', createStepName='Step-1',
|
||||
region=BRregion, u1=UNSET, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=-6., amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.boundaryConditions['Bending'].setValues(amplitude='Amp-1')
|
||||
#
|
||||
VerAssembly.Set(nodes=Right, name='Right')
|
||||
VerAssembly.Set(nodes=BRight, name='BRight')
|
||||
if analysis=='Tension':
|
||||
VerModel.Equation(name='Constraint-1', terms=((1.0, 'Right', 1), ( -1.0, 'BRight', 1)))
|
||||
else:
|
||||
region1=VerAssembly.sets['BRight']
|
||||
region2=VerAssembly.sets['Right']
|
||||
VerModel.MultipointConstraint(name='Constraint-2',
|
||||
controlPoint=region1, surface=region2, mpcType=BEAM_MPC,
|
||||
userMode=DOF_MODE_MPC, userType=0, csys=None)
|
||||
#
|
||||
#Create Job and write input file
|
||||
if grainType=='Square':
|
||||
letter1='S'
|
||||
elif grainType=='Hexagon':
|
||||
letter1='H'
|
||||
elif grainType=='Voronoi':
|
||||
letter1='V'
|
||||
if analysis=='Tension':
|
||||
letter2='T'
|
||||
else:
|
||||
letter2='B'
|
||||
label='W'+str(numY)+'L'+str(numX)+letter1+letter2+str(eachModel)
|
||||
VerFile.Job(name=label, model='Model-1', type=ANALYSIS,userSubroutine='ucrystal.for')
|
||||
VerFile.jobs[label].writeInput(consistencyChecking=OFF)
|
||||
# VerFile.close()
|
292
JMBBM13a/GeometryGenerators/CP_Generator_100.py
Normal file
292
JMBBM13a/GeometryGenerators/CP_Generator_100.py
Normal file
|
@ -0,0 +1,292 @@
|
|||
# GrainGen V3.0
|
||||
# This script generates idealised and representative meshed micro-structure geometries
|
||||
# in 2-D through the Abaqus geometry kernel. - J. Grogan, 25/09/2011
|
||||
#
|
||||
# Import Abaqus and External Modules
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
import random
|
||||
import regionToolset
|
||||
import mesh
|
||||
import step
|
||||
import part
|
||||
import interaction
|
||||
import subprocess
|
||||
#randomSeed=[39928822]
|
||||
randomSeed=[2388997]
|
||||
randomSeed.append(39764)
|
||||
randomSeed.append(19230045)
|
||||
randomSeed.append(452398)
|
||||
randomSeed.append(872315)
|
||||
randomSeed.append(794738)
|
||||
randomSeed.append(224492579)
|
||||
randomSeed.append(96502382)
|
||||
randomSeed.append(4921299)
|
||||
randomSeed.append(3113145)
|
||||
randomSeed.append(36677835)
|
||||
for eachModel in range(0,10):
|
||||
#
|
||||
# Create Model Database
|
||||
VerFile=Mdb(pathName="MStructure")
|
||||
VerModel=VerFile.models['Model-1']
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
#
|
||||
# Assign Model Parameters
|
||||
#
|
||||
# Underlying Geometry
|
||||
xSize=0.8
|
||||
ySize=0.1
|
||||
#
|
||||
# Microstructure Geometry
|
||||
charLength=0.0119# Grain Side Length
|
||||
numX=800
|
||||
numY=100
|
||||
# numGrains=528 # Voronoi Only
|
||||
numGrains=840 # Voronoi Only
|
||||
hardRad=0.00 # Voronoi Only
|
||||
#
|
||||
# Other Parametersvgrain vumat
|
||||
grainType='Voronoi' # Options: Square, Hexagon, Voronoi
|
||||
meshSize=0.001
|
||||
analysis='Tension' # Options: Tension, Bending
|
||||
#
|
||||
# Draw Base Part
|
||||
BasePart=VerModel.Part(name='Base', dimensionality=TWO_D_PLANAR,type=DEFORMABLE_BODY)
|
||||
BasePart.DatumPointByCoordinate((0,0,0))
|
||||
BasePart.DatumPointByCoordinate((xSize,0,0))
|
||||
BasePart.DatumPointByCoordinate((0,ySize,0))
|
||||
pdatums=BasePart.datums
|
||||
BasePart.DatumPlaneByThreePoints(point1=pdatums[1], point2=pdatums[2], point3=pdatums[3])
|
||||
BasePart.DatumAxisByTwoPoint(point1=pdatums[1],point2=pdatums[2])
|
||||
partTransform = BasePart.MakeSketchTransform(sketchPlane=pdatums[4], sketchUpEdge=pdatums[5],
|
||||
sketchPlaneSide=SIDE1, sketchOrientation=BOTTOM, origin=(0,0,0))
|
||||
BaseSketch = VerModel.ConstrainedSketch(name='Base',sheetSize=200, transform=partTransform)
|
||||
#
|
||||
BaseSketch.Line(point1=(0.,0.),point2=(xSize,0.))
|
||||
BaseSketch.Line(point1=(xSize,0.),point2=(xSize,ySize))
|
||||
BaseSketch.Line(point1=(xSize,ySize),point2=(0.,ySize))
|
||||
BaseSketch.Line(point1=(0.,ySize),point2=(0.,0.))
|
||||
BasePart.BaseShell(sketch=BaseSketch)
|
||||
BasePart=VerModel.parts['Base']
|
||||
#
|
||||
# Draw Microstructure and Partition Base Part
|
||||
ParSketch=VerModel.ConstrainedSketch(name='Base',sheetSize=200, transform=partTransform)
|
||||
if grainType=='Square':
|
||||
offset=0.
|
||||
for i in range(0,numX):
|
||||
ParSketch.Line(point1=(offset,0.),point2=(offset,numY*charLength))
|
||||
offset=offset+charLength
|
||||
offset=0.
|
||||
for i in range(0,numY):
|
||||
ParSketch.Line(point1=(0.,offset),point2=(numX*charLength,offset))
|
||||
offset=offset+charLength
|
||||
elif grainType=='Hexagon':
|
||||
yLength=sin(radians(30.))*charLength
|
||||
xLength=cos(radians(30.))*charLength
|
||||
offsetX=0.
|
||||
for i in range(0,numX):
|
||||
offsetY=0.
|
||||
for j in range(0,numY):
|
||||
if j%2==0:
|
||||
xPos=offsetX
|
||||
else:
|
||||
xPos=offsetX+xLength
|
||||
ParSketch.Line(point1=(xLength+xPos,-yLength+offsetY),point2=(xLength+xPos,yLength+offsetY))
|
||||
ParSketch.Line(point1=(xLength+xPos,+yLength+offsetY),point2=(xPos,2.*yLength+offsetY))
|
||||
ParSketch.Line(point1=(xLength+xPos,-yLength+offsetY),point2=(xPos,-2.*yLength+offsetY))
|
||||
offsetY=offsetY+3.*yLength
|
||||
offsetX=offsetX+2.*xLength
|
||||
elif grainType=='Voronoi':
|
||||
random.seed(randomSeed[eachModel])
|
||||
qhullin=open('qhullin.dat','w')
|
||||
qhullin.write("%i \n"%(2))
|
||||
qhullin.write("%i \n"%(numGrains*9))
|
||||
xlist=[0.]
|
||||
ylist=[0.]
|
||||
#
|
||||
#Generate Point Seeds - Hardcore Voronoi Method Optional
|
||||
for i in range(0,numGrains):
|
||||
outside=False
|
||||
while outside==False:
|
||||
xcor=random.random()*xSize
|
||||
ycor=random.random()*ySize
|
||||
if hardRad==0.:
|
||||
outside=True
|
||||
break
|
||||
if len(xlist)>1:
|
||||
distold=1000.
|
||||
for i in range(1,len(xlist)):
|
||||
distnew=(xcor-xlist[i])*(xcor-xlist[i])+(ycor-ylist[i])*(ycor-ylist[i])
|
||||
distnew=sqrt(distnew)
|
||||
if distnew<distold:
|
||||
distold=distnew
|
||||
if distold>=hardRad:
|
||||
outside=True
|
||||
else:
|
||||
outside=True
|
||||
xlist.append(xcor)
|
||||
ylist.append(ycor)
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor+ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor+ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor+ySize))
|
||||
qhullin.close()
|
||||
#
|
||||
# Generate tesselation externally and post-process results
|
||||
scales=open('scales.dat','w')
|
||||
scales.write("%18.6f %18.6f \n"%(xSize,ySize))
|
||||
scales.close()
|
||||
retcode=subprocess.call("qhull.exe v Qbb TI qhullin.dat o TO qhullout.dat")
|
||||
retcode=subprocess.call("Voronoi2DPost.exe")
|
||||
FortranFile=open('fortranout.dat')
|
||||
num_cells=int(FortranFile.readline())
|
||||
cordx=[]
|
||||
cordy=[]
|
||||
x1=[]
|
||||
y1=[]
|
||||
x2=[]
|
||||
y2=[]
|
||||
k=0
|
||||
#
|
||||
# Generate Partition Sketch
|
||||
for i in range(0,num_cells):
|
||||
num_verts=int(FortranFile.readline())
|
||||
for j in range(0,num_verts):
|
||||
coords=FortranFile.readline().split(',')
|
||||
cordx.append([])
|
||||
cordy.append([])
|
||||
cordx[j]=float(coords[0])
|
||||
cordy[j]=float(coords[1])
|
||||
for j in range(0,num_verts-1):
|
||||
ParSketch.Line(point1=(cordx[j],cordy[j]),point2=(cordx[j+1],cordy[j+1]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[j]
|
||||
y1[k]=cordy[j]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[j+1]
|
||||
y2[k]=cordy[j+1]
|
||||
k=k+1
|
||||
ParSketch.Line(point1=(cordx[num_verts-1],cordy[num_verts-1]),
|
||||
point2=(cordx[0],cordy[0]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[num_verts-1]
|
||||
y1[k]=cordy[num_verts-1]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[0]
|
||||
y2[k]=cordy[0]
|
||||
k=k+1
|
||||
print i
|
||||
BasePart.PartitionFaceBySketch(faces=BasePart.faces, sketch=ParSketch)
|
||||
#
|
||||
# Generate Sections and Section Assignments
|
||||
labelcount=1
|
||||
regions=BasePart.faces
|
||||
for eachregion in regions:
|
||||
mlabel='Mat'+str(labelcount)
|
||||
VerModel.PEGSection(name=mlabel, material=mlabel, thickness=0.01,
|
||||
wedgeAngle1=0.0, wedgeAngle2=0.0)
|
||||
BasePart.SectionAssignment(region=(eachregion,),
|
||||
sectionName=mlabel, offset=0.0, offsetField='')
|
||||
labelcount=labelcount+1
|
||||
#
|
||||
# Mesh Part
|
||||
BasePart.ReferencePoint(point=(0.0, 0.0, 0.0))
|
||||
if grainType=='Square':
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD, technique=STRUCTURED)
|
||||
elif grainType=='Hexagon':
|
||||
offsetX=0.
|
||||
offsetY=0.
|
||||
ParSketch2=VerModel.ConstrainedSketch(name='Hex',sheetSize=200, transform=partTransform)
|
||||
for i in range(0,2*numX):
|
||||
ParSketch2.Line(point1=(offsetX,0.),point2=(offsetX,2.*charLength*numY))
|
||||
offsetX=offsetX+xLength
|
||||
for i in range(0,numY):
|
||||
ParSketch2.Line(point1=(0.,offsetY),point2=(2.*charLength*numX,offsetY))
|
||||
offsetY=offsetY+3.*yLength
|
||||
BasePart.PartitionFaceBySketch(faces=BasePart.faces, sketch=ParSketch2)
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD, technique=SWEEP)
|
||||
elif grainType=='Voronoi':
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD_DOMINATED, technique=FREE)
|
||||
BasePart.seedPart(size=meshSize)
|
||||
pickedRegions =(BasePart.faces, )
|
||||
elemType1 = mesh.ElemType(elemCode=CPEG8R, elemLibrary=STANDARD)
|
||||
#elemType1 = mesh.ElemType(elemCode=CPEG4R, elemLibrary=STANDARD,hourglassControl=ENHANCED)
|
||||
BasePart.setElementType(regions=pickedRegions, elemTypes=(elemType1,))
|
||||
BasePart.generateMesh()
|
||||
#
|
||||
#Steps
|
||||
VerModel.StaticStep(name='Step-1', previous='Initial',
|
||||
maxNumInc=100000, initialInc=0.03, minInc=1e-07, maxInc=0.15, nlgeom=ON, timePeriod=20.)
|
||||
VerModel.fieldOutputRequests['F-Output-1'].setValues(variables=(
|
||||
'LE', 'RF', 'S', 'U'), timeInterval=0.2, timeMarks=OFF)
|
||||
#
|
||||
#Boundary Conditions
|
||||
VerAssembly.Instance(name='Strut',part=BasePart, dependent=ON)
|
||||
iNodes=VerAssembly.instances['Strut'].nodes
|
||||
toler=0.01*meshSize
|
||||
Left=iNodes.getByBoundingBox(xMin=-toler,xMax=toler,yMin=-toler,yMax=ySize+toler)
|
||||
BLeft=iNodes.getByBoundingBox(xMin=-toler,xMax=toler,yMin=-toler,yMax=toler)
|
||||
Right=iNodes.getByBoundingBox(xMin=xSize-toler,xMax=xSize+toler,yMin=toler,yMax=ySize+toler)
|
||||
BRight=iNodes.getByBoundingBox(xMin=xSize-toler,xMax=xSize+toler,yMin=-toler,yMax=toler)
|
||||
#
|
||||
Lregion=regionToolset.Region(nodes=Left)
|
||||
BLregion=regionToolset.Region(nodes=BLeft)
|
||||
Rregion=regionToolset.Region(nodes=Right)
|
||||
BRregion=regionToolset.Region(nodes=BRight)
|
||||
#
|
||||
VerModel.SmoothStepAmplitude(name='Amp-1', timeSpan=TOTAL, data=(( 0.0, 0.0), (24.00, 1.0)))
|
||||
VerModel.DisplacementBC(name='LeftX', createStepName='Initial',
|
||||
region=Lregion, u1=0.0, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY1', createStepName='Initial',
|
||||
region=BLregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
if analysis=='Tension':
|
||||
VerModel.DisplacementBC(name='Tension', createStepName='Step-1',
|
||||
region=BRregion, u1=0.5*xSize, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY2', createStepName='Initial',
|
||||
region=BRregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.boundaryConditions['Tension'].setValues(amplitude='Amp-1')
|
||||
else:
|
||||
VerModel.DisplacementBC(name='Bending', createStepName='Step-1',
|
||||
region=BRregion, u1=UNSET, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=-6., amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.boundaryConditions['Bending'].setValues(amplitude='Amp-1')
|
||||
#
|
||||
VerAssembly.Set(nodes=Right, name='Right')
|
||||
VerAssembly.Set(nodes=BRight, name='BRight')
|
||||
if analysis=='Tension':
|
||||
VerModel.Equation(name='Constraint-1', terms=((1.0, 'Right', 1), ( -1.0, 'BRight', 1)))
|
||||
else:
|
||||
region1=VerAssembly.sets['BRight']
|
||||
region2=VerAssembly.sets['Right']
|
||||
VerModel.MultipointConstraint(name='Constraint-2',
|
||||
controlPoint=region1, surface=region2, mpcType=BEAM_MPC,
|
||||
userMode=DOF_MODE_MPC, userType=0, csys=None)
|
||||
#
|
||||
#Create Job and write input file
|
||||
if grainType=='Square':
|
||||
letter1='S'
|
||||
elif grainType=='Hexagon':
|
||||
letter1='H'
|
||||
elif grainType=='Voronoi':
|
||||
letter1='V'
|
||||
if analysis=='Tension':
|
||||
letter2='T'
|
||||
else:
|
||||
letter2='B'
|
||||
label='W'+str(numY)+'L'+str(numX)+letter1+letter2+str(eachModel)
|
||||
VerFile.Job(name=label, model='Model-1', type=ANALYSIS,userSubroutine='ucrystal.for')
|
||||
VerFile.jobs[label].writeInput(consistencyChecking=OFF)
|
||||
# VerFile.close()
|
292
JMBBM13a/GeometryGenerators/CP_Generator_150.py
Normal file
292
JMBBM13a/GeometryGenerators/CP_Generator_150.py
Normal file
|
@ -0,0 +1,292 @@
|
|||
# GrainGen V3.0
|
||||
# This script generates idealised and representative meshed micro-structure geometries
|
||||
# in 2-D through the Abaqus geometry kernel. - J. Grogan, 25/09/2011
|
||||
#
|
||||
# Import Abaqus and External Modules
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
import random
|
||||
import regionToolset
|
||||
import mesh
|
||||
import step
|
||||
import part
|
||||
import interaction
|
||||
import subprocess
|
||||
#randomSeed=[39928822]
|
||||
randomSeed=[3344993]
|
||||
randomSeed.append(39764)
|
||||
randomSeed.append(19230045)
|
||||
randomSeed.append(452398)
|
||||
randomSeed.append(872315)
|
||||
randomSeed.append(794738)
|
||||
randomSeed.append(224492579)
|
||||
randomSeed.append(96502382)
|
||||
randomSeed.append(4921299)
|
||||
randomSeed.append(3113145)
|
||||
randomSeed.append(36677835)
|
||||
for eachModel in range(0,10):
|
||||
#
|
||||
# Create Model Database
|
||||
VerFile=Mdb(pathName="MStructure")
|
||||
VerModel=VerFile.models['Model-1']
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
#
|
||||
# Assign Model Parameters
|
||||
#
|
||||
# Underlying Geometry
|
||||
xSize=0.8
|
||||
ySize=0.15
|
||||
#
|
||||
# Microstructure Geometry
|
||||
charLength=0.0119# Grain Side Length
|
||||
numX=800
|
||||
numY=150
|
||||
# numGrains=528 # Voronoi Only
|
||||
numGrains=1279 # Voronoi Only
|
||||
hardRad=0.00 # Voronoi Only
|
||||
#
|
||||
# Other Parametersvgrain vumat
|
||||
grainType='Voronoi' # Options: Square, Hexagon, Voronoi
|
||||
meshSize=0.001
|
||||
analysis='Tension' # Options: Tension, Bending
|
||||
#
|
||||
# Draw Base Part
|
||||
BasePart=VerModel.Part(name='Base', dimensionality=TWO_D_PLANAR,type=DEFORMABLE_BODY)
|
||||
BasePart.DatumPointByCoordinate((0,0,0))
|
||||
BasePart.DatumPointByCoordinate((xSize,0,0))
|
||||
BasePart.DatumPointByCoordinate((0,ySize,0))
|
||||
pdatums=BasePart.datums
|
||||
BasePart.DatumPlaneByThreePoints(point1=pdatums[1], point2=pdatums[2], point3=pdatums[3])
|
||||
BasePart.DatumAxisByTwoPoint(point1=pdatums[1],point2=pdatums[2])
|
||||
partTransform = BasePart.MakeSketchTransform(sketchPlane=pdatums[4], sketchUpEdge=pdatums[5],
|
||||
sketchPlaneSide=SIDE1, sketchOrientation=BOTTOM, origin=(0,0,0))
|
||||
BaseSketch = VerModel.ConstrainedSketch(name='Base',sheetSize=200, transform=partTransform)
|
||||
#
|
||||
BaseSketch.Line(point1=(0.,0.),point2=(xSize,0.))
|
||||
BaseSketch.Line(point1=(xSize,0.),point2=(xSize,ySize))
|
||||
BaseSketch.Line(point1=(xSize,ySize),point2=(0.,ySize))
|
||||
BaseSketch.Line(point1=(0.,ySize),point2=(0.,0.))
|
||||
BasePart.BaseShell(sketch=BaseSketch)
|
||||
BasePart=VerModel.parts['Base']
|
||||
#
|
||||
# Draw Microstructure and Partition Base Part
|
||||
ParSketch=VerModel.ConstrainedSketch(name='Base',sheetSize=200, transform=partTransform)
|
||||
if grainType=='Square':
|
||||
offset=0.
|
||||
for i in range(0,numX):
|
||||
ParSketch.Line(point1=(offset,0.),point2=(offset,numY*charLength))
|
||||
offset=offset+charLength
|
||||
offset=0.
|
||||
for i in range(0,numY):
|
||||
ParSketch.Line(point1=(0.,offset),point2=(numX*charLength,offset))
|
||||
offset=offset+charLength
|
||||
elif grainType=='Hexagon':
|
||||
yLength=sin(radians(30.))*charLength
|
||||
xLength=cos(radians(30.))*charLength
|
||||
offsetX=0.
|
||||
for i in range(0,numX):
|
||||
offsetY=0.
|
||||
for j in range(0,numY):
|
||||
if j%2==0:
|
||||
xPos=offsetX
|
||||
else:
|
||||
xPos=offsetX+xLength
|
||||
ParSketch.Line(point1=(xLength+xPos,-yLength+offsetY),point2=(xLength+xPos,yLength+offsetY))
|
||||
ParSketch.Line(point1=(xLength+xPos,+yLength+offsetY),point2=(xPos,2.*yLength+offsetY))
|
||||
ParSketch.Line(point1=(xLength+xPos,-yLength+offsetY),point2=(xPos,-2.*yLength+offsetY))
|
||||
offsetY=offsetY+3.*yLength
|
||||
offsetX=offsetX+2.*xLength
|
||||
elif grainType=='Voronoi':
|
||||
random.seed(randomSeed[eachModel])
|
||||
qhullin=open('qhullin.dat','w')
|
||||
qhullin.write("%i \n"%(2))
|
||||
qhullin.write("%i \n"%(numGrains*9))
|
||||
xlist=[0.]
|
||||
ylist=[0.]
|
||||
#
|
||||
#Generate Point Seeds - Hardcore Voronoi Method Optional
|
||||
for i in range(0,numGrains):
|
||||
outside=False
|
||||
while outside==False:
|
||||
xcor=random.random()*xSize
|
||||
ycor=random.random()*ySize
|
||||
if hardRad==0.:
|
||||
outside=True
|
||||
break
|
||||
if len(xlist)>1:
|
||||
distold=1000.
|
||||
for i in range(1,len(xlist)):
|
||||
distnew=(xcor-xlist[i])*(xcor-xlist[i])+(ycor-ylist[i])*(ycor-ylist[i])
|
||||
distnew=sqrt(distnew)
|
||||
if distnew<distold:
|
||||
distold=distnew
|
||||
if distold>=hardRad:
|
||||
outside=True
|
||||
else:
|
||||
outside=True
|
||||
xlist.append(xcor)
|
||||
ylist.append(ycor)
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor+ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor+ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor+ySize))
|
||||
qhullin.close()
|
||||
#
|
||||
# Generate tesselation externally and post-process results
|
||||
scales=open('scales.dat','w')
|
||||
scales.write("%18.6f %18.6f \n"%(xSize,ySize))
|
||||
scales.close()
|
||||
retcode=subprocess.call("qhull.exe v Qbb TI qhullin.dat o TO qhullout.dat")
|
||||
retcode=subprocess.call("Voronoi2DPost.exe")
|
||||
FortranFile=open('fortranout.dat')
|
||||
num_cells=int(FortranFile.readline())
|
||||
cordx=[]
|
||||
cordy=[]
|
||||
x1=[]
|
||||
y1=[]
|
||||
x2=[]
|
||||
y2=[]
|
||||
k=0
|
||||
#
|
||||
# Generate Partition Sketch
|
||||
for i in range(0,num_cells):
|
||||
num_verts=int(FortranFile.readline())
|
||||
for j in range(0,num_verts):
|
||||
coords=FortranFile.readline().split(',')
|
||||
cordx.append([])
|
||||
cordy.append([])
|
||||
cordx[j]=float(coords[0])
|
||||
cordy[j]=float(coords[1])
|
||||
for j in range(0,num_verts-1):
|
||||
ParSketch.Line(point1=(cordx[j],cordy[j]),point2=(cordx[j+1],cordy[j+1]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[j]
|
||||
y1[k]=cordy[j]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[j+1]
|
||||
y2[k]=cordy[j+1]
|
||||
k=k+1
|
||||
ParSketch.Line(point1=(cordx[num_verts-1],cordy[num_verts-1]),
|
||||
point2=(cordx[0],cordy[0]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[num_verts-1]
|
||||
y1[k]=cordy[num_verts-1]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[0]
|
||||
y2[k]=cordy[0]
|
||||
k=k+1
|
||||
print i
|
||||
BasePart.PartitionFaceBySketch(faces=BasePart.faces, sketch=ParSketch)
|
||||
#
|
||||
# Generate Sections and Section Assignments
|
||||
labelcount=1
|
||||
regions=BasePart.faces
|
||||
for eachregion in regions:
|
||||
mlabel='Mat'+str(labelcount)
|
||||
VerModel.PEGSection(name=mlabel, material=mlabel, thickness=0.01,
|
||||
wedgeAngle1=0.0, wedgeAngle2=0.0)
|
||||
BasePart.SectionAssignment(region=(eachregion,),
|
||||
sectionName=mlabel, offset=0.0, offsetField='')
|
||||
labelcount=labelcount+1
|
||||
#
|
||||
# Mesh Part
|
||||
BasePart.ReferencePoint(point=(0.0, 0.0, 0.0))
|
||||
if grainType=='Square':
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD, technique=STRUCTURED)
|
||||
elif grainType=='Hexagon':
|
||||
offsetX=0.
|
||||
offsetY=0.
|
||||
ParSketch2=VerModel.ConstrainedSketch(name='Hex',sheetSize=200, transform=partTransform)
|
||||
for i in range(0,2*numX):
|
||||
ParSketch2.Line(point1=(offsetX,0.),point2=(offsetX,2.*charLength*numY))
|
||||
offsetX=offsetX+xLength
|
||||
for i in range(0,numY):
|
||||
ParSketch2.Line(point1=(0.,offsetY),point2=(2.*charLength*numX,offsetY))
|
||||
offsetY=offsetY+3.*yLength
|
||||
BasePart.PartitionFaceBySketch(faces=BasePart.faces, sketch=ParSketch2)
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD, technique=SWEEP)
|
||||
elif grainType=='Voronoi':
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD_DOMINATED, technique=FREE)
|
||||
BasePart.seedPart(size=meshSize)
|
||||
pickedRegions =(BasePart.faces, )
|
||||
elemType1 = mesh.ElemType(elemCode=CPEG8R, elemLibrary=STANDARD)
|
||||
#elemType1 = mesh.ElemType(elemCode=CPEG4R, elemLibrary=STANDARD,hourglassControl=ENHANCED)
|
||||
BasePart.setElementType(regions=pickedRegions, elemTypes=(elemType1,))
|
||||
BasePart.generateMesh()
|
||||
#
|
||||
#Steps
|
||||
VerModel.StaticStep(name='Step-1', previous='Initial',
|
||||
maxNumInc=100000, initialInc=0.03, minInc=1e-07, maxInc=0.15, nlgeom=ON, timePeriod=20.)
|
||||
VerModel.fieldOutputRequests['F-Output-1'].setValues(variables=(
|
||||
'LE', 'RF', 'S', 'U'), timeInterval=0.2, timeMarks=OFF)
|
||||
#
|
||||
#Boundary Conditions
|
||||
VerAssembly.Instance(name='Strut',part=BasePart, dependent=ON)
|
||||
iNodes=VerAssembly.instances['Strut'].nodes
|
||||
toler=0.01*meshSize
|
||||
Left=iNodes.getByBoundingBox(xMin=-toler,xMax=toler,yMin=-toler,yMax=ySize+toler)
|
||||
BLeft=iNodes.getByBoundingBox(xMin=-toler,xMax=toler,yMin=-toler,yMax=toler)
|
||||
Right=iNodes.getByBoundingBox(xMin=xSize-toler,xMax=xSize+toler,yMin=toler,yMax=ySize+toler)
|
||||
BRight=iNodes.getByBoundingBox(xMin=xSize-toler,xMax=xSize+toler,yMin=-toler,yMax=toler)
|
||||
#
|
||||
Lregion=regionToolset.Region(nodes=Left)
|
||||
BLregion=regionToolset.Region(nodes=BLeft)
|
||||
Rregion=regionToolset.Region(nodes=Right)
|
||||
BRregion=regionToolset.Region(nodes=BRight)
|
||||
#
|
||||
VerModel.SmoothStepAmplitude(name='Amp-1', timeSpan=TOTAL, data=(( 0.0, 0.0), (24.00, 1.0)))
|
||||
VerModel.DisplacementBC(name='LeftX', createStepName='Initial',
|
||||
region=Lregion, u1=0.0, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY1', createStepName='Initial',
|
||||
region=BLregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
if analysis=='Tension':
|
||||
VerModel.DisplacementBC(name='Tension', createStepName='Step-1',
|
||||
region=BRregion, u1=0.5*xSize, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY2', createStepName='Initial',
|
||||
region=BRregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.boundaryConditions['Tension'].setValues(amplitude='Amp-1')
|
||||
else:
|
||||
VerModel.DisplacementBC(name='Bending', createStepName='Step-1',
|
||||
region=BRregion, u1=UNSET, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=-6., amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.boundaryConditions['Bending'].setValues(amplitude='Amp-1')
|
||||
#
|
||||
VerAssembly.Set(nodes=Right, name='Right')
|
||||
VerAssembly.Set(nodes=BRight, name='BRight')
|
||||
if analysis=='Tension':
|
||||
VerModel.Equation(name='Constraint-1', terms=((1.0, 'Right', 1), ( -1.0, 'BRight', 1)))
|
||||
else:
|
||||
region1=VerAssembly.sets['BRight']
|
||||
region2=VerAssembly.sets['Right']
|
||||
VerModel.MultipointConstraint(name='Constraint-2',
|
||||
controlPoint=region1, surface=region2, mpcType=BEAM_MPC,
|
||||
userMode=DOF_MODE_MPC, userType=0, csys=None)
|
||||
#
|
||||
#Create Job and write input file
|
||||
if grainType=='Square':
|
||||
letter1='S'
|
||||
elif grainType=='Hexagon':
|
||||
letter1='H'
|
||||
elif grainType=='Voronoi':
|
||||
letter1='V'
|
||||
if analysis=='Tension':
|
||||
letter2='T'
|
||||
else:
|
||||
letter2='B'
|
||||
label='W'+str(numY)+'L'+str(numX)+letter1+letter2+str(eachModel)
|
||||
VerFile.Job(name=label, model='Model-1', type=ANALYSIS,userSubroutine='ucrystal.for')
|
||||
VerFile.jobs[label].writeInput(consistencyChecking=OFF)
|
||||
VerFile.close()
|
292
JMBBM13a/GeometryGenerators/CP_Generator_30.py
Normal file
292
JMBBM13a/GeometryGenerators/CP_Generator_30.py
Normal file
|
@ -0,0 +1,292 @@
|
|||
# GrainGen V3.0
|
||||
# This script generates idealised and representative meshed micro-structure geometries
|
||||
# in 2-D through the Abaqus geometry kernel. - J. Grogan, 25/09/2011
|
||||
#
|
||||
# Import Abaqus and External Modules
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
import random
|
||||
import regionToolset
|
||||
import mesh
|
||||
import step
|
||||
import part
|
||||
import interaction
|
||||
import subprocess
|
||||
#randomSeed=[39928822]
|
||||
randomSeed=[41557]
|
||||
randomSeed.append(39764)
|
||||
randomSeed.append(19230045)
|
||||
randomSeed.append(452398)
|
||||
randomSeed.append(872315)
|
||||
randomSeed.append(794738)
|
||||
randomSeed.append(224492579)
|
||||
randomSeed.append(96502382)
|
||||
randomSeed.append(4921299)
|
||||
randomSeed.append(3113145)
|
||||
randomSeed.append(36677835)
|
||||
for eachModel in range(0,1):
|
||||
#
|
||||
# Create Model Database
|
||||
VerFile=Mdb(pathName="MStructure")
|
||||
VerModel=VerFile.models['Model-1']
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
#
|
||||
# Assign Model Parameters
|
||||
#
|
||||
# Underlying Geometry
|
||||
xSize=0.1
|
||||
ySize=0.5
|
||||
#
|
||||
# Microstructure Geometry
|
||||
charLength=0.00595 #Grain Side Length
|
||||
numX=10
|
||||
numY=70
|
||||
# numGrains=528 # Voronoi Only
|
||||
numGrains=127 # Voronoi Only
|
||||
hardRad=0.00 # Voronoi Only
|
||||
#
|
||||
# Other Parametersvgrain vumat
|
||||
grainType='Hexagon' # Options: Square, Hexagon, Voronoi
|
||||
meshSize=0.001
|
||||
analysis='Tension' # Options: Tension, Bending
|
||||
#
|
||||
# Draw Base Part
|
||||
BasePart=VerModel.Part(name='Base', dimensionality=TWO_D_PLANAR,type=DEFORMABLE_BODY)
|
||||
BasePart.DatumPointByCoordinate((0,0,0))
|
||||
BasePart.DatumPointByCoordinate((xSize,0,0))
|
||||
BasePart.DatumPointByCoordinate((0,ySize,0))
|
||||
pdatums=BasePart.datums
|
||||
BasePart.DatumPlaneByThreePoints(point1=pdatums[1], point2=pdatums[2], point3=pdatums[3])
|
||||
BasePart.DatumAxisByTwoPoint(point1=pdatums[1],point2=pdatums[2])
|
||||
partTransform = BasePart.MakeSketchTransform(sketchPlane=pdatums[4], sketchUpEdge=pdatums[5],
|
||||
sketchPlaneSide=SIDE1, sketchOrientation=BOTTOM, origin=(0,0,0))
|
||||
BaseSketch = VerModel.ConstrainedSketch(name='Base',sheetSize=200, transform=partTransform)
|
||||
#
|
||||
BaseSketch.Line(point1=(0.,0.),point2=(xSize,0.))
|
||||
BaseSketch.Line(point1=(xSize,0.),point2=(xSize,ySize))
|
||||
BaseSketch.Line(point1=(xSize,ySize),point2=(0.,ySize))
|
||||
BaseSketch.Line(point1=(0.,ySize),point2=(0.,0.))
|
||||
BasePart.BaseShell(sketch=BaseSketch)
|
||||
BasePart=VerModel.parts['Base']
|
||||
#
|
||||
# Draw Microstructure and Partition Base Part
|
||||
ParSketch=VerModel.ConstrainedSketch(name='Base',sheetSize=200, transform=partTransform)
|
||||
if grainType=='Square':
|
||||
offset=0.
|
||||
for i in range(0,numX):
|
||||
ParSketch.Line(point1=(offset,0.),point2=(offset,numY*charLength))
|
||||
offset=offset+charLength
|
||||
offset=0.
|
||||
for i in range(0,numY):
|
||||
ParSketch.Line(point1=(0.,offset),point2=(numX*charLength,offset))
|
||||
offset=offset+charLength
|
||||
elif grainType=='Hexagon':
|
||||
yLength=sin(radians(30.))*charLength
|
||||
xLength=cos(radians(30.))*charLength
|
||||
offsetX=0.
|
||||
for i in range(0,numX):
|
||||
offsetY=0.
|
||||
for j in range(0,numY):
|
||||
if j%2==0:
|
||||
xPos=offsetX
|
||||
else:
|
||||
xPos=offsetX+xLength
|
||||
ParSketch.Line(point1=(xLength+xPos,-yLength+offsetY),point2=(xLength+xPos,yLength+offsetY))
|
||||
ParSketch.Line(point1=(xLength+xPos,+yLength+offsetY),point2=(xPos,2.*yLength+offsetY))
|
||||
ParSketch.Line(point1=(xLength+xPos,-yLength+offsetY),point2=(xPos,-2.*yLength+offsetY))
|
||||
offsetY=offsetY+3.*yLength
|
||||
offsetX=offsetX+2.*xLength
|
||||
elif grainType=='Voronoi':
|
||||
random.seed(randomSeed[eachModel])
|
||||
qhullin=open('qhullin.dat','w')
|
||||
qhullin.write("%i \n"%(2))
|
||||
qhullin.write("%i \n"%(numGrains*9))
|
||||
xlist=[0.]
|
||||
ylist=[0.]
|
||||
#
|
||||
#Generate Point Seeds - Hardcore Voronoi Method Optional
|
||||
for i in range(0,numGrains):
|
||||
outside=False
|
||||
while outside==False:
|
||||
xcor=random.random()*xSize
|
||||
ycor=random.random()*ySize
|
||||
if hardRad==0.:
|
||||
outside=True
|
||||
break
|
||||
if len(xlist)>1:
|
||||
distold=1000.
|
||||
for i in range(1,len(xlist)):
|
||||
distnew=(xcor-xlist[i])*(xcor-xlist[i])+(ycor-ylist[i])*(ycor-ylist[i])
|
||||
distnew=sqrt(distnew)
|
||||
if distnew<distold:
|
||||
distold=distnew
|
||||
if distold>=hardRad:
|
||||
outside=True
|
||||
else:
|
||||
outside=True
|
||||
xlist.append(xcor)
|
||||
ylist.append(ycor)
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor+ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor+ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor+ySize))
|
||||
qhullin.close()
|
||||
#
|
||||
# Generate tesselation externally and post-process results
|
||||
scales=open('scales.dat','w')
|
||||
scales.write("%18.6f %18.6f \n"%(xSize,ySize))
|
||||
scales.close()
|
||||
retcode=subprocess.call("qhull.exe v Qbb TI qhullin.dat o TO qhullout.dat")
|
||||
retcode=subprocess.call("Voronoi2DPost.exe")
|
||||
FortranFile=open('fortranout.dat')
|
||||
num_cells=int(FortranFile.readline())
|
||||
cordx=[]
|
||||
cordy=[]
|
||||
x1=[]
|
||||
y1=[]
|
||||
x2=[]
|
||||
y2=[]
|
||||
k=0
|
||||
#
|
||||
# Generate Partition Sketch
|
||||
for i in range(0,num_cells):
|
||||
num_verts=int(FortranFile.readline())
|
||||
for j in range(0,num_verts):
|
||||
coords=FortranFile.readline().split(',')
|
||||
cordx.append([])
|
||||
cordy.append([])
|
||||
cordx[j]=float(coords[0])
|
||||
cordy[j]=float(coords[1])
|
||||
for j in range(0,num_verts-1):
|
||||
ParSketch.Line(point1=(cordx[j],cordy[j]),point2=(cordx[j+1],cordy[j+1]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[j]
|
||||
y1[k]=cordy[j]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[j+1]
|
||||
y2[k]=cordy[j+1]
|
||||
k=k+1
|
||||
ParSketch.Line(point1=(cordx[num_verts-1],cordy[num_verts-1]),
|
||||
point2=(cordx[0],cordy[0]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[num_verts-1]
|
||||
y1[k]=cordy[num_verts-1]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[0]
|
||||
y2[k]=cordy[0]
|
||||
k=k+1
|
||||
print i
|
||||
BasePart.PartitionFaceBySketch(faces=BasePart.faces, sketch=ParSketch)
|
||||
#
|
||||
# Generate Sections and Section Assignments
|
||||
labelcount=1
|
||||
regions=BasePart.faces
|
||||
for eachregion in regions:
|
||||
mlabel='Mat'+str(labelcount)
|
||||
VerModel.PEGSection(name=mlabel, material=mlabel, thickness=0.01,
|
||||
wedgeAngle1=0.0, wedgeAngle2=0.0)
|
||||
BasePart.SectionAssignment(region=(eachregion,),
|
||||
sectionName=mlabel, offset=0.0, offsetField='')
|
||||
labelcount=labelcount+1
|
||||
#
|
||||
# Mesh Part
|
||||
BasePart.ReferencePoint(point=(0.0, 0.0, 0.0))
|
||||
if grainType=='Square':
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD, technique=STRUCTURED)
|
||||
elif grainType=='Hexagon':
|
||||
offsetX=0.
|
||||
offsetY=0.
|
||||
ParSketch2=VerModel.ConstrainedSketch(name='Hex',sheetSize=200, transform=partTransform)
|
||||
for i in range(0,2*numX):
|
||||
ParSketch2.Line(point1=(offsetX,0.),point2=(offsetX,2.*charLength*numY))
|
||||
offsetX=offsetX+xLength
|
||||
for i in range(0,numY):
|
||||
ParSketch2.Line(point1=(0.,offsetY),point2=(2.*charLength*numX,offsetY))
|
||||
offsetY=offsetY+3.*yLength
|
||||
BasePart.PartitionFaceBySketch(faces=BasePart.faces, sketch=ParSketch2)
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD, technique=SWEEP)
|
||||
elif grainType=='Voronoi':
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD_DOMINATED, technique=FREE)
|
||||
BasePart.seedPart(size=meshSize)
|
||||
pickedRegions =(BasePart.faces, )
|
||||
elemType1 = mesh.ElemType(elemCode=CPEG8R, elemLibrary=STANDARD)
|
||||
#elemType1 = mesh.ElemType(elemCode=CPEG4R, elemLibrary=STANDARD,hourglassControl=ENHANCED)
|
||||
BasePart.setElementType(regions=pickedRegions, elemTypes=(elemType1,))
|
||||
BasePart.generateMesh()
|
||||
#
|
||||
#Steps
|
||||
VerModel.StaticStep(name='Step-1', previous='Initial',
|
||||
maxNumInc=100000, initialInc=0.03, minInc=1e-07, maxInc=0.15, nlgeom=ON, timePeriod=20.)
|
||||
VerModel.fieldOutputRequests['F-Output-1'].setValues(variables=(
|
||||
'LE', 'RF', 'S', 'U'), timeInterval=0.2, timeMarks=OFF)
|
||||
#
|
||||
#Boundary Conditions
|
||||
VerAssembly.Instance(name='Strut',part=BasePart, dependent=ON)
|
||||
iNodes=VerAssembly.instances['Strut'].nodes
|
||||
toler=0.01*meshSize
|
||||
Left=iNodes.getByBoundingBox(xMin=-toler,xMax=toler,yMin=-toler,yMax=ySize+toler)
|
||||
BLeft=iNodes.getByBoundingBox(xMin=-toler,xMax=toler,yMin=-toler,yMax=toler)
|
||||
Right=iNodes.getByBoundingBox(xMin=xSize-toler,xMax=xSize+toler,yMin=toler,yMax=ySize+toler)
|
||||
BRight=iNodes.getByBoundingBox(xMin=xSize-toler,xMax=xSize+toler,yMin=-toler,yMax=toler)
|
||||
#
|
||||
Lregion=regionToolset.Region(nodes=Left)
|
||||
BLregion=regionToolset.Region(nodes=BLeft)
|
||||
Rregion=regionToolset.Region(nodes=Right)
|
||||
BRregion=regionToolset.Region(nodes=BRight)
|
||||
#
|
||||
VerModel.SmoothStepAmplitude(name='Amp-1', timeSpan=TOTAL, data=(( 0.0, 0.0), (24.00, 1.0)))
|
||||
VerModel.DisplacementBC(name='LeftX', createStepName='Initial',
|
||||
region=Lregion, u1=0.0, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY1', createStepName='Initial',
|
||||
region=BLregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
if analysis=='Tension':
|
||||
VerModel.DisplacementBC(name='Tension', createStepName='Step-1',
|
||||
region=BRregion, u1=0.5*xSize, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY2', createStepName='Initial',
|
||||
region=BRregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.boundaryConditions['Tension'].setValues(amplitude='Amp-1')
|
||||
else:
|
||||
VerModel.DisplacementBC(name='Bending', createStepName='Step-1',
|
||||
region=BRregion, u1=UNSET, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=-6., amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.boundaryConditions['Bending'].setValues(amplitude='Amp-1')
|
||||
#
|
||||
VerAssembly.Set(nodes=Right, name='Right')
|
||||
VerAssembly.Set(nodes=BRight, name='BRight')
|
||||
if analysis=='Tension':
|
||||
VerModel.Equation(name='Constraint-1', terms=((1.0, 'Right', 1), ( -1.0, 'BRight', 1)))
|
||||
else:
|
||||
region1=VerAssembly.sets['BRight']
|
||||
region2=VerAssembly.sets['Right']
|
||||
VerModel.MultipointConstraint(name='Constraint-2',
|
||||
controlPoint=region1, surface=region2, mpcType=BEAM_MPC,
|
||||
userMode=DOF_MODE_MPC, userType=0, csys=None)
|
||||
#
|
||||
#Create Job and write input file
|
||||
if grainType=='Square':
|
||||
letter1='S'
|
||||
elif grainType=='Hexagon':
|
||||
letter1='H'
|
||||
elif grainType=='Voronoi':
|
||||
letter1='V'
|
||||
if analysis=='Tension':
|
||||
letter2='T'
|
||||
else:
|
||||
letter2='B'
|
||||
label='W'+str(numY)+'L'+str(numX)+letter1+letter2+str(eachModel)
|
||||
VerFile.Job(name=label, model='Model-1', type=ANALYSIS,userSubroutine='ucrystal.for')
|
||||
VerFile.jobs[label].writeInput(consistencyChecking=OFF)
|
||||
# VerFile.close()
|
293
JMBBM13a/GeometryGenerators/CP_Generator_30_Exp.py
Normal file
293
JMBBM13a/GeometryGenerators/CP_Generator_30_Exp.py
Normal file
|
@ -0,0 +1,293 @@
|
|||
# GrainGen V3.0
|
||||
# This script generates idealised and representative meshed micro-structure geometries
|
||||
# in 2-D through the Abaqus geometry kernel. - J. Grogan, 25/09/2011
|
||||
#
|
||||
# Import Abaqus and External Modules
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
import random
|
||||
import regionToolset
|
||||
import mesh
|
||||
import step
|
||||
import part
|
||||
import interaction
|
||||
import subprocess
|
||||
#randomSeed=[39928822]
|
||||
randomSeed=[41557]
|
||||
randomSeed.append(39764)
|
||||
randomSeed.append(19230045)
|
||||
randomSeed.append(452398)
|
||||
randomSeed.append(872315)
|
||||
randomSeed.append(794738)
|
||||
randomSeed.append(224492579)
|
||||
randomSeed.append(96502382)
|
||||
randomSeed.append(4921299)
|
||||
randomSeed.append(3113145)
|
||||
randomSeed.append(36677835)
|
||||
for eachModel in range(0,1):
|
||||
#
|
||||
# Create Model Database
|
||||
VerFile=Mdb(pathName="MStructure")
|
||||
VerModel=VerFile.models['Model-1']
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
#
|
||||
# Assign Model Parameters
|
||||
#
|
||||
# Underlying Geometry
|
||||
xSize=0.1
|
||||
ySize=0.008925
|
||||
#
|
||||
# Microstructure Geometry
|
||||
charLength=0.00595# Grain Side Length
|
||||
numX=15
|
||||
numY=5
|
||||
# numGrains=528 # Voronoi Only
|
||||
numGrains=127 # Voronoi Only
|
||||
hardRad=0.00 # Voronoi Only
|
||||
#
|
||||
# Other Parametersvgrain vumat
|
||||
grainType='Hexagon' # Options: Square, Hexagon, Voronoi
|
||||
meshSize=0.001
|
||||
analysis='Tension' # Options: Tension, Bending
|
||||
#
|
||||
# Draw Base Part
|
||||
BasePart=VerModel.Part(name='Base', dimensionality=TWO_D_PLANAR,type=DEFORMABLE_BODY)
|
||||
BasePart.DatumPointByCoordinate((0,0,0))
|
||||
BasePart.DatumPointByCoordinate((xSize,0,0))
|
||||
BasePart.DatumPointByCoordinate((0,ySize,0))
|
||||
pdatums=BasePart.datums
|
||||
BasePart.DatumPlaneByThreePoints(point1=pdatums[1], point2=pdatums[2], point3=pdatums[3])
|
||||
BasePart.DatumAxisByTwoPoint(point1=pdatums[1],point2=pdatums[2])
|
||||
partTransform = BasePart.MakeSketchTransform(sketchPlane=pdatums[4], sketchUpEdge=pdatums[5],
|
||||
sketchPlaneSide=SIDE1, sketchOrientation=BOTTOM, origin=(0,0,0))
|
||||
BaseSketch = VerModel.ConstrainedSketch(name='Base',sheetSize=200, transform=partTransform)
|
||||
#
|
||||
BaseSketch.Line(point1=(0.,0.),point2=(xSize,0.))
|
||||
BaseSketch.Line(point1=(xSize,0.),point2=(xSize,ySize))
|
||||
BaseSketch.Line(point1=(xSize,ySize),point2=(0.,ySize))
|
||||
BaseSketch.Line(point1=(0.,ySize),point2=(0.,0.))
|
||||
BasePart.BaseShell(sketch=BaseSketch)
|
||||
BasePart=VerModel.parts['Base']
|
||||
#
|
||||
# Draw Microstructure and Partition Base Part
|
||||
ParSketch=VerModel.ConstrainedSketch(name='Base',sheetSize=200, transform=partTransform)
|
||||
if grainType=='Square':
|
||||
offset=0.
|
||||
for i in range(0,numX):
|
||||
ParSketch.Line(point1=(offset,0.),point2=(offset,numY*charLength))
|
||||
offset=offset+charLength
|
||||
offset=0.
|
||||
for i in range(0,numY):
|
||||
ParSketch.Line(point1=(0.,offset),point2=(numX*charLength,offset))
|
||||
offset=offset+charLength
|
||||
elif grainType=='Hexagon':
|
||||
yLength=sin(radians(30.))*charLength
|
||||
xLength=cos(radians(30.))*charLength
|
||||
offsetX=0.
|
||||
for i in range(0,numX):
|
||||
offsetY=0.
|
||||
for j in range(0,numY):
|
||||
if j%2==0:
|
||||
xPos=offsetX
|
||||
else:
|
||||
xPos=offsetX+xLength
|
||||
ParSketch.Line(point1=(xLength+xPos,-yLength+offsetY),point2=(xLength+xPos,yLength+offsetY))
|
||||
ParSketch.Line(point1=(xLength+xPos,+yLength+offsetY),point2=(xPos,2.*yLength+offsetY))
|
||||
ParSketch.Line(point1=(xLength+xPos,-yLength+offsetY),point2=(xPos,-2.*yLength+offsetY))
|
||||
offsetY=offsetY+3.*yLength
|
||||
offsetX=offsetX+2.*xLength
|
||||
elif grainType=='Voronoi':
|
||||
random.seed(randomSeed[eachModel])
|
||||
qhullin=open('qhullin.dat','w')
|
||||
qhullin.write("%i \n"%(2))
|
||||
qhullin.write("%i \n"%(numGrains*9))
|
||||
xlist=[0.]
|
||||
ylist=[0.]
|
||||
#
|
||||
#Generate Point Seeds - Hardcore Voronoi Method Optional
|
||||
for i in range(0,numGrains):
|
||||
outside=False
|
||||
while outside==False:
|
||||
xcor=random.random()*xSize
|
||||
ycor=random.random()*ySize
|
||||
if hardRad==0.:
|
||||
outside=True
|
||||
break
|
||||
if len(xlist)>1:
|
||||
distold=1000.
|
||||
for i in range(1,len(xlist)):
|
||||
distnew=(xcor-xlist[i])*(xcor-xlist[i])+(ycor-ylist[i])*(ycor-ylist[i])
|
||||
distnew=sqrt(distnew)
|
||||
if distnew<distold:
|
||||
distold=distnew
|
||||
if distold>=hardRad:
|
||||
outside=True
|
||||
else:
|
||||
outside=True
|
||||
xlist.append(xcor)
|
||||
ylist.append(ycor)
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor+ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor+ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor+ySize))
|
||||
qhullin.close()
|
||||
#
|
||||
# Generate tesselation externally and post-process results
|
||||
scales=open('scales.dat','w')
|
||||
scales.write("%18.6f %18.6f \n"%(xSize,ySize))
|
||||
scales.close()
|
||||
retcode=subprocess.call("qhull.exe v Qbb TI qhullin.dat o TO qhullout.dat")
|
||||
retcode=subprocess.call("Voronoi2DPost.exe")
|
||||
FortranFile=open('fortranout.dat')
|
||||
num_cells=int(FortranFile.readline())
|
||||
cordx=[]
|
||||
cordy=[]
|
||||
x1=[]
|
||||
y1=[]
|
||||
x2=[]
|
||||
y2=[]
|
||||
k=0
|
||||
#
|
||||
# Generate Partition Sketch
|
||||
for i in range(0,num_cells):
|
||||
num_verts=int(FortranFile.readline())
|
||||
for j in range(0,num_verts):
|
||||
coords=FortranFile.readline().split(',')
|
||||
cordx.append([])
|
||||
cordy.append([])
|
||||
cordx[j]=float(coords[0])
|
||||
cordy[j]=float(coords[1])
|
||||
for j in range(0,num_verts-1):
|
||||
ParSketch.Line(point1=(cordx[j],cordy[j]),point2=(cordx[j+1],cordy[j+1]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[j]
|
||||
y1[k]=cordy[j]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[j+1]
|
||||
y2[k]=cordy[j+1]
|
||||
k=k+1
|
||||
ParSketch.Line(point1=(cordx[num_verts-1],cordy[num_verts-1]),
|
||||
point2=(cordx[0],cordy[0]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[num_verts-1]
|
||||
y1[k]=cordy[num_verts-1]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[0]
|
||||
y2[k]=cordy[0]
|
||||
k=k+1
|
||||
print i
|
||||
BasePart.PartitionFaceBySketch(faces=BasePart.faces, sketch=ParSketch)
|
||||
#
|
||||
# Generate Sections and Section Assignments
|
||||
labelcount=1
|
||||
regions=BasePart.faces
|
||||
for eachregion in regions:
|
||||
mlabel='Mat'+str(labelcount)
|
||||
# VerModel.PEGSection(name=mlabel, material=mlabel, thickness=0.01,
|
||||
# wedgeAngle1=0.0, wedgeAngle2=0.0)
|
||||
VerModel.HomogeneousSolidSection(name=mlabel,material=mlabel, thickness=0.1)
|
||||
BasePart.SectionAssignment(region=(eachregion,),
|
||||
sectionName=mlabel, offset=0.0, offsetField='')
|
||||
labelcount=labelcount+1
|
||||
#
|
||||
# Mesh Part
|
||||
BasePart.ReferencePoint(point=(0.0, 0.0, 0.0))
|
||||
if grainType=='Square':
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD, technique=STRUCTURED)
|
||||
elif grainType=='Hexagon':
|
||||
offsetX=0.
|
||||
offsetY=0.
|
||||
ParSketch2=VerModel.ConstrainedSketch(name='Hex',sheetSize=200, transform=partTransform)
|
||||
for i in range(0,2*numX):
|
||||
ParSketch2.Line(point1=(offsetX,0.),point2=(offsetX,2.*charLength*numY))
|
||||
offsetX=offsetX+xLength
|
||||
for i in range(0,numY):
|
||||
ParSketch2.Line(point1=(0.,offsetY),point2=(2.*charLength*numX,offsetY))
|
||||
offsetY=offsetY+3.*yLength
|
||||
BasePart.PartitionFaceBySketch(faces=BasePart.faces, sketch=ParSketch2)
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD, technique=SWEEP)
|
||||
elif grainType=='Voronoi':
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD_DOMINATED, technique=FREE)
|
||||
BasePart.seedPart(size=meshSize)
|
||||
pickedRegions =(BasePart.faces, )
|
||||
# elemType1 = mesh.ElemType(elemCode=CPEG8R, elemLibrary=STANDARD)
|
||||
elemType1 = mesh.ElemType(elemCode=CPE4R)
|
||||
BasePart.setElementType(regions=pickedRegions, elemTypes=(elemType1,))
|
||||
BasePart.generateMesh()
|
||||
#
|
||||
#Steps
|
||||
VerModel.StaticStep(name='Step-1', previous='Initial',
|
||||
maxNumInc=100000, initialInc=0.03, minInc=1e-07, maxInc=0.15, nlgeom=ON, timePeriod=20.)
|
||||
VerModel.fieldOutputRequests['F-Output-1'].setValues(variables=(
|
||||
'LE', 'RF', 'S', 'U'), timeInterval=0.2, timeMarks=OFF)
|
||||
#
|
||||
#Boundary Conditions
|
||||
VerAssembly.Instance(name='Strut',part=BasePart, dependent=ON)
|
||||
iNodes=VerAssembly.instances['Strut'].nodes
|
||||
toler=0.01*meshSize
|
||||
Left=iNodes.getByBoundingBox(xMin=-toler,xMax=toler,yMin=-toler,yMax=ySize+toler)
|
||||
BLeft=iNodes.getByBoundingBox(xMin=-toler,xMax=toler,yMin=-toler,yMax=toler)
|
||||
Right=iNodes.getByBoundingBox(xMin=xSize-toler,xMax=xSize+toler,yMin=toler,yMax=ySize+toler)
|
||||
BRight=iNodes.getByBoundingBox(xMin=xSize-toler,xMax=xSize+toler,yMin=-toler,yMax=toler)
|
||||
#
|
||||
Lregion=regionToolset.Region(nodes=Left)
|
||||
BLregion=regionToolset.Region(nodes=BLeft)
|
||||
Rregion=regionToolset.Region(nodes=Right)
|
||||
BRregion=regionToolset.Region(nodes=BRight)
|
||||
#
|
||||
VerModel.SmoothStepAmplitude(name='Amp-1', timeSpan=TOTAL, data=(( 0.0, 0.0), (24.00, 1.0)))
|
||||
VerModel.DisplacementBC(name='LeftX', createStepName='Initial',
|
||||
region=Lregion, u1=0.0, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY1', createStepName='Initial',
|
||||
region=BLregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
if analysis=='Tension':
|
||||
VerModel.DisplacementBC(name='Tension', createStepName='Step-1',
|
||||
region=BRregion, u1=0.5*xSize, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY2', createStepName='Initial',
|
||||
region=BRregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.boundaryConditions['Tension'].setValues(amplitude='Amp-1')
|
||||
else:
|
||||
VerModel.DisplacementBC(name='Bending', createStepName='Step-1',
|
||||
region=BRregion, u1=UNSET, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=-6., amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.boundaryConditions['Bending'].setValues(amplitude='Amp-1')
|
||||
#
|
||||
VerAssembly.Set(nodes=Right, name='Right')
|
||||
VerAssembly.Set(nodes=BRight, name='BRight')
|
||||
if analysis=='Tension':
|
||||
VerModel.Equation(name='Constraint-1', terms=((1.0, 'Right', 1), ( -1.0, 'BRight', 1)))
|
||||
else:
|
||||
region1=VerAssembly.sets['BRight']
|
||||
region2=VerAssembly.sets['Right']
|
||||
VerModel.MultipointConstraint(name='Constraint-2',
|
||||
controlPoint=region1, surface=region2, mpcType=BEAM_MPC,
|
||||
userMode=DOF_MODE_MPC, userType=0, csys=None)
|
||||
#
|
||||
#Create Job and write input file
|
||||
if grainType=='Square':
|
||||
letter1='S'
|
||||
elif grainType=='Hexagon':
|
||||
letter1='H'
|
||||
elif grainType=='Voronoi':
|
||||
letter1='V'
|
||||
if analysis=='Tension':
|
||||
letter2='T'
|
||||
else:
|
||||
letter2='B'
|
||||
label='W'+str(numY)+'L'+str(numX)+letter1+letter2+str(eachModel)
|
||||
VerFile.Job(name=label, model='Model-1', type=ANALYSIS,userSubroutine='ucrystal.for')
|
||||
VerFile.jobs[label].writeInput(consistencyChecking=OFF)
|
||||
# VerFile.close()
|
292
JMBBM13a/GeometryGenerators/CP_Generator_60.py
Normal file
292
JMBBM13a/GeometryGenerators/CP_Generator_60.py
Normal file
|
@ -0,0 +1,292 @@
|
|||
# GrainGen V3.0
|
||||
# This script generates idealised and representative meshed micro-structure geometries
|
||||
# in 2-D through the Abaqus geometry kernel. - J. Grogan, 25/09/2011
|
||||
#
|
||||
# Import Abaqus and External Modules
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
import random
|
||||
import regionToolset
|
||||
import mesh
|
||||
import step
|
||||
import part
|
||||
import interaction
|
||||
import subprocess
|
||||
#randomSeed=[39928822]
|
||||
randomSeed=[41557]
|
||||
randomSeed.append(39764)
|
||||
randomSeed.append(19230045)
|
||||
randomSeed.append(452398)
|
||||
randomSeed.append(872315)
|
||||
randomSeed.append(794738)
|
||||
randomSeed.append(224492579)
|
||||
randomSeed.append(96502382)
|
||||
randomSeed.append(4921299)
|
||||
randomSeed.append(3113145)
|
||||
randomSeed.append(36677835)
|
||||
for eachModel in range(0,10):
|
||||
#
|
||||
# Create Model Database
|
||||
VerFile=Mdb(pathName="MStructure")
|
||||
VerModel=VerFile.models['Model-1']
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
#
|
||||
# Assign Model Parameters
|
||||
#
|
||||
# Underlying Geometry
|
||||
xSize=0.8
|
||||
ySize=0.06
|
||||
#
|
||||
# Microstructure Geometry
|
||||
charLength=0.0119# Grain Side Length
|
||||
numX=800
|
||||
numY=60
|
||||
# numGrains=528 # Voronoi Only
|
||||
numGrains=500 # Voronoi Only
|
||||
hardRad=0.00 # Voronoi Only
|
||||
#
|
||||
# Other Parametersvgrain vumat
|
||||
grainType='Voronoi' # Options: Square, Hexagon, Voronoi
|
||||
meshSize=0.001
|
||||
analysis='Tension' # Options: Tension, Bending
|
||||
#
|
||||
# Draw Base Part
|
||||
BasePart=VerModel.Part(name='Base', dimensionality=TWO_D_PLANAR,type=DEFORMABLE_BODY)
|
||||
BasePart.DatumPointByCoordinate((0,0,0))
|
||||
BasePart.DatumPointByCoordinate((xSize,0,0))
|
||||
BasePart.DatumPointByCoordinate((0,ySize,0))
|
||||
pdatums=BasePart.datums
|
||||
BasePart.DatumPlaneByThreePoints(point1=pdatums[1], point2=pdatums[2], point3=pdatums[3])
|
||||
BasePart.DatumAxisByTwoPoint(point1=pdatums[1],point2=pdatums[2])
|
||||
partTransform = BasePart.MakeSketchTransform(sketchPlane=pdatums[4], sketchUpEdge=pdatums[5],
|
||||
sketchPlaneSide=SIDE1, sketchOrientation=BOTTOM, origin=(0,0,0))
|
||||
BaseSketch = VerModel.ConstrainedSketch(name='Base',sheetSize=200, transform=partTransform)
|
||||
#
|
||||
BaseSketch.Line(point1=(0.,0.),point2=(xSize,0.))
|
||||
BaseSketch.Line(point1=(xSize,0.),point2=(xSize,ySize))
|
||||
BaseSketch.Line(point1=(xSize,ySize),point2=(0.,ySize))
|
||||
BaseSketch.Line(point1=(0.,ySize),point2=(0.,0.))
|
||||
BasePart.BaseShell(sketch=BaseSketch)
|
||||
BasePart=VerModel.parts['Base']
|
||||
#
|
||||
# Draw Microstructure and Partition Base Part
|
||||
ParSketch=VerModel.ConstrainedSketch(name='Base',sheetSize=200, transform=partTransform)
|
||||
if grainType=='Square':
|
||||
offset=0.
|
||||
for i in range(0,numX):
|
||||
ParSketch.Line(point1=(offset,0.),point2=(offset,numY*charLength))
|
||||
offset=offset+charLength
|
||||
offset=0.
|
||||
for i in range(0,numY):
|
||||
ParSketch.Line(point1=(0.,offset),point2=(numX*charLength,offset))
|
||||
offset=offset+charLength
|
||||
elif grainType=='Hexagon':
|
||||
yLength=sin(radians(30.))*charLength
|
||||
xLength=cos(radians(30.))*charLength
|
||||
offsetX=0.
|
||||
for i in range(0,numX):
|
||||
offsetY=0.
|
||||
for j in range(0,numY):
|
||||
if j%2==0:
|
||||
xPos=offsetX
|
||||
else:
|
||||
xPos=offsetX+xLength
|
||||
ParSketch.Line(point1=(xLength+xPos,-yLength+offsetY),point2=(xLength+xPos,yLength+offsetY))
|
||||
ParSketch.Line(point1=(xLength+xPos,+yLength+offsetY),point2=(xPos,2.*yLength+offsetY))
|
||||
ParSketch.Line(point1=(xLength+xPos,-yLength+offsetY),point2=(xPos,-2.*yLength+offsetY))
|
||||
offsetY=offsetY+3.*yLength
|
||||
offsetX=offsetX+2.*xLength
|
||||
elif grainType=='Voronoi':
|
||||
random.seed(randomSeed[eachModel])
|
||||
qhullin=open('qhullin.dat','w')
|
||||
qhullin.write("%i \n"%(2))
|
||||
qhullin.write("%i \n"%(numGrains*9))
|
||||
xlist=[0.]
|
||||
ylist=[0.]
|
||||
#
|
||||
#Generate Point Seeds - Hardcore Voronoi Method Optional
|
||||
for i in range(0,numGrains):
|
||||
outside=False
|
||||
while outside==False:
|
||||
xcor=random.random()*xSize
|
||||
ycor=random.random()*ySize
|
||||
if hardRad==0.:
|
||||
outside=True
|
||||
break
|
||||
if len(xlist)>1:
|
||||
distold=1000.
|
||||
for i in range(1,len(xlist)):
|
||||
distnew=(xcor-xlist[i])*(xcor-xlist[i])+(ycor-ylist[i])*(ycor-ylist[i])
|
||||
distnew=sqrt(distnew)
|
||||
if distnew<distold:
|
||||
distold=distnew
|
||||
if distold>=hardRad:
|
||||
outside=True
|
||||
else:
|
||||
outside=True
|
||||
xlist.append(xcor)
|
||||
ylist.append(ycor)
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor+ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor+ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor+ySize))
|
||||
qhullin.close()
|
||||
#
|
||||
# Generate tesselation externally and post-process results
|
||||
scales=open('scales.dat','w')
|
||||
scales.write("%18.6f %18.6f \n"%(xSize,ySize))
|
||||
scales.close()
|
||||
retcode=subprocess.call("qhull.exe v Qbb TI qhullin.dat o TO qhullout.dat")
|
||||
retcode=subprocess.call("Voronoi2DPost.exe")
|
||||
FortranFile=open('fortranout.dat')
|
||||
num_cells=int(FortranFile.readline())
|
||||
cordx=[]
|
||||
cordy=[]
|
||||
x1=[]
|
||||
y1=[]
|
||||
x2=[]
|
||||
y2=[]
|
||||
k=0
|
||||
#
|
||||
# Generate Partition Sketch
|
||||
for i in range(0,num_cells):
|
||||
num_verts=int(FortranFile.readline())
|
||||
for j in range(0,num_verts):
|
||||
coords=FortranFile.readline().split(',')
|
||||
cordx.append([])
|
||||
cordy.append([])
|
||||
cordx[j]=float(coords[0])
|
||||
cordy[j]=float(coords[1])
|
||||
for j in range(0,num_verts-1):
|
||||
ParSketch.Line(point1=(cordx[j],cordy[j]),point2=(cordx[j+1],cordy[j+1]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[j]
|
||||
y1[k]=cordy[j]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[j+1]
|
||||
y2[k]=cordy[j+1]
|
||||
k=k+1
|
||||
ParSketch.Line(point1=(cordx[num_verts-1],cordy[num_verts-1]),
|
||||
point2=(cordx[0],cordy[0]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[num_verts-1]
|
||||
y1[k]=cordy[num_verts-1]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[0]
|
||||
y2[k]=cordy[0]
|
||||
k=k+1
|
||||
print i
|
||||
BasePart.PartitionFaceBySketch(faces=BasePart.faces, sketch=ParSketch)
|
||||
#
|
||||
# Generate Sections and Section Assignments
|
||||
labelcount=1
|
||||
regions=BasePart.faces
|
||||
for eachregion in regions:
|
||||
mlabel='Mat'+str(labelcount)
|
||||
VerModel.PEGSection(name=mlabel, material=mlabel, thickness=0.01,
|
||||
wedgeAngle1=0.0, wedgeAngle2=0.0)
|
||||
BasePart.SectionAssignment(region=(eachregion,),
|
||||
sectionName=mlabel, offset=0.0, offsetField='')
|
||||
labelcount=labelcount+1
|
||||
#
|
||||
# Mesh Part
|
||||
BasePart.ReferencePoint(point=(0.0, 0.0, 0.0))
|
||||
if grainType=='Square':
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD, technique=STRUCTURED)
|
||||
elif grainType=='Hexagon':
|
||||
offsetX=0.
|
||||
offsetY=0.
|
||||
ParSketch2=VerModel.ConstrainedSketch(name='Hex',sheetSize=200, transform=partTransform)
|
||||
for i in range(0,2*numX):
|
||||
ParSketch2.Line(point1=(offsetX,0.),point2=(offsetX,2.*charLength*numY))
|
||||
offsetX=offsetX+xLength
|
||||
for i in range(0,numY):
|
||||
ParSketch2.Line(point1=(0.,offsetY),point2=(2.*charLength*numX,offsetY))
|
||||
offsetY=offsetY+3.*yLength
|
||||
BasePart.PartitionFaceBySketch(faces=BasePart.faces, sketch=ParSketch2)
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD, technique=SWEEP)
|
||||
elif grainType=='Voronoi':
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD_DOMINATED, technique=FREE)
|
||||
BasePart.seedPart(size=meshSize)
|
||||
pickedRegions =(BasePart.faces, )
|
||||
elemType1 = mesh.ElemType(elemCode=CPEG8R, elemLibrary=STANDARD)
|
||||
#elemType1 = mesh.ElemType(elemCode=CPEG4R, elemLibrary=STANDARD,hourglassControl=ENHANCED)
|
||||
BasePart.setElementType(regions=pickedRegions, elemTypes=(elemType1,))
|
||||
BasePart.generateMesh()
|
||||
#
|
||||
#Steps
|
||||
VerModel.StaticStep(name='Step-1', previous='Initial',
|
||||
maxNumInc=100000, initialInc=0.03, minInc=1e-07, maxInc=0.15, nlgeom=ON, timePeriod=20.)
|
||||
VerModel.fieldOutputRequests['F-Output-1'].setValues(variables=(
|
||||
'LE', 'RF', 'S', 'U'), timeInterval=0.2, timeMarks=OFF)
|
||||
#
|
||||
#Boundary Conditions
|
||||
VerAssembly.Instance(name='Strut',part=BasePart, dependent=ON)
|
||||
iNodes=VerAssembly.instances['Strut'].nodes
|
||||
toler=0.01*meshSize
|
||||
Left=iNodes.getByBoundingBox(xMin=-toler,xMax=toler,yMin=-toler,yMax=ySize+toler)
|
||||
BLeft=iNodes.getByBoundingBox(xMin=-toler,xMax=toler,yMin=-toler,yMax=toler)
|
||||
Right=iNodes.getByBoundingBox(xMin=xSize-toler,xMax=xSize+toler,yMin=toler,yMax=ySize+toler)
|
||||
BRight=iNodes.getByBoundingBox(xMin=xSize-toler,xMax=xSize+toler,yMin=-toler,yMax=toler)
|
||||
#
|
||||
Lregion=regionToolset.Region(nodes=Left)
|
||||
BLregion=regionToolset.Region(nodes=BLeft)
|
||||
Rregion=regionToolset.Region(nodes=Right)
|
||||
BRregion=regionToolset.Region(nodes=BRight)
|
||||
#
|
||||
VerModel.SmoothStepAmplitude(name='Amp-1', timeSpan=TOTAL, data=(( 0.0, 0.0), (24.00, 1.0)))
|
||||
VerModel.DisplacementBC(name='LeftX', createStepName='Initial',
|
||||
region=Lregion, u1=0.0, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY1', createStepName='Initial',
|
||||
region=BLregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
if analysis=='Tension':
|
||||
VerModel.DisplacementBC(name='Tension', createStepName='Step-1',
|
||||
region=BRregion, u1=0.5*xSize, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY2', createStepName='Initial',
|
||||
region=BRregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.boundaryConditions['Tension'].setValues(amplitude='Amp-1')
|
||||
else:
|
||||
VerModel.DisplacementBC(name='Bending', createStepName='Step-1',
|
||||
region=BRregion, u1=UNSET, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=-6., amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.boundaryConditions['Bending'].setValues(amplitude='Amp-1')
|
||||
#
|
||||
VerAssembly.Set(nodes=Right, name='Right')
|
||||
VerAssembly.Set(nodes=BRight, name='BRight')
|
||||
if analysis=='Tension':
|
||||
VerModel.Equation(name='Constraint-1', terms=((1.0, 'Right', 1), ( -1.0, 'BRight', 1)))
|
||||
else:
|
||||
region1=VerAssembly.sets['BRight']
|
||||
region2=VerAssembly.sets['Right']
|
||||
VerModel.MultipointConstraint(name='Constraint-2',
|
||||
controlPoint=region1, surface=region2, mpcType=BEAM_MPC,
|
||||
userMode=DOF_MODE_MPC, userType=0, csys=None)
|
||||
#
|
||||
#Create Job and write input file
|
||||
if grainType=='Square':
|
||||
letter1='S'
|
||||
elif grainType=='Hexagon':
|
||||
letter1='H'
|
||||
elif grainType=='Voronoi':
|
||||
letter1='V'
|
||||
if analysis=='Tension':
|
||||
letter2='T'
|
||||
else:
|
||||
letter2='B'
|
||||
label='W'+str(numY)+'L'+str(numX)+letter1+letter2+str(eachModel)
|
||||
VerFile.Job(name=label, model='Model-1', type=ANALYSIS,userSubroutine='ucrystal.for')
|
||||
VerFile.jobs[label].writeInput(consistencyChecking=OFF)
|
||||
# VerFile.close()
|
290
JMBBM13a/GeometryGenerators/CP_Generator_Single.py
Normal file
290
JMBBM13a/GeometryGenerators/CP_Generator_Single.py
Normal file
|
@ -0,0 +1,290 @@
|
|||
# GrainGen V3.0
|
||||
# This script generates idealised and representative meshed micro-structure geometries
|
||||
# in 2-D through the Abaqus geometry kernel. - J. Grogan, 25/09/2011
|
||||
#
|
||||
# Import Abaqus and External Modules
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
import random
|
||||
import regionToolset
|
||||
import mesh
|
||||
import step
|
||||
import part
|
||||
import interaction
|
||||
import subprocess
|
||||
randomSeed=[39928822]
|
||||
randomSeed.append(39764)
|
||||
randomSeed.append(19230045)
|
||||
randomSeed.append(452398)
|
||||
randomSeed.append(872315)
|
||||
randomSeed.append(794738)
|
||||
randomSeed.append(224492579)
|
||||
randomSeed.append(96502382)
|
||||
randomSeed.append(4921299)
|
||||
randomSeed.append(3113145)
|
||||
randomSeed.append(36677835)
|
||||
for eachModel in range(0,1):
|
||||
#
|
||||
# Create Model Database
|
||||
VerFile=Mdb(pathName="MStructure")
|
||||
VerModel=VerFile.models['Model-1']
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
#
|
||||
# Assign Model Parameters
|
||||
#
|
||||
# Underlying Geometry
|
||||
xSize=0.01
|
||||
ySize=0.01
|
||||
#
|
||||
# Microstructure Geometry
|
||||
charLength=0.01# Grain Side Length
|
||||
numX=1
|
||||
numY=1
|
||||
numGrains=82 # Voronoi Only
|
||||
hardRad=0.00 # Voronoi Only
|
||||
#
|
||||
# Other Parametersvgrain vumat
|
||||
grainType='Square' # Options: Square, Hexagon, Voronoi
|
||||
meshSize=0.001
|
||||
analysis='Tension' # Options: Tension, Bending
|
||||
#
|
||||
# Draw Base Part
|
||||
BasePart=VerModel.Part(name='Base', dimensionality=TWO_D_PLANAR,type=DEFORMABLE_BODY)
|
||||
BasePart.DatumPointByCoordinate((0,0,0))
|
||||
BasePart.DatumPointByCoordinate((xSize,0,0))
|
||||
BasePart.DatumPointByCoordinate((0,ySize,0))
|
||||
pdatums=BasePart.datums
|
||||
BasePart.DatumPlaneByThreePoints(point1=pdatums[1], point2=pdatums[2], point3=pdatums[3])
|
||||
BasePart.DatumAxisByTwoPoint(point1=pdatums[1],point2=pdatums[2])
|
||||
partTransform = BasePart.MakeSketchTransform(sketchPlane=pdatums[4], sketchUpEdge=pdatums[5],
|
||||
sketchPlaneSide=SIDE1, sketchOrientation=BOTTOM, origin=(0,0,0))
|
||||
BaseSketch = VerModel.ConstrainedSketch(name='Base',sheetSize=200, transform=partTransform)
|
||||
#
|
||||
BaseSketch.Line(point1=(0.,0.),point2=(xSize,0.))
|
||||
BaseSketch.Line(point1=(xSize,0.),point2=(xSize,ySize))
|
||||
BaseSketch.Line(point1=(xSize,ySize),point2=(0.,ySize))
|
||||
BaseSketch.Line(point1=(0.,ySize),point2=(0.,0.))
|
||||
BasePart.BaseShell(sketch=BaseSketch)
|
||||
BasePart=VerModel.parts['Base']
|
||||
#
|
||||
# Draw Microstructure and Partition Base Part
|
||||
ParSketch=VerModel.ConstrainedSketch(name='Base',sheetSize=200, transform=partTransform)
|
||||
if grainType=='Square':
|
||||
offset=0.
|
||||
for i in range(0,numX):
|
||||
ParSketch.Line(point1=(offset,0.),point2=(offset,numY*charLength))
|
||||
offset=offset+charLength
|
||||
offset=0.
|
||||
for i in range(0,numY):
|
||||
ParSketch.Line(point1=(0.,offset),point2=(numX*charLength,offset))
|
||||
offset=offset+charLength
|
||||
elif grainType=='Hexagon':
|
||||
yLength=sin(radians(30.))*charLength
|
||||
xLength=cos(radians(30.))*charLength
|
||||
offsetX=0.
|
||||
for i in range(0,numX):
|
||||
offsetY=0.
|
||||
for j in range(0,numY):
|
||||
if j%2==0:
|
||||
xPos=offsetX
|
||||
else:
|
||||
xPos=offsetX+xLength
|
||||
ParSketch.Line(point1=(xLength+xPos,-yLength+offsetY),point2=(xLength+xPos,yLength+offsetY))
|
||||
ParSketch.Line(point1=(xLength+xPos,+yLength+offsetY),point2=(xPos,2.*yLength+offsetY))
|
||||
ParSketch.Line(point1=(xLength+xPos,-yLength+offsetY),point2=(xPos,-2.*yLength+offsetY))
|
||||
offsetY=offsetY+3.*yLength
|
||||
offsetX=offsetX+2.*xLength
|
||||
elif grainType=='Voronoi':
|
||||
random.seed(randomSeed[eachModel])
|
||||
qhullin=open('qhullin.dat','w')
|
||||
qhullin.write("%i \n"%(2))
|
||||
qhullin.write("%i \n"%(numGrains*9))
|
||||
xlist=[0.]
|
||||
ylist=[0.]
|
||||
#
|
||||
#Generate Point Seeds - Hardcore Voronoi Method Optional
|
||||
for i in range(0,numGrains):
|
||||
outside=False
|
||||
while outside==False:
|
||||
xcor=random.random()*xSize
|
||||
ycor=random.random()*ySize
|
||||
if hardRad==0.:
|
||||
outside=True
|
||||
break
|
||||
if len(xlist)>1:
|
||||
distold=1000.
|
||||
for i in range(1,len(xlist)):
|
||||
distnew=(xcor-xlist[i])*(xcor-xlist[i])+(ycor-ylist[i])*(ycor-ylist[i])
|
||||
distnew=sqrt(distnew)
|
||||
if distnew<distold:
|
||||
distold=distnew
|
||||
if distold>=hardRad:
|
||||
outside=True
|
||||
else:
|
||||
outside=True
|
||||
xlist.append(xcor)
|
||||
ylist.append(ycor)
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor+ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor+ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+xSize,ycor-ySize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-xSize,ycor+ySize))
|
||||
qhullin.close()
|
||||
#
|
||||
# Generate tesselation externally and post-process results
|
||||
scales=open('scales.dat','w')
|
||||
scales.write("%18.6f %18.6f \n"%(xSize,ySize))
|
||||
scales.close()
|
||||
retcode=subprocess.call("qhull.exe v Qbb TI qhullin.dat o TO qhullout.dat")
|
||||
retcode=subprocess.call("Voronoi2DPost.exe")
|
||||
FortranFile=open('fortranout.dat')
|
||||
num_cells=int(FortranFile.readline())
|
||||
cordx=[]
|
||||
cordy=[]
|
||||
x1=[]
|
||||
y1=[]
|
||||
x2=[]
|
||||
y2=[]
|
||||
k=0
|
||||
#
|
||||
# Generate Partition Sketch
|
||||
for i in range(0,num_cells):
|
||||
num_verts=int(FortranFile.readline())
|
||||
for j in range(0,num_verts):
|
||||
coords=FortranFile.readline().split(',')
|
||||
cordx.append([])
|
||||
cordy.append([])
|
||||
cordx[j]=float(coords[0])
|
||||
cordy[j]=float(coords[1])
|
||||
for j in range(0,num_verts-1):
|
||||
ParSketch.Line(point1=(cordx[j],cordy[j]),point2=(cordx[j+1],cordy[j+1]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[j]
|
||||
y1[k]=cordy[j]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[j+1]
|
||||
y2[k]=cordy[j+1]
|
||||
k=k+1
|
||||
ParSketch.Line(point1=(cordx[num_verts-1],cordy[num_verts-1]),
|
||||
point2=(cordx[0],cordy[0]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[num_verts-1]
|
||||
y1[k]=cordy[num_verts-1]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[0]
|
||||
y2[k]=cordy[0]
|
||||
k=k+1
|
||||
print i
|
||||
# BasePart.PartitionFaceBySketch(faces=BasePart.faces, sketch=ParSketch)
|
||||
#
|
||||
# Generate Sections and Section Assignments
|
||||
labelcount=1
|
||||
regions=BasePart.faces
|
||||
for eachregion in regions:
|
||||
mlabel='Mat'+str(labelcount)
|
||||
VerModel.PEGSection(name=mlabel, material=mlabel, thickness=0.01,
|
||||
wedgeAngle1=0.0, wedgeAngle2=0.0)
|
||||
BasePart.SectionAssignment(region=(eachregion,),
|
||||
sectionName=mlabel, offset=0.0, offsetField='')
|
||||
labelcount=labelcount+1
|
||||
#
|
||||
# Mesh Part
|
||||
BasePart.ReferencePoint(point=(0.0, 0.0, 0.0))
|
||||
if grainType=='Square':
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD, technique=STRUCTURED)
|
||||
elif grainType=='Hexagon':
|
||||
offsetX=0.
|
||||
offsetY=0.
|
||||
ParSketch2=VerModel.ConstrainedSketch(name='Hex',sheetSize=200, transform=partTransform)
|
||||
for i in range(0,2*numX):
|
||||
ParSketch2.Line(point1=(offsetX,0.),point2=(offsetX,2.*charLength*numY))
|
||||
offsetX=offsetX+xLength
|
||||
for i in range(0,numY):
|
||||
ParSketch2.Line(point1=(0.,offsetY),point2=(2.*charLength*numX,offsetY))
|
||||
offsetY=offsetY+3.*yLength
|
||||
BasePart.PartitionFaceBySketch(faces=BasePart.faces, sketch=ParSketch2)
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD, technique=SWEEP)
|
||||
elif grainType=='Voronoi':
|
||||
BasePart.setMeshControls(regions=BasePart.faces, elemShape=QUAD_DOMINATED, technique=FREE)
|
||||
BasePart.seedPart(size=meshSize)
|
||||
pickedRegions =(BasePart.faces, )
|
||||
elemType1 = mesh.ElemType(elemCode=CPEG8R, elemLibrary=STANDARD)
|
||||
#elemType1 = mesh.ElemType(elemCode=CPEG4R, elemLibrary=STANDARD,hourglassControl=ENHANCED)
|
||||
BasePart.setElementType(regions=pickedRegions, elemTypes=(elemType1,))
|
||||
BasePart.generateMesh()
|
||||
#
|
||||
#Steps
|
||||
VerModel.StaticStep(name='Step-1', previous='Initial',
|
||||
maxNumInc=100000, initialInc=0.03, minInc=1e-07, maxInc=0.15, nlgeom=ON, timePeriod=35.)
|
||||
VerModel.fieldOutputRequests['F-Output-1'].setValues(variables=(
|
||||
'LE', 'RF', 'S', 'U'), timeInterval=0.2, timeMarks=OFF)
|
||||
#
|
||||
#Boundary Conditions
|
||||
VerAssembly.Instance(name='Strut',part=BasePart, dependent=ON)
|
||||
iNodes=VerAssembly.instances['Strut'].nodes
|
||||
toler=0.01*meshSize
|
||||
Left=iNodes.getByBoundingBox(xMin=-toler,xMax=toler,yMin=-toler,yMax=ySize+toler)
|
||||
BLeft=iNodes.getByBoundingBox(xMin=-toler,xMax=toler,yMin=-toler,yMax=toler)
|
||||
Right=iNodes.getByBoundingBox(xMin=xSize-toler,xMax=xSize+toler,yMin=toler,yMax=ySize+toler)
|
||||
BRight=iNodes.getByBoundingBox(xMin=xSize-toler,xMax=xSize+toler,yMin=-toler,yMax=toler)
|
||||
#
|
||||
Lregion=regionToolset.Region(nodes=Left)
|
||||
BLregion=regionToolset.Region(nodes=BLeft)
|
||||
Rregion=regionToolset.Region(nodes=Right)
|
||||
BRregion=regionToolset.Region(nodes=BRight)
|
||||
#
|
||||
VerModel.SmoothStepAmplitude(name='Amp-1', timeSpan=TOTAL, data=(( 0.0, 0.0), (48.00, 2.0)))
|
||||
VerModel.DisplacementBC(name='LeftX', createStepName='Initial',
|
||||
region=Lregion, u1=0.0, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY1', createStepName='Initial',
|
||||
region=BLregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
if analysis=='Tension':
|
||||
VerModel.DisplacementBC(name='Tension', createStepName='Step-1',
|
||||
region=BRregion, u1=0.5*xSize, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY2', createStepName='Initial',
|
||||
region=BRregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.boundaryConditions['Tension'].setValues(amplitude='Amp-1')
|
||||
else:
|
||||
VerModel.DisplacementBC(name='Bending', createStepName='Step-1',
|
||||
region=BRregion, u1=UNSET, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=-6., amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.boundaryConditions['Bending'].setValues(amplitude='Amp-1')
|
||||
#
|
||||
VerAssembly.Set(nodes=Right, name='Right')
|
||||
VerAssembly.Set(nodes=BRight, name='BRight')
|
||||
if analysis=='Tension':
|
||||
VerModel.Equation(name='Constraint-1', terms=((1.0, 'Right', 1), ( -1.0, 'BRight', 1)))
|
||||
else:
|
||||
region1=VerAssembly.sets['BRight']
|
||||
region2=VerAssembly.sets['Right']
|
||||
VerModel.MultipointConstraint(name='Constraint-2',
|
||||
controlPoint=region1, surface=region2, mpcType=BEAM_MPC,
|
||||
userMode=DOF_MODE_MPC, userType=0, csys=None)
|
||||
#
|
||||
#Create Job and write input file
|
||||
if grainType=='Square':
|
||||
letter1='S'
|
||||
elif grainType=='Hexagon':
|
||||
letter1='H'
|
||||
elif grainType=='Voronoi':
|
||||
letter1='V'
|
||||
if analysis=='Tension':
|
||||
letter2='T'
|
||||
else:
|
||||
letter2='B'
|
||||
label='W'+str(numY)+'L'+str(numX)+letter1+letter2+str(eachModel)
|
||||
VerFile.Job(name=label, model='Model-1', type=ANALYSIS,userSubroutine='ucrystal.for')
|
||||
VerFile.jobs[label].writeInput(consistencyChecking=OFF)
|
||||
# VerFile.close()
|
164
JMBBM13a/GeometryGenerators/GeoGen.py
Normal file
164
JMBBM13a/GeometryGenerators/GeoGen.py
Normal file
|
@ -0,0 +1,164 @@
|
|||
# GrainGen V2.0
|
||||
# This script generates idealised and representative meshed micro-structure geometries
|
||||
# in 2-D and 3-D through the Abaqus geometry kernel. - J. Grogan, 09/06/2011
|
||||
#
|
||||
# Import Abaqus and External Modules
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
import random
|
||||
import subprocess
|
||||
import regionToolset
|
||||
import mesh
|
||||
import step
|
||||
import part
|
||||
import interaction
|
||||
import GeomModules
|
||||
#
|
||||
# Create Model Database
|
||||
VerFile=Mdb(pathName="MStructure")
|
||||
VerModel=VerFile.models['Model-1']
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
#
|
||||
# Assign Model Parameters
|
||||
shape=1 # 1 - Square, 2- Hex, 3 -Dodec, 4- Voronoi
|
||||
part_type=3 # 2 - Shell, 3 - Solid
|
||||
dimension=3 # 2 - 2D, 3 - 3D
|
||||
rad=0.00595 # Characteristic Dimension (except Voronoi)
|
||||
meshsize=0.001 # Global Mesh Seed Size
|
||||
num_high=20 # Number of Grains in X-Dir
|
||||
num_wide=3 # Number of Grains in Y-Dir
|
||||
num_thick=3 # Number of Grains in Z-Dir
|
||||
num_grains=210# Target Number of Grains (Voronoi Only)
|
||||
scalex=3.4 # Voronoi Part Scale X-Dir (Voronoi Only)
|
||||
scaley=1. # Voronoi Part Scale Y-Dir (Voronoi Only)
|
||||
scalez=1. # Voronoi Part Scale Z-Dir (Voronoi Only)
|
||||
ana_type=1 # 1 - Crystal Plasticity, 2 - Corrosion
|
||||
hard_rad=0.0 # Hardcore voronoi min. radius (Voronoi Only)
|
||||
random_seed=2244763 # Random seed for voronoi grain generation or random vector generation
|
||||
#
|
||||
# Choose Script Function - Set to 1 to activate
|
||||
assemble_grains = 1 # Assemble Multiple Grains and Merge Them
|
||||
boolean_cut = 1 # Perform Boolean Cut Operation
|
||||
mesh_part = 0 # Mesh the Final Geometry
|
||||
mat_props = 0 # Assign Material Properties
|
||||
bound_conds = 0 # Generate steps and apply BCs
|
||||
write_output =0 # Write Output File
|
||||
post_proc = 0 # Postprocess INP file (Corrosion Only)
|
||||
#
|
||||
# For 2-D Solids thickness is set equal to one element
|
||||
if dimension==3:
|
||||
extrude_depth=rad
|
||||
else:
|
||||
extrude_depth=meshsize
|
||||
num_thick=1
|
||||
#
|
||||
# Draw a Square Grain
|
||||
if shape==1:
|
||||
GeomModules.DrawSquare(VerModel,part_type,rad,extrude_depth)
|
||||
#
|
||||
# Draw a Hexagonal Grain
|
||||
if shape==2:
|
||||
GeomModules.DrawHexagon(VerModel,part_type,rad,extrude_depth)
|
||||
#
|
||||
# Draw a Dodecahedral Grain
|
||||
if shape==3:
|
||||
GeomModules.DrawDodec(VerModel,rad)
|
||||
#
|
||||
# Draw a Voronoi Tessellation
|
||||
if shape==4:
|
||||
if dimension==2:
|
||||
maxsize=max(scalex,scaley)
|
||||
GeomModules.Voronoi2D(VerModel,part_type,extrude_depth,num_grains,maxsize,hard_rad,random_seed)
|
||||
else:
|
||||
maxsize=max(scalex,scaley,scalez)
|
||||
GeomModules.Voronoi3D(VerModel,num_grains,maxsize,hard_rad,random_seed)
|
||||
#
|
||||
# Assemble Base Parts
|
||||
if assemble_grains==1:
|
||||
if shape<=3:
|
||||
VerPart=VerModel.parts['Base']
|
||||
GeomModules.PatternParts(num_high,num_wide,num_thick,VerPart,rad,shape,VerModel)
|
||||
#
|
||||
# Make a Boolean Template
|
||||
if boolean_cut==1:
|
||||
if shape>1:
|
||||
GeomModules.BooleanPart(VerModel,part_type,rad,extrude_depth,num_high,
|
||||
num_wide,num_thick,shape,dimension,scalex,scaley,scalez)
|
||||
BoolPart=VerModel.parts['Template']
|
||||
#
|
||||
#Perform Boolean Cut
|
||||
if shape==1:
|
||||
VerPart=VerModel.parts['Merged']
|
||||
del VerAssembly.instances['Merged-1']
|
||||
else:
|
||||
VerAssembly.InstanceFromBooleanCut(name='FinalPart',
|
||||
instanceToBeCut=VerAssembly.instances['Merged-1'],
|
||||
cuttingInstances=(VerAssembly.instances['Template-1'], ),
|
||||
originalInstances=DELETE)
|
||||
del VerAssembly.instances['FinalPart-1']
|
||||
VerPart=VerModel.parts['FinalPart']
|
||||
#
|
||||
# Mesh Part
|
||||
if mesh_part==1:
|
||||
if shape<3:
|
||||
VerPart.setMeshControls(regions=VerPart.cells, elemShape=HEX, technique=STRUCTURED)
|
||||
if shape==3:
|
||||
VerPart.setMeshControls(regions=VerPart.cells, elemShape=TET, technique=FREE)
|
||||
if shape==4:
|
||||
if dimension==2:
|
||||
VerPart.setMeshControls(regions=VerPart.cells, elemShape=HEX, technique=SWEEP,
|
||||
algorithm=ADVANCING_FRONT)
|
||||
else:
|
||||
VerPart.setMeshControls(regions=VerPart.cells, elemShape=TET, technique=FREE)
|
||||
VerPart.seedPart(size=meshsize)
|
||||
VerPart.generateMesh()
|
||||
#
|
||||
# For Corrosion Analysis Output Part Vertices and Element Connectivity
|
||||
if ana_type==2:
|
||||
GeomModules.VertsConn(VerPart,dimension)
|
||||
ecor=open('ecor.dat','w')
|
||||
for eachface in VerPart.faces:
|
||||
if len(eachface.getAdjacentFaces())<7.:
|
||||
xnor=eachface.getNormal()[0]
|
||||
ynor=eachface.getNormal()[1]
|
||||
znor=eachface.getNormal()[2]
|
||||
if (xnor==0.)and(znor==0.):
|
||||
# if (ynor==1.)or(ynor==-1.):
|
||||
if (ynor==1.):
|
||||
ecor.write("%6.4f %6.4f %6.4f\n"%(xnor,ynor,znor))
|
||||
ecor.close()
|
||||
#
|
||||
#Generate Materials and Sections
|
||||
if mat_props==1:
|
||||
GeomModules.MatGen(ana_type,VerPart,VerModel,part_type,meshsize,random_seed)
|
||||
#
|
||||
#Steps and Boundary Conditions
|
||||
if bound_conds==1:
|
||||
VerModel.ExplicitDynamicsStep(name='Corrode', previous='Initial',
|
||||
massScaling=((SEMI_AUTOMATIC, MODEL, AT_BEGINNING, 0.0, 1e-06,
|
||||
BELOW_MIN, 0, 0, 0.0, 0.0, 0, None), ))
|
||||
VerModel.ExplicitDynamicsStep(name='Load', previous='Corrode',
|
||||
timePeriod=1.)
|
||||
VerModel.steps['Corrode'].Restart(numberIntervals=2,overlay=OFF,timeMarks=OFF)
|
||||
VerModel.steps['Load'].Restart(numberIntervals=2,overlay=OFF, timeMarks=OFF)
|
||||
VerModel.FieldOutputRequest(name='F-Output-1',
|
||||
createStepName='Corrode', variables=('A', 'CSTRESS', 'LE', 'PE',
|
||||
'PEEQ', 'RF', 'S', 'SDV', 'STATUS', 'U','V'), numIntervals=100)
|
||||
#
|
||||
#Loads and BCs
|
||||
VerAssembly.Instance(name='CorPart',part=VerPart, dependent=ON)
|
||||
iNodes=VerAssembly.instances['CorPart'].nodes
|
||||
# GeomModules.S1BCs(iNodes,VerModel,num_high,num_wide,num_thick,shape,
|
||||
# dimension,extrude_depth,rad,scalex,scaley,scalez)
|
||||
#
|
||||
#VerAssembly.Instance(name='CorPart',part=VerPart, dependent=ON)
|
||||
#Create Job and write input file
|
||||
if write_output ==1:
|
||||
VerFile.Job(name='GeomGenTemp', model='Model-1', type=ANALYSIS,
|
||||
explicitPrecision=SINGLE, nodalOutputPrecision=SINGLE,userSubroutine='',
|
||||
parallelizationMethodExplicit=DOMAIN,numDomains=1,multiprocessingMode=DEFAULT, numCpus=1)
|
||||
VerFile.jobs['GeomGenTemp'].writeInput(consistencyChecking=OFF)
|
||||
#
|
||||
# Perform Postprocessing for corrosion analysis
|
||||
if post_proc ==1:
|
||||
retcode=subprocess.call("GeomGenPost2.exe")
|
143
JMBBM13a/GeometryGenerators/GeoGen_Internal.py
Normal file
143
JMBBM13a/GeometryGenerators/GeoGen_Internal.py
Normal file
|
@ -0,0 +1,143 @@
|
|||
# GrainGen V2.0
|
||||
# This script generates idealised and representative meshed micro-structure geometries
|
||||
# in 2-D and 3-D through the Abaqus geometry kernel. - J. Grogan, 09/06/2011
|
||||
#
|
||||
# Import Neccesary Abaqus Modules
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
import random
|
||||
import subprocess
|
||||
import regionToolset
|
||||
import mesh
|
||||
import step
|
||||
import part
|
||||
import interaction
|
||||
import sys
|
||||
import GeomModules
|
||||
# Create CAE File and Set Up Model
|
||||
VerFile=Mdb(pathName="MStructure")
|
||||
ModelParams=open('pythonoptions.dat','r')
|
||||
VerModel=VerFile.models['Model-1']
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
# Read Model Params from File
|
||||
shape=int(ModelParams.readline())
|
||||
part_type=int(ModelParams.readline())
|
||||
dimension=int(ModelParams.readline())
|
||||
rad=float(ModelParams.readline())
|
||||
meshsize=float(ModelParams.readline())
|
||||
num_high=int(ModelParams.readline())
|
||||
num_wide=int(ModelParams.readline())
|
||||
num_thick=int(ModelParams.readline())
|
||||
num_grains=num_high*num_wide*num_thick
|
||||
num_grains=int(ModelParams.readline())
|
||||
scalex=float(ModelParams.readline())
|
||||
scaley=float(ModelParams.readline())
|
||||
ana_type=int(ModelParams.readline())
|
||||
hard_rad=float(ModelParams.readline())
|
||||
# For 2-D Solids thickness is set equal to one element
|
||||
if dimension==3:
|
||||
extrude_depth=rad
|
||||
else:
|
||||
extrude_depth=meshsize
|
||||
num_thick=1
|
||||
# Square Grains
|
||||
if shape==1:
|
||||
GeomModules.DrawSquare(VerModel,part_type,rad,extrude_depth)
|
||||
# Hexagonal Grains
|
||||
if shape==2:
|
||||
GeomModules.DrawHexagon(VerModel,part_type,rad,extrude_depth)
|
||||
# Dodecahedral Grains
|
||||
if shape==3:
|
||||
GeomModules.DrawDodec(VerModel,part_type,rad,extrude_depth)
|
||||
# Voronoi Tessellation
|
||||
if shape==4:
|
||||
if dimension==2:
|
||||
GeomModules.Voronoi2D(VerModel,part_type,rad,extrude_depth,num_grains,scalex,scaley,hard_rad)
|
||||
else:
|
||||
GeomModules.Voronoi3D(VerModel,part_type,rad,extrude_depth,num_grains,hard_rad)
|
||||
scalex=scalex/1.
|
||||
scaley=scaley/2.
|
||||
# Make Boolean Template
|
||||
if shape>1:
|
||||
GeomModules.BooleanPart(VerModel,part_type,rad,extrude_depth,num_high,
|
||||
num_wide,num_thick,shape,dimension,scalex,scaley)
|
||||
BoolPart=VerModel.parts['Template']
|
||||
# Instance base part - offset instances as required
|
||||
if shape<=3:
|
||||
VerPart=VerModel.parts['Base']
|
||||
GeomModules.PatternParts(num_high,num_wide,num_thick,VerPart,rad,shape,VerModel)
|
||||
OldPart=VerModel.parts['Merged']
|
||||
if shape==1:
|
||||
VerPart=VerModel.parts['Merged']
|
||||
del VerAssembly.instances['Merged-1']
|
||||
else:
|
||||
VerAssembly.InstanceFromBooleanCut(name='FinalPart',
|
||||
instanceToBeCut=VerAssembly.instances['Merged-1'],
|
||||
cuttingInstances=(VerAssembly.instances['Template-1'], ),
|
||||
originalInstances=DELETE)
|
||||
del VerAssembly.instances['FinalPart-1']
|
||||
VerPart=VerModel.parts['FinalPart']
|
||||
# Mesh Part
|
||||
if meshsize>0.:
|
||||
if shape<3:
|
||||
VerPart.setMeshControls(regions=VerPart.cells, elemShape=HEX, technique=STRUCTURED)
|
||||
if shape==3:
|
||||
VerPart.setMeshControls(regions=VerPart.cells, elemShape=TET, technique=FREE)
|
||||
if shape==4:
|
||||
if dimension==2:
|
||||
VerPart.setMeshControls(regions=VerPart.cells, elemShape=HEX, technique=SWEEP,
|
||||
algorithm=ADVANCING_FRONT)
|
||||
else:
|
||||
VerPart.setMeshControls(regions=VerPart.cells, elemShape=TET, technique=FREE)
|
||||
VerPart.seedPart(size=meshsize)
|
||||
VerPart.generateMesh()
|
||||
# For Corrosion Analysis Output Part Vertices and Element Connectivity
|
||||
if ana_type==2:
|
||||
GeomModules.VertsConn(OldPart,VerPart,dimension,shape,rad,extrude_depth)
|
||||
ecor=open('ecor.dat','w')
|
||||
for eachface in VerPart.faces:
|
||||
if len(eachface.getAdjacentFaces())<7.:
|
||||
xnor=eachface.getNormal()[0]
|
||||
ynor=eachface.getNormal()[1]
|
||||
znor=eachface.getNormal()[2]
|
||||
if (xnor==0.)and(znor==0.):
|
||||
# if (ynor==1.)or(ynor==-1.):
|
||||
if (ynor==1.):
|
||||
for eachelement in eachface.getElements():
|
||||
ecor.write("%i\n"%(eachelement.label))
|
||||
ecor.close()
|
||||
# Generate Materials and Sections
|
||||
MatName='Grain'
|
||||
CorRate=0.05
|
||||
GeomModules.MatGen(MatName,CorRate,ana_type,VerPart,VerModel,part_type,meshsize)
|
||||
MatName='Boundary'
|
||||
CorRate=0.5
|
||||
GeomModules.MatGen(MatName,CorRate,ana_type,VerPart,VerModel,part_type,meshsize)
|
||||
else:
|
||||
GeomModules.MatGen('',0.,ana_type,VerPart,VerModel,part_type,meshsize)
|
||||
#STEPS
|
||||
VerModel.ExplicitDynamicsStep(name='Corrode', previous='Initial',
|
||||
massScaling=((SEMI_AUTOMATIC, MODEL, AT_BEGINNING, 0.0, 1e-06,
|
||||
BELOW_MIN, 0, 0, 0.0, 0.0, 0, None), ))
|
||||
VerModel.ExplicitDynamicsStep(name='Load', previous='Corrode',
|
||||
timePeriod=1.)
|
||||
VerModel.steps['Corrode'].Restart(numberIntervals=2,overlay=OFF,timeMarks=OFF)
|
||||
VerModel.steps['Load'].Restart(numberIntervals=2,overlay=OFF, timeMarks=OFF)
|
||||
#Loads and BCs
|
||||
VerAssembly.Instance(name='CorPart',part=VerPart, dependent=ON)
|
||||
iNodes=VerAssembly.instances['CorPart'].nodes
|
||||
GeomModules.S1BCs(iNodes,VerModel,num_high,num_wide,num_thick,shape,
|
||||
dimension,extrude_depth,rad,scalex,scaley)
|
||||
#Create and Submit Job
|
||||
VerModel.FieldOutputRequest(name='F-Output-1',
|
||||
createStepName='Corrode', variables=(
|
||||
'A', 'CSTRESS', 'LE', 'PE', 'PEEQ', 'RF', 'S', 'SDV', 'STATUS', 'U',
|
||||
'V'), numIntervals=100)
|
||||
VerFile.Job(name='GeomGenTemp', model='Model-1', description='', type=ANALYSIS,
|
||||
atTime=None, waitMinutes=0, waitHours=0, queue=None,
|
||||
explicitPrecision=SINGLE, nodalOutputPrecision=SINGLE, echoPrint=OFF,
|
||||
modelPrint=OFF, contactPrint=OFF, historyPrint=OFF, userSubroutine='',
|
||||
scratch='', parallelizationMethodExplicit=DOMAIN, numDomains=4,
|
||||
activateLoadBalancing=False, multiprocessingMode=DEFAULT, numCpus=4)
|
||||
#OptFile.jobs['StentOpt1'].submit(consistencyChecking=OFF)
|
||||
VerFile.jobs['GeomGenTemp'].writeInput(consistencyChecking=OFF)
|
853
JMBBM13a/GeometryGenerators/GeomModules.py
Normal file
853
JMBBM13a/GeometryGenerators/GeomModules.py
Normal file
|
@ -0,0 +1,853 @@
|
|||
# Draw a Square Grain
|
||||
#
|
||||
def DrawSquare(VerModel,part_type,rad,extrude_depth):
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
label='Base'
|
||||
if part_type==3:
|
||||
VerPart=VerModel.Part(name=label, dimensionality=THREE_D,type=DEFORMABLE_BODY)
|
||||
else:
|
||||
VerPart=VerModel.Part(name=label, dimensionality=TWO_D_PLANAR,type=DEFORMABLE_BODY)
|
||||
VerPart.DatumPointByCoordinate((0,0,0))
|
||||
VerPart.DatumPointByCoordinate((1,0,0))
|
||||
VerPart.DatumPointByCoordinate((0,1,0))
|
||||
pdatums=VerPart.datums
|
||||
VerPart.DatumPlaneByThreePoints(point1=pdatums[1], point2=pdatums[2], point3=pdatums[3])
|
||||
VerPart.DatumAxisByTwoPoint(point1=pdatums[1],point2=pdatums[2])
|
||||
partTransform = VerPart.MakeSketchTransform(sketchPlane=pdatums[4], sketchUpEdge=pdatums[5],
|
||||
sketchPlaneSide=SIDE1, sketchOrientation=BOTTOM, origin=(0,0,0))
|
||||
VerSketch = VerModel.ConstrainedSketch(name=label,sheetSize=200, transform=partTransform)
|
||||
VerSketch.Line(point1=(0.,0.),point2=(rad,0.))
|
||||
VerSketch.Line(point1=(rad,0.),point2=(rad,rad))
|
||||
VerSketch.Line(point1=(rad,rad),point2=(0.,rad))
|
||||
VerSketch.Line(point1=(0.,rad),point2=(0.,0.))
|
||||
if part_type==3:
|
||||
VerPart.BaseSolidExtrude(sketch=VerSketch,depth=extrude_depth)
|
||||
else:
|
||||
VerPart.BaseShell(sketch=VerSketch)
|
||||
# Draw a Hexagonal Grain
|
||||
#
|
||||
def DrawHexagon(VerModel,part_type,rad,extrude_depth):
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
label='Base'
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
if part_type==3:
|
||||
VerPart=VerModel.Part(name=label, dimensionality=THREE_D,type=DEFORMABLE_BODY)
|
||||
else:
|
||||
VerPart=VerModel.Part(name=label, dimensionality=TWO_D_PLANAR,type=DEFORMABLE_BODY)
|
||||
VerPart.DatumPointByCoordinate((0,0,0))
|
||||
VerPart.DatumPointByCoordinate((1,0,0))
|
||||
VerPart.DatumPointByCoordinate((0,1,0))
|
||||
pdatums=VerPart.datums
|
||||
VerPart.DatumPlaneByThreePoints(point1=pdatums[1], point2=pdatums[2], point3=pdatums[3])
|
||||
VerPart.DatumAxisByTwoPoint(point1=pdatums[1],point2=pdatums[2])
|
||||
partTransform = VerPart.MakeSketchTransform(sketchPlane=pdatums[4], sketchUpEdge=pdatums[5],
|
||||
sketchPlaneSide=SIDE1, sketchOrientation=BOTTOM, origin=(0,0,0))
|
||||
VerSketch = VerModel.ConstrainedSketch(name=label,sheetSize=200, transform=partTransform)
|
||||
yheight=sin(radians(30.))
|
||||
xheight=cos(radians(30.))
|
||||
VerSketch.Line(point1=(0.,0.),point2=(rad*xheight,rad*yheight))
|
||||
VerSketch.Line(point1=(rad*xheight,rad*yheight),point2=(rad*xheight,rad*yheight+rad))
|
||||
VerSketch.Line(point1=(rad*xheight,rad*yheight+rad),point2=(0.,2.*rad*yheight+rad))
|
||||
VerSketch.Line(point1=(0.,2.*rad*yheight+rad),point2=(-rad*xheight,rad*yheight+rad))
|
||||
VerSketch.Line(point1=(-rad*xheight,rad*yheight+rad),point2=(-rad*xheight,rad*yheight))
|
||||
VerSketch.Line(point1=(-rad*xheight,rad*yheight),point2=(0.,0.))
|
||||
if part_type==3:
|
||||
VerPart.BaseSolidExtrude(sketch=VerSketch,depth=extrude_depth)
|
||||
else:
|
||||
VerPart.BaseShell(sketch=VerSketch)
|
||||
BasePart=VerModel.parts['Base']
|
||||
BasePartCells = BasePart.cells
|
||||
BasePartFaces = BasePart.faces
|
||||
BasePartVerts = BasePart.vertices
|
||||
if part_type==3:
|
||||
BasePart.PartitionCellByPlaneThreePoints(point1=BasePartVerts[4], point2=BasePartVerts[10],
|
||||
point3=BasePartVerts[11], cells=BasePartCells)
|
||||
else:
|
||||
BasePart.PartitionFaceByShortestPath(point1=BasePartVerts[4], point2=BasePartVerts[1],
|
||||
faces=BasePartFaces)
|
||||
# Draw a Dodecahedral Grain
|
||||
#
|
||||
def DrawDodec(VerModel,rad):
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
label='BaseTemp'
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
VerPart=VerModel.Part(name=label, dimensionality=THREE_D,type=DEFORMABLE_BODY)
|
||||
VerPart.DatumPointByCoordinate((0,0,0))
|
||||
VerPart.DatumPointByCoordinate((1,0,0))
|
||||
VerPart.DatumPointByCoordinate((0,1,0))
|
||||
pdatums=VerPart.datums
|
||||
VerPart.DatumPlaneByThreePoints(point1=pdatums[1], point2=pdatums[2], point3=pdatums[3])
|
||||
VerPart.DatumAxisByTwoPoint(point1=pdatums[1],point2=pdatums[2])
|
||||
partTransform = VerPart.MakeSketchTransform(sketchPlane=pdatums[4], sketchUpEdge=pdatums[5],
|
||||
sketchPlaneSide=SIDE1, sketchOrientation=BOTTOM, origin=(0,0,0))
|
||||
VerSketch = VerModel.ConstrainedSketch(name=label,sheetSize=200, transform=partTransform)
|
||||
VerSketch.Line(point1=(0.,0.),point2=(sqrt(2.)*rad,rad))
|
||||
VerSketch.Line(point1=(sqrt(2.)*rad,rad),point2=(0.,2.*rad))
|
||||
VerSketch.Line(point1=(0.,2.*rad),point2=(-sqrt(2.)*rad,rad))
|
||||
VerSketch.Line(point1=(-sqrt(2.)*rad,rad),point2=(0.,0.))
|
||||
VerPart.BaseShell(sketch=VerSketch)
|
||||
for i in range (1,13):
|
||||
dodecname='dodec'+str(i)
|
||||
VerAssembly.Instance(name=dodecname,part=VerPart, dependent=ON)
|
||||
VerAssembly.translate(instanceList=('dodec2', ), vector=(0.,0.,-2.*sqrt(2.)*rad))
|
||||
VerAssembly.rotate(instanceList=('dodec3','dodec4', ), axisPoint=(0.0, 0.0, 0.0),
|
||||
axisDirection=(0.0, 1., 0.0), angle=90.0)
|
||||
VerAssembly.translate(instanceList=('dodec3', ), vector=(sqrt(2.)*rad,0.,0.))
|
||||
VerAssembly.translate(instanceList=('dodec4', ), vector=(-sqrt(2.)*rad,0.,0.))
|
||||
VerAssembly.translate(instanceList=('dodec3','dodec4', ), vector=(0.,0.,-sqrt(2.)*rad))
|
||||
VerAssembly.rotate(instanceList=('dodec5','dodec6','dodec7','dodec8',),
|
||||
axisPoint=(-sqrt(2.)*rad, rad, 0.0), axisDirection=(0., 0., 1.), angle=90.0)
|
||||
VerAssembly.rotate(instanceList=('dodec5','dodec6','dodec7','dodec8',),
|
||||
axisPoint=(-sqrt(2.)*rad, rad, 0.0), axisDirection=(0., 1., 0.), angle=-45.0)
|
||||
VerAssembly.rotate(instanceList=('dodec5','dodec6','dodec7','dodec8',),
|
||||
axisPoint=(-sqrt(2.)*rad, rad, 0.0), axisDirection=(1., 0., 1.), angle=-45.0)
|
||||
VerAssembly.rotate(instanceList=('dodec6',),
|
||||
axisPoint=(0., rad, -sqrt(2.)*rad), axisDirection=(0., 1., 0.), angle=90.0)
|
||||
VerAssembly.rotate(instanceList=('dodec7',),
|
||||
axisPoint=(0., rad, -sqrt(2.)*rad), axisDirection=(0., 1., 0.), angle=180.0)
|
||||
VerAssembly.rotate(instanceList=('dodec8',),
|
||||
axisPoint=(0., rad, -sqrt(2.)*rad), axisDirection=(0., 1., 0.), angle=270.0)
|
||||
VerAssembly.rotate(instanceList=('dodec9','dodec10','dodec11','dodec12',),
|
||||
axisPoint=(-sqrt(2.)*rad, rad, 0.0), axisDirection=(0., 0., 1.), angle=-90.0)
|
||||
VerAssembly.rotate(instanceList=('dodec9','dodec10','dodec11','dodec12',),
|
||||
axisPoint=(-sqrt(2.)*rad, rad, 0.0), axisDirection=(0., 1., 0.), angle=-45.0)
|
||||
VerAssembly.rotate(instanceList=('dodec9','dodec10','dodec11','dodec12',),
|
||||
axisPoint=(-sqrt(2.)*rad, rad, 0.0), axisDirection=(1., 0., 1.), angle=45.0)
|
||||
VerAssembly.rotate(instanceList=('dodec10',),
|
||||
axisPoint=(0., rad, -sqrt(2.)*rad), axisDirection=(0., -1., 0.), angle=90.0)
|
||||
VerAssembly.rotate(instanceList=('dodec11',),
|
||||
axisPoint=(0., rad, -sqrt(2.)*rad), axisDirection=(0., -1., 0.), angle=180.0)
|
||||
VerAssembly.rotate(instanceList=('dodec12',),
|
||||
axisPoint=(0., rad, -sqrt(2.)*rad), axisDirection=(0., -1., 0.), angle=270.0)
|
||||
VerAssembly.InstanceFromBooleanMerge(name='Base', instances=(
|
||||
VerAssembly.instances['dodec1'],
|
||||
VerAssembly.instances['dodec2'], VerAssembly.instances['dodec3'],
|
||||
VerAssembly.instances['dodec4'], VerAssembly.instances['dodec5'],
|
||||
VerAssembly.instances['dodec6'], VerAssembly.instances['dodec7'],
|
||||
VerAssembly.instances['dodec8'], VerAssembly.instances['dodec9'],
|
||||
VerAssembly.instances['dodec10'],VerAssembly.instances['dodec11'],
|
||||
VerAssembly.instances['dodec12'], ),
|
||||
keepIntersections=ON, originalInstances=SUPPRESS, domain=GEOMETRY)
|
||||
VerPart=VerModel.parts['Base']
|
||||
VerPart.AddCells(faceList = VerPart.faces)
|
||||
for i in range (1,12):
|
||||
dodecname='dodec'+str(i)
|
||||
del VerAssembly.instances[dodecname]
|
||||
del VerAssembly.instances['Base-1']
|
||||
# Draw a 2D Voronoi Tessellation
|
||||
#
|
||||
def Voronoi2D(VerModel,part_type,extrude_depth,num_grains,maxsize,hard_rad,random_seed):
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
import random
|
||||
import subprocess
|
||||
xlist=[0.]
|
||||
ylist=[0.]
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
random.seed(random_seed)
|
||||
qhullin=open('qhullin.dat','w')
|
||||
qhullin.write("%i \n"%(2))
|
||||
qhullin.write("%i \n"%(num_grains*9))
|
||||
for i in range(0,num_grains):
|
||||
outside=False
|
||||
while outside==False:
|
||||
xcor=random.random()*maxsize
|
||||
ycor=random.random()*maxsize
|
||||
if hard_rad==0.:
|
||||
outside=True
|
||||
break
|
||||
if len(xlist)>1:
|
||||
distold=1000.
|
||||
for i in range(1,len(xlist)):
|
||||
distnew=(xcor-xlist[i])*(xcor-xlist[i])+(ycor-ylist[i])*(ycor-ylist[i])
|
||||
distnew=sqrt(distnew)
|
||||
if distnew<distold:
|
||||
distold=distnew
|
||||
if distold>=hard_rad:
|
||||
outside=True
|
||||
else:
|
||||
outside=True
|
||||
xlist.append(xcor)
|
||||
ylist.append(ycor)
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+maxsize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-maxsize,ycor))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor+maxsize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor,ycor-maxsize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+maxsize,ycor+maxsize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-maxsize,ycor-maxsize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor+maxsize,ycor-maxsize))
|
||||
qhullin.write("%18.6f %18.6f \n"%(xcor-maxsize,ycor+maxsize))
|
||||
qhullin.close()
|
||||
scales=open('scales.dat','w')
|
||||
scales.write("%18.6f \n"%(maxsize))
|
||||
scales.close()
|
||||
retcode=subprocess.call("qhull.exe v Qbb TI qhullin.dat o TO qhullout.dat")
|
||||
retcode=subprocess.call("Voronoi2DPost.exe")
|
||||
FortranFile=open('fortranout.dat')
|
||||
num_cells=int(FortranFile.readline())
|
||||
cordx=[]
|
||||
cordy=[]
|
||||
x1=[]
|
||||
y1=[]
|
||||
x2=[]
|
||||
y2=[]
|
||||
k=0
|
||||
for i in range(0,num_cells):
|
||||
label='Cell'+str(i)
|
||||
if part_type==3:
|
||||
VerPart=VerModel.Part(name=label, dimensionality=THREE_D,type=DEFORMABLE_BODY)
|
||||
else:
|
||||
VerPart=VerModel.Part(name=label, dimensionality=TWO_D_PLANAR,type=DEFORMABLE_BODY)
|
||||
# Constuct Datum Point At Each Node
|
||||
VerPart.DatumPointByCoordinate((0,0,0))
|
||||
VerPart.DatumPointByCoordinate((1,0,0))
|
||||
VerPart.DatumPointByCoordinate((0,1,0))
|
||||
pdatums=VerPart.datums
|
||||
# Constuct Datum Plane on Element Face and Datum Axis Along Element Base
|
||||
VerPart.DatumPlaneByThreePoints(point1=pdatums[1],
|
||||
point2=pdatums[2], point3=pdatums[3])
|
||||
VerPart.DatumAxisByTwoPoint(point1=pdatums[1],point2=pdatums[2])
|
||||
# Sketch New Part Geometry Over Original Element
|
||||
partTransform = VerPart.MakeSketchTransform(sketchPlane=pdatums[4],
|
||||
sketchUpEdge=pdatums[5],
|
||||
sketchPlaneSide=SIDE1, sketchOrientation=BOTTOM, origin=(0,0,0))
|
||||
VerSketch = VerModel.ConstrainedSketch(name=label,sheetSize=200,
|
||||
transform=partTransform)
|
||||
num_verts=int(FortranFile.readline())
|
||||
for j in range(0,num_verts):
|
||||
coords=FortranFile.readline().split(',')
|
||||
cordx.append([])
|
||||
cordy.append([])
|
||||
cordx[j]=float(coords[0])
|
||||
cordy[j]=float(coords[1])
|
||||
print i,num_verts
|
||||
for j in range(0,num_verts-1):
|
||||
VerSketch.Line(point1=(cordx[j],cordy[j]),point2=(cordx[j+1],cordy[j+1]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[j]
|
||||
y1[k]=cordy[j]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[j+1]
|
||||
y2[k]=cordy[j+1]
|
||||
k=k+1
|
||||
VerSketch.Line(point1=(cordx[num_verts-1],cordy[num_verts-1]),
|
||||
point2=(cordx[0],cordy[0]))
|
||||
x1.append([])
|
||||
y1.append([])
|
||||
x1[k]=cordx[num_verts-1]
|
||||
y1[k]=cordy[num_verts-1]
|
||||
x2.append([])
|
||||
y2.append([])
|
||||
x2[k]=cordx[0]
|
||||
y2[k]=cordy[0]
|
||||
k=k+1
|
||||
print i,num_verts,k
|
||||
if part_type==3:
|
||||
VerPart.BaseSolidExtrude(sketch=VerSketch, depth=extrude_depth)
|
||||
else:
|
||||
VerPart.Shell(sketchPlane=pdatums[4], sketchUpEdge=pdatums[5], sketchPlaneSide=SIDE1,
|
||||
sketchOrientation=BOTTOM, sketch=VerSketch)
|
||||
VerAssembly.Instance(name=label,part=VerPart)
|
||||
inst=[]
|
||||
inst.append([])
|
||||
for i in range(0,num_cells):
|
||||
inst[i]=VerAssembly.instances['Cell'+str(i)]
|
||||
if i<num_cells-1:
|
||||
inst.append([])
|
||||
VerAssembly.InstanceFromBooleanMerge(name='Merged',
|
||||
instances=inst,originalInstances=DELETE, keepIntersections=ON,domain=GEOMETRY)
|
||||
# Draw a 3D Voronoi Tessellation
|
||||
#
|
||||
def Voronoi3D(VerModel,num_grains,maxsize,hard_rad,random_seed):
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
import random
|
||||
import subprocess
|
||||
xlist=[0.]
|
||||
ylist=[0.]
|
||||
zlist=[0.]
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
random.seed(random_seed)
|
||||
qhullin=open('qhullin.dat','w')
|
||||
qhullin.write("%i \n"%(3))
|
||||
qhullin.write("%i \n"%(num_grains*27))
|
||||
for i in range(0,num_grains):
|
||||
outside=False
|
||||
while outside==False:
|
||||
xcor=random.random()*maxsize
|
||||
ycor=random.random()*maxsize
|
||||
zcor=random.random()*maxsize
|
||||
if hard_rad==0.:
|
||||
outside=True
|
||||
break
|
||||
if len(xlist)>1:
|
||||
distold=1000.
|
||||
for i in range(1,len(xlist)):
|
||||
distnew=(xcor-xlist[i])*(xcor-xlist[i])+(ycor-ylist[i])*(ycor-ylist[i])
|
||||
distnew=distnew+(zcor-zlist[i])*(zcor-zlist[i])
|
||||
distnew=sqrt(distnew)
|
||||
if distnew<distold:
|
||||
distold=distnew
|
||||
if distold>=hard_rad:
|
||||
outside=True
|
||||
else:
|
||||
outside=True
|
||||
xlist.append(xcor)
|
||||
ylist.append(ycor)
|
||||
zlist.append(zcor)
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor,ycor,zcor))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor+maxsize,ycor,zcor))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor-maxsize,ycor,zcor))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor,ycor+maxsize,zcor))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor,ycor-maxsize,zcor))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor+maxsize,ycor+maxsize,zcor))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor-maxsize,ycor-maxsize,zcor))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor+maxsize,ycor-maxsize,zcor))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor-maxsize,ycor+maxsize,zcor))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor,ycor,zcor+maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor+maxsize,ycor,zcor+maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor-maxsize,ycor,zcor+maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor,ycor+maxsize,zcor+maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor,ycor-maxsize,zcor+maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor+maxsize,ycor+maxsize,zcor+maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor-maxsize,ycor-maxsize,zcor+maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor+maxsize,ycor-maxsize,zcor+maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor-maxsize,ycor+maxsize,zcor+maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor,ycor,zcor-maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor+maxsize,ycor,zcor-maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor-maxsize,ycor,zcor-maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor,ycor+maxsize,zcor-maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor,ycor-maxsize,zcor-maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor+maxsize,ycor+maxsize,zcor-maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor-maxsize,ycor-maxsize,zcor-maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor+maxsize,ycor-maxsize,zcor-maxsize))
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor-maxsize,ycor+maxsize,zcor-maxsize))
|
||||
qhullin.close()
|
||||
scales=open('scales.dat','w')
|
||||
scales.write("%18.6f \n"%(maxsize))
|
||||
scales.close()
|
||||
retcode=subprocess.call("qvoronoi.exe TI qhullin.dat o Fi TO qhullout.dat")
|
||||
retcode=subprocess.call("Voronoi3DPost.exe")
|
||||
FortranFile=open('fortranout.dat')
|
||||
num_cells=int(FortranFile.readline())
|
||||
cordx=[]
|
||||
cordy=[]
|
||||
cordz=[]
|
||||
x1=[]
|
||||
y1=[]
|
||||
x2=[]
|
||||
y2=[]
|
||||
k=0
|
||||
for k in range(0,num_cells):
|
||||
ibreak=0
|
||||
num_hyp=int(FortranFile.readline())
|
||||
for i in range(0,num_hyp):
|
||||
label='C'+str(k)+'H'+str(i)
|
||||
VerPart=VerModel.Part(name=label, dimensionality=THREE_D,type=DEFORMABLE_BODY)
|
||||
# Constuct Datum Point At Each Node
|
||||
num_verts=int(FortranFile.readline())
|
||||
for j in range(0,num_verts):
|
||||
coords=FortranFile.readline().split(',')
|
||||
cordx.append([])
|
||||
cordy.append([])
|
||||
cordz.append([])
|
||||
cordx[j]=float(coords[0])
|
||||
cordy[j]=float(coords[1])
|
||||
cordz[j]=float(coords[2])
|
||||
VerPart.DatumPointByCoordinate((cordx[j],cordy[j],cordz[j]))
|
||||
pdatums=VerPart.datums
|
||||
p1x=pdatums[1].pointOn[0]
|
||||
p1y=pdatums[1].pointOn[1]
|
||||
p1z=pdatums[1].pointOn[2]
|
||||
tol=1.e-4
|
||||
for m in range(2,num_verts+1):
|
||||
px=pdatums[m].pointOn[0]
|
||||
py=pdatums[m].pointOn[1]
|
||||
pz=pdatums[m].pointOn[2]
|
||||
p1pk=sqrt((p1x-px)*(p1x-px)+(p1y-py)*(p1y-py)+(p1z-pz)*(p1z-pz))
|
||||
if p1pk>tol:
|
||||
index1=m
|
||||
p2x=px
|
||||
p2y=py
|
||||
p2z=pz
|
||||
break
|
||||
for m in range(2,num_verts+1):
|
||||
if m!=index1:
|
||||
px=pdatums[m].pointOn[0]
|
||||
py=pdatums[m].pointOn[1]
|
||||
pz=pdatums[m].pointOn[2]
|
||||
p1pk=sqrt((p1x-px)*(p1x-px)+(p1y-py)*(p1y-py)+(p1z-pz)*(p1z-pz))
|
||||
p2pk=sqrt((p2x-px)*(p2x-px)+(p2y-py)*(p2y-py)+(p2z-pz)*(p2z-pz))
|
||||
if p1pk>tol:
|
||||
if p2pk>tol:
|
||||
index2=m
|
||||
break
|
||||
VerPart.DatumPlaneByThreePoints(point1=pdatums[1], point2=pdatums[index1], point3=pdatums[index2])
|
||||
VerPart.DatumAxisByTwoPoint(point1=pdatums[1],point2=pdatums[index1])
|
||||
partTransform = VerPart.MakeSketchTransform(sketchPlane=pdatums[num_verts+1],
|
||||
sketchUpEdge=pdatums[num_verts+2], sketchPlaneSide=SIDE1, sketchOrientation=BOTTOM, origin=(0.,0.,0.))
|
||||
sklabel='Skbase'+'C'+str(k)+'H'+str(i)
|
||||
VerSketch=VerModel.ConstrainedSketch(name=sklabel,sheetSize=200, transform=partTransform)
|
||||
VerPart.projectReferencesOntoSketch(sketch=VerSketch, filter=COPLANAR_EDGES)
|
||||
verts=VerSketch.vertices
|
||||
centroidx=0.
|
||||
centroidy=0.
|
||||
angle=[]
|
||||
jnum=[]
|
||||
for j in range(0,num_verts):
|
||||
centroidx=centroidx+verts[j].coords[0]
|
||||
centroidy=centroidy+verts[j].coords[1]
|
||||
centroidx=centroidx/float(num_verts)
|
||||
centroidy=centroidy/float(num_verts)
|
||||
for j in range(0,num_verts):
|
||||
pointx=verts[j].coords[0]-centroidx
|
||||
pointy=verts[j].coords[1]-centroidy
|
||||
vertangle=atan2(pointy,pointx)
|
||||
if vertangle<0.:
|
||||
vertangle=2*pi+vertangle
|
||||
angle.append(vertangle)
|
||||
jnum.append(j)
|
||||
icheck=0
|
||||
while icheck==0:
|
||||
icheck=1
|
||||
for j in range(1,num_verts):
|
||||
if angle[j]<angle[j-1]:
|
||||
temp1=angle[j-1]
|
||||
temp2=jnum[j-1]
|
||||
angle[j-1]=angle[j]
|
||||
angle[j]=temp1
|
||||
jnum[j-1]=jnum[j]
|
||||
jnum[j]=temp2
|
||||
icheck=0
|
||||
for j in range(1,num_verts):
|
||||
x1=verts[jnum[j]].coords[0]
|
||||
x2=verts[jnum[j-1]].coords[0]
|
||||
y1=verts[jnum[j]].coords[1]
|
||||
y2=verts[jnum[j-1]].coords[1]
|
||||
VerSketch.Line(point1=(x1,y1),point2=(x2,y2))
|
||||
VerSketch.Line(point1=(verts[jnum[num_verts-1]].coords[0],
|
||||
verts[jnum[num_verts-1]].coords[1]),
|
||||
point2=(verts[jnum[0]].coords[0],verts[jnum[0]].coords[1]))
|
||||
VerPart.Shell(sketchPlane=pdatums[num_verts+1], sketchPlaneSide=SIDE1,
|
||||
sketchUpEdge=pdatums[num_verts+2],sketchOrientation=BOTTOM,sketch=VerSketch)
|
||||
label='Part'+'C'+str(k)+'H'+str(i)
|
||||
VerAssembly.Instance(name=label,part=VerPart)
|
||||
if ibreak==1:
|
||||
continue
|
||||
inst=[]
|
||||
inst.append([])
|
||||
for i in range(0,num_hyp):
|
||||
inst[i]=VerAssembly.instances['Part'+'C'+str(k)+'H'+str(i)]
|
||||
if i<num_hyp-1:
|
||||
inst.append([])
|
||||
VerAssembly.InstanceFromBooleanMerge(name='Merged'+str(k),
|
||||
instances=inst,originalInstances=DELETE, keepIntersections=ON,domain=GEOMETRY)
|
||||
shellpart=VerModel.parts['Merged'+str(k)]
|
||||
try:
|
||||
shellpart.AddCells(faceList = shellpart.faces)
|
||||
except AbaqusException,errormessage:
|
||||
print errormessage, 'Not Merged'
|
||||
VerAssembly.Instance(name='Part'+str(k),part=shellpart, dependent=ON)
|
||||
del VerAssembly.instances['Merged'+str(k)+'-1']
|
||||
for i in range(0,num_hyp):
|
||||
del VerModel.sketches['Skbase'+'C'+str(k)+'H'+str(i)]
|
||||
del VerModel.parts['C'+str(k)+'H'+str(i)]
|
||||
print float(k)/float(num_cells)
|
||||
inst=[]
|
||||
inst.append([])
|
||||
for i in range(0,num_cells):
|
||||
inst[i]=VerAssembly.instances['Part'+str(i)]
|
||||
if i<num_cells-1:
|
||||
inst.append([])
|
||||
VerAssembly.InstanceFromBooleanMerge(name='Merged',
|
||||
instances=inst,originalInstances=DELETE, keepIntersections=ON,domain=GEOMETRY)
|
||||
# Make a Boolean Template Part
|
||||
#
|
||||
def BooleanPart(VerModel,part_type,rad,extrude_depth,
|
||||
num_high,num_wide,num_thick,shape,dimension,scalex,scaley,scalez):
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
booSketch=VerModel.ConstrainedSketch(name='BSmall', sheetSize=20.0)
|
||||
if shape==1:
|
||||
vert1x=0.
|
||||
vert1y=0.
|
||||
vert2x=rad*num_high
|
||||
vert2y=0.
|
||||
vert3x=rad*num_high
|
||||
vert3y=rad*num_wide
|
||||
vert4x=0.
|
||||
vert4y=rad*num_wide
|
||||
edepth=extrude_depth*num_thick
|
||||
if shape==2:
|
||||
yheight=sin(radians(30.))
|
||||
xheight=cos(radians(30.))
|
||||
vert1x=0.
|
||||
vert1y=rad*yheight+rad/2.
|
||||
vert2x=rad*xheight*(float(num_high)-1.)*2.
|
||||
vert2y=rad*yheight+rad/2.
|
||||
vert3x=rad*xheight*(float(num_high)-1.)*2.
|
||||
vert3y=rad*yheight+rad/2.+(float(num_wide)-1.)*(rad+rad*yheight)
|
||||
vert4x=0.
|
||||
vert4y=rad*yheight+rad/2.+(float(num_wide)-1.)*(rad+rad*yheight)
|
||||
edepth=extrude_depth*num_thick
|
||||
if shape==3:
|
||||
vert1x=0.
|
||||
vert1y=rad
|
||||
vert2x=sqrt(2.)*rad*(2.*float(num_high)-1.)
|
||||
vert2y=rad
|
||||
vert3x=sqrt(2.)*rad*(2.*float(num_high)-1.)
|
||||
vert3y=rad*(2.*float(num_wide)-1.)
|
||||
vert4x=0.
|
||||
vert4y=rad*(2.*float(num_wide)-1.)
|
||||
edepth=sqrt(2.)*rad*(2.*float(num_thick)-1.)
|
||||
if shape==4:
|
||||
vert1x=0.
|
||||
vert1y=0.
|
||||
vert2x=scalex
|
||||
vert2y=0.
|
||||
vert3x=scalex
|
||||
vert3y=scaley
|
||||
vert4x=0.
|
||||
vert4y=scaley
|
||||
if dimension==2:
|
||||
edepth=extrude_depth
|
||||
else:
|
||||
edepth=scalez
|
||||
booSketch.Line(point1=(vert1x,vert1y), point2=(vert2x, vert2y))
|
||||
booSketch.Line(point1=(vert2x, vert2y), point2=(vert3x, vert3y))
|
||||
booSketch.Line(point1=(vert3x, vert3y), point2=(vert4x, vert4y))
|
||||
booSketch.Line(point1=(vert4x, vert4y), point2=(vert1x, vert1y))
|
||||
if part_type==3:
|
||||
booPart=VerModel.Part(name='BSmall', dimensionality=THREE_D,type=DEFORMABLE_BODY)
|
||||
booPart.BaseSolidExtrude(sketch=booSketch, depth=edepth)
|
||||
else:
|
||||
booPart=VerModel.Part(name='BSmall', dimensionality=TWO_D_PLANAR,type=DEFORMABLE_BODY)
|
||||
booPart.BaseShell(sketch=booSketch)
|
||||
booSketchB=VerModel.ConstrainedSketch(name='BBig', sheetSize=20.0)
|
||||
booSketchB.Line(point1=(vert1x-10.,vert1y-10.), point2=(vert2x+10., vert2y-10.))
|
||||
booSketchB.Line(point1=(vert2x+10., vert2y-10.), point2=(vert3x+10., vert3y+10.))
|
||||
booSketchB.Line(point1=(vert3x+10., vert3y+10.), point2=(vert4x-10., vert4y+10.))
|
||||
booSketchB.Line(point1=(vert4x-10., vert4y+10.), point2=(vert1x-10., vert1y-10.))
|
||||
if part_type==3:
|
||||
booPartb=VerModel.Part(name='BBig', dimensionality=THREE_D,type=DEFORMABLE_BODY)
|
||||
booPartb.BaseSolidExtrude(sketch=booSketchB, depth=edepth*10.)
|
||||
else:
|
||||
booPartb=VerModel.Part(name='BBig', dimensionality=TWO_D_PLANAR,type=DEFORMABLE_BODY)
|
||||
booPartb.BaseShell(sketch=booSketchB)
|
||||
VerAssembly.Instance(name='BSmall',part=booPart, dependent=ON)
|
||||
VerAssembly.Instance(name='BBig',part=booPartb, dependent=ON)
|
||||
if shape==3:
|
||||
if part_type==3:
|
||||
VerAssembly.translate(instanceList=('BSmall', ),
|
||||
vector=(0.,0.,-sqrt(2.)*rad))
|
||||
VerAssembly.translate(instanceList=('BBig', ),
|
||||
vector=(0.,0.,-sqrt(2.)*rad*5.))
|
||||
if shape==4:
|
||||
if part_type==3:
|
||||
VerAssembly.translate(instanceList=('BBig', ),
|
||||
vector=(0.,0.,-edepth*5.))
|
||||
VerAssembly.InstanceFromBooleanCut(name='Template',
|
||||
instanceToBeCut=VerAssembly.instances['BBig'],
|
||||
cuttingInstances=(VerAssembly.instances['BSmall'], ),
|
||||
originalInstances=DELETE)
|
||||
# Pattern base parts for multilpe grains
|
||||
#
|
||||
def PatternParts(num_high,num_wide,num_thick,VerPart,rad,shape,VerModel):
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
yheight=sin(radians(30.))
|
||||
xheight=cos(radians(30.))
|
||||
icount=0
|
||||
for i in range(0,num_high):
|
||||
for j in range(0,num_wide):
|
||||
for k in range(0,num_thick):
|
||||
label='Part'+str(icount)
|
||||
VerAssembly.Instance(name=label,part=VerPart, dependent=ON)
|
||||
# Square
|
||||
if shape==1:
|
||||
VerAssembly.translate(instanceList=(label, ),
|
||||
vector=(i*rad,j*rad,k*rad))
|
||||
# Hexagon
|
||||
if shape==2:
|
||||
if j%2==0:
|
||||
VerAssembly.translate(instanceList=(label, ),
|
||||
vector=(i*xheight*rad*2.,j*rad*(1.+yheight),k*rad))
|
||||
else:
|
||||
VerAssembly.translate(instanceList=(label, ),
|
||||
vector=(i*xheight*rad*2.+xheight*rad,j*rad*(1.+yheight),k*rad))
|
||||
# Dodecahedron
|
||||
if shape==3:
|
||||
if j%2==0:
|
||||
VerAssembly.translate(instanceList=(label, ),
|
||||
vector=(i*rad*2.*sqrt(2.),j*2.*rad,2.*k*rad*sqrt(2.)))
|
||||
else:
|
||||
VerAssembly.translate(instanceList=(label, ),
|
||||
vector=(i*rad*2.*sqrt(2.)+sqrt(2.)*rad,j*2.*rad,2.*k*rad*sqrt(2.)+sqrt(2.)*rad))
|
||||
icount=icount+1
|
||||
inst=[]
|
||||
inst.append([])
|
||||
for i in range(0,icount):
|
||||
inst[i]=VerAssembly.instances['Part'+str(i)]
|
||||
if i<icount-1:
|
||||
inst.append([])
|
||||
VerAssembly.InstanceFromBooleanMerge(name='Merged',
|
||||
instances=inst,originalInstances=DELETE, keepIntersections=ON,domain=GEOMETRY)
|
||||
# Output vertices and element connectivity for corrosion analysis
|
||||
#
|
||||
def VertsConn(VerPart,dimension):
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
vertout=open('vertout.dat','w')
|
||||
vertout.write("%i\n"%(len(VerPart.cells)))
|
||||
k=1.
|
||||
for eachcell in VerPart.cells:
|
||||
print k/float(len(VerPart.cells))
|
||||
cellElements=eachcell.getElements()
|
||||
vertout.write("%i\n"%(len(cellElements)))
|
||||
cellFaces=eachcell.getFaces()
|
||||
for eachElement in cellElements:
|
||||
vertout.write("%i\n"%(eachElement.label))
|
||||
Adj_Elem=eachElement.getAdjacentElements()
|
||||
vertout.write("%i\n"%(len(Adj_Elem)))
|
||||
for i in range(0,len(Adj_Elem)):
|
||||
vertout.write("%i\n"%(Adj_Elem[i].label))
|
||||
centroidx=0.
|
||||
centroidy=0.
|
||||
centroidz=0.
|
||||
dmin=1000.
|
||||
for eachNode in eachElement.getNodes():
|
||||
centroidx=centroidx+eachNode.coordinates[0]
|
||||
centroidy=centroidy+eachNode.coordinates[1]
|
||||
centroidz=centroidz+eachNode.coordinates[2]
|
||||
num_nodes=float(len(eachElement.getNodes()))
|
||||
centroidx=centroidx/num_nodes
|
||||
centroidy=centroidy/num_nodes
|
||||
centroidz=centroidz/num_nodes
|
||||
for i in range(0,len(cellFaces)):
|
||||
eachFace=VerPart.faces[cellFaces[i]]
|
||||
facex=eachFace.pointOn[0][0]
|
||||
facey=eachFace.pointOn[0][1]
|
||||
facez=eachFace.pointOn[0][2]
|
||||
normalx=eachFace.getNormal()[0]
|
||||
normaly=eachFace.getNormal()[1]
|
||||
normalz=eachFace.getNormal()[2]
|
||||
if dimension==2:
|
||||
if normalx==0.:
|
||||
if normaly==0.:
|
||||
if abs(normalz)==1:
|
||||
continue
|
||||
else:
|
||||
if len(Adj_Elem)<6:
|
||||
if normalx==0.:
|
||||
if normaly==0.:
|
||||
if abs(normalz)==1:
|
||||
continue
|
||||
dfcx=facex-centroidx
|
||||
dfcy=facey-centroidy
|
||||
dfcz=facez-centroidz
|
||||
distance=abs(dfcx*normalx+dfcy*normaly+dfcz*normalz)
|
||||
if distance<dmin:
|
||||
dmin=distance
|
||||
vertout.write("%18.6f\n"%(dmin))
|
||||
k=k+1
|
||||
vertout.close()
|
||||
# Generate Materials and Sections
|
||||
#
|
||||
def MatGen(ana_type,VerPart,VerModel,part_type,meshsize,random_seed):
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
import random
|
||||
if ana_type==2:
|
||||
VerModel.Material(name='Magnesium')
|
||||
VerModel.materials['Magnesium'].Density(table=((1e-05, ), ))
|
||||
VerModel.materials['Magnesium'].Depvar(deleteVar=20, n=30)
|
||||
VerModel.materials['Magnesium'].UserMaterial(
|
||||
mechanicalConstants=(44000.0, 0.35, 138.7, 16.0, 165.0,0.5))
|
||||
if part_type==3:
|
||||
regions=VerPart.cells
|
||||
else:
|
||||
regions=VerPart.faces
|
||||
VerModel.HomogeneousSolidSection(name='Magnesium',
|
||||
material='Magnesium', thickness=meshsize)
|
||||
VerPart.SectionAssignment(region=(regions,),
|
||||
sectionName='Magnesium', offset=0.0, offsetField='')
|
||||
else:
|
||||
labelcount=1
|
||||
if part_type==3:
|
||||
regions=VerPart.cells
|
||||
else:
|
||||
regions=VerPart.faces
|
||||
random.seed(random_seed)
|
||||
for eachregion in regions:
|
||||
rand1=(random.random()-0.5)*2.
|
||||
rand2=(random.random()-0.5)*2.
|
||||
rand3=(random.random()-0.5)*2.
|
||||
rand4=(random.random()-0.5)*2.
|
||||
rand5=(random.random()-0.5)*2.
|
||||
rand6=(rand1*rand4+rand2*rand5)/(-rand3)
|
||||
mlabel='Mat'+str(labelcount)
|
||||
VerModel.Material(name=mlabel)
|
||||
VerModel.materials[mlabel].Density(table=((1e-05, ), ))
|
||||
VerModel.materials[mlabel].Depvar(deleteVar=124, n=124)
|
||||
VerModel.materials[mlabel].UserMaterial(
|
||||
mechanicalConstants=(200000.0, 0.3,
|
||||
rand1, rand2, rand3,1.,0.,0.,rand4,rand5,rand6,0.,0.,1.,
|
||||
10.,0.001,541.5,109.5,60.8,1.,1.,0.5,1.))
|
||||
VerModel.HomogeneousSolidSection(name=mlabel,
|
||||
material=mlabel, thickness=meshsize)
|
||||
VerPart.SectionAssignment(region=(eachregion,),
|
||||
sectionName=mlabel, offset=0.0, offsetField='')
|
||||
labelcount=labelcount+1
|
||||
# Shape 1 BCs and Constraints - Uniaxial Tension
|
||||
#
|
||||
def S1BCs(iNodes,VerModel,num_high,num_wide,num_thick,shape,
|
||||
dimension,extrude_depth,rad,scalex,scaley,scalez):
|
||||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
import regionToolset
|
||||
VerAssembly=VerModel.rootAssembly
|
||||
Min=-0.001
|
||||
Max=0.001
|
||||
fwide=float(num_wide)
|
||||
fhigh=float(num_high)
|
||||
fthick=float(num_thick)
|
||||
if shape==1:
|
||||
# BC LEFT
|
||||
XMnBL=Min
|
||||
XMxBL=Max
|
||||
YMnBL=Min
|
||||
YMxBL=fwide*rad+Max
|
||||
ZMnBL=Min
|
||||
ZMxBL=Max+extrude_depth
|
||||
# BC BACK
|
||||
XMnBBK=Min
|
||||
XMxBBK=fhigh*rad+Max
|
||||
YMnBBK=Min
|
||||
YMxBBK=fwide*rad+Max
|
||||
ZMnBBK=Min
|
||||
ZMxBBK=Max
|
||||
# BC Bottom
|
||||
XMnBBT=Min
|
||||
XMxBBT=fhigh*rad+Max
|
||||
YMnBBT=Min
|
||||
YMxBBT=Max
|
||||
ZMnBBT=Min
|
||||
ZMxBBT=Max+extrude_depth
|
||||
# BC Right
|
||||
XMnBR=fhigh*rad+Min
|
||||
XMxBR=fhigh*rad+Max
|
||||
YMnBR=Min
|
||||
YMxBR=fwide*rad+Max
|
||||
ZMnBR=Min
|
||||
ZMxBR=Max+extrude_depth
|
||||
# RP
|
||||
XRP=fhigh*rad
|
||||
YRP=fwide*rad*0.5
|
||||
ZRP=extrude_depth*0.5
|
||||
if shape==2:
|
||||
yheight=sin(radians(30.))
|
||||
xheight=cos(radians(30.))
|
||||
# BC LEFT
|
||||
XMnBL=Min
|
||||
XMxBL=Max
|
||||
YMnBL=rad*yheight+rad/2.+Min
|
||||
YMxBL=rad*yheight+rad/2.+(fwide-1.)*(rad+rad*yheight)+Max
|
||||
ZMnBL=Min
|
||||
ZMxBL=Max+extrude_depth
|
||||
# BC BACK
|
||||
XMnBBK=Min
|
||||
XMxBBK=rad*xheight*(fhigh-1.)*2.+Max
|
||||
YMnBBK=rad*yheight+rad/2.+Min
|
||||
YMxBBK=rad*yheight+rad/2.+(fwide-1.)*(rad+rad*yheight)+Max
|
||||
ZMnBBK=Min
|
||||
ZMxBBK=Max
|
||||
# BC Bottom
|
||||
XMnBBT=Min
|
||||
XMxBBT=rad*xheight*(fhigh-1.)*2.+Max
|
||||
YMnBBT=rad*yheight+rad/2.+Min
|
||||
YMxBBT=rad*yheight+rad/2.+Max
|
||||
ZMnBBT=Min
|
||||
ZMxBBT=Max+extrude_depth
|
||||
# BC Right
|
||||
XMnBR=rad*xheight*(fhigh-1.)*2.+Min
|
||||
XMxBR=rad*xheight*(fhigh-1.)*2.+Max
|
||||
YMnBR=rad*yheight+rad/2.+Min
|
||||
YMxBR=rad*yheight+rad/2.+(fwide-1.)*(rad+rad*yheight)+Max
|
||||
ZMnBR=Min
|
||||
ZMxBR=Max+extrude_depth
|
||||
# RP
|
||||
XRP=rad*xheight*(fhigh-1.)*2.
|
||||
YRP=rad*yheight+rad/2.+(fwide-1.)*(rad+rad*yheight)*0.5
|
||||
ZRP=extrude_depth*0.5
|
||||
if shape==4:
|
||||
# BC LEFT
|
||||
XMnBL=Min
|
||||
XMxBL=Max
|
||||
YMnBL=Min
|
||||
YMxBL=scaley+Max
|
||||
ZMnBL=Min
|
||||
ZMxBL=Max+extrude_depth
|
||||
# BC BACK
|
||||
XMnBBK=Min
|
||||
XMxBBK=scalex+Max
|
||||
YMnBBK=Min
|
||||
YMxBBK=scaley+Max
|
||||
ZMnBBK=Min
|
||||
ZMxBBK=Max
|
||||
# BC Bottom
|
||||
XMnBBT=Min
|
||||
XMxBBT=scalex+Max
|
||||
YMnBBT=Min
|
||||
YMxBBT=Max
|
||||
ZMnBBT=Min
|
||||
ZMxBBT=Max+extrude_depth
|
||||
# BC Right
|
||||
XMnBR=scalex+Min
|
||||
XMxBR=scalex+Max
|
||||
YMnBR=Min
|
||||
YMxBR=scaley+Max
|
||||
ZMnBR=Min
|
||||
ZMxBR=Max+extrude_depth
|
||||
# RP
|
||||
XRP=scalex
|
||||
YRP=scaley*0.5
|
||||
ZRP=extrude_depth*0.5
|
||||
#
|
||||
total_length=(XMxBR-Max)-(XMnBL-Min)
|
||||
BLeft=iNodes.getByBoundingBox(xMin=XMnBL,xMax=XMxBL,yMin=YMnBL,yMax=YMxBL,zMin=ZMnBL,zMax=ZMxBL)
|
||||
BBack=iNodes.getByBoundingBox(xMin=XMnBBK,xMax=XMxBBK,yMin=YMnBBK,yMax=YMxBBK,zMin=ZMnBBK,zMax=ZMxBBK)
|
||||
BBot=iNodes.getByBoundingBox(xMin=XMnBBT,xMax=XMxBBT,yMin=YMnBBT,yMax=YMxBBT,zMin=ZMnBBT,zMax=ZMxBBT)
|
||||
BRight=iNodes.getByBoundingBox(xMin=XMnBR,xMax=XMxBR,yMin=YMnBR,yMax=YMxBR,zMin=ZMnBR,zMax=ZMxBR)
|
||||
Ref1=VerAssembly.ReferencePoint(point=(XRP,YRP,ZRP))
|
||||
#
|
||||
BLregion=regionToolset.Region(nodes=BLeft)
|
||||
BBregion=regionToolset.Region(nodes=BBot)
|
||||
BBKregion=regionToolset.Region(nodes=BBack)
|
||||
BRregion=regionToolset.Region(nodes=BRight)
|
||||
VerModel.DisplacementBC(name='LeftX', createStepName='Initial',
|
||||
region=BLregion, u1=0.0, u2=UNSET, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BottomY', createStepName='Initial',
|
||||
region=BBregion, u1=UNSET, u2=0.0, u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
VerModel.DisplacementBC(name='BackZ', createStepName='Initial',
|
||||
region=BBKregion, u1=UNSET, u2=UNSET, u3=0.0, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM)
|
||||
#
|
||||
id1=VerAssembly.features['RP-1'].id
|
||||
RPoint=regionToolset.Region(referencePoints=(VerAssembly.referencePoints[id1],))
|
||||
VerAssembly.Set(referencePoints=(VerAssembly.referencePoints[id1],), name='RPoint')
|
||||
VerAssembly.Set(nodes=BRight, name='BRight')
|
||||
VerModel.Equation(name='Constraint-1', terms=((1.0, 'BRight', 1), ( -1.0, 'RPoint', 1)))
|
||||
VerModel.SmoothStepAmplitude(name='Load', timeSpan=STEP, data=((0.0, 0.0), (1.0, 1.0)))
|
||||
VerModel.DisplacementBC(name='RPNode', createStepName='Load',
|
||||
region=RPoint, u1=total_length*0.17, u2=0., u3=UNSET, ur1=UNSET, ur2=UNSET,
|
||||
ur3=UNSET, amplitude='Load', fixed=OFF, distributionType=UNIFORM)
|
110
JMBBM13a/GeometryGenerators/UCRYS_JG.f90
Normal file
110
JMBBM13a/GeometryGenerators/UCRYS_JG.f90
Normal file
|
@ -0,0 +1,110 @@
|
|||
! Crystal Plasticity Input File Generator for Abaqus Standard
|
||||
!
|
||||
! 5/7/00 - Only valid for FCC structure
|
||||
! Only Asaro hardening model implemented
|
||||
! Only valid for isotropic elastic properties
|
||||
! Latent hardening parameters (Q1, Q2) set to (1, 0)
|
||||
! 30/08/11 - Modified by JGROGAN. Removed some seldom used choices
|
||||
! and added new random generator due to potential
|
||||
! problems with previous 'RANDU' type generator.(igen)
|
||||
! Added gen plane strain option (igps)
|
||||
!
|
||||
! Use odd number as seed for random number generator
|
||||
!
|
||||
! NLGEOM flag automatically assumed
|
||||
! Newton-raphson iteration scheme and default parameters inputted
|
||||
!
|
||||
! ******************************************************************
|
||||
program matgen
|
||||
integer ncrys,iseed
|
||||
character(1) filename
|
||||
character(len=256)input2(2)
|
||||
integer seed(1)
|
||||
real*8 E,mu,g0,ginf,h0,adot,n,thick
|
||||
! ******************************************************************
|
||||
ncrys=2000
|
||||
nfiles=5
|
||||
thick=0.1
|
||||
E=193000.
|
||||
mu=0.3
|
||||
g0=140.
|
||||
ginf=800.
|
||||
h0=150.
|
||||
adot=0.0106
|
||||
n=50.
|
||||
! iseed=22828385 !ori1
|
||||
! iseed=5835828 !ori2
|
||||
! iseed=369256 !ori3
|
||||
! iseed=39935222 !ori4
|
||||
! iseed=787678764 !ori5
|
||||
! iseed=987565 !ori6
|
||||
iseed=75336563 !ori7
|
||||
! iseed=367222567 !ori8
|
||||
! iseed=682268 !ori9
|
||||
! iseed=68768553 !ori10
|
||||
seed=iseed
|
||||
call random_seed(put=seed)
|
||||
igen=2
|
||||
istan=0
|
||||
igps=0
|
||||
do i=1,nfiles
|
||||
write(filename,'(i1)')i
|
||||
open(unit=11,status='unknown',file='Tens500_100.inp')
|
||||
open(unit=10,status='unknown',file='Tens500_100_'//trim(filename)//'.inp')
|
||||
input2(1)='**'
|
||||
do while (index(input2(1),'*End Assembly')==0)
|
||||
read(11,'(a)')input2(2)
|
||||
write(10,'(a)')input2(1)
|
||||
input2(1)=input2(2)
|
||||
enddo
|
||||
write(10,'(a)')'*End Assembly'
|
||||
! ******************************************************************
|
||||
do icrys=1,ncrys
|
||||
write(10,'(a)') '**'
|
||||
write(10,'(a,i5)')'*MATERIAL, NAME=MAT',icrys
|
||||
write(10,'(a)')'**'
|
||||
write(10,'(a)')'*USER MATERIAL, CONSTANTS=160, UNSYMM'
|
||||
write(10,'(f16.4,a,f6.4,a)')E,',',mu,','
|
||||
write(10,'(f6.4,a)')0.,','
|
||||
write(10,'(f6.4,a)')0.,','
|
||||
write(10,'(f6.4,a)')1.,','
|
||||
write(10,'(6(f6.4,a))')1.,',',1.,',',1.,',',1.,',',1.,',',0.,','
|
||||
write(10,'(f6.4,a)')0.,','
|
||||
write(10,'(f6.4,a)')0.,','
|
||||
call random_number(rand1)
|
||||
rand1=(rand1-0.5)*2.
|
||||
call random_number(rand2)
|
||||
rand2=(rand2-0.5)*2.
|
||||
call random_number(rand3)
|
||||
rand3=(rand3-0.5)*2.
|
||||
call random_number(rand4)
|
||||
rand4=(rand4-0.5)*2.
|
||||
call random_number(rand5)
|
||||
rand5=(rand5-0.5)*2.
|
||||
write(10,'(3(f12.6,a),3(f6.4,a))')rand1,',',rand2,',',rand3,',',1.,',',0.,',',0.
|
||||
rand6 = (rand1*rand4+rand2*rand5)/(-rand3)
|
||||
write(10,'(3(f12.6,a),3(f6.4,a))')rand4,',',rand5,',',rand6,',',0.,',',0.,',',1.
|
||||
write(10,'(2(f12.4,a))') n,',',adot,','
|
||||
write(10,'(f6.4,a)') 0.,','
|
||||
write(10,'(f6.4,a)') 0.,','
|
||||
write(10,'(3(f12.4,a))') h0,',',ginf,',',g0,','
|
||||
write(10,'(2(f6.4,a))') 1.,',',0.,','
|
||||
write(10,'(f6.4,a)') 0.,','
|
||||
write(10,'(f6.4,a)') 0.,','
|
||||
write(10,'(f6.4,a)') 0.,','
|
||||
write(10,'(f6.4,a)') 0.,','
|
||||
write(10,'(2(f6.4,a))') 0.5,',',1.,','
|
||||
write(10,'(2(f12.4,a))') 1.,',',10.,',1.e-5,'
|
||||
write(10,'(a)') '*Depvar'
|
||||
write(10,'(a)') '113'
|
||||
write(10,'(a)') '**'
|
||||
enddo
|
||||
ierr=0
|
||||
do while (ierr==0)
|
||||
read(11,'(a)',iostat=ierr)input2(1)
|
||||
if(ierr==0)write(10,'(a)')input2(1)
|
||||
enddo
|
||||
close(unit=10)
|
||||
close(unit=11)
|
||||
enddo
|
||||
end program matgen
|
90
JMBBM13a/GeometryGenerators/UCRYS_JG_PLAS.f90
Normal file
90
JMBBM13a/GeometryGenerators/UCRYS_JG_PLAS.f90
Normal file
|
@ -0,0 +1,90 @@
|
|||
! Crystal Plasticity Input File Generator for Abaqus Standard
|
||||
!
|
||||
! 5/7/00 - Only valid for FCC structure
|
||||
! Only Asaro hardening model implemented
|
||||
! Only valid for isotropic elastic properties
|
||||
! Latent hardening parameters (Q1, Q2) set to (1, 0)
|
||||
! 30/08/11 - Modified by JGROGAN. Removed some seldom used choices
|
||||
! and added new random generator due to potential
|
||||
! problems with previous 'RANDU' type generator.(igen)
|
||||
! Added gen plane strain option (igps)
|
||||
!
|
||||
! Use odd number as seed for random number generator
|
||||
!
|
||||
! NLGEOM flag automatically assumed
|
||||
! Newton-raphson iteration scheme and default parameters inputted
|
||||
!
|
||||
! ******************************************************************
|
||||
program matgen
|
||||
integer ncrys,iseed
|
||||
character(1) filename
|
||||
character(len=256)input2(2)
|
||||
integer seed(1)
|
||||
real*8 E,mu,g0,ginf,h0,adot,n,thick
|
||||
! ******************************************************************
|
||||
ncrys=300
|
||||
nfiles=5
|
||||
thick=0.1
|
||||
E=193000.
|
||||
mu=0.3
|
||||
g0=150.
|
||||
ginf=360.
|
||||
h0=380.
|
||||
adot=0.0106
|
||||
n=50.
|
||||
iseed=830963 !ori1
|
||||
iseed=211327 !ori2
|
||||
iseed=312099 !ori3
|
||||
iseed=98247 !ori4
|
||||
iseed=446725 !ori5
|
||||
iseed=504991 !ori6
|
||||
iseed=493487 !ori7
|
||||
iseed=902013 !ori8
|
||||
iseed=363209 !ori9
|
||||
iseed=418743 !ori10
|
||||
iseed=647832 !ori11
|
||||
iseed=921647832 !ori12
|
||||
seed=iseed
|
||||
call random_seed(put=seed)
|
||||
igen=2
|
||||
istan=0
|
||||
igps=0
|
||||
do i=1,nfiles
|
||||
write(filename,'(i1)')i
|
||||
open(unit=11,status='unknown',file='W1L80ST.inp')
|
||||
open(unit=10,status='unknown',file='W1L80STP_'//trim(filename)//'.inp')
|
||||
input2(1)='**'
|
||||
do while (index(input2(1),'*End Assembly')==0)
|
||||
read(11,'(a)')input2(2)
|
||||
write(10,'(a)')input2(1)
|
||||
input2(1)=input2(2)
|
||||
enddo
|
||||
write(10,'(a)')'*End Assembly'
|
||||
! ******************************************************************
|
||||
do icrys=1,ncrys
|
||||
write(10,'(a)') '**'
|
||||
write(10,'(a,i5)')'*MATERIAL, NAME=MAT',icrys
|
||||
write(10,'(a)')'**'
|
||||
write(10,'(a)')'*elastic'
|
||||
write(10,'(f16.4,a,f6.4)')E,',',mu
|
||||
call random_number(rand1)
|
||||
rh=800.
|
||||
if (rand1<0.1)rh=500.
|
||||
write(10,'(a)')'*plastic'
|
||||
stran=0.
|
||||
do j=1,50
|
||||
stress=350.+(rh-350.)*tanh(abs(1200.*stran/(rh-350.)))
|
||||
write(10,'(f16.4,a,f6.4)')stress,',',stran
|
||||
stran=stran+0.01
|
||||
enddo
|
||||
write(10,'(a)')'**'
|
||||
enddo
|
||||
ierr=0
|
||||
do while (ierr==0)
|
||||
read(11,'(a)',iostat=ierr)input2(1)
|
||||
if(ierr==0)write(10,'(a)')input2(1)
|
||||
enddo
|
||||
close(unit=10)
|
||||
close(unit=11)
|
||||
enddo
|
||||
end program matgen
|
113
JMBBM13a/GeometryGenerators/UCRYS_JG_exp.f90
Normal file
113
JMBBM13a/GeometryGenerators/UCRYS_JG_exp.f90
Normal file
|
@ -0,0 +1,113 @@
|
|||
! Crystal Plasticity Input File Generator for Abaqus Standard
|
||||
!
|
||||
! 5/7/00 - Only valid for FCC structure
|
||||
! Only Asaro hardening model implemented
|
||||
! Only valid for isotropic elastic properties
|
||||
! Latent hardening parameters (Q1, Q2) set to (1, 0)
|
||||
! 30/08/11 - Modified by JGROGAN. Removed some seldom used choices
|
||||
! and added new random generator due to potential
|
||||
! problems with previous 'RANDU' type generator.(igen)
|
||||
! Added gen plane strain option (igps)
|
||||
!
|
||||
! Use odd number as seed for random number generator
|
||||
!
|
||||
! NLGEOM flag automatically assumed
|
||||
! Newton-raphson iteration scheme and default parameters inputted
|
||||
!
|
||||
! ******************************************************************
|
||||
program matgen
|
||||
integer ncrys,iseed
|
||||
character(1) filename
|
||||
character(len=256)input2(2)
|
||||
integer seed(1)
|
||||
real*8 E,mu,g0,ginf,h0,adot,n,thick
|
||||
! ******************************************************************
|
||||
ncrys=2000
|
||||
nfiles=5
|
||||
thick=0.1
|
||||
E=193000.
|
||||
mu=0.3
|
||||
g0=140.
|
||||
ginf=800.
|
||||
h0=150.
|
||||
adot=0.0106
|
||||
n=50.
|
||||
! iseed=22828385 !ori1
|
||||
! iseed=5835828 !ori2
|
||||
! iseed=369256 !ori3
|
||||
! iseed=39935222 !ori4
|
||||
! iseed=787678764 !ori5
|
||||
! iseed=987565 !ori6
|
||||
iseed=75336563 !ori7
|
||||
! iseed=367222567 !ori8
|
||||
! iseed=682268 !ori9
|
||||
! iseed=68768553 !ori10
|
||||
seed=iseed
|
||||
call random_seed(put=seed)
|
||||
igen=2
|
||||
istan=0
|
||||
igps=0
|
||||
do i=1,nfiles
|
||||
write(filename,'(i1)')i
|
||||
open(unit=11,status='unknown',file='Tens150_400.inp')
|
||||
open(unit=10,status='unknown',file='Tens150_400_D'//trim(filename)//'.inp')
|
||||
input2(1)='**'
|
||||
do while (index(input2(1),'*End Assembly')==0)
|
||||
read(11,'(a)')input2(2)
|
||||
write(10,'(a)')input2(1)
|
||||
input2(1)=input2(2)
|
||||
enddo
|
||||
write(10,'(a)')'*End Assembly'
|
||||
! ******************************************************************
|
||||
do icrys=1,ncrys
|
||||
write(10,'(a)') '**'
|
||||
write(10,'(a,i5)')'*MATERIAL, NAME=MAT',icrys
|
||||
write(10,'(a)')'**'
|
||||
write(10,'(a)')'*USER MATERIAL, CONSTANTS=162, UNSYMM'
|
||||
write(10,'(f16.4,a,f6.4,a)')E,',',mu,','
|
||||
write(10,'(f6.4,a)')0.,','
|
||||
write(10,'(f6.4,a)')0.,','
|
||||
write(10,'(f6.4,a)')1.,','
|
||||
write(10,'(6(f6.4,a))')1.,',',1.,',',1.,',',1.,',',1.,',',0.,','
|
||||
write(10,'(f6.4,a)')0.,','
|
||||
write(10,'(f6.4,a)')0.,','
|
||||
call random_number(rand1)
|
||||
rand1=(rand1-0.5)*2.
|
||||
call random_number(rand2)
|
||||
rand2=(rand2-0.5)*2.
|
||||
call random_number(rand3)
|
||||
rand3=(rand3-0.5)*2.
|
||||
call random_number(rand4)
|
||||
rand4=(rand4-0.5)*2.
|
||||
call random_number(rand5)
|
||||
rand5=(rand5-0.5)*2.
|
||||
write(10,'(3(f12.6,a),3(f6.4,a))')rand1,',',rand2,',',rand3,',',1.,',',0.,',',0.
|
||||
rand6 = (rand1*rand4+rand2*rand5)/(-rand3)
|
||||
write(10,'(3(f12.6,a),3(f6.4,a))')rand4,',',rand5,',',rand6,',',0.,',',0.,',',1.
|
||||
write(10,'(2(f12.4,a))') n,',',adot,','
|
||||
write(10,'(f6.4,a)') 0.,','
|
||||
write(10,'(f6.4,a)') 0.,','
|
||||
write(10,'(3(f12.4,a))') h0,',',ginf,',',g0,','
|
||||
write(10,'(2(f6.4,a))') 1.,',',0.,','
|
||||
write(10,'(f6.4,a)') 0.,','
|
||||
write(10,'(f6.4,a)') 0.,','
|
||||
write(10,'(f6.4,a)') 0.,','
|
||||
write(10,'(f6.4,a)') 0.,','
|
||||
write(10,'(2(f6.4,a))') 0.5,',',1.,','
|
||||
write(10,'(2(f12.4,a))') 1.,',',10.,',1.e-5,'
|
||||
write(10,'(2(f6.4,a))') 4.03,',',1.,','
|
||||
write(10,'(a)') '*Depvar,delete=118'
|
||||
write(10,'(a)') '128'
|
||||
write(10,'(a)') '*Density'
|
||||
write(10,'(a)') '0.8e-05'
|
||||
write(10,'(a)') '**'
|
||||
enddo
|
||||
ierr=0
|
||||
do while (ierr==0)
|
||||
read(11,'(a)',iostat=ierr)input2(1)
|
||||
if(ierr==0)write(10,'(a)')input2(1)
|
||||
enddo
|
||||
close(unit=10)
|
||||
close(unit=11)
|
||||
enddo
|
||||
end program matgen
|
89
JMBBM13a/GeometryGenerators/Voronoi2DPost.f90
Normal file
89
JMBBM13a/GeometryGenerators/Voronoi2DPost.f90
Normal file
|
@ -0,0 +1,89 @@
|
|||
! This program takes output from the QHULL package and converts it into
|
||||
! a format suitable for use with the GeomGen script
|
||||
! J.Grogan 05/08/11
|
||||
program Voronoi2DPost
|
||||
!
|
||||
! Parameters
|
||||
parameter(max_verts=1000000,max_cells=100000,max_verts_in_cell=100)
|
||||
!
|
||||
! Variables
|
||||
character(len=256)full_line,test_string
|
||||
integer vnum(max_cells,max_verts_in_cell),num_verts(max_cells)
|
||||
integer in_tol(max_cells)
|
||||
real xv_cor(max_verts)
|
||||
real yv_cor(max_verts)
|
||||
logical xtrue
|
||||
logical ytrue
|
||||
!
|
||||
! Read Scales
|
||||
open(unit=15,file='scales.dat',status='unknown')
|
||||
read(15,*)xscale,yscale
|
||||
!
|
||||
! Read in vertex co-ordinates
|
||||
open(unit=11,file='qhullout.dat',status='unknown')
|
||||
read(11,*)
|
||||
read(11,*)num_verts_tot,num_cells,dummy
|
||||
do i=1,num_verts_tot
|
||||
read(11,*)xv_cor(i),yv_cor(i)
|
||||
enddo
|
||||
!
|
||||
! Read in vertices on each cell
|
||||
do i=1,num_cells
|
||||
read(11,*)num_verts(i)
|
||||
backspace(11)
|
||||
read(11,'(i2,a256)')idummy,full_line
|
||||
ileft=1
|
||||
num_points=1
|
||||
do iright=1,256
|
||||
test_string=full_line(iright:iright)
|
||||
if((test_string==' ').or.(iright==256))then
|
||||
read(full_line(ileft:iright-1),'(i6)')vnum(i,num_points)
|
||||
if(num_points==num_verts(i))exit
|
||||
ileft=iright+1
|
||||
num_points=num_points+1
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
!
|
||||
! Check if cells are within specified region
|
||||
open(unit=12,file='fortranout.dat',status='unknown')
|
||||
num_inside_cells=num_cells
|
||||
do i=1,num_cells
|
||||
icheck=0
|
||||
do j=1,num_verts(i)
|
||||
xcor=xv_cor(vnum(i,j)+1)
|
||||
ycor=yv_cor(vnum(i,j)+1)
|
||||
if(abs(xcor)==10.101)then
|
||||
icheck=0
|
||||
exit
|
||||
endif
|
||||
rmax_x=1.1*xscale
|
||||
rmax_y=1.1*yscale
|
||||
rmin=-0.1
|
||||
xtrue=(xcor<rmax_x).and.(xcor>rmin)
|
||||
ytrue=(ycor<rmax_y).and.(ycor>rmin)
|
||||
if(xtrue.and.ytrue)icheck=icheck+1
|
||||
enddo
|
||||
if(icheck<1)then
|
||||
in_tol(i)=2
|
||||
num_inside_cells=num_inside_cells-1
|
||||
else
|
||||
in_tol(i)=1
|
||||
endif
|
||||
enddo
|
||||
!
|
||||
! Write vertex coordinates for each cell
|
||||
write(12,*)num_inside_cells
|
||||
do i=1,num_cells
|
||||
if(in_tol(i)==1)then
|
||||
write(12,*)num_verts(i)
|
||||
do j=1,num_verts(i)
|
||||
write(12,*)xv_cor(vnum(i,j)+1),',',yv_cor(vnum(i,j)+1)
|
||||
enddo
|
||||
else
|
||||
cycle
|
||||
endif
|
||||
enddo
|
||||
close(unit=11)
|
||||
close(unit=12)
|
||||
end program
|
157
JMBBM13a/GeometryGenerators/Voronoi3DPost.f90
Normal file
157
JMBBM13a/GeometryGenerators/Voronoi3DPost.f90
Normal file
|
@ -0,0 +1,157 @@
|
|||
! This program takes output from the QHULL package and converts it into
|
||||
! a format suitable for use with the GeomGen script
|
||||
! J.Grogan 05/08/11
|
||||
program Voronoi3DPost
|
||||
!
|
||||
! Parameters
|
||||
parameter(max_verts=500000,max_cells=50000,max_verts_in_cell=100)
|
||||
parameter(max_hyps=500000,max_hyp_in_cell=100,max_verts_on_hyp=50)
|
||||
!
|
||||
! Variables
|
||||
character(len=256)full_line,test_string
|
||||
integer num_verts(max_cells)
|
||||
integer vert_list(max_cells,max_verts_in_cell)
|
||||
integer facet(2,max_hyps)
|
||||
integer hyp_list(max_cells,max_hyp_in_cell)
|
||||
integer num_cell_hyp(max_cells)
|
||||
integer cell_status(max_cells)
|
||||
integer num_hyp_verts(max_cells,max_hyp_in_cell)
|
||||
integer hyp_vert_list(max_cells,max_hyp_in_cell,max_verts_on_hyp)
|
||||
double precision xv_cor(max_verts)
|
||||
double precision yv_cor(max_verts)
|
||||
double precision zv_cor(max_verts)
|
||||
double precision cor(3,max_hyps)
|
||||
double precision offset(max_hyps)
|
||||
double precision xcor,ycor,zcor
|
||||
double precision dotrprod,distance,tol
|
||||
logical xtrue,ytrue,ztrue
|
||||
!
|
||||
! Open output files
|
||||
open(unit=12,file='fortranout.dat',status='unknown')
|
||||
!
|
||||
! Open scales file
|
||||
open(unit=15,file='scales.dat',status='unknown')
|
||||
read(15,*)rmaxscale
|
||||
!
|
||||
! Read tessellation results from QHULL
|
||||
open(unit=11,file='qhullout.dat',status='unknown')
|
||||
read(11,*)
|
||||
read(11,*)num_total_verts,num_cells
|
||||
!
|
||||
! Read in all vertice co-ordinates
|
||||
do i=1,num_total_verts
|
||||
read(11,*)xv_cor(i),yv_cor(i),zv_cor(i)
|
||||
enddo
|
||||
!
|
||||
! Read in vertice labels for each voronoi cell
|
||||
do i=1,num_cells
|
||||
read(11,*)num_verts(i)
|
||||
backspace(11)
|
||||
if(num_verts(i)>9)then
|
||||
read(11,'(i3,a256)')idummy,full_line
|
||||
else
|
||||
read(11,'(i2,a256)')idummy,full_line
|
||||
endif
|
||||
ileft=1
|
||||
num_points=1
|
||||
do iright=1,256
|
||||
test_string=full_line(iright:iright)
|
||||
if((test_string==' ').or.(iright==256))then
|
||||
read(full_line(ileft:iright-1),'(i6)')vert_list(i,num_points)
|
||||
if(num_points==num_verts(i))exit
|
||||
ileft=iright+1
|
||||
num_points=num_points+1
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
!
|
||||
! Read in bounded hyperplane cell labels and co-ordinates
|
||||
read(11,*)num_hyp
|
||||
do i=1,num_hyp
|
||||
read(11,*)dummy,facet(1,i),facet(2,i),cor(1,i),cor(2,i),cor(3,i),offset(i)
|
||||
enddo
|
||||
!
|
||||
! Determine hyperplanes of each cell
|
||||
do i=1,num_cells
|
||||
num_hy=1
|
||||
do j=1,num_hyp
|
||||
if((facet(1,j)==i-1).or.(facet(2,j)==i-1))then
|
||||
hyp_list(i,num_hy)=j
|
||||
num_cell_hyp(i)=num_hy
|
||||
num_hy=num_hy+1
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
!
|
||||
! Check if any cell vertices are outside the chosen tolerance
|
||||
do i=1,num_cells
|
||||
cell_status(i)=1
|
||||
if(num_verts(i)<3)cycle
|
||||
ibreak=0
|
||||
do j=1,num_verts(i)
|
||||
do k=1,num_verts(i)
|
||||
if(j==k)cycle
|
||||
x1=xv_cor(vert_list(i,j)+1)
|
||||
y1=yv_cor(vert_list(i,j)+1)
|
||||
z1=zv_cor(vert_list(i,j)+1)
|
||||
x2=xv_cor(vert_list(i,k)+1)
|
||||
y2=yv_cor(vert_list(i,k)+1)
|
||||
z2=zv_cor(vert_list(i,k)+1)
|
||||
dist=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1))
|
||||
if (dist<1.e-5)ibreak=1
|
||||
enddo
|
||||
enddo
|
||||
if(ibreak==1)cycle
|
||||
do j=1,num_verts(i)
|
||||
xcor=xv_cor(vert_list(i,j)+1)
|
||||
ycor=yv_cor(vert_list(i,j)+1)
|
||||
zcor=zv_cor(vert_list(i,j)+1)
|
||||
rmax=1.1*rmaxscale
|
||||
rmin=-0.1
|
||||
xtrue=(xcor<rmax).and.(xcor>rmin)
|
||||
ytrue=(ycor<rmax).and.(ycor>rmin)
|
||||
ztrue=(zcor<rmax).and.(zcor>rmin)
|
||||
if(xtrue.and.ytrue.and.ztrue)cell_status(i)=0
|
||||
enddo
|
||||
enddo
|
||||
!
|
||||
! For all cells within tolerance determine vertices on each hyperplane
|
||||
num_skipped=0
|
||||
tol=1.e-5*rmaxscale
|
||||
do i=1,num_cells
|
||||
if(cell_status(i)/=0)then
|
||||
num_skipped=num_skipped+1
|
||||
cycle
|
||||
endif
|
||||
do j=1,num_cell_hyp(i)
|
||||
nverts_on_hyp=1
|
||||
do k=1,num_verts(i)
|
||||
dotprod1=cor(1,hyp_list(i,j))*xv_cor(vert_list(i,k)+1)
|
||||
dotprod2=cor(2,hyp_list(i,j))*yv_cor(vert_list(i,k)+1)
|
||||
dotprod3=cor(3,hyp_list(i,j))*zv_cor(vert_list(i,k)+1)
|
||||
distance=dotprod1+dotprod2+dotprod3+offset(hyp_list(i,j))
|
||||
if(abs(distance)<tol)then
|
||||
hyp_vert_list(i,j,nverts_on_hyp)=vert_list(i,k)
|
||||
num_hyp_verts(i,j)=nverts_on_hyp
|
||||
nverts_on_hyp=nverts_on_hyp+1
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
! Write output for the of co-orindates of vertices on each hyperplane
|
||||
! that make up a cell.
|
||||
write(12,*)num_cells-num_skipped
|
||||
do i=1,num_cells
|
||||
if(cell_status(i)/=0)cycle
|
||||
write(12,*)num_cell_hyp(i)
|
||||
do j=1,num_cell_hyp(i)
|
||||
write(12,*)num_hyp_verts(i,j)
|
||||
do k=1,num_hyp_verts(i,j)
|
||||
xcor=xv_cor(hyp_vert_list(i,j,k)+1)
|
||||
ycor=yv_cor(hyp_vert_list(i,j,k)+1)
|
||||
zcor=zv_cor(hyp_vert_list(i,j,k)+1)
|
||||
write(12,'(2(f20.15,a),f20.15)')xcor,',',ycor,',',zcor
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
end program
|
103
JMBBM13a/GeometryGenerators/tesse.py
Normal file
103
JMBBM13a/GeometryGenerators/tesse.py
Normal file
|
@ -0,0 +1,103 @@
|
|||
from abaqusConstants import *
|
||||
from abaqus import *
|
||||
import regionToolset
|
||||
import sys
|
||||
import random
|
||||
import os
|
||||
import subprocess
|
||||
aModel=mdb.models['Model-1']
|
||||
aPart=aModel.parts['Part-1']
|
||||
num_grains=5
|
||||
sizeX=1.
|
||||
sizeY=1.
|
||||
sizeZ=1.
|
||||
random.seed(1111)
|
||||
qhullin=open('qhullin.dat','w')
|
||||
qhullin.write("%i \n"%(3))
|
||||
qhullin.write("%i \n"%(num_grains*27))
|
||||
for i in range(0,num_grains):
|
||||
xcor=random.random()*sizeX
|
||||
ycor=random.random()*sizeY
|
||||
zcor=random.random()*sizeZ
|
||||
maxX=-sizeX
|
||||
maxY=-sizeY
|
||||
maxZ=-sizeZ
|
||||
for j in range(0,3):
|
||||
for k in range(0,3):
|
||||
for m in range(0,3):
|
||||
qhullin.write("%18.6f %18.6f %18.6f \n"%(xcor+maxX,ycor+maxY,zcor+maxZ))
|
||||
maxZ=maxZ+sizeZ
|
||||
maxY=maxY+sizeY
|
||||
maxZ=-sizeZ
|
||||
maxX=maxX+sizeX
|
||||
maxY=-sizeY
|
||||
qhullin.close()
|
||||
retcode=subprocess.call("qvoronoi.exe TI qhullin.dat Fi Fn o TO qhullout.dat")
|
||||
HullFile=open('qhullout.dat')
|
||||
# Read Hyperplane Data
|
||||
numPlanes=int(HullFile.readline())
|
||||
hyps=[]
|
||||
vhyp=[]
|
||||
for i in range(0,numPlanes):
|
||||
hyps.append([])
|
||||
vhyp.append([])
|
||||
for i in range(0,numPlanes):
|
||||
coords=HullFile.readline().split(' ')
|
||||
cell1=int(coords[0])
|
||||
cell2=int(coords[1])
|
||||
crd=[]
|
||||
for j in range(3,len(coords)-1):
|
||||
if coords[j]!='':
|
||||
crd.append(float(coords[j]))
|
||||
hyps[cell1].append([crd[0],crd[1],crd[2],crd[3]])
|
||||
hyps[cell2].append([crd[0],crd[1],crd[2],crd[3]])
|
||||
# Read Vertex Neighbour Data
|
||||
numVerts=int(HullFile.readline())
|
||||
vNbr=[]
|
||||
vCrd=[]
|
||||
for i in range(0,numVerts+1):
|
||||
vNbr.append([])
|
||||
vCrd.append([])
|
||||
for i in range(0,numVerts):
|
||||
vNbr[i].append(HullFile.readline().split(' '))
|
||||
numVerts=int(HullFile.readline())
|
||||
dat1=HullFile.readline().split(' ')
|
||||
numVerts=int(dat1[0])
|
||||
numCells=int(dat1[1])
|
||||
# Read Vertex Coord Data
|
||||
for i in range(0,numVerts):
|
||||
vCrd[i].append(HullFile.readline().split(' '))
|
||||
# Read Cell Vertex Data
|
||||
vCell=[]
|
||||
for i in range(0,numCells):
|
||||
vCell.append([])
|
||||
for i in range(0,numCells):
|
||||
vCell[i].append(HullFile.readline().split(' '))
|
||||
# Find Vertices on Each Hyperplane on Each Cell
|
||||
for i in range(0,numCells):
|
||||
for j in range(0,len(hyps[i])):
|
||||
nx=hyps[i][j][0]
|
||||
ny=hyps[i][j][1]
|
||||
nz=hyps[i][j][2]
|
||||
off=hyps[i][j][3]
|
||||
vhyp=[]
|
||||
for k in range(0,int(vCell[i][0][0])):
|
||||
index=int(vCell[i][0][k])
|
||||
vx=float(vCrd[index][0][0])
|
||||
vy=float(vCrd[index][0][1])
|
||||
vz=float(vCrd[index][0][2])
|
||||
distance=nx*vx+ny*vy+nz*vz+off
|
||||
if abs(distance)<1.e-4:
|
||||
vhyp.append(index)
|
||||
for k in range(0,len(vhyp)):
|
||||
for m in range(0,len(vhyp)):
|
||||
if k!=m:
|
||||
ax=float(vCrd[vhyp[k]][0][0])
|
||||
ay=float(vCrd[vhyp[k]][0][1])
|
||||
az=float(vCrd[vhyp[k]][0][2])
|
||||
bx=float(vCrd[vhyp[m]][0][0])
|
||||
by=float(vCrd[vhyp[m]][0][1])
|
||||
bz=float(vCrd[vhyp[m]][0][2])
|
||||
aPart.WirePolyLine(points=((ax,ay,az),(bx,by,bz)),mergeWire=OFF)
|
||||
|
||||
HullFile.close()
|
Loading…
Add table
Add a link
Reference in a new issue