aerosandbox.dynamics.point_mass.common_point_mass
#
Module Contents#
Classes#
Helper class that provides a standard way to create an ABC using |
- class aerosandbox.dynamics.point_mass.common_point_mass._DynamicsPointMassBaseClass(mass_props=None, **state_variables_and_indirect_control_variables)[source]#
Bases:
aerosandbox.common.AeroSandboxObject
,abc.ABC
Helper class that provides a standard way to create an ABC using inheritance.
- Parameters:
mass_props (aerosandbox.MassProperties) –
- abstract property state: Dict[str, float | aerosandbox.numpy.ndarray][source]#
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, >>> ... >>> }
- Return type:
Dict[str, Union[float, aerosandbox.numpy.ndarray]]
- abstract property control_variables: Dict[str, float | aerosandbox.numpy.ndarray][source]#
- Return type:
Dict[str, Union[float, aerosandbox.numpy.ndarray]]
- property op_point[source]#
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.
- property translational_kinetic_energy: float[source]#
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[source]#
Computes the kinetic energy [J] from rotational motion.
KE = 0.5 * I * w^2
- Returns:
Kinetic energy [J]
- Return type:
float
- property kinetic_energy[source]#
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[source]#
Computes the potential energy [J] from gravity.
PE = mgh
- Parameters:
g (float) – Acceleration due to gravity [m/s^2]
- Returns:
Potential energy [J]
- mass_props[source]#
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
- get_new_instance_with_state(new_state=None)[source]#
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)[source]#
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:
manually, or
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)[source]#
‘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)[source]#
‘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.
- __getitem__(index)[source]#
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.
- __array__(dtype='O')[source]#
Allows NumPy array creation without infinite recursion in __len__ and __getitem__.
- abstract state_derivatives()[source]#
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)[source]#
Applies the relevant state derivative constraints to a given Opti instance.
- Parameters:
opti (aerosandbox.Opti) – 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)[source]#
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')[source]#
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)[source]#
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)
- 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, show=True)[source]#
- Parameters:
vehicle_model (Union[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) –
show (bool) –