예제 #1
0
    def __init__(self,
                 name,
                 masscenter=None,
                 mass=None,
                 frame=None,
                 central_inertia=None):

        self.name = name
        self.loads = []

        if frame is None:
            frame = ReferenceFrame(name + '_frame')

        if masscenter is None:
            masscenter = Point(name + '_masscenter')

        if central_inertia is None and mass is None:
            ixx = Symbol(name + '_ixx')
            iyy = Symbol(name + '_iyy')
            izz = Symbol(name + '_izz')
            izx = Symbol(name + '_izx')
            ixy = Symbol(name + '_ixy')
            iyz = Symbol(name + '_iyz')
            _inertia = (inertia(frame, ixx, iyy, izz, ixy, iyz,
                                izx), masscenter)
        else:
            _inertia = (central_inertia, masscenter)

        if mass is None:
            _mass = Symbol(name + '_mass')
        else:
            _mass = mass

        masscenter.set_vel(frame, 0)

        # If user passes masscenter and mass then a particle is created
        # otherwise a rigidbody. As a result a body may or may not have inertia.
        if central_inertia is None and mass is not None:
            self.frame = frame
            self.masscenter = masscenter
            Particle.__init__(self, name, masscenter, _mass)
        else:
            RigidBody.__init__(self, name, masscenter, frame, _mass, _inertia)
예제 #2
0
파일: body.py 프로젝트: arghdos/sympy
    def __init__(self, name, masscenter=None, mass=None, frame=None,
                 central_inertia=None):

        self.name = name
        self.loads = []

        if frame is None:
            frame = ReferenceFrame(name + '_frame')

        if masscenter is None:
            masscenter = Point(name + '_masscenter')

        if central_inertia is None and mass is None:
            ixx = Symbol(name + '_ixx')
            iyy = Symbol(name + '_iyy')
            izz = Symbol(name + '_izz')
            izx = Symbol(name + '_izx')
            ixy = Symbol(name + '_ixy')
            iyz = Symbol(name + '_iyz')
            _inertia = (inertia(frame, ixx, iyy, izz, ixy, iyz, izx),
                        masscenter)
        else:
            _inertia = (central_inertia, masscenter)

        if mass is None:
            _mass = Symbol(name + '_mass')
        else:
            _mass = mass

        masscenter.set_vel(frame, 0)

        # If user passes masscenter and mass then a particle is created
        # otherwise a rigidbody. As a result a body may or may not have inertia.
        if central_inertia is None and mass is not None:
            self.frame = frame
            self.masscenter = masscenter
            Particle.__init__(self, name, masscenter, _mass)
        else:
            RigidBody.__init__(self, name, masscenter, frame, _mass, _inertia)
예제 #3
0
    def __init__(self, name, mass=None, J_G=None, rho_G=None, J_diag=False):
        """
        Define a rigid body and introduce symbols for convenience.
        
           Origin point have no velocities in the body frame! 
            
        
        INPUTS:
            name: string (can be one character), make sure this string is unique between all bodies
        
        OPTIONAL INPUTS:
            mass : scalar, body mass
            J_G  : 3x3 array or 3-array defining the coordinates of the inertia tensor in the body frame at the COG
            rho_G: array-like of length 3 defining the coordinates of the COG in the body frame
            J_diag: if true, the inertial tensor J_G is initialized as diagonal
        
        
        """
        # YAMS Body creates a default "origin", "masscenter", and "frame"
        YAMSBody.__init__(self, name)

        # --- Mass
        if mass is None:
            mass = Symbol('M_' + name)

        # --- Inertia, creating a dyadic using our frame and G
        if J_G is not None:
            if len(list(J_G)) == 3:
                ixx = J_G[0]
                iyy = J_G[1]
                izz = J_G[2]
                ixy, iyz, izx = 0, 0, 0
            else:
                J_G = ensureMat(J_G, 3, 3)
                ixx = J_G[0, 0]
                iyy = J_G[1, 1]
                izz = J_G[2, 2]
                izx = J_G[2, 0]
                ixy = J_G[0, 1]
                iyz = J_G[1, 2]
        else:
            ixx = Symbol('J_xx_' + name)
            iyy = Symbol('J_yy_' + name)
            izz = Symbol('J_zz_' + name)
            izx = Symbol('J_zx_' + name)
            ixy = Symbol('J_xy_' + name)
            iyz = Symbol('J_yz_' + name)
        if J_diag:
            ixy, iyz, izx = 0, 0, 0

        #inertia: dyadic : (inertia(frame, *list), point)
        _inertia = (inertia(self.frame, ixx, iyy, izz, ixy, iyz,
                            izx), self.masscenter)

        # --- Position of COG in body frame
        if rho_G is None:
            rho_G = symbols('x_G_' + name + ', y_G_' + name + ', z_G_' + name)
        self.setGcoord(rho_G)
        self.masscenter.set_vel(self.frame, 0 * self.frame.x)

        # Init Sympy Rigid Body
        SympyRigidBody.__init__(self, name, self.masscenter, self.frame, mass,
                                _inertia)