How to upgrade old ODB files in Abaqus

Watch out when installing a brand new Abaqus release! 

 

You will have to upgrade all the ODBs obtained from your previous Abaqus version to open them again. I know this sounds annoying, but it’s not that bad. Let me show you how to upgrade your old ODB files in Abaqus manually and also using Python.

1. Manual upgrade of ODB files

If we try to open an ODB from Abaqus CAE (e.g. Abaqus 2023) and this ODB file was obtained from a previous Abaqus release (e.g. Abaqus 2019), Abaqus won’t be able to open it as it is. Instead, a warning message will be raised to let us that the ODB needs to be updated, by accepting, Abaqus will update it on the fly.

 

From now on, we can open that ODB with that Abaqus version.

 

This method is fine if we don’t have many ODB files or if these files are not too big (more than a few GB). Otherwise, this is extremely time consuming and tedious to do one by one.

2. Upgrading ODB files with Python

We are working with Abaqus, therefore there must be a solution using Python, right?

Absolutely! Abaqus provides a Python function to upgrade outdated ODB files: session.upgradeOdb

				
					# Import Abaqus modules
from abaqus import *
from abaqusConstants import *
from caeModules import *

# Path of the original ODB (existing)
odbPath = r'D:/myproject/mysimulation.odb'

# Path of the new ODB (upgraded)
newOdbPath = r'D:/myproject/mysimulation_new.odb'

# Upgrade ODB in Abaqus
session.upgradeOdb(existingOdbPath=odbPath,
                   upgradedOdbPath=newOdbPath)
                   
				
			

This is great! We can take advantage of this function to upgrade any ODB files automatically.

3. Automating the upgrade of ODB files

Let’s say that we want to upgrade all the ODB files inside our project folder. We can divide this great task into 4 small tasks:

 

  1. Traverse a folder and all its subfolders recursively.
  2. Find all the ODB files in the current folder (or subfolder).
  3. Identify which of these ODBs needs to be upgraded.
  4. Upgrade the ODB (using the upgradeOdb function).

3.1. Walk through folders and subfolders with Python

The function ‘walk‘ inside the module ‘os‘, enables traversing all the contents inside a folder recursively. The only input required for this purpose is a starting point, a parent folder like:

 

os.walk(r”D:/myproject”)

The snippet below shows how to apply this function for our purpose (don’t forget to import os):

				
					# Import Abaqus modules
from abaqus import *
from abaqusConstants import *
from caeModules import *
import os

parentDirectory = r'D:/myproject'

# 1) Traverse all folders/subfolders from parentDirectory
for curDirectory, folders, files in os.walk(parentDirectory):
    # curDirectory: current directory (string)
    # folders: folders in this directory (list of strings)
    # files: files in this directory (list of strings)

    print('\n*** Reading directory: ' + curDirectory)
                   
				
			

Thanks to os.walk the rest of the tasks become a lot easier.

3.2. Find all the ODB files in the current directory

We can use a ‘for’ loop to iterate through the list of file names (files) in the current directory and select only those with their name ending with “.odb“. An efficient implementation in Python is to use a list comprehension.

				
					# 2) Find the ODB files inside the current directory
odbs = [f for f in files if f.endswith('.odb')]
                   
				
			

3.3. Which ODB files need an upgrade?

Abaqus provides a specific function that lets us know if an ODB needs to be upgraded or not (‘session.isUpgradeRequiredForOdb‘). We can apply this function to each of the ODB files in the current directory (odbs) using a for loop.

				
					# Iterate through the odbs in the current directory (curDirectory)
for odb in odbs:

    odbPath = join(curDirectory, odb)

    # 3) Check if upgrade is required
    if session.isUpgradeRequiredForOdb(odbPath):
       ...

                   
				
			

The function isUpgradeRequiredForOdb takes the path of an ODB and returns a boolean. If True, the ODB needs to be upgraded, and that’s what we’ll do next.

3.4. Upgrade the ODB file

Once we know that an ODB file must be upgraded, let’s use the upgradeOdb function:

				
					# Iterate through the odbs in the current directory (curDirectory)
for odb in odbs:

    odbPath = join(curDirectory, odb)

    # 3) Check if upgrade is required
    if session.isUpgradeRequiredForOdb(odbPath):
    
       newOdbPath = odbPath.replace('.odb', '_new.odb')

       # 3) Upgrade odb
       session.upgradeOdb(existingOdbPath=odbPath,
                          upgradedOdbPath=newOdbPath)

                   
				
			

The upgraded ODBs will end with the suffix “new”.

3.5. Putting it all together

The final script may look like the following:

				
					# Import Abaqus modules
from abaqus import *
from abaqusConstants import *
from caeModules import *
import os

# Replace with the directory containing the ODBs
parentDirectory = r'D:/myproject'

# 1) Traverse all folders/subfolders from parentDirectory
for curDirectory, folders, files in os.walk(parentDirectory):
    # curDirectory: current directory (string)
    # folders: folders in this directory (list of strings)
    # files: files in this directory (list of strings)

    print('\n*** Reading directory: ' + curDirectory)
    
    # 2) Find the ODB files inside the current directory
    odbs = [f for f in files if f.endswith('.odb')]
                   
    # Iterate through the odbs in current directory (curDirectory)
    for odb in odbs:
    
        odbPath = join(curDirectory, odb)
    
        # 3) Check if upgrade is required
        if session.isUpgradeRequiredForOdb(odbPath):
        
            # Upgraded odbs end with "_new"
            newOdbPath = odbPath.replace('.odb', '_new.odb')
    
            # 4) Upgrade odb
            session.upgradeOdb(existingOdbPath=odbPath,
                               upgradedOdbPath=newOdbPath)
                              
            print('Upgraded: ' + odbPath)
    
                       
				
			

4. My ODB upgrader

I have added a few more details to the final Python script to upgrade ODB files and provide some more flexibility:

  • The script prints out some more information like the ODB size and the number of files upgraded in each directory.
  • The script skips unreadable ODBs (corrupted, protected files…).
  • Upgraded ODBs are renamed including the new Abaqus version (e.g. _23.odb).
  • Optional: Run in test mode. The script will print out all the ODBs that need an upgrade, but won’t take the time to upgrade them (recommended before massive upgrading)
  • Optional: Delete old ODBs after upgrading. If we guarantee that we don’t need the old ODB files anymore, go for it, but give it a run in test mode before (there is no undo after this…)

You can download the Python script (ODB upgrader) here.

5. Conclusion

Upgrading ODBs from previous Abaqus releases may be a bit annoying if we have just updated Abaqus in the middle of a project, but thanks to Python this “problem” becomes another opportunity to find value in this outstanding tool.

 

Python is not only an excellent tool to preprocess and postprocess our finite element models in Abaqus, but also for any other tasks that we want to automate. This time, we used a Python function from the Abaqus API, but we can also take advantage of it to deal with files, folders, etc.

 

By the way, if you want to learn how to start using Python inside Abaqus, I recommend you check out this other post.

Leave a Comment

Scroll to Top