我有一个python脚本,它从odb文件中提取温度,但是我希望它将温度输出从华氏度转换为摄氏度。我们输入的所有东西都是英语单位,然后我们的客户想要的是摄氏度。我如何修改以下脚本以自动将输出转换为摄氏度?在
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()
看起来你写的只是每个实例的最高温度。您只需在找到
tmax
后再进行操作。在要将Farenheit转换为摄氏度,请使用以下公式:
所以:
^{pr2}$在代码中,只需确定哪个变量代表华氏温度。这个值是
tmax
。将该值转换为摄氏度需要进行如下所示的简单计算。在相关问题 更多 >
编程相关推荐