Source code for suboptimumg.vehicle.aerodynamics.aerodynamics

from ...constants import *
from ..models import VehicleModel


[docs] class DRS: def __init__( self, vehicle_model: VehicleModel, ): self.vehicle_model = vehicle_model self.params = vehicle_model.aero.drs
[docs] def get_drs_drag(self, v): """ Calculate the drag force based on the current velocity with DRS active. Parameters ---------- v : float Current velocity (m/s) Returns ------- float Drag force (N) """ return 0.5 * self.params.drs_cd * self.params.drs_front_area * v**2 * RHO
[docs] def get_drs_lift(self, v): """ Calculate the lift force based on the current velocity with DRS active. Parameters ---------- v : float Current velocity (m/s) Returns ------- float Lift force (N) """ return 0.5 * self.params.drs_cl * self.params.drs_front_area * v**2 * RHO
[docs] def get_tot_drs_lift(self, v): """ Calculate the total lift force based on the current velocity with DRS active. Parameters ---------- v : float Current velocity (m/s) Returns ------- tuple Front and rear lift forces on each tire (N) (fl, fr, rl, rr) """ tot_lift = self.get_drs_lift(v) front_lift = tot_lift * self.params.drs_cop rear_lift = tot_lift * (1 - self.params.drs_cop) return (front_lift / 2,) * 2 + (rear_lift / 2,) * 2
[docs] def drs_activate(self, drs_threshold): """ Check whether DRS should be activated based on lateral acceleration. Parameters ---------- drs_threshold : float Current lateral acceleration threshold (m/s^2) Returns ------- bool True if DRS should be activated, False otherwise """ return self.params.drs_present and drs_threshold <= self.params.drs_accel_thresh
[docs] class Aero: def __init__( self, vehicle_model: VehicleModel, ): self.vehicle_model = vehicle_model self.params = vehicle_model.aero # Construct DRS if it exists in the vehicle model if self.params.drs is not None: self.drs = DRS(vehicle_model=vehicle_model) else: self.drs = None
[docs] def get_drag(self, v, drs_threshold): """ Calculates the drag force based on the current velocity. Varies the output based on the DRS active state. Returns ------- float Drag force (N) """ no_drs = 0.5 * self.params.cd * self.params.front_area * v**2 * RHO if self.drs is None: return no_drs drs_active = self.drs.drs_activate(drs_threshold) return self.drs.get_drs_drag(v) if drs_active else no_drs
[docs] def get_lift(self, v): """ Calculates the lift force based on the current velocity without DRS. Returns ------- float Lift force (N) """ return 0.5 * self.params.cl * self.params.front_area * v**2 * RHO
[docs] def tire_lift_forces(self, v, drs_threshold, pitch=None, roll=None): """ Calculates the lift force on each tire based on the current velocity. Varies the output based on the DRS active state. Returns ------- tuple Front and rear lift forces on each tire (N) """ if self.drs is not None and self.drs.drs_activate(drs_threshold): return self.drs.get_tot_drs_lift(v) else: tot_lift = self.get_lift(v) front_lift = tot_lift * self.params.cop rear_lift = tot_lift * (1 - self.params.cop) return ( front_lift / 2, front_lift / 2, rear_lift / 2, rear_lift / 2, )