from load import * from mesh import * from optimization import * from job import * from sketch import * from visualization import * from connectorBehavior import * from abaqus import getInput # mesh is not created in this script! #User inputs required parameters while True: try: m = float(getInput('Enter gear module:','2')) break except ValueError: print("Invalid input, please enter a number") while True: try: z1 = int(getInput("Enter number of teeth: ",'30')) break except ValueError: print("Invalid input, please enter an integer") while True: try: pressure_angle = float(getInput("Enter pressure angle: ",'20')) break
def all_over(self, angles, thickness, input_file_location): os.chdir(input_file_location) input_folder_name = getInput('Enter name for folder containing input files: ') if not os.path.exists(input_folder_name): os.mkdir(input_folder_name) print("Directory " , input_folder_name , " Created ") os.chdir(input_folder_name) else: print("Directory " , input_folder_name , " already exists") os.chdir(input_folder_name) return for angle in angles: try: openMdb(pathName=self.cae_file_path) p = mdb.models['Model-1'].parts['HW'] #--------------- Materials ------------------------------------- mdb.models['Model-1'].Material(name='CF') mdb.models['Model-1'].Material(name='Foam') mdb.models['Model-1'].materials['CF'].Elastic(type=ENGINEERING_CONSTANTS, table=((130000.0, 10000.0, 10000.0, 0.2, 0.2, 0.4, 4000.0, 4000.0, 3000.0), )) mdb.models['Model-1'].materials['Foam'].Elastic(type=ISOTROPIC, table=((300,0.3), )) #---------------- Section ---------------------------------------- sectionLayer1 = section.SectionLayer(material='CF', thickness=thickness, orientAngle=angle, numIntPts=3, plyName='') mdb.models['Model-1'].CompositeShellSection(name='CF', preIntegrate=OFF, idealization=NO_IDEALIZATION, symmetric=False, thicknessType=UNIFORM, poissonDefinition=DEFAULT, thicknessModulus=None, temperature=GRADIENT, useDensity=OFF, integrationRule=SIMPSON, layup=(sectionLayer1, )) mdb.models['Model-1'].HomogeneousSolidSection(name='Foam', material='Foam', thickness=None) # --------------- Assignment ---------------------------------------- cells = p.cells region = p.Set(cells=cells, name='Set-1') p.SectionAssignment(region=region, sectionName='Foam', offset=0.0, offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION) faces = p.faces p.Skin(faces=faces, name='Skin-1') region = p.Set(skinFaces=(('Skin-1', faces), ), name='Set-4') p.SectionAssignment(region=region, sectionName='CF', offset=0.0, offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION) # ----------------- Orientation ------------------------------------- s = p.faces edge = p.edges.getByBoundingBox(-1000,-1000,249,1000,1000,251) normalAxisRegion = p.Surface(side1Faces=s, name='Normal_Axis_Region') primaryAxisRegion = p.Set(edges=edge, name='Primary_Axis_Region') mdb.models['Model-1'].parts['HW'].MaterialOrientation(region=region, orientationType=GLOBAL, axis=AXIS_1, additionalRotationType=ROTATION_NONE, localCsys=None, fieldName='') """ mdb.models['Model-1'].parts['HW'].MaterialOrientation(region=region, orientationType=DISCRETE, axis=AXIS_3, normalAxisDefinition=SURFACE, normalAxisRegion=normalAxisRegion, flipNormalDirection=False, normalAxisDirection=AXIS_3, primaryAxisDefinition=EDGE, primaryAxisRegion=primaryAxisRegion, primaryAxisDirection=AXIS_2, flipPrimaryDirection=False, additionalRotationType=ROTATION_NONE, angle=0.0, additionalRotationField='') """ # ----------------- Skin Mesh ---------------------------------------- elemType1 = mesh.ElemType(elemCode=S8R, elemLibrary=STANDARD) elemType2 = mesh.ElemType(elemCode=STRI65, elemLibrary=STANDARD) a = mdb.models['Model-1'].rootAssembly f1 = a.instances['HW-1'].faces pickedRegions = regionToolset.Region(skinFaces=(('Skin-1', f1), )) a.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2)) # ------------------ Job ---------------------------------------------- name = 'HWAllOver_' + str(int(angle)) print(name) mdb.Job(name=name, model='Model-1', description='', type=ANALYSIS, atTime=None, waitMinutes=0, waitHours=0, queue=None, memory=90, memoryUnits=PERCENTAGE, getMemoryFromAnalysis=True, explicitPrecision=SINGLE, nodalOutputPrecision=SINGLE, echoPrint=OFF, modelPrint=OFF, contactPrint=OFF, historyPrint=OFF, userSubroutine='', scratch='', resultsFormat=ODB, multiprocessingMode=DEFAULT, numCpus=1, numGPUs=0) mdb.jobs[name].writeInput(consistencyChecking=OFF) mdb.close() except: pass
memoryUnits=PERCENTAGE, getMemoryFromAnalysis=True, explicitPrecision=SINGLE, nodalOutputPrecision=SINGLE, echoPrint=OFF, modelPrint=OFF, contactPrint=OFF, historyPrint=OFF, userSubroutine='', scratch='', resultsFormat=ODB, multiprocessingMode=DEFAULT, numCpus=1, numGPUs=0) mdb.jobs[Jobb[0]].writeInput(consistencyChecking=OFF) # Creating job .inp file n = n + 1 # Loop Counter previousset.insert(y, Sets[y]) print(previousset) for s in range(0, len(Sets), 1): # Remove previous loop section assignments del mdb.models['Model-1'].parts['Azp65C-PB_NFR_Solid'].sectionAssignments[0] #-----------Receive input from user on type of partition pattern ----------# reply = getInput('SELECT PARTITION METHOD (HORIZONTAL, VERTICAL, FAN(UNDER CONST), GRID(CELLS NOT ASSIGNED)):') if reply == 'HORIZONTAL': reply2 = getInput('Specify Partition Density (2,3...)') if reply2>1: SweepAssignSectionHorizontal(int(reply2)) else: print('You are a moron') elif reply == 'VERTICAL': reply2 = getInput('Specify Partition Density (2,3...)') if reply2 > 1: SweepAssignSectionVertical(int(reply2)) else: print('You are a moron') elif reply == FAN: print('You are a moron') elif reply == 'GRID':
#--------------------Initial Variable Names and Settings-------------------- reply = getWarningReply( message='Press YES for sheet body \nPress NO for solid body', buttons=(YES, NO)) if reply == YES: part_type = 0 elif reply == NO: part_type = 1 #part_name = str(getInput('Write part name here: ')) part_name = 'HW' file = part_name + '-1' model = mdb.models['Model-1'] tol = 0.01 r = float(getInput('Enter the propeller radius(mm):')) #r = 650 #--------------------Prompt user for which radii to inspect-------------------- fields = (('R= ', '0.5'), ('R= ', '0.6'), ('R= ', '0.7'), ('R= ', '0.8'), ('R= ', '0.9'), ('R= ', ''), ('R= ', ''), ('R= ', ''), ('R= ', ''), ('R= ', '')) r_input = getInputs( fields=fields, label='Enter percentages of the propeller radius(0.5, 0.6,...etc.):', dialogTitle='Inspected radii', ) #filter out empty and duplicate inputs r_val = [] for i in range(len(r_input)):
def SetUpAZP(self): # --------------------Initial Variable Names and Settings-------------------- #self.reply = Aba.getWarningReply(message='Press YES for sheet body \nPress NO for solid body', # buttons=(AbaCon.YES, AbaCon.NO)) self.r = float(getInput('Enter the propeller radius(mm):')) # --------------------Prompt user for which radii to inspect-------------------- fields = (('R= ', '0.5'), ('R= ', '0.6'), ('R= ', '0.7'), ('R= ', '0.8'), ('R= ', '0.9'), ('R= ', ''), ('R= ', ''), ('R= ', ''), ('R= ', ''), ('R= ', '')) self.r_input = getInputs( fields=fields, label= 'Enter percentages of the propeller radius(0.5, 0.6,...etc.):', dialogTitle='Inspected radii', ) # filter out empty and duplicate inputs self.r_val = [] for i in range(len(self.r_input)): duplicate = 0 if self.r_input[i] != '': self.r_val.append(float(self.r_input[i])) for j in range(len(self.r_val) - 1): if self.r_val[-1] == self.r_val[j]: duplicate = 1 if duplicate == 1: self.r_val.remove(self.r_val[-1]) self.r_val.sort() # --------------------Save list of radii and set names to C:\temp-------------------- self.r_name = [] # Used throughout the script to name sets self.set_name = [] for i in range(len(self.r_val)): self.r_name.append('R_' + str(self.r_val[i])[2:]) self.set_name.append('PROFILE-' + self.r_name[i]) self.npz_name = 'parameters_for_plot.npz' np.savez(self.npz_name, r_val=self.r_val, set_name=self.set_name) npzfile = np.load(self.npz_name) # --------------------Import-------------------- self.step = mdb.openStep(self.file_path, scaleFromFile=OFF) self.model.PartFromGeometryFile(name=self.part_name, geometryFile=self.step, combine=True, retainBoundary=True, mergeSolidRegions=True, dimensionality=THREE_D, type=DEFORMABLE_BODY) p = self.model.parts[self.part_name] session.viewports['Viewport: 1'].setValues(displayedObject=p) # --------------------Make instance-------------------- a = self.model.rootAssembly a.DatumCsysByDefault(CARTESIAN) a.Instance(name=self.file, part=p, dependent=OFF) # --------------------Particion Settings-------------------- a.DatumPlaneByPrincipalPlane(principalPlane=YZPLANE, offset=200.0) d1 = a.datums e1 = a.instances[self.file].edges a.Set(name='prePartiti', edges=e1) t = a.MakeSketchTransform(sketchPlane=d1[4], sketchUpEdge=e1[2], sketchPlaneSide=SIDE1, origin=(200.0, 0.0, 0.0)) s = self.model.ConstrainedSketch(name='__profile__', sheetSize=1926.91, gridSpacing=48.17, transform=t) g, v, d1, c = s.geometry, s.vertices, s.dimensions, s.constraints s.setPrimaryObject(option=SUPERIMPOSE) a = self.model.rootAssembly a.projectReferencesOntoSketch(sketch=s, filter=COPLANAR_EDGES) # --------------------Draw Radius circles-------------------- for i in range(len(self.r_val)): s.CircleByCenterPerimeter(center=(0.0, 0.0), point1=(self.r * self.r_val[i], 0.0)) # --------------------Make Partition-------------------- a = self.model.rootAssembly f1 = a.instances[self.file].faces d21 = a.datums e11 = a.instances[self.file].edges a.PartitionFaceBySketchThruAll(sketchPlane=d21[4], sketchUpEdge=e11[2], faces=f1, sketchPlaneSide=SIDE1, sketch=s) s.unsetPrimaryObject() del self.model.sketches['__profile__'] e1 = a.instances[self.file].edges a.Set(name='postPartiti', edges=e1) a.SetByBoolean(name='r_edges', sets=(a.sets['postPartiti'], a.sets['prePartiti']), operation=DIFFERENCE) e1 = a.instances[self.file].edges # --------------------MESH-------------------- # Sheet mesh if self.reply == YES: session.viewports['Viewport: 1'].assemblyDisplay.setValues(mesh=ON) session.viewports[ 'Viewport: 1'].assemblyDisplay.meshOptions.setValues( meshTechnique=ON) a = self.model.rootAssembly f1 = a.instances[self.file].faces a.setMeshControls( regions=f1, elemShape=TRI) # Choose between: QUAD, QUAD_DOMINATED, TRI partInstances = (a.instances[self.file], ) a.seedPartInstance(regions=partInstances, size=10.0, deviationFactor=0.1, minSizeFactor=0.1) elemType1 = mesh.ElemType(elemCode=S8R, elemLibrary=STANDARD) elemType2 = mesh.ElemType(elemCode=STRI65, elemLibrary=STANDARD) pickedRegions = (f1, ) a.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2)) partInstances = (a.instances[self.file], ) a.generateMesh(regions=partInstances) # Solid mesh if self.reply == NO: session.viewports['Viewport: 1'].assemblyDisplay.setValues(mesh=ON) session.viewports[ 'Viewport: 1'].assemblyDisplay.meshOptions.setValues( meshTechnique=ON) a = self.model.rootAssembly partInstances = (a.instances[self.file], ) a.seedPartInstance(regions=partInstances, size=10.0, deviationFactor=0.1, minSizeFactor=0.1) c1 = a.instances[self.file].cells a.setMeshControls(regions=c1, elemShape=TET, technique=FREE) elemType1 = mesh.ElemType(elemCode=C3D20R, elemLibrary=STANDARD) elemType2 = mesh.ElemType(elemCode=C3D15, elemLibrary=STANDARD) elemType3 = mesh.ElemType(elemCode=C3D10, elemLibrary=STANDARD) pickedRegions = (c1, ) a.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2, elemType3)) a.generateMesh(regions=partInstances) # --------------------NodeSets-------------------- for i in range(len(self.r_name)): edges = e1.getByBoundingCylinder((-1000, 0, 0), (1000, 0, 0), self.r * self.r_val[i] + self.tol) a.Set(edges=edges, name=self.r_name[i] + '+tol') edges = e1.getByBoundingCylinder((-1000, 0, 0), (1000, 0, 0), self.r * self.r_val[i] - self.tol) a.Set(edges=edges, name=self.r_name[i] + '-tol') a.SetByBoolean(name='Area', sets=(a.sets[self.r_name[i] + '+tol'], a.sets[self.r_name[i] + '-tol']), operation=DIFFERENCE) a.SetByBoolean(name=self.set_name[i], sets=(a.sets['Area'], a.sets['r_edges']), operation=INTERSECTION) del a.sets['Area'] del a.sets[self.r_name[i] + '+tol'] del a.sets[self.r_name[i] + '-tol'] n_labels = [] for j in range(len(a.sets[self.set_name[i]].nodes)): node = a.sets[self.set_name[i]].nodes[j].label n_labels.append(node) n_labels = np.array(n_labels) a.SetFromNodeLabels( name='nodes_' + self.r_name[i], nodeLabels=((self.file, n_labels), ), ) # --------------------Step-------------------- self.model.StaticStep(name='Step-1', previous='Initial', initialInc=0.001, maxInc=0.1) session.viewports['Viewport: 1'].assemblyDisplay.setValues( step='Step-1') session.viewports['Viewport: 1'].assemblyDisplay.setValues( loads=ON, bcs=ON, predefinedFields=ON, connectors=ON, adaptiveMeshConstraints=OFF) # --------------------Load-------------------- readfile = open(self.pressure_field_path, "r") reading = readfile.read() pressuredist = reading.split('\n') len_s = len(pressuredist) empty_rows = [] for i in range(len_s): if len(pressuredist[i]) == 0: empty_rows.append(i) t = pressuredist[i].split('\t') for j in range(len(t)): t[j] = float(t[j]) pressuredist[i] = t if len(empty_rows) > 0: for i in range(len(empty_rows)): del pressuredist[empty_rows[i]] self.model.MappedField(name='AnalyticalField-1', description='', regionType=POINT, partLevelData=False, localCsys=None, pointDataFormat=XYZ, fieldDataType=SCALAR, xyzPointData=pressuredist) a = self.model.rootAssembly s1 = a.instances[self.file].faces region = a.Surface(side1Faces=s1, name='Surf-1') self.model.Pressure(name='Load-1', createStepName='Step-1', region=region, distributionType=FIELD, field='AnalyticalField-1', magnitude=1.0, amplitude=UNSET) # --------------------BC-------------------- a = self.model.rootAssembly e1 = a.instances[self.file].edges edges = e1.getByBoundingCylinder( (1000, 0, 0), # Top #This is only correct for AzP65C (-1000, 0, 0), # Bottom self.r * 0.408) # Radius a.Set(edges=edges, name='BC_edges_extra') edges = e1.getByBoundingCylinder( (-254, -262, -7), # Top #This is only correct for AzP65C (-254, -262, -20), # Bottom 15) # Radius a.Set(edges=edges, name='BC_edges_single') region = a.SetByBoolean(name='BC-Edges', sets=(a.sets['BC_edges_extra'], a.sets['BC_edges_single']), operation=DIFFERENCE) self.model.DisplacementBC(name='BC-1', createStepName='Initial', region=region, u1=0.0, u2=0.0, u3=0.0, ur1=0.0, ur2=0.0, ur3=0.0, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM, fieldName='', localCsys=None) session.viewports['Viewport: 1'].setValues(displayedObject=p) session.viewports['Viewport: 1'].setValues(displayedObject=a)
def SetUpHW(self): # --------------------Initial Variable Names and Settings-------------------- self.reply = getWarningReply( message='Press YES for sheet body \nPress NO for solid body', buttons=(YES, NO)) self.r = float(getInput('Enter the propeller radius(mm):')) # --------------------Prompt user for which radii to inspect-------------------- self.fields = (('R= ', '0.5'), ('R= ', '0.6'), ('R= ', '0.7'), ('R= ', '0.8'), ('R= ', '0.9'), ('R= ', ''), ('R= ', ''), ('R= ', ''), ('R= ', ''), ('R= ', '')) self.r_input = getInputs( fields=self.fields, label= 'Enter percentages of the propeller radius(0.5, 0.6,...etc.):', dialogTitle='Inspected radii', ) # filter out empty and duplicate inputs self.r_val = [] for i in range(len(self.r_input)): duplicate = 0 if self.r_input[i] != '': self.r_val.append(float(self.r_input[i])) for j in range(len(self.r_val) - 1): if self.r_val[-1] == self.r_val[j]: duplicate = 1 if duplicate == 1: self.r_val.remove(self.r_val[-1]) self.r_val.sort() # r_val = [0.5, 0.6, 0.7, 0.8, 0.9, 0.95] #If all radii are predefined, uncomment this line, add the percentages to the list and comment out the previous 15 lines # --------------------Save list of radii and set names to C:\temp-------------------- self.r_name = [] # Used throughout the script to name sets self.set_name = [] for i in range(len(self.r_val)): self.r_name.append('R_' + str(self.r_val[i])[2:]) self.set_name.append('PROFILE-' + self.r_name[i]) npz_name = 'parameters_for_plot.npz' self.np.savez(npz_name, r_val=self.r_val, set_name=self.set_name) npzfile = self.np.load(npz_name) # --------------------Import-------------------- self.step = mdb.openStep(file_path, scaleFromFile=OFF) self.model.PartFromGeometryFile(name=self.part_name, geometryFile=self.step, combine=True, retainBoundary=True, mergeSolidRegions=True, dimensionality=THREE_D, type=DEFORMABLE_BODY) p = self.model.parts[self.part_name] session.viewports['Viewport: 1'].setValues(displayedObject=p) # --------------------Material-------------------- # model.Material(name='CF-UD') # model.materials['CF-UD'].Elastic(type=ENGINEERING_CONSTANTS, # table=((140000.0, 10000.0, 10000.0, # E1, E2, E3 # 0.28, 0.28, 0.5, # v12, v13, v23 # 3300.0, 3300.0, 3500.0),)) # G12, G13, G23 # --------------------Make instance-------------------- a = self.model.rootAssembly a.DatumCsysByDefault(CARTESIAN) a.Instance(name=self.file, part=p, dependent=OFF) # --------------------Partition Settings-------------------- a.DatumPlaneByPrincipalPlane(principalPlane=YZPLANE, offset=200.0) d1 = a.datums e1 = a.instances[self.file].edges a.Set(name='prePartiti', edges=e1) t = a.MakeSketchTransform(sketchPlane=d1[4], sketchUpEdge=d1[1].axis3, sketchPlaneSide=SIDE1, origin=(200.0, 0.0, 0.0)) s = self.model.ConstrainedSketch(name='__profile__', sheetSize=1926.91, gridSpacing=48.17, transform=t) g, v, d1, c = s.geometry, s.vertices, s.dimensions, s.constraints s.setPrimaryObject(option=SUPERIMPOSE) a = self.model.rootAssembly a.projectReferencesOntoSketch(sketch=s, filter=COPLANAR_EDGES) # --------------------Draw Radius circles-------------------- s.ConstructionLine(point1=(-26.25, 0.0), point2=(18.75, 0.0)) s.HorizontalConstraint(entity=g[2], addUndoState=False) s.ConstructionLine(point1=(0.0, 17.5), point2=(0.0, -10.0)) s.VerticalConstraint(entity=g[3], addUndoState=False) s.FixedConstraint(entity=g[3]) s.FixedConstraint(entity=g[2]) for line in range(len(self.r_val)): s.Line(point1=(-15.0, 15.0), point2=(13.75, 15.0)) s.HorizontalConstraint(entity=g[line + 4], addUndoState=False) s.ObliqueDimension(vertex1=v[2 * line], vertex2=v[2 * line + 1], textPoint=(-4.73760223388672, 9.81308364868164), value=1000) s.DistanceDimension(entity1=g[line + 4], entity2=g[2], textPoint=(29.0790710449219, 5.39719390869141), value=self.r_val[line] * self.r) s.DistanceDimension(entity1=v[2 * line], entity2=g[3], textPoint=(22.0712547302246, 49.0563049316406), value=500) # --------------------Make Partition-------------------- a = self.model.rootAssembly f1 = a.instances[self.file].faces d21 = a.datums e11 = a.instances[self.file].edges a.PartitionFaceBySketchThruAll(sketchPlane=d21[4], sketchUpEdge=d21[1].axis3, faces=f1, sketchPlaneSide=SIDE1, sketch=s) s.unsetPrimaryObject() del self.model.sketches['__profile__'] e1 = a.instances[self.file].edges a.Set(name='postPartiti', edges=e1) a.SetByBoolean(name='r_edges', sets=(a.sets['postPartiti'], a.sets['prePartiti']), operation=DIFFERENCE) e1 = a.instances[self.file].edges # --------------------MESH-------------------- # Sheet mesh if self.reply == YES: session.viewports['Viewport: 1'].assemblyDisplay.setValues(mesh=ON) session.viewports[ 'Viewport: 1'].assemblyDisplay.meshOptions.setValues( meshTechnique=ON) a = self.model.rootAssembly f1 = a.instances[self.file].faces a.setMeshControls( regions=f1, elemShape=TRI) # Choose between: QUAD, QUAD_DOMINATED, TRI partInstances = (a.instances[self.file], ) a.seedPartInstance(regions=partInstances, size=10.0, deviationFactor=0.1, minSizeFactor=0.1) elemType1 = mesh.ElemType(elemCode=S8R, elemLibrary=STANDARD) elemType2 = mesh.ElemType(elemCode=STRI65, elemLibrary=STANDARD) pickedRegions = (f1, ) a.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2)) partInstances = (a.instances[self.file], ) a.generateMesh(regions=partInstances) # Solid mesh if self.reply == NO: session.viewports['Viewport: 1'].assemblyDisplay.setValues(mesh=ON) session.viewports[ 'Viewport: 1'].assemblyDisplay.meshOptions.setValues( meshTechnique=ON) a = self.model.rootAssembly partInstances = (a.instances[self.file], ) a.seedPartInstance(regions=partInstances, size=10.0, deviationFactor=0.1, minSizeFactor=0.1) c1 = a.instances[self.file].cells a.setMeshControls(regions=c1, elemShape=TET, technique=FREE) elemType1 = mesh.ElemType(elemCode=C3D20R, elemLibrary=STANDARD) elemType2 = mesh.ElemType(elemCode=C3D15, elemLibrary=STANDARD) elemType3 = mesh.ElemType(elemCode=C3D10, elemLibrary=STANDARD) pickedRegions = (c1, ) a.setElementType(regions=pickedRegions, elemTypes=(elemType1, elemType2, elemType3)) a.generateMesh(regions=partInstances) # --------------------NodeSets-------------------- for i in range(len(self.r_name)): edges = e1.getByBoundingBox(-1000, -1000, self.r_val[i] * self.r - self.tol, 1000, 1000, self.r_val[i] * self.r + self.tol) a.Set(edges=edges, name='Area') a.SetByBoolean(name=self.set_name[i], sets=(a.sets['Area'], a.sets['r_edges']), operation=INTERSECTION) del a.sets['Area'] n_labels = [] for j in range(len(a.sets[self.set_name[i]].nodes)): node = a.sets[self.set_name[i]].nodes[j].label n_labels.append(node) n_labels = np.array(n_labels) a.SetFromNodeLabels( name='nodes_' + self.r_name[i], nodeLabels=((self.file, n_labels), ), ) # --------------------Step-------------------- self.model.StaticStep(name='Step-1', previous='Initial', initialInc=0.001, maxInc=0.1) session.viewports['Viewport: 1'].assemblyDisplay.setValues( step='Step-1') session.viewports['Viewport: 1'].assemblyDisplay.setValues( loads=ON, bcs=ON, predefinedFields=ON, connectors=ON, adaptiveMeshConstraints=OFF) # --------------------Load-------------------- readfile = open(pressure_field_path, "r") reading = readfile.read() pressuredist = reading.split('\n') len_s = len(pressuredist) for i in range(len_s): t = pressuredist[i].split('\t') for j in range(len(t)): t[j] = float(t[j]) pressuredist[i] = t self.model.MappedField(name='AnalyticalField-1', description='', regionType=POINT, partLevelData=False, localCsys=None, pointDataFormat=XYZ, fieldDataType=SCALAR, xyzPointData=pressuredist) a = self.model.rootAssembly s1 = a.instances[self.file].faces region = a.Surface(side1Faces=s1, name='Surf-1') self.model.Pressure(name='Load-1', createStepName='Step-1', region=region, distributionType=FIELD, field='AnalyticalField-1', magnitude=1.0, amplitude=UNSET) # --------------------BC-------------------- a = self.model.rootAssembly d1 = a.datums a.AttachmentPoints(name='Attachment Points-1', points=(d1[1].origin, ), setName='Attachment Points-1-Set-1') v1 = a.vertices verts1 = v1.getByBoundingBox(-1, -1, -1, 1, 1, 1) region1 = a.Set(vertices=verts1, name='m_Set-14') s1 = a.instances[self.file].faces side1Faces1 = s1.getByBoundingBox(-100, -150, 98, 100, 100, 102) region2 = a.Surface(side1Faces=side1Faces1, name='s_Surf-1') 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) self.model.DisplacementBC(name='BC-1', createStepName='Initial', region=region1, u1=0.0, u2=0.0, u3=0.0, ur1=0, ur2=0, ur3=0, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM, fieldName='', localCsys=None) session.viewports['Viewport: 1'].setValues(displayedObject=p) session.viewports['Viewport: 1'].setValues(displayedObject=a)