给出一个包含节点集的Abaqus odb文件(例如'ALL_SECS')。
可以通过以下模式在节点集的节点上提取坐标('COORD')或位移('U')之类的NODAL量:
如何在节点集的节点处提取/内插INTEGRATION_POINT数量?如何使用abaqus-python请求NODAL位置的fieldoutput?
from odbAccess import *
import numpy as np
# Helper function
def values_to_array(values, dim=2, item='data'):
length = len(values)
array = np.zeros((length, dim), dtype='float64')
for index in range(length):
array[index, :] = getattr(values[index], item)
return array
# Prepare and open
odb = openOdb(path='job.odb') # Solution of 2D-plane-stress model
instances = odb.rootAssembly.instances
instance = instances['PART']
sett = instance.nodeSets['ALL_SECS']
step = odb.steps.keys()[-1]
# Get coordinates and number of nodes in node set
frame = odb.steps[step].frames[-1]
values_xy = frame.fieldOutputs['COORD'].getSubset(region=sett).values
xy = values_to_array(values=values_xy, dim=2, item='dataDouble')
nbr_xy = len(values_xy)
print('len(values_xy)')
print(len(values_xy))
# Get nodal-quantity and number of nodes in node set
uvw = np.zeros((nbr_xy, 2), dtype=float)
outp = odb.steps[step].frames[-1].fieldOutputs['U']
values_u = outp.getSubset(region=sett).values
uvw = values_to_array(values=values_u, dim=2, item='dataDouble')
print('len(values_u)')
print(len(values_u))
eps = np.zeros((nbr_xy, 4), dtype=float)
outp = odb.steps[step].frames[-1].fieldOutputs['E']
values_eps = outp.getSubset(position=ELEMENT_NODAL, region=sett).values
# values_eps = outp.getSubset(position=ELEMENT_NODAL).getSubset(region=sett).values
print('len(values_eps)')
print(len(values_eps))
values_eps_nodal = outp.getSubset(position=NODAL, region=sett).values
print('len(values_eps_nodal)')
print(len(values_eps_nodal))
输出:
len(values_xy)
147
len(values_u)
147
len(values_eps)
408
len(values_eps_nodal)
0
eps
中的第i个应变是xy
中的第i个坐标处的应变。Abaqus API中似乎不存在此功能。特定于节点的数据(例如位移)可以轻松提取,请参见uv
。在单元节点和位置提取应变数据的关键步骤:nodeLabel
-> index
from odbAccess import *
import numpy as np
import pickle
from operator import attrgetter
def values_to_array(values, dim=2, item='data', dtype=np.float64):
'''Thanks to https://stackoverflow.com/a/46925902/8935243'''
array = np.array(
map(attrgetter(item), values),
dtype=dtype,
)
return array
def values_to_index_mapping(values, item='nodeLabel', check=True):
node_labels = values_to_array(values, dim=1, item=item, dtype=np.int64)
if check:
assert len(set(node_labels)) == len(node_labels)
mapping = {}
for index, label in enumerate(node_labels):
mapping[label] = index
return mapping
odb = openOdb(path='job.odb')
instances = odb.rootAssembly.instances
instance = instances['PART']
sett = instance.nodeSets['ALL_SECS']
step = odb.steps.keys()[-1]
# Coordinates
frame = odb.steps[step].frames[-1]
values = frame.fieldOutputs['COORD'].getSubset(region=sett).values
xy = values_to_array(values=values, dim=2, item='data')
# Dimensions
nbr_xy = len(values)
# Mapping: nodeLabel -> index
index_map = values_to_index_mapping(values=values, check=True)
# Displacements
uv = np.zeros((nbr_xy, 2), dtype=float)
outp = odb.steps[step].frames[-1].fieldOutputs['U']
values = outp.getSubset(region=sett).values
uv[:, :] = values_to_array(values=values, dim=2, item='data')
# Strains
eps = np.zeros((nbr_xy, 4), dtype=float)
tmp = np.zeros((nbr_xy, 1), dtype=float)
values_eps = odb.steps[step].frames[-1].fieldOutputs['E'].getSubset(
position=ELEMENT_NODAL,
region=sett,
).values
# Moving average, as ELEMENT_NODAL does no averaging
# and returns multiple values for nodes in sett
for ee in values_eps:
index = index_map[ee.nodeLabel]
tmp[index] += 1
eps[index] = (eps[index] * (tmp[index] - 1) + ee.data) / tmp[index]
odb.close()