Abaqus python脚本将转换我的.txt文件中的温度

时间:2015-10-26 17:24:57

标签: python temperature abaqus

我有一个python脚本从我的odb文件中提取温度但是我希望它将温度输出从F度转换为C度。我们输入所有内容作为英语单位然后我们的客户想要的东西在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()

2 个答案:

答案 0 :(得分:0)

在代码中,只需识别哪个变量代表华氏温度。该值为tmax。将该值转换为摄氏温度需要进行简单的计算,如下所示。

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

答案 1 :(得分:0)

好像你正在写每个实例的最高温度。您只需在找到它之后就可以使用tmax

要将Farenheit转换为Celsius,请使用以下公式:

C = (F-32)*(5/9)

所以:

def Celsius(F):
    C = (F-32)*(5/9)
    return C

 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 Celsius(v.data) > tmax:
            tmax = v.data

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