Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for coefficients_data functions #279

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions docs/World/Aerodynamic/coefficients_data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# coefficients_data

This file contains several functions for calculating the lift, drag and moment coefficients for a fictional airfoil based on the Selig1223. It also contains the same functions for calculating the coefficient of the inverted version of the airfoil (usually used on horizontal stabilizers).

This fictional airfoil stalls for 15 degrees and -5 degrees of AoA.

One just need to call the corresponding function with the desired angle-of-attack as argument:
```python
from adr.World.Aerodynamic.coefficients_data import get_CL, get_CD, get_CM, get_CL_inv, get_CD_inv, get_CM_inv

print(get_CL(18))
>>> 0
print(get_CL(12))
>>> 1.8
print(get_CL(-2))
>>> 0.399
print(get_CL(-12))
>>> 0


print(get_CD(18))
>>> 2.1
print(get_CD(12))
>>> 0.18


print(get_CM(18))
>>> 0
print(get_CM(12))
>>> -0.251


print(get_CL_inv(18))
>>> 0
print(get_CL_inv(-12))
>>> -1.8


print(get_CD_inv(12))
>>> 2.1
print(get_CD_inv(-18))
>>> 2.1


print(get_CM_inv(18))
>>> 0
print(get_CM_inv(-12))
>>> 0.251
```
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ nav:
World:
Ambient: World/Ambient.md
constants: World/constants.md
Aerodynamic:
coefficients_data: World/Aerodynamic/coefficients_data.md
helper funtions:
algebric: helper functions/algebric.md

Expand Down
63 changes: 63 additions & 0 deletions tests/World/Aerodynamic/test_coefficients_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import numpy.testing as npt

from adr.World.Aerodynamic.coefficients_data import get_CL, get_CD, get_CM, get_CL_inv, get_CD_inv, get_CM_inv


def test_get_CL():
npt.assert_almost_equal(get_CL(18), 0)
npt.assert_almost_equal(get_CL(12), 1.8)
npt.assert_almost_equal(get_CL(2), 0.8)
npt.assert_almost_equal(get_CL(0), 0.6)
npt.assert_almost_equal(get_CL(-2), 0.399, decimal=3)
npt.assert_almost_equal(get_CL(-12), 0)
npt.assert_almost_equal(get_CL(-18), 0)


def test_get_CD():
npt.assert_almost_equal(get_CD(18), 2.1)
npt.assert_almost_equal(get_CD(12), 0.18)
npt.assert_almost_equal(get_CD(2), 0.08)
npt.assert_almost_equal(get_CD(0), 0.06, decimal=3)
npt.assert_almost_equal(get_CD(-2), 0.04, decimal=3)
npt.assert_almost_equal(get_CD(-12), 2.1)
npt.assert_almost_equal(get_CD(-18), 2.1)


def test_get_CM():
npt.assert_almost_equal(get_CM(18), 0)
npt.assert_almost_equal(get_CM(12), -0.251, decimal=3)
npt.assert_almost_equal(get_CM(2), -0.260, decimal=3)
npt.assert_almost_equal(get_CM(0), -0.232, decimal=3)
npt.assert_almost_equal(get_CM(-2), -0.195, decimal=3)
npt.assert_almost_equal(get_CM(-12), 0)
npt.assert_almost_equal(get_CM(-18), 0)


def test_get_CL_inv():
npt.assert_almost_equal(get_CL_inv(18), 0)
npt.assert_almost_equal(get_CL_inv(12), 0)
npt.assert_almost_equal(get_CL_inv(2), -0.399, decimal=3)
npt.assert_almost_equal(get_CL_inv(0), -0.6)
npt.assert_almost_equal(get_CL_inv(-2), -0.8)
npt.assert_almost_equal(get_CL_inv(-12), -1.8)
npt.assert_almost_equal(get_CL_inv(-18), 0)


def test_get_CD_inv():
npt.assert_almost_equal(get_CD_inv(18), 2.1)
npt.assert_almost_equal(get_CD_inv(12), 2.1)
npt.assert_almost_equal(get_CD_inv(2), 0.04, decimal=3)
npt.assert_almost_equal(get_CD_inv(0), 0.06, decimal=3)
npt.assert_almost_equal(get_CD_inv(-2), 0.08)
npt.assert_almost_equal(get_CD_inv(-12), 0.18)
npt.assert_almost_equal(get_CD_inv(-18), 2.1)


def test_get_CM_inv():
npt.assert_almost_equal(get_CM_inv(18), 0)
npt.assert_almost_equal(get_CM_inv(12), 0)
npt.assert_almost_equal(get_CM_inv(2), 0.195, decimal=3)
npt.assert_almost_equal(get_CM_inv(0), 0.232, decimal=3)
npt.assert_almost_equal(get_CM_inv(-2), 0.260, decimal=3)
npt.assert_almost_equal(get_CM_inv(-12), 0.251, decimal=3)
npt.assert_almost_equal(get_CM_inv(-18), 0)