コード例 #1
0
def ADAMS_setup_INP(myAsm, key, asminfo, instRef, instAssemblyRef, myModel,
                    parallelCores, ramAllocated):
    """ Manipulates Abaqus model to provide correctly formatted INP file. """
    try:
        lodFileID = instRef[key]['ComponentID']
    except KeyError:
        try:
            lodFileID = instAssemblyRef[key]['ComponentID']
        except KeyError:
            cad_library.exitwitherror('LOD file not found for ' + str(key), -1,
                                      'AbaqusCAE_ADAMS.py')
    lodFileName = 'LT_' + lodFileID + '.lod'
    lodFilePath = os.path.join(os.getcwd(), lodFileName)

    # Constrain every vertice of the part in x, y and z directions with soft-springs
    constrainWithSoftSprings(key, myAsm)

    # Read the markers from the LOD files and define them in the Abaqus assembly as reference points
    refPointRef = readAndDefineMarkers(myAsm, lodFilePath)

    # Get the nodes inside the bounding box of the part which is connected to the current part
    (refPntOtherComp,
     sortedOtherComp) = getBoundingNodes(asminfo, key, instRef, myModel, myAsm)

    # Define MPCs between the reference points (markers) and the corresponding surfaces on the part
    defineMPCs(sortedOtherComp, refPntOtherComp, refPointRef, instRef, myAsm,
               myModel, key)

    inpName = createINP(myAsm, key, myModel, parallelCores,
                        ramAllocated)  # Create an INP file of the current part

    # Clean the current model of the Abaqus/CAE from the previous part itself and its constraints
    cleanModel(myModel, myAsm)

    # Define the previously created INP file of the current part as the temporary INP file
    inpTempFileName = inpName + '.inp'
    # Define the location of the temporary INP file and store it
    inpTempFilePath = os.path.join(os.getcwd(), inpTempFileName)
    with open(inpTempFilePath, 'r') as inpTempFile:
        # Determine upto which point the temporary INP file needs to be merged with the final INP file
        stopLine = parseInpTemp(inpTempFile)
        with open(lodFilePath, 'r') as lodFile:
            # Determine from which point the LOD file generated by Adams needs to be merged with the final INP file
            startLine = parseLOD(lodFile)

    with open(inpTempFilePath, 'r') as inpTempFile:
        with open(lodFilePath, 'r') as lodFile:
            # Define the name of the final INP file by using the name of the current part
            inpFileName = key + '.inp'
            # Define the location of the final INP file and store it
            inpFilePath = os.path.join(os.getcwd(), inpFileName)
            # Create the final INP file by opening and closing it
            open(inpFilePath, 'a').close()
            # Merge temporary INP file and LOD file to create the final INP file
            createFinalInp(inpFilePath, inpTempFile, lodFile, stopLine,
                           startLine)
    os.remove(inpTempFilePath)
コード例 #2
0
ファイル: AbaqusCAE_ADAMS.py プロジェクト: dyao-vu/meta-core
def ADAMS_setup_INP(myAsm, key, asminfo, instRef, instAssemblyRef,
                    myModel, parallelCores, ramAllocated):
    """ Manipulates Abaqus model to provide correctly formatted INP file. """
    try:
        lodFileID = instRef[key]['ComponentID']
    except KeyError:
        try:
            lodFileID = instAssemblyRef[key]['ComponentID']
        except KeyError:
            cad_library.exitwitherror('LOD file not found for ' + str(key), -1, 'AbaqusCAE_ADAMS.py')
    lodFileName = 'LT_' + lodFileID + '.lod'
    lodFilePath = os.path.join(os.getcwd(), lodFileName)

    # Constrain every vertice of the part in x, y and z directions with soft-springs
    constrainWithSoftSprings(key, myAsm)

    # Read the markers from the LOD files and define them in the Abaqus assembly as reference points
    refPointRef = readAndDefineMarkers(myAsm, lodFilePath)

    # Get the nodes inside the bounding box of the part which is connected to the current part
    (refPntOtherComp, sortedOtherComp) = getBoundingNodes(asminfo, key,
                                                          instRef, myModel, myAsm)

    # Define MPCs between the reference points (markers) and the corresponding surfaces on the part
    defineMPCs(sortedOtherComp, refPntOtherComp, refPointRef,
               instRef, myAsm, myModel, key)

    inpName = createINP(myAsm, key, myModel, parallelCores, ramAllocated)   # Create an INP file of the current part

    # Clean the current model of the Abaqus/CAE from the previous part itself and its constraints
    cleanModel(myModel, myAsm)

    # Define the previously created INP file of the current part as the temporary INP file
    inpTempFileName = inpName + '.inp'
    # Define the location of the temporary INP file and store it
    inpTempFilePath = os.path.join(os.getcwd(), inpTempFileName)
    with open(inpTempFilePath, 'r') as inpTempFile:
        # Determine upto which point the temporary INP file needs to be merged with the final INP file
        stopLine = parseInpTemp(inpTempFile)
        with open(lodFilePath, 'r') as lodFile:
            # Determine from which point the LOD file generated by Adams needs to be merged with the final INP file
            startLine = parseLOD(lodFile)

    with open(inpTempFilePath, 'r') as inpTempFile:
        with open(lodFilePath, 'r') as lodFile:
            # Define the name of the final INP file by using the name of the current part
            inpFileName = key + '.inp'
            # Define the location of the final INP file and store it
            inpFilePath = os.path.join(os.getcwd(), inpFileName)
            # Create the final INP file by opening and closing it
            open(inpFilePath, 'a').close()
            # Merge temporary INP file and LOD file to create the final INP file
            createFinalInp(inpFilePath, inpTempFile, lodFile, stopLine, startLine)
    os.remove(inpTempFilePath) 
コード例 #3
0
ファイル: AbaqusCAE_ADAMS.py プロジェクト: dyao-vu/meta-core
def ADAMS_setup_INP(myAsm,key,jointsMBDXML,instRef,myModel,parallelCores,ramAllocated):
    logger = logging.getLogger()
    constrainWithSoftSprings(key, myAsm)                                                            # Constrain every vertice of the part in x, y and z directions with soft-springs
    refPointRef = readAndDefineMarkers(key, os.getcwd(), myAsm)                                            # Read the markers from the LOD files and define them in the Abaqus assembly as reference points

    (refPntOtherComp, sortedOtherComp) = getBoundingNodes(jointsMBDXML,
        key, instRef,myModel, myAsm)                                                                # Get the nodes inside the bounding box of the part which is connected to the current part

    defineMPCs(sortedOtherComp, refPntOtherComp, refPointRef,
        instRef, myAsm, myModel, key)                                                               # Define MPCs between the reference points (markers) and the corresponding surfaces on the part

    inpName = createINP(myAsm, key, myModel, parallelCores, ramAllocated)                      # Create an INP file of the current part

    cleanModel(myModel, myAsm)                                                                      # Clean the current model of the Abaqus/CAE from the previous part itself and its constraints
                                                           
    inpTempFileName = inpName + '.inp'                                                              # Define the previously created INP file of the current part as the temporary INP file
    inpTempFilePath = os.path.join(os.getcwd(), inpTempFileName)                                           # Define the location of the temporary INP file and store it
    inpTempFile = open(inpTempFilePath, 'r')                                                        # Open the temporary INP file

    stopLine = parseInpTemp(inpTempFile)                                                            # Determine upto which point the temporary INP file needs to be merged with the final INP file
 
    if '_ASM__Z' in key:
        lodFileName = 'LT_' + key.rsplit('_ASM__Z',1)[0] + '.lod'
    else:
        lodFileName = 'LT_' + key.rsplit('__',1)[0] + '.lod'                                            # Define the name of the LOD file by using the name of the current part
    lodFilePath = os.path.join(os.getcwd(), lodFileName)                                                   # Define the location of the LOD file and store it
    lodFile = open(lodFilePath, 'r')                                                                # Open the LOD file

    startLine = parseLOD(lodFile)                                                                   # Determine from which point the LOD file generated by Adams needs...
                                                                                                    # ...to be merged with the final INP file
    inpTempFile.close()                                                                             # Close the temporary INP file (essential)
    lodFile.close()                                                                                 # Close the LOD file (essential)
    
    inpTempFile = open(inpTempFilePath, 'r')                                                        # Open the temporary INP file again (essential)
    lodFile = open(lodFilePath, 'r')                                                                # Open the LOD file again (essential)
    
    inpFileName = key + '.inp'                                                                      # Define the name of the final INP file by using the name of the current part
    inpFilePath = os.path.join(os.getcwd(), inpFileName)                                                   # Define the location of the final INP file and store it
    open(inpFilePath, 'a').close()                                                                  # Create the final INP file by opening and closing it

    inpFile = createFinalInp(inpFilePath, inpTempFile, lodFile, stopLine,
        startLine)                                                                                  # Merge temporary INP file and LOD file to create the final INP file
               
    inpFile.close()                                                                                 # Close the final INP file
    inpTempFile.close()                                                                             # Close the temporary INP file

    os.remove(inpTempFilePath) 
コード例 #4
0
def ADAMS_setup_INP(myAsm,key,jointsMBDXML,instRef, instAssemblyRef,
                    myModel,parallelCores,ramAllocated):
    logger = logging.getLogger()
    try:
        lodFileID = instRef[key]['ComponentID']
    except KeyError:
        try:
            lodFileID = instAssemblyRef[key]['ComponentID']
        except KeyError:
            logger.error('LOD file not found for ' + str(key))
            raise Exception('LOD file not found. Please check log.')
    lodFileName = 'LT_' + lodFileID + '.lod'
    lodFilePath = os.path.join(os.getcwd(), lodFileName)
    
    constrainWithSoftSprings(key, myAsm)                                                            # Constrain every vertice of the part in x, y and z directions with soft-springs
    refPointRef = readAndDefineMarkers(key, os.getcwd(), myAsm, lodFilePath)                                            # Read the markers from the LOD files and define them in the Abaqus assembly as reference points
       
    (refPntOtherComp, sortedOtherComp) = getBoundingNodes(jointsMBDXML,
        key, instRef,myModel, myAsm)                                                                # Get the nodes inside the bounding box of the part which is connected to the current part

    defineMPCs(sortedOtherComp, refPntOtherComp, refPointRef,
        instRef, myAsm, myModel, key)                                                               # Define MPCs between the reference points (markers) and the corresponding surfaces on the part

    inpName = createINP(myAsm, key, myModel, parallelCores, ramAllocated)                      # Create an INP file of the current part

    cleanModel(myModel, myAsm)                                                                      # Clean the current model of the Abaqus/CAE from the previous part itself and its constraints
                                                           
    inpTempFileName = inpName + '.inp'                                                              # Define the previously created INP file of the current part as the temporary INP file
    inpTempFilePath = os.path.join(os.getcwd(), inpTempFileName)                                           # Define the location of the temporary INP file and store it
    with open(inpTempFilePath, 'r') as inpTempFile:
        stopLine = parseInpTemp(inpTempFile)                                                            # Determine upto which point the temporary INP file needs to be merged with the final INP file
        with open(lodFilePath, 'r') as lodFile:
            startLine = parseLOD(lodFile)                                                                   # Determine from which point the LOD file generated by Adams needs...
                                                                                                        # ...to be merged with the final INP file
    with open(inpTempFilePath, 'r') as inpTempFile:
        with open(lodFilePath, 'r') as lodFile:
            inpFileName = key + '.inp'                                                                      # Define the name of the final INP file by using the name of the current part
            inpFilePath = os.path.join(os.getcwd(), inpFileName)                                                   # Define the location of the final INP file and store it
            open(inpFilePath, 'a').close()                                                                  # Create the final INP file by opening and closing it

            createFinalInp(inpFilePath, inpTempFile, lodFile, stopLine,
                            startLine)                                                                                  # Merge temporary INP file and LOD file to create the final INP file

    os.remove(inpTempFilePath)