def run_job(self, job_name, cpus=12): job = mdb.Job(name=job_name, model=self.mdb, numCpus=cpus, numDomains=cpus) job.submit() job.waitForCompletion()
def changeMatProp(myModel): mdb.models[myModel].materials['PM_INTERFACE_HMG'].Plastic( table=((0.0065, 0.0), )) mdb.models[myModel].materials['PM_INTERFACE_HMG'].elastic.setValues( table=((1.715, 0.3), ), type=ISOTROPIC) mdb.models[myModel].materials for mat in mdb.models[myModel].materials.keys(): myMat = mdb.models[myModel].materials[mat] if mat.startswith('PMGS'): rho = int(myMat.density.table[0][0]) if rho<1:rho=1 E = rho*conversion_factory nu = 0.3 del myMat.elastic myMat.Elastic(table=((E, nu), )) if mat.startswith('PM_CEMENT'): rho = int(myMat.density.table[0][0]) if rho<1:rho=1 E = cementMod nu = 0.3 del myMat.elastic myMat.Elastic(table=((E, nu), )) #mdb.models[myModel].steps['loading_step'].setValues(nlgeom=ON) jobname = myModel + '_ABAQUS' myJob = mdb.Job(model=myModel, name=jobname) myJob.setValues(numCpus=8,numDomains=8,multiprocessingMode=THREADS) myJob.writeInput() mdb.saveAs(myJob.name)
def shellTo2DSolid(modelName,newInpFileName): from abaqus import mdb from abaqusConstants import TWO_D_PLANAR,DEFORMABLE_BODY,OFF import mesh myModel = mdb.models[modelName] myPart = myModel.parts['PART-1'] ## clean node list (remove nodes not in the zMin plane) zCoord = list() nodeLabels = list() for node in myPart.nodes: zCoord.append(node.coordinates[2]) nodeLabels.append(node.label) minZ = min(zCoord) remNodes = [nodeLabels[i] for i, x in enumerate(zCoord) if x > minZ] myPart.SetFromNodeLabels(nodeLabels=remNodes, name='remNodeSet') myPart.deleteNode(nodes=myPart.sets['remNodeSet'], deleteUnreferencedNodes=ON) del myPart.sets['remNodeSet'] del nodeLabels # change parts from 3D shells to 2D planar myPart.setValues(space=TWO_D_PLANAR, type=DEFORMABLE_BODY) ## SECTIONS - delete shell sections for sName in myModel.sections.keys(): del myModel.sections[sName] for sa,secAss in enumerate(myPart.sectionAssignments): del myPart.sectionAssignments[sa] myJob = mdb.Job(model=modelName, name=newInpFileName) myJob.writeInput(consistencyChecking=OFF)
def createJob(self): # Allow use of multiple CPUs/cores cpus=multiprocessing.cpu_count() job = mdb.Job( name=self.modelName, model=self.modelName, 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, parallelizationMethodExplicit=DOMAIN, numDomains=cpus, activateLoadBalancing=False, multiprocessingMode=DEFAULT, numCpus=cpus ) job.writeInput(consistencyChecking=OFF)
def submitJob(modelName, fileName="Job-1"): mdb.Job(atTime=None, contactPrint=aq.OFF, description='', echoPrint=aq.OFF, explicitPrecision=aq.SINGLE, getMemoryFromAnalysis=True, historyPrint=aq.OFF, memory=90, memoryUnits=aq.PERCENTAGE, model=modelName, modelPrint=aq.OFF, multiprocessingMode=aq.DEFAULT, name=fileName, nodalOutputPrecision=aq.SINGLE, numCpus=1, queue=None, scratch='', type=aq.ANALYSIS, userSubroutine='', waitHours=0, waitMinutes=0) mdb.jobs[fileName].submit(consistencyChecking=aq.OFF) mdb.jobs[fileName].waitForCompletion() noElementsWarning = 0 warningString = '' for ii in mdb.jobs[fileName].messages: if ii.type == aq.WARNING: warningString = '*' datmsg = ii.data if datmsg.has_key('message'): datstr = datmsg['message'] nudat = datstr.split() noElementsWarning = nudat[0] break return warningString, noElementsWarning
def changeMatProp(myModel): #abaqusTools.deleteDefaultModel() mdb.models[myModel].materials for mat in mdb.models[myModel].materials.keys(): myMat = mdb.models[myModel].materials[mat] if mat.startswith('PMGS'): rho = int(myMat.density.table[0][0]) if rho<1:rho=1 E = rho*conversion_factory nu = 0.3 del myMat.elastic myMat.Elastic(table=((E, nu), )) if mat.startswith('PM_CEMENT'): rho = int(myMat.density.table[0][0]) if rho<1:rho=1 E = 2.45*percentageChange nu = 0.3 del myMat.elastic myMat.Elastic(table=((E, nu), )) #mdb.models[myModel].steps['loading_step'].setValues(nlgeom=ON) jobname = myModel + '_ABAQUS' myJob = mdb.Job(model=myModel, name=jobname) myJob.setValues(numCpus=noCPU,memory=mem,numDomains=noDomain,multiprocessingMode=THREADS) myJob.writeInput() mdb.saveAs(myJob.name)
def createJob(modelName, fileName='Job-1'): mdb.Job(atTime=None, contactPrint=aq.OFF, description='', echoPrint=aq.OFF, explicitPrecision=aq.SINGLE, getMemoryFromAnalysis=True, historyPrint=aq.OFF, memory=90, memoryUnits=aq.PERCENTAGE, model=modelName, modelPrint=aq.OFF, multiprocessingMode=aq.DEFAULT, name=fileName, nodalOutputPrecision=aq.SINGLE, numCpus=1, queue=None, scratch='', type=aq.ANALYSIS, userSubroutine='', waitHours=0, waitMinutes=0) return mdb.jobs[fileName]
def restartModel(model): from abaqus import mdb from abaqusConstants import PERCENTAGE modelName = model.name resModel = mdb.Model(name=modelName+'-Restart', objectToCopy=model) resModel.setValues(restartJob=modelName+'-Restart') restartJob = mdb.Job(name=modelName+'-Restart', model=modelName+'-Restart', type=RESTART, memory=60, memoryUnits=PERCENTAGE, getMemoryFromAnalysis=True) restartJob.submit() restartJob.waitForCompletion()
def write_file(self, file_name): # Set filename and path output_file_name = os.path.basename(file_name) output_file_name_no_ext = output_file_name.split('.')[0] output_directory = os.path.dirname(file_name) # Set path as working directory if output_directory: os.chdir(output_directory) self.myAssembly.Instance(name='Specimen', part=self.fatigue_part, dependent=ON) # Create job mdb.Job(name=output_file_name_no_ext, model=self.modelDB, 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='', parallelizationMethodExplicit=DOMAIN, numDomains=1, activateLoadBalancing=False, multiprocessingMode=DEFAULT, numCpus=1) # Write job to file mdb.jobs[output_file_name_no_ext].writeInput(consistencyChecking=OFF) # Remove job del mdb.jobs[output_file_name_no_ext] # Fix file name if os.path.exists(os.path.abspath(file_name)): os.remove(os.path.abspath(file_name)) os.rename( os.path.join(output_directory, output_file_name_no_ext + '.inp'), file_name)
def runJob(modelname): from abaqusConstants import * from abaqus import * import step jobname = modelname + '_ABAQUS' myJob = mdb.Job(model=modelname, name=jobname) myJob.setValues(numCpus=8, numDomains=8, multiprocessingMode=THREADS) myJob.writeInput() mdb.saveAs(myJob.name) print >> sys.__stdout__, jobname mdb.models[modelname].steps['loading_step'].setValues(initialInc=0.1, minInc=0.0001, maxInc=1) myJob.submit(consistencyChecking=OFF) #wait for job to complete before opening the odb and checking the stiffness myJob.waitForCompletion()
def changeMatProp(myModel): mdb.models[myModel].materials['PM_INTERFACE_HMG'].elastic.setValues( table=((E1, E2, E3, v, v, v, G, G, G), ), type=ENGINEERING_CONSTANTS) mdb.models[myModel].parts['PART-1'].MaterialOrientation( additionalRotationField='', additionalRotationType=ROTATION_NONE, angle=0.0, axis=AXIS_1, flipNormalDirection=False, flipPrimaryDirection=False, normalAxisDefinition=SURFACE, normalAxisDirection=AXIS_3, normalAxisRegion=mdb.models[myModel].parts['PART-1']. surfaces['INT_SURF'], orientationType=DISCRETE, primaryAxisDefinition=VECTOR, primaryAxisDirection=AXIS_1, primaryAxisVector=(0.0, 0.0, 1.0), region=mdb.models[myModel].parts['PART-1'].sets['PT_INTERFACE'], stackDirection=STACK_3) mdb.models[myModel].materials for mat in mdb.models[myModel].materials.keys(): myMat = mdb.models[myModel].materials[mat] if mat.startswith('PMGS'): rho = int(myMat.density.table[0][0]) if rho < 1: rho = 1 E = rho * conversion_factory nu = 0.3 del myMat.elastic myMat.Elastic(table=((E, nu), )) if mat.startswith('PM_CEMENT'): rho = int(myMat.density.table[0][0]) if rho < 1: rho = 1 E = cementMod nu = 0.3 del myMat.elastic myMat.Elastic(table=((E, nu), )) #mdb.models[myModel].steps['loading_step'].setValues(nlgeom=ON) jobname = myModel + '_ABAQUS' myJob = mdb.Job(model=myModel, name=jobname) myJob.setValues(numCpus=8, numDomains=8, multiprocessingMode=THREADS) myJob.writeInput() mdb.saveAs(myJob.name)
def parametrisedTests(scaleFactor): from abaqus import mdb backwardCompatibility.setValues(reportDeprecated=False) from abaqusConstants import ON, THREADS fileName = r'D:/myWork/procedures/opti4Abq_VC/opti4AbqExamples/scalar1Param/ovC2.inp' fileName.replace('/', os.sep) myModel = mdb.ModelFromInputFile(inputFileName=fileName, name='model') for mat in myModel.materials.keys(): myMat = myModel.materials[mat] if mat.startswith('PMGS'): rho = myMat.density.table[0][0] E = rho * scaleFactor nu = 0.3 del myMat.elastic myMat.Elastic(table=((E, nu), )) myJob = mdb.Job(model='model', name='scaledJob') myJob.writeInput() return myJob, mdb
# outputs # energy outputs model.HistoryOutputRequest(name='ENERGIES', createStepName=step_name, variables=('ALLEN', )) # load-disp outputs position = ref_point_positions[-1] region = model.rootAssembly.sets['Z{}_REF_POINT'.format(position)] model.HistoryOutputRequest(name='RP_{}'.format(position), createStepName=step_name, region=region, variables=('U', 'RF')) # create provisory inp modelJob = mdb.Job(model=model_name, name=job_name) modelJob.writeInput(consistencyChecking=OFF) # add imperfections to inp amp_factor = imperfection / previous_model_results['max_disps'][1] text = [ '*IMPERFECTION, FILE={}, STEP=1'.format(previous_model_job_name), '{}, {}'.format(1, amp_factor) ] with open('{}.inp'.format(job_name), 'r') as file: lines = file.readlines() line_cmp = '** {}\n'.format('INTERACTIONS') for i, line in reversed(list(enumerate(lines))): if line == line_cmp: break
def create_model_SPLA(mod_name, thetadeg, H, R, thickness, PL, E, nu, axial_load=None, axial_displ=None, damping=1.e-8, meshsize=None, bc_side='12', numCpus=None, linear_buckling=False, fil_name=None, mode_xi=None, mode_num=None): """Create a model of a simply supported unstiffened panel for the SPLA Parameters ---------- mod_name : str Model name. thetadeg : float Panel circumferential angle. H : float Panel height. R : float Panel radius. thickness : float Panel thickness. PL : float Perturbation load magnitude. E : float Young modulus nu : float Poisson's ratio. axial_load : float or None Resultant of the applied axial load. If ``None`` activates displacement controlled axial compression. axial_displ : float or None Axial displacement. damping : float, optional The artificial damping factor. meshsize : int or None, optional The mesh size using metric units. When ``None`` is used it is estimated based on the panel dimensions. bc_side : str, optional The degrees-of-freedom to be constrained at the side edges. numCpus : int or None, optional The number of CPUs for the corresponding job that will be created in Abaqus. linear_buckling : bool, optional Flag indicating if this model should be a linear buckling model. fil_name : str or None, optional The .fil file with the imperfection pattern. mode_xi : float or None, optional The imperfection amplitude. mode_num : int or None, optional The linear buckling mode to be applied as imperfection. """ from abaqusConstants import * from abaqus import mdb PL = float(abs(PL)) if axial_load is not None: axial_load = float(abs(axial_load)) load_controlled = True else: if axial_displ is None: axial_displ = 0.005 * H else: axial_displ = float(abs(axial_displ)) load_controlled = False thetarad = radians(thetadeg) xref = R * cos(thetarad / 2.) yref = R * sin(thetarad / 2.) if meshsize is None: meshsize = R * 2 * pi / 420. mod = mdb.Model(name=mod_name, modelType=STANDARD_EXPLICIT) ra = mod.rootAssembly s = mod.ConstrainedSketch(name='__profile__', sheetSize=2 * H) g, v, d, c = s.geometry, s.vertices, s.dimensions, s.constraints s.setPrimaryObject(option=STANDALONE) s.ArcByCenterEnds(center=(0.0, 0.0), point1=(xref, yref), point2=(xref, -yref), direction=CLOCKWISE) part = mod.Part(name='Part-1', dimensionality=THREE_D, type=DEFORMABLE_BODY) datums = part.datums part.BaseShellExtrude(sketch=s, depth=H) hplane = part.DatumPlaneByPrincipalPlane(principalPlane=XYPLANE, offset=H / 2.) part.PartitionFaceByDatumPlane(datumPlane=datums[hplane.id], faces=part.faces) vplane = part.DatumPlaneByPrincipalPlane(principalPlane=XZPLANE, offset=0.0) part.PartitionFaceByDatumPlane(datumPlane=datums[vplane.id], faces=part.faces) s.unsetPrimaryObject() del mod.sketches['__profile__'] part.seedPart(size=meshsize, deviationFactor=0.1, minSizeFactor=0.1) part.generateMesh() ra.Instance(name='Part-1-1', part=part, dependent=ON) ra.regenerate() inst = ra.instances['Part-1-1'] csys_cyl = ra.DatumCsysByThreePoints(name='csys_cyl', coordSysType=CYLINDRICAL, origin=(0.0, 0.0, 0.0), point1=(1.0, 0.0, 0.0), point2=(0.0, 1.0, 0.0)) csys_cyl = ra.datums[csys_cyl.id] vertices = inst.vertices reference_point = vertices.findAt(((R, 0, H), )) ra.Set(vertices=reference_point, name='set_RP') es = inst.edges top_edges = es.getByBoundingBox(0, -2 * R, 0.99 * H, 2 * R, 2 * R, 1.01 * H) set_top_edges = ra.Set(edges=top_edges, name='top_edges') if not linear_buckling: mod.StaticStep(name='constant_loads', previous='Initial', maxNumInc=100, stabilizationMethod=NONE, continueDampingFactors=False, adaptiveDampingRatio=None, initialInc=1.0, maxInc=1.0, nlgeom=ON) mod.StaticStep(name='variable_loads', previous='constant_loads', maxNumInc=10000, stabilizationMagnitude=1e-08, stabilizationMethod=DAMPING_FACTOR, continueDampingFactors=False, adaptiveDampingRatio=None, initialInc=0.01, maxInc=0.01) if PL > 0: perturbation_point = vertices.findAt(((R, 0, H / 2.), )) region = ra.Set(vertices=perturbation_point, name='perturbation_point') mod.ConcentratedForce(name='perturbation_load', createStepName='constant_loads', region=region, cf1=-PL, distributionType=UNIFORM, field='', localCsys=csys_cyl) mod.HistoryOutputRequest(name='history_RP', createStepName='constant_loads', variables=('U3', 'RF3'), region=ra.sets['set_RP'], sectionPoints=DEFAULT, rebar=EXCLUDE) if load_controlled: load_top = axial_load / (R * thetarad) region = ra.Surface(side1Edges=top_edges, name='Surf-1') mod.ShellEdgeLoad(name='load_top', createStepName='variable_loads', region=region, magnitude=load_top, distributionType=UNIFORM, field='', localCsys=csys_cyl) else: mod.DisplacementBC(name='axial_displacement', createStepName='variable_loads', region=set_top_edges, u1=UNSET, u2=UNSET, u3=-axial_displ, ur1=UNSET, ur2=UNSET, ur3=UNSET, amplitude=UNSET, fixed=OFF, distributionType=UNIFORM, fieldName='', localCsys=csys_cyl) if all([fil_name, mode_xi, mode_num]): if fil_name.endswith('.fil'): fil_name = fil_name[:-4] text = '*IMPERFECTION, STEP=1, FILE={0}'.format(fil_name) text += '\n{0:d}, {1:f}'.format(int(mode_num), float(mode_xi)) text += '\n**' pattern = '*Step' abaqus_functions.edit_keywords(mod=mod, text=text, before_pattern=pattern) else: mod.BuckleStep(name='linear_buckling', previous='Initial', numEigen=50, eigensolver=LANCZOS, minEigen=0.0, blockSize=DEFAULT, maxBlocks=DEFAULT) region = ra.Surface(side1Edges=top_edges, name='Surf-1') mod.ShellEdgeLoad(name='load_top', createStepName='linear_buckling', region=region, magnitude=1., distributionType=UNIFORM, field='', localCsys=csys_cyl) text = '' text += '\n**' text += '\n*NODE FILE' text += '\nU,' text += '\n*MODAL FILE' abaqus_functions.edit_keywords(mod=mod, text=text, before_pattern=None) mod.Material(name='Aluminum') mod.materials['Aluminum'].Elastic(table=((E, nu), )) mod.HomogeneousShellSection(name='Shell_property', preIntegrate=OFF, material='Aluminum', thicknessType=UNIFORM, thickness=thickness, thicknessField='', idealization=NO_IDEALIZATION, poissonDefinition=DEFAULT, thicknessModulus=None, temperature=GRADIENT, useDensity=OFF, integrationRule=SIMPSON, numIntPts=5) region = part.Set(faces=part.faces, name='part_faces') part.SectionAssignment(region=region, sectionName='Shell_property', offset=0.0, offsetType=MIDDLE_SURFACE, offsetField='', thicknessAssignment=FROM_SECTION) ra.regenerate() mod.DisplacementBC(name='bc_top', createStepName='Initial', region=set_top_edges, u1=SET, u2=SET, u3=UNSET, ur1=UNSET, ur2=UNSET, ur3=UNSET, amplitude=UNSET, distributionType=UNIFORM, fieldName='', localCsys=csys_cyl) bottom_edges = es.getByBoundingBox(0, -2 * R, -0.01 * H, 2 * R, 2 * R, 0.01 * H) set_bottom_edges = ra.Set(edges=bottom_edges, name='bottom_edges') mod.DisplacementBC(name='bc_bottom', createStepName='Initial', region=set_bottom_edges, u1=SET, u2=SET, u3=SET, ur1=UNSET, ur2=UNSET, ur3=UNSET, amplitude=UNSET, distributionType=UNIFORM, fieldName='', localCsys=csys_cyl) sidee = (es.getByBoundingBox(0, -1.01 * yref, -0.01 * H, R, -0.99 * yref, 1.01 * H) + es.getByBoundingBox(0, 0.99 * yref, -0.01 * H, R, 1.01 * yref, 1.01 * H)) set_side_edges = ra.Set(edges=sidee, name='side_edges') u1, u2, u3, ur1, ur2, ur3 = get_bc(bc_side) mod.DisplacementBC(name='bc_side', createStepName='Initial', region=set_side_edges, u1=u1, u2=u2, u3=u3, ur1=ur1, ur2=ur2, ur3=ur3, amplitude=UNSET, distributionType=UNIFORM, fieldName='', localCsys=csys_cyl) if numCpus is None: numCpus = cpu_count() job = mdb.Job(name=mod_name, model=mod_name, 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=numCpus, numDomains=numCpus, numGPUs=500)
def _meshing(model, VertexPolygon, MastDiameter, MastPitch, cross_section_props, Emodulus, Gmodulus, ConeSlope, nStories=1, power=1., Twist_angle=0., transition_length_ratio=1., include_name='include_mesh'): ''' Parameters ---------- VertexPolygon : int Number of vertices (sides) of the polygon base. MastDiameter : float Radius of the circumscribing circle of the polygon. MastPitch : float Pitch length of the strut (i.e. a single AstroMast!). cross_section_props : dict Stores the information about the cross-section. Specify the type of the cross section using 'type'. An empty 'type' will be understood as generalized cross section. Different types of sections are allowed: -'circular': requires 'd' -'generalized': requires 'Ixx', 'Iyy', 'J', 'area' Emodulus : float Youngus Modulus. Gmodulus : float Shear Modulus. ConeSlope : float Slope of the longerons (0 = straight, <0 larger at the top, >0 larger at the bottom). nStories : int Number of stories in HALF of the strut (i.e. in a single AstroMast!). power: float Power law exponent establishing the evolution of the spacing between battens. Twist_angle : float Do you want to twist the longerons? transition_length_ratio : float Transition zone for the longerons. ''' # initialization MastRadius = MastDiameter / 2.0 MastHeight = nStories * MastPitch # TODO: change section assignment Longeron_CS = cross_section_props['area'] Ix = cross_section_props['Ixx'] Iy = cross_section_props['Iyy'] J = cross_section_props['J'] Mesh_size = min(MastRadius, MastPitch) / 300.0 # Create all the joints of the a single Deployable Mast: joints = np.zeros((nStories + 1, VertexPolygon, 3)) joints_outter = np.zeros((nStories + 1, VertexPolygon, 3)) for iStorey in range(0, nStories + 1, 1): for iVertex in range(0, VertexPolygon, 1): # Constant spacing between each storey (linear evolution): Zcoord = MastHeight / nStories * iStorey # Power-law spacing between each storey (more frequent at the fixed end): # Zcoord = MastHeight*(float(iStorey)/float(nStories))**power # Power-law spacing between each storey (more frequent at the rotating end): # Zcoord = -MastHeight/(float(nStories)**power)*(float(nStories-iStorey)**power)+MastHeight # Exponential spacing between each storey # Zcoord =(MastHeight+1.0)/exp(float(nStories))*exp(float(iStorey)) # Xcoord = MastRadius * np.cos( 2.0 * np.pi / VertexPolygon * iVertex + Twist_angle * min(Zcoord / MastHeight / transition_length_ratio, 1.0)) Ycoord = MastRadius * np.sin( 2.0 * np.pi / VertexPolygon * iVertex + Twist_angle * min(Zcoord / MastHeight / transition_length_ratio, 1.0)) # Save point defining this joint: joints[iStorey, iVertex, :] = ( Xcoord * (1.0 - min(Zcoord, transition_length_ratio * MastHeight) / MastHeight * ConeSlope), Ycoord * (1.0 - min(Zcoord, transition_length_ratio * MastHeight) / MastHeight * ConeSlope), Zcoord) # # center = (0.0, 0.0) # vec = joints[iStorey, iVertex, 0:2] - center # norm_vec = np.linalg.norm(vec) joints_outter[iStorey, iVertex, 2] = joints[iStorey, iVertex, 2] joints_outter[iStorey, iVertex, 0:2] = joints[iStorey, iVertex, 0:2] # end iSide loop # end iStorey loop # Create the longerons: p_longerons = model.Part(name='longerons', dimensionality=THREE_D, type=DEFORMABLE_BODY) p_longerons = model.parts['longerons'] # d_longerons, r_longerons = p_longerons.datums, p_longerons.referencePoints LocalDatum_list = [] # List with local coordinate system for each longeron long_midpoints = [ ] # List with midpoints of longerons (just to determine a set containing the longerons) e_long = p_longerons.edges for iVertex in range(0, VertexPolygon, 1): # First create local coordinate system (useful for future constraints, etc.): iStorey = 0 origin = joints[iStorey, iVertex, :] point2 = joints[iStorey, iVertex - 1, :] name = 'Local_Datum_' + str(iVertex) LocalDatum_list.append( p_longerons.DatumCsysByThreePoints(origin=origin, point2=point2, name=name, coordSysType=CARTESIAN, point1=(0.0, 0.0, 0.0))) # # Then, create the longerons templist = [ ] # List that will contain the points used to make each longeron for iStorey in range(0, nStories + 1, 1): templist.append(joints[iStorey, iVertex, :]) if iStorey != 0: # Save midpoints of bars long_midpoints.append([ (joints[iStorey - 1, iVertex, :] + joints[iStorey, iVertex, :]) / 2, ]) # end if # end iStorey loop p_longerons.WirePolyLine(points=templist, mergeType=IMPRINT, meshable=ON) # Create set for each longeron (to assign local beam directions) for i in range(0, len(templist)): # loop over longerons edges if i == 0: select_edges = e_long.findAt([ templist[0], ]) # Find the first edge else: # Now find remaining edges in longerons temp = e_long.findAt([ templist[i], ]) select_edges = select_edges + temp # end if # end i loop longeron_name = 'longeron-' + str(iVertex) + '_set' p_longerons.Set(edges=select_edges, name=longeron_name) # end for iVertex loop # Longerons set: e_long = p_longerons.edges select_edges = [] for i in range(0, len(long_midpoints)): # loop over longerons edges if i == 0: select_edges = e_long.findAt( long_midpoints[0]) # Find the first edge else: # Now find remaining edges in longerons temp = e_long.findAt(long_midpoints[i]) select_edges = select_edges + temp # end if # end i loop p_longerons.Set(edges=select_edges, name='all_longerons_set') all_longerons_set_edges = select_edges p_longerons.Surface(circumEdges=all_longerons_set_edges, name='all_longerons_surface') # Create a set with all the joints: v_long = p_longerons.vertices select_vertices = [] select_top_vertices = [] select_bot_vertices = [] for iStorey in range(0, nStories + 1, 1): for iVertex in range(0, VertexPolygon, 1): # Select all the joints in the longerons: current_joint = v_long.findAt([ joints[iStorey, iVertex, :], ]) # Find the first vertex current_joint_name = 'joint-' + str(iStorey) + '-' + str(iVertex) # Create a set for each joint: p_longerons.Set(vertices=current_joint, name=current_joint_name) # if iStorey == 0 and iVertex == 0: select_vertices = current_joint # Instantiate the first point in set else: select_vertices = select_vertices + current_joint # Instantiate the first point in set # endif iStorey == 0 and iVertex == 0 # if iStorey == 0: # Also save the bottom nodes separately if iVertex == 0: # Start selecting the bottom joints for implementing the boundary conditions select_bot_vertices = current_joint else: select_bot_vertices = select_bot_vertices + current_joint # endif iStorey == 0: elif iStorey == nStories: # Also save the top nodes separately if iVertex == 0: # Start selecting the top joints for implementing the boundary conditions select_top_vertices = current_joint else: # remaining vertices: select_top_vertices = select_top_vertices + current_joint # end if # end iVertex loop # end iStorey loop p_longerons.Set(vertices=select_vertices, name='all_joints_set') p_longerons.Set(vertices=select_bot_vertices, name='bot_joints_set') p_longerons.Set(vertices=select_top_vertices, name='top_joints_set') # # Create materials: # model.Material(name='NiTi_alloy') # model.materials['NiTi_alloy'].Elastic(table=((83.0E3, 0.31), # )) # model.materials['NiTi_alloy'].Density(table=((1.0E-3, ), )) # model.Material(name='PC') # model.materials['PC'].Elastic(table=((2134, 0.27), # )) # model.materials['PC'].Density(table=((1.19E-3, ), )) # model.Material(name='PLA') # model.materials['PLA'].Elastic(table=((Emodulus, nu), # )) # model.materials['PLA'].Density(table=((1.24E-3, ), )) # model.Material(name='CNT') # model.materials['CNT'].Elastic(table=((1000.0E3, 0.3), # )) # model.materials['CNT'].Density(table=((1.0E-3, ), )) # Create beam profiles and beam sections: model.GeneralizedProfile(name='LongeronsProfile', area=Longeron_CS, i11=Ix, i12=0.0, i22=Iy, j=J, gammaO=0.0, gammaW=0.0) model.BeamSection(name='LongeronsSection', integration=BEFORE_ANALYSIS, poissonRatio=0.31, beamShape=CONSTANT, profile='LongeronsProfile', density=0.00124, thermalExpansion=OFF, temperatureDependency=OFF, dependencies=0, table=((Emodulus, Gmodulus), ), alphaDamping=0.0, betaDamping=0.0, compositeDamping=0.0, centroid=(0.0, 0.0), shearCenter=(0.0, 0.0), consistentMassMatrix=False) # Assign respective sections: p_longerons.SectionAssignment(offset=0.0, offsetField='', offsetType=MIDDLE_SURFACE, region=p_longerons.sets['all_longerons_set'], sectionName='LongeronsSection', thicknessAssignment=FROM_SECTION) # Assing beam orientation: for iVertex in range(0, VertexPolygon, 1): iStorey = 0 dir_vec_n1 = joints[iStorey, iVertex, :] - ( 0., 0., 0.) # Vector n1 perpendicular to the longeron tangent longeron_name = 'longeron-' + str(iVertex) + '_set' region = p_longerons.sets[longeron_name] p_longerons.assignBeamSectionOrientation(region=region, method=N1_COSINES, n1=dir_vec_n1) # end for iVertex # # delta = Mesh_size / 100.0 ######################################################################## # Mesh the structure # refPlane = p_longerons.DatumPlaneByPrincipalPlane(principalPlane=XYPLANE, offset=L/2) # d = p.datums # All_faces = facesLeafs+facesDoubleThickBoom # p.PartitionFaceByDatumPlane(datumPlane=d[refPlane.id], faces=All_faces) # # # p = model.parts['reducedCF_TRAC_boom'] p_longerons.seedPart(size=Mesh_size, deviationFactor=0.04, minSizeFactor=0.001, constraint=FINER) p_longerons.seedEdgeBySize(edges=all_longerons_set_edges, size=Mesh_size, deviationFactor=0.04, constraint=FINER) elemType_longerons = mesh.ElemType(elemCode=B31, elemLibrary=STANDARD) # Element type p_longerons.setElementType(regions=(all_longerons_set_edges, ), elemTypes=(elemType_longerons, )) p_longerons.generateMesh() ####################################################################### # Make Analytical surfaces for contact purposes s1 = model.ConstrainedSketch(name='__profile__', sheetSize=MastRadius * 3.0) # g, v, d, c = s1.geometry, s1.vertices, s1.dimensions, s1.constraints g = s1.geometry s1.setPrimaryObject(option=STANDALONE) s1.Line(point1=(0.0, -MastRadius * 1.1), point2=(0.0, MastRadius * 1.1)) s1.VerticalConstraint(entity=g[2], addUndoState=False) p_surf = model.Part(name='AnalyticSurf', dimensionality=THREE_D, type=ANALYTIC_RIGID_SURFACE) p_surf = model.parts['AnalyticSurf'] p_surf.AnalyticRigidSurfExtrude(sketch=s1, depth=MastRadius * 2.2) s1.unsetPrimaryObject() rigid_face = p_surf.faces # surf_select = f.findAt((0.0,MastRadius*1.05,0.0)) # surf_select = f[0] p_surf.Surface(side1Faces=rigid_face, name='rigid_support') # p_surf.Set(faces=surf_select, name='support_surface_set') # p_surf.sets['all_diagonals_set'] # # Make assembly: a = model.rootAssembly a.DatumCsysByDefault(CARTESIAN) # Create reference points to assign boundary conditions RP_ZmYmXm = a.ReferencePoint(point=(0.0, 0.0, -1.1 * MastRadius)) refpoint_ZmYmXm = (a.referencePoints[RP_ZmYmXm.id], ) a.Set(referencePoints=refpoint_ZmYmXm, name='RP_ZmYmXm') # RP_ZpYmXm = a.ReferencePoint(point=(0.0, 0.0, MastHeight + 1.1 * MastRadius)) refpoint_ZpYmXm = (a.referencePoints[RP_ZpYmXm.id], ) a.Set(referencePoints=refpoint_ZpYmXm, name='RP_ZpYmXm') # # Create longerons a_long = a.Instance(name='longerons-1-1', part=p_longerons, dependent=ON) # Create bottom surface a_surf_bot = a.Instance(name='AnalyticSurf-1-1', part=p_surf, dependent=ON) # Now rotate the plane to have the proper direction a.rotate(instanceList=('AnalyticSurf-1-1', ), axisPoint=(0.0, 0.0, 0.0), axisDirection=(0.0, 1.0, 0.0), angle=90.0) # # Create set with surface select_bot_surf = a_surf_bot.surfaces['rigid_support'] # Perhaps we need to define a set instead of a face # AnalyticSurf_surface=a_surf_bot.Surface(side1Faces=select_bot_surf, name='support_surf_bot-1') model.RigidBody(name='Constraint-RigidBody_surf_bot-1', refPointRegion=refpoint_ZmYmXm, surfaceRegion=select_bot_surf) for iVertex in range(0, VertexPolygon, 1): # # Select appropriate coordinate system: DatumID = LocalDatum_list[iVertex].id datum = a_long.datums[DatumID] for iStorey in range(0, nStories + 1, 1): # Current joint: current_joint_name = 'joint-' + str(iStorey) + '-' + str(iVertex) # Define COUPLING constraints for all the joints: if iStorey == 0: # Bottom base: # master_region = a.sets[ 'RP_ZmYmXm'] # Note that the master is the Reference Point # slave_region = a_long.sets[current_joint_name] # Make constraint for this joint: Constraint_name = 'RP_ZmYmXm_PinConstraint-' + str( iStorey) + '-' + str(iVertex) model.Coupling(name=Constraint_name, controlPoint=master_region, surface=slave_region, influenceRadius=WHOLE_SURFACE, couplingType=KINEMATIC, localCsys=datum, u1=ON, u2=ON, u3=ON, ur1=OFF, ur2=ON, ur3=ON) # # Constraint_name = 'RP_ZmYmXm_FixedConstraint-'+str(iStorey)+'-'+str(iVertex) # model.Coupling(name=Constraint_name, controlPoint=master_region, # surface=slave_region, influenceRadius=WHOLE_SURFACE, couplingType=KINEMATIC, # localCsys=datum, u1=ON, u2=ON, u3=ON, ur1=ON, ur2=ON, ur3=ON) # Make constraint for this joint: elif iStorey == nStories: # Top base: # master_region = a.sets[ 'RP_ZpYmXm'] # Note that the master is the Reference Point # slave_region = a_long.sets[current_joint_name] # Make constraint for this joint: Constraint_name = 'RP_ZpYmXm_PinConstraint-' + str( iStorey) + '-' + str(iVertex) model.Coupling(name=Constraint_name, controlPoint=master_region, surface=slave_region, influenceRadius=WHOLE_SURFACE, couplingType=KINEMATIC, localCsys=datum, u1=ON, u2=ON, u3=ON, ur1=OFF, ur2=ON, ur3=ON) # # Constraint_name = 'RP_ZpYmXm_FixedConstraint-'+str(iStorey)+'-'+str(iVertex) # model.Coupling(name=Constraint_name, controlPoint=master_region, # surface=slave_region, influenceRadius=WHOLE_SURFACE, couplingType=KINEMATIC, # localCsys=datum, u1=ON, u2=ON, u3=ON, ur1=ON, ur2=ON, ur3=ON) # Make constraint for this joint: else: # Middle stories: master_region = a_long.sets[current_joint_name] # slave_region = a_bat.sets[current_joint_name] # Make constraint for this joint: # endif iStorey # # end for iStorey # end for iVertex # # Create hinges: # select_joints=a.instances['deployable_mast-1'].sets['all_joints_set'] # select_RefPoint=a.sets['RP_joints'] # model.RigidBody(name='JointsContraint', refPointRegion=select_RefPoint, # pinRegion=select_joints) # # Export mesh to .inp file # modelJob = mdb.Job(name=include_name, model=model.name) modelJob.writeInput(consistencyChecking=OFF)
def create_job(self, job_params): """Define a single step for the analysis. Assigns *self.job*. Current limitations are: + numDomains is set to numCpus. + numGPUs is set to 0. + User subroutine are not supported. Args: job_params(JobParams): Special namedtuple describing the job created for analysis. See class for full description of options. Raises: AbaqusException: Various exceptions raised by the Abaqus API. """ # The abaqus module cannot be imported in the GUI code, # so only import it when running. from abaqus import mdb numCpus = job_params.numCpus description = job_params.description memoryPercent = job_params.memoryPercent explicitPrecision = job_params.explicitPrecision nodalOutputPrecision = job_params.nodalOutputPrecision # Validate and set job_params.explicitPrecision. if job_params.explicitPrecision.upper() == 'SINGLE': explicitPrecision = SINGLE elif job_params.explicitPrecision.upper() == 'DOUBLE': explicitPrecision = DOUBLE else: raise ValueError('invalid value for job_params.explicitPrecision') # Validate and set job_params.nodalOutputPrecision. if job_params.nodalOutputPrecision.upper() == 'SINGLE': nodalOutputPrecision = SINGLE elif job_params.nodalOutputPrecision.upper() == 'DOUBLE': nodalOutputPrecision = DOUBLE else: raise ValueError( 'invalid value for job_params.nodalOutputPrecision') self.job = mdb.Job(name=self.name, description=description, model=self.model, type=ANALYSIS, atTime=None, waitMinutes=0, waitHours=0, queue=None, memory=memoryPercent, memoryUnits=PERCENTAGE, getMemoryFromAnalysis=True, explicitPrecision=explicitPrecision, nodalOutputPrecision=nodalOutputPrecision, echoPrint=OFF, modelPrint=OFF, contactPrint=OFF, historyPrint=OFF, userSubroutine='', scratch='', resultsFormat=ODB, multiprocessingMode=DEFAULT, numCpus=numCpus, numDomains=numCpus, numGPUs=0) logger.info('Created the job named %s.', self.job.name)
def lin_buckle(model_name, job_name, n_longerons, bottom_diameter, young_modulus, shear_modulus, ratio_top_diameter, ratio_pitch, ratio_d): # variables from ratios d = ratio_d * bottom_diameter pitch = ratio_pitch * bottom_diameter top_diameter = bottom_diameter * (1. - ratio_top_diameter) # variables with defaults n_storeys = 1 twist_angle = 0. transition_length_ratio = 1. # compute variables mast_radius = bottom_diameter / 2. mast_height = n_storeys * pitch cone_slope = (bottom_diameter - top_diameter) / bottom_diameter # create abaqus model model = mdb.Model(name=model_name) backwardCompatibility.setValues(reportDeprecated=False) if 'Model-1' in mdb.models.keys(): del mdb.models['Model-1'] # create joints joints = np.zeros((n_storeys + 1, n_longerons, 3)) for i_storey in range(0, n_storeys + 1, 1): zcoord = mast_height / n_storeys * i_storey aux1 = 2.0 * np.pi / n_longerons aux2 = twist_angle * min( zcoord / mast_height / transition_length_ratio, 1.0) for i_vertex in range(0, n_longerons): aux3 = aux1 * i_vertex + aux2 xcoord = mast_radius * np.cos(aux3) ycoord = mast_radius * np.sin(aux3) joints[i_storey, i_vertex, :] = ( xcoord * (1.0 - min(zcoord, transition_length_ratio * mast_height) / mast_height * cone_slope), ycoord * (1.0 - min(zcoord, transition_length_ratio * mast_height) / mast_height * cone_slope), zcoord) # create geometry longerons longerons_name = 'LONGERONS' part_longerons = model.Part(longerons_name, dimensionality=THREE_D, type=DEFORMABLE_BODY) longeron_points = [] for i_vertex in range(0, n_longerons): # get required points longeron_points.append([ joints[i_storey, i_vertex, :] for i_storey in range(0, n_storeys + 1) ]) # create wires part_longerons.WirePolyLine(points=longeron_points[-1], mergeType=IMPRINT, meshable=ON) # create surface surface_name = 'ANALYTICAL_SURF' s = model.ConstrainedSketch(name='SURFACE_SKETCH', sheetSize=mast_radius * 3.0) s.Line(point1=(0.0, -mast_radius * 1.1), point2=(0.0, mast_radius * 1.1)) part_surf = model.Part(name=surface_name, dimensionality=THREE_D, type=ANALYTIC_RIGID_SURFACE) part_surf.AnalyticRigidSurfExtrude(sketch=s, depth=mast_radius * 2.2) # create required sets and surfaces # surface part_surf.Surface(side1Faces=part_surf.faces, name=surface_name) # longeron edges = part_longerons.edges vertices = part_longerons.vertices # individual sets all_edges = [] for i_vertex, long_pts in enumerate(longeron_points): # get vertices and edges selected_vertices = [vertices.findAt((pt, )) for pt in long_pts] all_edges.append(EdgeArray([edges.findAt(pt) for pt in long_pts])) # individual sets long_name = 'LONGERON-{}'.format(i_vertex) part_longerons.Set(edges=all_edges[-1], name=long_name) # joints for i_storey, vertex in enumerate(selected_vertices): joint_name = 'JOINT-{}-{}'.format(i_storey, i_vertex) part_longerons.Set(vertices=vertex, name=joint_name) name = 'ALL_LONGERONS' part_longerons.Set(edges=all_edges, name=name) name = 'ALL_LONGERONS_SURF' part_longerons.Surface(circumEdges=all_edges, name=name) # joint sets selected_vertices = [] for i_storey in range(0, n_storeys + 1): selected_vertices.append([]) for i_vertex in range(0, n_longerons): name = 'JOINT-{}-{}'.format(i_storey, i_vertex) selected_vertices[-1].append(part_longerons.sets[name].vertices) name = 'BOTTOM_JOINTS' part_longerons.Set(name=name, vertices=selected_vertices[0]) name = 'TOP_JOINTS' part_longerons.Set(name=name, vertices=selected_vertices[-1]) name = 'ALL_JOINTS' all_vertices = list(itertools.chain(*selected_vertices)) part_longerons.Set(name=name, vertices=all_vertices) # create beam section # create section material material_name = 'LONGERON_MATERIAL' nu = young_modulus / (2 * shear_modulus) - 1 abaqusMaterial = model.Material(name=material_name) abaqusMaterial.Elastic(type=ISOTROPIC, table=((young_modulus, nu), )) # create profile profile_name = 'LONGERONS_PROFILE' r = d / 2. model.CircularProfile(name=profile_name, r=r) # create profile section_name = 'LONGERONS_SECTION' model.BeamSection(consistentMassMatrix=False, integration=DURING_ANALYSIS, material=material_name, name=section_name, poissonRatio=0.31, profile=profile_name, temperatureVar=LINEAR) # section assignment part_longerons.SectionAssignment( offset=0.0, offsetField='', offsetType=MIDDLE_SURFACE, region=part_longerons.sets['ALL_LONGERONS'], sectionName=section_name, thicknessAssignment=FROM_SECTION) # section orientation for i_vertex, pts in enumerate(longeron_points): dir_vec_n1 = np.array(pts[0]) - (0., 0., 0.) longeron_name = 'LONGERON-{}'.format(i_vertex) region = part_longerons.sets[longeron_name] part_longerons.assignBeamSectionOrientation(region=region, method=N1_COSINES, n1=dir_vec_n1) # generate mesh # seed part mesh_size = min(mast_radius, pitch) / 300. mesh_deviation_factor = .04 mesh_min_size_factor = .001 element_code = B31 part_longerons.seedPart(size=mesh_size, deviationFactor=mesh_deviation_factor, minSizeFactor=mesh_min_size_factor, constraint=FINER) # assign element type elem_type_longerons = mesh.ElemType(elemCode=element_code) part_longerons.setElementType(regions=(part_longerons.edges, ), elemTypes=(elem_type_longerons, )) # generate mesh part_longerons.generateMesh() # create instances modelAssembly = model.rootAssembly part_surf = model.parts[surface_name] modelAssembly.Instance(name=longerons_name, part=part_longerons, dependent=ON) modelAssembly.Instance(name=surface_name, part=part_surf, dependent=ON) # rotate surface modelAssembly.rotate(instanceList=(surface_name, ), axisPoint=(0., 0., 0.), axisDirection=(0., 1., 0.), angle=90.) # create reference points for boundary conditions ref_point_positions = ['BOTTOM', 'TOP'] for i, position in enumerate(ref_point_positions): sign = 1 if i else -1 rp = modelAssembly.ReferencePoint(point=(0., 0., i * mast_height + sign * 1.1 * mast_radius)) modelAssembly.Set( referencePoints=(modelAssembly.referencePoints[rp.id], ), name='Z{}_REF_POINT'.format(position)) # add constraints for loading instance_longerons = modelAssembly.instances[longerons_name] instance_surf = modelAssembly.instances[surface_name] ref_points = [ modelAssembly.sets['Z{}_REF_POINT'.format(position)] for position in ref_point_positions ] # bottom point and analytic surface surf = instance_surf.surfaces[surface_name] model.RigidBody('CONSTRAINT-RIGID_BODY-BOTTOM', refPointRegion=ref_points[0], surfaceRegion=surf) # create local datums datums = [] for i_vertex in range(0, n_longerons): origin = joints[0, i_vertex, :] point2 = joints[0, i_vertex - 1, :] name = 'LOCAL_DATUM_{}'.format(i_vertex) datums.append( part_longerons.DatumCsysByThreePoints(origin=origin, point2=point2, name=name, coordSysType=CARTESIAN, point1=(0.0, 0.0, 0.0))) # create coupling constraints for i_vertex in range(n_longerons): datum = instance_longerons.datums[datums[i_vertex].id] for i, i_storey in enumerate([0, n_storeys]): joint_name = 'JOINT-{}-{}'.format(i_storey, i_vertex) slave_region = instance_longerons.sets[joint_name] master_region = ref_points[i] constraint_name = 'CONSTRAINT-%s-%i-%i' % ('Z{}_REF_POINT'.format( ref_point_positions[i]), i_storey, i_vertex) model.Coupling(name=constraint_name, controlPoint=master_region, surface=slave_region, influenceRadius=WHOLE_SURFACE, couplingType=KINEMATIC, localCsys=datum, u1=ON, u2=ON, u3=ON, ur1=OFF, ur2=ON, ur3=ON) # from now on, there's differences between linear buckle and riks # create step step_name = 'BUCKLE_STEP' model.BuckleStep(step_name, numEigen=20, previous='Initial', minEigen=0.) # set bcs (displacement) region_name = 'Z{}_REF_POINT'.format(ref_point_positions[0]) loaded_region = modelAssembly.sets[region_name] model.DisplacementBC('BC_FIX', createStepName=step_name, region=loaded_region, u1=0., u2=0., u3=0., ur1=0., ur2=0., ur3=0., buckleCase=BUCKLING_MODES) # set bcs (load) applied_load = -1. region_name = 'Z{}_REF_POINT'.format(ref_point_positions[-1]) loaded_region = modelAssembly.sets[region_name] model.ConcentratedForce('APPLIED_FORCE', createStepName=step_name, region=loaded_region, cf3=applied_load) # create provisory inp modelJob = mdb.Job(model=model_name, name=job_name) modelJob.writeInput(consistencyChecking=OFF) # ask for node file with open('{}.inp'.format(job_name), 'r') as file: lines = file.readlines() line_cmp = '** {}\n'.format('OUTPUT REQUESTS') for i, line in reversed(list(enumerate(lines))): if line == line_cmp: break insert_line = i + 2 for line in reversed(['*NODE FILE, frequency=1', 'U']): lines.insert(insert_line, '{}\n'.format(line)) with open('{}.inp'.format(job_name), 'w') as file: file.writelines(lines)
slave=instance_2.surfaces['YSym_Surface']) # The load, assuming unit nominal bending stress wb = spec.notch_height**2 * spec.thickness / 6 P = load * wb / (spec.length / 2 - spec.R1 - spec.load_position_x) / 2 spec.modelDB.ConcentratedForce(name='Force', createStepName='MechanicalLoad', region=spec.load_node, cf2=P) # Loading the residual stresses os.chdir(simulation_directory) if not os.path.isdir(simulation_directory): os.makedirs(simulation_directory) job = mdb.Job(name=job_name, model=spec.modelDB, numCpus=8, numDomains=8) job.submit(datacheckJob=True) job.waitForCompletion() shutil.copyfile(job_name + '.prt', dante_odb_path + 'utmis_' + specimen_name + '_half.prt') spec.modelDB.Stress(name='Residual_stress', distributionType=FROM_FILE, fileName=dante_odb_path + 'utmis_' + specimen_name + '_half.odb', step=1, increment=1) job.submit() job.waitForCompletion()
def createAnalysis(param): from abaqus import * backwardCompatibility.setValues(reportDeprecated=False) from abaqusConstants import * from caeModules import * import mesh Im2MeshToolbox = r"D:\myWork\procedures\2DImage2Mesh_VC" import sys sys.path.append(Im2MeshToolbox) from sipShell2Abq import shellTo2DGeo ## IMPORT FILE FROM SCANIP MODEL myModel = mdb.ModelFromInputFile(inputFileName=param['sipInpFile'], name=param['modelName']) shellTo2DGeo(myModel) deleteDefaultModel() ## SHORTCUTS myAssembly = myModel.rootAssembly allMats = myModel.materials ## STEP CREATION myModel.StaticStep(initialInc=0.01, timePeriod=param['timePeriod'], maxInc=.1, minInc=1e-9, name='displ', nlgeom=ON, previous='Initial') directions = list() matNames = list() slMaCouples = list() for i, myPart in enumerate(myModel.parts.values()): myPSet = myPart.sets part = myPart.name.split('_')[0] if part == 'INPLANE6': del myModel.parts['INPLANE6_Geo'] del myAssembly.features['INPLANE6_instance'] continue ## MATERIALS cSys = myPart.DatumCsysByThreePoints(coordSysType=CARTESIAN, origin=(0., 0., 0.), point1=(1., 0., 0.), point2=(0., 1., 0.)) mat = 'SM_' + part if allMats.has_key(mat): myMat = myModel.materials[mat] else: print 'material %s unknown!!!' % mat continue E = 0.06 #equivalent GM only as we are perp to fibers!! nu = 0.499 matParam = (E / (4 * (1. + nu)), 6 * (1 - 2. * nu) / E) if matParam[1] == 0.: # incompressible myMat.Hyperelastic(testData=OFF, table=(matParam, ), materialType=ISOTROPIC, type=NEO_HOOKE, behaviorType=INCOMPRESSIBLE) else: myMat.Hyperelastic(testData=OFF, table=(matParam, ), materialType=ISOTROPIC, type=NEO_HOOKE, behaviorType=COMPRESSIBLE) ## SECTION myModel.HomogeneousSolidSection(name='Section_%s' % part, material=mat, thickness=None) myPart.SectionAssignment(region=(myPart.faces[0], ), sectionName='Section_%s' % part) ## BC'S myISet = myAssembly.instances['%s_instance' % part].sets dMin = 'NS_%s_WITH_XMIN' % part dMax = 'NS_%s_WITH_XMAX' % part if myISet.has_key(dMin): myModel.PinnedBC(createStepName='displ', localCsys=None, name='fix_%d' % (i), region=myISet[dMin]) if part == 'INPLANE5': x1 = (1.10898, 1.29364) x2 = (1.29274, 0.74189) d1 = (0.134, -0.12) d2 = (0.18, -0.10) for node in myISet['SF_INPLANE5_WITH_SECTIONNED6'].nodes: i += 1 applyInterpolatedDisplacement(myModel, node, x1, x2, d1, d2, 'mov_%d' % (i)) ## Get Master/Slave couples oParts = list(myModel.parts.keys()) oParts.remove(myPart.name) for setName in myPSet.keys(): if setName.startswith('SF_%s_WITH_' % part): for oPart in oParts: oPartName = oPart.split('_')[0] if oPartName == 'INPLANE6': continue elif oPartName in setName: if [oPartName, part] not in slMaCouples: slMaCouples.append([part, oPartName]) ## CONSTRAINTS - same for all interfaces!! for nbInteraction, slMaCouple in enumerate(slMaCouples): masterName = 'SF_%s_WITH_%s' % (slMaCouple[1], slMaCouple[0]) slaveName = 'SF_%s_WITH_%s' % (slMaCouple[0], slMaCouple[1]) myMaInstance = myAssembly.instances['%s_instance' % slMaCouple[1]] mySlInstance = myAssembly.instances['%s_instance' % slMaCouple[0]] from interactions import Interactions inter = Interactions(myModel) inter.setName('interaction_%i' % nbInteraction) if param['interfaceType'] == 'Tie': inter.setMasterSlave(myMaInstance.sets[masterName], mySlInstance.sets[slaveName]) inter.setInteractionToTie() else: inter.setMasterSlave(myMaInstance.surfaces[masterName], mySlInstance.surfaces[slaveName]) inter.setNormalStiffness(param['normalStiffness']) if param['interfaceType'] == 'Friction': inter.setFrictionBehaviour('Friction') elif param['interfaceType'] == 'Rough': inter.setFrictionBehaviour('Rough') elif param['interfaceType'] == 'Cohesive': inter.setCohesiveBehaviour( useDefaultBehaviour=False, penalties=param['cohesivePenalties']) elif param['interfaceType'] == 'CohesiveRough': inter.setCohesiveBehaviour( useDefaultBehaviour=False, penalties=param['cohesivePenalties']) inter.setFrictionBehaviour('Rough') elif param['interfaceType'] == 'CohesiveFriction': inter.setCohesiveBehaviour() inter.setFrictionBehaviour('Friction') inter.createInteraction() ## JOB myJob = mdb.Job(model=param['modelName'], name=param['modelName']) myJob.writeInput(consistencyChecking=OFF) if param['numCpus'] > 1: myJob.setValues(numCpus=param['numCpus'], numDomains=param['numCpus'], multiprocessingMode=DEFAULT) return myJob, mdb
def shellTo2DGeo(modelName,newInpFileName): from abaqus import mdb from abaqusConstants import TWO_D_PLANAR,DEFORMABLE_BODY,OFF,ON myModel = mdb.models[modelName] myAssembly = myModel.rootAssembly for myPart in myModel.parts.values(): ## clean node list (remove nodes not in the zMin plane) zCoord = list() nodeLabels = list() for node in myPart.nodes: zCoord.append(node.coordinates[2]) nodeLabels.append(node.label) minZ = min(zCoord) remNodes = [nodeLabels[i] for i, x in enumerate(zCoord) if x > minZ] if len(remNodes): myPart.SetFromNodeLabels(nodeLabels=remNodes, name='remNodeSet') myPart.deleteNode(nodes=myPart.sets['remNodeSet'], deleteUnreferencedNodes=ON) del myPart.sets['remNodeSet'] del nodeLabels # change parts from 3D shells to 2D planar # myPart.setValues(space=TWO_D_PLANAR, type=DEFORMABLE_BODY) # for sa,secAss in enumerate(myPart.sectionAssignments): # del myPart.sectionAssignments[sa] # nodeInASet = dict{} # for myASetName in myAssembly.sets.key(): # set = myAssembly.sets[myASetName] # nodeInASet[myASetName] = set.nodes for myInstance in myAssembly.instances.values(): for myISet in myInstance.sets.keys(): if myISet.endswith('WITH_ZMIN'): mySketch = myModel.ConstrainedSketch(name='mySketch', sheetSize=30.0) for ele in myInstance.sets[myISet].elements: for edge in ele.getElemEdges(): if len(edge.getElements())==1: points=list() for node in edge.getNodes(): points.append((node.coordinates[0],node.coordinates[1])) mySketch.Line(point1=tuple(points[0]),point2=tuple(points[1])) myNewPart = myModel.Part(name=myISet.split('_')[1]+'Geo', dimensionality=TWO_D_PLANAR, type=DEFORMABLE_BODY) myNewPart.BaseShell(sketch=mySketch) del mySketch abaqusTools.createInstanceAndAddtoAssembly(myNewPart,myAssembly) for setName in myAssembly.sets.keys(): part = myModel.parts[setName.split('_')[1]+'Geo'] labelList = list() pNodes = list(part.vertices) aSNodes = list() print pNodes for node in myAssembly.sets[setName].nodes: aSNodes.append(node.coordinates) xMin = min(x[0] for x in aSNodes) xMax = max(x[0] for x in aSNodes) yMin = min(x[1] for x in aSNodes) yMax = max(x[1] for x in aSNodes) for pNode in pNodes: if nodeCoord == pNode.pointOn[0]: pNodes.remove(pNode) labelList.append(pNode) print len(labelList) part.Set(vertices=labelList,name=setName) #del myAssembly.sets[setName] del myAssembly.features['PART-1-1'] ## SECTIONS - delete shell sections for sName in myModel.sections.keys(): del myModel.sections[sName] myJob = mdb.Job(model=modelName, name=newInpFileName) myJob.writeInput(consistencyChecking=OFF)