首页 > 解决方案 > 在节点集中指定的节点处提取应变 [Abaqus python odb 访问]

问题描述

给定一个包含节点集的 Abaqus odb 文件(例如,'ALL_SECS')。

可以在通过以下模式设置的节点的节点处提取诸如坐标 ('COORD') 或位移 ('U') 之类的 NODAL 量:

如何在节点集的节点处提取/插值 INTEGRATION_POINT 数量?如何使用 abaqus-python 请求 NODAL 位置的字段输出?

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

标签: pythonabaqus

解决方案


以下解决方案是在节点集“ALL_SECS”中指定的节点处获得总应变(场输出“E”)的解决方法。由于提取节点的顺序未知,因此也提取位置信息,即节点的坐标。中的第 i 个应变eps是 中第 i 个坐标处的应变xy。Abaqus API 中似乎不存在此功能。节点特定的数据,如位移,可以很容易地提取出来,见uv。在单元节点和位置提取应变数据的关键步骤:

  • 识别坐标
  • 识别映射nodeLabel->index
  • 结合节点处的值,使用移动平均值从不同元素推断。(解释见链接

注:二维模型odb


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()


推荐阅读