具有欧拉角的abaqus中的部分(或实例)旋转

时间:2018-03-17 21:53:32

标签: python abaqus

我试图用许多夹杂物(圆柱体)模拟复合材料。我需要用给定的欧拉角将圆柱旋转到合适的位置。但是我从abaqus documentation发现,abaqus中的实例只能按某个轴旋转。

所以我想知道在abaqus(或abaqus-python)中是否有一种通过欧拉角旋转实例的方法?

1 个答案:

答案 0 :(得分:2)

回答Abaqus v6.14

您可以使用CAE中的Abaqus Python命令执行此操作。

回想一下关于轴 x y z的对象的角度θ的一些旋转的变换矩阵

enter image description here

围绕某个任意轴 u 的旋转看起来像

enter image description here

欧拉角转换看起来像产品

enter image description here

或类似,取决于您是否遵循正确的欧拉角度约定或Tait-Bryan惯例。以上是Tait-Bryan序列,它使一个物体围绕 x 轴旋转角度γ,然后 y 轴旋转角度β ,然后 z 关于角度α的轴。

Abaqus旋转在CAE中通过命令ra.rotate(instanceList, axisPoint, axisDirection, angle)定义,其中

  • raassembly个对象(mdb.models[...].rootAssembly
  • instanceList是一个可迭代的*(元组,列表或类似的)字符串,指定要旋转的实例,
  • axisPoint是一个可迭代的浮点数,指定要围绕(x,y,z)旋转的轴的起点,
  • axisDirection是一个可迭代的浮点数,用于指定轴的方向,
  • angle是您希望旋转对象的(正逆时针)角度,以度

例如,如果我想在某个程序集'Part-1-MESH-1-1'下围绕一个带原点的轴( a )旋转名为**的实例和字符串ra b c )关于逆时针角度的方向( u v w t 度,我会运行命令

ra.rotate(instanceList=('PART-1-MESH-1-1', ), axisPoint=(a, b, c), axisDirection=(u, v, w), angle=t)

这意味着在CAE中,欧拉角转换可以在3 rotate个命令中顺序完成。

您的脚本(包括帮助函数)应如下所示:

"""
Assumes a Right-handed coordinate system.
"""

import numpy as np


def _Ru(t, u):
    return np.array([[np.cos(t) + (u[0]**2)*(1 - np.cos(t)), u[0]*u[1]*(1 - np.cos(t)) - u[2]*np.sin(t), u[0]*u[2]*(1 - np.cos(t)) + u[1]*np.sin(t)],
                     [u[1]*u[0]*(1 - np.cos(t)) + u[2]*np.sin(t), np.cos(t) + (u[1]**2)*(1 - np.cos(t)), u[1]*u[2]*(1 - np.cos(t)) - u[0]*np.sin(t)],
                     [u[2]*u[0]*(1 - np.cos(t)) - u[1]*np.sin(t), u[2]*u[1]*(1 - np.cos(t)) + u[0]*np.sin(t), np.cos(t) + (u[2]**2)*(1 - np.cos(t))]])

def general_rotation(axis_order, angles, axes_dir=((1.0,0.0,0.0),(0.0,1.0,0.0))):
    """
    Inputs:
        axis_order - Iterable of ints specifying the axis order to apply the transformation.
                     For example, (0,1,2) means to apply the rotations around the (x,y,z) axes, in that order.
        angles     - Iterable of angles (in degrees) specifying the rotations. This should be the same length as axis_order.
        axes_dir   - Iterable of iterable of floats, specifying two orthogonal directions forming the local x and y axes, respectively. Defaults to global x and y axes.
    """

    # Convert all angles to radians
    angles = np.deg2rad(angles)

    # Calculate the third (z) axis and normalise all axes
    ax0 = np.array(axes_dir[0])
    ax1 = np.array(axes_dir[1])
    ax2 = np.cross(ax0, ax1)
    ax0 = ax0/np.linalg.norm(ax0)
    ax1 = ax1/np.linalg.norm(ax1)
    ax2 = ax2/np.linalg.norm(ax2)
    ax = [ax0, ax1, ax2] # Or similar iterable but must be mutable

    intermediate_axes = [None]*len(axis_order)

    # Calculate total transformation
    for i, a in enumerate(axis_order):

        # Store intermediate axes
        intermediate_axes[i] = list(ax)

        R = _Ru(angles[i], ax[a])

        # Don't bother transforming current axis that's being rotated about
        zot = [0,1,2]
        zot.remove(a)
        for aj in zot:
            ax[aj] = np.dot(R, ax[aj])

    return intermediate_axes

您可以通过

获取输出并旋转实例
rotate_axes = general_rotation(axis_order, angles, axes_dir)
for i in range(len(rotate_axes)):
    ra.rotate(instanceList=(instanceName, ), axisPoint=origin, axisDirection=rotate_axes[i][axis_order[i]], angle=angles[i])

ra作为assembly对象,instanceName作为表示要旋转的实例名称的字符串,origin作为轴的原点。< / p>

*在Python中,当只用一个成员指定tuple个对象时,必须在唯一的成员之后放置一个逗号。例如。包含数字1的元组由(1,) (1)构成。您也可以使用list代替。

**可以在模型树中找到确切的字符串:

enter image description here