我想在ABAQUS中创建一个自定义字段输出。为了证明概念,我想显示从莫尔斯圆计算的最大剪应力,如讨论的二维壳体的here。在
我有以下代码供参考:
from abaqusConstants import *
from odbAccess import *
from math import *
from copy import deepcopy
from caeModules import *
from driverUtils import executeOnCaeStartup
# ******************************************************************************
#Items in this box require student input when changing files
#must input the file path here.
odbPath = "/home/MohrsTest.odb"
odb = session.openOdb(name=odbPath, readOnly=FALSE)
odb = session.odbs[odbPath]
#this will display the instance names. Please choose one to input in line 14.
print odb.rootAssembly.instances.keys()
grout_instance = odb.rootAssembly.instances['SQUARE-1']
# ******************************************************************************
keys = odb.steps.keys()
for key in keys:
step = odb.steps[key]
for frame in step.frames:
print frame.description
Stress = frame.fieldOutputs['S']
#try modifying scalar fields rather than creating new var element by element.
S11=Stress.getScalarField(componentLabel="S11")
S22=Stress.getScalarField(componentLabel="S22")
S12=Stress.getScalarField(componentLabel="S12")
TauMax=((S11+S22)*0.5+sqrt(power((S11-S22)/2, 2)+power(S12, 2)))-((S11+S22)*0.5-sqrt(power((S11-S22)/2, 2)+power(S12, 2)))/2
ThetaP=(atan2(2 * S12, (S11 - S22))/2) * 180/pi
frame.FieldOutput(name='Tau Max', description='Max Tau from Mohrs circle',field=TauMax)
frame.FieldOutput(name='Theta P', description='Thetap as measured ccw from 0 degree',field=Thetap)
odb.save()
odb.close()
# must re - open the output database to see the new custom field output
Abaqus在试图计算TauMax时立即抛出一个错误,因为“类型错误:需要浮点运算”。但是,我尝试使用“工具->字段输出->从字段创建”,然后在cae中为单个帧创建一个字段输出。 如果查看此操作的回放文件,可以看到以下代码:
^{pr2}$因此,显然,FieldObject上的数学运算必须是可能的。为什么我的代码不允许这样做?在
我很高兴提供所有.odb和.cae文件以供参考和验证。在
我很确定本机
Abaqus/CAE
脚本使用numpy
作为数学函数。但是numpy.sqrt
会被math.sqrt
覆盖from math import *
。math.sqrt
无法处理.getScalarField()
生成的numpy
数组,因此出现错误。在相关问题 更多 >
编程相关推荐