Skip to content

Instantly share code, notes, and snippets.

@YannBerthelot
Created September 26, 2021 15:49
Show Gist options
  • Save YannBerthelot/9b3bb13f6fb17e4c9d669c1c185d999f to your computer and use it in GitHub Desktop.
Save YannBerthelot/9b3bb13f6fb17e4c9d669c1c185d999f to your computer and use it in GitHub Desktop.
import numpy as np
from numba import njit
MACH_CRITIC = 0.78
C_X_MIN = 0.095
@njit(nogil=True, fastmath=True)
def compute_cx(alpha, mach):
"""
Compute the drag coefficient at M = 0 depending on alpha
(the higher alpha the higher the drag)
"""
cx = np.power((np.degrees(alpha) + 5) * 0.03, 2) + C_X_MIN
if mach < MACH_CRITIC:
return cx / np.sqrt(1 - (mach ** 2))
if mach < 1:
return cx * 15 * (mach - MACH_CRITIC) + (cx / np.sqrt(1 - (mach ** 2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment