我得到IndexError: -1
的Abaqus中止腳本命令提示符 - IndexError:-1
我試圖運行在命令提示符下Python腳本錯誤。當我通過Abaqus CAE運行它時,它可以工作。當我嘗試使用沒有GUI的命令提示符運行時,我得到錯誤。
我能夠完成這項工作,但我的腳本也打開了輸出數據庫。在這一步出現錯誤。
我試過Google搜索它,但我沒有得到任何更聰明。這在Python中通常意味着什麼?爲什麼我的腳本在abaqus中工作,但只通過命令提示符的一半?
謝謝!
from time import gmtime, strftime
import time, os
from abaqus import *
from part import *
from material import *
from section import *
from assembly import *
from step import *
from interaction import *
from load import *
from mesh import *
from job import *
from sketch import *
from visualization import *
from connectorBehavior import *
from odbAccess import *
mdb = openMdb(pathName='X:\MinPreload-VaryingBC')
modelName = 'minPreload'
cMdb = mdb.models[modelName]
date = strftime("%Y-%d-%b", gmtime())
logPath_bu = 'C:\Users\yyt\maxMin-%s.txt' %date
logObj_bu = open(logPath_bu, 'a')
TopOfThePage = 'JobName\tCFNM at Preload\tTime Finished\tPreload\n\n'
logObj_bu.write(TopOfThePage)
logObj_bu.close()
output = open('C:\yyt\Output-%s.txt' %date, 'a')
output.write('Job \t\t\t'+'PS723\t\t'+'PS721\t\t'+'PL\t\t'+'FRIC\n\n')
output.close()
jobName = ""
maxCf = 0.0
#Temperature
minTemp = -49
maxTemp = 101
temperature = [minTemp, maxTemp]
bcTemp = 'Temperature'
#Friction
friction = [0.1, 0.1, 0.2, 0.2, 0.3, 0,3, 0.4, 0,4, 0.5, 0.5]
interactionProperty = 'Contact Seal Coupler'
#PressureSwitcher
Pressure = True
internalPressure = 76
cMdb.loads['IP'].resume('Pressure')
internalPressBC = cMdb.loads['IP']
setInternalPressureBC = internalPressBC.setValues(magnitude=internalPressure)
externalPressure = 33
cMdb.loads['ExtP'].resume('Pressure')
externalPressBC = cMdb.loads['ExtP']
setExternalPressureBC = externalPressBC.setValues(magnitude=externalPressure)
# Preload
adjustedPreload = 0
PLipht = 10
PLiplt = 10
PLextpht = 10
PLextplt = 10
for temp in temperature:
output = open('C:\yyt\Output-%s.txt' %date, 'a')
output.write('\n')
output.close()
tempBC = cMdb.boundaryConditions[bcTemp]
setTemp = tempBC.setValues(magnitude=temp)
if temp == minTemp:
adjustedPreload = 0.10315
else:
adjustedPreload = -0.21288
for fric in friction:
tangProp = cMdb.interactionProperties[interactionProperty].tangentialBehavior
tangProp.setValues(table=((fric,),))
if Pressure:
cMdb.loads['IP'].resume('Pressure')
cMdb.loads['ExtP'].suppress('Pressure')
press = 'IP'
else:
cMdb.loads['ExtP'].resume('Pressure')
cMdb.loads['IP'].suppress('Pressure')
press = 'ExtP'
if temp == maxTemp and Pressure:
PLi = PLipht
elif temp == minTemp and Pressure:
PLi = PLiplt
elif temp == maxTemp and Pressure:
PLi = PLextpht
elif temp == minTemp and Pressure:
PLi = PLextplt
for PL in range (PLi, 100):
axPL = float(PL)/100
preloadBC = cMdb.boundaryConditions['axial_move']
setPreloadBC = preloadBC.setValuesInStep('Pre', u2=axPL)
clampBC = cMdb.boundaryConditions['clamp']
modifyBottomCoupler = clampBC.setValuesInStep('Temp', -adjustedPreload)
setPreloadBC = preloadBC.setValuesInStep('Temp', u2=(axPL+adjustedPreload))
#Create a job
fricInt = fric*10
jobName = date + '_%dC-0_%df-%s-0_%dPLl' %(temp, fricInt, press, PL)
mdb.Job(model=modelName, name=jobName)
#submit Job
mdb.jobs[jobName].submit(consistencyChecking=OFF)
#Wait for job to complete
status = str(mdb.jobs[jobName].messages[-1].type)
mdb.jobs[jobName].waitForCompletion()
#Collect data from job
lastStepName = 'Pressure'
odb = session.openOdb(name=jobName+'.odb')
region = odb.steps[lastStepName].historyRegions['NodeSet Z000002']
region2 = odb.steps[lastStepName].historyRegions['NodeSet Z000001']
CFNM1 = region.historyOutputs['CFNM ASSEMBLY_SLAVEBOT/ASSEMBLY_MASTERBOT'].data
CFNM2 = region2.historyOutputs['CFNM ASSEMBLY_SLAVESURFTOP/ASSEMBLY_MASTERTOP'].data
for i, var in enumerate(CFNM1):
if i == len(CFNM1) - 1:
maxCf1 = var[-1]
print str(maxCf1) + 'CFNM1 724/723'
for i, var in enumerate(CFNM2):
if i == len(CFNM2) - 1:
maxCf2 = var[-1]
print str(maxCf2) + 'CFNM2 722/721'
output = open('C:\yyt\Output-%s.txt' %date, 'a')
output.write(jobName+'\t\t'+str(maxCf1)+'\t\t'+str(maxCf2)+'\t\t'+'0.'+str(PL)+'\t\t'+str(fric)+'\n')
output.close()
if maxCf1 >= 10000 and maxCf2 >= 10000:
time_done = strftime("%H:%M:%S", gmtime())
logObj_bu = open(logPath_bu, 'a')
logObj_bu.write(jobName+'\t'+' CFNM1 = ' + str(maxCf1)+' CFNM2 = ' + str(maxCf2)+'\t' + time_done + '%d\n\n' %PL)
logObj_bu.close()
Pressure = not Pressure
if temp == maxTemp and Pressure:
PLipht = axPL-0.02
elif temp == minTemp and Pressure:
PLiplt = axPL-0.02
elif temp == maxTemp and Pressure:
PLextpht = axPL-0.02
elif temp == minTemp and Pressure:
PLextplt = axPL-0.02
break
我得到
End Abaqus/Standard Analysis
Abaqus JOB 2014-06-Mar_-49C-0_1f-IP-0_10PLl COMPLETED
IndexError: -1
Abaqus Error: cae exited with an error.
http://docs.python.org/2/library/exceptions.html#exceptions.IndexError –
當您不顯示任何代碼或追蹤消息時,很難提供幫助。 – jcfollower
@jcfollower嗨!我現在添加了代碼。我不太清楚問題出在哪裏,所以我補充了一切。 – tore