Post · 7 min read· pp. 471–477

aerosandbox.dynamics.point_mass.common_point_mass

Classes

_DynamicsPointMassBaseClassHelper class that provides a standard way to create an ABC using

Module Contents

class aerosandbox.dynamics.point_mass.common_point_mass._DynamicsPointMassBaseClass(mass_props=None, **state_variables_and_indirect_control_variables) : Bases: aerosandbox.common.AeroSandboxObject, abc.ABC

code
Helper class that provides a standard way to create an ABC using
inheritance.

Parameters:
:   **mass\_props** ([*aerosandbox.MassProperties*](/u/e98c1a890dad6c0c#aerosandbox-massproperties)) –

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

*property* state*: Dict[str, float | aerosandbox.numpy.ndarray]*
:   Abstractmethod:

    Return type:
    :   Dict[str, Union[float, aerosandbox.numpy.ndarray]]

    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

    get\_new\_instance\_with\_state(*new\_state=None*)
    :   Creates a new instance of this same Dynamics class from the given state.

        Note that any control variables (forces, moments) associated with the previous instance are zeroed.

        Parameters:
        :   **new\_state** (*Union**[**Dict**[**str**,* *Union**[**float**,* *aerosandbox.numpy.ndarray**]**]**,* *List**,* *Tuple**,* *aerosandbox.numpy.ndarray**]*) – The new state to be used for the new instance. Ideally, this is represented as a Dict in identical format to the state of a Dynamics instance.

        Returns: A new instance of this same Dynamics class.

    \_set\_state(*new\_state=None*)
    :   Force-overwrites all state variables with a new set (either partial or complete) of state variables.

        Warning: this is *not* the intended public usage of Dynamics instances.
        If you want a new state yourself, you should instantiate a new one either:

        > 1. manually, or
        > 2. by using Dynamics.get\_new\_instance\_with\_state()

        Hence, this function is meant for PRIVATE use only - be careful how you use this! Especially note that
        control variables (e.g., forces, moments) do not reset to zero.

        Parameters:
        :   **new\_state** (*Union**[**Dict**[**str**,* *Union**[**float**,* *aerosandbox.numpy.ndarray**]**]**,* *List**,* *Tuple**,* *aerosandbox.numpy.ndarray**]*) –

    unpack\_state(*dict\_like\_state=None*)
    :   ‘Unpacks’ a Dict-like state into an array-like that represents the state of the dynamical system.

        Parameters:
        :   **dict\_like\_state** (*Dict**[**str**,* *Union**[**float**,* *aerosandbox.numpy.ndarray**]**]*) – Takes in a dict-like representation of the state.

        Return type:
        :   Tuple[Union[float, aerosandbox.numpy.ndarray]]

        Returns: The array representation of the state that you gave.

    pack\_state(*array\_like\_state=None*)
    :   ‘Packs’ an array into a Dict that represents the state of the dynamical system.

        Parameters:
        :   **array\_like\_state** (*Union**[**List**,* *Tuple**,* *aerosandbox.numpy.ndarray**]*) – Takes in an iterable that must have the same number of entries as the state vector of the system.

        Return type:
        :   Dict[str, Union[float, aerosandbox.numpy.ndarray]]

        Returns: The Dict representation of the state that you gave.

    *property* control\_variables*: Dict[str, float | aerosandbox.numpy.ndarray]*
    :   Abstractmethod:

        Return type:
        :   Dict[str, Union[float, aerosandbox.numpy.ndarray]]

    \_\_repr\_\_()
    :   Return type:
        :   str

    \_\_getitem\_\_(*index*)
    :   Indexes one item from each attribute of a Dynamics instance.
        Returns a new Dynamics instance of the same type.

        Parameters:
        :   **index** (*Union**[**int**,* *slice**]*) – The index that is being called; e.g.,:
            >>> first\_dyn = dyn[0]

        Returns: A new Dynamics instance, where each attribute is subscripted at the given value, if possible.

    \_\_len\_\_()

    \_\_array\_\_(*dtype='O'*)
    :   Allows NumPy array creation without infinite recursion in \_\_len\_\_ and \_\_getitem\_\_.

    *abstract* state\_derivatives()
    :   A function that returns the derivatives with respect to time of the state specified in the state property.

        Should return a Dict with the same keys as the state property.

        Return type:
        :   Dict[str, Union[float, aerosandbox.numpy.ndarray]]

    constrain\_derivatives(*opti*, *time*, *method='trapezoidal'*, *which='all'*, *\_stacklevel=1*)
    :   Applies the relevant state derivative constraints to a given Opti instance.

        Parameters:
        :   - **opti** ([*aerosandbox.Opti*](/u/e98c1a890dad6c0c#id0)) – the AeroSandbox Opti instance that constraints should be applied to.
            - **time** (*aerosandbox.numpy.ndarray*) – A vector that represents the time at each discrete point. Should be the same length as any
            - **instance.** (*vectorized state variables in the state property* *of* *this Dynamics*) –
            - **method** (*str*) – The discrete integration method to use. See Opti.constrain\_derivative() for options.
            - **which** (*Union**[**str**,* *List**[**str**]**,* *Tuple**[**str**]**]*) –

              Which state variables should be we constrain? By default, constrains all of them.

              Options:

              > - ”all”, which constrains all state variables (default)
              > - A list of strings that are state variable names (i.e., a subset of dyn.state.keys()),
              >
              > that gives the names of state variables to be constrained.
            - **\_stacklevel** – Optional and advanced, purely used for debugging. Allows users to correctly track where
            - **the** (*constraints are declared in the event that they are subclassing aerosandbox.Opti. Modifies*) –
            - **tracked** (*stacklevel* *of* *the declaration*) –
            - **using** (*which is then presented*) –
            - **`aerosandbox.Opti.variable\_declaration** –

        Returns:

    *abstract* 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** (*float*) – x-component of the vector, in from\_axes frame.
            - **y\_from** (*float*) – y-component of the vector, in from\_axes frame.
            - **z\_from** (*float*) – z-component of the vector, in from\_axes frame.
            - **from\_axes** (*str*) – The axes to convert from. See above for options.
            - **to\_axes** (*str*) – The axes to convert to. See above for options.

        Return type:
        :   Tuple[float, float, float]

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

    *abstract* add\_force(*Fx=0*, *Fy=0*, *Fz=0*, *axes='wind'*)
    :   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** (*str*) – The axis system that the specified force is in. One of:
              \* “geometry”
              \* “body”
              \* “wind”
              \* “stability”
              \* “earth”

        Return type:
        :   None

        Returns: None (in-place)

    add\_gravity\_force(*g=9.81*)
    :   In-place modifies the forces associated with this Dynamics instance: adds a force in the -z direction,
        equal to the weight of the aircraft.

        Parameters:
        :   **g** – The gravitational acceleration. [m/s^2]

        Return type:
        :   None

        Returns: None (in-place)

    *property* op\_point
    :   Returns an OperatingPoint object that represents the current state of the dynamics instance.

        This OperatingPoint object is effectively a subset of the state variables, and is used to compute aerodynamic
        forces and moments.

    draw(*vehicle\_model=None*, *backend='pyvista'*, *plotter=None*, *draw\_axes=True*, *draw\_global\_axes=True*, *draw\_global\_grid=True*, *scale\_vehicle\_model=None*, *n\_vehicles\_to\_draw=10*, *cg\_axes='geometry'*, *draw\_trajectory\_line=True*, *trajectory\_line\_color=None*, *draw\_altitude\_drape=True*, *draw\_ground\_plane=True*, *draw\_wingtip\_ribbon=True*, *set\_sky\_background=True*, *vehicle\_color=None*, *vehicle\_opacity=0.95*, *show=True*)
    :   Parameters:
        :   - **vehicle\_model** (*Union**[*[*aerosandbox.Airplane*](/u/e98c1a890dad6c0c#aerosandbox-airplane)*,* *PolyData**]*) –
            - **backend** (*str*) –
            - **draw\_axes** (*bool*) –
            - **draw\_global\_axes** (*bool*) –
            - **draw\_global\_grid** (*bool*) –
            - **scale\_vehicle\_model** (*Union**[**float**,* *None**]*) –
            - **n\_vehicles\_to\_draw** (*int*) –
            - **cg\_axes** (*str*) –
            - **draw\_trajectory\_line** (*bool*) –
            - **draw\_altitude\_drape** (*bool*) –
            - **draw\_ground\_plane** (*bool*) –
            - **draw\_wingtip\_ribbon** (*bool*) –
            - **set\_sky\_background** (*bool*) –
            - **vehicle\_opacity** (*float*) –
            - **show** (*bool*) –

    *property* altitude

    *property* translational\_kinetic\_energy*: float*
    :   Computes the kinetic energy [J] from translational motion.

        KE = 0.5 \* m \* v^2

        Returns:
        :   Kinetic energy [J]

        Return type:
        :   float

    *property* rotational\_kinetic\_energy*: float*
    :   Computes the kinetic energy [J] from rotational motion.

        KE = 0.5 \* I \* w^2

        Returns:
        :   Kinetic energy [J]

        Return type:
        :   float

    *property* kinetic\_energy
    :   Computes the kinetic energy [J] from translational and rotational motion.

        KE = 0.5 \* m \* v^2 + 0.5 \* I \* w^2

        Returns:
        :   Kinetic energy [J]

    *property* potential\_energy
    :   Computes the potential energy [J] from gravity.

        PE = mgh

        Parameters:
        :   **g** (*float*) – Acceleration due to gravity [m/s^2]

        Returns:
        :   Potential energy [J]