0
我想在ABAQUS中創建自定義字段輸出。爲了概念證明的目的,我想顯示從Mohrs圓圈計算出的最大剪切應力,如針對2D外殼所討論的here。在ABAQUS中爲自定義字段輸出創建腳本
我有我的代碼如下,僅供參考:
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中創建字段輸出。 如果我看重播文件這個動作,我可以看到下面的代碼:
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文件供參考和驗證。
這也是我的想法,但如果你看到我的第二個代碼塊,它就是這樣。 – User2341
是的,但運行導入'數學'的腳本? –
第二個代碼塊直接來自ABAQUS重放文件。我很樂意提供整個重放文件,但它不會導入任何不尋常的東西。它有從abaqus進口* ... – User2341