在ABAQUS

时间:2017-07-01 22:30:27

标签: python scripting abaqus

我想在ABAQUS中创建自定义字段输出。出于概念证明的目的,我想显示从Mohrs圆计算出的最大剪切应力,如针对2D壳体所讨论的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时立即抛出错误,因为"类型错误:需要浮点数。"但是,我尝试使用"工具 - >场输出 - >从Fields"创建然后在单个框架的cae中创建一个字段输出。 如果我查看此操作的重播文件,我可以看到以下代码:

s1f1_S = session.odbs['/home/MohrsTest.odb'].steps['Step-1'].frames[1].fieldOutputs['S']
tmpField = (((s1f1_S.getScalarField(componentLabel="S11")+\
    s1f1_S.getScalarField(componentLabel="S22"))*0.5+sqrt(power((
    s1f1_S.getScalarField(componentLabel="S11")-s1f1_S.getScalarField(
    componentLabel="S22"))/2, 2)+power(s1f1_S.getScalarField(
    componentLabel="S12"), 2)))-((s1f1_S.getScalarField(componentLabel="S11")+\
    s1f1_S.getScalarField(componentLabel="S22"))*0.5-sqrt(power((
    s1f1_S.getScalarField(componentLabel="S11")-s1f1_S.getScalarField(
    componentLabel="S22"))/2, 2)+power(s1f1_S.getScalarField(
    componentLabel="S12"), 2))))/2

因此,显然必须可以对FieldObject进行数学运算。为什么我的代码不允许这样做?

我很乐意提供所有.odb和.cae文件以供参考和验证。

1 个答案:

答案 0 :(得分:0)

我很确定原生Abaqus/CAE脚本使用numpy来表示数学函数。但numpy.sqrt执行math.sqrt时,from math import *会覆盖math.sqrtnumpy无法处理由.getScalarField()生成的 var name = document.getElementById('name').value; name= "<span style='font-size:32px;'>"+name+"</span>"; snumber= "<span style='font-size:32px;'>"+snumber+"</span>"; var snumber = document.getElementById('snumber').value; document.write("name="+name+""); document.write("&snumber="+snumber+"<br />"); 数组,并且您收到错误。

相关问题