我有以下代码:
from abaqus import *
from odbAccess import *
from abaqusConstants import *
import visualization
import fileinput
import os
import shutil
import numpy as np
from odbAccess import *
def tupled_list(mylist,n):
'''group every n elements of the list into a tuple '''
return list(zip(*[iter(mylist)]*n))
# Open odb
odb_filename = 'AbaqusResults.odb'
work_directory=os.getcwd()
odb_filepath = os.path.abspath(os.path.join(os.getcwd(),'..','outputs',odb_filename))
my_odb=session.openOdb(name=odb_filepath,readOnly=FALSE)
# Automate the proces of reading the step no matter what its name is
StepNames=(my_odb.steps.keys() )
lastStep=( StepNames[-1] )
# Automation of an instance naming (in the same way)
AllInstances = (my_odb.rootAssembly.instances.keys())
MyInstance = ( AllInstances[-1] )
SubmodelInstance=my_odb.rootAssembly.instances[MyInstance]
# Get dataset containing element labels and calculated quantities in here from text file
dataset = np.loadtxt(os.path.join(os.getcwd(),'AbaqusDataInput.txt'),delimiter=',')
# List of all element labels
elLabels = dataset[0,:].astype(int).tolist()
# Count the number of integration points for a single element
gausspoints = elLabels.count(1)
# Get damage data from dataset and format into a list of tuples, tuple length depends on number of integration points for eache element
damage = tupled_list(list(dataset[1,:]),gausspoints)
damage = [list(elem) for elem in damage]
# Remove duplicates from elLabel list
elLabels = list(set(elLabels))
for i in range(len(my_odb.steps[lastStep].frames)):
new_field_damage = my_odb.steps[lastStep].frames[i].FieldOutput(name='Damage',description='Damage sustained after one repitition of the loading history', type=SCALAR)
new_field_damage.addData(position=INTEGRATION_POINT, instance=SubmodelInstance, labels=elLabels, data=damage)
my_odb.save()
my_odb.close()
但出现以下错误:
Data at 141968 locations expected. Data at 17746 locations provided. Element data request failed. Element type is C3D20R. Data at 8 integration points per element expected
elLabels是包含17746个项目的列表, 损坏是一个包含17746个项目的元组列表,但每个项目都有8个值(每个积分点一个),例如[(x,x,x,x,x,x,x,x),(x,x,x,x,x,x,x,x),…]
因此,我为abaqus提供了17746个元素标签和17746 * 8个位置(按要求总共提供141968个数据点),所以我看不到为什么会出错。
我尝试了列表列表而不是元组列表,但是发生了相同的错误。我怀疑这只是使用正确的数据类型的问题,但Abaqus文档似乎严重缺乏。
该脚本适用于具有1个集成点的C3D8R元素的odb文件。然后,我提供相同的elLabels列表和损坏列表,但每个元组只有1个值(例如[[x,)(x,),…]),效果很好。
您知道我如何将数据导入元素集成点吗?
答案 0 :(得分:-1)
我想您可以先尝试确认Abaqus中的数据是否确实先存储在元素序列中,然后再存储在元素内的积分点序列。例如,对于S4R型,将S22的应力存储在所有元素的底面,然后存储在所有元素的顶面。也就是说,它们不是按元素1(底部,顶部),元素2(底部,顶部)的顺序排列。...元素n(底部顶部);而是:bottom(element1),bottom(element2)... bottom(element n),top(element1),top(element2).. top(element n)
尝试:
S22_ES = (o1.steps[LoadStep].frames[loadDir+1].fieldOutputs['S'].getScalarField(componentLabel="S22") .getSubset(region=Elset,position=INTEGRATION_POINT,))