Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
def caeAnalysis(p):
    # check parameter consistency
    assert not (p['withNucleus'] and p['internalPressure']), "do not set internal pressure if nucleus is modelled"
    
    # MODEL
    myModel = mdb.Model(p['modelName'])
    abaqusTools.deleteDefaultModel()
    myAssembly = myModel.rootAssembly
    
    #check if creating annulusCut and NucleusCut makes sense (ie check if there is indeed a cut to make with the dimensions given)
    cutAnnulus = False
    cutNucleus = False
    if p['punchCut']:
        D = getDistanceBetweenCentres((0,0,0),p['punchCentre']) 
        if D<p['punchRadius']+p['innerRadius']:
            cutNucleus = True
            if D>p['punchRadius']-p['innerRadius']:
                cutAnnulus = True      
        
        if (cutAnnulus or cutNucleus):
            punch =  genericIVDCreation.CylNucleus(myModel)
            punch.setCentre(p['punchCentre'])
            punch.setRadius(p['punchRadius'])
            punch.setHeight(p['height'])
            punch.setName('punch')
            #punchInstance,punchPart = punch.create()
    
    annulus =  genericIVDCreation.CylAnnulus(myModel)
    annulus.setInnerRadius(p['innerRadius'])
    annulus.setOuterRadius(p['outerRadius'])
    annulus.setHeight(p['height'])
    annulus.setNbLamellae(p['nbLamellae'])
    annulus.setNbCuts(p['nbCut'])
    if p['matType'] != 'Holzapfel':
        annulus.setToIncompressible()#will use hybrid elements for almost incompressible material - check if can be used for Holzapfel
    if cutAnnulus:
        annulus.cutWithPunch(punch)
    annulusParts,cutAnnulusPart = annulus.create()

    matNames = list()
    directions = list()
    for cyl in range(p['nbLamellae']):
        thisPart = annulusParts[cyl]
        for arc in range(p['nbCut'][cyl]):
            sectionName = 'annulus%i_section%i'%(cyl,arc)
            domainNb = int(sum(p['nbCut'][0:cyl]))+arc
            if cutAnnulusPart[cyl][arc]:# if the lamella is completely severed then two points are needed to define the cells
                lamellarThickness = (p['outerRadius']-p['innerRadius'])/p['nbLamellae']
                r0 = p['innerRadius']+(p['outerRadius']-p['innerRadius'])/p['nbLamellae']*cyl
                alpha = 360./p['nbCut'][cyl]*(arc+1-0.01)*math.pi/180.
                middlePt = ((r0*math.cos(alpha),p['height']/2.,r0*math.sin(alpha)),)
                pickedCells2 = (thisPart.cells.findAt(middlePt),thisPart.cells.findAt((annulus.midPoint[domainNb],)))
            else: pickedCells2 = thisPart.cells.findAt((annulus.midPoint[domainNb],))
            # create material
            matName = 'annulus%i'%domainNb
            if isinstance(p['holzapfelParameters'],list) and len(p['holzapfelParameters']) == int(sum(p['nbCut'])):#there is one set of parameters per cut
                matParam = p['holzapfelParameters'][domainNb]
            elif len(p['holzapfelParameters']) == 5:
                matParam = p['holzapfelParameters']
            else: raise("parameter 'holzapfelParameters' of unknown type or wrong length")
            if p['matType'] == 'Holzapfel':
                if isinstance(p['fiberDirection'],list) and len(p['fiberDirection']) == int(sum(p['nbCut'])):
                    fibreAngle = p['fiberDirection'][domainNb]
                elif isinstance(p['fiberDirection'],float) and p['nbLamellae']<2:
                    fibreAngle = p['fiberDirection']
                else: raise Exception("parameter 'fiberDirection' of unknown type or wrong length")
                matNames.append(matName)
                directions.append((0.,math.cos(fibreAngle),math.sin(fibreAngle)))
            
            material = genericIVDCreation.annulusMaterial(matName,p['matType'],myModel)
            material.setMatParam(matParam)
            if p['nbLamellae']<2:material.setToTwoDirections()
            material.define()
            
            # coordinate system
            csysCyl = thisPart.DatumCsysByThreePoints(coordSysType=CYLINDRICAL,origin=(0.,0.,0.),point1=(1.,0.,0.),point2=(0.,0.,-1.))
            # assign material
            #abaqusTools.assignMaterialToPart(matName,thisPart,myModel,orientation=csysCyl)
            abaqusTools.assignMaterialToPartition(matName,thisPart,sectionName,pickedCells2,myModel,orientation=csysCyl)
            
    if p['withNucleus']:
        #geometry and mesh
        nucleus =  genericIVDCreation.CylNucleus(myModel,annulus.bottomFaces,annulus.topFaces)
        nucleus.setRadius(p['innerRadius'])
        nucleus.setHeight(p['height'])
        if cutNucleus:
            nucleus.cutWithPunch(punch)
        nucleusInstance,nucleusPart = nucleus.create()
        # material - compressive modulus H~2G (Neo-Hookean model of sig = H/2(lambda-1/lambda)) and C10=G/2  ==> C10 = H/4
        myMat = myModel.Material(name='nucleus')
        myMat.Hyperelastic(testData=OFF,table=((p['compressiveModulus']/4.,0.0),),materialType=ISOTROPIC,type=NEO_HOOKE,behaviorType=INCOMPRESSIBLE)
        abaqusTools.assignMaterialToPart('nucleus',nucleusPart,myModel)
        #nucleus/annulus connection (rough contact)
        innerAnnulus = tuple(annulus.innerFaces[i] for i in range(p['nbCut'][0]))
        outerNucleus = nucleusInstance.faces.findAt((nucleus.outerPoint,))
        masterSurface = myAssembly.Surface(name='innerAnnulus',side1Faces=innerAnnulus)
        slaveSurface = myAssembly.Surface(name='outerNucleus',side1Faces=outerNucleus)
        from interactions import Interactions
        inter = Interactions(myModel)
        inter.setMasterSlave(masterSurface,slaveSurface)
        inter.setName('annulusNucleusInterface')
        inter.setFrictionBehaviour('Rough')
        inter.setNormalStiffness(1e8)
        inter.createInteraction()

        topFace = nucleus.topFaces
        bottomFace = nucleus.bottomFaces
    else:    
        topFace = annulus.topFaces
        bottomFace = annulus.bottomFaces
        
    ## SETS FOR OUTPUT ANALYSIS
    myAssembly.Set(faces=tuple(topFace), name='topFaces')
    myAssembly.Set(faces=tuple(bottomFace), name='bottomFaces')
        
    if p['nbLamellae']>1:
        ##CONSTRAINTS - same for all interfaces!!
        for nb in range(1,p['nbLamellae']):
            domainNb = int(sum(p['nbCut'][0:nb]))
            outerFaces = tuple(annulus.outerFaces[domainNb-i-1] for i in range(p['nbCut'][nb-1]))
            if any(cutAnnulusPart[cyl]):outerFaces2 = tuple(annulus.outerFaces2[domainNb-i-1] for i in range(p['nbCut'][nb-1]))
            innerFaces = tuple(annulus.innerFaces[domainNb+i] for i in range(p['nbCut'][nb]))
            if any(cutAnnulusPart[cyl]):masterSurface = myAssembly.Surface(name='master%d'%(nb),side1Faces=(outerFaces,outerFaces2))
            else:masterSurface = myAssembly.Surface(name='master%d'%(nb),side1Faces=outerFaces)
            slaveSurface = myAssembly.Surface(name='slave%d'%(nb),side1Faces=innerFaces)
            from interactions import Interactions
            inter = Interactions(myModel)
            inter.setMasterSlave(masterSurface,slaveSurface)
            inter.setName('interface%d'%(nb))
            if p['interfaceType'] == 'Tie':
                inter.setInteractionToTie()
            elif p['interfaceType'] == 'Friction':
                inter.setFrictionBehaviour('Friction')
            elif p['interfaceType'] == 'Cohesive':
                inter.setCohesiveBehaviour()
            elif p['interfaceType'] == 'CohesiveFriction':
                inter.setCohesiveBehaviour()
                inter.setFrictionBehaviour('Friction')
            inter.createInteraction()

	##STEP
    myModel.StaticStep(name='Load',previous='Initial',timePeriod=p['timePeriod'],initialInc=p['initialInc'],nlgeom=ON,
    maxInc=p['maxInc'],minInc=p['minInc'],maxNumInc=10000)
    myModel.steps['Load'].control.setValues(allowPropagation=OFF, resetDefaultValues=OFF, discontinuous=ON, timeIncrementation=(8, 10, 9., 16., 10.0, 4., 12., 10.0, 5., 3., 50.0))
    #I0=8(nb equ ite - cannot change if discontinuous ON),Ir=10 (nb conseq equ ite - cannot change if discontinuous ON),Ip=9,Ic=16,Il=10,Ig=4,Is=12,Ia=5,Ij=5,It=3,Isc=50
    myModel.steps['Load'].solverControl.setValues(allowPropagation=OFF, resetDefaultValues=OFF, maxIterations=10)
	
    ##LOAD/BC - after step as the step names are used!!!
    myTopSurface = myAssembly.Surface(name='topSurface',side1Faces=topFace)
    cylSys = myAssembly.DatumCsysByThreePoints(name='cylC',coordSysType=CYLINDRICAL, origin=(0,0,0),\
    point1=(1.0, 0.0, 0), point2=(0.0, 0.0, -1.0) )
    datumCyl = myAssembly.datums[cylSys.id]
    if p['load'] =='Pressure':#default !! magnitude provided = PRESSURE
        myModel.Pressure(name='Pressure',createStepName='Load',region=myTopSurface,magnitude=p['loadMagnitude'],
        distributionType=UNIFORM)
        myModel.PinnedBC(name='Fixed',createStepName='Load',region=tuple(bottomFace))
    elif p['load'] == 'Pressure_total': #!!magnitude provided = total INITIAL FORCE, when the area varies -> force = magnitude*area1/area0!!
        myModel.Pressure(name='Pressure',createStepName='Load',region=myTopSurface,magnitude=p['loadMagnitude'],
        distributionType=TOTAL_FORCE)
        myModel.PinnedBC(name='Fixed',createStepName='Load',region=tuple(bottomFace))
    elif p['load'] == 'vertDispl':
        myModel.DisplacementBC(name='Displ',createStepName='Load',region=tuple(topFace),u1=0.,u2=0.,u3=-p['displ'], localCsys=datumCyl)
        myModel.PinnedBC(name='Fixed',createStepName='Load',region=tuple(bottomFace))
    elif p['load'] == 'PressurePlane':# magnitude provided = concentrated FORCE on the rigid plane
        import regionToolset
        p['outerRadius'] = p['outerRadius']
        surf = myModel.ConstrainedSketch(name='surf', sheetSize=200.0)
        surf.Line(point1=(0.0, p['outerRadius']), point2=(0.0, -p['outerRadius']))
        surfPart = myModel.Part(name='crushingPart', dimensionality=THREE_D, type=ANALYTIC_RIGID_SURFACE)
        surfPart.AnalyticRigidSurfExtrude(sketch=surf, depth=2.*p['outerRadius'])
        surfPart.ReferencePoint(point=(0.0, 0.0, 0.0))
        crushPlane = myAssembly.Instance(name='crushingPlane', part=surfPart, dependent=ON)
        f1 = myAssembly.instances['crushingPlane'].faces[0]
        f2 = myAssembly.instances['cylinder0_instance'].faces[1]
        myAssembly.ParallelFace(movablePlane=f1, fixedPlane=f2, flip=ON)
        myAssembly.translate(instanceList=('crushingPlane', ), vector=(0.0, p['height'], 0.0))
        side1Faces1 = crushPlane.faces.getSequenceFromMask(mask=('[#1 ]', ), )
        myCrushingSurface = myAssembly.Surface(side1Faces=side1Faces1, name='crushingSurface')
        myModel.Tie(name='tieTop', master=myCrushingSurface, slave=myTopSurface)
        region = regionToolset.Region(referencePoints=(crushPlane.referencePoints[2], ))
        myModel.ConcentratedForce(name='Load-1', createStepName='Load', region=region, cf2=-p['loadMagnitude'], distributionType=UNIFORM,
        follower=ON)
        myModel.DisplacementBC(name='BC-2', createStepName='Load', region=region, u1=0.0, u3=0.0, ur1=0.0, ur2=0.0, ur3=0.0,
        distributionType=UNIFORM)
        myModel.DisplacementBC(name='noRadialDispl',createStepName='Load',region=tuple(topFace),u1=0.,u2=0.,localCsys=datumCyl)
        myModel.PinnedBC(name='Fixed',createStepName='Load',region=tuple(bottomFace))
    else:#load only in internal pressure
        if p['internalPressure']:
            myModel.XsymmBC(name='FixedTop',createStepName='Load',region=tuple(topFace),localCsys=datumCyl)
            myModel.XsymmBC(name='Fixed',createStepName='Load',region=tuple(bottomFace),localCsys=datumCyl)
        else: raise Exception("no BC's have been defined!!")
    if p['internalPressure']:
        myInnerSurface = myAssembly.Surface(name='innerSurface',side1Faces=tuple(annulus.innerFaces[i] for i in range(p['nbCut'][0])))
        myModel.Pressure(name='intPressure',createStepName='Load',region=myInnerSurface,magnitude=p['internalPressure'],
        distributionType=UNIFORM)
    	
    ## OUTPUT REQUESTS
    #fieldVariable = ('S', 'LE', 'U', 'RT', 'P', 'CSTRESS', 'CDISP', 'CFORCE')
    #myModel.fieldOutputRequests['F-Output-1'].setValues(variables=fieldVariable)
    
    ## JOB
    from jobCreation import JobDefinition
    myJobDef = JobDefinition(p['modelName'])
    myJobDef.setScratchDir(p['scratchDir'])
    if p['matType'] == 'Holzapfel':
        myJobDef.setToFibrous()        
        myJobDef.fibreDirections(directions)
        myJobDef.setFibreInputType('partition')
        myJobDef.setMatNames(matNames)
        if p['nbLamellae']<2:myJobDef.setPartitionTwoDirections()
    myNewJob = myJobDef.create()
    if p['numCpus']>1:
        myNewJob.setValues(numCpus=p['numCpus'],numDomains=p['numCpus'],multiprocessingMode=THREADS)
    myNewJob.setValues(memory=3, memoryUnits=GIGA_BYTES)
    mdb.saveAs(myNewJob.name)
    #-------------------------------------------------------
    return myNewJob,mdb