phd-scripts/JMBBM13a/3D_Report/TrussMaker.py

80 lines
3.1 KiB
Python
Raw Normal View History

2024-05-13 19:50:21 +00:00
from abaqusConstants import *
from abaqus import *
import regionToolset
import mesh
#
zModel = mdb.models['Model-1']
zAssembly = zModel.rootAssembly
Num_Long=25
Num_High=10
#
zSketch = zModel.ConstrainedSketch(name='__profile__',sheetSize=200.0)
zSketch.Line(point1=(0.0, 0.0), point2=(1., 0.0))
zModel.Part(name='BaseTruss', dimensionality=TWO_D_PLANAR,type=DEFORMABLE_BODY)
zPart = mdb.models['Model-1'].parts['BaseTruss']
zPart.BaseWire(sketch=zSketch)
#
zInstances=[]
k=0
for i in range(0,Num_Long):
for j in range(0,Num_High):
label='I_L'+str(i)+'_H'+str(j)
zAssembly.Instance(name=label, part=zPart, dependent=ON)
zAssembly.translate(instanceList=(label, ), vector=(float(i), float(j), 0.0))
zInstances.append([])
zInstances[k]=zAssembly.instances[label]
k=k+1
zAssembly.InstanceFromBooleanMerge(name='FinalTruss', instances=zInstances, keepIntersections=ON,
originalInstances=SUPPRESS, domain=GEOMETRY)
#
zPart = mdb.models['Model-1'].parts['FinalTruss']
k=1
for eachEdge in zPart.edges:
label='Mat '+str(k)
points=eachEdge.pointOn
zEdges=zPart.edges.findAt(points)
zModel.Material(name=label)
zModel.TrussSection(name=label, material=label,area=1.0)
k=k+1
region = regionToolset.Region(edges=zEdges)
zPart.SectionAssignment(region=region, sectionName=label, offset=0.0,
offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION)
#
zPart.seedPart(size=1.0, deviationFactor=0.1)
elemType1 = mesh.ElemType(elemCode=T2D2, elemLibrary=STANDARD)
pickedRegions =(zPart.edges, )
zPart.setElementType(regions=pickedRegions, elemTypes=(elemType1, ))
zPart.generateMesh()
zVerts = zAssembly.instances['FinalTruss-1'].vertices
zModel.StaticStep(name='Step-1', previous='Initial',
maxNumInc=10000, initialInc=0.1, minInc=1e-07, maxInc=0.1, nlgeom=ON)
k=1
for eachVert in zVerts:
label='BC'+str(k)
points=eachVert.pointOn
zVert=zVerts.findAt(points)
pointX=int(points[0][0])
pointY=int(points[0][1])
if pointY==0:
zAssembly.Set(name='ASet'+str(pointX),vertices=zVert)
else:
zAssembly.Set(name='Temp',vertices=zVert)
try:
zAssembly.SetByMerge(name='BSet'+str(pointX), sets=(zAssembly.sets['BSet'+str(pointX)],zAssembly.sets['Temp']))
except:
zAssembly.Set(name='BSet'+str(pointX),vertices=zVert)
region = regionToolset.Region(vertices=zVert)
zModel.DisplacementBC(name=label+'_Y', createStepName='Initial',
region=region, u1=UNSET, u2=SET, ur3=SET, amplitude=UNSET,
distributionType=UNIFORM, fieldName='', localCsys=None)
k=k+1
if points[0][0]==0.:
zModel.DisplacementBC(name=label+'_X', createStepName='Initial',
region=region, u1=SET, u2=UNSET, ur3=UNSET, amplitude=UNSET,
distributionType=UNIFORM, fieldName='', localCsys=None)
if points[0][0]==float(Num_Long) and points[0][1]==0.:
zModel.DisplacementBC(name='DISP', createStepName='Step-1',
region=region, u1=float(Num_Long)/2., u2=UNSET, ur3=UNSET, amplitude=UNSET,
distributionType=UNIFORM, fieldName='', localCsys=None)
for i in range(0,Num_Long+1):
zModel.Equation('Eq'+str(i),terms=((1.,'BSet'+str(i),1),(-1.,'ASet'+str(i),1)))