Post · 7 min read· pp. 511–517

aerosandbox.dynamics.rigid_body

Submodules

Classes

DynamicsRigidBody2DBodyDynamics instance:
DynamicsRigidBody3DBodyEulerDynamics instance:

Package Contents

class aerosandbox.dynamics.rigid_body.DynamicsRigidBody2DBody(mass_props=None, x_e=0, z_e=0, u_b=0, w_b=0, theta=0, q=0) : Bases: aerosandbox.dynamics.rigid_body.rigid_3D.body_euler.DynamicsRigidBody3DBodyEuler

code
Dynamics instance:
\* simulating a rigid body
\* in 2D
\* with velocity parameterized in body axes

State variables:
:   x\_e: x-position, in Earth axes. [meters]
    z\_e: z-position, in Earth axes. [meters]
    u\_b: x-velocity, in body axes. [m/s]
    w\_b: z-velocity, in body axes. [m/s]
    theta: pitch angle. [rad]
    q: y-angular-velocity, in body axes. [rad/sec]

Control variables:
:   Fx\_b: Force along the body-x axis. [N]
    Fz\_b: Force along the body-z axis. [N]
    My\_b: Moment about the body-y axis. [Nm]

Parameters:
:   - **mass\_props** ([*aerosandbox.weights.mass\_properties.MassProperties*](/u/921f7ad402625b18#aerosandbox-weights-mass-properties-massproperties)) –
    - **x\_e** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
    - **z\_e** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
    - **u\_b** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
    - **w\_b** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
    - **theta** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
    - **q** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –

mass\_props
:   For each state variable, self.state\_var = state\_var

    For each indirect control variable, self.indirect\_control\_var = indirect\_control\_var

    For each control variable, self.control\_var = 0

x\_e *= 0*

y\_e *= 0*

z\_e *= 0*

u\_b *= 0*

v\_b *= 0*

w\_b *= 0*

phi *= 0*

theta *= 0*

psi *= 0*

p *= 0*

q *= 0*

r *= 0*

Fx\_b *= 0*

Fy\_b *= 0*

Fz\_b *= 0*

Mx\_b *= 0*

My\_b *= 0*

Mz\_b *= 0*

hx\_b *= 0*

hy\_b *= 0*

hz\_b *= 0*

*property* state
:   Returns the state variables of this Dynamics instance as a Dict.

    Keys are strings that give the name of the variables.
    Values are the variables themselves.

    This method should look something like:
    :   ```default

{ "x_e": self.x_e, "u_e": self.u_e, ... }

code

    *property* control\_variables

    state\_derivatives()
    :   Computes the state derivatives (i.e. equations of motion) for a body in 3D space.

        Based on Section 9.8.2 of Flight Vehicle Aerodynamics by Mark Drela.

        Returns:
        :   {
            :   “xe” : d\_xe,
                “ye” : d\_ye,
                “ze” : d\_ze,
                “u” : d\_u,
                “v” : d\_v,
                “w” : d\_w,
                “phi” : d\_phi,
                “theta”: d\_theta,
                “psi” : d\_psi,
                “p” : d\_p,
                “q” : d\_q,
                “r” : d\_r,

            }

        Return type:
        :   Time derivatives of each of the 12 state variables, given in a dictionary

<a id="aerosandbox.dynamics.rigid_body.DynamicsRigidBody3DBodyEuler"></a> *class* aerosandbox.dynamics.rigid\_body.DynamicsRigidBody3DBodyEuler(*mass\_props=None*, *x\_e=0*, *y\_e=0*, *z\_e=0*, *u\_b=0*, *v\_b=0*, *w\_b=0*, *phi=0*, *theta=0*, *psi=0*, *p=0*, *q=0*, *r=0*)
:   Bases: [`aerosandbox.dynamics.rigid_body.common_rigid_body._DynamicsRigidBodyBaseClass`](/u/b00fb929966beb88#aerosandbox-dynamics-rigid-body-common-rigid-body-dynamicsrigidbodybaseclass)

    Dynamics instance:
    \* simulating a rigid body
    \* in 3D
    \* with velocity parameterized in body axes
    \* and angle parameterized in Euler angles

    State variables:
    :   x\_e: x-position, in Earth axes. [meters]
        y\_e: y-position, in Earth axes. [meters]
        z\_e: z-position, in Earth axes. [meters]
        u\_b: x-velocity, in body axes. [m/s]
        v\_b: y-velocity, in body axes. [m/s]
        w\_b: z-velocity, in body axes. [m/s]
        phi: roll angle. Uses yaw-pitch-roll Euler angle convention. [rad]
        theta: pitch angle. Uses yaw-pitch-roll Euler angle convention. [rad]
        psi: yaw angle. Uses yaw-pitch-roll Euler angle convention. [rad]
        p: x-angular-velocity, in body axes. [rad/sec]
        q: y-angular-velocity, in body axes. [rad/sec]
        r: z-angular-velocity, in body axes. [rad/sec]

    Control variables:
    :   Fx\_b: Force along the body-x axis. [N]
        Fy\_b: Force along the body-y axis. [N]
        Fz\_b: Force along the body-z axis. [N]
        Mx\_b: Moment about the body-x axis. [Nm]
        My\_b: Moment about the body-y axis. [Nm]
        Mz\_b: Moment about the body-z axis. [Nm]
        hx\_b: Angular momentum (e.g., propellers) about the body-x axis. [kg\*m^2/sec]
        hy\_b: Angular momentum (e.g., propellers) about the body-y axis. [kg\*m^2/sec]
        hz\_b: Angular momentum (e.g., propellers) about the body-z axis. [kg\*m^2/sec]

    Parameters:
    :   - **mass\_props** ([*aerosandbox.weights.mass\_properties.MassProperties*](/u/921f7ad402625b18#aerosandbox-weights-mass-properties-massproperties)) –
        - **x\_e** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
        - **y\_e** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
        - **z\_e** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
        - **u\_b** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
        - **v\_b** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
        - **w\_b** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
        - **phi** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
        - **theta** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
        - **psi** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
        - **p** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
        - **q** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –
        - **r** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) –

    mass\_props
    :   For each state variable, self.state\_var = state\_var

        For each indirect control variable, self.indirect\_control\_var = indirect\_control\_var

        For each control variable, self.control\_var = 0

    x\_e *= 0*

    y\_e *= 0*

    z\_e *= 0*

    u\_b *= 0*

    v\_b *= 0*

    w\_b *= 0*

    phi *= 0*

    theta *= 0*

    psi *= 0*

    p *= 0*

    q *= 0*

    r *= 0*

    Fx\_b *= 0*

    Fy\_b *= 0*

    Fz\_b *= 0*

    Mx\_b *= 0*

    My\_b *= 0*

    Mz\_b *= 0*

    hx\_b *= 0*

    hy\_b *= 0*

    hz\_b *= 0*

    *property* state
    :   Returns the state variables of this Dynamics instance as a Dict.

        Keys are strings that give the name of the variables.
        Values are the variables themselves.

        This method should look something like:
        :   ```default
>>> {
>>>     "x_e": self.x_e,
>>>     "u_e": self.u_e,
>>>     ...
>>> }
code
*property* control\_variables

state\_derivatives()
:   Computes the state derivatives (i.e. equations of motion) for a body in 3D space.

    Based on Section 9.8.2 of Flight Vehicle Aerodynamics by Mark Drela.

    Returns:
    :   {
        :   “xe” : d\_xe,
            “ye” : d\_ye,
            “ze” : d\_ze,
            “u” : d\_u,
            “v” : d\_v,
            “w” : d\_w,
            “phi” : d\_phi,
            “theta”: d\_theta,
            “psi” : d\_psi,
            “p” : d\_p,
            “q” : d\_q,
            “r” : d\_r,

        }

    Return type:
    :   Time derivatives of each of the 12 state variables, given in a dictionary

convert\_axes(*x\_from*, *y\_from*, *z\_from*, *from\_axes*, *to\_axes*)
:   Converts a vector [x\_from, y\_from, z\_from], as given in the from\_axes frame, to an equivalent vector [x\_to,
    y\_to, z\_to], as given in the to\_axes frame.

    Identical to OperatingPoint.convert\_axes(), but adds in “earth” as a valid axis frame. For more documentation,
    see the docstring of OperatingPoint.convert\_axes().

    Both from\_axes and to\_axes should be a string, one of:
    :   - “geometry”
        - “body”
        - “wind”
        - “stability”
        - “earth”

    Parameters:
    :   - **x\_from** – x-component of the vector, in from\_axes frame.
        - **y\_from** – y-component of the vector, in from\_axes frame.
        - **z\_from** – z-component of the vector, in from\_axes frame.
        - **from\_axes** (*str*) – The axes to convert from.
        - **to\_axes** (*str*) – The axes to convert to.

    Returns: The x-, y-, and z-components of the vector, in to\_axes frame. Given as a tuple.

add\_force(*Fx=0*, *Fy=0*, *Fz=0*, *axes='body'*)
:   Adds a force (in whichever axis system you choose) to this Dynamics instance.

    Parameters:
    :   - **Fx** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) – Force in the x-direction in the axis system chosen. [N]
        - **Fy** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) – Force in the y-direction in the axis system chosen. [N]
        - **Fz** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) – Force in the z-direction in the axis system chosen. [N]
        - **axes** – The axis system that the specified force is in. One of:
          \* “geometry”
          \* “body”
          \* “wind”
          \* “stability”
          \* “earth”

    Returns: None (in-place)

add\_moment(*Mx=0*, *My=0*, *Mz=0*, *axes='body'*)
:   Adds a moment (in whichever axis system you choose) to this Dynamics instance.

    Parameters:
    :   - **Mx** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) – Moment about the x-axis in the axis system chosen. Assumed these moments are applied about the center of mass. [Nm]
        - **My** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) – Moment about the y-axis in the axis system chosen. Assumed these moments are applied about the center of mass. [Nm]
        - **Mz** (*Union**[**float**,* *aerosandbox.numpy.ndarray**]*) – Moment about the z-axis in the axis system chosen. Assumed these moments are applied about the center of mass. [Nm]
        - **axes** – The axis system that the specified moment is in. One of:
          \* “geometry”
          \* “body”
          \* “wind”
          \* “stability”
          \* “earth”

    Returns: None (in-place)

*property* speed
:   The speed of the object, expressed as a scalar.

*property* alpha
:   The angle of attack, in degrees.

*property* beta
:   The sideslip angle, in degrees.