-
-
Notifications
You must be signed in to change notification settings - Fork 282
added solar drag #388
added solar drag #388
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the code looks good. I left some comments, but the summary is:
- Simplify test code as much as possible
- Avoid using specific bodies in the docstrings (Earth & Sun), since these functions are totally general and don't depend on an special configuration.
R_Earth=Earth.R.to(u.km).value, C_R=2.0, A=2e-4, m=100, Wdivc_s=Sun.Wdivc.value, sun=sun_normalized) | ||
|
||
delta_as, delta_eccs, delta_incs, delta_raans, delta_argps, delta_hs = [], [], [], [], [], [] | ||
for ri, vi in zip(r, v): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, so this is the required code to get a time history of orbital elements... There should be an easier way to do it. Not for this pull request, of course.
@@ -168,3 +169,57 @@ def test_3rd_body_Curtis(test_params): | |||
(argp_f * u.rad).to(u.deg) - test_params['orbit'][4]], | |||
[test_params['raan'], test_params['inc'], test_params['argp']], | |||
rtol=1e-1) | |||
|
|||
|
|||
solar_pressure_checks = [{'t_days': 200, 'deltas_expected': [3e-3, -8e-3, -0.035, -80.0]}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use pytest.mark.parametrize
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we can't, because we first calculate trajectory and then check it on some special time values. If we calculate trajectory multiple times, testing would take tooooo long
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I understand. I think this could be achieved more cleanly using xunit
setup functions https://docs.pytest.org/en/latest/xunit_setup.html or fixtures https://docs.pytest.org/en/latest/fixture.html#scope-sharing-a-fixture-instance-across-tests-in-a-class-module-or-session but let's not block the pull request because of this.
{'t_days': 1095, 'deltas_expected': [0.0, 0.06, -0.165, -10.0]}, | ||
] | ||
|
||
drag_force_orbit = [10085.44 * u.km, 0.025422 * u.one, 88.3924 * u.deg, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be defined inside the test function?
@@ -99,3 +99,65 @@ def third_body(t0, state, k, k_third, third_body): | |||
body_r = third_body(t0) | |||
delta_r = body_r - state[:3] | |||
return k_third * delta_r / norm(delta_r) ** 3 - k_third * body_r / norm(body_r) ** 3 | |||
|
|||
|
|||
def shadow_function(r_sat, r_sun, R_Earth): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this apply only for the Earth? Or in fact any attractor around any star?
Parameters | ||
---------- | ||
r_sat : numpy.ndarray | ||
position of the satellite in the Earth frame (km) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above: we should avoid the Earth/Sun
terminology and use attractor/star
or similar. This should work for satellites around Mars, or around planets that orbit stars other than the Sun.
return theta < theta_1 + theta_2 | ||
|
||
|
||
def solar_pressure(t0, state, k, R_Earth, C_R, A, m, Wdivc_s, sun): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to radiation_pressure
?
r_sat = state[:3] | ||
P_s = Wdivc_s / (norm(r_sun) ** 2) | ||
|
||
nu = float(shadow_function(r_sat, r_sun, R_Earth)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart!
Also, this needs a rebase on current master. |
Codecov Report
@@ Coverage Diff @@
## master #388 +/- ##
==========================================
+ Coverage 83.44% 83.59% +0.14%
==========================================
Files 34 34
Lines 1758 1774 +16
Branches 143 143
==========================================
+ Hits 1467 1483 +16
Misses 252 252
Partials 39 39
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All tests passed now! But there's an extra import, and also this still needs a rebase on current master.
@@ -101,6 +102,7 @@ def third_body(t0, state, k, k_third, third_body): | |||
return k_third * delta_r / norm(delta_r) ** 3 - k_third * body_r / norm(body_r) ** 3 | |||
|
|||
|
|||
@jit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as a clarification, norm
is not jit-eable because it's meant to preserve units of quantities.
@@ -1,6 +1,7 @@ | |||
import pytest | |||
import functools | |||
import numpy as np | |||
import cProfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops!
Merged! Thanks @nikita-astronaut 👏 |
Seems like everything's working for now