def pipeEigenValue(self): ''' Before the call of this method, the pipe Part should be produced by calling createPerfectPipe function. The eigen mode could used for pipe imperfections in the following simulation :return: ''' m=mdb.models[self.pipeModel] p=m.parts[self.pipePart] a=m.rootAssembly self.pipePro() nodes=a.instances[self.pipePart+str(-1)].nodes n_all=nodes.getByBoundingCylinder((-1,0,0),(self.L+1,0,0),0.2) n_bottom=nodes.getByBoundingBox(xMin=-1,xMax=0.1) n_top=nodes.getByBoundingBox(xMin=self.L-0.1,xMax=self.L+0.1) a.Set(nodes=n_all,name='n_all') a.Set(nodes=n_bottom,name='n_bottom') a.Set(nodes=n_top,name='n_top') import step m.BuckleStep(name='Step-eigenValue',previous='Initial',description='EigenValue analyses', numEigen=5,eigensolver=SUBSPACE) import load regions=regionToolset.Region(nodes=n_top) m.DisplacementBC(name='top-Simply',createStepName='Initial',region=regions,u2=SET) regions=regionToolset.Region(nodes=n_bottom) m.DisplacementBC(name='bottom',createStepName='Initial',region=regions,u1=SET,u2=SET) regions=regionToolset.Region(nodes=n_all) m.DisplacementBC(name='upheaval-fix',createStepName='Initial',region=regions,u3=SET) regions=regionToolset.Region(nodes=n_top) m.ConcentratedForce(name='unitLoad',createStepName='Step-eigenValue',region=regions,cf1=-1.0)
def material(): mdb.models['Flat_Specimen'].Material(name='GFRP_Vacuum') mdb.models['Flat_Specimen'].materials['GFRP_Vacuum'].Elastic( type=ENGINEERING_CONSTANTS, table=((44800.0, 12000.0, 12000.0, 0.3, 0.3, 0.1, 5000.0, 5000.0, 5000.0), )) session.viewports['Viewport: 1'].view.setValues(nearPlane=353.179, farPlane=540.333, width=60.4153, height=33.8254, viewOffsetX=59.1911, viewOffsetY=25.8288) layupOrientation = mdb.models['Flat_Specimen'].parts['Part-1'].datums[4] p = mdb.models['Flat_Specimen'].parts['Part-1'] c = p.cells cells = c.getSequenceFromMask(mask=('[#8 ]', ), ) region1=regionToolset.Region(cells=cells) p = mdb.models['Flat_Specimen'].parts['Part-1'] c = p.cells cells = c.getSequenceFromMask(mask=('[#10 ]', ), ) region2=regionToolset.Region(cells=cells) p = mdb.models['Flat_Specimen'].parts['Part-1'] c = p.cells cells = c.getSequenceFromMask(mask=('[#2 ]', ), ) region3=regionToolset.Region(cells=cells) p = mdb.models['Flat_Specimen'].parts['Part-1'] c = p.cells cells = c.getSequenceFromMask(mask=('[#4 ]', ), ) region4=regionToolset.Region(cells=cells) p = mdb.models['Flat_Specimen'].parts['Part-1'] c = p.cells cells = c.getSequenceFromMask(mask=('[#1 ]', ), ) region5=regionToolset.Region(cells=cells) p = mdb.models['Flat_Specimen'].parts['Part-1'] s = p.faces side1Faces = s.getSequenceFromMask(mask=('[#200000 ]', ), ) normalAxisRegion = p.Surface(side1Faces=side1Faces, name='Set_Surf_Top') primaryAxisDatum=mdb.models['Flat_Specimen'].parts['Part-1'].datums[4].axis3
def defineAndAssignSections(model, part, frame): ''' :param model: :param part: :param frame: :return: :type frame: uFrame1 ''' edges = part.edges for b in frame.strut.beams: e = edges.findAt((b.getMiddlePoint(), )) region = regionToolset.Region(edges=e) section = uSection.getSectionFromModel(model, b.material, b.profile) part.SectionAssignment(region=region, sectionName=section.name, offset=0.0, offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION) for c in frame.strut.columns: e = edges.findAt((c.getMiddlePoint(), )) region = regionToolset.Region(edges=e) section = uSection.getSectionFromModel(model, c.material, c.profile) part.SectionAssignment(region=region, sectionName=section.name, offset=0.0, offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION)
def createAppliedLoad(paramsDict): for key in list(paramsDict): exec('%s="%s"' %(key, paramsDict[key])) try:#only expecting strings or numbers. exec('%s=float(%s)' %(key, key)) except ValueError: pass a = mdb.models[modelName].rootAssembly if strongOrient: #Much better results when weak axis bending is distributed. Strong axis doesn't care so much. region = a.instances[columnPartName + '-1'].sets['Set-1'] mdb.models[modelName].ConcentratedForce(name='Load-1', createStepName='Load', region=region, cf1=0, cf2=appliedLoad/2, cf3=-axialLoad/2, distributionType=UNIFORM, field='', localCsys=None) else: #Distributed AKA traction load #Lateral Load s1 = a.instances['Column-1'].faces side1Faces1 = s1.getByBoundingBox(zMin = Z+tFD) region = regionToolset.Region(side1Faces=side1Faces1) mdb.models[modelName].SurfaceTraction( name='TractionLoad', createStepName='Load', region=region, magnitude=appliedLoad / bA, directionVector=((0,0,0),(0,1,0)), distributionType=UNIFORM, field='', localCsys=None, resultant=OFF) #Axial Load if axialLoad != 0.0: s1 = a.instances['Column-1'].faces side1Faces1 = s1.getByBoundingBox(zMin = Z+tFD) region = regionToolset.Region(side1Faces=side1Faces1) mdb.models[modelName].SurfaceTraction( name='TractionLoad', createStepName='Load', region=region, magnitude=axialLoad / bA, directionVector=((0,0,0),(0,0,-1)), distributionType=UNIFORM, field='', localCsys=None, resultant=OFF)
def Load_Mesh(partname): a = mdb.models['Model-1'].rootAssembly f1 = a.instances[partname + '-1'].faces faces1 = f1.getSequenceFromMask(mask=('[#400 ]',), ) region = regionToolset.Region(faces=faces1) mdb.models['Model-1'].EncastreBC(name='BC-1', createStepName='Initial', region=region, localCsys=None) a = mdb.models['Model-1'].rootAssembly f1 = a.instances[partname + '-1'].faces faces1 = f1.getSequenceFromMask(mask=('[#1000000 ]',), ) region = regionToolset.Region(faces=faces1) mdb.models['Model-1'].DisplacementBC(name='BC-2', createStepName='Initial', region=region, u1=SET, u2=UNSET, u3=SET, ur1=SET, ur2=SET, ur3=SET, amplitude=UNSET, distributionType=UNIFORM, fieldName='', localCsys=None) a = mdb.models['Model-1'].rootAssembly r1 = a.instances[partname + '-1'].referencePoints refPoints1 = (r1[6],) region = regionToolset.Region(referencePoints=refPoints1) mdb.models['Model-1'].ConcentratedForce(name='Load-1', createStepName='Step-1', region=region, cf2=1500.0, distributionType=UNIFORM, field='', localCsys=None) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Mesh # a = mdb.models['Model-1'].rootAssembly partInstances = (a.instances[partname + '-1'],) a.seedPartInstance(regions=partInstances, size=1.7, deviationFactor=0.1, minSizeFactor=0.1) # a = mdb.models['Model-1'].rootAssembly partInstances = (a.instances[partname + '-1'],) a.generateMesh(regions=partInstances)
def createBoundaryConditions(paramsDict): for key in list(paramsDict): exec('%s="%s"' %(key, paramsDict[key])) try:#only expecting strings or numbers. exec('%s=float(%s)' %(key, key)) except ValueError: pass #Fixed BC a = mdb.models[modelName].rootAssembly if modelName == 'onePartModel': f = a.instances[ColumnPart + '-1'].faces else: f = a.instances['Foundation-1'].faces facesBottom = f.getByBoundingBox(zMax=0.0) facesSides = f.getByBoundingBox(xMin=fWX/2) if boundaryConditions == 'Default': #Bottom faces1 = facesBottom elif boundaryConditions == 'Sides': faces1 = facesSides region = regionToolset.Region(faces=faces1) mdb.models[modelName].EncastreBC(name='FixedBC', createStepName='Initial', region=region, localCsys=None) #Symmetry BC if modelName <> 'onePartModel': #Column symmetry a = mdb.models[modelName].rootAssembly f = a.instances['Column-1'].faces faces1 = f.getByBoundingBox(xMax = 0.0) #Get all faces that lie on the x=0.0 plane. region = regionToolset.Region(faces=faces1) mdb.models[modelName].XsymmBC(name='ColumnSymmetry', createStepName='Initial', region=region) #Foundation symmetry f = a.instances['Foundation-1'].faces faces1 = f.getByBoundingBox(xMax = 0.0) #Get all faces that lie on the x=0.0 plane. region = regionToolset.Region(faces=faces1) mdb.models[modelName].XsymmBC(name='ContinuumSymmetry', createStepName='Initial', region=region) else: a = mdb.models[modelName].rootAssembly f = a.instances['CombinedPart-1'].faces faces1 = f.getByBoundingBox(xMax = 0.0) #Get all faces that lie on the x=0.0 plane. region = regionToolset.Region(faces=faces1) mdb.models[modelName].XsymmBC(name='Symmetry', createStepName='Initial', region=region) if modelType == 'CohesiveZoneModel': pass #Will not be affected by presence of cohesive zone when the getByBoundingBox method is used.
def section_ass(): import section import regionToolset import displayGroupMdbToolset as dgm import part import material import assembly import step import interaction import load import mesh import optimization import job import sketch import visualization import xyPlot import displayGroupOdbToolset as dgo import connectorBehavior p = mdb.models['test'].parts['pyrite'] c = p.cells cells = c.getSequenceFromMask(mask=('[#1 ]', ), ) region = regionToolset.Region(cells=cells) p.SectionAssignment(region=region, sectionName='quartz', offset=0.0, offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION) p = mdb.models['test'].parts['calcite'] session.viewports['Viewport: 1'].setValues(displayedObject=p) p = mdb.models['test'].parts['calcite'] c = p.cells cells = c.getSequenceFromMask(mask=('[#1 ]', ), ) region = regionToolset.Region(cells=cells) p = mdb.models['test'].parts['calcite'] p.SectionAssignment(region=region, sectionName='feldspar', offset=0.0, offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION) p = mdb.models['test'].parts['merged_mesh_2'] session.viewports['Viewport: 1'].setValues(displayedObject=p) a = mdb.models['test'].rootAssembly session.viewports['Viewport: 1'].setValues(displayedObject=a) session.viewports['Viewport: 1'].assemblyDisplay.setValues(mesh=ON) session.viewports['Viewport: 1'].assemblyDisplay.meshOptions.setValues( meshTechnique=ON) p = mdb.models['test'].parts['merged_mesh_2'] e = p.elements elements = e.getSequenceFromMask(mask=('[#ffffffff:62 #ffff ]', ), ) region = regionToolset.Region(elements=elements) p = mdb.models['test'].parts['merged_mesh_2'] p.SectionAssignment(region=region, sectionName='feldspar', offset=0.0, offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION)
def set_property(): print("in set_property") # Material Property # Rigid mdb.models['Model-1'].Material(name='Rigid') mdb.models['Model-1'].materials['Rigid'].Density(table=((1.019e-05, ), )) mdb.models['Model-1'].materials['Rigid'].Elastic(table=((1, 0.3), )) # # Section mdb.models['Model-1'].HomogeneousSolidSection(name='Rigid', material='Rigid', thickness=None) # Assign p = mdb.models['Model-1'].parts['Impact Head'] cells = p.cells.getSequenceFromMask(mask=('[#1 ]', ), ) region = regionToolset.Region(cells=cells) p.SectionAssignment(region=region, sectionName='Rigid', offset=0.0, offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION) p = mdb.models['Model-1'].parts['Support Down'] cells = p.cells.getSequenceFromMask(mask=('[#1 ]', ), ) region = regionToolset.Region(cells=cells) p = mdb.models['Model-1'].parts['Support Down'] p.SectionAssignment(region=region, sectionName='Rigid', offset=0.0, offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION) p = mdb.models['Model-1'].parts['Support Up'] cells = p.cells.getSequenceFromMask(mask=('[#1 ]', ), ) region = regionToolset.Region(cells=cells) # p = mdb.models['Model-1'].parts['Support Up'] p.SectionAssignment(region=region, sectionName='Rigid', offset=0.0, offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION)
def rigidbody(mdb, vertices, thickness): """Input: mdb = (obj) model database vertices = (list) list of polygon vertices thickness = (f) thickness of polygon Function: Applies rigid body constraint by creating reference point and selecting bottom plane Output: none """ from abaqus import * from abaqusConstants import * import regionToolset output = [] num_vert = len(vertices[0]) a = mdb.models['standard'].rootAssembly bottom = min(vertices[0][1]) left = min(vertices[0][0]) a = mdb.models['standard'].rootAssembly e1 = a.instances['planetop-1'].edges coord = e1.getClosest(coordinates=((0, -bottom + thickness, 0), )) RP = a.ReferencePoint(point=a.instances['planetop-1'].InterestingPoint( edge=e1.findAt(coordinates=coord[0][1]), rule=MIDDLE)) RP_id = RP.id region2 = a.instances['planetop-1'].sets['planar2'] r1 = a.referencePoints refPoints1 = mdb.models['standard'].rootAssembly.referencePoints[RP_id] region1 = regionToolset.Region(referencePoints=(refPoints1, )) mdb.models['standard'].RigidBody(name='Constraint-1', refPointRegion=region1, bodyRegion=region2) #Rigid body definition for bot plane a = mdb.models['standard'].rootAssembly e2 = a.instances['plane-1'].edges coord = e2.getClosest(coordinates=((0, bottom + thickness, 0), )) RP = a.ReferencePoint(point=a.instances['plane-1'].InterestingPoint( edge=e2.findAt(coordinates=coord[0][1]), rule=MIDDLE)) RP_id = RP.id region2 = a.instances['plane-1'].sets['planar'] r1 = a.referencePoints refPoints1 = mdb.models['standard'].rootAssembly.referencePoints[RP_id] region1 = regionToolset.Region(referencePoints=(refPoints1, )) mdb.models['standard'].RigidBody(name='Constraint-2', refPointRegion=region1, bodyRegion=region2)
def setConcentratedForce(model, instance, stepName, frame): ''' :param model: :param instance: :param stepName: 添加在哪一个分析步 :return: :type stepName: str :type load: uLoad :type frame: uFrame1 ''' for iN in range(0, frame.strut.iNodes.__len__()): for jN in range(0, frame.strut.jNodes.__len__()): x, y = frame.strut.iNodes[iN], frame.strut.jNodes[jN] # 节点的二维坐标 weight = frame.strut.getNodeWeight( iNodeIndex=iN, jNodeIndex=jN) # 与节点相连的所有构件的重量之各的一半 # 在节点上施加集中荷载 vertice = instance.vertices.findAt(((x, y, 0.0), )) rg = regionToolset.Region(vertices=vertice) fName = 'CFN_' + str(iN) + str( jN) # CFN 表示 Concentrated Force acted on Node force = -1 * weight * frame.method.kc # 施加的集中力的值 model.ConcentratedForce(name=fName, createStepName=stepName, region=rg, cf1=force, distributionType=UNIFORM, field='', localCsys=None)
def createSpecifiedTemperatureConstraint(myModel, myAsm, entry, myStep, amp, instName, regionName): """ Apply specified temperature boundary condition in Abaqus model. """ logger = logging.getLogger() try: if not entry['Component']: tempFace = entry['FaceIDs'][0] instances = entry['Instance'] faces = myAsm.instances[instances].faces region = regionToolset.Region(faces=faces[tempFace:tempFace + 1]) else: region = (myAsm.instances[instName].cells, ) # Apply BC to entire part logger.info('Creating load/BC on entirety of ' + instName + ' with treatment Specified Temperature. \n') specTempName = regionName + '-SpecTemp' myModel.TemperatureBC(name=specTempName, createStepName=myStep.name, region=region, magnitude=entry['SpecifiedTemperature'], distributionType=UNIFORM, amplitude=amp) # create specified temperature BC except: cad_library.exitwitherror( 'Error creating specified temperature constraint.', -1, 'AbaqusThermal.py')
def create(self): from abaqusConstants import (UNSET, OFF, UNIFORM, CYLINDRICAL) """Include Constant Amplitude Perturbation Buckle. The load step in which the perturbation buckle is included depends on the ``step`` parameter, which can be 1 or 2. If applied in the first step it will be kept constant, whereas in the second step it will be incremented. The perturbation buckle is included after finding its corresponding vertice. The perturbation buckle is **not created** if its value is smaller then ``0.1*TOL`` (see :mod:`desicos.constants`). .. note:: Must be called from Abaqus. """ if abs(self.cbtotal) < 0.1 * TOL: return from abaqus import mdb import regionToolset cc = self.impconf.conecyl mod = mdb.models[cc.model_name] inst_shell = mod.rootAssembly.instances['INST_SHELL'] region = regionToolset.Region( vertices=inst_shell.vertices.findAt(((self.x, self.y, self.z), ))) vert = inst_shell.vertices.findAt(((self.x, self.y, self.z), )) set_CSBI_R1 = mod.rootAssembly.Set(vertices=vert, name='RF_1_csbi') #mod.rootAssembly.Set(vertex=region, name='RF_1_csbi') step_name = cc.get_step_name(self.step) CSBI_datum = mod.rootAssembly.DatumCsysByThreePoints( name='CSBI', coordSysType=CYLINDRICAL, origin=(0.0, 0.0, 0.0), point1=(1.0, 0.0, 0.0), point2=(0.0, 1.0, 0.0)) datum_CSBI = mod.rootAssembly.datums[CSBI_datum.id] mod.DisplacementBC(name=self.name, createStepName=step_name, region=region, u1=-self.cbradial, u2=UNSET, u3=-self.cbmeridional, ur1=UNSET, ur2=UNSET, ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM, fieldName='', localCsys=datum_CSBI) mod.HistoryOutputRequest(name='CSBI_R1', createStepName=step_name, variables=('U1', 'RF1'), region=set_CSBI_R1)
def assignElementType(self): """ """ elementCodes = self.inputData.getElementCodes() regions = regionToolset.Region(cells=self.mdb["mergedInstance"].cells) self.mdb["assembly"].setElementType(regions=regions, elemTypes=elementCodes)
def makeRegionForBCFromNode(self, node): """ """ instance = self.getCrackContainerInstance() nodeSeq = instance.nodes.sequenceFromLabels(labels=(node.label, )) region = regionToolset.Region(nodes=nodeSeq) return region
def giveMaterial_alpha(faces, i, a1, b1, c1, a2): import section import regionToolset import displayGroupMdbToolset as dgm import part import material import assembly import step import interaction import load import mesh import job import sketch import visualization import xyPlot import displayGroupOdbToolset as dgo import connectorBehavior name = 'alpha' + str(i) mdb.models[mname].Material(name=name) mdb.models[mname].materials[name].Depvar(n=68) mdb.models[mname].materials[name].UserMaterial( unsymm=ON, mechanicalConstants=(0, 1, 0, 1.00, 1, 1, 0, 0, a1, b1, c1, 0.500, 1.000, 1, 5)) mdb.models[mname].HomogeneousSolidSection(name=name, material=name, thickness=None) p = mdb.models[mname].parts[pname] region = regionToolset.Region(faces=faces) p.SectionAssignment(region=region, sectionName=name, offset=0.0, offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION)
def assignSectionToPart(self, partName): """ """ sectionName = self.inputData.getSectionName() region = regionToolset.Region(cells=self.mdb["parts"][partName].cells) self.mdb["parts"][partName].SectionAssignment(region=region, sectionName=sectionName)
def createRigidBody(self, RefID, InstanceName): ''' InstanceName='UpperPlate' or 'LowerPlate' ''' a = mdb.models[MyModel._modelName].rootAssembly if InstanceName == 'UpperPlate': height = MyModel._sectionHeight elif InstanceName == 'LowerPlate': height = 0 e1 = a.instances[InstanceName].edges edges1 = e1.findAt(((MyModel._sectionLength / 2, height, 0.0), )) region2 = a.Set(edges=edges1, name='Rigid_Set-' + InstanceName) r1 = a.referencePoints refPoints1 = (r1[RefID], ) import regionToolset region1 = regionToolset.Region(referencePoints=refPoints1) mdb.models[MyModel._modelName].RigidBody(name=InstanceName + 'RigidBody', refPointRegion=region1, bodyRegion=region2, refPointAtCOM=ON)
def pipePro(self): ''' this function is to define the common properties of pipes with respect to material section, assembly, and mesh. :return: ''' m=mdb.models[self.pipeModel] p=m.parts[self.pipePart] import section material_lib(self.pipeModel) m.PipeProfile(name='profile-1', r=self.od/2, t=self.t) m.BeamSection(name='Section-1',profile='profile-1', material=self.m,integration=DURING_ANALYSIS) pipeEdge=p.edges region=(pipeEdge,) p.SectionAssignment(region=region, sectionName='Section-1') region=(pipeEdge,) p.assignBeamSectionOrientation(region=region,method=N1_COSINES,n1=(0,0,-1)) region=(pipeEdge,) p.assignBeamSectionOrientation(region=region,method=N1_COSINES,n1=(0,0,-1)) import assembly a=m.rootAssembly a.Instance(name=self.pipePart+str(-1),part=p,dependent=OFF) # edges for seeds and mesh l_lon=a.instances[self.pipePart+str(-1)].edges.getByBoundingBox(xMin=-1,xMax=self.L+1) a.Set(edges=l_lon,name='pipeL') import mesh a.seedEdgeBySize(edges=l_lon,size=self.sPipe,constraint=FINER) regions=a.instances[self.pipePart+str(-1)].edges a.generateMesh(regions=(a.instances[self.pipePart+str(-1)],)) elemType1=mesh.ElemType(elemCode=PIPE32H) regions=regionToolset.Region(edges=a.instances[self.pipePart+str(-1)].edges) a.setElementType(regions=regions,elemTypes=(elemType1,))
def create(self): """Include the perturbation load. The load step in which the perturbation load is included depends on the ``step`` parameter, which can be 1 or 2. If applied in the first step it will be kept constant, whereas in the second step it will be incremented. The perturbation load is included after finding its corresponding vertice. The perturbation load is **not created** if its value is smaller then ``0.1*TOL`` (see :mod:`desicos.constants`). .. note:: Must be called from Abaqus. """ if abs(self.pltotal) < 0.1*TOL: return from abaqus import mdb import regionToolset cc = self.impconf.conecyl mod = mdb.models[cc.model_name] inst_shell = mod.rootAssembly.instances['INST_SHELL'] region = regionToolset.Region(vertices=inst_shell.vertices.findAt( ((self.x, self.y, self.z),))) step_name = cc.get_step_name(self.step) mod.ConcentratedForce(name=self.name, createStepName=step_name, region=region, cf1=self.plx, cf2=self.ply, cf3=self.plz, field='')
def assignSectionToAllParts(self): """ """ sectionName = self.inputData.getSectionName() for partName in self.mdb["parts"].keys(): part = self.mdb["parts"][partName] region = regionToolset.Region(cells=part.cells) part.SectionAssignment(region=region, sectionName=sectionName)
def set_plate_property(Stack, Metal_name, polymer_name): print("in set plate property") p = mdb.models['Model-1'].parts['Plate'] c = p.cells layup = [] num = 1 for _ in Stack: if (_[0] != _[1]): if _[0]: layup.append( section.SectionLayer(material=Metal_name, thickness=_[2], orientAngle=_[3], numIntPts=3, plyName="p%d" % num)) else: layup.append( section.SectionLayer(material=polymer_name, thickness=_[2], orientAngle=_[3], numIntPts=3, plyName="p%d" % num)) num += 1 mdb.models['Model-1'].CompositeShellSection(name='Section-1', preIntegrate=OFF, idealization=NO_IDEALIZATION, symmetric=False, thicknessType=UNIFORM, poissonDefinition=DEFAULT, thicknessModulus=None, temperature=GRADIENT, useDensity=OFF, integrationRule=SIMPSON, layup=tuple(layup, )) p = mdb.models['Model-1'].parts['Plate'] c = p.cells cells = c.getSequenceFromMask(mask=('[#3 ]', ), ) region = regionToolset.Region(cells=cells) p = mdb.models['Model-1'].parts['Plate'] p.SectionAssignment(region=region, sectionName='Section-1', offset=0.0, offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION) mdb.models['Model-1'].parts['Plate'].MaterialOrientation( region=region, orientationType=SYSTEM, axis=AXIS_3, localCsys=None, fieldName='', additionalRotationType=ROTATION_ANGLE, additionalRotationField='', angle=0.0, stackDirection=STACK_3)
def applyInterpolatedDisplacement2(myModel,node,x1,x2,d1,d2,BCName): x = node.coordinates a = (x[0]-x2[0])/(x1[0]-x2[0]) b = (x[1]-x2[1])/(x1[1]-x2[1]) d = (a*d1[0]+(1.-a)*d2[0],b*d1[1]+(1.-b)*d2[1]) import regionToolset import mesh nodeArray = mesh.MeshNodeArray(nodes=(node,)) nodeRegion = regionToolset.Region(nodes=nodeArray) myModel.DisplacementBC(createStepName='displ', localCsys=None, name=BCName, region=nodeRegion, u1=abs(d[0])*-1.,u2=d[1])
def createRigidTopConstraint(paramsDict): for key in list(paramsDict): exec('%s="%s"' %(key, paramsDict[key])) try:#only expecting strings or numbers. exec('%s=float(%s)' %(key, key)) except ValueError: pass a = mdb.models[modelName].rootAssembly e1 = a.instances[columnPartName + '-1'].edges v1 = a.instances[columnPartName + '-1'].vertices refID = a.ReferencePoint(point=v1.findAt(coordinates=(0.0, 0.0, Z+tFD))).id f1 = a.instances[columnPartName + '-1'].faces faces1 = f1.getByBoundingBox(zMin = Z+tFD) region4=regionToolset.Region(faces=faces1) r1 = a.referencePoints refPoints1=(r1[refID], ) region1=regionToolset.Region(referencePoints=refPoints1) mdb.models[modelName].RigidBody(name='FlangeRigidBody', refPointRegion=region1, tieRegion=region4)
def createMaterialOrientation(self, part): """ """ region = regionToolset.Region(cells=part.cells) localCsys = part.datums[2] part.MaterialOrientation(region=region, orientationType=GLOBAL, axis=AXIS_1, additionalRotationType=ROTATION_NONE, localCsys=None, fieldName='', stackDirection=STACK_3)
def pipeRiks(self): ''' this function can be simply used for the buckling analysis based on modified Riks mehtod. Pipe is under uniaxial compression, There is no introduction of the seabed. Before the call of this method, the pipe Part should be produced by calling createPerfectPipe function, the common modeling function pipePro() should be called as well :return: no return, but produce a model for riks simulation. ''' m=mdb.models[self.pipeModel] p=m.parts[self.pipePart] a=m.rootAssembly self.pipePro() nodes=a.instances[self.pipePart+str(-1)].nodes n_all=nodes.getByBoundingCylinder((-1,0,0),(self.L+1,0,0),0.2) n_bottom=nodes.getByBoundingBox(xMin=-1,xMax=0.1) n_top=nodes.getByBoundingBox(xMin=self.L-0.1,xMax=self.L+0.1) n_center=nodes.getByBoundingBox(xMin=self.L/2-0.1,xMax=self.L/2+0.1) a.Set(nodes=n_all,name='n_all') a.Set(nodes=n_bottom,name='n_bottom') a.Set(nodes=n_top,name='n_top') a.Set(nodes=n_center,name='n_center') import interaction import step m.StaticRiksStep(name='Step-Riks',previous='Initial',\ description='this is the step used for stability analysis',\ maxLPF=1,maxNumInc=100,initialArcInc=0.01,minArcInc=1e-10,maxArcInc=0.1,nlgeom=ON) regions=a.sets['n_top'] m.HistoryOutputRequest(name='H-Output-2',createStepName='Step-Riks',variables=('UT','MISES','S11','E11'),region=regions) regions=a.sets['n_center'] m.HistoryOutputRequest(name='centerHistory',createStepName='Step-Riks',variables=('UT',),region=regions) import load regions=regionToolset.Region(nodes=n_top) m.DisplacementBC(name='top-Simply',createStepName='Initial',region=regions,u2=SET) regions=regionToolset.Region(nodes=n_bottom) m.DisplacementBC(name='bottom',createStepName='Initial',region=regions,u1=SET,u2=SET) regions=regionToolset.Region(nodes=n_all) m.DisplacementBC(name='upheaval-fix',createStepName='Initial',region=regions,u3=SET)
def createXFEMcrack(self): """ """ crackName = self.inputData.getCrackInteractionProperties()["name"] contactPropertiesName = self.inputData.getCrackContactProperties()["crackContactPropertyName"] singularityCalcRadius = self.inputData.getSingularityCalcRadius() if singularityCalcRadius == 0.0: singularityCalcRadius = None crackDomainRegion = regionToolset.Region( cells=self.mdb["mergedInstance"].cells) crackLocationRegion = regionToolset.Region( faces=self.mdb["sets"]["faces"]["crackFlanks"].faces) self.mdb["assembly"].engineeringFeatures.XFEMCrack( name=crackName, allowCrackGrowth=False, crackDomain=crackDomainRegion, crackLocation=crackLocationRegion, interactionProperty=contactPropertiesName, singularityCalcRadius=singularityCalcRadius)
def assignSectionToCrackDomain(self): """ """ sectionName = self.inputData.getSectionName() solidParts = self.inputData.getSolidPartsParameters() (name,) = solidParts.keys() crackDomainName = name part = self.mdb["parts"][crackDomainName] region = regionToolset.Region(cells=part.cells) part.SectionAssignment( region=region, sectionName=sectionName)
def set_interaction(): a = mdb.models['Model-1'].rootAssembly p = mdb.models['Model-1'].parts['Impact Head'] p = mdb.models['Model-1'].parts['Plate'] a = mdb.models['Model-1'].rootAssembly p1 = mdb.models['Model-1'].parts['Support Down'] a = mdb.models['Model-1'].rootAssembly mdb.models['Model-1'].ContactProperty('IntProp-1') mdb.models['Model-1'].interactionProperties['IntProp-1'].NormalBehavior( pressureOverclosure=HARD, allowSeparation=ON, constraintEnforcementMethod=DEFAULT) mdb.models['Model-1'].interactionProperties[ 'IntProp-1'].TangentialBehavior(formulation=FRICTIONLESS) #: The interaction property "IntProp-1" has been created. mdb.models['Model-1'].ContactExp(name='Int-1', createStepName='Initial') mdb.models['Model-1'].interactions['Int-1'].includedPairs.setValuesInStep( stepName='Initial', useAllstar=ON) mdb.models['Model-1'].interactions[ 'Int-1'].contactPropertyAssignments.appendInStep( stepName='Initial', assignments=((GLOBAL, SELF, 'IntProp-1'), )) #: The interaction "Int-1" has been created. a = mdb.models['Model-1'].rootAssembly c1 = a.instances['Impact Head'].cells cells1 = c1.getSequenceFromMask(mask=('[#1 ]', ), ) region2 = regionToolset.Region(cells=cells1) a = mdb.models['Model-1'].rootAssembly r1 = a.instances['Impact Head'].referencePoints refPoints1 = (r1[2], ) region1 = regionToolset.Region(referencePoints=refPoints1) mdb.models['Model-1'].RigidBody(name='Constraint-1', refPointRegion=region1, bodyRegion=region2) a = mdb.models['Model-1'].rootAssembly c1 = a.instances['Support Up'].cells cells1 = c1.getSequenceFromMask(mask=('[#1 ]', ), ) region2 = regionToolset.Region(cells=cells1) a = mdb.models['Model-1'].rootAssembly r1 = a.instances['Support Up'].referencePoints refPoints1 = (r1[2], ) region1 = regionToolset.Region(referencePoints=refPoints1) mdb.models['Model-1'].RigidBody(name='Constraint-2', refPointRegion=region1, bodyRegion=region2) a = mdb.models['Model-1'].rootAssembly c1 = a.instances['Support Down'].cells cells1 = c1.getSequenceFromMask(mask=('[#1 ]', ), ) region2 = regionToolset.Region(cells=cells1) a = mdb.models['Model-1'].rootAssembly r1 = a.instances['Support Down'].referencePoints refPoints1 = (r1[2], ) region1 = regionToolset.Region(referencePoints=refPoints1) mdb.models['Model-1'].RigidBody(name='Constraint-3', refPointRegion=region1, bodyRegion=region2)
def assignBeamSectionOrientation(frame, part): ''' :type frame: uFrame1 ''' # recommend using edges.findAt() # 定义梁截面方向 rg = frame.strut.getFrameRegion() edges = part.edges.getByBoundingBox(rg[0], rg[1], rg[2], rg[3], rg[4], rg[5]) region = regionToolset.Region(edges=edges) part.assignBeamSectionOrientation(region=region, method=N1_COSINES, n1=(0.0, 0.0, -1.0))
def Assembly_Step(partname): a = mdb.models['Model-1'].rootAssembly a = mdb.models['Model-1'].rootAssembly a.DatumCsysByDefault(CARTESIAN) p = mdb.models['Model-1'].parts[partname] a.Instance(name=partname + '-1', part=p, dependent=ON) #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mdb.models['Model-1'].StaticStep(name='Step-1', previous='Initial') session.viewports['Viewport: 1'].assemblyDisplay.setValues(step='Step-1') #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Interaction a = mdb.models['Model-1'].rootAssembly r1 = a.instances[partname + '-1'].referencePoints refPoints1 = (r1[6],) region1 = regionToolset.Region(referencePoints=refPoints1) a = mdb.models['Model-1'].rootAssembly f1 = a.instances[partname + '-1'].faces faces1 = f1.getSequenceFromMask(mask=('[#1000000 ]',), ) region2 = regionToolset.Region(faces=faces1) mdb.models['Model-1'].Coupling(name='Constraint-1', controlPoint=region1, surface=region2, influenceRadius=WHOLE_SURFACE, couplingType=KINEMATIC, localCsys=None, u1=ON, u2=ON, u3=ON, ur1=ON, ur2=ON, ur3=ON) a = mdb.models['Model-1'].rootAssembly a.makeIndependent(instances=(a.instances[partname + '-1'],))