aerosandbox.dynamics.point_mass.common_point_mass ================================================= .. py:module:: aerosandbox.dynamics.point_mass.common_point_mass Classes ------- .. autoapisummary:: aerosandbox.dynamics.point_mass.common_point_mass._DynamicsPointMassBaseClass Module Contents --------------- .. py:class:: _DynamicsPointMassBaseClass(mass_props = None, **state_variables_and_indirect_control_variables) Bases: :py:obj:`aerosandbox.common.AeroSandboxObject`, :py:obj:`abc.ABC` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: 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 .. py:property:: state :type: Dict[str, Union[float, aerosandbox.numpy.ndarray]] :abstractmethod: 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: >>> { >>> "x_e": self.x_e, >>> "u_e": self.u_e, >>> ... >>> } .. py:method:: 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. :param new_state: 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. .. py:method:: _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: a) manually, or b) 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. .. py:method:: unpack_state(dict_like_state = None) 'Unpacks' a Dict-like state into an array-like that represents the state of the dynamical system. :param dict_like_state: Takes in a dict-like representation of the state. Returns: The array representation of the state that you gave. .. py:method:: pack_state(array_like_state = None) 'Packs' an array into a Dict that represents the state of the dynamical system. :param array_like_state: Takes in an iterable that must have the same number of entries as the state vector of the system. Returns: The Dict representation of the state that you gave. .. py:property:: control_variables :type: Dict[str, Union[float, aerosandbox.numpy.ndarray]] :abstractmethod: .. py:method:: __repr__() .. py:method:: __getitem__(index) Indexes one item from each attribute of a Dynamics instance. Returns a new Dynamics instance of the same type. :param index: 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. .. py:method:: __len__() .. py:method:: __array__(dtype='O') Allows NumPy array creation without infinite recursion in __len__ and __getitem__. .. py:method:: state_derivatives() :abstractmethod: 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. .. py:method:: constrain_derivatives(opti, time, method = 'trapezoidal', which = 'all', _stacklevel=1) Applies the relevant state derivative constraints to a given Opti instance. :param opti: the AeroSandbox `Opti` instance that constraints should be applied to. :param time: A vector that represents the time at each discrete point. Should be the same length as any :param vectorized state variables in the `state` property of this Dynamics instance.: :param method: The discrete integration method to use. See Opti.constrain_derivative() for options. :param which: 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. :param _stacklevel: Optional and advanced, purely used for debugging. Allows users to correctly track where :param constraints are declared in the event that they are subclassing `aerosandbox.Opti`. Modifies the: :param stacklevel of the declaration tracked: :param which is then presented using: :param `aerosandbox.Opti.variable_declaration: :type `aerosandbox.Opti.variable_declaration: )` and `aerosandbox.Opti.constraint_declaration( Returns: .. py:method:: convert_axes(x_from, y_from, z_from, from_axes, to_axes) :abstractmethod: 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" :param x_from: x-component of the vector, in `from_axes` frame. :param y_from: y-component of the vector, in `from_axes` frame. :param z_from: z-component of the vector, in `from_axes` frame. :param from_axes: The axes to convert from. See above for options. :param to_axes: The axes to convert to. See above for options. Returns: The x-, y-, and z-components of the vector, in `to_axes` frame. Given as a tuple. .. py:method:: add_force(Fx = 0, Fy = 0, Fz = 0, axes = 'wind') :abstractmethod: Adds a force (in whichever axis system you choose) to this Dynamics instance. :param Fx: Force in the x-direction in the axis system chosen. [N] :param Fy: Force in the y-direction in the axis system chosen. [N] :param Fz: Force in the z-direction in the axis system chosen. [N] :param axes: The axis system that the specified force is in. One of: * "geometry" * "body" * "wind" * "stability" * "earth" Returns: None (in-place) .. py:method:: 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. :param g: The gravitational acceleration. [m/s^2] Returns: None (in-place) .. py: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. .. py:method:: 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) .. py:property:: altitude .. py:property:: translational_kinetic_energy :type: float Computes the kinetic energy [J] from translational motion. KE = 0.5 * m * v^2 :returns: Kinetic energy [J] .. py:property:: rotational_kinetic_energy :type: float Computes the kinetic energy [J] from rotational motion. KE = 0.5 * I * w^2 :returns: Kinetic energy [J] .. py: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] .. py:property:: potential_energy Computes the potential energy [J] from gravity. PE = mgh :param g: Acceleration due to gravity [m/s^2] :returns: Potential energy [J]