Search code examples
pythontemperatureabaqus

Abaqus python script that will convert temperature in my .txt file


I have a python script that extracts the temperature from my odb file however I want it to convert the temperature output from degrees F to degrees C. We input everything as english units put then our customers want things in the degrees C. How can I modify the following script to automatically convert my output to degrees C?

from odbAccess import *
import sys

# Open output file for writing
outputFile = open('OutputFileName.txt','w')

# Define odb file names
odbNameList = ('JobName.odb',)

# Define instance name and set name
instanceNameList = ('INSTANCE-1','INSTANCE-2',)
setName = 'SET-1'

# Process odb files
for odbName in odbNameList:

# Open file for reading
    odb = openOdb(path=odbName)

# Process steps
    for stepName in odb.steps.keys():

# Get field output objects for variables TEMPERATURE and ELEMENT VOLUME
        temperatureField = odb.steps[stepName].frames[-1].fieldOutputs['NT11']
        for instanceName in instanceNameList:               
            setData = odb.rootAssembly.instances[instanceName].nodeSets[setName]

            tempField = temperatureField.getSubset(region=setData, position=NODAL)
            tempValues = tempField.values

            tmax = 0
            for v in tempValues:
                if v.data > tmax:
                    tmax = v.data

            outputFile.write('%s %s %s %6.3f\n' % (odbName, stepName, instanceName, tmax))

# Close odb file
    odb.close()

# Close output file
outputFile.close()

Solution

  • In the code, simply identify which variable represents the temperature in Fahrenheit. That value is tmax. Converting that value to Celsius requires a simple calculation as demonstrated below.

    if v.data > tmax:
        tmax = v.data
        tmax_celsius = (tmax-32)/1.8