Generic Surface Class#

class rocketpy.GenericSurface[source]#

Defines a generic aerodynamic surface with custom force and moment coefficients. The coefficients can be nonlinear functions of the angle of attack, sideslip angle, Mach number, Reynolds number, pitch rate, yaw rate and roll rate.

__init__(reference_area, reference_length, coefficients, center_of_pressure=(0, 0, 0), name='Generic Surface')[source]#

Create a generic aerodynamic surface, defined by its aerodynamic coefficients. This surface is used to model any aerodynamic surface that does not fit the predefined classes.

Important

All the aerodynamic coefficients can be input as callable functions of angle of attack, angle of sideslip, Mach number, Reynolds number, pitch rate, yaw rate and roll rate. For CSV files, the header must contain at least one of the following: “alpha”, “beta”, “mach”, “reynolds”, “pitch_rate”, “yaw_rate” and “roll_rate”.

Parameters:
  • reference_area (int, float) – Reference area of the aerodynamic surface. Has the unit of meters squared. Commonly defined as the rocket’s cross-sectional area.

  • reference_length (int, float) – Reference length of the aerodynamic surface. Has the unit of meters. Commonly defined as the rocket’s diameter.

  • coefficients (dict) –

    List of coefficients. If a coefficient is omitted, it is set to 0. The valid coefficients are:

    cL: str, callable, optional

    Lift coefficient. Can be a path to a CSV file or a callable. Default is 0.

    cQ: str, callable, optional

    Side force coefficient. Can be a path to a CSV file or a callable. Default is 0.

    cD: str, callable, optional

    Drag coefficient. Can be a path to a CSV file or a callable. Default is 0.

    cm: str, callable, optional

    Pitch moment coefficient. Can be a path to a CSV file or a callable. Default is 0.

    cn: str, callable, optional

    Yaw moment coefficient. Can be a path to a CSV file or a callable. Default is 0.

    cl: str, callable, optional

    Roll moment coefficient. Can be a path to a CSV file or a callable. Default is 0.

  • center_of_pressure (tuple, list, optional) – Application point of the aerodynamic forces and moments. The center of pressure is defined in the local coordinate system of the aerodynamic surface. The default value is (0, 0, 0).

  • name (str, optional) – Name of the aerodynamic surface. Default is ‘GenericSurface’.

_get_default_coefficients()[source]#

Returns default coefficients

Returns:

default_coefficients – Dictionary whose keys are the coefficients names and keys are the default values.

Return type:

dict

_complete_coefficients(input_coefficients, default_coefficients)[source]#

Creates a copy of the input coefficients dict and fill it with missing keys with default values

Parameters:
  • input_coefficients (str, dict) – Coefficients dictionary passed by the user. If the user only specifies some of the coefficients, the remaining are completed with class default values

  • default_coefficients (dict) – Default coefficients of the class

Returns:

coefficients – Coefficients dictionary used to setup coefficient attributes

Return type:

dict

_check_coefficients(input_coefficients, default_coefficients)[source]#

Check if input coefficients have only valid keys

Parameters:
  • input_coefficients (str, dict) – Coefficients dictionary passed by the user. If the user only specifies some of the coefficients, the remaining are completed with class default values

  • default_coefficients (dict) – Default coefficients of the class

Raises:

ValueError – Raises a value error if the input coefficient has an invalid key

_compute_from_coefficients(rho, stream_speed, alpha, beta, mach, reynolds, pitch_rate, yaw_rate, roll_rate)[source]#

Compute the aerodynamic forces and moments from the aerodynamic coefficients.

Parameters:
  • rho (float) – Air density.

  • stream_speed (float) – Magnitude of the airflow speed.

  • alpha (float) – Angle of attack in radians.

  • beta (float) – Sideslip angle in radians.

  • mach (float) – Mach number.

  • reynolds (float) – Reynolds number.

  • pitch_rate (float) – Pitch rate in radians per second.

  • yaw_rate (float) – Yaw rate in radians per second.

  • roll_rate (float) – Roll rate in radians per second.

Returns:

The aerodynamic forces (lift, side_force, drag) and moments (pitch, yaw, roll) in the body frame.

Return type:

tuple of float

compute_forces_and_moments(stream_velocity, stream_speed, stream_mach, rho, cp, omega, reynolds)[source]#

Computes the forces and moments acting on the aerodynamic surface. Used in each time step of the simulation. This method is valid for both linear and nonlinear aerodynamic coefficients.

Parameters:
  • stream_velocity (tuple of float) – The velocity of the airflow relative to the surface.

  • stream_speed (float) – The magnitude of the airflow speed.

  • stream_mach (float) – The Mach number of the airflow.

  • rho (float) – Air density.

  • cp (Vector) – Center of pressure coordinates in the body frame.

  • omega (tuple of float) – Tuple containing angular velocities around the x, y, z axes.

  • reynolds (float) – Reynolds number.

  • omega – Tuple containing angular velocities around the x, y, z axes.

Returns:

The aerodynamic forces (lift, side_force, drag) and moments (pitch, yaw, roll) in the body frame.

Return type:

tuple of float

_process_input(input_data, coeff_name)[source]#

Process the input data, either as a CSV file or a callable function.

Parameters:
  • input_data (str or callable) – Input data to be processed, either a path to a CSV or a callable.

  • coeff_name (str) – Name of the coefficient being processed for error reporting.

Returns:

Function object with 7 input arguments (alpha, beta, mach, reynolds, pitch_rate, yaw_rate, roll_rate).

Return type:

Function