- 积分
- 0
- 注册时间
- 2014-3-3
- 仿真币
-
- 最后登录
- 1970-1-1
|
各位坛友,这是我在用户手册上找到的用python写代码来引入初始缺陷,但是却不知道怎么用?而且我将其复制到abaqus运行环境下,产生了语法错误!SystemError: raw_input() may not be called from Abaqus/CAE CLI。这就是产生的错误,新手刚用,搞得头疼,希望大家能帮个忙,讲解讲解
import sys
from odbAccess import *
from types import IntType
# Get input from the user
odbName = raw_input('Enter odb name (w/o .odb): ')
modes = eval(raw_input('Enter mode shape(s): ')) #这个mode shape(s)是什么?是输入我想要的模态数目还是我想要的模态对应的关键字?
if type(modes) is IntType:
modes = (modes,)
odb = openOdb(odbName + '.odb')
# Get the undeformed coordinates from the first
# step and frame
step = odb.steps.values()[0]
try:
coords = step.frames[0].fieldOutputs['COORD'] # 这个 frame 是什么?对应模型中的什么?
except:
err = "The analysis must include a field output request \
for variable COORD."
print err
sys.exit(1)
# Perturb the nodal coordinates
factors = []
for mode in modes:
try:
frame = step.frames[mode]
except IndexError:
print 'Input error: mode %s does not exist' % mode
sys.exit(1)
factors.append(float(raw_input(
'Enter imperfection factor for mode %s: '% mode))) #为什么是在这个地方添加factors。这个地方想法太混乱,(没制动step,frame 和mode的区别,不知道怎么表达!
coords = coords + factors[-1] * frame.fieldOutputs['U']
# Write new nodal coordinates to a file
outFile = open(odbName + '_perturbed.inp', 'w')
header = \
"""
*******************************************************
** Node data for perturbed mesh.
** Input mesh from: %s
** Mode shapes used: %s
** Imperfection factors used: %s
*******************************************************
"""
outFile.write(header % (odbName, modes, factors))
format = '%6i, %14.7e, %14.7e, %14.7e\n'
for value in coords.values:
outFile.write(
format % ((value.nodeLabel,) + tuple(value.data)))
outFile.write('** End of perturbed mesh node input file.')
outFile.close()
|
|