dbookstaber / py_ballistics

Point-mass ballistic trajectory calculator with support for custom drag models
GNU Lesser General Public License v3.0
2 stars 0 forks source link

Validate atmospheric calculations #9

Open dbookstaber opened 8 months ago

dbookstaber commented 8 months ago

During testing (the old test_danger_space unittest), with an absurdly dense atmosphere (1000 hPa) that led to a trajectory drop through 4000ft, the t in conditions.py::get_density_factor_and_mach_for_altitude() went negative. As best I can tell this is a temperature, so this shouldn't be possible no matter how extreme the variables. This function is probably supposed to do calculations in Kelvin, but it appears to be doing them in whatever Temperature units were set. So we need some test cases here.

Specific values found in this test case:

dbookstaber commented 7 months ago

The cIcaoFreezingPointTemperatureR is wrong: °R = °F + 459.67. Freezing point in °F = 32, so freezing point in °R = 491.67. However, making this correction breaks test_computer.py::test_temp_atmo. Actually it looks like the variable is just misnamed: It appears that everywhere in the code it is used to convert units between Rankine and Fahrenheit.

References for validation of the remaining logic:

dbookstaber commented 7 months ago

C_d (drag coefficient) is a function of Mach number. Drag force is a function of air density * C_d.

drag = density_factor * velocity * self.drag_by_mach(velocity / mach)

where

density_factor, mach = atmo.get_density_factor_and_mach_for_altitude(alt0 + range_vector.y)

and

density_factor = density / cStandardDensity

Atmo.get_density_factor_and_mach_for_altitude() returns incorrect density. The adjusted pressure equation there is just wrong.

dbookstaber commented 7 months ago

References to validate:

Others:

Python package: https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.density.html#metpy.calc.density