Skip to content

Down force - #17

Merged
joshuaRiefman merged 37 commits into
mainfrom
down_force
Sep 27, 2025
Merged

Down force#17
joshuaRiefman merged 37 commits into
mainfrom
down_force

Conversation

@skrifana

Copy link
Copy Markdown
Contributor
  • Creation of aeroshell class that accounts for drag and down force calculations
  • Includes basic regression tests for the motor model and extended aeroshell model

@joshuaRiefman joshuaRiefman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good! Just some suggestions

Comment thread physics/models/motor/__init__.py Outdated
Comment thread physics/models/motor/__init__.py Outdated
Comment thread physics/models/motor/basic_motor.py Outdated
Comment thread physics/models/motor/basic_motor.py Outdated
Comment thread physics/models/motor/basic_motor.py Outdated
Comment thread physics/models/aeroshell/aeroshell.py Outdated
Comment thread physics/models/aeroshell/aeroshell.py Outdated

"""
# Lookup table mapping wind angle to lift values for a wind speed of 60 km/hr. Comes from CFD simulation in the google drive. Positive sign convention as it is directed towards the ground, and is taken as the negative of lift
angle_to_lift = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe change the name to downforce?




class AeroshellWithDownForce(Aeroshell):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of this code is the exact same as aeroshell.py except swapping the lookup tables. You might be able to generalize the calculate_drag_force and calculate_down_force functions into a calculate_aerodynamic_force and then you just pass in the necessary lookup table.
I haven't looked or thought about this too closely so it may not be possible, but worth a thought.
The reason for doing this is just to have less copying of code which makes maintaining (and testing) code easier.

Comment thread physics/models/aeroshell/aeroshell_downforce.py Outdated
@jonahjlee
jonahjlee self-requested a review September 13, 2025 04:26
@joshuaRiefman
joshuaRiefman self-requested a review September 24, 2025 02:06
# Conflicts:
#	physics/models/motor/basic_motor.py
Comment thread physics/models/aeroshell/aeroshell.py Outdated
The look up table data comes from a CFD carried out by the Aeroshell team - https://docs.google.com/spreadsheets/d/1D1ydUj-6aG-gBzlq2zTr8WgdxVIGQ9PqUZPuLfDphcg/edit?usp=sharing

"""
angle_to_unscaled_drag = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make these be inputs to the constructor

Comment thread physics/models/aeroshell/aeroshell.py Outdated
"""
# Lookup table mapping wind angle to drag values for a wind speed of 60 km/hr. Comes from CFD simulation in the google drive.

if force_type == "drag":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the table be the input, not force_type

Comment thread physics/models/aeroshell/aeroshell.py Outdated
}

@staticmethod
def calculate_aero_force(wind_speeds, wind_attack_angles, required_speed_ms, force_type):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add helpers like calculate_downforce and calculate_drag_force which call this

Comment thread physics/models/aeroshell/aeroshell.py Outdated
Drag force refers to the resistive force that affects the vehicles. This is considered by both the wind and motion of the car
Down force refers to negative lift force i.e. acting against the normal force at every tick

:param np.ndarray wind_speeds: (float[N]) speeds of wind in m/s, where > 0 means against the direction of the vehicle

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redo documentation to reflect updated class structure

Comment thread physics/models/aeroshell/aeroshell.py Outdated

"""

def __init__(self, drag_lookup, down_lookup):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type hint these variables

Comment thread physics/models/aeroshell/aeroshell.py Outdated

return drag_forces

def calculate_drag(self, wind_speeds, wind_attack_angles, required_speed_ms):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add docstrings and type hints

Comment thread physics/models/aeroshell/aeroshell.py Outdated
values = np.array(list(lookup_table.values()))
func = make_interp_spline(angles, values, k=3)
force_ref = func(wind_attack_angles)
wind_drag = direction * force_ref * (wind_speeds ** 2) / (16.667 ** 2)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make magic numbers into constants

Comment thread physics/models/aeroshell/aeroshell.py Outdated
values = np.array(list(lookup_table.values()))
func = make_interp_spline(angles, values, k=3)
force_ref = func(wind_attack_angles)
wind_drag = direction * force_ref * (wind_speeds ** 2) / (16.667 ** 2)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generalize name of variable (since its not necessarily drag)

@joshuaRiefman
joshuaRiefman merged commit b731636 into main Sep 27, 2025
2 checks passed
@joshuaRiefman
joshuaRiefman deleted the down_force branch September 27, 2025 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants