diff --git a/README.md b/README.md
index 835c04d..631e132 100644
--- a/README.md
+++ b/README.md
@@ -26,6 +26,15 @@
- Simple customizable phased array ground stations
+- Automatically-generated thrust profiles for select orbital maneuvers:
+
+ - Continuous (low) thrust orbit raising/lowering between circular orbits
+
+ - Continuous (low) thrust maneuvers to change argument of perigee
+
+ - Note: Thrust profiles of argument of periapsis change maneuvers are calculated assuming a "continuous" maneuver takes place (i.e., a burn arc angle $\alpha = \pi/2$ radians in https://apps.dtic.mil/sti/tr/pdf/ADA384536.pdf). Therefore it is not recommended to use this feature outside of parameter ranges where this assumption does not hold.
+
+
## TO DO
- Automate code coverage badge updating via Github Actions
- Change thrust profiles to be input in the satellite body-frame
diff --git a/tests/test_coverage_detailed.PhasedArrayGroundStation.cpp.b1467fc67cdaa758f7764df5452c5918.html b/tests/test_coverage_detailed.PhasedArrayGroundStation.cpp.b1467fc67cdaa758f7764df5452c5918.html
index a184212..10c0b03 100644
--- a/tests/test_coverage_detailed.PhasedArrayGroundStation.cpp.b1467fc67cdaa758f7764df5452c5918.html
+++ b/tests/test_coverage_detailed.PhasedArrayGroundStation.cpp.b1467fc67cdaa758f7764df5452c5918.html
@@ -26,7 +26,7 @@
GCC Code Coverage Report
| Date: |
- 2025-04-22 23:09:44 |
+ 2025-05-06 17:04:10 |
@@ -669,8 +669,8 @@ GCC Code Coverage Report
1/2
-
✓ Branch 0 taken 23489550 times.
-
✗ Branch 1 not taken.
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 23489550 times.
@@ -843,8 +843,8 @@ GCC Code Coverage Report
2/2
-
✓ Branch 0 taken 13985136 times.
-
✓ Branch 1 taken 817956 times.
+
✓ Branch 0 taken 817956 times.
+
✓ Branch 1 taken 13985136 times.
@@ -1014,8 +1014,8 @@ GCC Code Coverage Report
1/2
-
✗ Branch 0 not taken.
-
✓ Branch 1 taken 1296 times.
+
✓ Branch 0 taken 1296 times.
+
✗ Branch 1 not taken.
diff --git a/tests/test_coverage_detailed.PhasedArrayGroundStation.h.5b54056581927049d160ff3354b9e6f1.html b/tests/test_coverage_detailed.PhasedArrayGroundStation.h.5b54056581927049d160ff3354b9e6f1.html
index 3a96b9e..50f909a 100644
--- a/tests/test_coverage_detailed.PhasedArrayGroundStation.h.5b54056581927049d160ff3354b9e6f1.html
+++ b/tests/test_coverage_detailed.PhasedArrayGroundStation.h.5b54056581927049d160ff3354b9e6f1.html
@@ -26,7 +26,7 @@ GCC Code Coverage Report
| Date: |
- 2025-04-22 23:09:44 |
+ 2025-05-06 17:04:10 |
diff --git a/tests/test_coverage_detailed.Satellite.cpp.bef08eb3aaec087d7cd23d21b2ecdb00.html b/tests/test_coverage_detailed.Satellite.cpp.bef08eb3aaec087d7cd23d21b2ecdb00.html
index 6c0ace4..70aa3ad 100644
--- a/tests/test_coverage_detailed.Satellite.cpp.bef08eb3aaec087d7cd23d21b2ecdb00.html
+++ b/tests/test_coverage_detailed.Satellite.cpp.bef08eb3aaec087d7cd23d21b2ecdb00.html
@@ -26,7 +26,7 @@ GCC Code Coverage Report
| Date: |
- 2025-04-22 23:09:44 |
+ 2025-05-06 17:04:10 |
@@ -40,21 +40,21 @@ GCC Code Coverage Report
| Lines: |
- 358 |
- 363 |
- 98.6% |
+ 365 |
+ 388 |
+ 94.1% |
| Functions: |
- 18 |
- 18 |
- 100.0% |
+ 19 |
+ 20 |
+ 95.0% |
| Branches: |
- 82 |
- 94 |
- 87.2% |
+ 87 |
+ 108 |
+ 80.6% |
@@ -70,24 +70,26 @@ GCC Code Coverage Report
Call count |
Block coverage |
- | Satellite::add_LVLH_thrust_profile(std::__1::array<double, 3ul>, double, double) (line 243) | called 10 times | 100.0% |
- | Satellite::add_LVLH_thrust_profile(std::__1::array<double, 3ul>, double, double, double) (line 258) | called 11 times | 100.0% |
- | Satellite::add_bodyframe_torque_profile(std::__1::array<double, 3ul>, double, double) (line 538) | called 10 times | 100.0% |
- | Satellite::add_bodyframe_torque_profile(std::__1::array<double, 3ul>, double, double, double) (line 551) | called 10 times | 85.0% |
- | Satellite::calculate_instantaneous_orbit_angular_acceleration() (line 592) | called 8948062 times | 100.0% |
- | Satellite::calculate_instantaneous_orbit_rate() (line 572) | called 8948062 times | 100.0% |
- | Satellite::calculate_orbital_period() (line 18) | called 54 times | 100.0% |
- | Satellite::calculate_perifocal_position() (line 25) | called 53 times | 100.0% |
- | Satellite::calculate_perifocal_velocity() (line 46) | called 53 times | 100.0% |
- | Satellite::convert_ECI_to_perifocal(std::__1::array<double, 3ul>) (line 114) | called 53688054 times | 100.0% |
- | Satellite::convert_perifocal_to_ECI(std::__1::array<double, 3ul>) (line 64) | called 106 times | 100.0% |
- | Satellite::evolve_RK45(double, double, bool, bool, std::__1::pair<double, double>) (line 379) | called 8948009 times | 84.0% |
- | Satellite::get_attitude_val(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 629) | called 96215 times | 84.0% |
- | Satellite::get_orbital_elements() (line 368) | called 9 times | 100.0% |
- | Satellite::get_orbital_parameter(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 513) | called 95660 times | 82.0% |
- | Satellite::initialize_and_normalize_body_quaternion(double, double, double) (line 618) | called 55 times | 100.0% |
- | Satellite::initialize_body_angular_velocity_vec_wrt_LVLH_in_body_frame() (line 655) | called 53 times | 100.0% |
- | Satellite::update_orbital_elements_from_position_and_velocity() (line 282) | called 8948011 times | 100.0% |
+ | Satellite::add_LVLH_thrust_profile(double, double, double) (line 280) | not called | 0.0% |
+ | Satellite::add_LVLH_thrust_profile(std::__1::array<double, 3ul>, double, double) (line 240) | called 10 times | 100.0% |
+ | Satellite::add_LVLH_thrust_profile(std::__1::array<double, 3ul>, double, double, double) (line 255) | called 12 times | 100.0% |
+ | Satellite::add_arg_of_periapsis_change_thrust() (line 687) | called 8948009 times | 70.0% |
+ | Satellite::add_bodyframe_torque_profile(std::__1::array<double, 3ul>, double, double) (line 561) | called 10 times | 100.0% |
+ | Satellite::add_bodyframe_torque_profile(std::__1::array<double, 3ul>, double, double, double) (line 574) | called 10 times | 85.0% |
+ | Satellite::calculate_instantaneous_orbit_angular_acceleration() (line 615) | called 8948064 times | 100.0% |
+ | Satellite::calculate_instantaneous_orbit_rate() (line 595) | called 8948064 times | 100.0% |
+ | Satellite::calculate_orbital_period() (line 18) | called 56 times | 100.0% |
+ | Satellite::calculate_perifocal_position() (line 25) | called 55 times | 100.0% |
+ | Satellite::calculate_perifocal_velocity() (line 44) | called 55 times | 100.0% |
+ | Satellite::convert_ECI_to_perifocal(std::__1::array<double, 3ul>) (line 111) | called 53688054 times | 100.0% |
+ | Satellite::convert_perifocal_to_ECI(std::__1::array<double, 3ul>) (line 61) | called 110 times | 100.0% |
+ | Satellite::evolve_RK45(double, double, bool, bool, std::__1::pair<double, double>) (line 394) | called 8948009 times | 82.0% |
+ | Satellite::get_attitude_val(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 652) | called 96215 times | 84.0% |
+ | Satellite::get_orbital_elements() (line 383) | called 9 times | 100.0% |
+ | Satellite::get_orbital_parameter(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 536) | called 95664 times | 82.0% |
+ | Satellite::initialize_and_normalize_body_quaternion(double, double, double) (line 641) | called 57 times | 100.0% |
+ | Satellite::initialize_body_angular_velocity_vec_wrt_LVLH_in_body_frame() (line 678) | called 55 times | 100.0% |
+ | Satellite::update_orbital_elements_from_position_and_velocity() (line 287) | called 8948011 times | 81.0% |
@@ -224,7 +226,7 @@ GCC Code Coverage Report
18 |
|
- 54 |
+ 56 |
double Satellite::calculate_orbital_period() { |
@@ -238,14 +240,14 @@ GCC Code Coverage Report
20 |
|
- 54 |
+ 56 |
double T = 2 * M_PI * sqrt(pow(a_, 3) / (G * mass_Earth)); |
| 21 |
|
- 54 |
+ 56 |
return T; |
@@ -273,7 +275,7 @@ GCC Code Coverage Report
25 |
|
- 53 |
+ 55 |
std::array<double, 3> Satellite::calculate_perifocal_position() { |
@@ -294,2041 +296,2069 @@ GCC Code Coverage Report
28 |
|
- 53 |
- double mu = G * mass_Earth; |
-
-
- | 29 |
-
- |
- |
- |
-
-
- | 30 |
-
- |
- 53 |
+ 55 |
double p = |
- | 31 |
+ 29 |
|
- 53 |
+ 55 |
a_ * (1 - eccentricity_) * (1 + eccentricity_); // rearranging eq. 1-47 |
- | 32 |
+ 30 |
|
|
|
- | 33 |
+ 31 |
|
- 53 |
+ 55 |
double r = p / (1 + eccentricity_ * cos(true_anomaly_)); |
- | 34 |
+ 32 |
|
|
|
- | 35 |
+ 33 |
|
- 53 |
+ 55 |
double r_perifocal_P = r * cos(true_anomaly_); |
- | 36 |
+ 34 |
|
- 53 |
+ 55 |
double r_perifocal_Q = r * sin(true_anomaly_); |
- | 37 |
+ 35 |
|
|
|
- | 38 |
+ 36 |
|
- 53 |
+ 55 |
calculated_perifocal_position.at(0) = r_perifocal_P; |
- | 39 |
+ 37 |
|
- 53 |
+ 55 |
calculated_perifocal_position.at(1) = r_perifocal_Q; |
- | 40 |
+ 38 |
|
- 53 |
+ 55 |
calculated_perifocal_position.at(2) = 0; // W component is 0 |
- | 41 |
+ 39 |
|
|
|
- | 42 |
+ 40 |
|
- 53 |
+ 55 |
return calculated_perifocal_position; |
- | 43 |
+ 41 |
|
|
} |
- | 44 |
+ 42 |
|
|
|
- | 45 |
+ 43 |
|
|
// Objective: calculate the perifocal velocity of the satellite |
- | 46 |
+ 44 |
|
- 53 |
+ 55 |
std::array<double, 3> Satellite::calculate_perifocal_velocity() { |
- | 47 |
+ 45 |
|
|
// Using approach from Fundamentals of Astrodynamics |
- | 48 |
+ 46 |
|
|
std::array<double, 3> calculated_perifocal_velocity; |
- | 49 |
-
- |
- 53 |
- double mu = G * mass_Earth; |
-
-
- | 50 |
+ 47 |
|
- 53 |
+ 55 |
double p = |
- | 51 |
+ 48 |
|
- 53 |
+ 55 |
a_ * (1 - eccentricity_) * (1 + eccentricity_); // rearranging eq. 1-47 |
- | 52 |
+ 49 |
|
- |
- |
+ 55 |
+ const double mu_Earth = G*mass_Earth; |
- | 53 |
+ 50 |
|
- 53 |
- double v_perifocal_P = sqrt(mu / p) * (-sin(true_anomaly_)); |
+ 55 |
+ double v_perifocal_P = sqrt(mu_Earth / p) * (-sin(true_anomaly_)); |
- | 54 |
+ 51 |
|
- 53 |
- double v_perifocal_Q = sqrt(mu / p) * (eccentricity_ + cos(true_anomaly_)); |
+ 55 |
+ double v_perifocal_Q = sqrt(mu_Earth / p) * (eccentricity_ + cos(true_anomaly_)); |
- | 55 |
+ 52 |
|
|
|
- | 56 |
+ 53 |
|
- 53 |
+ 55 |
calculated_perifocal_velocity.at(0) = v_perifocal_P; |
- | 57 |
+ 54 |
|
- 53 |
+ 55 |
calculated_perifocal_velocity.at(1) = v_perifocal_Q; |
- | 58 |
+ 55 |
|
- 53 |
+ 55 |
calculated_perifocal_velocity.at(2) = 0; // 0 component in the W direction |
- | 59 |
+ 56 |
|
|
|
- | 60 |
+ 57 |
|
- 53 |
+ 55 |
return calculated_perifocal_velocity; |
- | 61 |
+ 58 |
|
|
} |
- | 62 |
+ 59 |
|
|
|
- | 63 |
+ 60 |
|
|
// Objective: convert a vector from perifocal frame to ECI coordinates |
- | 64 |
+ 61 |
|
- 106 |
+ 110 |
std::array<double, 3> Satellite::convert_perifocal_to_ECI( |
- | 65 |
+ 62 |
|
|
const std::array<double, 3> input_perifocal_vec) { |
- | 66 |
+ 63 |
|
|
// Method from Fundamentals of Astrodynamics |
- | 67 |
+ 64 |
|
|
// Sounds like what they describe as their "Geocentric-Equatorial" coordinate |
- | 68 |
+ 65 |
|
|
// system is ECI |
- | 69 |
+ 66 |
|
- 106 |
+ 110 |
Matrix3d R_tilde_matrix; |
- | 70 |
+ 67 |
|
|
|
- | 71 |
+ 68 |
|
- 106 |
+ 110 |
R_tilde_matrix(0, 0) = |
- | 72 |
+ 69 |
|
- 212 |
+ 220 |
cos(raan_) * cos(arg_of_periapsis_) - |
- | 73 |
+ 70 |
|
- 106 |
+ 110 |
sin(raan_) * sin(arg_of_periapsis_) * cos(inclination_); |
- | 74 |
+ 71 |
|
|
|
- | 75 |
+ 72 |
|
- 106 |
+ 110 |
R_tilde_matrix(0, 1) = |
- | 76 |
+ 73 |
|
- 212 |
+ 220 |
-cos(raan_) * sin(arg_of_periapsis_) - |
- | 77 |
+ 74 |
|
- 106 |
+ 110 |
sin(raan_) * cos(arg_of_periapsis_) * cos(inclination_); |
- | 78 |
+ 75 |
|
|
|
- | 79 |
+ 76 |
|
- 106 |
+ 110 |
R_tilde_matrix(0, 2) = sin(raan_) * sin(inclination_); |
- | 80 |
+ 77 |
|
|
|
- | 81 |
+ 78 |
|
- 106 |
+ 110 |
R_tilde_matrix(1, 0) = |
- | 82 |
+ 79 |
|
- 212 |
+ 220 |
sin(raan_) * cos(arg_of_periapsis_) + |
- | 83 |
+ 80 |
|
- 106 |
+ 110 |
cos(raan_) * sin(arg_of_periapsis_) * cos(inclination_); |
- | 84 |
+ 81 |
|
|
|
- | 85 |
+ 82 |
|
- 106 |
+ 110 |
R_tilde_matrix(1, 1) = |
- | 86 |
+ 83 |
|
- 212 |
+ 220 |
-sin(raan_) * sin(arg_of_periapsis_) + |
- | 87 |
+ 84 |
|
- 106 |
+ 110 |
cos(raan_) * cos(arg_of_periapsis_) * cos(inclination_); |
- | 88 |
+ 85 |
|
|
|
- | 89 |
+ 86 |
|
- 106 |
+ 110 |
R_tilde_matrix(1, 2) = -cos(raan_) * sin(inclination_); |
- | 90 |
+ 87 |
|
|
|
- | 91 |
+ 88 |
|
- 106 |
+ 110 |
R_tilde_matrix(2, 0) = sin(arg_of_periapsis_) * sin(inclination_); |
- | 92 |
+ 89 |
|
|
|
- | 93 |
+ 90 |
|
- 106 |
+ 110 |
R_tilde_matrix(2, 1) = cos(arg_of_periapsis_) * sin(inclination_); |
- | 94 |
+ 91 |
|
|
|
- | 95 |
+ 92 |
|
- 106 |
+ 110 |
R_tilde_matrix(2, 2) = cos(inclination_); |
- | 96 |
+ 93 |
|
|
|
- | 97 |
+ 94 |
|
|
// convert to Eigen vectors just to make sure matrix-vector multiplication is |
- | 98 |
+ 95 |
|
|
// done correctly |
- | 99 |
+ 96 |
|
- 106 |
+ 110 |
Vector3d vector_ijk(0, 0, 0); |
- | 100 |
+ 97 |
|
- 106 |
+ 110 |
Vector3d vector_pqw(0, 0, 0); |
- | 101 |
+ 98 |
|
|
|
- | 102 |
+ 99 |
|
- 106 |
+ 110 |
vector_pqw(0) = input_perifocal_vec.at(0); |
- | 103 |
+ 100 |
|
- 106 |
+ 110 |
vector_pqw(1) = input_perifocal_vec.at(1); |
- | 104 |
+ 101 |
|
- 106 |
+ 110 |
vector_pqw(2) = input_perifocal_vec.at(2); |
- | 105 |
+ 102 |
|
|
|
- | 106 |
+ 103 |
|
- 106 |
+ 110 |
vector_ijk = R_tilde_matrix * vector_pqw; |
- | 107 |
+ 104 |
|
- 212 |
+ 220 |
std::array<double, 3> output_vector_ijk = {vector_ijk(0), vector_ijk(1), |
- | 108 |
+ 105 |
|
- 106 |
+ 110 |
vector_ijk(2)}; |
- | 109 |
+ 106 |
|
|
|
- | 110 |
+ 107 |
|
- 106 |
+ 110 |
return output_vector_ijk; |
- | 111 |
+ 108 |
|
|
} |
- | 112 |
+ 109 |
|
|
|
- | 113 |
+ 110 |
|
|
// Objective: convert vector from ECI frame to perifocal frame |
- | 114 |
+ 111 |
|
53688054 |
std::array<double, 3> Satellite::convert_ECI_to_perifocal( |
- | 115 |
+ 112 |
|
|
const std::array<double, 3> input_ECI_vec) { |
- | 116 |
+ 113 |
|
|
// Method from Fundamentals of Astrodynamics, and using |
- | 117 |
+ 114 |
|
|
// https://en.wikipedia.org/wiki/Perifocal_coordinate_system Sounds like what |
- | 118 |
+ 115 |
|
|
// they describe as their "Geocentric-Equatorial" coordinate system is ECI |
- | 119 |
+ 116 |
|
53688054 |
Matrix3d R_tilde_matrix; |
- | 120 |
+ 117 |
|
|
|
- | 121 |
+ 118 |
|
53688054 |
R_tilde_matrix(0, 0) = |
- | 122 |
+ 119 |
|
107376108 |
cos(raan_) * cos(arg_of_periapsis_) - |
- | 123 |
+ 120 |
|
53688054 |
sin(raan_) * sin(arg_of_periapsis_) * cos(inclination_); |
- | 124 |
+ 121 |
|
|
|
- | 125 |
+ 122 |
|
53688054 |
R_tilde_matrix(0, 1) = |
- | 126 |
+ 123 |
|
107376108 |
-cos(raan_) * sin(arg_of_periapsis_) - |
- | 127 |
+ 124 |
|
53688054 |
sin(raan_) * cos(arg_of_periapsis_) * cos(inclination_); |
- | 128 |
+ 125 |
|
|
|
- | 129 |
+ 126 |
|
53688054 |
R_tilde_matrix(0, 2) = sin(raan_) * sin(inclination_); |
- | 130 |
+ 127 |
|
|
|
- | 131 |
+ 128 |
|
53688054 |
R_tilde_matrix(1, 0) = |
- | 132 |
+ 129 |
|
107376108 |
sin(raan_) * cos(arg_of_periapsis_) + |
- | 133 |
+ 130 |
|
53688054 |
cos(raan_) * sin(arg_of_periapsis_) * cos(inclination_); |
- | 134 |
+ 131 |
|
|
|
- | 135 |
+ 132 |
|
53688054 |
R_tilde_matrix(1, 1) = |
- | 136 |
+ 133 |
|
107376108 |
-sin(raan_) * sin(arg_of_periapsis_) + |
- | 137 |
+ 134 |
|
53688054 |
cos(raan_) * cos(arg_of_periapsis_) * cos(inclination_); |
- | 138 |
+ 135 |
|
|
|
- | 139 |
+ 136 |
|
53688054 |
R_tilde_matrix(1, 2) = -cos(raan_) * sin(inclination_); |
- | 140 |
+ 137 |
|
|
|
- | 141 |
+ 138 |
|
53688054 |
R_tilde_matrix(2, 0) = sin(arg_of_periapsis_) * sin(inclination_); |
- | 142 |
+ 139 |
|
|
|
- | 143 |
+ 140 |
|
53688054 |
R_tilde_matrix(2, 1) = cos(arg_of_periapsis_) * sin(inclination_); |
- | 144 |
+ 141 |
|
|
|
- | 145 |
+ 142 |
|
53688054 |
R_tilde_matrix(2, 2) = cos(inclination_); |
- | 146 |
+ 143 |
|
|
|
- | 147 |
+ 144 |
|
|
// convert to Eigen vectors just to make sure matrix-vector multiplication is |
- | 148 |
+ 145 |
|
|
// done correctly |
- | 149 |
+ 146 |
|
53688054 |
Vector3d vector_ijk(0, 0, 0); |
- | 150 |
+ 147 |
|
53688054 |
Vector3d vector_pqw(0, 0, 0); |
- | 151 |
+ 148 |
|
53688054 |
vector_ijk(0) = input_ECI_vec.at(0); |
- | 152 |
+ 149 |
|
53688054 |
vector_ijk(1) = input_ECI_vec.at(1); |
- | 153 |
+ 150 |
|
53688054 |
vector_ijk(2) = input_ECI_vec.at(2); |
- | 154 |
+ 151 |
|
|
|
- | 155 |
+ 152 |
|
53688054 |
vector_pqw = (R_tilde_matrix.inverse()) * vector_ijk; |
- | 156 |
+ 153 |
|
107376108 |
std::array<double, 3> output_vector_pqw = {vector_pqw(0), vector_pqw(1), |
- | 157 |
+ 154 |
|
53688054 |
vector_pqw(2)}; |
- | 158 |
+ 155 |
|
|
|
- | 159 |
+ 156 |
|
53688054 |
return output_vector_pqw; |
- | 160 |
+ 157 |
|
|
} |
- | 161 |
+ 158 |
|
|
|
- | 162 |
+ 159 |
|
|
// Objective: evolve position and velocity (combined into one vector) one |
- | 163 |
+ 160 |
|
|
// timestep via RK4 method |
- | 164 |
+ 161 |
|
|
// void Satellite::evolve_RK4(const double input_step_size) { |
- | 165 |
+ 162 |
|
|
// // format input position and velocity arrays into single array for RK4 step |
- | 166 |
+ 163 |
|
|
// std::array<double, 6> combined_initial_position_and_velocity_array = {}; |
- | 167 |
+ 164 |
|
|
// std::pair<std::array<double, 3>, std::array<double, 3>> |
- | 168 |
+ 165 |
|
|
// output_position_velocity_pair = {}; |
- | 169 |
+ 166 |
|
|
|
- | 170 |
+ 167 |
|
|
// for (size_t ind = 0; ind < 3; ind++) { |
- | 171 |
+ 168 |
|
|
// combined_initial_position_and_velocity_array.at(ind) = |
- | 172 |
+ 169 |
|
|
// ECI_position_.at(ind); |
- | 173 |
+ 170 |
|
|
// } |
- | 174 |
+ 171 |
|
|
// for (size_t ind = 3; ind < 6; ind++) { |
- | 175 |
+ 172 |
|
|
// combined_initial_position_and_velocity_array.at(ind) = |
- | 176 |
+ 173 |
|
|
// ECI_velocity_.at(ind - 3); |
- | 177 |
+ 174 |
|
|
// } |
- | 178 |
+ 175 |
|
|
|
- | 179 |
+ 176 |
|
|
// // populate list of thrust forces at half a timestep past, for RK4 |
- | 180 |
+ 177 |
|
|
// // calculations |
- | 181 |
+ 178 |
|
|
// std::vector<std::array<double, 3>> list_of_LVLH_forces_at_half_timestep_past = |
- | 182 |
+ 179 |
|
|
// {}; |
- | 183 |
+ 180 |
|
|
// std::vector<std::array<double, 3>> list_of_ECI_forces_at_half_timestep_past = |
- | 184 |
+ 181 |
|
|
// {}; |
- | 185 |
+ 182 |
|
|
|
- | 186 |
+ 183 |
|
|
// for (const ThrustProfileLVLH thrust_profile : thrust_profile_list_) { |
- | 187 |
+ 184 |
|
|
// if (((t_ + (input_step_size / 2.0)) >= thrust_profile.t_start_) && |
- | 188 |
+ 185 |
|
|
// ((t_ + (input_step_size / 2.0)) <= thrust_profile.t_end_)) { |
- | 189 |
+ 186 |
|
|
// list_of_LVLH_forces_at_half_timestep_past.push_back( |
- | 190 |
+ 187 |
|
|
// thrust_profile.LVLH_force_vec_); |
- | 191 |
+ 188 |
|
|
// std::array<double, 3> ECI_thrust_vector = convert_LVLH_to_ECI_manual( |
- | 192 |
+ 189 |
|
|
// thrust_profile.LVLH_force_vec_, ECI_position_, ECI_velocity_); |
- | 193 |
+ 190 |
|
|
// list_of_ECI_forces_at_half_timestep_past.push_back(ECI_thrust_vector); |
- | 194 |
+ 191 |
|
|
// } |
- | 195 |
+ 192 |
|
|
// } |
- | 196 |
+ 193 |
|
|
|
- | 197 |
+ 194 |
|
|
// // populate list of thrust forces at a timestep past, for RK4 calculations |
- | 198 |
+ 195 |
|
|
// std::vector<std::array<double, 3>> list_of_LVLH_forces_at_one_timestep_past = |
- | 199 |
+ 196 |
|
|
// {}; |
- | 200 |
+ 197 |
|
|
// std::vector<std::array<double, 3>> list_of_ECI_forces_at_one_timestep_past = |
- | 201 |
+ 198 |
|
|
// {}; |
- | 202 |
+ 199 |
|
|
|
- | 203 |
+ 200 |
|
|
// for (const ThrustProfileLVLH thrust_profile : thrust_profile_list_) { |
- | 204 |
+ 201 |
|
|
// if (((t_ + input_step_size) >= thrust_profile.t_start_) && |
- | 205 |
+ 202 |
|
|
// ((t_ + input_step_size) <= thrust_profile.t_end_)) { |
- | 206 |
+ 203 |
|
|
// list_of_LVLH_forces_at_one_timestep_past.push_back( |
- | 207 |
+ 204 |
|
|
// thrust_profile.LVLH_force_vec_); |
- | 208 |
+ 205 |
|
|
// std::array<double, 3> ECI_thrust_vector = convert_LVLH_to_ECI_manual( |
- | 209 |
+ 206 |
|
|
// thrust_profile.LVLH_force_vec_, ECI_position_, ECI_velocity_); |
- | 210 |
+ 207 |
|
|
// list_of_ECI_forces_at_one_timestep_past.push_back(ECI_thrust_vector); |
- | 211 |
+ 208 |
|
|
// } |
- | 212 |
+ 209 |
|
|
// } |
- | 213 |
+ 210 |
|
|
|
- | 214 |
+ 211 |
|
|
// std::array<double, 6> output_combined_position_and_velocity_array = |
- | 215 |
+ 212 |
|
|
// RK4_step<6>(combined_initial_position_and_velocity_array, input_step_size, |
- | 216 |
+ 213 |
|
|
// RK4_deriv_function_orbit_position_and_velocity, m_, |
- | 217 |
+ 214 |
|
|
// list_of_ECI_forces_at_this_time_, |
- | 218 |
+ 215 |
|
|
// list_of_ECI_forces_at_half_timestep_past, |
- | 219 |
+ 216 |
|
|
// list_of_ECI_forces_at_one_timestep_past); |
- | 220 |
+ 217 |
|
|
// // std::array<double,6> output_combined_angular_array= |
- | 221 |
+ 218 |
|
|
// // RK4_step<6>(combined_initial_angular_array,input_step_size,RK4_deriv_function_angular,I_,list_of_body_frame_torques_at_this_time_,list_of_body_frame_torques_at_half_timestep_past,list_of_body_frame_torques_at_one_timestep_past); |
- | 222 |
+ 219 |
|
|
|
- | 223 |
+ 220 |
|
|
// for (size_t ind = 0; ind < 3; ind++) { |
- | 224 |
+ 221 |
|
|
// ECI_position_.at(ind) = output_combined_position_and_velocity_array.at(ind); |
- | 225 |
+ 222 |
|
|
// ECI_velocity_.at(ind) = |
- | 226 |
+ 223 |
|
|
// output_combined_position_and_velocity_array.at(ind + 3); |
- | 227 |
+ 224 |
|
|
// // also update the perifocal versions |
- | 228 |
+ 225 |
|
|
// perifocal_position_ = convert_ECI_to_perifocal(ECI_position_); |
- | 229 |
+ 226 |
|
|
// perifocal_velocity_ = convert_ECI_to_perifocal(ECI_velocity_); |
- | 230 |
+ 227 |
|
|
// } |
- | 231 |
+ 228 |
|
|
// t_ += input_step_size; |
- | 232 |
+ 229 |
|
|
|
- | 233 |
+ 230 |
|
|
// list_of_LVLH_forces_at_this_time_ = list_of_LVLH_forces_at_one_timestep_past; |
- | 234 |
+ 231 |
|
|
// list_of_ECI_forces_at_this_time_ = list_of_ECI_forces_at_one_timestep_past; |
- | 235 |
+ 232 |
|
|
|
- | 236 |
+ 233 |
|
|
// // Update orbital parameters |
- | 237 |
+ 234 |
|
|
// update_orbital_elements_from_position_and_velocity(); |
- | 238 |
+ 235 |
|
|
|
- | 239 |
+ 236 |
|
|
// return; |
- | 240 |
+ 237 |
|
|
// } |
- | 241 |
+ 238 |
|
|
|
- | 242 |
+ 239 |
|
|
// Objective: add a LVLH frame thrust profile to the satellite |
- | 243 |
+ 240 |
|
10 |
void Satellite::add_LVLH_thrust_profile( |
- | 244 |
+ 241 |
|
|
const std::array<double, 3> input_LVLH_thrust_vector, |
- | 245 |
+ 242 |
|
|
const double input_thrust_start_time, const double input_thrust_end_time) { |
- | 246 |
+ 243 |
|
10 |
ThrustProfileLVLH new_thrust_profile( |
- | 247 |
+ 244 |
|
10 |
input_thrust_start_time, input_thrust_end_time, input_LVLH_thrust_vector); |
- | 248 |
+ 245 |
|
10 |
thrust_profile_list_.push_back(new_thrust_profile); |
- | 249 |
+ 246 |
2/2
- ✓ Branch 0 taken 2 times.
- ✓ Branch 1 taken 8 times.
+ ✓ Branch 0 taken 8 times.
+ ✓ Branch 1 taken 2 times.
|
10 |
- if (input_thrust_start_time == 0) { |
+ if (input_thrust_start_time == t_) { |
- | 250 |
+ 247 |
|
2 |
list_of_LVLH_forces_at_this_time_.push_back(input_LVLH_thrust_vector); |
- | 251 |
+ 248 |
|
2 |
std::array<double, 3> ECI_thrust_vector = convert_LVLH_to_ECI_manual( |
- | 252 |
+ 249 |
|
2 |
input_LVLH_thrust_vector, ECI_position_, ECI_velocity_); |
- | 253 |
+ 250 |
|
2 |
list_of_ECI_forces_at_this_time_.push_back(ECI_thrust_vector); |
- | 254 |
+ 251 |
|
2 |
} |
- | 255 |
+ 252 |
|
10 |
} |
- | 256 |
+ 253 |
|
|
|
- | 257 |
+ 254 |
|
|
// Alternate input argument style |
- | 258 |
+ 255 |
|
- 11 |
+ 12 |
void Satellite::add_LVLH_thrust_profile( |
- | 259 |
+ 256 |
|
|
const std::array<double, 3> input_LVLH_normalized_thrust_direction, |
- | 260 |
+ 257 |
|
|
const double input_LVLH_thrust_magnitude, |
- | 261 |
+ 258 |
|
|
const double input_thrust_start_time, const double input_thrust_end_time) { |
- | 262 |
+ 259 |
|
- 11 |
+ 12 |
ThrustProfileLVLH new_thrust_profile( |
- | 263 |
+ 260 |
|
- 11 |
+ 12 |
input_thrust_start_time, input_thrust_end_time, |
- | 264 |
+ 261 |
|
- 11 |
+ 12 |
input_LVLH_normalized_thrust_direction, input_LVLH_thrust_magnitude); |
- | 265 |
+ 262 |
|
- 11 |
+ 12 |
thrust_profile_list_.push_back(new_thrust_profile); |
- | 266 |
+ 263 |
|
|
|
- | 267 |
+ 264 |
|
- 11 |
+ 12 |
std::array<double, 3> LVLH_thrust_vec = {0, 0, 0}; |
- | 268 |
+ 265 |
|
|
|
- | 269 |
+ 266 |
2/2
- ✓ Branch 0 taken 11 times.
- ✓ Branch 1 taken 33 times.
+ ✓ Branch 0 taken 12 times.
+ ✓ Branch 1 taken 36 times.
|
- 44 |
+ 48 |
for (size_t ind = 0; ind < 3; ind++) { |
- | 270 |
+ 267 |
|
- 66 |
+ 72 |
LVLH_thrust_vec.at(ind) = input_LVLH_thrust_magnitude * |
- | 271 |
+ 268 |
|
- 33 |
+ 36 |
input_LVLH_normalized_thrust_direction.at(ind); |
- | 272 |
+ 269 |
|
- 33 |
+ 36 |
} |
- | 273 |
+ 270 |
|
|
|
- | 274 |
+ 271 |
2/2
- ✓ Branch 0 taken 8 times.
- ✓ Branch 1 taken 3 times.
+ ✓ Branch 0 taken 4 times.
+ ✓ Branch 1 taken 8 times.
|
- 11 |
- if (input_thrust_start_time == 0) { |
+ 12 |
+ if (input_thrust_start_time == t_) { |
- | 275 |
+ 272 |
|
8 |
list_of_LVLH_forces_at_this_time_.push_back(LVLH_thrust_vec); |
- | 276 |
+ 273 |
|
8 |
std::array<double, 3> ECI_thrust_vector = convert_LVLH_to_ECI_manual( |
- | 277 |
+ 274 |
|
8 |
LVLH_thrust_vec, ECI_position_, ECI_velocity_); |
- | 278 |
+ 275 |
|
8 |
list_of_ECI_forces_at_this_time_.push_back(ECI_thrust_vector); |
- | 279 |
+ 276 |
|
8 |
} |
- | 280 |
+ 277 |
|
- 11 |
+ 12 |
} |
- | 281 |
+ 278 |
|
|
|
+
+ | 279 |
+
+ |
+ |
+ // Now the version for argument of periapsis change maneuvers |
+
+
+ | 280 |
+
+ |
+ ✗ |
+ void Satellite::add_LVLH_thrust_profile(const double input_thrust_start_time, const double final_arg_of_periapsis, |
+
+
+ | 281 |
+
+ |
+ |
+ const double input_thrust_magnitude) { |
+
| 282 |
|
- 8948011 |
- int Satellite::update_orbital_elements_from_position_and_velocity() { |
+ ✗ |
+ ThrustProfileLVLH thrust_profile(input_thrust_start_time,final_arg_of_periapsis,input_thrust_magnitude, |
| 283 |
|
- |
- // Anytime the orbit is changed via external forces, need to update the |
+ ✗ |
+ arg_of_periapsis_, eccentricity_, a_, m_); |
| 284 |
|
- |
- // orbital parameters of the satellite. True anomaly should change over time |
+ ✗ |
+ thrust_profile_list_.push_back(thrust_profile); |
| 285 |
|
- |
- // even in absence of external forces Using approach from Fundamentals of |
+ ✗ |
+ } |
| 286 |
|
|
- // Astrodynamics |
+ |
| 287 |
|
8948011 |
- int error_code = 0; // 0 represents nominal operation |
+ int Satellite::update_orbital_elements_from_position_and_velocity() { |
| 288 |
|
- 8948011 |
- double mu = G * mass_Earth; |
+ |
+ // Anytime the orbit is changed via external forces, need to update the |
| 289 |
|
|
- |
+ // orbital parameters of the satellite. True anomaly should change over time |
| 290 |
|
+ |
+ // even in absence of external forces Using approach from Fundamentals of |
+
+
+ | 291 |
+
+ |
+ |
+ // Astrodynamics |
+
+
+ | 292 |
+
+ |
+ 8948011 |
+ int error_code = 0; // 0 represents nominal operation |
+
+
+ | 293 |
+
+ |
+ 8948011 |
+ double mu_Earth = G*mass_Earth; |
+
+
+ | 294 |
+
+ |
17896022 |
Vector3d position_vector = {ECI_position_.at(0), ECI_position_.at(1), |
- | 291 |
+ 295 |
|
8948011 |
ECI_position_.at(2)}; |
- | 292 |
+ 296 |
|
17896022 |
Vector3d velocity_vector = {ECI_velocity_.at(0), ECI_velocity_.at(1), |
- | 293 |
+ 297 |
|
8948011 |
ECI_velocity_.at(2)}; |
- | 294 |
+ 298 |
|
8948011 |
Vector3d h_vector = position_vector.cross(velocity_vector); |
- | 295 |
+ 299 |
|
8948011 |
double h = h_vector.norm(); |
- | 296 |
+ 300 |
|
|
|
- | 297 |
+ 301 |
|
8948011 |
Vector3d n_vector = {-h_vector(1), h_vector(0), 0}; |
- | 298 |
+ 302 |
|
8948011 |
double n = n_vector.norm(); |
- | 299 |
+ 303 |
|
|
|
- | 300 |
+ 304 |
|
8948011 |
double v_magnitude = get_speed(); |
- | 301 |
+ 305 |
|
8948011 |
double r_magnitude = get_radius(); |
- | 302 |
+ 306 |
|
|
|
- | 303 |
+ 307 |
|
|
Vector3d e_vec_component_1 = |
- | 304 |
+ 308 |
|
8948011 |
- (1.0 / mu) * (v_magnitude * v_magnitude - (mu / r_magnitude)) * |
+ (1.0 / mu_Earth) * (v_magnitude * v_magnitude - (mu_Earth / r_magnitude)) * |
- | 305 |
+ 309 |
|
|
position_vector; |
- | 306 |
+ 310 |
|
|
Vector3d e_vec_component_2 = |
- | 307 |
+ 311 |
|
8948011 |
- (1.0 / mu) * (position_vector.dot(velocity_vector)) * velocity_vector; |
+ (1.0 / mu_Earth) * (position_vector.dot(velocity_vector)) * velocity_vector; |
- | 308 |
+ 312 |
|
8948011 |
Vector3d e_vec = e_vec_component_1 - e_vec_component_2; |
- | 309 |
+ 313 |
|
8948011 |
double calculated_eccentricity = e_vec.norm(); |
- | 310 |
+ 314 |
|
|
|
- | 311 |
+ 315 |
|
8948011 |
- double calculated_p = h * h / mu; |
+ double calculated_p = h * h / mu_Earth; |
- | 312 |
+ 316 |
|
|
|
- | 313 |
+ 317 |
|
8948011 |
double calculated_i = acos(h_vector(2) / h); |
- | 314 |
+ 318 |
|
|
|
- | 315 |
+ 319 |
|
8948011 |
double calculated_RAAN = acos(n_vector(0) / n); |
- | 316 |
+ 320 |
2/2
@@ -2342,49 +2372,49 @@ GCC Code Coverage Report
if (n_vector(1) < 0) { |
|
- | 317 |
+ 321 |
|
3820595 |
calculated_RAAN = 2 * M_PI - calculated_RAAN; |
- | 318 |
+ 322 |
|
3820595 |
} |
- | 319 |
+ 323 |
|
|
|
- | 320 |
+ 324 |
|
|
// Need to treat the e \approx 0 case (circular orbits) specially |
- | 321 |
+ 325 |
|
|
double calculated_arg_of_periapsis; |
- | 322 |
+ 326 |
|
|
double calculated_true_anomaly; |
- | 323 |
+ 327 |
2/2
@@ -2398,21 +2428,21 @@ GCC Code Coverage Report
if (calculated_eccentricity > pow(10, -15)) { |
|
- | 324 |
+ 328 |
|
8948007 |
calculated_arg_of_periapsis = |
- | 325 |
+ 329 |
|
8948007 |
acos(n_vector.dot(e_vec) / (n * calculated_eccentricity)); |
- | 326 |
+ 330 |
2/2
@@ -2426,42 +2456,126 @@ GCC Code Coverage Report
if (e_vec(2) < 0) { |
|
- | 327 |
+ 331 |
|
148 |
calculated_arg_of_periapsis = 2 * M_PI - calculated_arg_of_periapsis; |
- | 328 |
+ 332 |
|
148 |
} |
- | 329 |
+ 333 |
+
+ |
+ 17896014 |
+ calculated_true_anomaly = acos(e_vec.dot(position_vector) / |
+
+
+ | 334 |
+
+ |
+ 8948007 |
+ (calculated_eccentricity * r_magnitude)); |
+
+
+ | 335 |
+
+
+ 1/2
+
+ ✓ Branch 0 taken 8948007 times.
+ ✗ Branch 1 not taken.
+
+
+ |
+ 8948007 |
+ if (std::isnan(calculated_true_anomaly)) { |
+
+
+ | 336 |
|
|
- |
+ // First try arg of the following acos call to a float to avoid bug |
- | 330 |
+ 337 |
|
- 17896014 |
- calculated_true_anomaly = acos(e_vec.dot(position_vector) / |
+ |
+ // where it ended up being represented by a value with magnitude |
- | 331 |
+ 338 |
|
- 8948007 |
- (calculated_eccentricity * r_magnitude)); |
+ |
+ // slightly larger than one, causing NaN in output of acos |
- | 332 |
+ 339 |
+
+ |
+ ✗ |
+ float true_anomaly_acos_arg_float = e_vec.dot(position_vector) / |
+
+
+ | 340 |
+
+ |
+ ✗ |
+ (calculated_eccentricity * r_magnitude); |
+
+
+ | 341 |
+
+ |
+ ✗ |
+ calculated_true_anomaly = acos(true_anomaly_acos_arg_float); |
+
+
+ | 342 |
+
+ |
+ ✗ |
+ if (std::isnan(calculated_true_anomaly)) { |
+
+
+ | 343 |
+
+ |
+ ✗ |
+ std::cout << "NaN true anomaly encountered.\n"; |
+
+
+ | 344 |
+
+ |
+ ✗ |
+ error_code = 10; |
+
+
+ | 345 |
+
+ |
+ ✗ |
+ } |
+
+
+ | 346 |
+
+ |
+ ✗ |
+ } |
+
+
+ | 347 |
2/2
@@ -2475,105 +2589,105 @@ GCC Code Coverage Report
if (position_vector.dot(velocity_vector) < 0) { |
|
- | 333 |
+ 348 |
|
3959858 |
calculated_true_anomaly = 2 * M_PI - calculated_true_anomaly; |
- | 334 |
+ 349 |
|
3959858 |
} |
- | 335 |
+ 350 |
|
|
|
- | 336 |
+ 351 |
|
8948007 |
} else { |
- | 337 |
+ 352 |
|
|
// Approximately circular orbits |
- | 338 |
+ 353 |
|
|
// For this case, I'll set the true anomaly to be the argument of latitude |
- | 339 |
+ 354 |
|
|
// (which is valid when arg of periapsis is 0, which is what I'm setting it |
- | 340 |
+ 355 |
|
|
// to) Refs: https://en.wikipedia.org/wiki/True_anomaly#Circular_orbit , |
- | 341 |
+ 356 |
|
|
// https://en.wikipedia.org/wiki/Argument_of_latitude , |
- | 342 |
+ 357 |
|
|
// https://en.wikipedia.org/wiki/Argument_of_periapsis |
- | 343 |
+ 358 |
|
4 |
calculated_arg_of_periapsis = 0; // Setting this |
- | 344 |
+ 359 |
|
|
|
- | 345 |
+ 360 |
|
4 |
double calculated_arg_of_latitude = |
- | 346 |
+ 361 |
|
4 |
acos(n_vector.dot(position_vector) / (n * r_magnitude)); |
- | 347 |
+ 362 |
1/2
@@ -2587,413 +2701,434 @@ GCC Code Coverage Report
if (position_vector(2) < 0) { |
|
- | 348 |
+ 363 |
|
4 |
calculated_arg_of_latitude = (2 * M_PI - calculated_arg_of_latitude); |
- | 349 |
+ 364 |
|
4 |
} |
- | 350 |
+ 365 |
|
4 |
calculated_true_anomaly = calculated_arg_of_latitude; // For this case |
- | 351 |
+ 366 |
|
|
} |
- | 352 |
+ 367 |
|
|
|
- | 353 |
+ 368 |
|
8948011 |
double calculated_a = |
- | 354 |
+ 369 |
|
8948011 |
calculated_p / (1.0 - calculated_eccentricity * calculated_eccentricity); |
- | 355 |
+ 370 |
|
|
|
- | 356 |
+ 371 |
|
|
// Update stored values of these orbital elements |
- | 357 |
+ 372 |
|
|
|
- | 358 |
+ 373 |
|
8948011 |
a_ = calculated_a; |
- | 359 |
+ 374 |
|
8948011 |
eccentricity_ = calculated_eccentricity; |
- | 360 |
+ 375 |
|
8948011 |
inclination_ = calculated_i; |
- | 361 |
+ 376 |
|
8948011 |
raan_ = calculated_RAAN; |
- | 362 |
+ 377 |
|
8948011 |
arg_of_periapsis_ = calculated_arg_of_periapsis; |
- | 363 |
+ 378 |
|
8948011 |
true_anomaly_ = calculated_true_anomaly; |
- | 364 |
+ 379 |
|
|
|
- | 365 |
+ 380 |
|
8948011 |
return error_code; |
- | 366 |
+ 381 |
|
|
} |
- | 367 |
+ 382 |
|
|
|
- | 368 |
+ 383 |
|
9 |
std::array<double, 6> Satellite::get_orbital_elements() { |
- | 369 |
+ 384 |
|
|
std::array<double, 6> orbit_elems_array; |
- | 370 |
+ 385 |
|
9 |
orbit_elems_array.at(0) = a_; |
- | 371 |
+ 386 |
|
9 |
orbit_elems_array.at(1) = eccentricity_; |
- | 372 |
+ 387 |
|
9 |
orbit_elems_array.at(2) = inclination_; |
- | 373 |
+ 388 |
|
9 |
orbit_elems_array.at(3) = raan_; |
- | 374 |
+ 389 |
|
9 |
orbit_elems_array.at(4) = arg_of_periapsis_; |
- | 375 |
+ 390 |
|
9 |
orbit_elems_array.at(5) = true_anomaly_; |
- | 376 |
+ 391 |
|
9 |
return orbit_elems_array; |
- | 377 |
+ 392 |
|
|
} |
- | 378 |
+ 393 |
|
|
|
- | 379 |
+ 394 |
|
8948009 |
std::pair<double, int> Satellite::evolve_RK45( |
- | 380 |
+ 395 |
|
|
const double input_epsilon, const double input_step_size, |
- | 381 |
+ 396 |
|
|
const bool perturbation, const bool atmospheric_drag, |
- | 382 |
+ 397 |
|
|
const std::pair<double, double> drag_elements) { |
- | 383 |
+ 398 |
|
|
// perturbation is a flag which, when set to true, currently accounts for J2 |
- | 384 |
+ 399 |
|
|
// perturbation. |
- | 385 |
+ 400 |
|
|
|
- | 386 |
+ 401 |
|
|
// Let's do a single RK45_step call with y_n combined between orbital motion |
- | 387 |
+ 402 |
|
|
// and attitude variables, |
- | 388 |
+ 403 |
|
|
// y_n = {ECI_position_x, ECI_position_y, ECI_position_z, ECI_velocity_x, |
- | 389 |
+ 404 |
|
|
// ECI_velocity_y, ECI_velocity_z, q_0, q_1, q_2, q_3, omega_x, omega_y, |
- | 390 |
+ 405 |
|
|
// omega_z} Where the quaternion represents the attitude of the spacecraft |
- | 391 |
+ 406 |
|
|
// body frame with respect to the LVLH frame, and omega_i is the angular |
- | 392 |
+ 407 |
|
|
// velocity around the ith axis of the body frame with respect to the LVLH |
- | 393 |
+ 408 |
|
|
// frame, represented in the body frame |
- | 394 |
+ 409 |
|
|
|
- | 395 |
+ 410 |
|
|
// The tuple drag_elements contains the F_10 value and the A_p value used for |
- | 396 |
+ 411 |
|
|
// atmospheric drag calculations, if applicable |
- | 397 |
+ 412 |
|
|
// F_10 is the first element, A_p is the second element |
- | 398 |
+ 413 |
|
8948009 |
double input_F_10 = drag_elements.first; |
- | 399 |
+ 414 |
|
8948009 |
double input_A_p = drag_elements.second; |
- | 400 |
+ 415 |
|
|
|
- | 401 |
+ 416 |
+
+ |
+ |
+ // Add any thrusts from an argument of periapsis change maneuver, if applicable |
+
+
+ | 417 |
+
+ |
+ 8948009 |
+ int arg_of_periapsis_code = add_arg_of_periapsis_change_thrust(); |
+
+
+ | 418 |
+
+ |
+ |
+ |
+
+
+ | 419 |
|
|
std::array<double, 13> |
- | 402 |
+ 420 |
|
8948009 |
combined_initial_position_velocity_quaternion_angular_velocity_array = {}; |
- | 403 |
+ 421 |
|
|
std::pair<std::array<double, 3>, std::array<double, 3>> |
- | 404 |
+ 422 |
|
8948009 |
output_position_velocity_pair = {}; |
- | 405 |
+ 423 |
|
|
|
- | 406 |
+ 424 |
2/2
@@ -3007,28 +3142,28 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < 3; ind++) { |
|
- | 407 |
+ 425 |
|
26844027 |
combined_initial_position_velocity_quaternion_angular_velocity_array.at( |
- | 408 |
+ 426 |
|
53688054 |
ind) = ECI_position_.at(ind); |
- | 409 |
+ 427 |
|
26844027 |
} |
- | 410 |
+ 428 |
2/2
@@ -3042,28 +3177,28 @@ GCC Code Coverage Report
for (size_t ind = 3; ind < 6; ind++) { |
|
- | 411 |
+ 429 |
|
26844027 |
combined_initial_position_velocity_quaternion_angular_velocity_array.at( |
- | 412 |
+ 430 |
|
53688054 |
ind) = ECI_velocity_.at(ind - 3); |
- | 413 |
+ 431 |
|
26844027 |
} |
- | 414 |
+ 432 |
2/2
@@ -3077,35 +3212,35 @@ GCC Code Coverage Report
for (size_t ind = 6; ind < 10; ind++) { |
|
- | 415 |
+ 433 |
|
35792036 |
combined_initial_position_velocity_quaternion_angular_velocity_array.at( |
- | 416 |
+ 434 |
|
71584072 |
ind) = quaternion_satellite_bodyframe_wrt_LVLH_.at(ind - 6); |
- | 417 |
+ 435 |
|
35792036 |
} |
- | 418 |
+ 436 |
|
|
|
- | 419 |
+ 437 |
2/2
@@ -3119,167 +3254,167 @@ GCC Code Coverage Report
for (size_t ind = 10; ind < 13; ind++) { |
|
- | 420 |
+ 438 |
|
26844027 |
combined_initial_position_velocity_quaternion_angular_velocity_array.at( |
- | 421 |
+ 439 |
|
53688054 |
ind) = body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(ind - 10); |
- | 422 |
+ 440 |
|
26844027 |
} |
- | 423 |
+ 441 |
|
|
|
- | 424 |
+ 442 |
|
|
Matrix3d LVLH_to_body_transformation_matrix = |
- | 425 |
+ 443 |
|
8948009 |
LVLH_to_body_transformation_matrix_from_quaternion( |
- | 426 |
+ 444 |
|
8948009 |
quaternion_satellite_bodyframe_wrt_LVLH_); |
- | 427 |
+ 445 |
|
|
|
- | 428 |
+ 446 |
|
8948009 |
Vector3d body_angular_velocity_vec_wrt_LVLH_in_body_frame_eigenform = { |
- | 429 |
+ 447 |
|
8948009 |
body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(0), |
- | 430 |
+ 448 |
|
8948009 |
body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(1), |
- | 431 |
+ 449 |
|
8948009 |
body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(2)}; |
- | 432 |
+ 450 |
|
|
|
- | 433 |
+ 451 |
|
8948009 |
Vector3d omega_I = calculate_omega_I( |
- | 434 |
+ 452 |
|
8948009 |
body_angular_velocity_vec_wrt_LVLH_in_body_frame_eigenform, |
- | 435 |
+ 453 |
|
8948009 |
LVLH_to_body_transformation_matrix, orbital_rate_); |
- | 436 |
+ 454 |
|
|
|
- | 437 |
+ 455 |
|
8948009 |
Vector3d omega_LVLH_wrt_inertial_in_LVLH = {0, -orbital_rate_, 0}; |
- | 438 |
+ 456 |
|
|
|
- | 439 |
+ 457 |
|
8948009 |
Matrix3d J_matrix = construct_J_matrix(J_11_, J_22_, J_33_); |
- | 440 |
+ 458 |
|
|
|
- | 441 |
+ 459 |
|
|
std::pair<std::array<double, 13>, std::pair<double, double>> output_pair = |
- | 442 |
+ 460 |
1/2
- ✗ Branch 0 not taken.
- ✓ Branch 1 taken 8948009 times.
+ ✓ Branch 0 taken 8948009 times.
+ ✗ Branch 1 not taken.
|
@@ -3287,28 +3422,28 @@ GCC Code Coverage Report
RK45_step<13>( |
- | 443 |
+ 461 |
|
8948009 |
combined_initial_position_velocity_quaternion_angular_velocity_array, |
- | 444 |
+ 462 |
|
8948009 |
input_step_size, |
- | 445 |
+ 463 |
|
8948009 |
RK45_combined_orbit_position_velocity_attitude_deriv_function, |
- | 446 |
+ 464 |
3/6
@@ -3326,7 +3461,7 @@ GCC Code Coverage Report
J_matrix, bodyframe_torque_profile_list_, omega_I, |
|
- | 447 |
+ 465 |
1/2
@@ -3340,7 +3475,7 @@ GCC Code Coverage Report
orbital_angular_acceleration_, LVLH_to_body_transformation_matrix, |
|
- | 448 |
+ 466 |
2/4
@@ -3356,70 +3491,70 @@ GCC Code Coverage Report
omega_LVLH_wrt_inertial_in_LVLH, m_, thrust_profile_list_, |
|
- | 449 |
+ 467 |
|
8948009 |
inclination_, arg_of_periapsis_, true_anomaly_, input_F_10, input_A_p, |
- | 450 |
+ 468 |
|
8948009 |
A_s_, perturbation, atmospheric_drag, t_, input_epsilon); |
- | 451 |
+ 469 |
|
|
|
- | 452 |
+ 470 |
|
|
std::array<double, 13> |
- | 453 |
+ 471 |
|
|
output_combined_position_velocity_quaternion_angular_velocity_array = |
- | 454 |
+ 472 |
|
8948009 |
output_pair.first; |
- | 455 |
+ 473 |
|
8948009 |
double step_size_successfully_used_here = output_pair.second.first; |
- | 456 |
+ 474 |
|
8948009 |
double new_step_size = output_pair.second.second; |
- | 457 |
+ 475 |
|
|
|
- | 458 |
+ 476 |
2/2
@@ -3433,91 +3568,91 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < 3; ind++) { |
|
- | 459 |
+ 477 |
|
26844027 |
ECI_position_.at(ind) = |
- | 460 |
+ 478 |
|
26844027 |
output_combined_position_velocity_quaternion_angular_velocity_array.at( |
- | 461 |
+ 479 |
|
26844027 |
ind); |
- | 462 |
+ 480 |
|
26844027 |
ECI_velocity_.at(ind) = |
- | 463 |
+ 481 |
|
26844027 |
output_combined_position_velocity_quaternion_angular_velocity_array.at( |
- | 464 |
+ 482 |
|
26844027 |
ind + 3); |
- | 465 |
+ 483 |
|
|
// Also update the perifocal versions |
- | 466 |
+ 484 |
|
26844027 |
perifocal_position_ = convert_ECI_to_perifocal(ECI_position_); |
- | 467 |
+ 485 |
|
26844027 |
perifocal_velocity_ = convert_ECI_to_perifocal(ECI_velocity_); |
- | 468 |
+ 486 |
|
26844027 |
} |
- | 469 |
+ 487 |
|
8948009 |
t_ += step_size_successfully_used_here; |
- | 470 |
+ 488 |
|
|
|
- | 471 |
+ 489 |
2/2
@@ -3531,118 +3666,118 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < quaternion_satellite_bodyframe_wrt_LVLH_.size(); |
|
- | 472 |
+ 490 |
|
35792036 |
ind++) { |
- | 473 |
+ 491 |
|
35792036 |
quaternion_satellite_bodyframe_wrt_LVLH_.at(ind) = |
- | 474 |
+ 492 |
|
35792036 |
output_combined_position_velocity_quaternion_angular_velocity_array.at( |
- | 475 |
+ 493 |
|
35792036 |
ind + 6); |
- | 476 |
+ 494 |
|
35792036 |
} |
- | 477 |
+ 495 |
|
8948009 |
quaternion_satellite_bodyframe_wrt_LVLH_ = |
- | 478 |
+ 496 |
|
8948009 |
normalize_quaternion(quaternion_satellite_bodyframe_wrt_LVLH_); |
- | 479 |
+ 497 |
|
|
std::array<double, 3> updated_roll_yaw_pitch = |
- | 480 |
+ 498 |
|
8948009 |
convert_quaternion_to_roll_yaw_pitch_angles( |
- | 481 |
+ 499 |
|
8948009 |
quaternion_satellite_bodyframe_wrt_LVLH_); |
- | 482 |
+ 500 |
|
|
|
- | 483 |
+ 501 |
|
8948009 |
roll_angle_ = updated_roll_yaw_pitch.at(0); |
- | 484 |
+ 502 |
|
8948009 |
yaw_angle_ = updated_roll_yaw_pitch.at(1); |
- | 485 |
+ 503 |
|
8948009 |
pitch_angle_ = updated_roll_yaw_pitch.at(2); |
- | 486 |
+ 504 |
|
|
|
- | 487 |
+ 505 |
2/2
- ✓ Branch 0 taken 8948009 times.
- ✓ Branch 1 taken 26844027 times.
+ ✓ Branch 0 taken 26844027 times.
+ ✓ Branch 1 taken 8948009 times.
|
@@ -3650,112 +3785,112 @@ GCC Code Coverage Report
for (size_t ind = 0; |
- | 488 |
+ 506 |
|
35792036 |
ind < body_angular_velocity_vec_wrt_LVLH_in_body_frame_.size(); ind++) { |
- | 489 |
+ 507 |
|
26844027 |
body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(ind) = |
- | 490 |
+ 508 |
|
26844027 |
output_combined_position_velocity_quaternion_angular_velocity_array.at( |
- | 491 |
+ 509 |
|
26844027 |
ind + 10); |
- | 492 |
+ 510 |
|
26844027 |
} |
- | 493 |
+ 511 |
|
|
|
- | 494 |
+ 512 |
|
|
// Update orbital parameters |
- | 495 |
+ 513 |
|
8948009 |
int orbit_elems_error_code = |
- | 496 |
+ 514 |
|
8948009 |
update_orbital_elements_from_position_and_velocity(); |
- | 497 |
+ 515 |
|
8948009 |
orbital_rate_ = calculate_instantaneous_orbit_rate(); |
- | 498 |
+ 516 |
|
8948009 |
orbital_angular_acceleration_ = |
- | 499 |
+ 517 |
|
8948009 |
calculate_instantaneous_orbit_angular_acceleration(); |
- | 500 |
+ 518 |
|
8948009 |
std::pair<double, int> evolve_RK45_output_pair; |
- | 501 |
+ 519 |
|
|
// Orbital radius shouldn't be less than or equal to Earth's radius |
- | 502 |
+ 520 |
|
8948009 |
double new_orbital_radius = get_radius(); |
- | 503 |
+ 521 |
1/2
@@ -3769,119 +3904,161 @@ GCC Code Coverage Report
if (new_orbital_radius <= radius_Earth){ |
|
- | 504 |
+ 522 |
|
✗ |
orbit_elems_error_code = 2; |
- | 505 |
+ 523 |
|
✗ |
} |
- | 506 |
+ 524 |
|
8948009 |
evolve_RK45_output_pair.first = new_step_size; |
- | 507 |
+ 525 |
|
8948009 |
evolve_RK45_output_pair.second = orbit_elems_error_code; |
- | 508 |
+ 526 |
|
|
|
- | 509 |
+ 527 |
+
+ |
+ |
+ // If you just added a temporally localized thrust profile stemming from an argument of periapsis change thrust profile, |
+
+
+ | 528 |
+
+ |
+ |
+ // remove it now that it's no longer needed to avoid bloat of the thrust profile list |
+
+
+ | 529 |
+
+
+ 1/2
+
+ ✓ Branch 0 taken 8948009 times.
+ ✗ Branch 1 not taken.
+
+
+ |
+ 8948009 |
+ if (arg_of_periapsis_code == 1) { |
+
+
+ | 530 |
+
+ |
+ ✗ |
+ thrust_profile_list_.pop_back(); |
+
+
+ | 531 |
+
+ |
+ ✗ |
+ } |
+
+
+ | 532 |
|
8948009 |
return evolve_RK45_output_pair; |
- | 510 |
+ 533 |
|
✗ |
} |
- | 511 |
+ 534 |
|
|
|
- | 512 |
+ 535 |
|
|
// Returns a specific orbital element |
- | 513 |
+ 536 |
|
- 95660 |
+ 95664 |
double Satellite::get_orbital_parameter(const std::string orbital_parameter_name) { |
- | 514 |
+ 537 |
2/2
- ✓ Branch 0 taken 9348 times.
- ✓ Branch 1 taken 86312 times.
+ ✓ Branch 0 taken 9350 times.
+ ✓ Branch 1 taken 86314 times.
|
- 95660 |
+ 95664 |
if (orbital_parameter_name == "Semimajor Axis") { |
- | 515 |
+ 538 |
|
- 9348 |
+ 9350 |
return a_; |
- | 516 |
+ 539 |
2/2
- ✓ Branch 0 taken 9344 times.
+ ✓ Branch 0 taken 9346 times.
✓ Branch 1 taken 76968 times.
|
- 86312 |
+ 86314 |
} else if (orbital_parameter_name == "Eccentricity") { |
- | 517 |
+ 540 |
|
- 9344 |
+ 9346 |
return eccentricity_; |
- | 518 |
+ 541 |
2/2
@@ -3895,14 +4072,14 @@ GCC Code Coverage Report
} else if (orbital_parameter_name == "Inclination") { |
|
- | 519 |
+ 542 |
|
9344 |
return inclination_*(180/M_PI); // Returns val in degrees |
- | 520 |
+ 543 |
2/2
@@ -3916,14 +4093,14 @@ GCC Code Coverage Report
} else if (orbital_parameter_name == "RAAN") { |
|
- | 521 |
+ 544 |
|
9344 |
return raan_ * (180.0 / M_PI); // Returns val in degrees |
- | 522 |
+ 545 |
2/2
@@ -3937,14 +4114,14 @@ GCC Code Coverage Report
} else if (orbital_parameter_name == "Argument of Periapsis") { |
|
- | 523 |
+ 546 |
|
9344 |
return arg_of_periapsis_ * (180.0 / M_PI); // Returns val in degrees |
- | 524 |
+ 547 |
2/2
@@ -3958,14 +4135,14 @@ GCC Code Coverage Report
} else if (orbital_parameter_name == "True Anomaly") { |
|
- | 525 |
+ 548 |
|
20903 |
return true_anomaly_ * (180.0 / M_PI); // Returns val in degrees |
- | 526 |
+ 549 |
2/2
@@ -3979,14 +4156,14 @@ GCC Code Coverage Report
} else if (orbital_parameter_name == "Orbital Rate") { |
|
- | 527 |
+ 550 |
|
9344 |
return orbital_rate_; |
- | 528 |
+ 551 |
2/2
@@ -4000,14 +4177,14 @@ GCC Code Coverage Report
} else if (orbital_parameter_name == "Orbital Angular Acceleration") { |
|
- | 529 |
+ 552 |
|
9344 |
return orbital_angular_acceleration_; |
- | 530 |
+ 553 |
2/2
@@ -4021,21 +4198,21 @@ GCC Code Coverage Report
} else if (orbital_parameter_name == "Total Energy") { |
|
- | 531 |
+ 554 |
|
9344 |
return get_total_energy(); |
- | 532 |
+ 555 |
|
|
} else { |
- | 533 |
+ 556 |
1/2
@@ -4049,90 +4226,90 @@ GCC Code Coverage Report
throw std::invalid_argument("Value name not recognized"); |
|
- | 534 |
+ 557 |
|
|
} |
- | 535 |
+ 558 |
|
- 95659 |
+ 95663 |
} |
- | 536 |
+ 559 |
|
|
|
- | 537 |
+ 560 |
|
|
// Objective: add a body frame torque profile to the satellite |
- | 538 |
+ 561 |
|
10 |
void Satellite::add_bodyframe_torque_profile( |
- | 539 |
+ 562 |
|
|
const std::array<double, 3> input_bodyframe_torque_vector, |
- | 540 |
+ 563 |
|
|
const double input_torque_start_time, const double input_torque_end_time) { |
- | 541 |
+ 564 |
|
20 |
BodyframeTorqueProfile new_torque_profile(input_torque_start_time, |
- | 542 |
+ 565 |
|
10 |
input_torque_end_time, |
- | 543 |
+ 566 |
|
10 |
input_bodyframe_torque_vector); |
- | 544 |
+ 567 |
|
10 |
bodyframe_torque_profile_list_.push_back(new_torque_profile); |
- | 545 |
+ 568 |
2/2
- ✓ Branch 0 taken 1 times.
- ✓ Branch 1 taken 9 times.
+ ✓ Branch 0 taken 9 times.
+ ✓ Branch 1 taken 1 times.
|
@@ -4140,84 +4317,84 @@ GCC Code Coverage Report
if (input_torque_start_time == 0) { |
- | 546 |
+ 569 |
|
1 |
list_of_body_frame_torques_at_this_time_.push_back( |
- | 547 |
+ 570 |
|
|
input_bodyframe_torque_vector); |
- | 548 |
+ 571 |
|
1 |
} |
- | 549 |
+ 572 |
|
10 |
} |
- | 550 |
+ 573 |
|
|
// Alternate input argument style |
- | 551 |
+ 574 |
|
10 |
void Satellite::add_bodyframe_torque_profile( |
- | 552 |
+ 575 |
|
|
const std::array<double, 3> input_bodyframe_direction_unit_vec, |
- | 553 |
+ 576 |
|
|
const double input_bodyframe_torque_magnitude, |
- | 554 |
+ 577 |
|
|
const double input_torque_start_time, const double input_torque_end_time) { |
- | 555 |
+ 578 |
|
10 |
std::array<double, 3> input_bodyframe_torque_vector = {0, 0, 0}; |
- | 556 |
+ 579 |
|
|
|
- | 557 |
+ 580 |
2/2
@@ -4231,69 +4408,69 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < 3; ind++) { |
|
- | 558 |
+ 581 |
|
30 |
input_bodyframe_torque_vector.at(ind) = |
- | 559 |
+ 582 |
|
60 |
input_bodyframe_torque_magnitude * |
- | 560 |
+ 583 |
|
30 |
input_bodyframe_direction_unit_vec.at(ind); |
- | 561 |
+ 584 |
|
30 |
} |
- | 562 |
+ 585 |
|
20 |
BodyframeTorqueProfile new_torque_profile(input_torque_start_time, |
- | 563 |
+ 586 |
|
10 |
input_torque_end_time, |
- | 564 |
+ 587 |
|
10 |
input_bodyframe_torque_vector); |
- | 565 |
+ 588 |
|
10 |
bodyframe_torque_profile_list_.push_back(new_torque_profile); |
- | 566 |
+ 589 |
1/2
- ✗ Branch 0 not taken.
- ✓ Branch 1 taken 10 times.
+ ✓ Branch 0 taken 10 times.
+ ✗ Branch 1 not taken.
|
@@ -4301,448 +4478,448 @@ GCC Code Coverage Report
if (input_torque_start_time == 0) { |
- | 567 |
+ 590 |
|
✗ |
list_of_body_frame_torques_at_this_time_.push_back( |
- | 568 |
+ 591 |
|
|
input_bodyframe_torque_vector); |
- | 569 |
+ 592 |
|
✗ |
} |
- | 570 |
+ 593 |
|
10 |
} |
- | 571 |
+ 594 |
|
|
|
- | 572 |
+ 595 |
|
- 8948062 |
+ 8948064 |
double Satellite::calculate_instantaneous_orbit_rate() { |
- | 573 |
+ 596 |
|
|
// Need to figure out how to calculate the equivalent of w_0 in section 4.3.1 |
- | 574 |
+ 597 |
|
|
// of |
- | 575 |
+ 598 |
|
|
// https://ntrs.nasa.gov/api/citations/20240009554/downloads/Space%20Attitude%20Development%20Control.pdf |
- | 576 |
+ 599 |
|
|
// but for general elliptical orbits Is this proportional to the rate of |
- | 577 |
+ 600 |
|
|
// change of the true anomaly? Proof sketched out here: |
- | 578 |
+ 601 |
|
|
// https://space.stackexchange.com/questions/21615/how-to-calculate-the-complete-true-anomaly-motion-in-an-elliptical-orbit |
- | 579 |
+ 602 |
|
- 17896124 |
+ 17896128 |
Vector3d position_vector = {perifocal_position_.at(0), |
- | 580 |
+ 603 |
|
- 8948062 |
+ 8948064 |
perifocal_position_.at(1), |
- | 581 |
+ 604 |
|
- 8948062 |
+ 8948064 |
perifocal_position_.at(2)}; |
- | 582 |
+ 605 |
|
- 17896124 |
+ 17896128 |
Vector3d velocity_vector = {perifocal_velocity_.at(0), |
- | 583 |
+ 606 |
|
- 8948062 |
+ 8948064 |
perifocal_velocity_.at(1), |
- | 584 |
+ 607 |
|
- 8948062 |
+ 8948064 |
perifocal_velocity_.at(2)}; |
- | 585 |
+ 608 |
|
- 8948062 |
+ 8948064 |
Vector3d h_vector = position_vector.cross(velocity_vector); |
- | 586 |
+ 609 |
|
- 8948062 |
+ 8948064 |
double h = h_vector.norm(); |
- | 587 |
+ 610 |
|
- 8948062 |
+ 8948064 |
double r = get_radius(); |
- | 588 |
+ 611 |
|
- 8948062 |
+ 8948064 |
double orbit_rate = h / (r * r); |
- | 589 |
+ 612 |
|
- 8948062 |
+ 8948064 |
return orbit_rate; |
- | 590 |
+ 613 |
|
|
} |
- | 591 |
+ 614 |
|
|
|
- | 592 |
+ 615 |
|
- 8948062 |
+ 8948064 |
double Satellite::calculate_instantaneous_orbit_angular_acceleration() { |
- | 593 |
+ 616 |
|
|
// Need to figure out how to calculate the equivalent of w_0^dot to get the |
- | 594 |
+ 617 |
|
|
// w_lvlh^dot term in Ch.4 of |
- | 595 |
+ 618 |
|
|
// https://ntrs.nasa.gov/api/citations/20240009554/downloads/Space%20Attitude%20Development%20Control.pdf |
- | 596 |
+ 619 |
|
|
// but for general elliptical orbits Proof sketched out here: |
- | 597 |
+ 620 |
|
|
// https://space.stackexchange.com/questions/21615/how-to-calculate-the-complete-true-anomaly-motion-in-an-elliptical-orbit |
- | 598 |
+ 621 |
|
|
// This assumes angular momentum is constant |
- | 599 |
+ 622 |
|
- 17896124 |
+ 17896128 |
Vector3d position_vector = {perifocal_position_.at(0), |
- | 600 |
+ 623 |
|
- 8948062 |
+ 8948064 |
perifocal_position_.at(1), |
- | 601 |
+ 624 |
|
- 8948062 |
+ 8948064 |
perifocal_position_.at(2)}; |
- | 602 |
+ 625 |
|
- 17896124 |
+ 17896128 |
Vector3d velocity_vector = {perifocal_velocity_.at(0), |
- | 603 |
+ 626 |
|
- 8948062 |
+ 8948064 |
perifocal_velocity_.at(1), |
- | 604 |
+ 627 |
|
- 8948062 |
+ 8948064 |
perifocal_velocity_.at(2)}; |
- | 605 |
+ 628 |
|
- 8948062 |
+ 8948064 |
Vector3d h_vector = position_vector.cross(velocity_vector); |
- | 606 |
+ 629 |
|
- 8948062 |
+ 8948064 |
double h = h_vector.norm(); |
- | 607 |
+ 630 |
|
- 8948062 |
+ 8948064 |
double r = get_radius(); |
- | 608 |
+ 631 |
|
- 8948062 |
+ 8948064 |
Vector3d unit_position_vector = position_vector; |
- | 609 |
+ 632 |
|
- 8948062 |
+ 8948064 |
unit_position_vector.normalize(); |
- | 610 |
+ 633 |
|
- 8948062 |
+ 8948064 |
double orbit_angular_acceleration = |
- | 611 |
+ 634 |
|
- 8948062 |
+ 8948064 |
-2 * h / (r * r * r) * velocity_vector.dot(unit_position_vector); |
- | 612 |
+ 635 |
|
|
|
- | 613 |
+ 636 |
|
|
// Neglecting term relating to derivative of h for now (would be an h^dot / |
- | 614 |
+ 637 |
|
|
// r^2 term added to the above term) |
- | 615 |
+ 638 |
|
- 8948062 |
+ 8948064 |
return orbit_angular_acceleration; |
- | 616 |
+ 639 |
|
|
} |
- | 617 |
+ 640 |
|
|
|
- | 618 |
+ 641 |
|
- 55 |
+ 57 |
void Satellite::initialize_and_normalize_body_quaternion( |
- | 619 |
+ 642 |
|
|
const double roll_angle, const double pitch_angle, const double yaw_angle) { |
- | 620 |
+ 643 |
|
|
std::array<double, 4> quaternion = |
- | 621 |
+ 644 |
|
- 55 |
+ 57 |
rollyawpitch_angles_to_quaternion(roll_angle, pitch_angle, yaw_angle); |
- | 622 |
+ 645 |
|
|
std::array<double, 4> normalized_quaternion = |
- | 623 |
+ 646 |
|
- 55 |
+ 57 |
normalize_quaternion(quaternion); |
- | 624 |
+ 647 |
|
- 55 |
+ 57 |
quaternion_satellite_bodyframe_wrt_LVLH_ = normalized_quaternion; |
- | 625 |
+ 648 |
|
- 55 |
+ 57 |
return; |
- | 626 |
+ 649 |
|
|
} |
- | 627 |
+ 650 |
|
|
|
- | 628 |
+ 651 |
|
|
// Return a specific attitude-related value |
- | 629 |
+ 652 |
|
96215 |
double Satellite::get_attitude_val(std::string input_attitude_val_name) { |
- | 630 |
+ 653 |
2/2
@@ -4756,14 +4933,14 @@ GCC Code Coverage Report
if (input_attitude_val_name == "Roll") { |
|
- | 631 |
+ 654 |
|
9621 |
return roll_angle_ * (180.0 / M_PI); // Returns val in degrees |
- | 632 |
+ 655 |
2/2
@@ -4777,14 +4954,14 @@ GCC Code Coverage Report
} else if (input_attitude_val_name == "Pitch") { |
|
- | 633 |
+ 656 |
|
9625 |
return pitch_angle_ * (180.0 / M_PI); // Returns val in degrees |
- | 634 |
+ 657 |
2/2
@@ -4798,14 +4975,14 @@ GCC Code Coverage Report
} else if (input_attitude_val_name == "Yaw") { |
|
- | 635 |
+ 658 |
|
9621 |
return yaw_angle_ * (180.0 / M_PI); // Returns val in degrees |
- | 636 |
+ 659 |
2/2
@@ -4819,14 +4996,14 @@ GCC Code Coverage Report
} else if (input_attitude_val_name == "omega_x") { |
|
- | 637 |
+ 660 |
|
9621 |
return body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(0) * (180.0 / M_PI); // Returns val in degrees/s |
- | 638 |
+ 661 |
2/2
@@ -4840,14 +5017,14 @@ GCC Code Coverage Report
} else if (input_attitude_val_name == "omega_y") { |
|
- | 639 |
+ 662 |
|
9621 |
return body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(1) * (180.0 / M_PI); // Returns val in degrees/s |
- | 640 |
+ 663 |
2/2
@@ -4861,14 +5038,14 @@ GCC Code Coverage Report
} else if (input_attitude_val_name == "omega_z") { |
|
- | 641 |
+ 664 |
|
9621 |
return body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(2) * (180.0 / M_PI); // Returns val in degrees/s |
- | 642 |
+ 665 |
2/2
@@ -4882,14 +5059,14 @@ GCC Code Coverage Report
} else if (input_attitude_val_name == "q_0") { |
|
- | 643 |
+ 666 |
|
9621 |
return quaternion_satellite_bodyframe_wrt_LVLH_.at(0); |
- | 644 |
+ 667 |
2/2
@@ -4903,14 +5080,14 @@ GCC Code Coverage Report
} else if (input_attitude_val_name == "q_1") { |
|
- | 645 |
+ 668 |
|
9621 |
return quaternion_satellite_bodyframe_wrt_LVLH_.at(1); |
- | 646 |
+ 669 |
2/2
@@ -4924,14 +5101,14 @@ GCC Code Coverage Report
} else if (input_attitude_val_name == "q_2") { |
|
- | 647 |
+ 670 |
|
9621 |
return quaternion_satellite_bodyframe_wrt_LVLH_.at(2); |
- | 648 |
+ 671 |
2/2
@@ -4945,21 +5122,21 @@ GCC Code Coverage Report
} else if (input_attitude_val_name == "q_3") { |
|
- | 649 |
+ 672 |
|
9621 |
return quaternion_satellite_bodyframe_wrt_LVLH_.at(3); |
- | 650 |
+ 673 |
|
|
} else { |
- | 651 |
+ 674 |
1/2
@@ -4973,91 +5150,221 @@ GCC Code Coverage Report
throw std::invalid_argument("Value name not recognized"); |
|
- | 652 |
+ 675 |
|
|
} |
- | 653 |
+ 676 |
|
96214 |
} |
- | 654 |
+ 677 |
|
|
|
- | 655 |
+ 678 |
|
- 53 |
+ 55 |
void Satellite::initialize_body_angular_velocity_vec_wrt_LVLH_in_body_frame() { |
- | 656 |
+ 679 |
|
- 53 |
+ 55 |
std::array<double, 3> initial_body_angular_velocity_in_LVLH_frame = { |
- | 657 |
+ 680 |
|
- 53 |
+ 55 |
0, orbital_rate_, 0}; |
- | 658 |
+ 681 |
|
- 53 |
+ 55 |
body_angular_velocity_vec_wrt_LVLH_in_body_frame_ = |
- | 659 |
+ 682 |
|
- 53 |
+ 55 |
convert_array_from_LVLH_to_bodyframe( |
- | 660 |
+ 683 |
|
- 53 |
+ 55 |
initial_body_angular_velocity_in_LVLH_frame, roll_angle_, yaw_angle_, |
- | 661 |
+ 684 |
|
- 53 |
+ 55 |
pitch_angle_); // Because LVLH is always rotating around y axis to |
- | 662 |
+ 685 |
|
|
// keep z pointed towards Earth |
- | 663 |
+ 686 |
|
- 53 |
+ 55 |
} |
- | 664 |
+ 687 |
+
+ |
+ 8948009 |
+ int Satellite::add_arg_of_periapsis_change_thrust() { |
+
+
+ | 688 |
+
+ |
+ |
+ // Returning 0 means didn't find any arg of periapsis change thrust profiles |
+
+
+ | 689 |
+
+ |
+ |
+ // Returning 1 means it did find one and added a temporally localized thrust at this time |
+
+
+ | 690 |
+
+
+ 2/2
+
+ ✓ Branch 0 taken 8948009 times.
+ ✓ Branch 1 taken 7691628 times.
+
+
+ |
+ 16639637 |
+ for (ThrustProfileLVLH thrust_profile : thrust_profile_list_) { |
+
+
+ | 691 |
+
+
+ 1/6
+
+ ✗ Branch 0 not taken.
+ ✓ Branch 1 taken 7691628 times.
+ ✗ Branch 2 not taken.
+ ✗ Branch 3 not taken.
+ ✗ Branch 4 not taken.
+ ✗ Branch 5 not taken.
+
+
+ |
+ 7691628 |
+ if ((thrust_profile.arg_of_periapsis_change_thrust_profile) && (thrust_profile.t_start_ <= t_) && (thrust_profile.t_end_ >= t_)) { |
+
+
+ | 692 |
+
+ |
+ ✗ |
+ std::array<double,3> thrust_direction_vec = {sin(true_anomaly_), 0, cos(true_anomaly_)}; |
+
+
+ | 693 |
+
+ |
+ |
+ |
+
+
+ | 694 |
+
+ |
+ ✗ |
+ add_LVLH_thrust_profile(thrust_direction_vec, thrust_profile.sign_of_delta_omega*thrust_profile.thrust_magnitude_,t_,thrust_profile.t_end_); |
+
+
+ | 695 |
+
+ |
+ |
+ // can add one with t_end stretching all the way to the t_end of the total arg of periapsis change maneuver because this temporary thrust profile will |
+
+
+ | 696 |
+
+ |
+ |
+ // be deleted after this RK45 step. This end time is given so that whatever timestep is chosen for this step, all intermediate calculated steps will |
+
+
+ | 697 |
+
+ |
+ |
+ // also see this thrust. |
+
+
+ | 698 |
+
+ |
+ ✗ |
+ return 1; |
+
+
+ | 699 |
+
+ |
+ |
+ } |
+
+
+ | 700 |
+
+ |
+ |
+ } |
+
+
+ | 701 |
+
+ |
+ 8948009 |
+ return 0; |
+
+
+ | 702 |
+
+ |
+ 8948009 |
+ } |
+
+
+ | 703 |
|
|
diff --git a/tests/test_coverage_detailed.Satellite.h.016907876294210b00a2d880adf10425.html b/tests/test_coverage_detailed.Satellite.h.016907876294210b00a2d880adf10425.html
index 4ad7646..73c0fb1 100644
--- a/tests/test_coverage_detailed.Satellite.h.016907876294210b00a2d880adf10425.html
+++ b/tests/test_coverage_detailed.Satellite.h.016907876294210b00a2d880adf10425.html
@@ -26,7 +26,7 @@ GCC Code Coverage Report
| Date: |
- 2025-04-22 23:09:44 |
+ 2025-05-06 17:04:10 |
@@ -40,21 +40,21 @@ GCC Code Coverage Report
| Lines: |
- 175 |
- 175 |
- 100.0% |
+ 179 |
+ 193 |
+ 92.7% |
| Functions: |
- 18 |
- 18 |
- 100.0% |
+ 19 |
+ 20 |
+ 95.0% |
| Branches: |
107 |
- 174 |
- 61.5% |
+ 176 |
+ 60.8% |
@@ -70,24 +70,26 @@ GCC Code Coverage Report
Call count |
Block coverage |
- | BodyframeTorqueProfile::BodyframeTorqueProfile(double, double, std::__1::array<double, 3ul>) (line 58) | called 42 times | 100.0% |
- | BodyframeTorqueProfile::BodyframeTorqueProfile(double, double, std::__1::array<double, 3ul>, double) (line 64) | called 2 times | 100.0% |
- | BodyframeTorqueProfile::operator==(BodyframeTorqueProfile const&) (line 75) | called 1 time | 100.0% |
- | Satellite::Satellite(Satellite const&) (line 84) | called 26974378 times | 100.0% |
- | Satellite::Satellite(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 152) | called 124 times | 100.0% |
- | Satellite::get_ECI_position() (line 271) | called 13489787 times | 100.0% |
- | Satellite::get_instantaneous_time() (line 306) | called 22422291 times | 100.0% |
- | Satellite::get_name() (line 307) | called 2737 times | 100.0% |
- | Satellite::get_radius() (line 284) | called 35801628 times | 100.0% |
- | Satellite::get_radius_ECI() (line 291) | called 2 times | 100.0% |
- | Satellite::get_speed() (line 273) | called 8957373 times | 100.0% |
- | Satellite::get_speed_ECI() (line 280) | called 2 times | 100.0% |
- | Satellite::get_total_energy() (line 295) | called 9352 times | 100.0% |
- | Satellite::operator=(Satellite const&) (line 84) | called 2052 times | 100.0% |
- | Satellite::~Satellite() (line 84) | called 26974484 times | 100.0% |
- | ThrustProfileLVLH::ThrustProfileLVLH(double, double, std::__1::array<double, 3ul>) (line 27) | called 22 times | 100.0% |
- | ThrustProfileLVLH::ThrustProfileLVLH(double, double, std::__1::array<double, 3ul>, double) (line 33) | called 24 times | 100.0% |
- | ThrustProfileLVLH::operator==(ThrustProfileLVLH const&) (line 45) | called 1 time | 100.0% |
+ | BodyframeTorqueProfile::BodyframeTorqueProfile(double, double, std::__1::array<double, 3ul>) (line 80) | called 42 times | 100.0% |
+ | BodyframeTorqueProfile::BodyframeTorqueProfile(double, double, std::__1::array<double, 3ul>, double) (line 86) | called 2 times | 100.0% |
+ | BodyframeTorqueProfile::operator==(BodyframeTorqueProfile const&) (line 97) | called 1 time | 100.0% |
+ | Satellite::Satellite(Satellite const&) (line 106) | called 26974378 times | 100.0% |
+ | Satellite::Satellite(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 174) | called 128 times | 100.0% |
+ | Satellite::get_ECI_position() (line 293) | called 13489787 times | 100.0% |
+ | Satellite::get_instantaneous_time() (line 328) | called 22422291 times | 100.0% |
+ | Satellite::get_mass() (line 327) | called 2 times | 100.0% |
+ | Satellite::get_name() (line 329) | called 2737 times | 100.0% |
+ | Satellite::get_radius() (line 306) | called 35801632 times | 100.0% |
+ | Satellite::get_radius_ECI() (line 313) | called 2 times | 100.0% |
+ | Satellite::get_speed() (line 295) | called 8957373 times | 100.0% |
+ | Satellite::get_speed_ECI() (line 302) | called 2 times | 100.0% |
+ | Satellite::get_total_energy() (line 317) | called 9352 times | 100.0% |
+ | Satellite::operator=(Satellite const&) (line 106) | called 2052 times | 100.0% |
+ | Satellite::~Satellite() (line 106) | called 26974488 times | 100.0% |
+ | ThrustProfileLVLH::ThrustProfileLVLH(double, double, double, double, double, double, double) (line 47) | not called | 0.0% |
+ | ThrustProfileLVLH::ThrustProfileLVLH(double, double, std::__1::array<double, 3ul>) (line 30) | called 22 times | 100.0% |
+ | ThrustProfileLVLH::ThrustProfileLVLH(double, double, std::__1::array<double, 3ul>, double) (line 36) | called 26 times | 100.0% |
+ | ThrustProfileLVLH::operator==(ThrustProfileLVLH const&) (line 67) | called 1 time | 100.0% |
@@ -266,165 +268,319 @@ GCC Code Coverage Report
24 |
|
- 23 |
+ 24 |
double t_start_ = {0}; |
| 25 |
|
- 23 |
+ 24 |
double t_end_ = {0}; |
| 26 |
|
- 23 |
- std::array<double, 3> LVLH_force_vec_ = {0, 0, 0}; |
+ 24 |
+ bool arg_of_periapsis_change_thrust_profile = false; |
| 27 |
|
+ 24 |
+ double sign_of_delta_omega = {1}; |
+
+
+ | 28 |
+
+ |
+ 24 |
+ double thrust_magnitude_ = {0}; // Only used for argument of periapsis change thrust profiles |
+
+
+ | 29 |
+
+ |
+ 24 |
+ std::array<double, 3> LVLH_force_vec_ = {0, 0, 0}; |
+
+
+ | 30 |
+
+ |
22 |
ThrustProfileLVLH(const double t_start, const double t_end, |
- | 28 |
+ 31 |
|
11 |
const std::array<double, 3> LVLH_force_vec) { |
- | 29 |
+ 32 |
|
11 |
t_start_ = t_start; |
- | 30 |
+ 33 |
|
11 |
t_end_ = t_end; |
- | 31 |
+ 34 |
|
11 |
LVLH_force_vec_ = LVLH_force_vec; |
- | 32 |
+ 35 |
|
22 |
} |
- | 33 |
+ 36 |
|
- 24 |
+ 26 |
ThrustProfileLVLH( |
- | 34 |
+ 37 |
|
|
const double t_start, const double t_end, |
- | 35 |
+ 38 |
|
|
const std::array<double, 3> LVLH_normalized_force_direction_vec, |
- | 36 |
+ 39 |
|
- 12 |
+ 13 |
const double input_force_magnitude) { |
- | 37 |
+ 40 |
|
- 12 |
+ 13 |
t_start_ = t_start; |
- | 38 |
+ 41 |
|
- 12 |
+ 13 |
t_end_ = t_end; |
- | 39 |
+ 42 |
2/2
- ✓ Branch 0 taken 36 times.
- ✓ Branch 1 taken 12 times.
+ ✓ Branch 0 taken 39 times.
+ ✓ Branch 1 taken 13 times.
|
- 48 |
+ 52 |
for (size_t ind = 0; ind < 3; ind++) { |
- | 40 |
+ 43 |
|
- 36 |
+ 39 |
LVLH_force_vec_.at(ind) = |
- | 41 |
+ 44 |
|
- 36 |
+ 39 |
input_force_magnitude * LVLH_normalized_force_direction_vec.at(ind); |
- | 42 |
+ 45 |
|
- 36 |
+ 39 |
} |
- | 43 |
+ 46 |
|
- 24 |
+ 26 |
} |
- | 44 |
+ 47 |
+
+ |
+ ✗ |
+ ThrustProfileLVLH(const double t_start, const double final_arg_of_periapsis, |
+
+
+ | 48 |
|
|
- |
+ const double thrust_magnitude, const double initial_arg_of_periapsis, |
- | 45 |
+ 49 |
+
+ |
+ |
+ const double satellite_eccentricity, const double satellite_a, |
+
+
+ | 50 |
+
+ |
+ ✗ |
+ const double satellite_mass) { |
+
+
+ | 51 |
+
+ |
+ |
+ // Thrust profile for continuous-thrust argument of periapsis change |
+
+
+ | 52 |
+
+ |
+ |
+ // Main ref: https://apps.dtic.mil/sti/tr/pdf/ADA384536.pdf |
+
+
+ | 53 |
+
+ |
+ |
+ // |
+
+
+ | 54 |
+
+ |
+ |
+ // Used Eq. 67 in https://link.springer.com/article/10.1007/s10569-021-10033-9#Sec15 to determine burn angles |
+
+
+ | 55 |
+
+ |
+ ✗ |
+ arg_of_periapsis_change_thrust_profile = true; |
+
+
+ | 56 |
+
+ |
+ ✗ |
+ t_start_ = t_start; |
+
+
+ | 57 |
+
+ |
+ ✗ |
+ const double alpha = M_PI/2.0; // continous thrust |
+
+
+ | 58 |
+
+ |
+ ✗ |
+ (final_arg_of_periapsis > initial_arg_of_periapsis) ? sign_of_delta_omega = 1.0 : sign_of_delta_omega = -1.0; |
+
+
+ | 59 |
+
+ |
+ ✗ |
+ thrust_magnitude_ = thrust_magnitude; |
+
+
+ | 60 |
+
+ |
+ ✗ |
+ const double mu_Earth = G*mass_Earth; |
+
+
+ | 61 |
+
+ |
+ ✗ |
+ const double delta_omega_mag = abs(final_arg_of_periapsis - initial_arg_of_periapsis); // = delta_omega / sgn(delta_omega) |
+
+
+ | 62 |
+
+ |
+ ✗ |
+ const double delta_V = (2.0/3.0)*sqrt(mu_Earth/satellite_a)*satellite_eccentricity*delta_omega_mag/sqrt(1-satellite_eccentricity*satellite_eccentricity); |
+
+
+ | 63 |
+
+ |
+ ✗ |
+ const double acceleration = thrust_magnitude/satellite_mass; |
+
+
+ | 64 |
+
+ |
+ ✗ |
+ t_end_ = t_start + delta_V/acceleration; |
+
+
+ | 65 |
+
+ |
+ ✗ |
+ std::cout << "Transfer time: " << t_end_ << "\n"; |
+
+
+ | 66 |
+
+ |
+ ✗ |
+ } |
+
+
+ | 67 |
|
1 |
bool operator==(const ThrustProfileLVLH& input_profile) { |
- | 46 |
+ 68 |
1/2
@@ -438,13 +594,13 @@ GCC Code Coverage Report
return ((t_start_ == input_profile.t_start_) && |
|
- | 47 |
+ 69 |
1/2
- ✓ Branch 0 taken 1 times.
- ✗ Branch 1 not taken.
+ ✗ Branch 0 not taken.
+ ✓ Branch 1 taken 1 times.
|
@@ -452,161 +608,161 @@ GCC Code Coverage Report
(t_end_ == input_profile.t_end_) && |
- | 48 |
+ 70 |
|
2 |
(std::equal(LVLH_force_vec_.begin(), LVLH_force_vec_.end(), |
- | 49 |
+ 71 |
|
1 |
input_profile.LVLH_force_vec_.begin()))); |
- | 50 |
+ 72 |
|
|
} |
- | 51 |
+ 73 |
|
|
}; |
- | 52 |
+ 74 |
|
|
|
- | 53 |
+ 75 |
|
|
class BodyframeTorqueProfile { |
- | 54 |
+ 76 |
|
|
public: |
- | 55 |
+ 77 |
|
22 |
double t_start_ = {0}; |
- | 56 |
+ 78 |
|
22 |
double t_end_ = {0}; |
- | 57 |
+ 79 |
|
22 |
std::array<double, 3> bodyframe_torque_list = {0, 0, 0}; |
- | 58 |
+ 80 |
|
42 |
BodyframeTorqueProfile(const double t_start, const double t_end, |
- | 59 |
+ 81 |
|
21 |
const std::array<double, 3> bodyframe_torque_vec) { |
- | 60 |
+ 82 |
|
21 |
t_start_ = t_start; |
- | 61 |
+ 83 |
|
21 |
t_end_ = t_end; |
- | 62 |
+ 84 |
|
21 |
bodyframe_torque_list = bodyframe_torque_vec; |
- | 63 |
+ 85 |
|
42 |
} |
- | 64 |
+ 86 |
|
2 |
BodyframeTorqueProfile( |
- | 65 |
+ 87 |
|
|
const double t_start, const double t_end, |
- | 66 |
+ 88 |
|
|
const std::array<double, 3> bodyframe_normalized_torque_axis_vec, |
- | 67 |
+ 89 |
|
1 |
const double input_torque_magnitude) { |
- | 68 |
+ 90 |
|
1 |
t_start_ = t_start; |
- | 69 |
+ 91 |
|
1 |
t_end_ = t_end; |
- | 70 |
+ 92 |
2/2
@@ -620,49 +776,49 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < 3; ind++) { |
|
- | 71 |
+ 93 |
|
3 |
bodyframe_torque_list.at(ind) = |
- | 72 |
+ 94 |
|
3 |
input_torque_magnitude * bodyframe_normalized_torque_axis_vec.at(ind); |
- | 73 |
+ 95 |
|
3 |
} |
- | 74 |
+ 96 |
|
2 |
} |
- | 75 |
+ 97 |
|
1 |
bool operator==(const BodyframeTorqueProfile& input_profile) { |
- | 76 |
+ 98 |
|
1 |
return ( |
- | 77 |
+ 99 |
1/2
@@ -676,13 +832,13 @@ GCC Code Coverage Report
(t_start_ == input_profile.t_start_) && |
|
- | 78 |
+ 100 |
1/2
- ✓ Branch 0 taken 1 times.
- ✗ Branch 1 not taken.
+ ✗ Branch 0 not taken.
+ ✓ Branch 1 taken 1 times.
|
@@ -690,42 +846,42 @@ GCC Code Coverage Report
(t_end_ == input_profile.t_end_) && |
- | 79 |
+ 101 |
|
2 |
(std::equal(bodyframe_torque_list.begin(), bodyframe_torque_list.end(), |
- | 80 |
+ 102 |
|
1 |
input_profile.bodyframe_torque_list.begin()))); |
- | 81 |
+ 103 |
|
|
} |
- | 82 |
+ 104 |
|
|
}; |
- | 83 |
+ 105 |
|
|
|
- | 84 |
+ 106 |
5/10
@@ -738,8 +894,8 @@ GCC Code Coverage Report
✗ Branch 5 not taken.
✓ Branch 6 taken 13487189 times.
✗ Branch 7 not taken.
- ✗ Branch 8 not taken.
- ✓ Branch 9 taken 13487189 times.
+ ✓ Branch 8 taken 13487189 times.
+ ✗ Branch 9 not taken.
|
@@ -747,590 +903,590 @@ GCC Code Coverage Report
class Satellite { |
- | 85 |
+ 107 |
|
|
private: |
- | 86 |
+ 108 |
|
- 62 |
+ 64 |
double inclination_ = {0}; |
- | 87 |
+ 109 |
|
- 62 |
+ 64 |
double raan_ = { |
- | 88 |
+ 110 |
|
|
0}; // Assuming RAAN can be used interchangeably with longitude of |
- | 89 |
+ 111 |
|
|
// ascending node for the Earth-orbiting satellites simulated here |
- | 90 |
+ 112 |
|
- 62 |
+ 64 |
double arg_of_periapsis_ = {0}; |
- | 91 |
+ 113 |
|
- 62 |
+ 64 |
double eccentricity_ = {0}; |
- | 92 |
+ 114 |
|
- 62 |
+ 64 |
double a_ = {0}; |
- | 93 |
+ 115 |
|
- 62 |
+ 64 |
double true_anomaly_ = {0}; |
- | 94 |
+ 116 |
|
- 62 |
+ 64 |
double orbital_period_ = {0}; |
- | 95 |
+ 117 |
|
- 62 |
+ 64 |
double m_ = {1}; // default value to prevent infinities in acceleration |
- | 96 |
+ 118 |
|
|
// calculations from a=F/m |
- | 97 |
+ 119 |
|
|
// double I_={1}; //moment of inertia, taken to be same for all 3 principal |
- | 98 |
+ 120 |
|
|
// axes, set to default value for same reasons as mass |
- | 99 |
+ 121 |
|
- 62 |
+ 64 |
double t_ = {0}; |
- | 100 |
+ 122 |
|
|
|
- | 101 |
+ 123 |
|
- 62 |
+ 64 |
double orbital_rate_ = {0}; |
- | 102 |
+ 124 |
|
- 62 |
+ 64 |
double orbital_angular_acceleration_ = {0}; // Time derivative of orbital |
- | 103 |
+ 125 |
|
|
// rate |
- | 104 |
+ 126 |
|
|
|
- | 105 |
+ 127 |
|
|
// Now body-frame attributes |
- | 106 |
+ 128 |
|
|
// Assuming diagonal J matrix |
- | 107 |
+ 129 |
|
- 62 |
+ 64 |
double J_11_ = {1}; |
- | 108 |
+ 130 |
|
- 62 |
+ 64 |
double J_22_ = {1}; |
- | 109 |
+ 131 |
|
- 62 |
+ 64 |
double J_33_ = {1}; |
- | 110 |
+ 132 |
|
|
// The following angles are angles of the satellite body frame with respect to |
- | 111 |
+ 133 |
|
|
// the LVLH frame, represented in the body frame |
- | 112 |
+ 134 |
|
- 62 |
+ 64 |
double pitch_angle_ = {0}; |
- | 113 |
+ 135 |
|
- 62 |
+ 64 |
double roll_angle_ = {0}; |
- | 114 |
+ 136 |
|
- 62 |
+ 64 |
double yaw_angle_ = {0}; |
- | 115 |
+ 137 |
|
|
|
- | 116 |
+ 138 |
|
|
// For atmospheric drag calculations |
- | 117 |
+ 139 |
|
|
// Surface area of satellite assumed to face drag conditions |
- | 118 |
+ 140 |
|
- 62 |
+ 64 |
double A_s_ = {0}; |
- | 119 |
+ 141 |
|
|
|
- | 120 |
+ 142 |
|
|
// body-frame angular velocities relative to the LVLH frame, represented in |
- | 121 |
+ 143 |
|
|
// the body frame |
- | 122 |
+ 144 |
|
- 62 |
+ 64 |
std::array<double, 3> body_angular_velocity_vec_wrt_LVLH_in_body_frame_ = { |
- | 123 |
+ 145 |
|
- 62 |
+ 64 |
0, 0, 0}; |
- | 124 |
+ 146 |
|
|
|
- | 125 |
+ 147 |
|
|
// quaternion representing attitude of satellite body frame with respect to |
- | 126 |
+ 148 |
|
|
// the LVLH frame |
- | 127 |
+ 149 |
|
|
std::array<double, 4> quaternion_satellite_bodyframe_wrt_LVLH_; |
- | 128 |
+ 150 |
|
|
|
- | 129 |
+ 151 |
|
- 62 |
+ 64 |
std::string name_ = ""; |
- | 130 |
+ 152 |
|
|
|
- | 131 |
+ 153 |
|
- 62 |
+ 64 |
std::array<double, 3> perifocal_position_ = {0, 0, 0}; |
- | 132 |
+ 154 |
|
- 62 |
+ 64 |
std::array<double, 3> perifocal_velocity_ = {0, 0, 0}; |
- | 133 |
+ 155 |
|
|
|
- | 134 |
+ 156 |
|
- 62 |
+ 64 |
std::array<double, 3> ECI_position_ = {0, 0, 0}; |
- | 135 |
+ 157 |
|
- 62 |
+ 64 |
std::array<double, 3> ECI_velocity_ = {0, 0, 0}; |
- | 136 |
+ 158 |
|
|
|
- | 137 |
+ 159 |
|
- 62 |
+ 64 |
std::vector<ThrustProfileLVLH> thrust_profile_list_ = {}; |
- | 138 |
+ 160 |
|
- 62 |
+ 64 |
std::vector<BodyframeTorqueProfile> bodyframe_torque_profile_list_ = {}; |
- | 139 |
+ 161 |
|
|
|
- | 140 |
+ 162 |
|
- 62 |
+ 64 |
std::vector<std::array<double, 3>> list_of_LVLH_forces_at_this_time_ = {}; |
- | 141 |
+ 163 |
|
- 62 |
+ 64 |
std::vector<std::array<double, 3>> list_of_ECI_forces_at_this_time_ = {}; |
- | 142 |
+ 164 |
|
- 62 |
+ 64 |
std::vector<std::array<double, 3>> list_of_body_frame_torques_at_this_time_ = |
- | 143 |
+ 165 |
|
|
{}; |
- | 144 |
+ 166 |
|
|
|
- | 145 |
+ 167 |
|
- 62 |
+ 64 |
double drag_surface_area = {0}; // Surface area of satellite used for |
- | 146 |
+ 168 |
|
|
// atmospheric drag calculations |
- | 147 |
+ 169 |
|
|
|
- | 148 |
+ 170 |
|
|
void initialize_body_angular_velocity_vec_wrt_LVLH_in_body_frame(); |
- | 149 |
+ 171 |
|
|
|
- | 150 |
+ 172 |
|
|
public: |
- | 151 |
+ 173 |
1/2
- ✓ Branch 0 taken 62 times.
+ ✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
|
- 62 |
+ 64 |
std::string plotting_color_ = ""; |
- | 152 |
+ 174 |
|
- 186 |
+ 192 |
Satellite(const std::string input_file_name) { |
- | 153 |
+ 175 |
|
|
// baselining JSON input file format specifying initial orbital parameters |
- | 154 |
+ 176 |
|
|
// of satellite semimajor axis is read in units of km angles are read in |
- | 155 |
+ 177 |
|
|
// units of degrees, then internally translated to radians |
- | 156 |
+ 178 |
1/2
- ✓ Branch 0 taken 62 times.
+ ✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
|
- 62 |
+ 64 |
std::ifstream input_filestream(input_file_name); |
- | 157 |
+ 179 |
1/2
- ✓ Branch 0 taken 62 times.
+ ✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
|
- 62 |
+ 64 |
json input_data = json::parse(input_filestream); |
- | 158 |
+ 180 |
|
|
|
- | 159 |
+ 181 |
3/4
- ✓ Branch 0 taken 61 times.
+ ✓ Branch 0 taken 63 times.
✓ Branch 1 taken 1 times.
- ✓ Branch 2 taken 61 times.
+ ✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
|
- 62 |
+ 64 |
inclination_ = input_data.at("Inclination"); |
- | 160 |
+ 182 |
|
|
// convert to radians |
- | 161 |
+ 183 |
|
- 61 |
+ 63 |
inclination_ *= (M_PI / 180.0); |
- | 162 |
+ 184 |
2/2
- ✓ Branch 0 taken 60 times.
+ ✓ Branch 0 taken 62 times.
✓ Branch 1 taken 1 times.
|
- 61 |
+ 63 |
if (inclination_ == 0) { |
- | 163 |
+ 185 |
2/4
@@ -1346,259 +1502,259 @@ GCC Code Coverage Report
throw std::invalid_argument( |
|
- | 164 |
+ 186 |
|
|
"Zero inclination orbits are not currently supported"); |
- | 165 |
+ 187 |
|
|
} |
- | 166 |
+ 188 |
|
|
|
- | 167 |
+ 189 |
3/4
- ✓ Branch 0 taken 59 times.
+ ✓ Branch 0 taken 61 times.
✓ Branch 1 taken 1 times.
- ✓ Branch 2 taken 59 times.
+ ✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
|
- 60 |
+ 62 |
raan_ = input_data.at("RAAN"); |
- | 168 |
+ 190 |
|
|
// convert to radians |
- | 169 |
+ 191 |
|
- 59 |
+ 61 |
raan_ *= (M_PI / 180.0); |
- | 170 |
+ 192 |
|
|
|
- | 171 |
+ 193 |
3/4
- ✓ Branch 0 taken 58 times.
+ ✓ Branch 0 taken 60 times.
✓ Branch 1 taken 1 times.
- ✓ Branch 2 taken 58 times.
+ ✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
|
- 59 |
+ 61 |
arg_of_periapsis_ = input_data.at("Argument of Periapsis"); |
- | 172 |
+ 194 |
|
|
// convert to radians |
- | 173 |
+ 195 |
|
- 58 |
+ 60 |
arg_of_periapsis_ *= (M_PI / 180.0); |
- | 174 |
+ 196 |
|
|
|
- | 175 |
+ 197 |
3/4
- ✓ Branch 0 taken 57 times.
+ ✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
- ✓ Branch 2 taken 57 times.
+ ✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
|
- 58 |
+ 60 |
eccentricity_ = input_data.at("Eccentricity"); |
- | 176 |
+ 198 |
|
|
// If circular orbit, arg of periapsis is undefined, using convention of |
- | 177 |
+ 199 |
|
|
// setting it to 0 in this case |
- | 178 |
+ 200 |
2/2
- ✓ Branch 0 taken 44 times.
- ✓ Branch 1 taken 13 times.
+ ✓ Branch 0 taken 45 times.
+ ✓ Branch 1 taken 14 times.
|
- 57 |
+ 59 |
if (eccentricity_ == 0) { |
- | 179 |
+ 201 |
|
- 13 |
+ 14 |
arg_of_periapsis_ = 0; |
- | 180 |
+ 202 |
|
- 13 |
+ 14 |
} |
- | 181 |
+ 203 |
|
|
|
- | 182 |
+ 204 |
3/4
- ✓ Branch 0 taken 56 times.
+ ✓ Branch 0 taken 58 times.
✓ Branch 1 taken 1 times.
- ✓ Branch 2 taken 56 times.
+ ✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
|
- 57 |
+ 59 |
a_ = input_data.at("Semimajor Axis"); |
- | 183 |
+ 205 |
|
- 56 |
+ 58 |
a_ *= 1000.0; // converting from km to m |
- | 184 |
+ 206 |
|
|
|
- | 185 |
+ 207 |
3/4
- ✓ Branch 0 taken 55 times.
+ ✓ Branch 0 taken 57 times.
✓ Branch 1 taken 1 times.
- ✓ Branch 2 taken 55 times.
+ ✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
|
- 56 |
+ 58 |
true_anomaly_ = input_data.at("True Anomaly"); |
- | 186 |
+ 208 |
|
|
// convert to radians |
- | 187 |
+ 209 |
|
- 55 |
+ 57 |
true_anomaly_ *= (M_PI / 180.0); |
- | 188 |
+ 210 |
|
|
|
- | 189 |
+ 211 |
|
|
// making initial pitch angle an optional parameter |
- | 190 |
+ 212 |
4/6
- ✓ Branch 0 taken 55 times.
+ ✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 55 times.
+ ✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
- ✓ Branch 5 taken 47 times.
+ ✓ Branch 5 taken 49 times.
|
- 55 |
+ 57 |
if (input_data.find("Initial Pitch Angle") != input_data.end()) { |
- | 191 |
+ 213 |
2/4
@@ -1614,53 +1770,53 @@ GCC Code Coverage Report
pitch_angle_ = input_data.at("Initial Pitch Angle"); |
|
- | 192 |
+ 214 |
|
|
// convert to radians |
- | 193 |
+ 215 |
|
8 |
pitch_angle_ *= (M_PI / 180.0); |
- | 194 |
+ 216 |
|
8 |
} |
- | 195 |
+ 217 |
|
|
// making initial roll angle an optional parameter |
- | 196 |
+ 218 |
4/6
- ✓ Branch 0 taken 55 times.
+ ✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 55 times.
+ ✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
- ✓ Branch 5 taken 47 times.
+ ✓ Branch 5 taken 49 times.
|
- 55 |
+ 57 |
if (input_data.find("Initial Roll Angle") != input_data.end()) { |
- | 197 |
+ 219 |
2/4
@@ -1676,53 +1832,53 @@ GCC Code Coverage Report
roll_angle_ = input_data.at("Initial Roll Angle"); |
|
- | 198 |
+ 220 |
|
|
// convert to radians |
- | 199 |
+ 221 |
|
8 |
roll_angle_ *= (M_PI / 180.0); |
- | 200 |
+ 222 |
|
8 |
} |
- | 201 |
+ 223 |
|
|
// making initial yaw angle an optional parameter |
- | 202 |
+ 224 |
4/6
- ✓ Branch 0 taken 55 times.
+ ✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 55 times.
+ ✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
- ✓ Branch 5 taken 47 times.
+ ✓ Branch 5 taken 49 times.
|
- 55 |
+ 57 |
if (input_data.find("Initial Yaw Angle") != input_data.end()) { |
- | 203 |
+ 225 |
2/4
@@ -1738,129 +1894,129 @@ GCC Code Coverage Report
yaw_angle_ = input_data.at("Initial Yaw Angle"); |
|
- | 204 |
+ 226 |
|
|
// convert to radians |
- | 205 |
+ 227 |
|
8 |
yaw_angle_ *= (M_PI / 180.0); |
- | 206 |
+ 228 |
|
8 |
} |
- | 207 |
+ 229 |
|
|
|
- | 208 |
+ 230 |
2/4
- ✓ Branch 0 taken 55 times.
+ ✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 55 times.
+ ✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
|
- 110 |
+ 114 |
initialize_and_normalize_body_quaternion(roll_angle_, pitch_angle_, |
- | 209 |
+ 231 |
|
- 55 |
+ 57 |
yaw_angle_); |
- | 210 |
+ 232 |
|
|
|
- | 211 |
+ 233 |
3/4
- ✓ Branch 0 taken 54 times.
+ ✓ Branch 0 taken 56 times.
✓ Branch 1 taken 1 times.
- ✓ Branch 2 taken 54 times.
+ ✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
|
- 55 |
+ 57 |
m_ = input_data.at("Mass"); |
- | 212 |
+ 234 |
3/4
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✓ Branch 1 taken 1 times.
- ✓ Branch 2 taken 53 times.
+ ✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
|
- 54 |
+ 56 |
name_ = input_data.at("Name"); |
- | 213 |
+ 235 |
|
|
|
- | 214 |
+ 236 |
|
|
// Making plotting color an optional parameter |
- | 215 |
+ 237 |
4/6
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 53 times.
+ ✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
- ✓ Branch 5 taken 41 times.
+ ✓ Branch 5 taken 43 times.
|
- 53 |
+ 55 |
if (input_data.find("Plotting Color") != input_data.end()) { |
- | 216 |
+ 238 |
2/4
@@ -1876,53 +2032,53 @@ GCC Code Coverage Report
plotting_color_ = input_data.at("Plotting Color"); |
|
- | 217 |
+ 239 |
|
12 |
} |
- | 218 |
+ 240 |
|
|
|
- | 219 |
+ 241 |
|
|
// Making satellite surface area facing drag conditions an optional |
- | 220 |
+ 242 |
|
|
// parameter |
- | 221 |
+ 243 |
4/6
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 53 times.
+ ✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
- ✓ Branch 5 taken 39 times.
+ ✓ Branch 5 taken 41 times.
|
- 53 |
+ 55 |
if (input_data.find("A_s") != input_data.end()) { |
- | 222 |
+ 244 |
2/4
@@ -1938,193 +2094,193 @@ GCC Code Coverage Report
A_s_ = input_data.at("A_s"); |
|
- | 223 |
+ 245 |
|
14 |
} |
- | 224 |
+ 246 |
|
|
|
- | 225 |
+ 247 |
|
- 53 |
+ 55 |
t_ = 0; // for now, assuming satellites are initialized at time t=0; |
- | 226 |
+ 248 |
|
|
|
- | 227 |
+ 249 |
1/2
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
|
- 53 |
+ 55 |
orbital_period_ = calculate_orbital_period(); |
- | 228 |
+ 250 |
|
|
|
- | 229 |
+ 251 |
|
|
// updated workflow |
- | 230 |
+ 252 |
1/2
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
|
- 53 |
+ 55 |
perifocal_position_ = calculate_perifocal_position(); |
- | 231 |
+ 253 |
1/2
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
|
- 53 |
+ 55 |
perifocal_velocity_ = calculate_perifocal_velocity(); |
- | 232 |
+ 254 |
|
|
|
- | 233 |
+ 255 |
1/2
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
|
- 53 |
+ 55 |
ECI_position_ = convert_perifocal_to_ECI(perifocal_position_); |
- | 234 |
+ 256 |
1/2
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
|
- 53 |
+ 55 |
ECI_velocity_ = convert_perifocal_to_ECI(perifocal_velocity_); |
- | 235 |
+ 257 |
|
|
|
- | 236 |
+ 258 |
1/2
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
|
- 53 |
+ 55 |
orbital_rate_ = calculate_instantaneous_orbit_rate(); |
- | 237 |
+ 259 |
1/2
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
|
- 53 |
+ 55 |
initialize_body_angular_velocity_vec_wrt_LVLH_in_body_frame(); |
- | 238 |
+ 260 |
|
|
// making initial omega_x an optional parameter |
- | 239 |
+ 261 |
4/6
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 53 times.
+ ✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
- ✓ Branch 5 taken 45 times.
+ ✓ Branch 5 taken 47 times.
|
- 53 |
+ 55 |
if (input_data.find("Initial omega_x") != input_data.end()) { |
- | 240 |
+ 262 |
|
8 |
double initial_omega_x_wrt_LVLH_in_body_frame = |
- | 241 |
+ 263 |
2/4
@@ -2140,21 +2296,21 @@ GCC Code Coverage Report
input_data.at("Initial omega_x"); |
|
- | 242 |
+ 264 |
|
|
// convert to radians/s |
- | 243 |
+ 265 |
|
8 |
initial_omega_x_wrt_LVLH_in_body_frame *= (M_PI / 180.0); |
- | 244 |
+ 266 |
1/2
@@ -2168,53 +2324,53 @@ GCC Code Coverage Report
body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(0) += |
|
- | 245 |
+ 267 |
|
8 |
initial_omega_x_wrt_LVLH_in_body_frame; |
- | 246 |
+ 268 |
|
8 |
} |
- | 247 |
+ 269 |
|
|
// making initial omega_y an optional parameter |
- | 248 |
+ 270 |
4/6
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 53 times.
+ ✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
- ✓ Branch 5 taken 45 times.
+ ✓ Branch 5 taken 47 times.
|
- 53 |
+ 55 |
if (input_data.find("Initial omega_y") != input_data.end()) { |
- | 249 |
+ 271 |
|
8 |
double initial_omega_y_wrt_LVLH_in_body_frame = |
- | 250 |
+ 272 |
2/4
@@ -2230,21 +2386,21 @@ GCC Code Coverage Report
input_data.at("Initial omega_y"); |
|
- | 251 |
+ 273 |
|
|
// convert to radians/s |
- | 252 |
+ 274 |
|
8 |
initial_omega_y_wrt_LVLH_in_body_frame *= (M_PI / 180.0); |
- | 253 |
+ 275 |
1/2
@@ -2258,60 +2414,60 @@ GCC Code Coverage Report
body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(1) += |
|
- | 254 |
+ 276 |
|
8 |
initial_omega_y_wrt_LVLH_in_body_frame; |
- | 255 |
+ 277 |
|
8 |
} |
- | 256 |
+ 278 |
|
|
|
- | 257 |
+ 279 |
|
|
// making initial omega_z an optional parameter |
- | 258 |
+ 280 |
4/6
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 53 times.
+ ✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
- ✓ Branch 5 taken 45 times.
+ ✓ Branch 5 taken 47 times.
|
- 53 |
+ 55 |
if (input_data.find("Initial omega_z") != input_data.end()) { |
- | 259 |
+ 281 |
|
8 |
double initial_omega_z_wrt_LVLH_in_body_frame = |
- | 260 |
+ 282 |
2/4
@@ -2327,21 +2483,21 @@ GCC Code Coverage Report
input_data.at("Initial omega_z"); |
|
- | 261 |
+ 283 |
|
|
// convert to radians/s |
- | 262 |
+ 284 |
|
8 |
initial_omega_z_wrt_LVLH_in_body_frame *= (M_PI / 180.0); |
- | 263 |
+ 285 |
1/2
@@ -2355,707 +2511,721 @@ GCC Code Coverage Report
body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(2) += |
|
- | 264 |
+ 286 |
|
8 |
initial_omega_z_wrt_LVLH_in_body_frame; |
- | 265 |
+ 287 |
|
8 |
} |
- | 266 |
+ 288 |
|
|
|
- | 267 |
+ 289 |
|
- 53 |
+ 55 |
orbital_angular_acceleration_ = |
- | 268 |
+ 290 |
1/2
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
|
- 53 |
+ 55 |
calculate_instantaneous_orbit_angular_acceleration(); |
- | 269 |
+ 291 |
|
- 124 |
+ 128 |
} |
- | 270 |
+ 292 |
|
|
|
- | 271 |
+ 293 |
|
13489787 |
std::array<double, 3> get_ECI_position() { return ECI_position_; } |
- | 272 |
+ 294 |
|
|
std::array<double, 3> get_ECI_velocity() { return ECI_velocity_; } |
- | 273 |
+ 295 |
|
8957373 |
double get_speed() { |
- | 274 |
+ 296 |
|
|
// shouldn't matter which frame I use, might as well use perifocal coords |
- | 275 |
+ 297 |
|
|
// since it's fewer operations (no W-direction component so can omit that |
- | 276 |
+ 298 |
|
|
// term, whereas there's x,y,z components in ECI) |
- | 277 |
+ 299 |
|
17914746 |
return sqrt(pow(perifocal_velocity_.at(0), 2) + |
- | 278 |
+ 300 |
|
8957373 |
pow(perifocal_velocity_.at(1), 2)); |
- | 279 |
+ 301 |
|
|
} |
- | 280 |
+ 302 |
|
2 |
double get_speed_ECI() { |
- | 281 |
+ 303 |
|
4 |
return sqrt(pow(ECI_velocity_.at(0), 2) + pow(ECI_velocity_.at(1), 2) + |
- | 282 |
+ 304 |
|
2 |
pow(ECI_velocity_.at(2), 2)); |
- | 283 |
+ 305 |
|
|
} |
- | 284 |
+ 306 |
|
- 35801628 |
+ 35801632 |
double get_radius() { |
- | 285 |
+ 307 |
|
|
// shouldn't matter which frame I use, might as well use perifocal coords |
- | 286 |
+ 308 |
|
|
// since it's fewer operations (no W-direction component so can omit that |
- | 287 |
+ 309 |
|
|
// term, whereas there's x,y,z components in ECI) |
- | 288 |
+ 310 |
|
- 71603256 |
+ 71603264 |
return sqrt(pow(perifocal_position_.at(0), 2) + |
- | 289 |
+ 311 |
|
- 35801628 |
+ 35801632 |
pow(perifocal_position_.at(1), 2)); |
- | 290 |
+ 312 |
|
|
} |
- | 291 |
+ 313 |
|
2 |
double get_radius_ECI() { |
- | 292 |
+ 314 |
|
4 |
return sqrt(pow(ECI_position_.at(0), 2) + pow(ECI_position_.at(1), 2) + |
- | 293 |
+ 315 |
|
2 |
pow(ECI_position_.at(2), 2)); |
- | 294 |
+ 316 |
|
|
} |
- | 295 |
+ 317 |
|
9352 |
double get_total_energy() { |
- | 296 |
+ 318 |
|
9352 |
double orbital_radius = get_radius(); |
- | 297 |
+ 319 |
|
9352 |
double gravitational_potential_energy = |
- | 298 |
+ 320 |
|
9352 |
-G * mass_Earth * m_ / orbital_radius; |
- | 299 |
+ 321 |
|
|
|
- | 300 |
+ 322 |
|
9352 |
double orbital_speed = get_speed(); |
- | 301 |
+ 323 |
|
9352 |
double kinetic_energy = (1.0 / 2.0) * m_ * (orbital_speed * orbital_speed); |
- | 302 |
+ 324 |
|
|
|
- | 303 |
+ 325 |
|
9352 |
return (gravitational_potential_energy + kinetic_energy); |
- | 304 |
+ 326 |
|
|
} |
- | 305 |
+ 327 |
|
- |
- |
+ 2 |
+ double get_mass() { return m_; } |
- | 306 |
+ 328 |
|
22422291 |
double get_instantaneous_time() { return t_; } |
- | 307 |
+ 329 |
|
2737 |
std::string get_name() { return name_; } |
- | 308 |
+ 330 |
|
|
// void evolve_RK4(const double input_timestep); |
- | 309 |
+ 331 |
|
|
|
- | 310 |
+ 332 |
|
|
std::array<double, 3> body_frame_to_ECI( |
- | 311 |
+ 333 |
|
|
const std::array<double, 3> input_vector); |
- | 312 |
+ 334 |
|
|
|
- | 313 |
+ 335 |
|
|
std::array<double, 3> ECI_to_body_frame( |
- | 314 |
+ 336 |
|
|
const std::array<double, 3> input_vector); |
- | 315 |
+ 337 |
|
|
|
- | 316 |
+ 338 |
|
|
std::array<double, 3> calculate_perifocal_position(); |
- | 317 |
+ 339 |
|
|
|
- | 318 |
+ 340 |
|
|
std::array<double, 3> calculate_perifocal_velocity(); |
- | 319 |
+ 341 |
|
|
|
- | 320 |
+ 342 |
|
|
std::array<double, 3> convert_perifocal_to_ECI( |
- | 321 |
+ 343 |
|
|
const std::array<double, 3> input_perifocal_vec); |
- | 322 |
+ 344 |
|
|
std::array<double, 3> convert_ECI_to_perifocal( |
- | 323 |
+ 345 |
|
|
const std::array<double, 3> input_ECI_vec); |
- | 324 |
+ 346 |
|
|
|
- | 325 |
+ 347 |
|
|
// std::array<double,3> convert_LVLH_to_ECI(std::array<double,3> |
- | 326 |
+ 348 |
|
|
// input_LVLH_vec); |
- | 327 |
+ 349 |
|
|
|
- | 328 |
+ 350 |
|
|
void add_LVLH_thrust_profile( |
- | 329 |
+ 351 |
|
|
const std::array<double, 3> input_LVLH_normalized_thrust_direction, |
- | 330 |
+ 352 |
|
|
const double input_LVLH_thrust_magnitude, |
- | 331 |
+ 353 |
|
|
const double input_thrust_start_time, const double input_thrust_end_time); |
- | 332 |
+ 354 |
|
|
void add_LVLH_thrust_profile( |
- | 333 |
+ 355 |
|
|
const std::array<double, 3> input_LVLH_thrust_vector, |
- | 334 |
+ 356 |
|
|
const double input_thrust_start_time, const double input_thrust_end_time); |
- | 335 |
+ 357 |
|
|
- |
+ void add_LVLH_thrust_profile(const double input_thrust_start_time, const double final_arg_of_periapsis, |
- | 336 |
+ 358 |
+
+ |
+ |
+ const double input_thrust_magnitude); |
+
+
+ | 359 |
|
|
void add_bodyframe_torque_profile( |
- | 337 |
+ 360 |
|
|
const std::array<double, 3> input_bodyframe_direction_unit_vec, |
- | 338 |
+ 361 |
|
|
const double input_bodyframe_torque_magnitude, |
- | 339 |
+ 362 |
|
|
const double input_torque_start_time, const double input_torque_end_time); |
- | 340 |
+ 363 |
|
|
void add_bodyframe_torque_profile( |
- | 341 |
+ 364 |
|
|
const std::array<double, 3> input_bodyframe_torque_vector, |
- | 342 |
+ 365 |
|
|
const double input_torque_start_time, const double input_torque_end_time); |
- | 343 |
+ 366 |
|
|
|
- | 344 |
+ 367 |
|
|
int update_orbital_elements_from_position_and_velocity(); |
- | 345 |
+ 368 |
|
|
std::array<double, 6> get_orbital_elements(); |
- | 346 |
+ 369 |
|
|
|
- | 347 |
+ 370 |
|
|
std::pair<double, int> evolve_RK45( |
- | 348 |
+ 371 |
|
|
const double input_epsilon, const double input_initial_timestep, |
- | 349 |
+ 372 |
|
|
const bool perturbation = true, const bool atmospheric_drag = false, |
- | 350 |
+ 373 |
|
|
std::pair<double, double> drag_elements = {}); |
- | 351 |
+ 374 |
|
|
|
- | 352 |
+ 375 |
|
|
double get_orbital_parameter(const std::string orbital_parameter_name); |
- | 353 |
+ 376 |
|
|
double calculate_instantaneous_orbit_rate(); |
- | 354 |
+ 377 |
|
|
double calculate_instantaneous_orbit_angular_acceleration(); |
- | 355 |
+ 378 |
|
|
void initialize_and_normalize_body_quaternion(const double roll_angle, |
- | 356 |
+ 379 |
|
|
const double pitch_angle, |
- | 357 |
+ 380 |
|
|
const double yaw_angle); |
- | 358 |
+ 381 |
|
|
double get_attitude_val(const std::string input_attitude_val_name); |
- | 359 |
+ 382 |
|
|
double calculate_orbital_period(); |
- | 360 |
+ 383 |
+
+ |
+ |
+ int add_arg_of_periapsis_change_thrust(); |
+
+
+ | 384 |
|
|
}; |
- | 361 |
+ 385 |
|
|
|
- | 362 |
+ 386 |
|
|
#endif |
- | 363 |
+ 387 |
|
|
diff --git a/tests/test_coverage_detailed.functions.html b/tests/test_coverage_detailed.functions.html
index 5469c08..3c95629 100644
--- a/tests/test_coverage_detailed.functions.html
+++ b/tests/test_coverage_detailed.functions.html
@@ -22,7 +22,7 @@ GCC Code Coverage Report
| Date: |
- 2025-04-22 23:09:44 |
+ 2025-05-06 17:04:10 |
@@ -37,21 +37,21 @@ GCC Code Coverage Report
| Lines: |
- 1540 |
- 1603 |
- 96.1% |
+ 1618 |
+ 1766 |
+ 91.6% |
| Functions: |
- 73 |
- 73 |
- 100.0% |
+ 78 |
+ 81 |
+ 96.3% |
| Branches: |
- 816 |
- 1383 |
- 59.0% |
+ 784 |
+ 1321 |
+ 59.3% |
@@ -67,10 +67,10 @@ GCC Code Coverage Report
Call count |
Block coverage |
- | BodyframeTorqueProfile::BodyframeTorqueProfile(double, double, std::__1::array<double, 3ul>) (include/Satellite.h:58) | called 42 times | 100.0% |
- | BodyframeTorqueProfile::BodyframeTorqueProfile(double, double, std::__1::array<double, 3ul>, double) (include/Satellite.h:64) | called 2 times | 100.0% |
- | BodyframeTorqueProfile::operator==(BodyframeTorqueProfile const&) (include/Satellite.h:75) | called 1 time | 100.0% |
- | LVLH_to_body_transformation_matrix_from_quaternion(std::__1::array<double, 4ul>) (src/utils.cpp:913) | called 8948009 times | 81.0% |
+ | BodyframeTorqueProfile::BodyframeTorqueProfile(double, double, std::__1::array<double, 3ul>) (include/Satellite.h:80) | called 42 times | 100.0% |
+ | BodyframeTorqueProfile::BodyframeTorqueProfile(double, double, std::__1::array<double, 3ul>, double) (include/Satellite.h:86) | called 2 times | 100.0% |
+ | BodyframeTorqueProfile::operator==(BodyframeTorqueProfile const&) (include/Satellite.h:97) | called 1 time | 100.0% |
+ | LVLH_to_body_transformation_matrix_from_quaternion(std::__1::array<double, 4ul>) (src/utils.cpp:921) | called 8948009 times | 81.0% |
| PhasedArrayGroundStation::PhasedArrayGroundStation(PhasedArrayGroundStation const&) (include/PhasedArrayGroundStation.h:11) | called 648 times | 100.0% |
| PhasedArrayGroundStation::PhasedArrayGroundStation(double, double, double, double, int) (include/PhasedArrayGroundStation.h:28) | called 10 times | 100.0% |
| PhasedArrayGroundStation::angle_to_satellite_from_normal(Satellite) (src/PhasedArrayGroundStation.cpp:34) | called 8749080 times | 100.0% |
@@ -80,66 +80,74 @@ GCC Code Coverage Report
| PhasedArrayGroundStation::num_sats_connected_at_this_time(double) (src/PhasedArrayGroundStation.cpp:70) | called 8747784 times | 84.0% |
| PhasedArrayGroundStation::update_linked_sats_map(unsigned long, double, double) (src/PhasedArrayGroundStation.cpp:112) | called 714942 times | 77.0% |
| PhasedArrayGroundStation::~PhasedArrayGroundStation() (include/PhasedArrayGroundStation.h:11) | called 658 times | 100.0% |
- | RK45_combined_orbit_position_velocity_attitude_deriv_function(std::__1::array<double, 13ul>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, double, bool, bool) (src/utils.cpp:1089) | called 54944076 times | 88.0% |
- | RK45_deriv_function_orbit_position_and_velocity(std::__1::array<double, 6ul>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, double, double, bool, bool) (src/utils.cpp:345) | called 54944076 times | 83.0% |
- | RK45_satellite_body_angular_deriv_function(std::__1::array<double, 7ul>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (src/utils.cpp:1021) | called 54944076 times | 87.0% |
- | Satellite::Satellite(Satellite const&) (include/Satellite.h:84) | called 26974378 times | 100.0% |
- | Satellite::Satellite(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (include/Satellite.h:152) | called 124 times | 100.0% |
- | Satellite::add_LVLH_thrust_profile(std::__1::array<double, 3ul>, double, double) (src/Satellite.cpp:243) | called 10 times | 100.0% |
- | Satellite::add_LVLH_thrust_profile(std::__1::array<double, 3ul>, double, double, double) (src/Satellite.cpp:258) | called 11 times | 100.0% |
- | Satellite::add_bodyframe_torque_profile(std::__1::array<double, 3ul>, double, double) (src/Satellite.cpp:538) | called 10 times | 100.0% |
- | Satellite::add_bodyframe_torque_profile(std::__1::array<double, 3ul>, double, double, double) (src/Satellite.cpp:551) | called 10 times | 85.0% |
- | Satellite::calculate_instantaneous_orbit_angular_acceleration() (src/Satellite.cpp:592) | called 8948062 times | 100.0% |
- | Satellite::calculate_instantaneous_orbit_rate() (src/Satellite.cpp:572) | called 8948062 times | 100.0% |
- | Satellite::calculate_orbital_period() (src/Satellite.cpp:18) | called 54 times | 100.0% |
- | Satellite::calculate_perifocal_position() (src/Satellite.cpp:25) | called 53 times | 100.0% |
- | Satellite::calculate_perifocal_velocity() (src/Satellite.cpp:46) | called 53 times | 100.0% |
- | Satellite::convert_ECI_to_perifocal(std::__1::array<double, 3ul>) (src/Satellite.cpp:114) | called 53688054 times | 100.0% |
- | Satellite::convert_perifocal_to_ECI(std::__1::array<double, 3ul>) (src/Satellite.cpp:64) | called 106 times | 100.0% |
- | Satellite::evolve_RK45(double, double, bool, bool, std::__1::pair<double, double>) (src/Satellite.cpp:379) | called 8948009 times | 84.0% |
- | Satellite::get_ECI_position() (include/Satellite.h:271) | called 13489787 times | 100.0% |
- | Satellite::get_attitude_val(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/Satellite.cpp:629) | called 96215 times | 84.0% |
- | Satellite::get_instantaneous_time() (include/Satellite.h:306) | called 22422291 times | 100.0% |
- | Satellite::get_name() (include/Satellite.h:307) | called 2737 times | 100.0% |
- | Satellite::get_orbital_elements() (src/Satellite.cpp:368) | called 9 times | 100.0% |
- | Satellite::get_orbital_parameter(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/Satellite.cpp:513) | called 95660 times | 82.0% |
- | Satellite::get_radius() (include/Satellite.h:284) | called 35801628 times | 100.0% |
- | Satellite::get_radius_ECI() (include/Satellite.h:291) | called 2 times | 100.0% |
- | Satellite::get_speed() (include/Satellite.h:273) | called 8957373 times | 100.0% |
- | Satellite::get_speed_ECI() (include/Satellite.h:280) | called 2 times | 100.0% |
- | Satellite::get_total_energy() (include/Satellite.h:295) | called 9352 times | 100.0% |
- | Satellite::initialize_and_normalize_body_quaternion(double, double, double) (src/Satellite.cpp:618) | called 55 times | 100.0% |
- | Satellite::initialize_body_angular_velocity_vec_wrt_LVLH_in_body_frame() (src/Satellite.cpp:655) | called 53 times | 100.0% |
- | Satellite::operator=(Satellite const&) (include/Satellite.h:84) | called 2052 times | 100.0% |
- | Satellite::update_orbital_elements_from_position_and_velocity() (src/Satellite.cpp:282) | called 8948011 times | 100.0% |
- | Satellite::~Satellite() (include/Satellite.h:84) | called 26974484 times | 100.0% |
- | ThrustProfileLVLH::ThrustProfileLVLH(double, double, std::__1::array<double, 3ul>) (include/Satellite.h:27) | called 22 times | 100.0% |
- | ThrustProfileLVLH::ThrustProfileLVLH(double, double, std::__1::array<double, 3ul>, double) (include/Satellite.h:33) | called 24 times | 100.0% |
- | ThrustProfileLVLH::operator==(ThrustProfileLVLH const&) (include/Satellite.h:45) | called 1 time | 100.0% |
- | calculate_omega_I(Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, double) (src/utils.cpp:1066) | called 8948009 times | 100.0% |
- | calculate_orbital_acceleration(std::__1::array<double, 3ul>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, std::__1::array<double, 3ul>, double, double, double, double, double, double, double, bool, bool) (src/utils.cpp:154) | called 54944076 times | 97.0% |
- | calculate_spacecraft_bodyframe_angular_acceleration(Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (src/utils.cpp:934) | called 54944076 times | 100.0% |
- | construct_J_matrix(double, double, double) (src/utils.cpp:1079) | called 8948009 times | 100.0% |
- | convert_ECEF_to_ECI(Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (src/utils.cpp:1224) | called 13480446 times | 100.0% |
- | convert_LVLH_to_ECI_manual(std::__1::array<double, 3ul>, std::__1::array<double, 3ul>, std::__1::array<double, 3ul>) (src/utils.cpp:37) | called 1939922 times | 75.0% |
- | convert_array_from_LVLH_to_bodyframe(std::__1::array<double, 3ul>, double, double, double) (src/utils.cpp:1193) | called 53 times | 100.0% |
- | convert_cylindrical_to_cartesian(double, double, double, double) (src/utils.cpp:133) | called 36697692 times | 100.0% |
- | convert_lat_long_to_ECEF(double, double, double) (src/utils.cpp:1209) | called 5 times | 100.0% |
- | convert_quaternion_to_roll_yaw_pitch_angles(std::__1::array<double, 4ul>) (src/utils.cpp:1162) | called 8948009 times | 100.0% |
- | normalize_quaternion(std::__1::array<double, 4ul>) (src/utils.cpp:1150) | called 8948064 times | 100.0% |
- | quaternion_kinematics_equation(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>) (src/utils.cpp:992) | called 54944076 times | 77.0% |
- | quaternion_multiplication(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 4, 1, 0, 4, 1>) (src/utils.cpp:15) | called 110 times | 77.0% |
- | rollyawpitch_angles_to_quaternion(double, double, double) (src/utils.cpp:897) | called 55 times | 100.0% |
- | rollyawpitch_bodyframe_to_LVLH_matrix(double, double, double) (src/utils.cpp:875) | called 53 times | 100.0% |
- | sim_and_draw_orbit_gnuplot(std::__1::vector<Satellite, std::__1::allocator<Satellite>>, double, double, double, bool, bool, std::__1::pair<double, double>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/utils.cpp:381) | called 18 times | 78.0% |
- | sim_and_plot_attitude_evolution_gnuplot(std::__1::vector<Satellite, std::__1::allocator<Satellite>>, double, double, double, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, bool, bool, std::__1::pair<double, double>) (src/utils.cpp:723) | called 180 times | 77.0% |
- | sim_and_plot_gs_connectivity_distance_gnuplot(PhasedArrayGroundStation, std::__1::vector<Satellite, std::__1::allocator<Satellite>>, double, double, double, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, bool, bool, std::__1::pair<double, double>) (src/utils.cpp:1241) | called 162 times | 73.0% |
- | sim_and_plot_gs_connectivity_gnuplot(PhasedArrayGroundStation, std::__1::vector<Satellite, std::__1::allocator<Satellite>>, double, double, double, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, bool, bool, std::__1::pair<double, double>) (src/utils.cpp:1402) | called 162 times | 75.0% |
- | sim_and_plot_orbital_elem_gnuplot(std::__1::vector<Satellite, std::__1::allocator<Satellite>>, double, double, double, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, bool, bool, std::__1::pair<double, double>) (src/utils.cpp:545) | called 162 times | 76.0% |
- | std::__1::pair<std::__1::array<double, 13>, std::__1::pair<double, double>> RK45_step<13>(std::__1::array<double, 13>, double, std::__1::function<std::__1::array<double, 13> (std::__1::array<double, 13>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, double, bool, bool)>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, bool, double, double, double) (include/utils.h:302) | called 9157346 times | 87.0% |
- | x_rot_matrix(double) (src/utils.cpp:712) | called 53 times | 81.0% |
- | y_rot_matrix(double) (src/utils.cpp:704) | called 53 times | 81.0% |
- | z_rot_matrix(double) (src/utils.cpp:695) | called 13480499 times | 81.0% |
+ | RK45_combined_orbit_position_velocity_attitude_deriv_function(std::__1::array<double, 13ul>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, double, bool, bool) (src/utils.cpp:1097) | called 54944076 times | 88.0% |
+ | RK45_deriv_function_orbit_position_and_velocity(std::__1::array<double, 6ul>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, double, double, bool, bool) (src/utils.cpp:347) | called 54944076 times | 83.0% |
+ | RK45_satellite_body_angular_deriv_function(std::__1::array<double, 7ul>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (src/utils.cpp:1029) | called 54944076 times | 87.0% |
+ | Satellite::Satellite(Satellite const&) (include/Satellite.h:106) | called 26974378 times | 100.0% |
+ | Satellite::Satellite(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (include/Satellite.h:174) | called 128 times | 100.0% |
+ | Satellite::add_LVLH_thrust_profile(double, double, double) (src/Satellite.cpp:280) | not called | 0.0% |
+ | Satellite::add_LVLH_thrust_profile(std::__1::array<double, 3ul>, double, double) (src/Satellite.cpp:240) | called 10 times | 100.0% |
+ | Satellite::add_LVLH_thrust_profile(std::__1::array<double, 3ul>, double, double, double) (src/Satellite.cpp:255) | called 12 times | 100.0% |
+ | Satellite::add_arg_of_periapsis_change_thrust() (src/Satellite.cpp:687) | called 8948009 times | 70.0% |
+ | Satellite::add_bodyframe_torque_profile(std::__1::array<double, 3ul>, double, double) (src/Satellite.cpp:561) | called 10 times | 100.0% |
+ | Satellite::add_bodyframe_torque_profile(std::__1::array<double, 3ul>, double, double, double) (src/Satellite.cpp:574) | called 10 times | 85.0% |
+ | Satellite::calculate_instantaneous_orbit_angular_acceleration() (src/Satellite.cpp:615) | called 8948064 times | 100.0% |
+ | Satellite::calculate_instantaneous_orbit_rate() (src/Satellite.cpp:595) | called 8948064 times | 100.0% |
+ | Satellite::calculate_orbital_period() (src/Satellite.cpp:18) | called 56 times | 100.0% |
+ | Satellite::calculate_perifocal_position() (src/Satellite.cpp:25) | called 55 times | 100.0% |
+ | Satellite::calculate_perifocal_velocity() (src/Satellite.cpp:44) | called 55 times | 100.0% |
+ | Satellite::convert_ECI_to_perifocal(std::__1::array<double, 3ul>) (src/Satellite.cpp:111) | called 53688054 times | 100.0% |
+ | Satellite::convert_perifocal_to_ECI(std::__1::array<double, 3ul>) (src/Satellite.cpp:61) | called 110 times | 100.0% |
+ | Satellite::evolve_RK45(double, double, bool, bool, std::__1::pair<double, double>) (src/Satellite.cpp:394) | called 8948009 times | 82.0% |
+ | Satellite::get_ECI_position() (include/Satellite.h:293) | called 13489787 times | 100.0% |
+ | Satellite::get_attitude_val(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/Satellite.cpp:652) | called 96215 times | 84.0% |
+ | Satellite::get_instantaneous_time() (include/Satellite.h:328) | called 22422291 times | 100.0% |
+ | Satellite::get_mass() (include/Satellite.h:327) | called 2 times | 100.0% |
+ | Satellite::get_name() (include/Satellite.h:329) | called 2737 times | 100.0% |
+ | Satellite::get_orbital_elements() (src/Satellite.cpp:383) | called 9 times | 100.0% |
+ | Satellite::get_orbital_parameter(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/Satellite.cpp:536) | called 95664 times | 82.0% |
+ | Satellite::get_radius() (include/Satellite.h:306) | called 35801632 times | 100.0% |
+ | Satellite::get_radius_ECI() (include/Satellite.h:313) | called 2 times | 100.0% |
+ | Satellite::get_speed() (include/Satellite.h:295) | called 8957373 times | 100.0% |
+ | Satellite::get_speed_ECI() (include/Satellite.h:302) | called 2 times | 100.0% |
+ | Satellite::get_total_energy() (include/Satellite.h:317) | called 9352 times | 100.0% |
+ | Satellite::initialize_and_normalize_body_quaternion(double, double, double) (src/Satellite.cpp:641) | called 57 times | 100.0% |
+ | Satellite::initialize_body_angular_velocity_vec_wrt_LVLH_in_body_frame() (src/Satellite.cpp:678) | called 55 times | 100.0% |
+ | Satellite::operator=(Satellite const&) (include/Satellite.h:106) | called 2052 times | 100.0% |
+ | Satellite::update_orbital_elements_from_position_and_velocity() (src/Satellite.cpp:287) | called 8948011 times | 81.0% |
+ | Satellite::~Satellite() (include/Satellite.h:106) | called 26974488 times | 100.0% |
+ | SimParameters::SimParameters(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (include/utils.h:33) | called 10 times | 100.0% |
+ | SimParameters::~SimParameters() (include/utils.h:20) | called 10 times | 100.0% |
+ | ThrustProfileLVLH::ThrustProfileLVLH(double, double, double, double, double, double, double) (include/Satellite.h:47) | not called | 0.0% |
+ | ThrustProfileLVLH::ThrustProfileLVLH(double, double, std::__1::array<double, 3ul>) (include/Satellite.h:30) | called 22 times | 100.0% |
+ | ThrustProfileLVLH::ThrustProfileLVLH(double, double, std::__1::array<double, 3ul>, double) (include/Satellite.h:36) | called 26 times | 100.0% |
+ | ThrustProfileLVLH::operator==(ThrustProfileLVLH const&) (include/Satellite.h:67) | called 1 time | 100.0% |
+ | add_lowthrust_orbit_transfer(Satellite&, double, double, double) (src/utils.cpp:1573) | called 2 times | 55.0% |
+ | calculate_omega_I(Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, double) (src/utils.cpp:1074) | called 8948009 times | 100.0% |
+ | calculate_orbital_acceleration(std::__1::array<double, 3ul>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, std::__1::array<double, 3ul>, double, double, double, double, double, double, double, bool, bool) (src/utils.cpp:155) | called 54944076 times | 97.0% |
+ | calculate_spacecraft_bodyframe_angular_acceleration(Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (src/utils.cpp:942) | called 54944076 times | 100.0% |
+ | calibrate_mean_val(Satellite, SimParameters const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/utils.cpp:1617) | not called | 0.0% |
+ | construct_J_matrix(double, double, double) (src/utils.cpp:1087) | called 8948009 times | 100.0% |
+ | convert_ECEF_to_ECI(Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (src/utils.cpp:1232) | called 13480446 times | 100.0% |
+ | convert_LVLH_to_ECI_manual(std::__1::array<double, 3ul>, std::__1::array<double, 3ul>, std::__1::array<double, 3ul>) (src/utils.cpp:38) | called 1939922 times | 75.0% |
+ | convert_array_from_LVLH_to_bodyframe(std::__1::array<double, 3ul>, double, double, double) (src/utils.cpp:1201) | called 55 times | 100.0% |
+ | convert_cylindrical_to_cartesian(double, double, double, double) (src/utils.cpp:134) | called 36697692 times | 100.0% |
+ | convert_lat_long_to_ECEF(double, double, double) (src/utils.cpp:1217) | called 5 times | 100.0% |
+ | convert_quaternion_to_roll_yaw_pitch_angles(std::__1::array<double, 4ul>) (src/utils.cpp:1170) | called 8948009 times | 100.0% |
+ | normalize_quaternion(std::__1::array<double, 4ul>) (src/utils.cpp:1158) | called 8948066 times | 100.0% |
+ | quaternion_kinematics_equation(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>) (src/utils.cpp:1000) | called 54944076 times | 77.0% |
+ | quaternion_multiplication(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 4, 1, 0, 4, 1>) (src/utils.cpp:16) | called 114 times | 77.0% |
+ | rollyawpitch_angles_to_quaternion(double, double, double) (src/utils.cpp:905) | called 57 times | 100.0% |
+ | rollyawpitch_bodyframe_to_LVLH_matrix(double, double, double) (src/utils.cpp:883) | called 55 times | 100.0% |
+ | sim_and_draw_orbit_gnuplot(std::__1::vector<Satellite, std::__1::allocator<Satellite>>, SimParameters const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/utils.cpp:383) | called 18 times | 79.0% |
+ | sim_and_plot_attitude_evolution_gnuplot(std::__1::vector<Satellite, std::__1::allocator<Satellite>>, SimParameters const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/utils.cpp:733) | called 180 times | 82.0% |
+ | sim_and_plot_gs_connectivity_distance_gnuplot(PhasedArrayGroundStation, std::__1::vector<Satellite, std::__1::allocator<Satellite>>, SimParameters const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/utils.cpp:1249) | called 162 times | 77.0% |
+ | sim_and_plot_gs_connectivity_gnuplot(PhasedArrayGroundStation, std::__1::vector<Satellite, std::__1::allocator<Satellite>>, SimParameters const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/utils.cpp:1409) | called 162 times | 81.0% |
+ | sim_and_plot_orbital_elem_gnuplot(std::__1::vector<Satellite, std::__1::allocator<Satellite>>, SimParameters const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/utils.cpp:555) | called 162 times | 81.0% |
+ | std::__1::pair<std::__1::array<double, 13>, std::__1::pair<double, double>> RK45_step<13>(std::__1::array<double, 13>, double, std::__1::function<std::__1::array<double, 13> (std::__1::array<double, 13>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, double, bool, bool)>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, bool, double, double, double) (include/utils.h:346) | called 9157346 times | 87.0% |
+ | x_rot_matrix(double) (src/utils.cpp:722) | called 55 times | 81.0% |
+ | y_rot_matrix(double) (src/utils.cpp:714) | called 55 times | 81.0% |
+ | z_rot_matrix(double) (src/utils.cpp:705) | called 13480501 times | 81.0% |
diff --git a/tests/test_coverage_detailed.html b/tests/test_coverage_detailed.html
index f02fabd..267aefd 100644
--- a/tests/test_coverage_detailed.html
+++ b/tests/test_coverage_detailed.html
@@ -22,7 +22,7 @@ GCC Code Coverage Report
| Date: |
- 2025-04-22 23:09:44 |
+ 2025-05-06 17:04:10 |
| Coverage: |
@@ -45,21 +45,21 @@ GCC Code Coverage Report
| Lines: |
- 1540 |
- 1603 |
- 96.1% |
+ 1618 |
+ 1766 |
+ 91.6% |
| Functions: |
- 73 |
- 73 |
- 100.0% |
+ 78 |
+ 81 |
+ 96.3% |
| Branches: |
- 816 |
- 1383 |
- 59.0% |
+ 784 |
+ 1321 |
+ 59.3% |
@@ -105,14 +105,14 @@ GCC Code Coverage Report
include/Satellite.h
- 100.0
+ 92.7
|
- 100.0% |
- 175 / 175 |
- 100.0% |
- 18 / 18 |
- 61.5% |
- 107 / 174 |
+ 92.7% |
+ 179 / 193 |
+ 95.0% |
+ 19 / 20 |
+ 60.8% |
+ 107 / 176 |
@@ -121,14 +121,14 @@ GCC Code Coverage Report
include/utils.h
- 100.0
+ 93.8
|
- 100.0% |
- 87 / 87 |
+ 93.8% |
+ 121 / 129 |
100.0% |
- 1 / 1 |
- 57.8% |
- 74 / 128 |
+ 3 / 3 |
+ 50.9% |
+ 113 / 222 |
@@ -153,14 +153,14 @@ GCC Code Coverage Report
src/Satellite.cpp
- 98.6
+ 94.1
|
- 98.6% |
- 358 / 363 |
- 100.0% |
- 18 / 18 |
- 87.2% |
- 82 / 94 |
+ 94.1% |
+ 365 / 388 |
+ 95.0% |
+ 19 / 20 |
+ 80.6% |
+ 87 / 108 |
@@ -169,14 +169,14 @@ GCC Code Coverage Report
src/utils.cpp
- 93.6
+ 89.5
|
- 93.6% |
- 836 / 893 |
- 100.0% |
- 27 / 27 |
- 55.1% |
- 511 / 928 |
+ 89.5% |
+ 869 / 971 |
+ 96.6% |
+ 28 / 29 |
+ 57.5% |
+ 435 / 756 |
diff --git a/tests/test_coverage_detailed.utils.cpp.4d3039dff574b788948119de402ca8d9.html b/tests/test_coverage_detailed.utils.cpp.4d3039dff574b788948119de402ca8d9.html
index fdf7121..c79b88a 100644
--- a/tests/test_coverage_detailed.utils.cpp.4d3039dff574b788948119de402ca8d9.html
+++ b/tests/test_coverage_detailed.utils.cpp.4d3039dff574b788948119de402ca8d9.html
@@ -26,7 +26,7 @@ GCC Code Coverage Report
| Date: |
- 2025-04-22 23:09:44 |
+ 2025-05-06 17:04:10 |
@@ -40,21 +40,21 @@ GCC Code Coverage Report
| Lines: |
- 836 |
- 893 |
- 93.6% |
+ 869 |
+ 971 |
+ 89.5% |
| Functions: |
- 27 |
- 27 |
- 100.0% |
+ 28 |
+ 29 |
+ 96.6% |
| Branches: |
- 511 |
- 928 |
- 55.1% |
+ 435 |
+ 756 |
+ 57.5% |
@@ -70,33 +70,35 @@ GCC Code Coverage Report
Call count |
Block coverage |
- | LVLH_to_body_transformation_matrix_from_quaternion(std::__1::array<double, 4ul>) (line 913) | called 8948009 times | 81.0% |
- | RK45_combined_orbit_position_velocity_attitude_deriv_function(std::__1::array<double, 13ul>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, double, bool, bool) (line 1089) | called 54944076 times | 88.0% |
- | RK45_deriv_function_orbit_position_and_velocity(std::__1::array<double, 6ul>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, double, double, bool, bool) (line 345) | called 54944076 times | 83.0% |
- | RK45_satellite_body_angular_deriv_function(std::__1::array<double, 7ul>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (line 1021) | called 54944076 times | 87.0% |
- | calculate_omega_I(Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, double) (line 1066) | called 8948009 times | 100.0% |
- | calculate_orbital_acceleration(std::__1::array<double, 3ul>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, std::__1::array<double, 3ul>, double, double, double, double, double, double, double, bool, bool) (line 154) | called 54944076 times | 97.0% |
- | calculate_spacecraft_bodyframe_angular_acceleration(Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (line 934) | called 54944076 times | 100.0% |
- | construct_J_matrix(double, double, double) (line 1079) | called 8948009 times | 100.0% |
- | convert_ECEF_to_ECI(Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (line 1224) | called 13480446 times | 100.0% |
- | convert_LVLH_to_ECI_manual(std::__1::array<double, 3ul>, std::__1::array<double, 3ul>, std::__1::array<double, 3ul>) (line 37) | called 1939922 times | 75.0% |
- | convert_array_from_LVLH_to_bodyframe(std::__1::array<double, 3ul>, double, double, double) (line 1193) | called 53 times | 100.0% |
- | convert_cylindrical_to_cartesian(double, double, double, double) (line 133) | called 36697692 times | 100.0% |
- | convert_lat_long_to_ECEF(double, double, double) (line 1209) | called 5 times | 100.0% |
- | convert_quaternion_to_roll_yaw_pitch_angles(std::__1::array<double, 4ul>) (line 1162) | called 8948009 times | 100.0% |
- | normalize_quaternion(std::__1::array<double, 4ul>) (line 1150) | called 8948064 times | 100.0% |
- | quaternion_kinematics_equation(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>) (line 992) | called 54944076 times | 77.0% |
- | quaternion_multiplication(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 4, 1, 0, 4, 1>) (line 15) | called 110 times | 77.0% |
- | rollyawpitch_angles_to_quaternion(double, double, double) (line 897) | called 55 times | 100.0% |
- | rollyawpitch_bodyframe_to_LVLH_matrix(double, double, double) (line 875) | called 53 times | 100.0% |
- | sim_and_draw_orbit_gnuplot(std::__1::vector<Satellite, std::__1::allocator<Satellite>>, double, double, double, bool, bool, std::__1::pair<double, double>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 381) | called 18 times | 78.0% |
- | sim_and_plot_attitude_evolution_gnuplot(std::__1::vector<Satellite, std::__1::allocator<Satellite>>, double, double, double, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, bool, bool, std::__1::pair<double, double>) (line 723) | called 180 times | 77.0% |
- | sim_and_plot_gs_connectivity_distance_gnuplot(PhasedArrayGroundStation, std::__1::vector<Satellite, std::__1::allocator<Satellite>>, double, double, double, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, bool, bool, std::__1::pair<double, double>) (line 1241) | called 162 times | 73.0% |
- | sim_and_plot_gs_connectivity_gnuplot(PhasedArrayGroundStation, std::__1::vector<Satellite, std::__1::allocator<Satellite>>, double, double, double, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, bool, bool, std::__1::pair<double, double>) (line 1402) | called 162 times | 75.0% |
- | sim_and_plot_orbital_elem_gnuplot(std::__1::vector<Satellite, std::__1::allocator<Satellite>>, double, double, double, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, bool, bool, std::__1::pair<double, double>) (line 545) | called 162 times | 76.0% |
- | x_rot_matrix(double) (line 712) | called 53 times | 81.0% |
- | y_rot_matrix(double) (line 704) | called 53 times | 81.0% |
- | z_rot_matrix(double) (line 695) | called 13480499 times | 81.0% |
+ | LVLH_to_body_transformation_matrix_from_quaternion(std::__1::array<double, 4ul>) (line 921) | called 8948009 times | 81.0% |
+ | RK45_combined_orbit_position_velocity_attitude_deriv_function(std::__1::array<double, 13ul>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, double, bool, bool) (line 1097) | called 54944076 times | 88.0% |
+ | RK45_deriv_function_orbit_position_and_velocity(std::__1::array<double, 6ul>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, double, double, bool, bool) (line 347) | called 54944076 times | 83.0% |
+ | RK45_satellite_body_angular_deriv_function(std::__1::array<double, 7ul>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (line 1029) | called 54944076 times | 87.0% |
+ | add_lowthrust_orbit_transfer(Satellite&, double, double, double) (line 1573) | called 2 times | 55.0% |
+ | calculate_omega_I(Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, double) (line 1074) | called 8948009 times | 100.0% |
+ | calculate_orbital_acceleration(std::__1::array<double, 3ul>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, std::__1::array<double, 3ul>, double, double, double, double, double, double, double, bool, bool) (line 155) | called 54944076 times | 97.0% |
+ | calculate_spacecraft_bodyframe_angular_acceleration(Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (line 942) | called 54944076 times | 100.0% |
+ | calibrate_mean_val(Satellite, SimParameters const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 1617) | not called | 0.0% |
+ | construct_J_matrix(double, double, double) (line 1087) | called 8948009 times | 100.0% |
+ | convert_ECEF_to_ECI(Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (line 1232) | called 13480446 times | 100.0% |
+ | convert_LVLH_to_ECI_manual(std::__1::array<double, 3ul>, std::__1::array<double, 3ul>, std::__1::array<double, 3ul>) (line 38) | called 1939922 times | 75.0% |
+ | convert_array_from_LVLH_to_bodyframe(std::__1::array<double, 3ul>, double, double, double) (line 1201) | called 55 times | 100.0% |
+ | convert_cylindrical_to_cartesian(double, double, double, double) (line 134) | called 36697692 times | 100.0% |
+ | convert_lat_long_to_ECEF(double, double, double) (line 1217) | called 5 times | 100.0% |
+ | convert_quaternion_to_roll_yaw_pitch_angles(std::__1::array<double, 4ul>) (line 1170) | called 8948009 times | 100.0% |
+ | normalize_quaternion(std::__1::array<double, 4ul>) (line 1158) | called 8948066 times | 100.0% |
+ | quaternion_kinematics_equation(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>) (line 1000) | called 54944076 times | 77.0% |
+ | quaternion_multiplication(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 4, 1, 0, 4, 1>) (line 16) | called 114 times | 77.0% |
+ | rollyawpitch_angles_to_quaternion(double, double, double) (line 905) | called 57 times | 100.0% |
+ | rollyawpitch_bodyframe_to_LVLH_matrix(double, double, double) (line 883) | called 55 times | 100.0% |
+ | sim_and_draw_orbit_gnuplot(std::__1::vector<Satellite, std::__1::allocator<Satellite>>, SimParameters const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 383) | called 18 times | 79.0% |
+ | sim_and_plot_attitude_evolution_gnuplot(std::__1::vector<Satellite, std::__1::allocator<Satellite>>, SimParameters const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 733) | called 180 times | 82.0% |
+ | sim_and_plot_gs_connectivity_distance_gnuplot(PhasedArrayGroundStation, std::__1::vector<Satellite, std::__1::allocator<Satellite>>, SimParameters const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 1249) | called 162 times | 77.0% |
+ | sim_and_plot_gs_connectivity_gnuplot(PhasedArrayGroundStation, std::__1::vector<Satellite, std::__1::allocator<Satellite>>, SimParameters const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 1409) | called 162 times | 81.0% |
+ | sim_and_plot_orbital_elem_gnuplot(std::__1::vector<Satellite, std::__1::allocator<Satellite>>, SimParameters const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 555) | called 162 times | 81.0% |
+ | x_rot_matrix(double) (line 722) | called 55 times | 81.0% |
+ | y_rot_matrix(double) (line 714) | called 55 times | 81.0% |
+ | z_rot_matrix(double) (line 705) | called 13480501 times | 81.0% |
@@ -164,333 +166,340 @@ GCC Code Coverage Report
|
|
- |
+ #include "utils.h" |
| 9 |
|
|
- using Eigen::Matrix3d; |
+ |
| 10 |
|
|
- using Eigen::Matrix4d; |
+ using Eigen::Matrix3d; |
| 11 |
|
|
- using Eigen::Quaterniond; |
+ using Eigen::Matrix4d; |
| 12 |
|
|
- using Eigen::Vector3d; |
+ using Eigen::Quaterniond; |
| 13 |
|
|
- using Eigen::Vector4d; |
+ using Eigen::Vector3d; |
| 14 |
|
|
- |
+ using Eigen::Vector4d; |
| 15 |
|
- 110 |
- Vector4d quaternion_multiplication(const Vector4d quaternion_1, |
+ |
+ |
| 16 |
|
+ 114 |
+ Vector4d quaternion_multiplication(const Vector4d quaternion_1, |
+
+
+ | 17 |
+
+ |
|
const Vector4d quaternion_2) { |
- | 17 |
+ 18 |
|
|
// Ref: https://en.wikipedia.org/wiki/Quaternion#Scalar_and_vector_parts |
- | 18 |
+ 19 |
|
- 110 |
+ 114 |
Vector3d quat_1_vec_component = { |
- | 19 |
+ 20 |
|
- 110 |
+ 114 |
quaternion_1(1), quaternion_1(2), |
- | 20 |
+ 21 |
|
- 110 |
+ 114 |
quaternion_1(3)}; // Here adopting convention that scalar part is first |
- | 21 |
+ 22 |
|
|
// element of quaternion |
- | 22 |
+ 23 |
|
- 220 |
+ 228 |
Vector3d quat_2_vec_component = {quaternion_2(1), quaternion_2(2), |
- | 23 |
+ 24 |
|
- 110 |
+ 114 |
quaternion_2(3)}; |
- | 24 |
+ 25 |
|
|
Vector3d vec_part_of_result = |
- | 25 |
+ 26 |
|
- 330 |
+ 342 |
quaternion_1(0) * quat_2_vec_component + |
- | 26 |
+ 27 |
|
- 220 |
+ 228 |
quaternion_2(0) * quat_1_vec_component + |
- | 27 |
+ 28 |
|
- 110 |
+ 114 |
quat_1_vec_component.cross(quat_2_vec_component); |
- | 28 |
+ 29 |
|
- 110 |
+ 114 |
Vector4d result; |
- | 29 |
+ 30 |
|
- 330 |
+ 342 |
result << quaternion_1(0) * quaternion_2(0) - |
- | 30 |
+ 31 |
1/2
- ✓ Branch 0 taken 110 times.
+ ✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
|
- 110 |
+ 114 |
quat_1_vec_component.dot(quat_2_vec_component), |
- | 31 |
+ 32 |
5/10
- ✓ Branch 0 taken 110 times.
+ ✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 110 times.
+ ✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
- ✓ Branch 4 taken 110 times.
+ ✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
- ✓ Branch 6 taken 110 times.
+ ✓ Branch 6 taken 114 times.
✗ Branch 7 not taken.
- ✓ Branch 8 taken 110 times.
+ ✓ Branch 8 taken 114 times.
✗ Branch 9 not taken.
|
- 220 |
+ 228 |
vec_part_of_result(0), vec_part_of_result(1), vec_part_of_result(2); |
- | 32 |
+ 33 |
|
- 110 |
+ 114 |
return result; |
- | 33 |
+ 34 |
|
✗ |
} |
- | 34 |
+ 35 |
|
|
|
- | 35 |
+ 36 |
|
|
//"manual" version, via dot products and cross products with position and |
- | 36 |
+ 37 |
|
|
// velocity vectors |
- | 37 |
+ 38 |
|
1939922 |
std::array<double, 3> convert_LVLH_to_ECI_manual( |
- | 38 |
+ 39 |
|
|
const std::array<double, 3> input_LVLH_vec, |
- | 39 |
+ 40 |
|
|
const std::array<double, 3> input_position_vec, |
- | 40 |
+ 41 |
|
|
const std::array<double, 3> input_velocity_vec) { |
- | 41 |
+ 42 |
|
|
// LVLH x-axis is defined as in the direction of motion |
- | 42 |
+ 43 |
|
|
// LVLH z-axis is defined as pointing back towards Earth, so along the |
- | 43 |
+ 44 |
|
|
// reversed direction of the position vector from the center of the Earth |
- | 44 |
+ 45 |
|
|
// y-axis determined from a cross product |
- | 45 |
+ 46 |
|
|
|
- | 46 |
+ 47 |
|
1939922 |
Vector3d ECI_unit_vec_x = {1.0, 0.0, 0.0}; |
- | 47 |
+ 48 |
|
1939922 |
Vector3d ECI_unit_vec_y = {0.0, 1.0, 0.0}; |
- | 48 |
+ 49 |
|
1939922 |
Vector3d ECI_unit_vec_z = {0.0, 0.0, 1.0}; |
- | 49 |
+ 50 |
|
|
|
- | 50 |
+ 51 |
|
1939922 |
std::array<double, 3> current_ECI_position_array = input_position_vec; |
- | 51 |
+ 52 |
|
1939922 |
Vector3d current_ECI_position_unit_vec; |
- | 52 |
+ 53 |
1/2
@@ -504,7 +513,7 @@ GCC Code Coverage Report
current_ECI_position_unit_vec << current_ECI_position_array.at(0), |
|
- | 53 |
+ 54 |
3/6
@@ -522,42 +531,42 @@ GCC Code Coverage Report
current_ECI_position_array.at(1), current_ECI_position_array.at(2); |
|
- | 54 |
+ 55 |
|
|
current_ECI_position_unit_vec |
- | 55 |
+ 56 |
|
1939922 |
.normalize(); // to make it actually a unit vector |
- | 56 |
+ 57 |
|
|
|
- | 57 |
+ 58 |
|
1939922 |
std::array<double, 3> current_ECI_velocity_array = input_velocity_vec; |
- | 58 |
+ 59 |
|
1939922 |
Vector3d current_ECI_velocity_unit_vec; |
- | 59 |
+ 60 |
1/2
@@ -571,7 +580,7 @@ GCC Code Coverage Report
current_ECI_velocity_unit_vec << current_ECI_velocity_array.at(0), |
|
- | 60 |
+ 61 |
3/6
@@ -589,889 +598,889 @@ GCC Code Coverage Report
current_ECI_velocity_array.at(1), current_ECI_velocity_array.at(2); |
|
- | 61 |
+ 62 |
|
1939922 |
current_ECI_velocity_unit_vec.normalize(); |
- | 62 |
+ 63 |
|
|
|
- | 63 |
+ 64 |
|
1939922 |
Vector3d LVLH_x_unit_vec = current_ECI_velocity_unit_vec; |
- | 64 |
+ 65 |
|
1939922 |
Vector3d LVLH_z_unit_vec = (-1) * current_ECI_position_unit_vec; |
- | 65 |
+ 66 |
|
|
|
- | 66 |
+ 67 |
|
1939922 |
Vector3d LVLH_y_unit_vec = LVLH_z_unit_vec.cross(LVLH_x_unit_vec); |
- | 67 |
+ 68 |
|
|
// Should already be normalized, just in case though |
- | 68 |
+ 69 |
|
1939922 |
LVLH_y_unit_vec.normalize(); |
- | 69 |
+ 70 |
|
|
|
- | 70 |
+ 71 |
|
5819766 |
double v_x_ECI = input_LVLH_vec.at(0) * ECI_unit_vec_x.dot(LVLH_x_unit_vec) + |
- | 71 |
+ 72 |
|
3879844 |
input_LVLH_vec.at(1) * ECI_unit_vec_x.dot(LVLH_y_unit_vec) + |
- | 72 |
+ 73 |
|
1939922 |
input_LVLH_vec.at(2) * ECI_unit_vec_x.dot(LVLH_z_unit_vec); |
- | 73 |
+ 74 |
|
|
|
- | 74 |
+ 75 |
|
5819766 |
double v_y_ECI = input_LVLH_vec.at(0) * ECI_unit_vec_y.dot(LVLH_x_unit_vec) + |
- | 75 |
+ 76 |
|
3879844 |
input_LVLH_vec.at(1) * ECI_unit_vec_y.dot(LVLH_y_unit_vec) + |
- | 76 |
+ 77 |
|
1939922 |
input_LVLH_vec.at(2) * ECI_unit_vec_y.dot(LVLH_z_unit_vec); |
- | 77 |
+ 78 |
|
|
|
- | 78 |
+ 79 |
|
5819766 |
double v_z_ECI = input_LVLH_vec.at(0) * ECI_unit_vec_z.dot(LVLH_x_unit_vec) + |
- | 79 |
+ 80 |
|
3879844 |
input_LVLH_vec.at(1) * ECI_unit_vec_z.dot(LVLH_y_unit_vec) + |
- | 80 |
+ 81 |
|
1939922 |
input_LVLH_vec.at(2) * ECI_unit_vec_z.dot(LVLH_z_unit_vec); |
- | 81 |
+ 82 |
|
|
|
- | 82 |
+ 83 |
|
1939922 |
std::array<double, 3> output_ECI_arr = {v_x_ECI, v_y_ECI, v_z_ECI}; |
- | 83 |
+ 84 |
|
1939922 |
return output_ECI_arr; |
- | 84 |
+ 85 |
|
✗ |
} |
- | 85 |
+ 86 |
|
|
|
- | 86 |
+ 87 |
|
|
// baselining cartesian coordinates in ECI frame |
- | 87 |
+ 88 |
|
|
|
- | 88 |
+ 89 |
|
|
// std::array<double, 3> calculate_orbital_acceleration( |
- | 89 |
+ 90 |
|
|
// const std::array<double, 3> input_r_vec, const double input_spacecraft_mass, |
- | 90 |
+ 91 |
|
|
// const std::vector<std::array<double, 3>> |
- | 91 |
+ 92 |
|
|
// input_vec_of_force_vectors_in_ECI) { |
- | 92 |
+ 93 |
|
|
// // Note: this is the version used in the RK4 solver |
- | 93 |
+ 94 |
|
|
// // orbital acceleration = -G m_Earth/distance^3 * r_vec (just based on |
- | 94 |
+ 95 |
|
|
// // rearranging F=ma with a the acceleration due to gravitational attraction |
- | 95 |
+ 96 |
|
|
// // between satellite and Earth |
- | 96 |
+ 97 |
|
|
// // https://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation) |
- | 97 |
+ 98 |
|
|
// // going to be assuming Earth's position doesn't change for now |
- | 98 |
+ 99 |
|
|
// // also assuming Earth is spherical, can loosen this assumption in the future |
- | 99 |
+ 100 |
|
|
// // note: this is in ECI frame |
- | 100 |
+ 101 |
|
|
|
- | 101 |
+ 102 |
|
|
// std::array<double, 3> acceleration_vec_due_to_gravity = |
- | 102 |
+ 103 |
|
|
// input_r_vec; // shouldn't need to explicitly call copy function because |
- | 103 |
+ 104 |
|
|
// // input_r_vec is passed by value not ref |
- | 104 |
+ 105 |
|
|
|
- | 105 |
+ 106 |
|
|
// // F=ma |
- | 106 |
+ 107 |
|
|
// // a=F/m = (F_grav + F_ext)/m = (F_grav/m) + (F_ext/m) = -G*M_Earth/distance^3 |
- | 107 |
+ 108 |
|
|
// // + ... |
- | 108 |
+ 109 |
|
|
|
- | 109 |
+ 110 |
|
|
// const double distance = sqrt(input_r_vec.at(0) * input_r_vec.at(0) + |
- | 110 |
+ 111 |
|
|
// input_r_vec.at(1) * input_r_vec.at(1) + |
- | 111 |
+ 112 |
|
|
// input_r_vec.at(2) * input_r_vec.at(2)); |
- | 112 |
+ 113 |
|
|
// const double overall_factor = -G * mass_Earth / pow(distance, 3); |
- | 113 |
+ 114 |
|
|
|
- | 114 |
+ 115 |
|
|
// for (size_t ind = 0; ind < input_r_vec.size(); ind++) { |
- | 115 |
+ 116 |
|
|
// acceleration_vec_due_to_gravity.at(ind) *= overall_factor; |
- | 116 |
+ 117 |
|
|
// } |
- | 117 |
+ 118 |
|
|
|
- | 118 |
+ 119 |
|
|
// // now add effects from externally-applied forces, e.g., thrusters, if any |
- | 119 |
+ 120 |
|
|
// std::array<double, 3> acceleration_vec = acceleration_vec_due_to_gravity; |
- | 120 |
+ 121 |
|
|
|
- | 121 |
+ 122 |
|
|
// for (std::array<double, 3> external_force_vec_in_ECI : |
- | 122 |
+ 123 |
|
|
// input_vec_of_force_vectors_in_ECI) { |
- | 123 |
+ 124 |
|
|
// acceleration_vec.at(0) += |
- | 124 |
+ 125 |
|
|
// (external_force_vec_in_ECI.at(0) / input_spacecraft_mass); |
- | 125 |
+ 126 |
|
|
// acceleration_vec.at(1) += |
- | 126 |
+ 127 |
|
|
// (external_force_vec_in_ECI.at(1) / input_spacecraft_mass); |
- | 127 |
+ 128 |
|
|
// acceleration_vec.at(2) += |
- | 128 |
+ 129 |
|
|
// (external_force_vec_in_ECI.at(2) / input_spacecraft_mass); |
- | 129 |
+ 130 |
|
|
// } |
- | 130 |
+ 131 |
|
|
// return acceleration_vec; |
- | 131 |
+ 132 |
|
|
// } |
- | 132 |
+ 133 |
|
|
|
- | 133 |
+ 134 |
|
36697692 |
std::array<double, 3> convert_cylindrical_to_cartesian( |
- | 134 |
+ 135 |
|
|
const double input_r_comp, const double input_theta_comp, |
- | 135 |
+ 136 |
|
|
const double input_z_comp, const double input_theta) { |
- | 136 |
+ 137 |
|
36697692 |
std::array<double, 3> output_cartesian_vec = {0, 0, 0}; |
- | 137 |
+ 138 |
|
|
|
- | 138 |
+ 139 |
|
|
// Dot product method |
- | 139 |
+ 140 |
|
|
// See |
- | 140 |
+ 141 |
|
|
// https://en.wikipedia.org/wiki/Vector_fields_in_cylindrical_and_spherical_coordinates |
- | 141 |
+ 142 |
|
|
// for relation between unit vectors |
- | 142 |
+ 143 |
|
36697692 |
double x_comp = |
- | 143 |
+ 144 |
|
36697692 |
input_r_comp * cos(input_theta) + input_theta_comp * (-sin(input_theta)); |
- | 144 |
+ 145 |
|
36697692 |
double y_comp = |
- | 145 |
+ 146 |
|
36697692 |
input_r_comp * sin(input_theta) + input_theta_comp * (cos(input_theta)); |
- | 146 |
+ 147 |
|
36697692 |
double z_comp = input_z_comp; |
- | 147 |
+ 148 |
|
|
|
- | 148 |
+ 149 |
|
36697692 |
output_cartesian_vec.at(0) = x_comp; |
- | 149 |
+ 150 |
|
36697692 |
output_cartesian_vec.at(1) = y_comp; |
- | 150 |
+ 151 |
|
36697692 |
output_cartesian_vec.at(2) = z_comp; |
- | 151 |
+ 152 |
|
36697692 |
return output_cartesian_vec; |
- | 152 |
+ 153 |
|
|
} |
- | 153 |
+ 154 |
|
|
|
- | 154 |
+ 155 |
|
54944076 |
std::array<double, 3> calculate_orbital_acceleration( |
- | 155 |
+ 156 |
|
|
const std::array<double, 3> input_r_vec, const double input_spacecraft_mass, |
- | 156 |
+ 157 |
|
|
const std::vector<ThrustProfileLVLH> input_list_of_thrust_profiles_LVLH, |
- | 157 |
+ 158 |
|
|
const double input_evaluation_time, |
- | 158 |
+ 159 |
|
|
const std::array<double, 3> input_velocity_vec, |
- | 159 |
+ 160 |
|
|
const double input_inclination, const double input_arg_of_periapsis, |
- | 160 |
+ 161 |
|
|
const double input_true_anomaly, const double input_F_10, |
- | 161 |
+ 162 |
|
|
const double input_A_p, const double input_A_s, |
- | 162 |
+ 163 |
|
|
const double input_satellite_mass, const bool perturbation, |
- | 163 |
+ 164 |
|
|
const bool atmospheric_drag) { |
- | 164 |
+ 165 |
|
|
// Note: this is the version used in the RK45 solver (this has a more updated |
- | 165 |
+ 166 |
|
|
// workflow) orbital acceleration = -G m_Earth/distance^3 * r_vec (just based |
- | 166 |
+ 167 |
|
|
// on rearranging F=ma with a the acceleration due to gravitational attraction |
- | 167 |
+ 168 |
|
|
// between satellite and Earth |
- | 168 |
+ 169 |
|
|
// https://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation) |
- | 169 |
+ 170 |
|
|
// going to be assuming Earth's position doesn't change for now |
- | 170 |
+ 171 |
|
|
// also assuming Earth is spherical, can loosen this assumption in the future |
- | 171 |
+ 172 |
|
|
// note: this is in ECI frame (r_vec and velocity vec should also be in ECI |
- | 172 |
+ 173 |
|
|
// frame) |
- | 173 |
+ 174 |
|
|
|
- | 174 |
+ 175 |
|
|
std::array<double, 3> acceleration_vec_due_to_gravity = |
- | 175 |
+ 176 |
|
54944076 |
input_r_vec; // shouldn't need to explicitly call copy function because |
- | 176 |
+ 177 |
|
|
// input_r_vec is passed by value not ref |
- | 177 |
+ 178 |
|
|
|
- | 178 |
+ 179 |
|
|
// F=ma |
- | 179 |
+ 180 |
|
|
// a=F/m = (F_grav + F_ext)/m = (F_grav/m) + (F_ext/m) = -G*M_Earth/distance^3 |
- | 180 |
+ 181 |
|
|
// + ... |
- | 181 |
+ 182 |
|
|
|
- | 182 |
+ 183 |
|
164832228 |
const double distance = sqrt(input_r_vec.at(0) * input_r_vec.at(0) + |
- | 183 |
+ 184 |
|
109888152 |
input_r_vec.at(1) * input_r_vec.at(1) + |
- | 184 |
+ 185 |
|
54944076 |
input_r_vec.at(2) * input_r_vec.at(2)); |
- | 185 |
+ 186 |
|
54944076 |
const double overall_factor = -G * mass_Earth / pow(distance, 3); |
- | 186 |
+ 187 |
|
|
|
- | 187 |
+ 188 |
2/2
@@ -1485,84 +1494,84 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < input_r_vec.size(); ind++) { |
|
- | 188 |
+ 189 |
|
164832228 |
acceleration_vec_due_to_gravity.at(ind) *= overall_factor; |
- | 189 |
+ 190 |
|
164832228 |
} |
- | 190 |
+ 191 |
|
|
|
- | 191 |
+ 192 |
|
54944076 |
std::array<double, 3> acceleration_vec = acceleration_vec_due_to_gravity; |
- | 192 |
+ 193 |
|
|
|
- | 193 |
+ 194 |
|
|
// now add effects from externally-applied forces, e.g., thrusters, if any |
- | 194 |
+ 195 |
|
|
|
- | 195 |
+ 196 |
|
|
std::vector<std::array<double, 3>> list_of_LVLH_forces_at_evaluation_time = |
- | 196 |
+ 197 |
|
54944076 |
{}; |
- | 197 |
+ 198 |
|
54944076 |
std::vector<std::array<double, 3>> list_of_ECI_forces_at_evaluation_time = {}; |
- | 198 |
+ 199 |
|
|
|
- | 199 |
+ 200 |
2/2
@@ -1576,37 +1585,51 @@ GCC Code Coverage Report
for (const ThrustProfileLVLH thrust_profile : |
|
- | 200 |
+ 201 |
|
54944076 |
input_list_of_thrust_profiles_LVLH) { |
- | 201 |
+ 202 |
- 4/4
+ 3/4
✓ Branch 0 taken 48060569 times.
✓ Branch 1 taken 259423 times.
- ✓ Branch 2 taken 46120657 times.
+ ✗ Branch 2 not taken.
✓ Branch 3 taken 1939912 times.
|
- 48319992 |
- if ((input_evaluation_time >= thrust_profile.t_start_) && |
+ 50259904 |
+ if ((input_evaluation_time >= thrust_profile.t_start_) && |
- | 202 |
+ 203 |
+
+ 2/2
+
+ ✓ Branch 0 taken 1939912 times.
+ ✓ Branch 1 taken 46120657 times.
+
+
|
48060569 |
- (input_evaluation_time <= thrust_profile.t_end_)) { |
+ (input_evaluation_time <= thrust_profile.t_end_) && |
- | 203 |
+ 204 |
+
+ |
+ 1939912 |
+ (thrust_profile.arg_of_periapsis_change_thrust_profile == false)) { |
+
+
+ | 205 |
1/2
@@ -1620,14 +1643,14 @@ GCC Code Coverage Report
list_of_LVLH_forces_at_evaluation_time.push_back( |
|
- | 204 |
+ 206 |
|
1939912 |
thrust_profile.LVLH_force_vec_); |
- | 205 |
+ 207 |
1/2
@@ -1641,14 +1664,14 @@ GCC Code Coverage Report
std::array<double, 3> ECI_thrust_vector = convert_LVLH_to_ECI_manual( |
|
- | 206 |
+ 208 |
|
1939912 |
thrust_profile.LVLH_force_vec_, input_r_vec, input_velocity_vec); |
- | 207 |
+ 209 |
1/2
@@ -1662,28 +1685,28 @@ GCC Code Coverage Report
list_of_ECI_forces_at_evaluation_time.push_back(ECI_thrust_vector); |
|
- | 208 |
+ 210 |
|
1939912 |
} |
- | 209 |
+ 211 |
|
|
} |
- | 210 |
+ 212 |
|
|
|
- | 211 |
+ 213 |
2/2
@@ -1697,14 +1720,14 @@ GCC Code Coverage Report
for (std::array<double, 3> external_force_vec_in_ECI : |
|
- | 212 |
+ 214 |
|
54944076 |
list_of_ECI_forces_at_evaluation_time) { |
- | 213 |
+ 215 |
1/2
@@ -1718,7 +1741,7 @@ GCC Code Coverage Report
acceleration_vec.at(0) += |
|
- | 214 |
+ 216 |
1/2
@@ -1732,7 +1755,7 @@ GCC Code Coverage Report
(external_force_vec_in_ECI.at(0) / input_spacecraft_mass); |
|
- | 215 |
+ 217 |
1/2
@@ -1746,7 +1769,7 @@ GCC Code Coverage Report
acceleration_vec.at(1) += |
|
- | 216 |
+ 218 |
1/2
@@ -1760,7 +1783,7 @@ GCC Code Coverage Report
(external_force_vec_in_ECI.at(1) / input_spacecraft_mass); |
|
- | 217 |
+ 219 |
1/2
@@ -1774,7 +1797,7 @@ GCC Code Coverage Report
acceleration_vec.at(2) += |
|
- | 218 |
+ 220 |
1/2
@@ -1788,21 +1811,21 @@ GCC Code Coverage Report
(external_force_vec_in_ECI.at(2) / input_spacecraft_mass); |
|
- | 219 |
+ 221 |
|
|
} |
- | 220 |
+ 222 |
|
|
|
- | 221 |
+ 223 |
2/2
@@ -1816,70 +1839,70 @@ GCC Code Coverage Report
if (perturbation) { |
|
- | 222 |
+ 224 |
|
|
// If accounting for J2 perturbation |
- | 223 |
+ 225 |
|
|
|
- | 224 |
+ 226 |
|
|
// Now let's add the additional acceleration components due to the J2 |
- | 225 |
+ 227 |
|
|
// perturbation Ref: |
- | 226 |
+ 228 |
|
|
// https://vatankhahghadim.github.io/AER506/Notes/6%20-%20Orbital%20Perturbations.pdf |
- | 227 |
+ 229 |
|
36697692 |
double J2 = 1.083 * pow(10, -3); |
- | 228 |
+ 230 |
|
36697692 |
- double mu = G * mass_Earth; |
+ const double mu_Earth = G*mass_Earth; |
- | 229 |
+ 231 |
|
36697692 |
double C = |
- | 230 |
+ 232 |
|
36697692 |
- 3 * mu * J2 * radius_Earth * radius_Earth / (2 * pow(distance, 4)); |
+ 3 * mu_Earth * J2 * radius_Earth * radius_Earth / (2 * pow(distance, 4)); |
- | 231 |
+ 233 |
1/2
@@ -1893,7 +1916,7 @@ GCC Code Coverage Report
double x = input_r_vec.at(0); |
|
- | 232 |
+ 234 |
1/2
@@ -1907,35 +1930,35 @@ GCC Code Coverage Report
double y = input_r_vec.at(1); |
|
- | 233 |
+ 235 |
|
36697692 |
double rho = sqrt(pow(x, 2) + pow(y, 2)); |
- | 234 |
+ 236 |
|
|
double theta; |
- | 235 |
+ 237 |
|
|
// Ref: |
- | 236 |
+ 238 |
|
|
// https://en.wikipedia.org/wiki/Cylindrical_coordinate_system#Line_and_volume_elements |
- | 237 |
+ 239 |
2/2
@@ -1949,49 +1972,49 @@ GCC Code Coverage Report
if (x >= 0) { |
|
- | 238 |
+ 240 |
|
14214099 |
theta = asin( |
- | 239 |
+ 241 |
|
14214099 |
y / rho); // Note: here setting theta=0 even if both x and y are |
- | 240 |
+ 242 |
|
|
// zero, whereas it should technically be indeterminate, |
- | 241 |
+ 243 |
|
|
// but I'm going to assume this edge condition won't be hit |
- | 242 |
+ 244 |
|
|
// and I don't want undefined behavior |
- | 243 |
+ 245 |
|
14214099 |
} else { |
- | 244 |
+ 246 |
2/2
@@ -2005,112 +2028,112 @@ GCC Code Coverage Report
if (y >= 0) { |
|
- | 245 |
+ 247 |
|
11762631 |
theta = -asin(y / rho) + M_PI; |
- | 246 |
+ 248 |
|
11762631 |
} else { |
- | 247 |
+ 249 |
|
10720962 |
theta = -asin(y / rho) - M_PI; |
- | 248 |
+ 250 |
|
|
} |
- | 249 |
+ 251 |
|
|
} |
- | 250 |
+ 252 |
|
|
|
- | 251 |
+ 253 |
|
36697692 |
double a_r = |
- | 252 |
+ 254 |
|
73395384 |
C * (3 * pow(sin(input_inclination), 2) * |
- | 253 |
+ 255 |
|
36697692 |
pow(sin(input_arg_of_periapsis + input_true_anomaly), 2) - |
- | 254 |
+ 256 |
|
|
1); |
- | 255 |
+ 257 |
|
73395384 |
double a_theta = -C * pow(sin(input_inclination), 2) * |
- | 256 |
+ 258 |
|
36697692 |
sin(2 * (input_arg_of_periapsis + input_true_anomaly)); |
- | 257 |
+ 259 |
|
73395384 |
double a_z = -C * sin(2 * input_inclination) * |
- | 258 |
+ 260 |
|
36697692 |
sin(input_arg_of_periapsis + input_true_anomaly); |
- | 259 |
+ 261 |
|
|
std::array<double, 3> cartesian_acceleration_components = |
- | 260 |
+ 262 |
1/2
@@ -2124,20 +2147,20 @@ GCC Code Coverage Report
convert_cylindrical_to_cartesian(a_r, a_theta, a_z, theta); |
|
- | 261 |
+ 263 |
|
|
|
- | 262 |
+ 264 |
2/2
- ✓ Branch 0 taken 110093076 times.
- ✓ Branch 1 taken 36697692 times.
+ ✓ Branch 0 taken 36697692 times.
+ ✓ Branch 1 taken 110093076 times.
|
@@ -2145,7 +2168,7 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < 3; ind++) { |
- | 263 |
+ 265 |
2/4
@@ -2161,28 +2184,28 @@ GCC Code Coverage Report
acceleration_vec.at(ind) += cartesian_acceleration_components.at(ind); |
|
- | 264 |
+ 266 |
|
110093076 |
} |
- | 265 |
+ 267 |
|
36697692 |
} |
- | 266 |
+ 268 |
|
54944076 |
double altitude = (distance - radius_Earth) / 1000.0; // km |
- | 267 |
+ 269 |
5/6
@@ -2200,21 +2223,21 @@ GCC Code Coverage Report
if ((atmospheric_drag) && (altitude >= 140) && (altitude <= 400)) { |
|
- | 268 |
+ 270 |
|
|
// Refs: https://angeo.copernicus.org/articles/39/397/2021/ |
- | 269 |
+ 271 |
|
|
// https://www.spaceacademy.net.au/watch/debris/atmosmod.htm |
- | 270 |
+ 272 |
1/2
@@ -2228,7 +2251,7 @@ GCC Code Coverage Report
double speed = sqrt(pow(input_velocity_vec.at(0), 2) + |
|
- | 271 |
+ 273 |
1/2
@@ -2242,7 +2265,7 @@ GCC Code Coverage Report
pow(input_velocity_vec.at(1), 2) + |
|
- | 272 |
+ 274 |
1/2
@@ -2256,21 +2279,21 @@ GCC Code Coverage Report
pow(input_velocity_vec.at(2), 2)); |
|
- | 273 |
+ 275 |
|
|
// First, esimate atmospheric density |
- | 274 |
+ 276 |
|
178356 |
double rho = {0}; |
- | 275 |
+ 277 |
2/2
@@ -2284,202 +2307,202 @@ GCC Code Coverage Report
if (altitude < 180) { |
|
- | 276 |
+ 278 |
|
552 |
double a0 = 7.001985 * pow(10, -2); |
- | 277 |
+ 279 |
|
552 |
double a1 = -4.336216 * pow(10, -3); |
- | 278 |
+ 280 |
|
552 |
double a2 = -5.009831 * pow(10, -3); |
- | 279 |
+ 281 |
|
552 |
double a3 = 1.621827 * pow(10, -4); |
- | 280 |
+ 282 |
|
552 |
double a4 = -2.471283 * pow(10, -6); |
- | 281 |
+ 283 |
|
552 |
double a5 = 1.904383 * pow(10, -8); |
- | 282 |
+ 284 |
|
552 |
double a6 = -7.189421 * pow(10, -11); |
- | 283 |
+ 285 |
|
552 |
double a7 = 1.060067 * pow(10, -13); |
- | 284 |
+ 286 |
|
1104 |
double fit_val = a0 + a1*altitude + a2*pow(altitude,2) |
- | 285 |
+ 287 |
|
552 |
+ a3*pow(altitude,3) + a4*pow(altitude,4) |
- | 286 |
+ 288 |
|
552 |
+ a5*pow(altitude,5) + a6*pow(altitude,6) |
- | 287 |
+ 289 |
|
552 |
+ a7*pow(altitude,7); |
- | 288 |
+ 290 |
|
|
|
- | 289 |
+ 291 |
|
552 |
rho = pow(10, fit_val); |
- | 290 |
+ 292 |
|
552 |
} else { |
- | 291 |
+ 293 |
|
177804 |
double T = 900 + 2.5 * (input_F_10 - 70) + 1.5 * input_A_p; |
- | 292 |
+ 294 |
|
177804 |
double new_mu = 27 - 0.012 * (altitude - 200); |
- | 293 |
+ 295 |
|
177804 |
double H = T / new_mu; |
- | 294 |
+ 296 |
|
177804 |
rho = 6 * pow(10, -10) * exp(-(altitude - 175) / H); |
- | 295 |
+ 297 |
|
|
} |
- | 296 |
+ 298 |
|
|
|
- | 297 |
+ 299 |
|
|
// Now estimate the satellite's ballistic coefficient B |
- | 298 |
+ 300 |
|
178356 |
double C_d = 2.2; |
- | 299 |
+ 301 |
|
178356 |
double B = C_d * input_A_s / input_satellite_mass; |
- | 300 |
+ 302 |
|
178356 |
double drag_deceleration = (1.0 / 2.0) * rho * B * pow(speed, 2); |
- | 301 |
+ 303 |
|
|
// Should act in direction directly opposite to velocity |
- | 302 |
+ 304 |
|
178356 |
std::array<double, 3> velocity_unit_vec = {0.0, 0.0, 0.0}; |
- | 303 |
+ 305 |
2/2
- ✓ Branch 0 taken 535068 times.
- ✓ Branch 1 taken 178356 times.
+ ✓ Branch 0 taken 178356 times.
+ ✓ Branch 1 taken 535068 times.
|
@@ -2487,7 +2510,7 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < 3; ind++) { |
- | 304 |
+ 306 |
2/4
@@ -2503,27 +2526,27 @@ GCC Code Coverage Report
velocity_unit_vec.at(ind) = input_velocity_vec.at(ind) / speed; |
|
- | 305 |
+ 307 |
|
535068 |
} |
- | 306 |
+ 308 |
|
178356 |
std::array<double, 3> drag_acceleration_vec = {0.0, 0.0, 0.0}; |
- | 307 |
+ 309 |
2/2
- ✓ Branch 0 taken 535068 times.
- ✓ Branch 1 taken 178356 times.
+ ✓ Branch 0 taken 178356 times.
+ ✓ Branch 1 taken 535068 times.
|
@@ -2531,7 +2554,7 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < 3; ind++) { |
- | 308 |
+ 310 |
1/2
@@ -2545,7 +2568,7 @@ GCC Code Coverage Report
drag_acceleration_vec.at(ind) = |
|
- | 309 |
+ 311 |
1/2
@@ -2559,34 +2582,34 @@ GCC Code Coverage Report
drag_deceleration * (-1) * velocity_unit_vec.at(ind); |
|
- | 310 |
+ 312 |
|
|
// Factor of (-1) because this acceleration acts in direction opposite to |
- | 311 |
+ 313 |
|
|
// velocity |
- | 312 |
+ 314 |
|
535068 |
} |
- | 313 |
+ 315 |
2/2
- ✓ Branch 0 taken 535068 times.
- ✓ Branch 1 taken 178356 times.
+ ✓ Branch 0 taken 178356 times.
+ ✓ Branch 1 taken 535068 times.
|
@@ -2594,7 +2617,7 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < 3; ind++) { |
- | 314 |
+ 316 |
2/4
@@ -2610,308 +2633,308 @@ GCC Code Coverage Report
acceleration_vec.at(ind) += drag_acceleration_vec.at(ind); |
|
- | 315 |
+ 317 |
|
535068 |
} |
- | 316 |
+ 318 |
|
178356 |
} |
- | 317 |
+ 319 |
|
|
|
- | 318 |
+ 320 |
|
|
return acceleration_vec; |
- | 319 |
+ 321 |
|
54944076 |
} |
- | 320 |
+ 322 |
|
|
|
- | 321 |
+ 323 |
|
|
// std::array<double, 6> RK4_deriv_function_orbit_position_and_velocity( |
- | 322 |
+ 324 |
|
|
// const std::array<double, 6> input_position_and_velocity, |
- | 323 |
+ 325 |
|
|
// const double input_spacecraft_mass, |
- | 324 |
+ 326 |
|
|
// const std::vector<std::array<double, 3>> |
- | 325 |
+ 327 |
|
|
// input_vec_of_force_vectors_in_ECI) { |
- | 326 |
+ 328 |
|
|
// std::array<double, 6> derivative_of_input_y = {}; |
- | 327 |
+ 329 |
|
|
// std::array<double, 3> position_array = {}; |
- | 328 |
+ 330 |
|
|
|
- | 329 |
+ 331 |
|
|
// for (size_t ind = 0; ind < 3; ind++) { |
- | 330 |
+ 332 |
|
|
// derivative_of_input_y.at(ind) = input_position_and_velocity.at(ind + 3); |
- | 331 |
+ 333 |
|
|
// position_array.at(ind) = input_position_and_velocity.at(ind); |
- | 332 |
+ 334 |
|
|
// } |
- | 333 |
+ 335 |
|
|
|
- | 334 |
+ 336 |
|
|
// std::array<double, 3> calculated_orbital_acceleration = |
- | 335 |
+ 337 |
|
|
// calculate_orbital_acceleration(position_array, input_spacecraft_mass, |
- | 336 |
+ 338 |
|
|
// input_vec_of_force_vectors_in_ECI); |
- | 337 |
+ 339 |
|
|
|
- | 338 |
+ 340 |
|
|
// for (size_t ind = 3; ind < 6; ind++) { |
- | 339 |
+ 341 |
|
|
// derivative_of_input_y.at(ind) = calculated_orbital_acceleration.at(ind - 3); |
- | 340 |
+ 342 |
|
|
// } |
- | 341 |
+ 343 |
|
|
|
- | 342 |
+ 344 |
|
|
// return derivative_of_input_y; |
- | 343 |
+ 345 |
|
|
// } |
- | 344 |
+ 346 |
|
|
|
- | 345 |
+ 347 |
|
54944076 |
std::array<double, 6> RK45_deriv_function_orbit_position_and_velocity( |
- | 346 |
+ 348 |
|
|
const std::array<double, 6> input_position_and_velocity, |
- | 347 |
+ 349 |
|
|
const double input_spacecraft_mass, |
- | 348 |
+ 350 |
|
|
const std::vector<ThrustProfileLVLH> input_list_of_thrust_profiles_LVLH, |
- | 349 |
+ 351 |
|
|
const double input_evaluation_time, const double input_inclination, |
- | 350 |
+ 352 |
|
|
const double input_arg_of_periapsis, const double input_true_anomaly, |
- | 351 |
+ 353 |
|
|
const double input_F_10, const double input_A_p, const double input_A_s, |
- | 352 |
+ 354 |
|
|
const double input_satellite_mass, const bool perturbation, |
- | 353 |
+ 355 |
|
|
const bool atmospheric_drag) { |
- | 354 |
+ 356 |
|
54944076 |
std::array<double, 6> derivative_of_input_y = {}; |
- | 355 |
+ 357 |
|
54944076 |
std::array<double, 3> position_array = {}; |
- | 356 |
+ 358 |
|
54944076 |
std::array<double, 3> velocity_array = {}; |
- | 357 |
+ 359 |
|
|
|
- | 358 |
+ 360 |
2/2
@@ -2925,49 +2948,49 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < 3; ind++) { |
|
- | 359 |
+ 361 |
|
164832228 |
derivative_of_input_y.at(ind) = input_position_and_velocity.at(ind + 3); |
- | 360 |
+ 362 |
|
164832228 |
velocity_array.at(ind) = input_position_and_velocity.at(ind + 3); |
- | 361 |
+ 363 |
|
164832228 |
position_array.at(ind) = input_position_and_velocity.at(ind); |
- | 362 |
+ 364 |
|
164832228 |
} |
- | 363 |
+ 365 |
|
|
|
- | 364 |
+ 366 |
|
|
std::array<double, 3> calculated_orbital_acceleration = |
- | 365 |
+ 367 |
1/2
@@ -2981,49 +3004,49 @@ GCC Code Coverage Report
calculate_orbital_acceleration( |
|
- | 366 |
+ 368 |
|
54944076 |
position_array, input_spacecraft_mass, |
- | 367 |
+ 369 |
|
54944076 |
input_list_of_thrust_profiles_LVLH, input_evaluation_time, |
- | 368 |
+ 370 |
|
54944076 |
velocity_array, input_inclination, input_arg_of_periapsis, |
- | 369 |
+ 371 |
|
54944076 |
input_true_anomaly, input_F_10, input_A_p, input_A_s, |
- | 370 |
+ 372 |
|
54944076 |
input_satellite_mass, perturbation, atmospheric_drag); |
- | 371 |
+ 373 |
|
|
|
- | 372 |
+ 374 |
2/2
@@ -3037,126 +3060,84 @@ GCC Code Coverage Report
for (size_t ind = 3; ind < 6; ind++) { |
|
- | 373 |
+ 375 |
|
164832228 |
derivative_of_input_y.at(ind) = calculated_orbital_acceleration.at(ind - 3); |
- | 374 |
+ 376 |
|
164832228 |
} |
- | 375 |
+ 377 |
|
|
|
- | 376 |
+ 378 |
|
54944076 |
return derivative_of_input_y; |
- | 377 |
+ 379 |
|
✗ |
} |
- | 378 |
+ 380 |
|
|
|
- | 379 |
+ 381 |
|
|
// Objective: simulate the input satellites over the specified total sim time, |
- | 380 |
+ 382 |
|
|
// and visualize the resulting orbits in an interactive 3D plot using gnuplot |
- | 381 |
+ 383 |
|
18 |
void sim_and_draw_orbit_gnuplot(std::vector<Satellite> input_satellite_vector, |
-
- | 382 |
-
- |
- |
- const double input_timestep, |
-
-
- | 383 |
-
- |
- |
- const double input_total_sim_time, |
-
| 384 |
|
|
- const double input_epsilon, |
+ const SimParameters& input_sim_parameters, |
| 385 |
|
|
- const bool perturbation, |
-
-
- | 386 |
-
- |
- |
- const bool atmospheric_drag, |
-
-
- | 387 |
-
- |
- |
- const std::pair<double, double> drag_elements, |
-
-
- | 388 |
-
- |
- |
- const std::string input_terminal, |
-
-
- | 389 |
-
- |
- |
const std::string output_file_name) { |
- | 390 |
+ 386 |
1/2
@@ -3170,49 +3151,42 @@ GCC Code Coverage Report
if (input_satellite_vector.size() < 1) { |
|
- | 391 |
+ 387 |
|
✗ |
std::cout << "No input Satellite objects\n"; |
- | 392 |
+ 388 |
|
✗ |
return; |
- | 393 |
+ 389 |
|
|
} |
- | 394 |
-
- |
- |
- |
-
-
- | 395 |
+ 390 |
|
|
// first, open "pipe" to gnuplot |
- | 396 |
+ 391 |
|
18 |
std::string gnuplot_arg_string = "gnuplot"; |
- | 397 |
+ 392 |
1/2
@@ -3223,24 +3197,24 @@ GCC Code Coverage Report
|
18 |
- if (input_terminal == "qt"){ |
+ if (input_sim_parameters.terminal_name_3D == "qt"){ |
- | 398 |
+ 393 |
|
✗ |
gnuplot_arg_string += " -persist"; |
- | 399 |
+ 394 |
|
✗ |
} |
- | 400 |
+ 395 |
1/2
@@ -3254,27 +3228,27 @@ GCC Code Coverage Report
FILE *gnuplot_pipe = popen(gnuplot_arg_string.c_str(), "w"); |
|
- | 401 |
+ 396 |
|
|
|
- | 402 |
+ 397 |
|
|
// if it exists |
- | 403 |
+ 398 |
1/2
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
+ ✗ Branch 0 not taken.
+ ✓ Branch 1 taken 18 times.
|
@@ -3282,167 +3256,151 @@ GCC Code Coverage Report
if (gnuplot_pipe) { |
- | 404 |
+ 399 |
+
+ |
+ 18 |
+ fprintf(gnuplot_pipe, "set terminal '%s' size 900,700 font ',14'\n",input_sim_parameters.terminal_name_3D.c_str()); |
+
+
+ | 400 |
1/2
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
+ ✗ Branch 0 not taken.
+ ✓ Branch 1 taken 18 times.
|
18 |
- fprintf(gnuplot_pipe, "set terminal '%s' size 900,700 font ',14'\n",input_terminal.c_str()); |
+ if (input_sim_parameters.terminal_name_3D == "png") { |
+
+
+ | 401 |
+
+ |
+ 18 |
+ fprintf(gnuplot_pipe, "set output '../%s.png'\n",output_file_name.c_str()); |
+
+
+ | 402 |
+
+ |
+ 18 |
+ } |
+
+
+ | 403 |
+
+ |
+ |
+ // formatting |
+
+
+ | 404 |
+
+ |
+ 18 |
+ fprintf(gnuplot_pipe, "set xlabel 'x [m]' offset 0,-2\n"); |
| 405 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- if (input_terminal == "png") { |
+ 18 |
+ fprintf(gnuplot_pipe, "set ylabel 'y [m]' offset -2,0\n"); |
| 406 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "set output '../%s.png'\n",output_file_name.c_str()); |
+ 18 |
+ fprintf(gnuplot_pipe, "set zlabel 'z [m]'\n"); |
| 407 |
|
- 18 |
- } |
+ 36 |
+ fprintf(gnuplot_pipe, |
| 408 |
|
|
- // formatting |
+ "set title 'Simulated orbits up to time %.2f s' offset 0,-7.5\n", |
| 409 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "set xlabel 'x [m]' offset 0,-2\n"); |
+ 18 |
+ input_sim_parameters.total_sim_time); |
| 410 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "set ylabel 'y [m]' offset -2,0\n"); |
+ |
+ // fprintf(gnuplot_pipe,"set view 70,1,1,1\n"); |
| 411 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "set zlabel 'z [m]'\n"); |
+ 18 |
+ fprintf(gnuplot_pipe, "set view equal xyz\n"); |
| 412 |
- 2/4
+ 1/2
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
- ✓ Branch 2 taken 18 times.
- ✗ Branch 3 not taken.
+ ✗ Branch 0 not taken.
+ ✓ Branch 1 taken 18 times.
|
- 36 |
- fprintf(gnuplot_pipe, |
+ 18 |
+ if (input_sim_parameters.x_increment != 0) { |
| 413 |
|
- |
- "set title 'Simulated orbits up to time %.2f s' offset 0,-7.5\n", |
+ ✗ |
+ fprintf(gnuplot_pipe, "set xtics %e offset 0,-1\n",input_sim_parameters.x_increment); |
| 414 |
|
- 18 |
- input_total_sim_time); |
+ ✗ |
+ } |
| 415 |
|
|
- // fprintf(gnuplot_pipe,"set view 70,1,1,1\n"); |
+ else { |
| 416 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "set view equal xyz\n"); |
+ 18 |
+ fprintf(gnuplot_pipe, "set xtics offset 0,-1\n"); |
| 417 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "set xtics offset 0,-1\n"); |
+ |
+ } |
| 418 |
@@ -3450,184 +3408,184 @@ GCC Code Coverage Report
1/2
-
✓ Branch 0 taken 18 times.
-
✗ Branch 1 not taken.
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 18 times.
18 |
- fprintf(gnuplot_pipe, "set ytics offset -1,0\n"); |
+ if (input_sim_parameters.y_increment != 0) { |
| 419 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "unset colorbox\n"); |
+ ✗ |
+ fprintf(gnuplot_pipe, "set ytics %e offset -1,0\n",input_sim_parameters.y_increment); |
| 420 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "set style fill transparent solid 1.0\n"); |
+ ✗ |
+ } |
| 421 |
|
|
- |
+ else { |
| 422 |
+
+ |
+ 18 |
+ fprintf(gnuplot_pipe, "set ytics offset -1,0\n"); |
+
+
+ | 423 |
+
+ |
+ |
+ } |
+
+
+ | 424 |
1/2
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
+ ✗ Branch 0 not taken.
+ ✓ Branch 1 taken 18 times.
|
18 |
- fprintf(gnuplot_pipe, "set key offset 0,-10\n"); |
+ if (input_sim_parameters.z_increment != 0) { |
- | 423 |
+ 425 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "set hidden3d front\n"); |
+ ✗ |
+ fprintf(gnuplot_pipe, "set ztics %e\n",input_sim_parameters.z_increment); |
- | 424 |
+ 426 |
+
+ |
+ ✗ |
+ } |
+
+
+ | 427 |
+
+ |
+ 18 |
+ fprintf(gnuplot_pipe, "unset colorbox\n"); |
+
+
+ | 428 |
+
+ |
+ 18 |
+ fprintf(gnuplot_pipe, "set style fill transparent solid 1.0\n"); |
+
+
+ | 429 |
|
|
|
- | 425 |
+ 430 |
+
+ |
+ 18 |
+ fprintf(gnuplot_pipe, "set key offset 0,-10\n"); |
+
+
+ | 431 |
+
+ |
+ 18 |
+ fprintf(gnuplot_pipe, "set hidden3d front\n"); |
+
+
+ | 432 |
+
+ |
+ |
+ |
+
+
+ | 433 |
|
|
// plotting |
- | 426 |
+ 434 |
|
|
// first let's set the stage for plotting the Earth |
- | 427 |
+ 435 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "R_Earth=%.17g\n", radius_Earth); |
+ 18 |
+ fprintf(gnuplot_pipe, "R_Earth=%.17g\n", radius_Earth); |
- | 428 |
+ 436 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "set isosamples 50,50\n"); |
+ 18 |
+ fprintf(gnuplot_pipe, "set isosamples 50,50\n"); |
- | 429 |
+ 437 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "set parametric\n"); |
+ 18 |
+ fprintf(gnuplot_pipe, "set parametric\n"); |
- | 430 |
+ 438 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "set urange [-pi/2:pi/2]\n"); |
+ 18 |
+ fprintf(gnuplot_pipe, "set urange [-pi/2:pi/2]\n"); |
- | 431 |
+ 439 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "set vrange [0:2*pi]\n"); |
+ 18 |
+ fprintf(gnuplot_pipe, "set vrange [0:2*pi]\n"); |
- | 432 |
+ 440 |
|
|
|
- | 433 |
+ 441 |
|
|
// first satellite |
- | 434 |
+ 442 |
2/4
@@ -3643,7 +3601,7 @@ GCC Code Coverage Report
Satellite current_satellite = input_satellite_vector.at(0); |
|
- | 435 |
+ 443 |
2/2
@@ -3657,7 +3615,7 @@ GCC Code Coverage Report
if (input_satellite_vector.size() == 1) { |
|
- | 436 |
+ 444 |
2/2
@@ -3671,35 +3629,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 437 |
+ 445 |
-
- 1/2
-
- ✓ Branch 0 taken 3 times.
- ✗ Branch 1 not taken.
-
-
|
- 3 |
- fprintf(gnuplot_pipe, |
+ 3 |
+ fprintf(gnuplot_pipe, |
- | 438 |
+ 446 |
|
|
"splot '-' with lines lw 1 lc rgb '%s' title '%s' \\\n", |
- | 439 |
+ 447 |
|
3 |
current_satellite.plotting_color_.c_str(), |
- | 440 |
+ 448 |
1/2
@@ -3713,28 +3664,21 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 441 |
+ 449 |
|
3 |
} else { |
- | 442 |
+ 450 |
-
- 1/2
-
- ✓ Branch 0 taken 3 times.
- ✗ Branch 1 not taken.
-
-
|
- 3 |
- fprintf(gnuplot_pipe, "splot '-' with lines lw 1 title '%s' \\\n", |
+ 3 |
+ fprintf(gnuplot_pipe, "splot '-' with lines lw 1 title '%s' \\\n", |
- | 443 |
+ 451 |
1/2
@@ -3748,42 +3692,42 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 444 |
+ 452 |
|
|
} |
- | 445 |
+ 453 |
|
|
|
- | 446 |
+ 454 |
|
6 |
} |
- | 447 |
+ 455 |
|
|
|
- | 448 |
+ 456 |
|
|
else { |
- | 449 |
+ 457 |
2/2
@@ -3797,35 +3741,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 450 |
+ 458 |
-
- 1/2
-
- ✓ Branch 0 taken 6 times.
- ✗ Branch 1 not taken.
-
-
|
- 6 |
- fprintf(gnuplot_pipe, |
+ 6 |
+ fprintf(gnuplot_pipe, |
- | 451 |
+ 459 |
|
|
"splot '-' with lines lw 1 lc rgb '%s' title '%s'\\\n", |
- | 452 |
+ 460 |
|
6 |
current_satellite.plotting_color_.c_str(), |
- | 453 |
+ 461 |
1/2
@@ -3839,28 +3776,21 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 454 |
+ 462 |
|
6 |
} else { |
- | 455 |
+ 463 |
-
- 1/2
-
- ✓ Branch 0 taken 6 times.
- ✗ Branch 1 not taken.
-
-
|
- 6 |
- fprintf(gnuplot_pipe, "splot '-' with lines lw 1 title '%s'\\\n", |
+ 6 |
+ fprintf(gnuplot_pipe, "splot '-' with lines lw 1 title '%s'\\\n", |
- | 456 |
+ 464 |
1/2
@@ -3874,28 +3804,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 457 |
+ 465 |
|
|
} |
- | 458 |
+ 466 |
|
|
} |
- | 459 |
+ 467 |
|
|
|
- | 460 |
+ 468 |
2/2
@@ -3909,14 +3839,14 @@ GCC Code Coverage Report
for (size_t satellite_index = 1; |
|
- | 461 |
+ 469 |
|
72 |
satellite_index < input_satellite_vector.size(); satellite_index++) { |
- | 462 |
+ 470 |
2/4
@@ -3932,7 +3862,7 @@ GCC Code Coverage Report
current_satellite = input_satellite_vector.at(satellite_index); |
|
- | 463 |
+ 471 |
2/2
@@ -3946,7 +3876,7 @@ GCC Code Coverage Report
if (satellite_index < input_satellite_vector.size() - 1) { |
|
- | 464 |
+ 472 |
2/2
@@ -3960,35 +3890,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 465 |
+ 473 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, |
+ 18 |
+ fprintf(gnuplot_pipe, |
- | 466 |
+ 474 |
|
|
",'-' with lines lw 1 lc rgb '%s' title '%s' \\\n", |
- | 467 |
+ 475 |
|
18 |
current_satellite.plotting_color_.c_str(), |
- | 468 |
+ 476 |
1/2
@@ -4002,28 +3925,21 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 469 |
+ 477 |
|
18 |
} else { |
- | 470 |
+ 478 |
-
- 1/2
-
- ✓ Branch 0 taken 24 times.
- ✗ Branch 1 not taken.
-
-
|
- 24 |
- fprintf(gnuplot_pipe, ",'-' with lines lw 1 title '%s' \\\n", |
+ 24 |
+ fprintf(gnuplot_pipe, ",'-' with lines lw 1 title '%s' \\\n", |
- | 471 |
+ 479 |
1/2
@@ -4037,42 +3953,42 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 472 |
+ 480 |
|
|
} |
- | 473 |
+ 481 |
|
|
|
- | 474 |
+ 482 |
|
42 |
} |
- | 475 |
+ 483 |
|
|
|
- | 476 |
+ 484 |
|
|
else { |
- | 477 |
+ 485 |
2/2
@@ -4086,35 +4002,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 478 |
+ 486 |
-
- 1/2
-
- ✓ Branch 0 taken 6 times.
- ✗ Branch 1 not taken.
-
-
|
- 6 |
- fprintf(gnuplot_pipe, |
+ 6 |
+ fprintf(gnuplot_pipe, |
- | 479 |
+ 487 |
|
|
",'-' with lines lw 1 lc rgb '%s' title '%s'\\\n", |
- | 480 |
+ 488 |
|
6 |
current_satellite.plotting_color_.c_str(), |
- | 481 |
+ 489 |
1/2
@@ -4128,28 +4037,21 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 482 |
+ 490 |
|
6 |
} else { |
- | 483 |
+ 491 |
-
- 1/2
-
- ✓ Branch 0 taken 6 times.
- ✗ Branch 1 not taken.
-
-
|
- 6 |
- fprintf(gnuplot_pipe, ",'-' with lines lw 1 title '%s'\\\n", |
+ 6 |
+ fprintf(gnuplot_pipe, ",'-' with lines lw 1 title '%s'\\\n", |
- | 484 |
+ 492 |
1/2
@@ -4163,70 +4065,63 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 485 |
+ 493 |
|
|
} |
- | 486 |
+ 494 |
|
|
} |
- | 487 |
+ 495 |
|
54 |
} |
- | 488 |
+ 496 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, |
+ 18 |
+ fprintf(gnuplot_pipe, |
- | 489 |
+ 497 |
|
|
",R_Earth*cos(u)*cos(v),R_Earth*cos(u)*sin(v),R_Earth*sin(u) " |
- | 490 |
+ 498 |
|
|
"notitle with pm3d fillcolor rgbcolor 'navy'\n"); |
- | 491 |
+ 499 |
|
|
|
- | 492 |
+ 500 |
|
|
// now the orbit data, inline, one satellite at a time |
- | 493 |
+ 501 |
1/2
@@ -4240,7 +4135,7 @@ GCC Code Coverage Report
std::cout << "Running simulation...\n"; |
|
- | 494 |
+ 502 |
2/2
@@ -4254,14 +4149,14 @@ GCC Code Coverage Report
for (size_t satellite_index = 0; |
|
- | 495 |
+ 503 |
|
90 |
satellite_index < input_satellite_vector.size(); satellite_index++) { |
- | 496 |
+ 504 |
2/4
@@ -4277,14 +4172,14 @@ GCC Code Coverage Report
Satellite current_satellite = input_satellite_vector.at(satellite_index); |
|
- | 497 |
+ 505 |
|
|
std::array<double, 3> initial_position = |
- | 498 |
+ 506 |
1/2
@@ -4298,15 +4193,13 @@ GCC Code Coverage Report
current_satellite.get_ECI_position(); |
|
- | 499 |
+ 507 |
- 2/4
+ 1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 72 times.
- ✗ Branch 3 not taken.
|
@@ -4314,7 +4207,7 @@ GCC Code Coverage Report
fprintf(gnuplot_pipe, "%.17g %.17g %.17g\n", initial_position.at(0), |
- | 500 |
+ 508 |
2/4
@@ -4330,42 +4223,42 @@ GCC Code Coverage Report
initial_position.at(1), initial_position.at(2)); |
|
- | 501 |
+ 509 |
|
|
|
- | 502 |
+ 510 |
|
72 |
std::array<double, 3> evolved_position = {}; |
- | 503 |
+ 511 |
|
|
|
- | 504 |
+ 512 |
|
72 |
- double timestep_to_use = input_timestep; |
+ double timestep_to_use = input_sim_parameters.initial_timestep_guess; |
- | 505 |
+ 513 |
|
72 |
double current_satellite_time = |
- | 506 |
+ 514 |
1/2
@@ -4379,28 +4272,35 @@ GCC Code Coverage Report
current_satellite.get_instantaneous_time(); |
|
- | 507 |
+ 515 |
2/2
- ✓ Branch 0 taken 72 times.
- ✓ Branch 1 taken 9272 times.
+ ✓ Branch 0 taken 9272 times.
+ ✓ Branch 1 taken 72 times.
|
9344 |
- while (current_satellite_time < input_total_sim_time) { |
+ while (current_satellite_time < input_sim_parameters.total_sim_time) { |
- | 508 |
+ 516 |
+
+ |
+ 9272 |
+ std::pair<double, double> drag_elements = {input_sim_parameters.F_10, input_sim_parameters.A_p}; |
+
+
+ | 517 |
|
|
std::pair<double, int> new_timestep_and_error_code = |
- | 509 |
+ 518 |
2/4
@@ -4413,38 +4313,38 @@ GCC Code Coverage Report
|
18544 |
- current_satellite.evolve_RK45(input_epsilon, timestep_to_use, |
+ current_satellite.evolve_RK45(input_sim_parameters.epsilon, timestep_to_use, |
- | 510 |
+ 519 |
|
9272 |
- perturbation, atmospheric_drag, |
+ input_sim_parameters.perturbation_bool, |
- | 511 |
+ 520 |
|
9272 |
- drag_elements); |
+ input_sim_parameters.drag_bool, drag_elements); |
- | 512 |
+ 521 |
|
9272 |
double new_timestep = new_timestep_and_error_code.first; |
- | 513 |
+ 522 |
|
9272 |
int error_code = new_timestep_and_error_code.second; |
- | 514 |
+ 523 |
1/2
@@ -4458,56 +4358,56 @@ GCC Code Coverage Report
if (error_code != 0) { |
|
- | 515 |
+ 524 |
|
✗ |
std::cout << "Error code " << error_code << " detected, halting visualization\n"; |
- | 516 |
+ 525 |
|
✗ |
fprintf(gnuplot_pipe, "e\n"); |
- | 517 |
+ 526 |
|
✗ |
fprintf(gnuplot_pipe, "exit \n"); |
- | 518 |
+ 527 |
|
✗ |
pclose(gnuplot_pipe); |
- | 519 |
+ 528 |
|
✗ |
return; |
- | 520 |
+ 529 |
|
|
} |
- | 521 |
+ 530 |
|
9272 |
timestep_to_use = new_timestep; |
- | 522 |
+ 531 |
1/2
@@ -4521,7 +4421,7 @@ GCC Code Coverage Report
evolved_position = current_satellite.get_ECI_position(); |
|
- | 523 |
+ 532 |
1/2
@@ -4535,15 +4435,13 @@ GCC Code Coverage Report
current_satellite_time = current_satellite.get_instantaneous_time(); |
|
- | 524 |
+ 533 |
- 2/4
+ 1/2
✓ Branch 0 taken 9272 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 9272 times.
- ✗ Branch 3 not taken.
|
@@ -4551,7 +4449,7 @@ GCC Code Coverage Report
fprintf(gnuplot_pipe, "%.17g %.17g %.17g\n", evolved_position.at(0), |
- | 525 |
+ 534 |
2/4
@@ -4567,28 +4465,21 @@ GCC Code Coverage Report
evolved_position.at(1), evolved_position.at(2)); |
|
- | 526 |
+ 535 |
|
|
} |
- | 527 |
+ 536 |
-
- 1/2
-
- ✓ Branch 0 taken 72 times.
- ✗ Branch 1 not taken.
-
-
|
- 72 |
- fprintf(gnuplot_pipe, "e\n"); |
+ 72 |
+ fprintf(gnuplot_pipe, "e\n"); |
- | 528 |
+ 537 |
1/2
@@ -4602,49 +4493,49 @@ GCC Code Coverage Report
} |
|
- | 529 |
+ 538 |
+
+ |
+ |
+ |
+
+
+ | 539 |
1/2
- ✗ Branch 0 not taken.
- ✓ Branch 1 taken 18 times.
+ ✓ Branch 0 taken 18 times.
+ ✗ Branch 1 not taken.
|
18 |
- if (input_terminal == "qt"){ |
+ if (input_sim_parameters.terminal_name_3D == "qt"){ |
- | 530 |
+ 540 |
|
✗ |
fprintf(gnuplot_pipe, "pause mouse keypress\n"); |
- | 531 |
+ 541 |
|
✗ |
} |
- | 532 |
+ 542 |
-
- 1/2
-
- ✓ Branch 0 taken 18 times.
- ✗ Branch 1 not taken.
-
-
|
- 18 |
- fprintf(gnuplot_pipe, "exit \n"); |
+ 18 |
+ fprintf(gnuplot_pipe, "exit \n"); |
- | 533 |
+ 543 |
1/2
@@ -4658,7 +4549,7 @@ GCC Code Coverage Report
pclose(gnuplot_pipe); |
|
- | 534 |
+ 544 |
1/2
@@ -4672,14 +4563,14 @@ GCC Code Coverage Report
std::cout << "Done\n"; |
|
- | 535 |
+ 545 |
|
|
|
- | 536 |
+ 546 |
1/2
@@ -4693,119 +4584,98 @@ GCC Code Coverage Report
} else { |
|
- | 537 |
+ 547 |
|
✗ |
std::cout << "gnuplot not found"; |
- | 538 |
+ 548 |
|
|
} |
- | 539 |
+ 549 |
|
|
|
- | 540 |
+ 550 |
|
18 |
return; |
- | 541 |
+ 551 |
|
18 |
} |
- | 542 |
+ 552 |
|
|
|
- | 543 |
+ 553 |
|
|
// Objective: simulate the input satellites over the specified total sim time, |
- | 544 |
+ 554 |
|
|
// and plot a specific orbital element over time |
- | 545 |
+ 555 |
|
162 |
void sim_and_plot_orbital_elem_gnuplot( |
- | 546 |
-
- |
- |
- std::vector<Satellite> input_satellite_vector, const double input_timestep, |
-
-
- | 547 |
-
- |
- |
- const double input_total_sim_time, const double input_epsilon, |
-
-
- | 548 |
-
- |
- |
- const std::string input_orbital_element_name, |
-
-
- | 549 |
+ 556 |
|
|
- const std::string file_name, |
+ std::vector<Satellite> input_satellite_vector, |
- | 550 |
+ 557 |
|
|
- const bool perturbation, |
+ const SimParameters& input_sim_parameters, |
- | 551 |
+ 558 |
|
|
- const bool atmospheric_drag, |
+ std::string input_orbital_element_name, |
- | 552 |
+ 559 |
|
|
- const std::pair<double, double> drag_elements) { |
+ const std::string file_name) { |
- | 553 |
+ 560 |
1/2
@@ -4819,56 +4689,56 @@ GCC Code Coverage Report
if (input_satellite_vector.size() < 1) { |
|
- | 554 |
+ 561 |
|
✗ |
std::cout << "No input Satellite objects\n"; |
- | 555 |
+ 562 |
|
✗ |
return; |
- | 556 |
+ 563 |
|
|
} |
- | 557 |
+ 564 |
|
|
|
- | 558 |
+ 565 |
|
|
// first, open "pipe" to gnuplot |
- | 559 |
+ 566 |
|
162 |
FILE *gnuplot_pipe = popen("gnuplot", "w"); |
- | 560 |
+ 567 |
|
|
// if it exists |
- | 561 |
+ 568 |
1/2
@@ -4882,35 +4752,35 @@ GCC Code Coverage Report
if (gnuplot_pipe) { |
|
- | 562 |
+ 569 |
|
162 |
fprintf(gnuplot_pipe, "set terminal png size 800,500 font ',14' linewidth 2\n"); |
- | 563 |
+ 570 |
|
|
// formatting |
- | 564 |
+ 571 |
|
162 |
fprintf(gnuplot_pipe, "set output '../%s.png'\n",file_name.c_str()); |
- | 565 |
+ 572 |
|
162 |
fprintf(gnuplot_pipe, "set xlabel 'Time [s]'\n"); |
- | 566 |
+ 573 |
2/2
@@ -4924,21 +4794,21 @@ GCC Code Coverage Report
if (input_orbital_element_name == "Semimajor Axis") { |
|
- | 567 |
+ 574 |
|
36 |
fprintf(gnuplot_pipe, "set ylabel '%s [m]'\n", |
- | 568 |
+ 575 |
|
18 |
input_orbital_element_name.c_str()); |
- | 569 |
+ 576 |
2/2
@@ -4952,105 +4822,105 @@ GCC Code Coverage Report
} else if (input_orbital_element_name == "Eccentricity") { |
|
- | 570 |
+ 577 |
|
36 |
fprintf(gnuplot_pipe, "set ylabel '%s'\n", |
- | 571 |
+ 578 |
|
18 |
input_orbital_element_name.c_str()); |
- | 572 |
+ 579 |
|
18 |
} else { |
- | 573 |
+ 580 |
|
252 |
fprintf(gnuplot_pipe, "set ylabel '%s [deg]'\n", |
- | 574 |
+ 581 |
|
126 |
input_orbital_element_name.c_str()); |
- | 575 |
+ 582 |
|
|
} |
- | 576 |
+ 583 |
|
324 |
fprintf(gnuplot_pipe, "set title '%s simulated up to time %.2f s'\n", |
- | 577 |
+ 584 |
|
162 |
- input_orbital_element_name.c_str(), input_total_sim_time); |
+ input_orbital_element_name.c_str(), input_sim_parameters.total_sim_time); |
- | 578 |
+ 585 |
|
162 |
fprintf(gnuplot_pipe, "set key right bottom\n"); |
- | 579 |
+ 586 |
|
|
|
- | 580 |
+ 587 |
|
|
// plotting |
- | 581 |
+ 588 |
|
|
|
- | 582 |
+ 589 |
|
|
// first satellite |
- | 583 |
+ 590 |
|
162 |
Satellite current_satellite = input_satellite_vector.at(0); |
- | 584 |
+ 591 |
2/2
@@ -5064,7 +4934,7 @@ GCC Code Coverage Report
if (input_satellite_vector.size() == 1) { |
|
- | 585 |
+ 592 |
2/2
@@ -5078,35 +4948,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 586 |
+ 593 |
-
- 1/2
-
- ✓ Branch 0 taken 27 times.
- ✗ Branch 1 not taken.
-
-
|
- 27 |
- fprintf(gnuplot_pipe, |
+ 27 |
+ fprintf(gnuplot_pipe, |
- | 587 |
+ 594 |
|
|
"plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \n", |
- | 588 |
+ 595 |
|
27 |
current_satellite.plotting_color_.c_str(), |
- | 589 |
+ 596 |
1/2
@@ -5120,35 +4983,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 590 |
+ 597 |
|
27 |
} else { |
- | 591 |
+ 598 |
-
- 1/2
-
- ✓ Branch 0 taken 27 times.
- ✗ Branch 1 not taken.
-
-
|
- 27 |
- fprintf(gnuplot_pipe, |
+ 27 |
+ fprintf(gnuplot_pipe, |
- | 592 |
+ 599 |
|
|
"plot '-' using 1:2 with lines lw 1 title '%s' \n", |
- | 593 |
+ 600 |
1/2
@@ -5162,42 +5018,42 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 594 |
+ 601 |
|
|
} |
- | 595 |
+ 602 |
|
|
|
- | 596 |
+ 603 |
|
54 |
} |
- | 597 |
+ 604 |
|
|
|
- | 598 |
+ 605 |
|
|
else { |
- | 599 |
+ 606 |
2/2
@@ -5211,35 +5067,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 600 |
+ 607 |
-
- 1/2
-
- ✓ Branch 0 taken 54 times.
- ✗ Branch 1 not taken.
-
-
|
- 54 |
- fprintf(gnuplot_pipe, |
+ 54 |
+ fprintf(gnuplot_pipe, |
- | 601 |
+ 608 |
|
|
"plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\\\n", |
- | 602 |
+ 609 |
|
54 |
current_satellite.plotting_color_.c_str(), |
- | 603 |
+ 610 |
1/2
@@ -5253,35 +5102,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 604 |
+ 611 |
|
54 |
} else { |
- | 605 |
+ 612 |
-
- 1/2
-
- ✓ Branch 0 taken 54 times.
- ✗ Branch 1 not taken.
-
-
|
- 54 |
- fprintf(gnuplot_pipe, |
+ 54 |
+ fprintf(gnuplot_pipe, |
- | 606 |
+ 613 |
|
|
"plot '-' using 1:2 with lines lw 1 title '%s'\\\n", |
- | 607 |
+ 614 |
1/2
@@ -5295,28 +5137,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 608 |
+ 615 |
|
|
} |
- | 609 |
+ 616 |
|
|
} |
- | 610 |
+ 617 |
|
|
|
- | 611 |
+ 618 |
2/2
@@ -5330,14 +5172,14 @@ GCC Code Coverage Report
for (size_t satellite_index = 1; |
|
- | 612 |
+ 619 |
|
648 |
satellite_index < input_satellite_vector.size(); satellite_index++) { |
- | 613 |
+ 620 |
2/4
@@ -5353,7 +5195,7 @@ GCC Code Coverage Report
current_satellite = input_satellite_vector.at(satellite_index); |
|
- | 614 |
+ 621 |
2/2
@@ -5367,7 +5209,7 @@ GCC Code Coverage Report
if (satellite_index < input_satellite_vector.size() - 1) { |
|
- | 615 |
+ 622 |
2/2
@@ -5381,35 +5223,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 616 |
+ 623 |
-
- 1/2
-
- ✓ Branch 0 taken 162 times.
- ✗ Branch 1 not taken.
-
-
|
- 162 |
- fprintf(gnuplot_pipe, |
+ 162 |
+ fprintf(gnuplot_pipe, |
- | 617 |
+ 624 |
|
|
",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \\\n", |
- | 618 |
+ 625 |
|
162 |
current_satellite.plotting_color_.c_str(), |
- | 619 |
+ 626 |
1/2
@@ -5423,35 +5258,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 620 |
+ 627 |
|
162 |
} else { |
- | 621 |
+ 628 |
-
- 1/2
-
- ✓ Branch 0 taken 216 times.
- ✗ Branch 1 not taken.
-
-
|
- 216 |
- fprintf(gnuplot_pipe, |
+ 216 |
+ fprintf(gnuplot_pipe, |
- | 622 |
+ 629 |
|
|
",'-' using 1:2 with lines lw 1 title '%s' \\\n", |
- | 623 |
+ 630 |
1/2
@@ -5465,42 +5293,42 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 624 |
+ 631 |
|
|
} |
- | 625 |
+ 632 |
|
|
|
- | 626 |
+ 633 |
|
378 |
} |
- | 627 |
+ 634 |
|
|
|
- | 628 |
+ 635 |
|
|
else { |
- | 629 |
+ 636 |
2/2
@@ -5514,35 +5342,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 630 |
+ 637 |
-
- 1/2
-
- ✓ Branch 0 taken 54 times.
- ✗ Branch 1 not taken.
-
-
|
- 54 |
- fprintf(gnuplot_pipe, |
+ 54 |
+ fprintf(gnuplot_pipe, |
- | 631 |
+ 638 |
|
|
",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\n", |
- | 632 |
+ 639 |
|
54 |
current_satellite.plotting_color_.c_str(), |
- | 633 |
+ 640 |
1/2
@@ -5556,28 +5377,21 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 634 |
+ 641 |
|
54 |
} else { |
- | 635 |
+ 642 |
-
- 1/2
-
- ✓ Branch 0 taken 54 times.
- ✗ Branch 1 not taken.
-
-
|
- 54 |
- fprintf(gnuplot_pipe, ",'-' using 1:2 with lines lw 1 title '%s'\n", |
+ 54 |
+ fprintf(gnuplot_pipe, ",'-' using 1:2 with lines lw 1 title '%s'\n", |
- | 636 |
+ 643 |
1/2
@@ -5591,42 +5405,42 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 637 |
+ 644 |
|
|
} |
- | 638 |
+ 645 |
|
|
} |
- | 639 |
+ 646 |
|
486 |
} |
- | 640 |
+ 647 |
|
|
|
- | 641 |
+ 648 |
|
|
// now the orbit data, inline, one satellite at a time |
- | 642 |
+ 649 |
1/2
@@ -5640,7 +5454,7 @@ GCC Code Coverage Report
std::cout << "Running simulation...\n"; |
|
- | 643 |
+ 650 |
2/2
@@ -5654,14 +5468,14 @@ GCC Code Coverage Report
for (size_t satellite_index = 0; |
|
- | 644 |
+ 651 |
|
810 |
satellite_index < input_satellite_vector.size(); satellite_index++) { |
- | 645 |
+ 652 |
2/4
@@ -5677,14 +5491,14 @@ GCC Code Coverage Report
Satellite current_satellite = input_satellite_vector.at(satellite_index); |
|
- | 646 |
+ 653 |
|
648 |
double val = |
- | 647 |
+ 654 |
2/4
@@ -5700,14 +5514,14 @@ GCC Code Coverage Report
current_satellite.get_orbital_parameter(input_orbital_element_name); |
|
- | 648 |
+ 655 |
|
648 |
double current_satellite_time = |
- | 649 |
+ 656 |
1/2
@@ -5721,49 +5535,42 @@ GCC Code Coverage Report
current_satellite.get_instantaneous_time(); |
|
- | 650 |
+ 657 |
-
- 1/2
-
- ✓ Branch 0 taken 648 times.
- ✗ Branch 1 not taken.
-
-
|
- 648 |
- fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, val); |
+ 648 |
+ fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, val); |
- | 651 |
+ 658 |
|
|
|
- | 652 |
+ 659 |
|
648 |
double evolved_val = {0}; |
- | 653 |
+ 660 |
|
|
|
- | 654 |
+ 661 |
|
648 |
- double timestep_to_use = input_timestep; |
+ double timestep_to_use = input_sim_parameters.initial_timestep_guess; |
- | 655 |
+ 662 |
1/2
@@ -5777,7 +5584,7 @@ GCC Code Coverage Report
current_satellite_time = current_satellite.get_instantaneous_time(); |
|
- | 656 |
+ 663 |
2/2
@@ -5788,17 +5595,38 @@ GCC Code Coverage Report
|
84096 |
- while (current_satellite_time < input_total_sim_time) { |
+ while (current_satellite_time < input_sim_parameters.total_sim_time) { |
- | 657 |
+ 664 |
+
+ |
+ |
+ // std::cout << "========================================================\n"; |
+
+
+ | 665 |
+
+ |
+ |
+ // std::cout << "Running an evolve step at satellite time " << current_satellite_time << "\n"; |
+
+
+ | 666 |
+
+ |
+ 83448 |
+ std::pair<double, double> drag_elements = {input_sim_parameters.F_10, input_sim_parameters.A_p}; |
+
+
+ | 667 |
|
|
std::pair<double, int> new_timestep_and_error_code = |
- | 658 |
+ 668 |
2/4
@@ -5811,45 +5639,45 @@ GCC Code Coverage Report
|
166896 |
- current_satellite.evolve_RK45(input_epsilon, timestep_to_use, |
+ current_satellite.evolve_RK45(input_sim_parameters.epsilon, timestep_to_use, |
- | 659 |
+ 669 |
|
83448 |
- perturbation, atmospheric_drag, |
+ input_sim_parameters.perturbation_bool, |
- | 660 |
+ 670 |
|
83448 |
- drag_elements); |
+ input_sim_parameters.drag_bool, drag_elements); |
- | 661 |
+ 671 |
|
83448 |
double new_timestep = new_timestep_and_error_code.first; |
- | 662 |
+ 672 |
|
83448 |
int error_code = new_timestep_and_error_code.second; |
- | 663 |
+ 673 |
|
|
|
- | 664 |
+ 674 |
1/2
@@ -5863,63 +5691,63 @@ GCC Code Coverage Report
if (error_code != 0) { |
|
- | 665 |
+ 675 |
|
✗ |
std::cout << "Error code " << error_code << " detected, halting visualization\n"; |
- | 666 |
+ 676 |
|
✗ |
fprintf(gnuplot_pipe, "e\n"); |
- | 667 |
+ 677 |
|
✗ |
fprintf(gnuplot_pipe, "exit \n"); |
- | 668 |
+ 678 |
|
✗ |
pclose(gnuplot_pipe); |
- | 669 |
+ 679 |
|
✗ |
return; |
- | 670 |
+ 680 |
|
|
} |
- | 671 |
+ 681 |
|
83448 |
timestep_to_use = new_timestep; |
- | 672 |
+ 682 |
|
83448 |
evolved_val = |
- | 673 |
+ 683 |
2/4
@@ -5935,7 +5763,7 @@ GCC Code Coverage Report
current_satellite.get_orbital_parameter(input_orbital_element_name); |
|
- | 674 |
+ 684 |
1/2
@@ -5949,65 +5777,49 @@ GCC Code Coverage Report
current_satellite_time = current_satellite.get_instantaneous_time(); |
|
- | 675 |
+ 685 |
|
|
// printf("%.17g %.17g\n", current_satellite_time, |
- | 676 |
+ 686 |
|
|
// evolved_val); |
- | 677 |
+ 687 |
-
- 2/4
-
- ✓ Branch 0 taken 83448 times.
- ✗ Branch 1 not taken.
- ✓ Branch 2 taken 83448 times.
- ✗ Branch 3 not taken.
-
-
|
- 166896 |
- fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, |
+ 166896 |
+ fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, |
- | 678 |
+ 688 |
|
83448 |
evolved_val); |
- | 679 |
+ 689 |
|
|
} |
- | 680 |
+ 690 |
-
- 1/2
-
- ✓ Branch 0 taken 648 times.
- ✗ Branch 1 not taken.
-
-
|
- 648 |
- fprintf(gnuplot_pipe, "e\n"); |
+ 648 |
+ fprintf(gnuplot_pipe, "e\n"); |
- | 681 |
+ 691 |
1/2
@@ -6021,42 +5833,28 @@ GCC Code Coverage Report
} |
|
- | 682 |
+ 692 |
-
- 1/2
-
- ✓ Branch 0 taken 162 times.
- ✗ Branch 1 not taken.
-
-
|
- 162 |
- fprintf(gnuplot_pipe, "pause mouse keypress\n"); |
+ 162 |
+ fprintf(gnuplot_pipe, "pause mouse keypress\n"); |
- | 683 |
+ 693 |
|
|
|
- | 684 |
+ 694 |
-
- 1/2
-
- ✓ Branch 0 taken 162 times.
- ✗ Branch 1 not taken.
-
-
|
- 162 |
- fprintf(gnuplot_pipe, "exit \n"); |
+ 162 |
+ fprintf(gnuplot_pipe, "exit \n"); |
- | 685 |
+ 695 |
1/2
@@ -6070,7 +5868,7 @@ GCC Code Coverage Report
pclose(gnuplot_pipe); |
|
- | 686 |
+ 696 |
1/2
@@ -6084,14 +5882,14 @@ GCC Code Coverage Report
std::cout << "Done\n"; |
|
- | 687 |
+ 697 |
|
|
|
- | 688 |
+ 698 |
1/3
@@ -6106,384 +5904,363 @@ GCC Code Coverage Report
} else { |
|
- | 689 |
+ 699 |
|
✗ |
std::cout << "gnuplot not found"; |
- | 690 |
+ 700 |
|
|
} |
- | 691 |
+ 701 |
|
|
|
- | 692 |
+ 702 |
|
162 |
return; |
- | 693 |
+ 703 |
|
162 |
} |
- | 694 |
+ 704 |
|
|
|
- | 695 |
+ 705 |
|
- 13480499 |
+ 13480501 |
Matrix3d z_rot_matrix(const double input_angle) { |
- | 696 |
+ 706 |
|
- 13480499 |
+ 13480501 |
Matrix3d z_rotation_matrix; |
- | 697 |
+ 707 |
3/6
- ✓ Branch 0 taken 13480499 times.
+ ✓ Branch 0 taken 13480501 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 13480499 times.
+ ✓ Branch 2 taken 13480501 times.
✗ Branch 3 not taken.
- ✓ Branch 4 taken 13480499 times.
+ ✓ Branch 4 taken 13480501 times.
✗ Branch 5 not taken.
|
- 26960998 |
+ 26961002 |
z_rotation_matrix << cos(input_angle), -sin(input_angle), 0, |
- | 698 |
+ 708 |
3/6
- ✓ Branch 0 taken 13480499 times.
+ ✓ Branch 0 taken 13480501 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 13480499 times.
+ ✓ Branch 2 taken 13480501 times.
✗ Branch 3 not taken.
- ✓ Branch 4 taken 13480499 times.
+ ✓ Branch 4 taken 13480501 times.
✗ Branch 5 not taken.
|
- 13480499 |
+ 13480501 |
sin(input_angle),cos(input_angle), 0, |
- | 699 |
+ 709 |
2/4
- ✓ Branch 0 taken 13480499 times.
+ ✓ Branch 0 taken 13480501 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 13480499 times.
+ ✓ Branch 2 taken 13480501 times.
✗ Branch 3 not taken.
|
- 13480499 |
+ 13480501 |
0, 0, 1; |
- | 700 |
+ 710 |
|
|
|
- | 701 |
+ 711 |
|
- 13480499 |
+ 13480501 |
return z_rotation_matrix; |
- | 702 |
+ 712 |
|
✗ |
} |
- | 703 |
+ 713 |
|
|
|
- | 704 |
+ 714 |
|
- 53 |
+ 55 |
Matrix3d y_rot_matrix(const double input_angle) { |
- | 705 |
+ 715 |
|
- 53 |
+ 55 |
Matrix3d y_rotation_matrix; |
- | 706 |
+ 716 |
6/12
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 53 times.
+ ✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
- ✓ Branch 4 taken 53 times.
+ ✓ Branch 4 taken 55 times.
✗ Branch 5 not taken.
- ✓ Branch 6 taken 53 times.
+ ✓ Branch 6 taken 55 times.
✗ Branch 7 not taken.
- ✓ Branch 8 taken 53 times.
+ ✓ Branch 8 taken 55 times.
✗ Branch 9 not taken.
- ✓ Branch 10 taken 53 times.
+ ✓ Branch 10 taken 55 times.
✗ Branch 11 not taken.
|
- 106 |
+ 110 |
y_rotation_matrix << cos(input_angle), 0, sin(input_angle), 0, 1, 0, |
- | 707 |
+ 717 |
2/4
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 53 times.
+ ✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
|
- 53 |
+ 55 |
-sin(input_angle), 0, cos(input_angle); |
- | 708 |
+ 718 |
|
|
|
- | 709 |
+ 719 |
|
- 53 |
+ 55 |
return y_rotation_matrix; |
- | 710 |
+ 720 |
|
✗ |
} |
- | 711 |
+ 721 |
|
|
|
- | 712 |
+ 722 |
|
- 53 |
+ 55 |
Matrix3d x_rot_matrix(const double input_angle) { |
- | 713 |
+ 723 |
|
- 53 |
+ 55 |
Matrix3d x_rotation_matrix; |
- | 714 |
+ 724 |
7/14
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 53 times.
+ ✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
- ✓ Branch 4 taken 53 times.
+ ✓ Branch 4 taken 55 times.
✗ Branch 5 not taken.
- ✓ Branch 6 taken 53 times.
+ ✓ Branch 6 taken 55 times.
✗ Branch 7 not taken.
- ✓ Branch 8 taken 53 times.
+ ✓ Branch 8 taken 55 times.
✗ Branch 9 not taken.
- ✓ Branch 10 taken 53 times.
+ ✓ Branch 10 taken 55 times.
✗ Branch 11 not taken.
- ✓ Branch 12 taken 53 times.
+ ✓ Branch 12 taken 55 times.
✗ Branch 13 not taken.
|
- 106 |
+ 110 |
x_rotation_matrix << 1, 0, 0, 0, cos(input_angle), -sin(input_angle), 0, |
- | 715 |
+ 725 |
1/2
- ✓ Branch 0 taken 53 times.
+ ✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
|
- 53 |
+ 55 |
sin(input_angle), cos(input_angle); |
- | 716 |
+ 726 |
|
|
|
- | 717 |
+ 727 |
|
- 53 |
+ 55 |
return x_rotation_matrix; |
- | 718 |
+ 728 |
|
✗ |
} |
- | 719 |
+ 729 |
|
|
|
- | 720 |
+ 730 |
|
|
|
- | 721 |
+ 731 |
|
|
// Objective: simulate the input satellites over the specified total sim time, |
- | 722 |
+ 732 |
|
|
// and plot a specific attitude-related value over time |
- | 723 |
+ 733 |
|
180 |
void sim_and_plot_attitude_evolution_gnuplot( |
- | 724 |
+ 734 |
|
|
- std::vector<Satellite> input_satellite_vector, const double input_timestep, |
+ std::vector<Satellite> input_satellite_vector, |
- | 725 |
+ 735 |
|
|
- const double input_total_sim_time, const double input_epsilon, |
+ const SimParameters& input_sim_parameters, |
- | 726 |
+ 736 |
|
|
const std::string input_plotted_val_name, |
- | 727 |
-
- |
- |
- const std::string file_name, |
-
-
- | 728 |
-
- |
- |
- const bool perturbation, |
-
-
- | 729 |
-
- |
- |
- const bool atmospheric_drag, |
-
-
- | 730 |
+ 737 |
|
|
- const std::pair<double, double> drag_elements) { |
+ const std::string file_name) { |
- | 731 |
+ 738 |
1/2
@@ -6497,56 +6274,56 @@ GCC Code Coverage Report
if (input_satellite_vector.size() < 1) { |
|
- | 732 |
+ 739 |
|
✗ |
std::cout << "No input Satellite objects\n"; |
- | 733 |
+ 740 |
|
✗ |
return; |
- | 734 |
+ 741 |
|
|
} |
- | 735 |
+ 742 |
|
|
|
- | 736 |
+ 743 |
|
|
// first, open "pipe" to gnuplot |
- | 737 |
+ 744 |
|
180 |
FILE *gnuplot_pipe = popen("gnuplot", "w"); |
- | 738 |
+ 745 |
|
|
// if it exists |
- | 739 |
+ 746 |
1/2
@@ -6560,35 +6337,35 @@ GCC Code Coverage Report
if (gnuplot_pipe) { |
|
- | 740 |
+ 747 |
|
180 |
fprintf(gnuplot_pipe, "set terminal png size 800,500 font ',14' linewidth 2\n"); |
- | 741 |
+ 748 |
|
|
// formatting |
- | 742 |
+ 749 |
|
180 |
fprintf(gnuplot_pipe, "set output '../%s.png'\n",file_name.c_str()); |
- | 743 |
+ 750 |
|
180 |
fprintf(gnuplot_pipe, "set xlabel 'Time [s]'\n"); |
- | 744 |
+ 751 |
4/4
@@ -6604,7 +6381,7 @@ GCC Code Coverage Report
if ((input_plotted_val_name == "omega_x") || |
|
- | 745 |
+ 752 |
2/2
@@ -6618,28 +6395,28 @@ GCC Code Coverage Report
(input_plotted_val_name == "omega_y") || |
|
- | 746 |
+ 753 |
|
144 |
(input_plotted_val_name == "omega_z")) { |
- | 747 |
+ 754 |
|
108 |
fprintf(gnuplot_pipe, "set ylabel '%s [deg/s]'\n", |
- | 748 |
+ 755 |
|
54 |
input_plotted_val_name.c_str()); |
- | 749 |
+ 756 |
4/4
@@ -6655,7 +6432,7 @@ GCC Code Coverage Report
} else if ((input_plotted_val_name == "Roll") || |
|
- | 750 |
+ 757 |
2/2
@@ -6669,112 +6446,112 @@ GCC Code Coverage Report
(input_plotted_val_name == "Pitch") || |
|
- | 751 |
+ 758 |
|
90 |
(input_plotted_val_name == "Yaw")) { |
- | 752 |
+ 759 |
|
108 |
fprintf(gnuplot_pipe, "set ylabel '%s [deg]'\n", |
- | 753 |
+ 760 |
|
54 |
input_plotted_val_name.c_str()); |
- | 754 |
+ 761 |
|
54 |
} else { |
- | 755 |
+ 762 |
|
144 |
fprintf(gnuplot_pipe, "set ylabel '%s'\n", |
- | 756 |
+ 763 |
|
72 |
input_plotted_val_name.c_str()); |
- | 757 |
+ 764 |
|
|
} |
- | 758 |
+ 765 |
|
360 |
fprintf(gnuplot_pipe, "set title '%s simulated up to time %.2f s'\n", |
- | 759 |
+ 766 |
|
180 |
- input_plotted_val_name.c_str(), input_total_sim_time); |
+ input_plotted_val_name.c_str(), input_sim_parameters.total_sim_time); |
- | 760 |
+ 767 |
|
180 |
fprintf(gnuplot_pipe, "set key right bottom\n"); |
- | 761 |
+ 768 |
|
|
|
- | 762 |
+ 769 |
|
|
// plotting |
- | 763 |
+ 770 |
|
|
|
- | 764 |
+ 771 |
|
|
// first satellite |
- | 765 |
+ 772 |
|
180 |
Satellite current_satellite = input_satellite_vector.at(0); |
- | 766 |
+ 773 |
2/2
@@ -6788,7 +6565,7 @@ GCC Code Coverage Report
if (input_satellite_vector.size() == 1) { |
|
- | 767 |
+ 774 |
2/2
@@ -6802,35 +6579,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 768 |
+ 775 |
-
- 1/2
-
- ✓ Branch 0 taken 30 times.
- ✗ Branch 1 not taken.
-
-
|
- 30 |
- fprintf(gnuplot_pipe, |
+ 30 |
+ fprintf(gnuplot_pipe, |
- | 769 |
+ 776 |
|
|
"plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \n", |
- | 770 |
+ 777 |
|
30 |
current_satellite.plotting_color_.c_str(), |
- | 771 |
+ 778 |
1/2
@@ -6844,35 +6614,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 772 |
+ 779 |
|
30 |
} else { |
- | 773 |
+ 780 |
-
- 1/2
-
- ✓ Branch 0 taken 30 times.
- ✗ Branch 1 not taken.
-
-
|
- 30 |
- fprintf(gnuplot_pipe, |
+ 30 |
+ fprintf(gnuplot_pipe, |
- | 774 |
+ 781 |
|
|
"plot '-' using 1:2 with lines lw 1 title '%s' \n", |
- | 775 |
+ 782 |
1/2
@@ -6886,42 +6649,42 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 776 |
+ 783 |
|
|
} |
- | 777 |
+ 784 |
|
|
|
- | 778 |
+ 785 |
|
60 |
} |
- | 779 |
+ 786 |
|
|
|
- | 780 |
+ 787 |
|
|
else { |
- | 781 |
+ 788 |
2/2
@@ -6935,35 +6698,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 782 |
+ 789 |
-
- 1/2
-
- ✓ Branch 0 taken 60 times.
- ✗ Branch 1 not taken.
-
-
|
- 60 |
- fprintf(gnuplot_pipe, |
+ 60 |
+ fprintf(gnuplot_pipe, |
- | 783 |
+ 790 |
|
|
"plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\\\n", |
- | 784 |
+ 791 |
|
60 |
current_satellite.plotting_color_.c_str(), |
- | 785 |
+ 792 |
1/2
@@ -6977,35 +6733,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 786 |
+ 793 |
|
60 |
} else { |
- | 787 |
+ 794 |
-
- 1/2
-
- ✓ Branch 0 taken 60 times.
- ✗ Branch 1 not taken.
-
-
|
- 60 |
- fprintf(gnuplot_pipe, |
+ 60 |
+ fprintf(gnuplot_pipe, |
- | 788 |
+ 795 |
|
|
"plot '-' using 1:2 with lines lw 1 title '%s'\\\n", |
- | 789 |
+ 796 |
1/2
@@ -7019,28 +6768,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 790 |
+ 797 |
|
|
} |
- | 791 |
+ 798 |
|
|
} |
- | 792 |
+ 799 |
|
|
|
- | 793 |
+ 800 |
2/2
@@ -7054,14 +6803,14 @@ GCC Code Coverage Report
for (size_t satellite_index = 1; |
|
- | 794 |
+ 801 |
|
720 |
satellite_index < input_satellite_vector.size(); satellite_index++) { |
- | 795 |
+ 802 |
2/4
@@ -7077,7 +6826,7 @@ GCC Code Coverage Report
current_satellite = input_satellite_vector.at(satellite_index); |
|
- | 796 |
+ 803 |
2/2
@@ -7091,7 +6840,7 @@ GCC Code Coverage Report
if (satellite_index < input_satellite_vector.size() - 1) { |
|
- | 797 |
+ 804 |
2/2
@@ -7105,35 +6854,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 798 |
+ 805 |
-
- 1/2
-
- ✓ Branch 0 taken 180 times.
- ✗ Branch 1 not taken.
-
-
|
- 180 |
- fprintf(gnuplot_pipe, |
+ 180 |
+ fprintf(gnuplot_pipe, |
- | 799 |
+ 806 |
|
|
",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \\\n", |
- | 800 |
+ 807 |
|
180 |
current_satellite.plotting_color_.c_str(), |
- | 801 |
+ 808 |
1/2
@@ -7147,35 +6889,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 802 |
+ 809 |
|
180 |
} else { |
- | 803 |
+ 810 |
-
- 1/2
-
- ✓ Branch 0 taken 240 times.
- ✗ Branch 1 not taken.
-
-
|
- 240 |
- fprintf(gnuplot_pipe, |
+ 240 |
+ fprintf(gnuplot_pipe, |
- | 804 |
+ 811 |
|
|
",'-' using 1:2 with lines lw 1 title '%s' \\\n", |
- | 805 |
+ 812 |
1/2
@@ -7189,42 +6924,42 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 806 |
+ 813 |
|
|
} |
- | 807 |
+ 814 |
|
|
|
- | 808 |
+ 815 |
|
420 |
} |
- | 809 |
+ 816 |
|
|
|
- | 810 |
+ 817 |
|
|
else { |
- | 811 |
+ 818 |
2/2
@@ -7238,35 +6973,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 812 |
+ 819 |
-
- 1/2
-
- ✓ Branch 0 taken 60 times.
- ✗ Branch 1 not taken.
-
-
|
- 60 |
- fprintf(gnuplot_pipe, |
+ 60 |
+ fprintf(gnuplot_pipe, |
- | 813 |
+ 820 |
|
|
",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\n", |
- | 814 |
+ 821 |
|
60 |
current_satellite.plotting_color_.c_str(), |
- | 815 |
+ 822 |
1/2
@@ -7280,28 +7008,21 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 816 |
+ 823 |
|
60 |
} else { |
- | 817 |
+ 824 |
-
- 1/2
-
- ✓ Branch 0 taken 60 times.
- ✗ Branch 1 not taken.
-
-
|
- 60 |
- fprintf(gnuplot_pipe, ",'-' using 1:2 with lines lw 1 title '%s'\n", |
+ 60 |
+ fprintf(gnuplot_pipe, ",'-' using 1:2 with lines lw 1 title '%s'\n", |
- | 818 |
+ 825 |
1/2
@@ -7315,42 +7036,42 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 819 |
+ 826 |
|
|
} |
- | 820 |
+ 827 |
|
|
} |
- | 821 |
+ 828 |
|
540 |
} |
- | 822 |
+ 829 |
|
|
|
- | 823 |
+ 830 |
|
|
// now the orbit data, inline, one satellite at a time |
- | 824 |
+ 831 |
1/2
@@ -7364,7 +7085,7 @@ GCC Code Coverage Report
std::cout << "Running simulation...\n"; |
|
- | 825 |
+ 832 |
2/2
@@ -7378,14 +7099,14 @@ GCC Code Coverage Report
for (size_t satellite_index = 0; |
|
- | 826 |
+ 833 |
|
900 |
satellite_index < input_satellite_vector.size(); satellite_index++) { |
- | 827 |
+ 834 |
2/4
@@ -7401,7 +7122,7 @@ GCC Code Coverage Report
Satellite current_satellite = input_satellite_vector.at(satellite_index); |
|
- | 828 |
+ 835 |
2/4
@@ -7417,14 +7138,14 @@ GCC Code Coverage Report
double val = current_satellite.get_attitude_val(input_plotted_val_name); |
|
- | 829 |
+ 836 |
|
720 |
double current_satellite_time = |
- | 830 |
+ 837 |
1/2
@@ -7438,49 +7159,42 @@ GCC Code Coverage Report
current_satellite.get_instantaneous_time(); |
|
- | 831 |
+ 838 |
-
- 1/2
-
- ✓ Branch 0 taken 720 times.
- ✗ Branch 1 not taken.
-
-
|
- 720 |
- fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, val); |
+ 720 |
+ fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, val); |
- | 832 |
+ 839 |
|
|
|
- | 833 |
+ 840 |
|
720 |
double evolved_val = {0}; |
- | 834 |
+ 841 |
|
|
|
- | 835 |
+ 842 |
|
720 |
- double timestep_to_use = input_timestep; |
+ double timestep_to_use = input_sim_parameters.initial_timestep_guess; |
- | 836 |
+ 843 |
1/2
@@ -7494,7 +7208,7 @@ GCC Code Coverage Report
current_satellite_time = current_satellite.get_instantaneous_time(); |
|
- | 837 |
+ 844 |
2/2
@@ -7505,17 +7219,24 @@ GCC Code Coverage Report
|
96210 |
- while (current_satellite_time < input_total_sim_time) { |
+ while (current_satellite_time < input_sim_parameters.total_sim_time) { |
- | 838 |
+ 845 |
+
+ |
+ 95490 |
+ std::pair<double, double> drag_elements = {input_sim_parameters.F_10, input_sim_parameters.A_p}; |
+
+
+ | 846 |
|
|
std::pair<double, int> new_timestep_and_error_code = |
- | 839 |
+ 847 |
2/4
@@ -7528,45 +7249,45 @@ GCC Code Coverage Report
|
190980 |
- current_satellite.evolve_RK45(input_epsilon, timestep_to_use, |
+ current_satellite.evolve_RK45(input_sim_parameters.epsilon, timestep_to_use, |
- | 840 |
+ 848 |
|
95490 |
- perturbation, atmospheric_drag, |
+ input_sim_parameters.perturbation_bool, |
- | 841 |
+ 849 |
|
95490 |
- drag_elements); |
+ input_sim_parameters.drag_bool, drag_elements); |
- | 842 |
+ 850 |
|
95490 |
double new_timestep = new_timestep_and_error_code.first; |
- | 843 |
+ 851 |
|
95490 |
int error_code = new_timestep_and_error_code.second; |
- | 844 |
+ 852 |
|
|
|
- | 845 |
+ 853 |
1/2
@@ -7580,63 +7301,63 @@ GCC Code Coverage Report
if (error_code != 0) { |
|
- | 846 |
+ 854 |
|
✗ |
std::cout << "Error code " << error_code << " detected, halting visualization\n"; |
- | 847 |
+ 855 |
|
✗ |
fprintf(gnuplot_pipe, "e\n"); |
- | 848 |
+ 856 |
|
✗ |
fprintf(gnuplot_pipe, "exit \n"); |
- | 849 |
+ 857 |
|
✗ |
pclose(gnuplot_pipe); |
- | 850 |
+ 858 |
|
✗ |
return; |
- | 851 |
+ 859 |
|
|
} |
- | 852 |
+ 860 |
|
95490 |
timestep_to_use = new_timestep; |
- | 853 |
+ 861 |
|
95490 |
evolved_val = |
- | 854 |
+ 862 |
2/4
@@ -7652,7 +7373,7 @@ GCC Code Coverage Report
current_satellite.get_attitude_val(input_plotted_val_name); |
|
- | 855 |
+ 863 |
1/2
@@ -7666,51 +7387,35 @@ GCC Code Coverage Report
current_satellite_time = current_satellite.get_instantaneous_time(); |
|
- | 856 |
+ 864 |
-
- 2/4
-
- ✓ Branch 0 taken 95490 times.
- ✗ Branch 1 not taken.
- ✓ Branch 2 taken 95490 times.
- ✗ Branch 3 not taken.
-
-
|
- 190980 |
- fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, |
+ 190980 |
+ fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, |
- | 857 |
+ 865 |
|
95490 |
evolved_val); |
- | 858 |
+ 866 |
|
|
} |
- | 859 |
+ 867 |
-
- 1/2
-
- ✓ Branch 0 taken 720 times.
- ✗ Branch 1 not taken.
-
-
|
- 720 |
- fprintf(gnuplot_pipe, "e\n"); |
+ 720 |
+ fprintf(gnuplot_pipe, "e\n"); |
- | 860 |
+ 868 |
1/2
@@ -7724,42 +7429,28 @@ GCC Code Coverage Report
} |
|
- | 861 |
+ 869 |
-
- 1/2
-
- ✓ Branch 0 taken 180 times.
- ✗ Branch 1 not taken.
-
-
|
- 180 |
- fprintf(gnuplot_pipe, "pause mouse keypress\n"); |
+ 180 |
+ fprintf(gnuplot_pipe, "pause mouse keypress\n"); |
- | 862 |
+ 870 |
|
|
|
- | 863 |
+ 871 |
-
- 1/2
-
- ✓ Branch 0 taken 180 times.
- ✗ Branch 1 not taken.
-
-
|
- 180 |
- fprintf(gnuplot_pipe, "exit \n"); |
+ 180 |
+ fprintf(gnuplot_pipe, "exit \n"); |
- | 864 |
+ 872 |
1/2
@@ -7773,7 +7464,7 @@ GCC Code Coverage Report
pclose(gnuplot_pipe); |
|
- | 865 |
+ 873 |
1/2
@@ -7787,21 +7478,21 @@ GCC Code Coverage Report
std::cout << "Done\n"; |
|
- | 866 |
+ 874 |
|
|
|
- | 867 |
+ 875 |
|
|
|
- | 868 |
+ 876 |
1/3
@@ -7816,392 +7507,392 @@ GCC Code Coverage Report
} else { |
|
- | 869 |
+ 877 |
|
✗ |
std::cout << "gnuplot not found"; |
- | 870 |
+ 878 |
|
|
} |
- | 871 |
+ 879 |
|
|
|
- | 872 |
+ 880 |
|
180 |
return; |
- | 873 |
+ 881 |
|
180 |
} |
- | 874 |
+ 882 |
|
|
|
- | 875 |
+ 883 |
|
- 53 |
+ 55 |
Matrix3d rollyawpitch_bodyframe_to_LVLH_matrix(const double input_roll, |
- | 876 |
+ 884 |
|
|
const double input_pitch, |
- | 877 |
+ 885 |
|
|
const double input_yaw) { |
- | 878 |
+ 886 |
|
|
// Going off convention in |
- | 879 |
+ 887 |
|
|
// https://ntrs.nasa.gov/api/citations/19770024112/downloads/19770024112.pdf |
- | 880 |
+ 888 |
|
|
// which appears to be first rotating by pitch, then yaw, then roll |
- | 881 |
+ 889 |
|
|
// This is a convention where the rotations are performed as: v_body = |
- | 882 |
+ 890 |
|
|
// R_x(roll)R_z(yaw)R_y(pitch)v_LVLH That's an intrinsic Tait-Bryan xzy |
- | 883 |
+ 891 |
|
|
// sequence, following convention described in |
- | 884 |
+ 892 |
|
|
// https://en.wikipedia.org/wiki/Rotation_matrix To my understanding, this is |
- | 885 |
+ 893 |
|
|
// equivalent to an extrinsic Tait-Bryan yzx sequence |
- | 886 |
+ 894 |
|
|
|
- | 887 |
+ 895 |
|
|
// First going to construct LVLH_to_bodyframe matrix, then take transpose to |
- | 888 |
+ 896 |
|
|
// make it the bodyframe_to_LVLH matrix |
- | 889 |
+ 897 |
|
- 159 |
+ 165 |
Matrix3d bodyframe_to_LVLH_matrix = x_rot_matrix(input_roll) * |
- | 890 |
+ 898 |
|
- 106 |
+ 110 |
z_rot_matrix(input_yaw) * |
- | 891 |
+ 899 |
|
- 53 |
+ 55 |
y_rot_matrix(input_pitch); |
- | 892 |
+ 900 |
|
- 53 |
+ 55 |
bodyframe_to_LVLH_matrix.transpose(); |
- | 893 |
+ 901 |
|
|
|
- | 894 |
+ 902 |
|
- 53 |
+ 55 |
return bodyframe_to_LVLH_matrix; |
- | 895 |
+ 903 |
|
|
} |
- | 896 |
+ 904 |
|
|
|
- | 897 |
+ 905 |
|
- 55 |
+ 57 |
std::array<double, 4> rollyawpitch_angles_to_quaternion( |
- | 898 |
+ 906 |
|
|
const double input_roll, const double input_pitch, const double input_yaw) { |
- | 899 |
+ 907 |
|
|
// Refs : |
- | 900 |
+ 908 |
|
|
// https://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/Euler%20to%20quat.pdf |
- | 901 |
+ 909 |
|
|
// and |
- | 902 |
+ 910 |
|
|
// https://ntrs.nasa.gov/api/citations/19770024112/downloads/19770024112.pdf |
- | 903 |
+ 911 |
|
- 55 |
+ 57 |
Vector4d q_pitch = {cos(input_pitch / 2), 0.0, sin(input_pitch / 2), 0.0}; |
- | 904 |
+ 912 |
|
- 55 |
+ 57 |
Vector4d q_yaw = {cos(input_yaw / 2), 0.0, 0.0, sin(input_yaw / 2)}; |
- | 905 |
+ 913 |
|
- 55 |
+ 57 |
Vector4d q_roll = {cos(input_roll / 2), sin(input_roll / 2), 0.0, 0.0}; |
- | 906 |
+ 914 |
|
- 55 |
+ 57 |
Vector4d q_tot = quaternion_multiplication( |
- | 907 |
+ 915 |
|
- 55 |
+ 57 |
q_roll, quaternion_multiplication(q_yaw, q_pitch)); |
- | 908 |
+ 916 |
|
- 110 |
+ 114 |
std::array<double, 4> output_quaternion = {q_tot(0), q_tot(1), q_tot(2), |
- | 909 |
+ 917 |
|
- 55 |
+ 57 |
q_tot(3)}; |
- | 910 |
+ 918 |
|
- 55 |
+ 57 |
return output_quaternion; |
- | 911 |
+ 919 |
|
|
} |
- | 912 |
+ 920 |
|
|
|
- | 913 |
+ 921 |
|
8948009 |
Matrix3d LVLH_to_body_transformation_matrix_from_quaternion( |
- | 914 |
+ 922 |
|
|
const std::array<double, 4> input_bodyframe_quaternion_relative_to_LVLH) { |
- | 915 |
+ 923 |
|
|
// Ref: |
- | 916 |
+ 924 |
|
|
// https://ntrs.nasa.gov/api/citations/20240009554/downloads/Space%20Attitude%20Development%20Control.pdf |
- | 917 |
+ 925 |
|
|
// section 4.3.1 |
- | 918 |
+ 926 |
|
8948009 |
double q0 = input_bodyframe_quaternion_relative_to_LVLH.at(0); |
- | 919 |
+ 927 |
|
8948009 |
double q1 = input_bodyframe_quaternion_relative_to_LVLH.at(1); |
- | 920 |
+ 928 |
|
8948009 |
double q2 = input_bodyframe_quaternion_relative_to_LVLH.at(2); |
- | 921 |
+ 929 |
|
8948009 |
double q3 = input_bodyframe_quaternion_relative_to_LVLH.at(3); |
- | 922 |
+ 930 |
|
|
|
- | 923 |
+ 931 |
|
8948009 |
Matrix3d LVLH_to_body_mat; |
- | 924 |
+ 932 |
2/4
@@ -8217,7 +7908,7 @@ GCC Code Coverage Report
LVLH_to_body_mat << 2 * q0 * q0 - 1 + 2 * q1 * q1, 2 * q1 * q2 + 2 * q0 * q3, |
|
- | 925 |
+ 933 |
2/4
@@ -8233,7 +7924,7 @@ GCC Code Coverage Report
2 * q1 * q3 - 2 * q0 * q2, 2 * q1 * q2 - 2 * q0 * q3, |
|
- | 926 |
+ 934 |
2/4
@@ -8249,7 +7940,7 @@ GCC Code Coverage Report
2 * q0 * q0 - 1 + 2 * q2 * q2, 2 * q2 * q3 + 2 * q0 * q1, |
|
- | 927 |
+ 935 |
2/4
@@ -8265,182 +7956,182 @@ GCC Code Coverage Report
2 * q1 * q3 + 2 * q0 * q2, 2 * q2 * q3 - 2 * q0 * q1, |
|
- | 928 |
+ 936 |
|
8948009 |
2 * q0 * q0 - 1 + 2 * q3 * q3; |
- | 929 |
+ 937 |
|
|
|
- | 930 |
+ 938 |
|
8948009 |
return LVLH_to_body_mat; |
- | 931 |
+ 939 |
|
✗ |
} |
- | 932 |
+ 940 |
|
|
|
- | 933 |
+ 941 |
|
|
// Objective: compute time derivatives of bodyframe angular velocities |
- | 934 |
+ 942 |
|
54944076 |
std::array<double, 3> calculate_spacecraft_bodyframe_angular_acceleration( |
- | 935 |
+ 943 |
|
|
const Matrix3d J_matrix, |
- | 936 |
+ 944 |
|
|
const std::vector<BodyframeTorqueProfile> |
- | 937 |
+ 945 |
|
|
input_bodyframe_torque_profile_list, |
- | 938 |
+ 946 |
|
|
const Vector3d input_omega_I, |
- | 939 |
+ 947 |
|
|
const double input_orbital_angular_acceleration, |
- | 940 |
+ 948 |
|
|
const Vector3d input_omega_bodyframe_wrt_LVLH_in_body_frame, |
- | 941 |
+ 949 |
|
|
const Matrix3d input_LVLH_to_bodyframe_transformation_matrix, |
- | 942 |
+ 950 |
|
|
const Vector3d input_omega_LVLH_wrt_inertial_in_LVLH, |
- | 943 |
+ 951 |
|
|
const double input_evaluation_time) { |
- | 944 |
+ 952 |
|
|
// Using approach from |
- | 945 |
+ 953 |
|
|
// https://ntrs.nasa.gov/api/citations/20240009554/downloads/Space%20Attitude%20Development%20Control.pdf |
- | 946 |
+ 954 |
|
|
// , Ch. 4 especially Objective: calculate omega_dot in spacecraft body frame |
- | 947 |
+ 955 |
|
|
// w.r.t. the LVLH frame, expressed in the spacecraft body frame Disturbance |
- | 948 |
+ 956 |
|
|
// torques, if eventually added in, should just be more torque profiles in the |
- | 949 |
+ 957 |
|
|
// satellite object's list of torque profiles So the input_torques vector |
- | 950 |
+ 958 |
|
|
// includes both disturbance and control torques |
- | 951 |
+ 959 |
|
54944076 |
Vector3d bodyframe_torque_vec = {0, 0, 0}; |
- | 952 |
+ 960 |
|
|
|
- | 953 |
+ 961 |
2/2
@@ -8454,22 +8145,22 @@ GCC Code Coverage Report
for (const BodyframeTorqueProfile bodyframe_torque_profile : |
|
- | 954 |
+ 962 |
|
54944076 |
input_bodyframe_torque_profile_list) { |
- | 955 |
+ 963 |
4/4
✓ Branch 0 taken 44255510 times.
✓ Branch 1 taken 1321090 times.
- ✓ Branch 2 taken 44049910 times.
- ✓ Branch 3 taken 205600 times.
+ ✓ Branch 2 taken 205600 times.
+ ✓ Branch 3 taken 44049910 times.
|
@@ -8477,14 +8168,14 @@ GCC Code Coverage Report
if ((input_evaluation_time >= bodyframe_torque_profile.t_start_) && |
- | 956 |
+ 964 |
|
44255510 |
(input_evaluation_time <= bodyframe_torque_profile.t_end_)) { |
- | 957 |
+ 965 |
2/2
@@ -8498,399 +8189,399 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < 3; ind++) { |
|
- | 958 |
+ 966 |
|
616800 |
bodyframe_torque_vec(ind) += |
- | 959 |
+ 967 |
|
616800 |
bodyframe_torque_profile.bodyframe_torque_list.at(ind); |
- | 960 |
+ 968 |
|
616800 |
} |
- | 961 |
+ 969 |
|
205600 |
} |
- | 962 |
+ 970 |
|
|
} |
- | 963 |
+ 971 |
|
|
|
- | 964 |
+ 972 |
|
54944076 |
Vector3d omega_lvlh_dot = {0, -input_orbital_angular_acceleration, 0}; |
- | 965 |
+ 973 |
|
54944076 |
Matrix3d inverted_J_matrix = J_matrix; |
- | 966 |
+ 974 |
|
54944076 |
inverted_J_matrix.inverse(); |
- | 967 |
+ 975 |
|
|
|
- | 968 |
+ 976 |
|
|
Vector3d comp1 = |
- | 969 |
+ 977 |
|
54944076 |
-inverted_J_matrix * (input_omega_I.cross(J_matrix * input_omega_I)); |
- | 970 |
+ 978 |
|
54944076 |
Vector3d comp2 = inverted_J_matrix * bodyframe_torque_vec; |
- | 971 |
+ 979 |
|
54944076 |
Vector3d comp3 = input_omega_bodyframe_wrt_LVLH_in_body_frame.cross( |
- | 972 |
+ 980 |
|
54944076 |
input_LVLH_to_bodyframe_transformation_matrix * |
- | 973 |
+ 981 |
|
|
input_omega_LVLH_wrt_inertial_in_LVLH); |
- | 974 |
+ 982 |
|
54944076 |
Vector3d omega_dot_vec_LVLH_wrt_inertial_in_ECI = { |
- | 975 |
+ 983 |
|
54944076 |
0, -input_orbital_angular_acceleration, 0}; |
- | 976 |
+ 984 |
|
54944076 |
Vector3d comp4 = -input_LVLH_to_bodyframe_transformation_matrix * |
- | 977 |
+ 985 |
|
|
omega_dot_vec_LVLH_wrt_inertial_in_ECI; |
- | 978 |
+ 986 |
|
|
|
- | 979 |
+ 987 |
|
|
Vector3d angular_acceleration_bodyframe_wrt_LVLH_in_bodyframe = |
- | 980 |
+ 988 |
|
54944076 |
comp1 + comp2 + comp3 + comp4; |
- | 981 |
+ 989 |
|
|
std::array<double, 3> |
- | 982 |
+ 990 |
|
54944076 |
angular_acceleration_bodyframe_wrt_LVLH_in_bodyframe_array = { |
- | 983 |
+ 991 |
|
164832228 |
angular_acceleration_bodyframe_wrt_LVLH_in_bodyframe(0), |
- | 984 |
+ 992 |
|
54944076 |
angular_acceleration_bodyframe_wrt_LVLH_in_bodyframe(1), |
- | 985 |
+ 993 |
|
54944076 |
angular_acceleration_bodyframe_wrt_LVLH_in_bodyframe(2)}; |
- | 986 |
+ 994 |
|
|
|
- | 987 |
+ 995 |
|
54944076 |
return angular_acceleration_bodyframe_wrt_LVLH_in_bodyframe_array; |
- | 988 |
+ 996 |
|
|
} |
- | 989 |
+ 997 |
|
|
|
- | 990 |
+ 998 |
|
|
// Objective: compute time derivatives of components of quaternion describing |
- | 991 |
+ 999 |
|
|
// orientation of satellite body frame with respect to LVLH frame |
- | 992 |
+ 1000 |
|
54944076 |
Vector4d quaternion_kinematics_equation( |
- | 993 |
+ 1001 |
|
|
const Vector4d quaternion_of_bodyframe_relative_to_ref_frame, |
- | 994 |
+ 1002 |
|
|
const Vector3d angular_velocity_vec_wrt_ref_frame_in_body_frame) { |
- | 995 |
+ 1003 |
|
|
// Ref: |
- | 996 |
+ 1004 |
|
|
// https://ntrs.nasa.gov/api/citations/20240009554/downloads/Space%20Attitude%20Development%20Control.pdf |
- | 997 |
+ 1005 |
|
|
// Section 4.1.2 |
- | 998 |
+ 1006 |
|
|
|
- | 999 |
+ 1007 |
|
|
// Here assuming scalar component is first in quaternion |
- | 1000 |
+ 1008 |
|
54944076 |
Vector3d vec_component_of_quaternion = { |
- | 1001 |
+ 1009 |
|
54944076 |
quaternion_of_bodyframe_relative_to_ref_frame(1), |
- | 1002 |
+ 1010 |
|
54944076 |
quaternion_of_bodyframe_relative_to_ref_frame(2), |
- | 1003 |
+ 1011 |
|
54944076 |
quaternion_of_bodyframe_relative_to_ref_frame(3)}; |
- | 1004 |
+ 1012 |
|
54944076 |
double q_0_dot = |
- | 1005 |
+ 1013 |
|
54944076 |
(-0.5) * angular_velocity_vec_wrt_ref_frame_in_body_frame.dot( |
- | 1006 |
+ 1014 |
|
|
vec_component_of_quaternion); |
- | 1007 |
+ 1015 |
|
|
Vector3d vec_q_dot = |
- | 1008 |
+ 1016 |
|
109888152 |
(-0.5) * angular_velocity_vec_wrt_ref_frame_in_body_frame.cross( |
- | 1009 |
+ 1017 |
|
54944076 |
vec_component_of_quaternion) + |
- | 1010 |
+ 1018 |
|
54944076 |
(0.5) * quaternion_of_bodyframe_relative_to_ref_frame(0) * |
- | 1011 |
+ 1019 |
|
|
angular_velocity_vec_wrt_ref_frame_in_body_frame; |
- | 1012 |
+ 1020 |
|
|
|
- | 1013 |
+ 1021 |
|
54944076 |
Vector4d quaternion_derivative; |
- | 1014 |
+ 1022 |
6/12
@@ -8914,224 +8605,224 @@ GCC Code Coverage Report
quaternion_derivative << q_0_dot, vec_q_dot(0), vec_q_dot(1), vec_q_dot(2); |
|
- | 1015 |
+ 1023 |
|
|
|
- | 1016 |
+ 1024 |
|
54944076 |
return quaternion_derivative; |
- | 1017 |
+ 1025 |
|
✗ |
} |
- | 1018 |
+ 1026 |
|
|
|
- | 1019 |
+ 1027 |
|
|
// Computes time derivative of combined satellite quaternion + angular velocity |
- | 1020 |
+ 1028 |
|
|
// vector |
- | 1021 |
+ 1029 |
|
54944076 |
std::array<double, 7> RK45_satellite_body_angular_deriv_function( |
- | 1022 |
+ 1030 |
|
|
const std::array<double, 7> combined_bodyframe_angular_array, |
- | 1023 |
+ 1031 |
|
|
const Matrix3d J_matrix, |
- | 1024 |
+ 1032 |
|
|
const std::vector<BodyframeTorqueProfile> |
- | 1025 |
+ 1033 |
|
|
input_bodyframe_torque_profile_list, |
- | 1026 |
+ 1034 |
|
|
const Vector3d input_omega_I, double input_orbital_angular_acceleration, |
- | 1027 |
+ 1035 |
|
|
const Matrix3d input_LVLH_to_bodyframe_transformation_matrix, |
- | 1028 |
+ 1036 |
|
|
const Vector3d input_omega_LVLH_wrt_inertial_in_LVLH, |
- | 1029 |
+ 1037 |
|
|
const double input_evaluation_time) { |
- | 1030 |
+ 1038 |
|
|
// Setting this up for an RK45 step with |
- | 1031 |
+ 1039 |
|
|
// y={q_0,q_1,q_2,q_3,omega_1,omega_2,omega_3} Objective is to produce dy/dt |
- | 1032 |
+ 1040 |
|
|
// Input quaternion should be quaternion of bodyframe relative to LVLH |
- | 1033 |
+ 1041 |
|
54944076 |
std::array<double, 7> combined_angular_derivative_array = {0, 0, 0, 0, |
- | 1034 |
+ 1042 |
|
|
0, 0, 0}; |
- | 1035 |
+ 1043 |
|
109888152 |
Vector4d quaternion = {combined_bodyframe_angular_array.at(0), |
- | 1036 |
+ 1044 |
|
54944076 |
combined_bodyframe_angular_array.at(1), |
- | 1037 |
+ 1045 |
|
54944076 |
combined_bodyframe_angular_array.at(2), |
- | 1038 |
+ 1046 |
|
54944076 |
combined_bodyframe_angular_array.at(3)}; |
- | 1039 |
+ 1047 |
|
54944076 |
Vector3d body_angular_velocity_vec_wrt_LVLH_in_body_frame = { |
- | 1040 |
+ 1048 |
|
54944076 |
combined_bodyframe_angular_array.at(4), |
- | 1041 |
+ 1049 |
|
54944076 |
combined_bodyframe_angular_array.at(5), |
- | 1042 |
+ 1050 |
|
54944076 |
combined_bodyframe_angular_array.at(6)}; |
- | 1043 |
+ 1051 |
|
54944076 |
Vector4d quaternion_derivative = quaternion_kinematics_equation( |
- | 1044 |
+ 1052 |
|
54944076 |
quaternion, body_angular_velocity_vec_wrt_LVLH_in_body_frame); |
- | 1045 |
+ 1053 |
|
|
std::array<double, 3> body_angular_acceleration_vec_wrt_LVLH_in_body_frame = |
- | 1046 |
+ 1054 |
1/2
@@ -9145,7 +8836,7 @@ GCC Code Coverage Report
calculate_spacecraft_bodyframe_angular_acceleration( |
|
- | 1047 |
+ 1055 |
1/2
@@ -9159,14 +8850,14 @@ GCC Code Coverage Report
J_matrix, input_bodyframe_torque_profile_list, input_omega_I, |
|
- | 1048 |
+ 1056 |
|
54944076 |
input_orbital_angular_acceleration, |
- | 1049 |
+ 1057 |
1/2
@@ -9180,7 +8871,7 @@ GCC Code Coverage Report
body_angular_velocity_vec_wrt_LVLH_in_body_frame, |
|
- | 1050 |
+ 1058 |
1/2
@@ -9194,7 +8885,7 @@ GCC Code Coverage Report
input_LVLH_to_bodyframe_transformation_matrix, |
|
- | 1051 |
+ 1059 |
1/2
@@ -9208,14 +8899,14 @@ GCC Code Coverage Report
input_omega_LVLH_wrt_inertial_in_LVLH, input_evaluation_time); |
|
- | 1052 |
+ 1060 |
|
|
|
- | 1053 |
+ 1061 |
2/2
@@ -9229,21 +8920,21 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < 4; ind++) { |
|
- | 1054 |
+ 1062 |
|
219776304 |
combined_angular_derivative_array.at(ind) = quaternion_derivative(ind); |
- | 1055 |
+ 1063 |
|
219776304 |
} |
- | 1056 |
+ 1064 |
2/2
@@ -9257,385 +8948,385 @@ GCC Code Coverage Report
for (size_t ind = 4; ind < 7; ind++) { |
|
- | 1057 |
+ 1065 |
|
164832228 |
combined_angular_derivative_array.at(ind) = |
- | 1058 |
+ 1066 |
|
164832228 |
body_angular_acceleration_vec_wrt_LVLH_in_body_frame.at(ind - 4); |
- | 1059 |
+ 1067 |
|
164832228 |
} |
- | 1060 |
+ 1068 |
|
|
|
- | 1061 |
+ 1069 |
|
54944076 |
return combined_angular_derivative_array; |
- | 1062 |
+ 1070 |
|
✗ |
} |
- | 1063 |
+ 1071 |
|
|
|
- | 1064 |
+ 1072 |
|
|
// Calculate angular velocity of spacecraft body frame with respect to |
- | 1065 |
+ 1073 |
|
|
// inertial (ECI) frame |
- | 1066 |
+ 1074 |
|
8948009 |
Vector3d calculate_omega_I( |
- | 1067 |
+ 1075 |
|
|
const Vector3d input_bodyframe_ang_vel_vector_wrt_lvlh, |
- | 1068 |
+ 1076 |
|
|
const Matrix3d input_LVLH_to_bodyframe_transformation_matrix, |
- | 1069 |
+ 1077 |
|
|
const double input_orbital_rate) { |
- | 1070 |
+ 1078 |
|
|
// Eq. 4.17 in |
- | 1071 |
+ 1079 |
|
|
// https://ntrs.nasa.gov/api/citations/20240009554/downloads/Space%20Attitude%20Development%20Control.pdf |
- | 1072 |
+ 1080 |
|
8948009 |
Vector3d omega_LVLH_wrt_inertial_in_LVLH = {0, -input_orbital_rate, 0}; |
- | 1073 |
+ 1081 |
|
8948009 |
Vector3d omega_I = input_bodyframe_ang_vel_vector_wrt_lvlh + |
- | 1074 |
+ 1082 |
|
8948009 |
input_LVLH_to_bodyframe_transformation_matrix * |
- | 1075 |
+ 1083 |
|
|
omega_LVLH_wrt_inertial_in_LVLH; |
- | 1076 |
+ 1084 |
|
8948009 |
return omega_I; |
- | 1077 |
+ 1085 |
|
|
} |
- | 1078 |
+ 1086 |
|
|
|
- | 1079 |
+ 1087 |
|
8948009 |
Matrix3d construct_J_matrix(const double input_Jxx, const double input_Jyy, |
- | 1080 |
+ 1088 |
|
|
const double input_Jzz) { |
- | 1081 |
+ 1089 |
|
8948009 |
Matrix3d J_matrix = Matrix3d::Zero(); |
- | 1082 |
+ 1090 |
|
8948009 |
J_matrix(0, 0) = input_Jxx; |
- | 1083 |
+ 1091 |
|
8948009 |
J_matrix(1, 1) = input_Jyy; |
- | 1084 |
+ 1092 |
|
8948009 |
J_matrix(2, 2) = input_Jzz; |
- | 1085 |
+ 1093 |
|
8948009 |
return J_matrix; |
- | 1086 |
+ 1094 |
|
|
} |
- | 1087 |
+ 1095 |
|
|
|
- | 1088 |
+ 1096 |
|
|
std::array<double, 13> |
- | 1089 |
+ 1097 |
|
54944076 |
RK45_combined_orbit_position_velocity_attitude_deriv_function( |
- | 1090 |
+ 1098 |
|
|
const std::array<double, 13> |
- | 1091 |
+ 1099 |
|
|
combined_position_velocity_bodyframe_angular_array, |
- | 1092 |
+ 1100 |
|
|
const Matrix3d J_matrix, |
- | 1093 |
+ 1101 |
|
|
const std::vector<BodyframeTorqueProfile> |
- | 1094 |
+ 1102 |
|
|
input_bodyframe_torque_profile_list, |
- | 1095 |
+ 1103 |
|
|
const Vector3d input_omega_I, double input_orbital_angular_acceleration, |
- | 1096 |
+ 1104 |
|
|
const Matrix3d input_LVLH_to_bodyframe_transformation_matrix, |
- | 1097 |
+ 1105 |
|
|
const Vector3d input_omega_LVLH_wrt_inertial_in_LVLH, |
- | 1098 |
+ 1106 |
|
|
const double input_spacecraft_mass, |
- | 1099 |
+ 1107 |
|
|
const std::vector<ThrustProfileLVLH> input_list_of_thrust_profiles_LVLH, |
- | 1100 |
+ 1108 |
|
|
const double input_evaluation_time, const double input_inclination, |
- | 1101 |
+ 1109 |
|
|
const double input_arg_of_periapsis, const double input_true_anomaly, |
- | 1102 |
+ 1110 |
|
|
const double input_F_10, const double input_A_p, const double input_A_s, |
- | 1103 |
+ 1111 |
|
|
const bool perturbation, const bool atmospheric_drag) { |
- | 1104 |
+ 1112 |
|
|
// Input vector is in the form of {ECI_position, |
- | 1105 |
+ 1113 |
|
|
// ECI_velocity,bodyframe_quaternion_to_LVLH,bodyframe_omega_wrt_LVLH} |
- | 1106 |
+ 1114 |
|
|
// Objective is to output derivative of that vector |
- | 1107 |
+ 1115 |
|
|
std::array<double, 13> derivative_vec; |
- | 1108 |
+ 1116 |
|
|
std::array<double, 6> combined_position_and_velocity_array; |
- | 1109 |
+ 1117 |
|
|
std::array<double, 7> combined_angular_array; |
- | 1110 |
+ 1118 |
|
|
|
- | 1111 |
+ 1119 |
2/2
@@ -9649,35 +9340,35 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < combined_position_and_velocity_array.size(); |
|
- | 1112 |
+ 1120 |
|
329664456 |
ind++) { |
- | 1113 |
+ 1121 |
|
329664456 |
combined_position_and_velocity_array.at(ind) = |
- | 1114 |
+ 1122 |
|
329664456 |
combined_position_velocity_bodyframe_angular_array.at(ind); |
- | 1115 |
+ 1123 |
|
329664456 |
} |
- | 1116 |
+ 1124 |
2/2
@@ -9691,42 +9382,42 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < combined_angular_array.size(); ind++) { |
|
- | 1117 |
+ 1125 |
|
384608532 |
combined_angular_array.at(ind) = |
- | 1118 |
+ 1126 |
|
384608532 |
combined_position_velocity_bodyframe_angular_array.at( |
- | 1119 |
+ 1127 |
|
384608532 |
ind + combined_position_and_velocity_array.size()); |
- | 1120 |
+ 1128 |
|
384608532 |
} |
- | 1121 |
+ 1129 |
|
|
std::array<double, 6> orbital_position_and_velocity_derivative_array = |
- | 1122 |
+ 1130 |
1/2
@@ -9740,56 +9431,56 @@ GCC Code Coverage Report
RK45_deriv_function_orbit_position_and_velocity( |
|
- | 1123 |
+ 1131 |
|
54944076 |
combined_position_and_velocity_array, input_spacecraft_mass, |
- | 1124 |
+ 1132 |
|
54944076 |
input_list_of_thrust_profiles_LVLH, input_evaluation_time, |
- | 1125 |
+ 1133 |
|
54944076 |
input_inclination, input_arg_of_periapsis, input_true_anomaly, |
- | 1126 |
+ 1134 |
|
54944076 |
input_F_10, input_A_p, input_A_s, input_spacecraft_mass, perturbation, |
- | 1127 |
+ 1135 |
|
54944076 |
atmospheric_drag); |
- | 1128 |
+ 1136 |
|
|
|
- | 1129 |
+ 1137 |
|
|
std::array<double, 7> angular_derivative_array = |
- | 1130 |
+ 1138 |
1/2
@@ -9803,14 +9494,14 @@ GCC Code Coverage Report
RK45_satellite_body_angular_deriv_function( |
|
- | 1131 |
+ 1139 |
|
54944076 |
combined_angular_array, J_matrix, input_bodyframe_torque_profile_list, |
- | 1132 |
+ 1140 |
1/2
@@ -9824,7 +9515,7 @@ GCC Code Coverage Report
input_omega_I, input_orbital_angular_acceleration, |
|
- | 1133 |
+ 1141 |
1/2
@@ -9838,7 +9529,7 @@ GCC Code Coverage Report
input_LVLH_to_bodyframe_transformation_matrix, |
|
- | 1134 |
+ 1142 |
1/2
@@ -9852,14 +9543,14 @@ GCC Code Coverage Report
input_omega_LVLH_wrt_inertial_in_LVLH, input_evaluation_time); |
|
- | 1135 |
+ 1143 |
|
|
|
- | 1136 |
+ 1144 |
2/2
@@ -9873,35 +9564,35 @@ GCC Code Coverage Report
for (size_t ind = 0; |
|
- | 1137 |
+ 1145 |
|
384608532 |
ind < orbital_position_and_velocity_derivative_array.size(); ind++) { |
- | 1138 |
+ 1146 |
|
329664456 |
derivative_vec.at(ind) = |
- | 1139 |
+ 1147 |
|
329664456 |
orbital_position_and_velocity_derivative_array.at(ind); |
- | 1140 |
+ 1148 |
|
329664456 |
} |
- | 1141 |
+ 1149 |
2/2
@@ -9915,791 +9606,777 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < angular_derivative_array.size(); ind++) { |
|
- | 1142 |
+ 1150 |
|
769217064 |
derivative_vec.at(ind + |
- | 1143 |
+ 1151 |
|
769217064 |
orbital_position_and_velocity_derivative_array.size()) = |
- | 1144 |
+ 1152 |
|
384608532 |
angular_derivative_array.at(ind); |
- | 1145 |
+ 1153 |
|
384608532 |
} |
- | 1146 |
+ 1154 |
|
|
|
- | 1147 |
+ 1155 |
|
54944076 |
return derivative_vec; |
- | 1148 |
+ 1156 |
|
✗ |
} |
- | 1149 |
+ 1157 |
|
|
|
- | 1150 |
+ 1158 |
|
- 8948064 |
+ 8948066 |
std::array<double, 4> normalize_quaternion( |
- | 1151 |
+ 1159 |
|
|
std::array<double, 4> input_quaternion) { |
- | 1152 |
+ 1160 |
|
- 8948064 |
+ 8948066 |
double length = 0; |
- | 1153 |
+ 1161 |
2/2
- ✓ Branch 0 taken 35792256 times.
- ✓ Branch 1 taken 8948064 times.
+ ✓ Branch 0 taken 35792264 times.
+ ✓ Branch 1 taken 8948066 times.
|
- 44740320 |
+ 44740330 |
for (size_t ind = 0; ind < input_quaternion.size(); ind++) { |
- | 1154 |
+ 1162 |
|
- 35792256 |
+ 35792264 |
length += (input_quaternion.at(ind) * input_quaternion.at(ind)); |
- | 1155 |
+ 1163 |
|
- 35792256 |
+ 35792264 |
} |
- | 1156 |
+ 1164 |
2/2
- ✓ Branch 0 taken 35792256 times.
- ✓ Branch 1 taken 8948064 times.
+ ✓ Branch 0 taken 35792264 times.
+ ✓ Branch 1 taken 8948066 times.
|
- 44740320 |
+ 44740330 |
for (size_t ind = 0; ind < input_quaternion.size(); ind++) { |
- | 1157 |
+ 1165 |
|
- 35792256 |
+ 35792264 |
input_quaternion.at(ind) /= sqrt(length); |
- | 1158 |
+ 1166 |
|
- 35792256 |
+ 35792264 |
} |
- | 1159 |
+ 1167 |
|
- 8948064 |
+ 8948066 |
return input_quaternion; |
- | 1160 |
+ 1168 |
|
|
} |
- | 1161 |
+ 1169 |
|
|
|
- | 1162 |
+ 1170 |
|
8948009 |
std::array<double, 3> convert_quaternion_to_roll_yaw_pitch_angles( |
- | 1163 |
+ 1171 |
|
|
const std::array<double, 4> input_quaternion) { |
- | 1164 |
+ 1172 |
|
|
// Based on approach in |
- | 1165 |
+ 1173 |
|
|
// https://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/quat_2_euler_paper_ver2-1.pdf |
- | 1166 |
+ 1174 |
|
|
// Again, here I'm going off the pitch-yaw-roll sequence used in |
- | 1167 |
+ 1175 |
|
|
// https://ntrs.nasa.gov/api/citations/19770024112/downloads/19770024112.pdf |
- | 1168 |
+ 1176 |
|
|
// Where the angles which defined the orbiter attitude with respect to LVLH |
- | 1169 |
+ 1177 |
|
|
// are [A]_from_LVLH_to_BY = Rx(roll)*R_z(yaw)*R_y(pitch) |
- | 1170 |
+ 1178 |
|
|
|
- | 1171 |
+ 1179 |
|
17896018 |
Vector3d v3 = {0, 1, |
- | 1172 |
+ 1180 |
|
8948009 |
0}; // unit vector in direction of last rotation performed, |
- | 1173 |
+ 1181 |
|
|
// which in this sequence is the y unit vector |
- | 1174 |
+ 1182 |
|
17896018 |
Quaterniond eigen_quaternion(input_quaternion.at(0), input_quaternion.at(1), |
- | 1175 |
+ 1183 |
|
8948009 |
input_quaternion.at(2), input_quaternion.at(3)); |
- | 1176 |
+ 1184 |
|
8948009 |
eigen_quaternion.normalize(); // Just in case |
- | 1177 |
+ 1185 |
|
8948009 |
Matrix3d rotation_matrix = eigen_quaternion.toRotationMatrix(); |
- | 1178 |
+ 1186 |
|
8948009 |
Vector3d euler_angles = rotation_matrix.eulerAngles( |
- | 1179 |
+ 1187 |
|
|
0, 2, |
- | 1180 |
+ 1188 |
|
|
1); // Eigen uses intrinsic convention, so this is an intrinsic XZY |
- | 1181 |
+ 1189 |
|
|
// (denoted x-z'-y'' in the notation Wikipedia uses) or extrinsic YZX |
- | 1182 |
+ 1190 |
|
|
// sequence corresponding to R_x R_z R_y (e.g., see |
- | 1183 |
+ 1191 |
|
|
// https://arg.usask.ca/docs/skplatform/appendices/rotation_matrices.html) |
- | 1184 |
+ 1192 |
|
|
|
- | 1185 |
+ 1193 |
|
8948009 |
double roll = euler_angles(0); |
- | 1186 |
+ 1194 |
|
8948009 |
double yaw = euler_angles(1); |
- | 1187 |
+ 1195 |
|
8948009 |
double pitch = euler_angles(2); |
- | 1188 |
+ 1196 |
|
|
|
- | 1189 |
+ 1197 |
|
8948009 |
std::array<double, 3> output_angle_vec = {roll, yaw, pitch}; |
- | 1190 |
+ 1198 |
|
8948009 |
return output_angle_vec; |
- | 1191 |
+ 1199 |
|
|
} |
- | 1192 |
+ 1200 |
|
|
|
- | 1193 |
+ 1201 |
|
- 53 |
+ 55 |
std::array<double, 3> convert_array_from_LVLH_to_bodyframe( |
- | 1194 |
+ 1202 |
|
|
const std::array<double, 3> input_LVLH_frame_array, const double input_roll, |
- | 1195 |
+ 1203 |
|
|
const double input_yaw, const double input_pitch) { |
- | 1196 |
+ 1204 |
|
|
Matrix3d transformation_matrix = |
- | 1197 |
+ 1205 |
|
- 53 |
+ 55 |
rollyawpitch_bodyframe_to_LVLH_matrix(input_roll, input_pitch, input_yaw); |
- | 1198 |
+ 1206 |
|
- 106 |
+ 110 |
Vector3d input_LVLH_frame_vector = {input_LVLH_frame_array.at(0), |
- | 1199 |
+ 1207 |
|
- 53 |
+ 55 |
input_LVLH_frame_array.at(1), |
- | 1200 |
+ 1208 |
|
- 53 |
+ 55 |
input_LVLH_frame_array.at(2)}; |
- | 1201 |
+ 1209 |
|
- 53 |
+ 55 |
Vector3d bodyframe_vec = transformation_matrix * input_LVLH_frame_vector; |
- | 1202 |
+ 1210 |
|
- 106 |
+ 110 |
std::array<double, 3> bodyframe_arr = {bodyframe_vec(0), bodyframe_vec(1), |
- | 1203 |
+ 1211 |
|
- 53 |
+ 55 |
bodyframe_vec(2)}; |
- | 1204 |
+ 1212 |
|
- 53 |
+ 55 |
return bodyframe_arr; |
- | 1205 |
+ 1213 |
|
|
} |
- | 1206 |
+ 1214 |
|
|
|
- | 1207 |
+ 1215 |
|
|
|
- | 1208 |
+ 1216 |
|
|
|
- | 1209 |
+ 1217 |
|
5 |
Vector3d convert_lat_long_to_ECEF(const double latitude, const double longitude, const double height) { |
- | 1210 |
+ 1218 |
|
5 |
double a = 6378137; // Equatorial radius [m] |
- | 1211 |
+ 1219 |
|
5 |
double b = 6356752; // Polar radius [m] |
- | 1212 |
+ 1220 |
|
|
|
- | 1213 |
+ 1221 |
|
|
// Refs: https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#From_geodetic_to_ECEF_coordinates |
- | 1214 |
+ 1222 |
|
|
// https://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html |
- | 1215 |
+ 1223 |
|
5 |
double e = 1 - ((b * b)/(a * a)); |
- | 1216 |
+ 1224 |
|
5 |
double N = a / (sqrt(1 - ((e * e) / (1 + pow(cos(latitude)/sin(latitude),2)) ))); |
- | 1217 |
+ 1225 |
|
5 |
double x = (N + height)*cos(latitude)*cos(longitude); |
- | 1218 |
+ 1226 |
|
5 |
double y = (N + height)*cos(latitude)*sin(longitude); |
- | 1219 |
+ 1227 |
|
5 |
double z = ((1 - e * e)*N + height) * sin(latitude); |
- | 1220 |
+ 1228 |
|
5 |
Vector3d output_ECEF_array = {x,y,z}; |
- | 1221 |
+ 1229 |
|
5 |
return output_ECEF_array; |
- | 1222 |
+ 1230 |
|
|
} |
- | 1223 |
+ 1231 |
|
|
|
- | 1224 |
+ 1232 |
|
13480446 |
Vector3d convert_ECEF_to_ECI(const Vector3d input_ECEF_position, const double input_time) { |
- | 1225 |
+ 1233 |
|
|
// Simple rotation-based conversion, not yet accounting for higher-fidelity effects like changes to Earth axes |
- | 1226 |
+ 1234 |
|
|
// Ref: https://x-lumin.com/wp-content/uploads/2020/09/Coordinate_Transforms.pdf |
- | 1227 |
+ 1235 |
|
|
// https://space.stackexchange.com/questions/43187/is-this-commonly-attributed-eci-earth-centered-inertial-to-ecef-earth-centere |
- | 1228 |
+ 1236 |
|
|
// https://space.stackexchange.com/questions/38807/transform-eci-to-ecef |
- | 1229 |
+ 1237 |
|
13480446 |
double omega_Earth = 0.261799387799149 * (1.0/3600.0); // [radians / second] |
- | 1230 |
+ 1238 |
|
13480446 |
double ERA_at_J200 = 280.46 * (M_PI/180); //radians |
- | 1231 |
+ 1239 |
|
|
// Going to be assuming, for simplicity, that satellites start orbiting at the J200 epoch |
- | 1232 |
+ 1240 |
|
13480446 |
double theta_g = ERA_at_J200 + omega_Earth*input_time; |
- | 1233 |
+ 1241 |
|
13480446 |
Matrix3d rotation_matrix = z_rot_matrix(theta_g); |
- | 1234 |
+ 1242 |
|
13480446 |
Vector3d ECI_array = rotation_matrix*input_ECEF_position; |
- | 1235 |
+ 1243 |
|
13480446 |
return ECI_array; |
- | 1236 |
+ 1244 |
|
|
} |
- | 1237 |
+ 1245 |
|
|
|
- | 1238 |
+ 1246 |
|
|
|
- | 1239 |
+ 1247 |
|
|
|
- | 1240 |
+ 1248 |
|
|
|
- | 1241 |
+ 1249 |
|
162 |
void sim_and_plot_gs_connectivity_distance_gnuplot( |
- | 1242 |
+ 1250 |
|
|
PhasedArrayGroundStation input_ground_station, |
- | 1243 |
-
- |
- |
- std::vector<Satellite> input_satellite_vector, const double input_timestep, |
-
-
- | 1244 |
-
- |
- |
- const double input_total_sim_time, const double input_epsilon, |
-
-
- | 1245 |
+ 1251 |
|
|
- const std::string file_name = "output", |
+ std::vector<Satellite> input_satellite_vector, |
- | 1246 |
+ 1252 |
|
|
- const bool perturbation = true, const bool atmospheric_drag = false, |
+ const SimParameters& input_sim_parameters, |
- | 1247 |
+ 1253 |
|
|
- const std::pair<double, double> drag_elements = {}) { |
+ const std::string file_name) { |
- | 1248 |
+ 1254 |
|
|
|
- | 1249 |
+ 1255 |
|
|
// Objective: given an input ground station and satellite vector, |
- | 1250 |
+ 1256 |
|
|
// plot contact distances between ground station and satellites over time |
- | 1251 |
+ 1257 |
|
|
|
- | 1252 |
+ 1258 |
1/2
@@ -10713,62 +10390,62 @@ GCC Code Coverage Report
if (input_satellite_vector.size() < 1) { |
|
- | 1253 |
+ 1259 |
|
✗ |
std::cout << "No input Satellite objects\n"; |
- | 1254 |
+ 1260 |
|
✗ |
return; |
- | 1255 |
+ 1261 |
|
|
} |
- | 1256 |
+ 1262 |
|
|
|
- | 1257 |
+ 1263 |
|
|
// first, open "pipe" to gnuplot |
- | 1258 |
+ 1264 |
|
162 |
FILE *gnuplot_pipe = popen("gnuplot", "w"); |
- | 1259 |
+ 1265 |
|
|
// if it exists |
- | 1260 |
+ 1266 |
1/2
- ✓ Branch 0 taken 162 times.
- ✗ Branch 1 not taken.
+ ✗ Branch 0 not taken.
+ ✓ Branch 1 taken 162 times.
|
@@ -10776,112 +10453,112 @@ GCC Code Coverage Report
if (gnuplot_pipe) { |
- | 1261 |
+ 1267 |
|
162 |
fprintf(gnuplot_pipe, "set terminal png size 800,500 font ',14' linewidth 2\n"); |
- | 1262 |
+ 1268 |
|
|
// formatting |
- | 1263 |
+ 1269 |
|
162 |
fprintf(gnuplot_pipe, "set output '../%s.png'\n",file_name.c_str()); |
- | 1264 |
+ 1270 |
|
162 |
fprintf(gnuplot_pipe, "set xlabel 'Time [s]'\n"); |
- | 1265 |
+ 1271 |
|
162 |
fprintf(gnuplot_pipe, "set ylabel 'Distance [m]'\n"); |
- | 1266 |
+ 1272 |
|
|
|
- | 1267 |
+ 1273 |
|
324 |
fprintf(gnuplot_pipe, "set title 'Phased array ground station connectivity " |
- | 1268 |
+ 1274 |
|
162 |
"with %d beams'\n",input_ground_station.num_beams_); |
- | 1269 |
+ 1275 |
|
162 |
fprintf(gnuplot_pipe, "set key outside\n"); |
- | 1270 |
+ 1276 |
|
162 |
- int x_max_plot_window = std::floor(input_total_sim_time*1.05); |
+ int x_max_plot_window = std::floor(input_sim_parameters.total_sim_time*1.05); |
- | 1271 |
+ 1277 |
|
162 |
fprintf(gnuplot_pipe, "set xrange[0:%d]\n",x_max_plot_window); |
- | 1272 |
+ 1278 |
|
|
// plotting |
- | 1273 |
+ 1279 |
|
|
|
- | 1274 |
+ 1280 |
|
|
// first satellite |
- | 1275 |
+ 1281 |
|
162 |
Satellite current_satellite = input_satellite_vector.at(0); |
- | 1276 |
+ 1282 |
2/2
@@ -10895,7 +10572,7 @@ GCC Code Coverage Report
if (input_satellite_vector.size() == 1) { |
|
- | 1277 |
+ 1283 |
2/2
@@ -10909,35 +10586,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 1278 |
+ 1284 |
-
- 1/2
-
- ✓ Branch 0 taken 27 times.
- ✗ Branch 1 not taken.
-
-
|
- 27 |
- fprintf(gnuplot_pipe, |
+ 27 |
+ fprintf(gnuplot_pipe, |
- | 1279 |
+ 1285 |
|
|
"plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \n", |
- | 1280 |
+ 1286 |
|
27 |
current_satellite.plotting_color_.c_str(), |
- | 1281 |
+ 1287 |
1/2
@@ -10951,35 +10621,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1282 |
+ 1288 |
|
27 |
} else { |
- | 1283 |
+ 1289 |
-
- 1/2
-
- ✓ Branch 0 taken 27 times.
- ✗ Branch 1 not taken.
-
-
|
- 27 |
- fprintf(gnuplot_pipe, |
+ 27 |
+ fprintf(gnuplot_pipe, |
- | 1284 |
+ 1290 |
|
|
"plot '-' using 1:2 with lines lw 1 title '%s' \n", |
- | 1285 |
+ 1291 |
1/2
@@ -10993,42 +10656,42 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1286 |
+ 1292 |
|
|
} |
- | 1287 |
+ 1293 |
|
|
|
- | 1288 |
+ 1294 |
|
54 |
} |
- | 1289 |
+ 1295 |
|
|
|
- | 1290 |
+ 1296 |
|
|
else { |
- | 1291 |
+ 1297 |
2/2
@@ -11042,35 +10705,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 1292 |
+ 1298 |
-
- 1/2
-
- ✓ Branch 0 taken 54 times.
- ✗ Branch 1 not taken.
-
-
|
- 54 |
- fprintf(gnuplot_pipe, |
+ 54 |
+ fprintf(gnuplot_pipe, |
- | 1293 |
+ 1299 |
|
|
"plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\\\n", |
- | 1294 |
+ 1300 |
|
54 |
current_satellite.plotting_color_.c_str(), |
- | 1295 |
+ 1301 |
1/2
@@ -11084,35 +10740,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1296 |
+ 1302 |
|
54 |
} else { |
- | 1297 |
+ 1303 |
-
- 1/2
-
- ✓ Branch 0 taken 54 times.
- ✗ Branch 1 not taken.
-
-
|
- 54 |
- fprintf(gnuplot_pipe, |
+ 54 |
+ fprintf(gnuplot_pipe, |
- | 1298 |
+ 1304 |
|
|
"plot '-' using 1:2 with lines lw 1 title '%s'\\\n", |
- | 1299 |
+ 1305 |
1/2
@@ -11126,28 +10775,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1300 |
+ 1306 |
|
|
} |
- | 1301 |
+ 1307 |
|
|
} |
- | 1302 |
+ 1308 |
|
|
|
- | 1303 |
+ 1309 |
2/2
@@ -11161,14 +10810,14 @@ GCC Code Coverage Report
for (size_t satellite_index = 1; |
|
- | 1304 |
+ 1310 |
|
648 |
satellite_index < input_satellite_vector.size(); satellite_index++) { |
- | 1305 |
+ 1311 |
2/4
@@ -11184,7 +10833,7 @@ GCC Code Coverage Report
current_satellite = input_satellite_vector.at(satellite_index); |
|
- | 1306 |
+ 1312 |
2/2
@@ -11198,7 +10847,7 @@ GCC Code Coverage Report
if (satellite_index < input_satellite_vector.size() - 1) { |
|
- | 1307 |
+ 1313 |
2/2
@@ -11212,35 +10861,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 1308 |
+ 1314 |
-
- 1/2
-
- ✓ Branch 0 taken 162 times.
- ✗ Branch 1 not taken.
-
-
|
- 162 |
- fprintf(gnuplot_pipe, |
+ 162 |
+ fprintf(gnuplot_pipe, |
- | 1309 |
+ 1315 |
|
|
",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \\\n", |
- | 1310 |
+ 1316 |
|
162 |
current_satellite.plotting_color_.c_str(), |
- | 1311 |
+ 1317 |
1/2
@@ -11254,35 +10896,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1312 |
+ 1318 |
|
162 |
} else { |
- | 1313 |
+ 1319 |
-
- 1/2
-
- ✓ Branch 0 taken 216 times.
- ✗ Branch 1 not taken.
-
-
|
- 216 |
- fprintf(gnuplot_pipe, |
+ 216 |
+ fprintf(gnuplot_pipe, |
- | 1314 |
+ 1320 |
|
|
",'-' using 1:2 with lines lw 1 title '%s' \\\n", |
- | 1315 |
+ 1321 |
1/2
@@ -11296,42 +10931,42 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1316 |
+ 1322 |
|
|
} |
- | 1317 |
+ 1323 |
|
|
|
- | 1318 |
+ 1324 |
|
378 |
} |
- | 1319 |
+ 1325 |
|
|
|
- | 1320 |
+ 1326 |
|
|
else { |
- | 1321 |
+ 1327 |
2/2
@@ -11345,35 +10980,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 1322 |
+ 1328 |
-
- 1/2
-
- ✓ Branch 0 taken 54 times.
- ✗ Branch 1 not taken.
-
-
|
- 54 |
- fprintf(gnuplot_pipe, |
+ 54 |
+ fprintf(gnuplot_pipe, |
- | 1323 |
+ 1329 |
|
|
",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\n", |
- | 1324 |
+ 1330 |
|
54 |
current_satellite.plotting_color_.c_str(), |
- | 1325 |
+ 1331 |
1/2
@@ -11387,28 +11015,21 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1326 |
+ 1332 |
|
54 |
} else { |
- | 1327 |
+ 1333 |
-
- 1/2
-
- ✓ Branch 0 taken 54 times.
- ✗ Branch 1 not taken.
-
-
|
- 54 |
- fprintf(gnuplot_pipe, ",'-' using 1:2 with lines lw 1 title '%s'\n", |
+ 54 |
+ fprintf(gnuplot_pipe, ",'-' using 1:2 with lines lw 1 title '%s'\n", |
- | 1328 |
+ 1334 |
1/2
@@ -11422,42 +11043,42 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1329 |
+ 1335 |
|
|
} |
- | 1330 |
+ 1336 |
|
|
} |
- | 1331 |
+ 1337 |
|
486 |
} |
- | 1332 |
+ 1338 |
|
|
|
- | 1333 |
+ 1339 |
|
|
// now the orbit data, inline, one satellite at a time |
- | 1334 |
+ 1340 |
1/2
@@ -11471,7 +11092,7 @@ GCC Code Coverage Report
std::cout << "Running simulation...\n"; |
|
- | 1335 |
+ 1341 |
2/2
@@ -11485,14 +11106,14 @@ GCC Code Coverage Report
for (size_t satellite_index = 0; |
|
- | 1336 |
+ 1342 |
|
810 |
satellite_index < input_satellite_vector.size(); satellite_index++) { |
- | 1337 |
+ 1343 |
2/4
@@ -11508,14 +11129,14 @@ GCC Code Coverage Report
Satellite current_satellite = input_satellite_vector.at(satellite_index); |
|
- | 1338 |
+ 1344 |
|
648 |
double current_satellite_time = |
- | 1339 |
+ 1345 |
1/2
@@ -11529,22 +11150,22 @@ GCC Code Coverage Report
current_satellite.get_instantaneous_time(); |
|
- | 1340 |
+ 1346 |
|
648 |
double previous_time = current_satellite_time - 1; |
- | 1341 |
+ 1347 |
2/4
✓ Branch 0 taken 648 times.
✗ Branch 1 not taken.
- ✓ Branch 2 taken 648 times.
- ✗ Branch 3 not taken.
+ ✗ Branch 2 not taken.
+ ✓ Branch 3 taken 648 times.
|
@@ -11552,20 +11173,20 @@ GCC Code Coverage Report
double ground_station_beam_angle = input_ground_station.angle_to_satellite_from_normal(current_satellite); |
- | 1342 |
+ 1348 |
|
|
double initial_distance; |
- | 1343 |
+ 1349 |
1/2
- ✓ Branch 0 taken 648 times.
- ✗ Branch 1 not taken.
+ ✗ Branch 0 not taken.
+ ✓ Branch 1 taken 648 times.
|
@@ -11573,84 +11194,77 @@ GCC Code Coverage Report
if (ground_station_beam_angle > input_ground_station.max_beam_angle_from_normal_) { |
- | 1344 |
+ 1350 |
-
- 1/2
-
- ✓ Branch 0 taken 648 times.
- ✗ Branch 1 not taken.
-
-
|
- 648 |
- fprintf(gnuplot_pipe, "%.17g NaN\n", current_satellite_time); |
+ 648 |
+ fprintf(gnuplot_pipe, "%.17g NaN\n", current_satellite_time); |
- | 1345 |
+ 1351 |
|
648 |
} |
- | 1346 |
+ 1352 |
|
|
else { |
- | 1347 |
+ 1353 |
|
✗ |
initial_distance = input_ground_station.distance_to_satellite(current_satellite); |
- | 1348 |
+ 1354 |
|
✗ |
fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, initial_distance); |
- | 1349 |
+ 1355 |
|
|
} |
- | 1350 |
+ 1356 |
|
|
|
- | 1351 |
+ 1357 |
|
648 |
double evolved_distance = {0}; |
- | 1352 |
+ 1358 |
|
|
|
- | 1353 |
+ 1359 |
|
648 |
- double timestep_to_use = input_timestep; |
+ double timestep_to_use = input_sim_parameters.initial_timestep_guess; |
- | 1354 |
+ 1360 |
1/2
@@ -11664,28 +11278,35 @@ GCC Code Coverage Report
current_satellite_time = current_satellite.get_instantaneous_time(); |
|
- | 1355 |
+ 1361 |
2/2
- ✓ Branch 0 taken 648 times.
- ✓ Branch 1 taken 4373892 times.
+ ✓ Branch 0 taken 4373892 times.
+ ✓ Branch 1 taken 648 times.
|
4374540 |
- while (current_satellite_time < input_total_sim_time) { |
+ while (current_satellite_time < input_sim_parameters.total_sim_time) { |
- | 1356 |
+ 1362 |
+
+ |
+ 4373892 |
+ std::pair<double, double> drag_elements = {input_sim_parameters.F_10, input_sim_parameters.A_p}; |
+
+
+ | 1363 |
|
|
std::pair<double, int> new_timestep_and_error_code = |
- | 1357 |
+ 1364 |
2/4
@@ -11698,45 +11319,45 @@ GCC Code Coverage Report
|
8747784 |
- current_satellite.evolve_RK45(input_epsilon, timestep_to_use, |
+ current_satellite.evolve_RK45(input_sim_parameters.epsilon, timestep_to_use, |
- | 1358 |
+ 1365 |
|
4373892 |
- perturbation, atmospheric_drag, |
+ input_sim_parameters.perturbation_bool, |
- | 1359 |
+ 1366 |
|
4373892 |
- drag_elements); |
+ input_sim_parameters.drag_bool, drag_elements); |
- | 1360 |
+ 1367 |
|
4373892 |
double new_timestep = new_timestep_and_error_code.first; |
- | 1361 |
+ 1368 |
|
4373892 |
int error_code = new_timestep_and_error_code.second; |
- | 1362 |
+ 1369 |
|
|
|
- | 1363 |
+ 1370 |
1/2
@@ -11750,56 +11371,56 @@ GCC Code Coverage Report
if (error_code != 0) { |
|
- | 1364 |
+ 1371 |
|
✗ |
std::cout << "Error code " << error_code << " detected, halting visualization\n"; |
- | 1365 |
+ 1372 |
|
✗ |
fprintf(gnuplot_pipe, "e\n"); |
- | 1366 |
+ 1373 |
|
✗ |
fprintf(gnuplot_pipe, "exit \n"); |
- | 1367 |
+ 1374 |
|
✗ |
pclose(gnuplot_pipe); |
- | 1368 |
+ 1375 |
|
✗ |
return; |
- | 1369 |
+ 1376 |
|
|
} |
- | 1370 |
+ 1377 |
|
4373892 |
timestep_to_use = new_timestep; |
- | 1371 |
+ 1378 |
2/4
@@ -11815,14 +11436,14 @@ GCC Code Coverage Report
evolved_distance = input_ground_station.distance_to_satellite(current_satellite); |
|
- | 1372 |
+ 1379 |
|
4373892 |
previous_time = current_satellite_time; |
- | 1373 |
+ 1380 |
1/2
@@ -11836,7 +11457,7 @@ GCC Code Coverage Report
current_satellite_time = current_satellite.get_instantaneous_time(); |
|
- | 1374 |
+ 1381 |
2/4
@@ -11852,14 +11473,14 @@ GCC Code Coverage Report
ground_station_beam_angle = input_ground_station.angle_to_satellite_from_normal(current_satellite); |
|
- | 1375 |
+ 1382 |
|
|
// Check number of existing connections to ground station at this point |
- | 1376 |
+ 1383 |
1/2
@@ -11873,7 +11494,7 @@ GCC Code Coverage Report
int num_sats_at_this_time = input_ground_station.num_sats_connected_at_this_time(current_satellite_time); |
|
- | 1377 |
+ 1384 |
4/4
@@ -11889,35 +11510,28 @@ GCC Code Coverage Report
if ( (ground_station_beam_angle > input_ground_station.max_beam_angle_from_normal_) || (num_sats_at_this_time == input_ground_station.num_beams_)) { |
|
- | 1378 |
+ 1385 |
-
- 1/2
-
- ✓ Branch 0 taken 4016421 times.
- ✗ Branch 1 not taken.
-
-
|
- 4016421 |
- fprintf(gnuplot_pipe, "%.17g NaN\n", current_satellite_time); |
+ 4016421 |
+ fprintf(gnuplot_pipe, "%.17g NaN\n", current_satellite_time); |
- | 1379 |
+ 1386 |
|
4016421 |
} |
- | 1380 |
+ 1387 |
|
|
else { |
- | 1381 |
+ 1388 |
2/4
@@ -11933,21 +11547,14 @@ GCC Code Coverage Report
evolved_distance = input_ground_station.distance_to_satellite(current_satellite); |
|
- | 1382 |
+ 1389 |
-
- 1/2
-
- ✓ Branch 0 taken 357471 times.
- ✗ Branch 1 not taken.
-
-
|
- 357471 |
- fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, evolved_distance); |
+ 357471 |
+ fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, evolved_distance); |
- | 1383 |
+ 1390 |
1/2
@@ -11961,35 +11568,28 @@ GCC Code Coverage Report
input_ground_station.update_linked_sats_map(satellite_index, current_satellite_time, previous_time); |
|
- | 1384 |
+ 1391 |
|
|
} |
- | 1385 |
+ 1392 |
|
|
} |
- | 1386 |
+ 1393 |
-
- 1/2
-
- ✓ Branch 0 taken 648 times.
- ✗ Branch 1 not taken.
-
-
|
- 648 |
- fprintf(gnuplot_pipe, "e\n"); |
+ 648 |
+ fprintf(gnuplot_pipe, "e\n"); |
- | 1387 |
+ 1394 |
1/2
@@ -12003,42 +11603,28 @@ GCC Code Coverage Report
} |
|
- | 1388 |
+ 1395 |
-
- 1/2
-
- ✓ Branch 0 taken 162 times.
- ✗ Branch 1 not taken.
-
-
|
- 162 |
- fprintf(gnuplot_pipe, "pause mouse keypress\n"); |
+ 162 |
+ fprintf(gnuplot_pipe, "pause mouse keypress\n"); |
- | 1389 |
+ 1396 |
|
|
|
- | 1390 |
+ 1397 |
-
- 1/2
-
- ✓ Branch 0 taken 162 times.
- ✗ Branch 1 not taken.
-
-
|
- 162 |
- fprintf(gnuplot_pipe, "exit \n"); |
+ 162 |
+ fprintf(gnuplot_pipe, "exit \n"); |
- | 1391 |
+ 1398 |
1/2
@@ -12052,7 +11638,7 @@ GCC Code Coverage Report
pclose(gnuplot_pipe); |
|
- | 1392 |
+ 1399 |
1/2
@@ -12066,14 +11652,14 @@ GCC Code Coverage Report
std::cout << "Done\n"; |
|
- | 1393 |
+ 1400 |
|
|
|
- | 1394 |
+ 1401 |
1/3
@@ -12088,133 +11674,112 @@ GCC Code Coverage Report
} else { |
|
- | 1395 |
+ 1402 |
|
✗ |
std::cout << "gnuplot not found"; |
- | 1396 |
+ 1403 |
|
|
} |
- | 1397 |
+ 1404 |
|
|
|
- | 1398 |
+ 1405 |
|
162 |
return; |
- | 1399 |
+ 1406 |
|
|
|
- | 1400 |
+ 1407 |
|
162 |
} |
- | 1401 |
+ 1408 |
|
|
|
- | 1402 |
+ 1409 |
|
162 |
- void sim_and_plot_gs_connectivity_gnuplot( |
-
-
- | 1403 |
-
- |
- |
- PhasedArrayGroundStation input_ground_station, |
-
-
- | 1404 |
-
- |
- |
- std::vector<Satellite> input_satellite_vector, const double input_timestep, |
+ void sim_and_plot_gs_connectivity_gnuplot(PhasedArrayGroundStation input_ground_station, |
- | 1405 |
-
- |
- |
- const double input_total_sim_time, const double input_epsilon, |
-
-
- | 1406 |
+ 1410 |
|
|
- const std::string file_name = "output", |
+ std::vector<Satellite> input_satellite_vector, |
- | 1407 |
+ 1411 |
|
|
- const bool perturbation = true, const bool atmospheric_drag = false, |
+ const SimParameters& input_sim_parameters, |
- | 1408 |
+ 1412 |
|
|
- const std::pair<double, double> drag_elements = {}) { |
+ const std::string file_name) { |
- | 1409 |
+ 1413 |
|
|
|
- | 1410 |
+ 1414 |
|
|
// Objective: given an input ground station and satellite vector, |
- | 1411 |
+ 1415 |
|
|
// plot contact distances between ground station and satellites over time |
- | 1412 |
+ 1416 |
|
|
|
- | 1413 |
+ 1417 |
1/2
@@ -12228,56 +11793,56 @@ GCC Code Coverage Report
if (input_satellite_vector.size() < 1) { |
|
- | 1414 |
+ 1418 |
|
✗ |
std::cout << "No input Satellite objects\n"; |
- | 1415 |
+ 1419 |
|
✗ |
return; |
- | 1416 |
+ 1420 |
|
|
} |
- | 1417 |
+ 1421 |
|
|
|
- | 1418 |
+ 1422 |
|
|
// first, open "pipe" to gnuplot |
- | 1419 |
+ 1423 |
|
162 |
FILE *gnuplot_pipe = popen("gnuplot", "w"); |
- | 1420 |
+ 1424 |
|
|
// if it exists |
- | 1421 |
+ 1425 |
1/2
@@ -12291,126 +11856,126 @@ GCC Code Coverage Report
if (gnuplot_pipe) { |
|
- | 1422 |
+ 1426 |
|
162 |
fprintf(gnuplot_pipe, "set terminal png size 800,500 font ',14' linewidth 2\n"); |
- | 1423 |
+ 1427 |
|
|
// formatting |
- | 1424 |
+ 1428 |
|
162 |
fprintf(gnuplot_pipe, "set output '../%s.png'\n",file_name.c_str()); |
- | 1425 |
+ 1429 |
|
162 |
fprintf(gnuplot_pipe, "set xlabel 'Time [s]'\n"); |
- | 1426 |
+ 1430 |
|
162 |
fprintf(gnuplot_pipe, "set ylabel 'Satellite Index'\n"); |
- | 1427 |
+ 1431 |
|
|
|
- | 1428 |
+ 1432 |
|
324 |
fprintf(gnuplot_pipe, "set title 'Phased array ground station connectivity " |
- | 1429 |
+ 1433 |
|
162 |
"with %d beams'\n",input_ground_station.num_beams_); |
- | 1430 |
+ 1434 |
|
162 |
fprintf(gnuplot_pipe, "set key outside\n"); |
- | 1431 |
+ 1435 |
|
162 |
- int x_max_plot_window = std::floor(input_total_sim_time*1.05); |
+ int x_max_plot_window = std::floor(input_sim_parameters.total_sim_time*1.05); |
- | 1432 |
+ 1436 |
|
162 |
fprintf(gnuplot_pipe, "set xrange[0:%d]\n",x_max_plot_window); |
- | 1433 |
+ 1437 |
|
162 |
fprintf(gnuplot_pipe, "set yrange[-0.5:%lu]\n",input_satellite_vector.size()); |
- | 1434 |
+ 1438 |
|
|
|
- | 1435 |
+ 1439 |
|
|
// plotting |
- | 1436 |
+ 1440 |
|
|
|
- | 1437 |
+ 1441 |
|
|
// first satellite |
- | 1438 |
+ 1442 |
|
162 |
Satellite current_satellite = input_satellite_vector.at(0); |
- | 1439 |
+ 1443 |
2/2
@@ -12424,7 +11989,7 @@ GCC Code Coverage Report
if (input_satellite_vector.size() == 1) { |
|
- | 1440 |
+ 1444 |
2/2
@@ -12438,35 +12003,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 1441 |
+ 1445 |
-
- 1/2
-
- ✓ Branch 0 taken 27 times.
- ✗ Branch 1 not taken.
-
-
|
- 27 |
- fprintf(gnuplot_pipe, |
+ 27 |
+ fprintf(gnuplot_pipe, |
- | 1442 |
+ 1446 |
|
|
"plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \n", |
- | 1443 |
+ 1447 |
|
27 |
current_satellite.plotting_color_.c_str(), |
- | 1444 |
+ 1448 |
1/2
@@ -12480,35 +12038,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1445 |
+ 1449 |
|
27 |
} else { |
- | 1446 |
+ 1450 |
-
- 1/2
-
- ✓ Branch 0 taken 27 times.
- ✗ Branch 1 not taken.
-
-
|
- 27 |
- fprintf(gnuplot_pipe, |
+ 27 |
+ fprintf(gnuplot_pipe, |
- | 1447 |
+ 1451 |
|
|
"plot '-' using 1:2 with lines lw 1 title '%s' \n", |
- | 1448 |
+ 1452 |
1/2
@@ -12522,42 +12073,42 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1449 |
+ 1453 |
|
|
} |
- | 1450 |
+ 1454 |
|
|
|
- | 1451 |
+ 1455 |
|
54 |
} |
- | 1452 |
+ 1456 |
|
|
|
- | 1453 |
+ 1457 |
|
|
else { |
- | 1454 |
+ 1458 |
2/2
@@ -12571,35 +12122,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 1455 |
+ 1459 |
-
- 1/2
-
- ✓ Branch 0 taken 54 times.
- ✗ Branch 1 not taken.
-
-
|
- 54 |
- fprintf(gnuplot_pipe, |
+ 54 |
+ fprintf(gnuplot_pipe, |
- | 1456 |
+ 1460 |
|
|
"plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\\\n", |
- | 1457 |
+ 1461 |
|
54 |
current_satellite.plotting_color_.c_str(), |
- | 1458 |
+ 1462 |
1/2
@@ -12613,35 +12157,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1459 |
+ 1463 |
|
54 |
} else { |
- | 1460 |
+ 1464 |
-
- 1/2
-
- ✓ Branch 0 taken 54 times.
- ✗ Branch 1 not taken.
-
-
|
- 54 |
- fprintf(gnuplot_pipe, |
+ 54 |
+ fprintf(gnuplot_pipe, |
- | 1461 |
+ 1465 |
|
|
"plot '-' using 1:2 with lines lw 1 title '%s'\\\n", |
- | 1462 |
+ 1466 |
1/2
@@ -12655,28 +12192,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1463 |
+ 1467 |
|
|
} |
- | 1464 |
+ 1468 |
|
|
} |
- | 1465 |
+ 1469 |
|
|
|
- | 1466 |
+ 1470 |
2/2
@@ -12690,14 +12227,14 @@ GCC Code Coverage Report
for (size_t satellite_index = 1; |
|
- | 1467 |
+ 1471 |
|
648 |
satellite_index < input_satellite_vector.size(); satellite_index++) { |
- | 1468 |
+ 1472 |
2/4
@@ -12713,7 +12250,7 @@ GCC Code Coverage Report
current_satellite = input_satellite_vector.at(satellite_index); |
|
- | 1469 |
+ 1473 |
2/2
@@ -12727,7 +12264,7 @@ GCC Code Coverage Report
if (satellite_index < input_satellite_vector.size() - 1) { |
|
- | 1470 |
+ 1474 |
2/2
@@ -12741,35 +12278,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 1471 |
+ 1475 |
-
- 1/2
-
- ✗ Branch 0 not taken.
- ✓ Branch 1 taken 162 times.
-
-
|
- 162 |
- fprintf(gnuplot_pipe, |
+ 162 |
+ fprintf(gnuplot_pipe, |
- | 1472 |
+ 1476 |
|
|
",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \\\n", |
- | 1473 |
+ 1477 |
|
162 |
current_satellite.plotting_color_.c_str(), |
- | 1474 |
+ 1478 |
1/2
@@ -12783,35 +12313,28 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1475 |
+ 1479 |
|
162 |
} else { |
- | 1476 |
+ 1480 |
-
- 1/2
-
- ✗ Branch 0 not taken.
- ✓ Branch 1 taken 216 times.
-
-
|
- 216 |
- fprintf(gnuplot_pipe, |
+ 216 |
+ fprintf(gnuplot_pipe, |
- | 1477 |
+ 1481 |
|
|
",'-' using 1:2 with lines lw 1 title '%s' \\\n", |
- | 1478 |
+ 1482 |
1/2
@@ -12825,42 +12348,42 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1479 |
+ 1483 |
|
|
} |
- | 1480 |
+ 1484 |
|
|
|
- | 1481 |
+ 1485 |
|
378 |
} |
- | 1482 |
+ 1486 |
|
|
|
- | 1483 |
+ 1487 |
|
|
else { |
- | 1484 |
+ 1488 |
2/2
@@ -12874,35 +12397,28 @@ GCC Code Coverage Report
if (current_satellite.plotting_color_.size() > 0) { |
|
- | 1485 |
+ 1489 |
-
- 1/2
-
- ✗ Branch 0 not taken.
- ✓ Branch 1 taken 54 times.
-
-
|
- 54 |
- fprintf(gnuplot_pipe, |
+ 54 |
+ fprintf(gnuplot_pipe, |
- | 1486 |
+ 1490 |
|
|
",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\n", |
- | 1487 |
+ 1491 |
|
54 |
current_satellite.plotting_color_.c_str(), |
- | 1488 |
+ 1492 |
1/2
@@ -12916,28 +12432,21 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1489 |
+ 1493 |
|
54 |
} else { |
- | 1490 |
+ 1494 |
-
- 1/2
-
- ✗ Branch 0 not taken.
- ✓ Branch 1 taken 54 times.
-
-
|
- 54 |
- fprintf(gnuplot_pipe, ",'-' using 1:2 with lines lw 1 title '%s'\n", |
+ 54 |
+ fprintf(gnuplot_pipe, ",'-' using 1:2 with lines lw 1 title '%s'\n", |
- | 1491 |
+ 1495 |
1/2
@@ -12951,42 +12460,42 @@ GCC Code Coverage Report
current_satellite.get_name().c_str()); |
|
- | 1492 |
+ 1496 |
|
|
} |
- | 1493 |
+ 1497 |
|
|
} |
- | 1494 |
+ 1498 |
|
486 |
} |
- | 1495 |
+ 1499 |
|
|
|
- | 1496 |
+ 1500 |
|
|
// now the orbit data, inline, one satellite at a time |
- | 1497 |
+ 1501 |
1/2
@@ -13000,7 +12509,7 @@ GCC Code Coverage Report
std::cout << "Running simulation...\n"; |
|
- | 1498 |
+ 1502 |
2/2
@@ -13014,14 +12523,14 @@ GCC Code Coverage Report
for (size_t satellite_index = 0; |
|
- | 1499 |
+ 1503 |
|
810 |
satellite_index < input_satellite_vector.size(); satellite_index++) { |
- | 1500 |
+ 1504 |
2/4
@@ -13037,14 +12546,14 @@ GCC Code Coverage Report
Satellite current_satellite = input_satellite_vector.at(satellite_index); |
|
- | 1501 |
+ 1505 |
|
648 |
double current_satellite_time = |
- | 1502 |
+ 1506 |
1/2
@@ -13058,14 +12567,14 @@ GCC Code Coverage Report
current_satellite.get_instantaneous_time(); |
|
- | 1503 |
+ 1507 |
|
648 |
double previous_time = current_satellite_time - 1; |
- | 1504 |
+ 1508 |
2/4
@@ -13081,14 +12590,14 @@ GCC Code Coverage Report
double ground_station_beam_angle = input_ground_station.angle_to_satellite_from_normal(current_satellite); |
|
- | 1505 |
+ 1509 |
|
|
|
- | 1506 |
+ 1510 |
1/2
@@ -13102,63 +12611,56 @@ GCC Code Coverage Report
if (ground_station_beam_angle > input_ground_station.max_beam_angle_from_normal_) { |
|
- | 1507 |
+ 1511 |
-
- 1/2
-
- ✓ Branch 0 taken 648 times.
- ✗ Branch 1 not taken.
-
-
|
- 648 |
- fprintf(gnuplot_pipe, "%.17g NaN\n", current_satellite_time); |
+ 648 |
+ fprintf(gnuplot_pipe, "%.17g NaN\n", current_satellite_time); |
- | 1508 |
+ 1512 |
|
648 |
} |
- | 1509 |
+ 1513 |
|
|
else { |
- | 1510 |
+ 1514 |
|
✗ |
fprintf(gnuplot_pipe, "%.17g %lu\n", current_satellite_time, satellite_index); |
- | 1511 |
+ 1515 |
|
|
} |
- | 1512 |
+ 1516 |
|
|
|
- | 1513 |
+ 1517 |
|
648 |
- double timestep_to_use = input_timestep; |
+ double timestep_to_use = input_sim_parameters.initial_timestep_guess; |
- | 1514 |
+ 1518 |
1/2
@@ -13172,28 +12674,35 @@ GCC Code Coverage Report
current_satellite_time = current_satellite.get_instantaneous_time(); |
|
- | 1515 |
+ 1519 |
2/2
- ✓ Branch 0 taken 648 times.
- ✓ Branch 1 taken 4373892 times.
+ ✓ Branch 0 taken 4373892 times.
+ ✓ Branch 1 taken 648 times.
|
4374540 |
- while (current_satellite_time < input_total_sim_time) { |
+ while (current_satellite_time < input_sim_parameters.total_sim_time) { |
- | 1516 |
+ 1520 |
+
+ |
+ 4373892 |
+ std::pair<double, double> drag_elements = {input_sim_parameters.F_10, input_sim_parameters.A_p}; |
+
+
+ | 1521 |
|
|
std::pair<double, int> new_timestep_and_error_code = |
- | 1517 |
+ 1522 |
2/4
@@ -13206,45 +12715,45 @@ GCC Code Coverage Report
|
8747784 |
- current_satellite.evolve_RK45(input_epsilon, timestep_to_use, |
+ current_satellite.evolve_RK45(input_sim_parameters.epsilon, timestep_to_use, |
- | 1518 |
+ 1523 |
|
4373892 |
- perturbation, atmospheric_drag, |
+ input_sim_parameters.perturbation_bool, |
- | 1519 |
+ 1524 |
|
4373892 |
- drag_elements); |
+ input_sim_parameters.drag_bool, drag_elements); |
- | 1520 |
+ 1525 |
|
4373892 |
double new_timestep = new_timestep_and_error_code.first; |
- | 1521 |
+ 1526 |
|
4373892 |
int error_code = new_timestep_and_error_code.second; |
- | 1522 |
+ 1527 |
|
|
|
- | 1523 |
+ 1528 |
1/2
@@ -13258,63 +12767,63 @@ GCC Code Coverage Report
if (error_code != 0) { |
|
- | 1524 |
+ 1529 |
|
✗ |
std::cout << "Error code " << error_code << " detected, halting visualization\n"; |
- | 1525 |
+ 1530 |
|
✗ |
fprintf(gnuplot_pipe, "e\n"); |
- | 1526 |
+ 1531 |
|
✗ |
fprintf(gnuplot_pipe, "exit \n"); |
- | 1527 |
+ 1532 |
|
✗ |
pclose(gnuplot_pipe); |
- | 1528 |
+ 1533 |
|
✗ |
return; |
- | 1529 |
+ 1534 |
|
|
} |
- | 1530 |
+ 1535 |
|
4373892 |
timestep_to_use = new_timestep; |
- | 1531 |
+ 1536 |
|
4373892 |
previous_time = current_satellite_time; |
- | 1532 |
+ 1537 |
1/2
@@ -13328,7 +12837,7 @@ GCC Code Coverage Report
current_satellite_time = current_satellite.get_instantaneous_time(); |
|
- | 1533 |
+ 1538 |
2/4
@@ -13344,14 +12853,14 @@ GCC Code Coverage Report
ground_station_beam_angle = input_ground_station.angle_to_satellite_from_normal(current_satellite); |
|
- | 1534 |
+ 1539 |
|
|
// Check number of existing connections to ground station at this point |
- | 1535 |
+ 1540 |
1/2
@@ -13365,7 +12874,7 @@ GCC Code Coverage Report
int num_sats_at_this_time = input_ground_station.num_sats_connected_at_this_time(current_satellite_time); |
|
- | 1536 |
+ 1541 |
4/4
@@ -13381,49 +12890,35 @@ GCC Code Coverage Report
if ( (ground_station_beam_angle > input_ground_station.max_beam_angle_from_normal_) || (num_sats_at_this_time == input_ground_station.num_beams_)) { |
|
- | 1537 |
+ 1542 |
-
- 1/2
-
- ✓ Branch 0 taken 4016421 times.
- ✗ Branch 1 not taken.
-
-
|
- 4016421 |
- fprintf(gnuplot_pipe, "%.17g NaN\n", current_satellite_time); |
+ 4016421 |
+ fprintf(gnuplot_pipe, "%.17g NaN\n", current_satellite_time); |
- | 1538 |
+ 1543 |
|
4016421 |
} |
- | 1539 |
+ 1544 |
|
|
else { |
- | 1540 |
+ 1545 |
-
- 1/2
-
- ✓ Branch 0 taken 357471 times.
- ✗ Branch 1 not taken.
-
-
|
- 357471 |
- fprintf(gnuplot_pipe, "%.17g %lu\n", current_satellite_time, satellite_index); |
+ 357471 |
+ fprintf(gnuplot_pipe, "%.17g %lu\n", current_satellite_time, satellite_index); |
- | 1541 |
+ 1546 |
1/2
@@ -13437,35 +12932,28 @@ GCC Code Coverage Report
input_ground_station.update_linked_sats_map(satellite_index, current_satellite_time, previous_time); |
|
- | 1542 |
+ 1547 |
|
|
} |
- | 1543 |
+ 1548 |
|
|
} |
- | 1544 |
+ 1549 |
-
- 1/2
-
- ✓ Branch 0 taken 648 times.
- ✗ Branch 1 not taken.
-
-
|
- 648 |
- fprintf(gnuplot_pipe, "e\n"); |
+ 648 |
+ fprintf(gnuplot_pipe, "e\n"); |
- | 1545 |
+ 1550 |
1/2
@@ -13479,91 +12967,77 @@ GCC Code Coverage Report
} |
|
- | 1546 |
+ 1551 |
|
|
// for (auto key_val_pair : input_ground_station.linked_sats_map_) { |
- | 1547 |
+ 1552 |
|
|
// std::cout << "==========================================\n"; |
- | 1548 |
+ 1553 |
|
|
// std::cout << "Satellite index " << key_val_pair.first << "\n"; |
- | 1549 |
+ 1554 |
|
|
// for (std::pair<double,double> range : key_val_pair.second) { |
- | 1550 |
+ 1555 |
|
|
// std::cout << "{" << range.first << "," << range.second << "}\n"; |
- | 1551 |
+ 1556 |
|
|
// } |
- | 1552 |
+ 1557 |
|
|
// } |
- | 1553 |
+ 1558 |
-
- 1/2
-
- ✓ Branch 0 taken 162 times.
- ✗ Branch 1 not taken.
-
-
|
- 162 |
- fprintf(gnuplot_pipe, "pause mouse keypress\n"); |
+ 162 |
+ fprintf(gnuplot_pipe, "pause mouse keypress\n"); |
- | 1554 |
+ 1559 |
|
|
|
- | 1555 |
+ 1560 |
-
- 1/2
-
- ✓ Branch 0 taken 162 times.
- ✗ Branch 1 not taken.
-
-
|
- 162 |
- fprintf(gnuplot_pipe, "exit \n"); |
+ 162 |
+ fprintf(gnuplot_pipe, "exit \n"); |
- | 1556 |
+ 1561 |
1/2
@@ -13577,7 +13051,7 @@ GCC Code Coverage Report
pclose(gnuplot_pipe); |
|
- | 1557 |
+ 1562 |
1/2
@@ -13591,14 +13065,14 @@ GCC Code Coverage Report
std::cout << "Done\n"; |
|
- | 1558 |
+ 1563 |
|
|
|
- | 1559 |
+ 1564 |
1/3
@@ -13613,49 +13087,714 @@ GCC Code Coverage Report
} else { |
|
- | 1560 |
+ 1565 |
|
✗ |
std::cout << "gnuplot not found"; |
- | 1561 |
+ 1566 |
|
|
} |
- | 1562 |
+ 1567 |
|
|
|
- | 1563 |
+ 1568 |
|
162 |
return; |
- | 1564 |
+ 1569 |
|
|
|
- | 1565 |
+ 1570 |
|
162 |
} |
- | 1566 |
+ 1571 |
+
+ |
+ |
+ |
+
+
+ | 1572 |
+
+ |
+ |
+ |
+
+
+ | 1573 |
+
+ |
+ 2 |
+ int add_lowthrust_orbit_transfer(Satellite& input_satellite_object, const double final_orbit_semimajor_axis_km, |
+
+
+ | 1574 |
+
+ |
+ |
+ const double input_thrust_magnitude, const double transfer_initiation_time) { |
+
+
+ | 1575 |
+
+ |
+ |
+ // Only transfers between circular orbits are supported at this time |
+
+
+ | 1576 |
+
+ |
+ |
+ // Ref: https://prussing.ae.illinois.edu/AE402/low.thrust.pdf |
+
+
+ | 1577 |
+
+ |
+ 2 |
+ int error_code = 0; |
+
+
+ | 1578 |
+
+
+ 1/2
+
+ ✓ Branch 0 taken 2 times.
+ ✗ Branch 1 not taken.
+
+
+ |
+ 2 |
+ double initial_eccentricity = input_satellite_object.get_orbital_parameter("Eccentricity"); |
+
+
+ | 1579 |
+
+
+ 2/2
+
+ ✓ Branch 0 taken 1 times.
+ ✓ Branch 1 taken 1 times.
+
+
+ |
+ 2 |
+ if (initial_eccentricity != 0) { |
+
+
+ | 1580 |
+
+ |
+ 1 |
+ std::cout << "Satellite's initial orbit was not circular\n"; |
+
+
+ | 1581 |
+
+ |
+ 1 |
+ error_code = 1; |
+
+
+ | 1582 |
+
+ |
+ 1 |
+ } |
+
+
+ | 1583 |
+
+ |
+ 2 |
+ double satellite_mass = input_satellite_object.get_mass(); |
+
+
+ | 1584 |
+
+
+ 1/2
+
+ ✓ Branch 0 taken 2 times.
+ ✗ Branch 1 not taken.
+
+
+ |
+ 2 |
+ if (satellite_mass <= 0) { |
+
+
+ | 1585 |
+
+ |
+ ✗ |
+ std::cout << "Error: satellite mass was <= 0\n"; |
+
+
+ | 1586 |
+
+ |
+ ✗ |
+ error_code = 2; |
+
+
+ | 1587 |
+
+ |
+ ✗ |
+ } |
+
+
+ | 1588 |
+
+ |
+ 2 |
+ double thrust_acceleration = input_thrust_magnitude/satellite_mass; |
+
+
+ | 1589 |
+
+ |
+ 2 |
+ double semimajor_axis_final = 1000 * final_orbit_semimajor_axis_km; // m |
+
+
+ | 1590 |
+
+
+ 1/2
+
+ ✓ Branch 0 taken 2 times.
+ ✗ Branch 1 not taken.
+
+
+ |
+ 2 |
+ double semimajor_axis_initial = input_satellite_object.get_orbital_parameter("Semimajor Axis"); |
+
+
+ | 1591 |
+
+ |
+ 2 |
+ const double mu_Earth = G*mass_Earth; |
+
+
+ | 1592 |
+
+ |
+ 2 |
+ double comp1 =sqrt(mu_Earth/semimajor_axis_initial); |
+
+
+ | 1593 |
+
+ |
+ 2 |
+ double comp2 = sqrt(mu_Earth/semimajor_axis_final); |
+
+
+ | 1594 |
+
+ |
+ 2 |
+ double time_to_burn = (comp1-comp2)/thrust_acceleration; |
+
+
+ | 1595 |
+
+ |
+ |
+ |
+
+
+ | 1596 |
+
+ |
+ |
+ // Thrust is purely co-linear with velocity vector, so in the +- x direction of the LVLH frame |
+
+
+ | 1597 |
+
+ |
+ |
+ // (along +x if raising orbit, -x if lowering orbit) |
+
+
+ | 1598 |
+
+ |
+ |
+ std::array<double,3> LVLH_thrust_direction; |
+
+
+ | 1599 |
+
+
+ 1/2
+
+ ✓ Branch 0 taken 2 times.
+ ✗ Branch 1 not taken.
+
+
+ |
+ 2 |
+ if (semimajor_axis_initial < semimajor_axis_final) { |
+
+
+ | 1600 |
+
+ |
+ 2 |
+ LVLH_thrust_direction = {1,0,0}; |
+
+
+ | 1601 |
+
+ |
+ 2 |
+ } |
+
+
+ | 1602 |
+
+ |
+ ✗ |
+ else if (semimajor_axis_initial > semimajor_axis_final) { |
+
+
+ | 1603 |
+
+ |
+ ✗ |
+ LVLH_thrust_direction = {-1,0,0}; |
+
+
+ | 1604 |
+
+ |
+ ✗ |
+ time_to_burn = (-1)*time_to_burn; // Since this would have otherwise been negative |
+
+
+ | 1605 |
+
+ |
+ ✗ |
+ } |
+
+
+ | 1606 |
+
+ |
+ |
+ else { |
+
+
+ | 1607 |
+
+ |
+ ✗ |
+ std::cout << "Error: initial and final semimajor axes were equal.\n"; |
+
+
+ | 1608 |
+
+ |
+ ✗ |
+ error_code = 3; // Arbitrarily choose a burn direction in this scenario, since it shouldn't matter |
+
+
+ | 1609 |
+
+ |
+ |
+ } |
+
+
+ | 1610 |
+
+
+ 2/2
+
+ ✓ Branch 0 taken 1 times.
+ ✓ Branch 1 taken 1 times.
+
+
+ |
+ 2 |
+ if (error_code == 0) { |
+
+
+ | 1611 |
+
+ |
+ 2 |
+ input_satellite_object.add_LVLH_thrust_profile(LVLH_thrust_direction, input_thrust_magnitude, |
+
+
+ | 1612 |
+
+ |
+ 1 |
+ transfer_initiation_time, transfer_initiation_time + time_to_burn); |
+
+
+ | 1613 |
+
+ |
+ 1 |
+ } |
+
+
+ | 1614 |
+
+ |
+ 2 |
+ return error_code; |
+
+
+ | 1615 |
+
+ |
+ ✗ |
+ } |
+
+
+ | 1616 |
+
+ |
+ |
+ |
+
+
+ | 1617 |
+
+ |
+ ✗ |
+ double calibrate_mean_val(Satellite satellite_object, const SimParameters& input_sim_parameters, const std::string input_parameter_name) { |
+
+
+ | 1618 |
+
+ |
+ |
+ // Objective: help calibrate simulations in context of inherent oscillations of parameters |
+
+
+ | 1619 |
+
+ |
+ |
+ // Here, the mean value of oscillations will be assumed to be constant (oscillations don't drift up or down over time) |
+
+
+ | 1620 |
+
+ |
+ |
+ |
+
+
+ | 1621 |
+
+ |
+ |
+ // Let the simulation run without external applied forces, return mean value of parameter |
+
+
+ | 1622 |
+
+ |
+ |
+ // Not passing in satellite object by ref so that its internal clock doesn't get altered from its initial value before the actual |
+
+
+ | 1623 |
+
+ |
+ |
+ // simulations start |
+
+
+ | 1624 |
+
+ |
+ |
+ |
+
+
+ | 1625 |
+
+ |
+ ✗ |
+ double val = |
+
+
+ | 1626 |
+
+ |
+ ✗ |
+ satellite_object.get_orbital_parameter(input_parameter_name); |
+
+
+ | 1627 |
+
+ |
+ ✗ |
+ double mean_val = val; |
+
+
+ | 1628 |
+
+ |
+ ✗ |
+ size_t num_datapoints = 1; |
+
+
+ | 1629 |
+
+ |
+ ✗ |
+ double current_satellite_time = |
+
+
+ | 1630 |
+
+ |
+ ✗ |
+ satellite_object.get_instantaneous_time(); |
+
+
+ | 1631 |
+
+ |
+ |
+ |
+
+
+ | 1632 |
+
+ |
+ ✗ |
+ double evolved_val = {0}; |
+
+
+ | 1633 |
+
+ |
+ |
+ |
+
+
+ | 1634 |
+
+ |
+ ✗ |
+ double timestep_to_use = input_sim_parameters.initial_timestep_guess; |
+
+
+ | 1635 |
+
+ |
+ ✗ |
+ current_satellite_time = satellite_object.get_instantaneous_time(); |
+
+
+ | 1636 |
+
+ |
+ ✗ |
+ while (current_satellite_time < input_sim_parameters.total_sim_time) { |
+
+
+ | 1637 |
+
+ |
+ ✗ |
+ std::pair<double, double> drag_elements = {input_sim_parameters.F_10, input_sim_parameters.A_p}; |
+
+
+ | 1638 |
+
+ |
+ |
+ std::pair<double, int> new_timestep_and_error_code = |
+
+
+ | 1639 |
+
+ |
+ ✗ |
+ satellite_object.evolve_RK45(input_sim_parameters.epsilon, timestep_to_use, |
+
+
+ | 1640 |
+
+ |
+ ✗ |
+ input_sim_parameters.perturbation_bool, |
+
+
+ | 1641 |
+
+ |
+ ✗ |
+ input_sim_parameters.drag_bool, drag_elements); |
+
+
+ | 1642 |
+
+ |
+ ✗ |
+ double new_timestep = new_timestep_and_error_code.first; |
+
+
+ | 1643 |
+
+ |
+ ✗ |
+ int error_code = new_timestep_and_error_code.second; |
+
+
+ | 1644 |
+
+ |
+ |
+ |
+
+
+ | 1645 |
+
+ |
+ ✗ |
+ if (error_code != 0) { |
+
+
+ | 1646 |
+
+ |
+ ✗ |
+ std::cout << "Error code " << error_code << " detected, halting simulation and returning 0\n"; |
+
+
+ | 1647 |
+
+ |
+ ✗ |
+ return 0.0; |
+
+
+ | 1648 |
+
+ |
+ |
+ } |
+
+
+ | 1649 |
+
+ |
+ ✗ |
+ timestep_to_use = new_timestep; |
+
+
+ | 1650 |
+
+ |
+ ✗ |
+ evolved_val = |
+
+
+ | 1651 |
+
+ |
+ ✗ |
+ satellite_object.get_orbital_parameter(input_parameter_name); |
+
+
+ | 1652 |
+
+ |
+ ✗ |
+ mean_val += evolved_val; |
+
+
+ | 1653 |
+
+ |
+ ✗ |
+ num_datapoints+=1; |
+
+
+ | 1654 |
+
+ |
+ |
+ |
+
+
+ | 1655 |
+
+ |
+ ✗ |
+ current_satellite_time = satellite_object.get_instantaneous_time(); |
+
+
+ | 1656 |
+
+ |
+ |
+ } |
+
+
+ | 1657 |
+
+ |
+ ✗ |
+ mean_val /= num_datapoints; |
+
+
+ | 1658 |
+
+ |
+ ✗ |
+ return mean_val; |
+
+
+ | 1659 |
+
+ |
+ ✗ |
+ } |
+
+
+ | 1660 |
|
|
diff --git a/tests/test_coverage_detailed.utils.h.0924fa377d356c0f9a6a386ccdf5fa6d.html b/tests/test_coverage_detailed.utils.h.0924fa377d356c0f9a6a386ccdf5fa6d.html
index bf7d6e3..4e910b8 100644
--- a/tests/test_coverage_detailed.utils.h.0924fa377d356c0f9a6a386ccdf5fa6d.html
+++ b/tests/test_coverage_detailed.utils.h.0924fa377d356c0f9a6a386ccdf5fa6d.html
@@ -26,7 +26,7 @@ GCC Code Coverage Report
| Date: |
- 2025-04-22 23:09:44 |
+ 2025-05-06 17:04:10 |
@@ -40,21 +40,21 @@ GCC Code Coverage Report
| Lines: |
- 87 |
- 87 |
- 100.0% |
+ 121 |
+ 129 |
+ 93.8% |
| Functions: |
- 1 |
- 1 |
+ 3 |
+ 3 |
100.0% |
| Branches: |
- 74 |
- 128 |
- 57.8% |
+ 113 |
+ 222 |
+ 50.9% |
@@ -70,7 +70,9 @@ GCC Code Coverage Report
Call count |
Block coverage |
- | std::__1::pair<std::__1::array<double, 13>, std::__1::pair<double, double>> RK45_step<13>(std::__1::array<double, 13>, double, std::__1::function<std::__1::array<double, 13> (std::__1::array<double, 13>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, double, bool, bool)>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, bool, double, double, double) (line 302) | called 9157346 times | 87.0% |
+ | SimParameters::SimParameters(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 33) | called 10 times | 100.0% |
+ | SimParameters::~SimParameters() (line 20) | called 10 times | 100.0% |
+ | std::__1::pair<std::__1::array<double, 13>, std::__1::pair<double, double>> RK45_step<13>(std::__1::array<double, 13>, double, std::__1::function<std::__1::array<double, 13> (std::__1::array<double, 13>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, double, bool, bool)>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, std::__1::vector<BodyframeTorqueProfile, std::__1::allocator<BodyframeTorqueProfile>>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double, std::__1::vector<ThrustProfileLVLH, std::__1::allocator<ThrustProfileLVLH>>, double, double, double, double, double, double, bool, double, double, double) (line 346) | called 9157346 times | 87.0% |
@@ -85,2380 +87,2846 @@ GCC Code Coverage Report
Source |
- | 1 |
+ 1 |
+
+ |
+ |
+ #ifndef UTILS_HEADER |
+
+
+ | 2 |
+
+ |
+ |
+ #define UTILS_HEADER |
+
+
+ | 3 |
+
+ |
+ |
+ |
+
+
+ | 4 |
+
+ |
+ |
+ #include <Eigen/Dense> |
+
+
+ | 5 |
+
+ |
+ |
+ #include <functional> |
+
+
+ | 6 |
+
+ |
+ |
+ #include <iostream> |
+
+
+ | 7 |
+
+ |
+ |
+ #include <nlohmann/json.hpp> |
+
+
+ | 8 |
+
+ |
+ |
+ |
+
+
+ | 9 |
+
+ |
+ |
+ #include "Satellite.h" |
+
+
+ | 10 |
+
+ |
+ |
+ #include "PhasedArrayGroundStation.h" |
+
+
+ | 11 |
+
+ |
+ |
+ |
+
+
+ | 12 |
+
+ |
+ |
+ using Eigen::Matrix3d; |
+
+
+ | 13 |
+
+ |
+ |
+ using Eigen::MatrixXd; |
+
+
+ | 14 |
+
+ |
+ |
+ using Eigen::Vector3d; |
+
+
+ | 15 |
+
+ |
+ |
+ using Eigen::Vector4d; |
+
+
+ | 16 |
+
+ |
+ |
+ |
+
+
+ | 17 |
+
+ |
+ |
+ using json = nlohmann::json; |
+
+
+ | 18 |
+
+ |
+ |
+ |
+
+
+ | 19 |
+
+ |
+ |
+ |
+
+
+ | 20 |
+
+ |
+ |
+ struct SimParameters { |
+
+
+ | 21 |
+
+ |
+ 5 |
+ double initial_timestep_guess = 1; |
+
+
+ | 22 |
+
+ |
+ 5 |
+ double total_sim_time = 10; |
+
+
+ | 23 |
+
+ |
+ 5 |
+ double epsilon = pow(10, -8); |
+
+
+ | 24 |
+
+ |
+ 5 |
+ bool perturbation_bool = true; |
+
+
+ | 25 |
+
+ |
+ 5 |
+ bool drag_bool = false; |
+
+
+ | 26 |
+
+ |
+ 5 |
+ double x_increment = 0; |
+
+
+ | 27 |
+
+ |
+ 5 |
+ double y_increment = 0; |
+
+
+ | 28 |
+
+ |
+ 5 |
+ double z_increment = 0; |
+
+
+ | 29 |
+
+ |
+ 5 |
+ double F_10 = 0; // Solar radio ten centimeter flux |
+
+
+ | 30 |
+
+ |
+ 5 |
+ double A_p = 0; // Geomagnetic A_p index |
+
+
+ | 31 |
+
+ |
+ 5 |
+ std::string terminal_name_3D = "qt"; |
+
+
+ | 32 |
+
+ |
+ |
+ |
+
+
+ | 33 |
+
+ |
+ 10 |
+ SimParameters(const std::string parameter_json_file_name) { |
+
+
+ | 34 |
+
+
+ 1/2
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+
+
+ |
+ 5 |
+ std::ifstream input_filestream(parameter_json_file_name); |
+
+
+ | 35 |
+
+
+ 1/2
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+
+
+ |
+ 5 |
+ json input_data = json::parse(input_filestream); |
+
+
+ | 36 |
+
+ |
+ |
+ |
+
+
+ | 37 |
+
+
+ 3/6
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+ ✓ Branch 2 taken 5 times.
+ ✗ Branch 3 not taken.
+ ✓ Branch 4 taken 5 times.
+ ✗ Branch 5 not taken.
+
+
+ |
+ 5 |
+ if (input_data.find("Initial timestep guess") != input_data.end()) { |
+
+
+ | 38 |
+
+
+ 2/4
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+ ✓ Branch 2 taken 5 times.
+ ✗ Branch 3 not taken.
+
+
+ |
+ 5 |
+ initial_timestep_guess = input_data.at("Initial timestep guess"); |
+
+
+ | 39 |
+
+ |
+ 5 |
+ } |
+
+
+ | 40 |
+
+
+ 3/6
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+ ✓ Branch 2 taken 5 times.
+ ✗ Branch 3 not taken.
+ ✓ Branch 4 taken 5 times.
+ ✗ Branch 5 not taken.
+
+
+ |
+ 5 |
+ if (input_data.find("Simulation duration") != input_data.end()) { |
+
+
+ | 41 |
+
+
+ 2/4
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+ ✓ Branch 2 taken 5 times.
+ ✗ Branch 3 not taken.
+
+
+ |
+ 5 |
+ total_sim_time = input_data.at("Simulation duration"); |
+
+
+ | 42 |
+
+ |
+ 5 |
+ } |
+
+
+ | 43 |
+
+
+ 3/6
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+ ✓ Branch 2 taken 5 times.
+ ✗ Branch 3 not taken.
+ ✓ Branch 4 taken 5 times.
+ ✗ Branch 5 not taken.
+
+
+ |
+ 5 |
+ if (input_data.find("epsilon") != input_data.end()) { |
+
+
+ | 44 |
+
+
+ 2/4
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+ ✓ Branch 2 taken 5 times.
+ ✗ Branch 3 not taken.
+
+
+ |
+ 5 |
+ epsilon = input_data.at("epsilon"); |
+
+
+ | 45 |
+
+ |
+ 5 |
+ } |
+
+
+ | 46 |
+
+
+ 3/6
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+ ✓ Branch 2 taken 5 times.
+ ✗ Branch 3 not taken.
+ ✓ Branch 4 taken 5 times.
+ ✗ Branch 5 not taken.
+
+
+ |
+ 5 |
+ if (input_data.find("Perturbation") != input_data.end()) { |
+
+
+ | 47 |
+
+
+ 2/4
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+ ✓ Branch 2 taken 5 times.
+ ✗ Branch 3 not taken.
+
+
+ |
+ 5 |
+ perturbation_bool = input_data.at("Perturbation"); |
+
+
+ | 48 |
+
+ |
+ 5 |
+ } |
+
+
+ | 49 |
+
+
+ 3/6
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+ ✓ Branch 2 taken 5 times.
+ ✗ Branch 3 not taken.
+ ✓ Branch 4 taken 5 times.
+ ✗ Branch 5 not taken.
+
+
+ |
+ 5 |
+ if (input_data.find("Drag") != input_data.end()) { |
+
+
+ | 50 |
+
+
+ 2/4
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+ ✓ Branch 2 taken 5 times.
+ ✗ Branch 3 not taken.
+
+
+ |
+ 5 |
+ drag_bool = input_data.at("Drag"); |
+
+
+ | 51 |
|
- |
- #ifndef UTILS_HEADER |
+ 5 |
+ } |
- | 2 |
+ 52 |
+
+ 3/6
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+ ✓ Branch 2 taken 5 times.
+ ✗ Branch 3 not taken.
+ ✗ Branch 4 not taken.
+ ✓ Branch 5 taken 5 times.
+
+
|
- |
- #define UTILS_HEADER |
+ 5 |
+ if (input_data.find("X increment") != input_data.end()) { |
- | 3 |
+ 53 |
|
- |
- |
+ ✗ |
+ x_increment = input_data.at("X increment"); |
- | 4 |
+ 54 |
|
- |
- #include <Eigen/Dense> |
+ ✗ |
+ } |
- | 5 |
+ 55 |
+
+ 3/6
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+ ✓ Branch 2 taken 5 times.
+ ✗ Branch 3 not taken.
+ ✗ Branch 4 not taken.
+ ✓ Branch 5 taken 5 times.
+
+
|
- |
- #include <functional> |
+ 5 |
+ if (input_data.find("Y increment") != input_data.end()) { |
- | 6 |
+ 56 |
|
- |
- #include <iostream> |
+ ✗ |
+ y_increment = input_data.at("Y increment"); |
- | 7 |
+ 57 |
|
- |
- |
+ ✗ |
+ } |
- | 8 |
+ 58 |
+
+ 3/6
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+ ✓ Branch 2 taken 5 times.
+ ✗ Branch 3 not taken.
+ ✗ Branch 4 not taken.
+ ✓ Branch 5 taken 5 times.
+
+
|
- |
- #include "Satellite.h" |
+ 5 |
+ if (input_data.find("Z increment") != input_data.end()) { |
- | 9 |
+ 59 |
|
- |
- #include "PhasedArrayGroundStation.h" |
+ ✗ |
+ z_increment = input_data.at("Z increment"); |
- | 10 |
+ 60 |
|
- |
- |
+ ✗ |
+ } |
- | 11 |
+ 61 |
+
+ 3/6
+
+ ✓ Branch 0 taken 5 times.
+ ✗ Branch 1 not taken.
+ ✓ Branch 2 taken 5 times.
+ ✗ Branch 3 not taken.
+ ✗ Branch 4 not taken.
+ ✓ Branch 5 taken 5 times.
+
+
|
- |
- using Eigen::Matrix3d; |
+ 5 |
+ if (input_data.find("3D plotting terminal") != input_data.end()) { |
- | 12 |
+ 62 |
|
- |
- using Eigen::MatrixXd; |
+ ✗ |
+ terminal_name_3D = input_data.at("3D plotting terminal"); |
- | 13 |
+ 63 |
|
- |
- using Eigen::Vector3d; |
+ ✗ |
+ } |
- | 14 |
+ 64 |
+
+ |
+ 10 |
+ } |
+
+
+ | 65 |
|
|
- using Eigen::Vector4d; |
+ }; |
- | 15 |
+ 66 |
|
|
|
- | 16 |
+ 67 |
|
|
std::array<double, 3> calculate_orbital_acceleration( |
- | 17 |
+ 68 |
|
|
const std::array<double, 3> input_r_vec, const double input_spacecraft_mass, |
- | 18 |
+ 69 |
|
|
const std::vector<std::array<double, 3>> input_vec_of_force_vectors_in_ECI = |
- | 19 |
+ 70 |
|
|
{}); |
- | 20 |
+ 71 |
|
|
std::array<double, 3> calculate_orbital_acceleration( |
- | 21 |
+ 72 |
|
|
const std::array<double, 3> input_r_vec, const double input_spacecraft_mass, |
- | 22 |
+ 73 |
|
|
const std::vector<ThrustProfileLVLH> input_list_of_thrust_profiles_LVLH, |
- | 23 |
+ 74 |
|
|
const double input_evaluation_time, |
- | 24 |
+ 75 |
|
|
const std::array<double, 3> input_velocity_vec, |
- | 25 |
+ 76 |
|
|
const double input_inclination, const double input_arg_of_periapsis, |
- | 26 |
+ 77 |
|
|
const double input_true_anomaly, const double input_F_10, |
- | 27 |
+ 78 |
|
|
const double input_A_p, const double input_A_s, |
- | 28 |
+ 79 |
|
|
const double input_satellite_mass, const bool perturbation, |
- | 29 |
+ 80 |
|
|
const bool atmospheric_drag); |
- | 30 |
+ 81 |
|
|
|
- | 31 |
+ 82 |
|
|
std::array<double, 6> RK4_deriv_function_orbit_position_and_velocity( |
- | 32 |
+ 83 |
|
|
const std::array<double, 6> input_position_and_velocity, |
- | 33 |
+ 84 |
|
|
const double input_spacecraft_mass, |
- | 34 |
+ 85 |
|
|
const std::vector<std::array<double, 3>> input_vec_of_force_vectors_in_ECI = |
- | 35 |
+ 86 |
|
|
{}); |
- | 36 |
+ 87 |
|
|
|
- | 37 |
+ 88 |
|
|
// template <int T> |
- | 38 |
+ 89 |
|
|
// std::array<double, T> RK4_step( |
- | 39 |
+ 90 |
|
|
// const std::array<double, T> y_n, const double input_step_size, |
- | 40 |
+ 91 |
|
|
// std::function<std::array<double, T>(const std::array<double, T> input_y_vec, |
- | 41 |
+ 92 |
|
|
// const double input_spacecraft_mass, |
- | 42 |
+ 93 |
|
|
// const std::vector<std::array<double, 3>> |
- | 43 |
+ 94 |
|
|
// input_vec_of_force_vectors_in_ECI)> |
- | 44 |
+ 95 |
|
|
// input_derivative_function, |
- | 45 |
+ 96 |
|
|
// const double input_spacecraft_mass, |
- | 46 |
+ 97 |
|
|
// const std::vector<std::array<double, 3>> |
- | 47 |
+ 98 |
|
|
// input_vec_of_force_vectors_in_ECI_at_t = {}, |
- | 48 |
+ 99 |
|
|
// const std::vector<std::array<double, 3>> |
- | 49 |
+ 100 |
|
|
// input_vec_of_force_vectors_in_ECI_at_t_and_halfstep = {}, |
- | 50 |
+ 101 |
|
|
// const std::vector<std::array<double, 3>> |
- | 51 |
+ 102 |
|
|
// input_vec_of_force_vectors_in_ECI_at_t_and_step = {}) { |
- | 52 |
+ 103 |
|
|
// // ref: |
- | 53 |
+ 104 |
|
|
// // https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods#The_Runge%E2%80%93Kutta_method |
- | 54 |
+ 105 |
|
|
// std::array<double, T> y_nplus1 = y_n; |
- | 55 |
+ 106 |
|
|
|
- | 56 |
+ 107 |
|
|
// // first, k=1; |
- | 57 |
+ 108 |
|
|
// // going to be assuming derivative function does not have explicit time |
- | 58 |
+ 109 |
|
|
// // dependence |
- | 59 |
+ 110 |
|
|
// std::array<double, T> k_1 = input_derivative_function( |
- | 60 |
+ 111 |
|
|
// y_n, input_spacecraft_mass, input_vec_of_force_vectors_in_ECI_at_t); |
- | 61 |
+ 112 |
|
|
|
- | 62 |
+ 113 |
|
|
// // now k_2 |
- | 63 |
+ 114 |
|
|
// std::array<double, T> y_vec_for_k_2 = y_n; |
- | 64 |
+ 115 |
|
|
// for (size_t ind = 0; ind < T; ind++) { |
- | 65 |
+ 116 |
|
|
// y_vec_for_k_2.at(ind) += ((input_step_size / 2) * k_1.at(ind)); |
- | 66 |
+ 117 |
|
|
// } |
- | 67 |
+ 118 |
|
|
|
- | 68 |
+ 119 |
|
|
// std::array<double, T> k_2 = input_derivative_function( |
- | 69 |
+ 120 |
|
|
// y_vec_for_k_2, input_spacecraft_mass, |
- | 70 |
+ 121 |
|
|
// input_vec_of_force_vectors_in_ECI_at_t_and_halfstep); |
- | 71 |
+ 122 |
|
|
// // now k_3 |
- | 72 |
+ 123 |
|
|
// std::array<double, T> y_vec_for_k_3 = y_n; |
- | 73 |
+ 124 |
|
|
// for (size_t ind = 0; ind < T; ind++) { |
- | 74 |
+ 125 |
|
|
// y_vec_for_k_3.at(ind) += ((input_step_size / 2) * k_2.at(ind)); |
- | 75 |
+ 126 |
|
|
// } |
- | 76 |
+ 127 |
|
|
|
- | 77 |
+ 128 |
|
|
// std::array<double, T> k_3 = input_derivative_function( |
- | 78 |
+ 129 |
|
|
// y_vec_for_k_3, input_spacecraft_mass, |
- | 79 |
+ 130 |
|
|
// input_vec_of_force_vectors_in_ECI_at_t_and_halfstep); |
- | 80 |
+ 131 |
|
|
|
- | 81 |
+ 132 |
|
|
// // now k_4 |
- | 82 |
+ 133 |
|
|
// std::array<double, T> y_vec_for_k_4 = y_n; |
- | 83 |
+ 134 |
|
|
// for (size_t ind = 0; ind < T; ind++) { |
- | 84 |
+ 135 |
|
|
// y_vec_for_k_4.at(ind) += (input_step_size * k_3.at(ind)); |
- | 85 |
+ 136 |
|
|
// } |
- | 86 |
+ 137 |
|
|
|
- | 87 |
+ 138 |
|
|
// std::array<double, T> k_4 = input_derivative_function( |
- | 88 |
+ 139 |
|
|
// y_vec_for_k_4, input_spacecraft_mass, |
- | 89 |
+ 140 |
|
|
// input_vec_of_force_vectors_in_ECI_at_t_and_step); |
- | 90 |
+ 141 |
|
|
|
- | 91 |
+ 142 |
|
|
// for (size_t ind = 0; ind < T; ind++) { |
- | 92 |
+ 143 |
|
|
// y_nplus1.at(ind) += |
- | 93 |
+ 144 |
|
|
// ((input_step_size / 6) * |
- | 94 |
+ 145 |
|
|
// (k_1.at(ind) + 2 * k_2.at(ind) + 2 * k_3.at(ind) + k_4.at(ind))); |
- | 95 |
+ 146 |
|
|
// } |
- | 96 |
+ 147 |
|
|
|
- | 97 |
+ 148 |
|
|
// return y_nplus1; |
- | 98 |
+ 149 |
|
|
// } |
- | 99 |
+ 150 |
|
|
|
- | 100 |
+ 151 |
|
|
void sim_and_draw_orbit_gnuplot( |
- | 101 |
-
- |
- |
- std::vector<Satellite> input_satellite_vector, const double input_timestep, |
-
-
- | 102 |
-
- |
- |
- const double input_total_sim_time, const double input_epsilon, |
-
-
- | 103 |
+ 152 |
|
|
- const bool perturbation = true, const bool atmospheric_drag = false, |
+ std::vector<Satellite> input_satellite_vector, |
- | 104 |
+ 153 |
|
|
- const std::pair<double, double> drag_elements = {}, |
+ const SimParameters& input_sim_parameters, |
- | 105 |
+ 154 |
|
|
- const std::string input_terminal = "qt", //Currently, "qt" and "png" are supported |
+ const std::string output_file_name = "output" |
- | 106 |
+ 155 |
|
|
- const std::string output_file_name = "output"); |
+ ); |
- | 107 |
+ 156 |
|
|
|
- | 108 |
+ 157 |
|
|
template <int T> |
- | 109 |
+ 158 |
|
|
std::pair<std::array<double, T>, std::pair<double, double>> RK45_step( |
- | 110 |
+ 159 |
|
|
std::array<double, T> y_n, double input_step_size, |
- | 111 |
+ 160 |
|
|
std::function<std::array<double, T>( |
- | 112 |
+ 161 |
|
|
const std::array<double, T>, const double, |
- | 113 |
+ 162 |
|
|
std::vector<ThrustProfileLVLH>, double, double, double, double, bool)> |
- | 114 |
+ 163 |
|
|
input_derivative_function, |
- | 115 |
+ 164 |
|
|
const double input_spacecraft_mass, |
- | 116 |
+ 165 |
|
|
std::vector<ThrustProfileLVLH> input_list_of_thrust_profiles_LVLH, |
- | 117 |
+ 166 |
|
|
double input_t_n, double input_epsilon, double input_inclination, |
- | 118 |
+ 167 |
|
|
double input_arg_of_periapsis, double input_true_anomaly, |
- | 119 |
+ 168 |
|
|
bool perturbation) { |
- | 120 |
+ 169 |
|
|
// Version for satellite orbital motion time evolution |
- | 121 |
+ 170 |
|
|
// Implementing RK4(5) method for its adaptive step size |
- | 122 |
+ 171 |
|
|
// Refs:https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta%E2%80%93Fehlberg_method |
- | 123 |
+ 172 |
|
|
// , |
- | 124 |
+ 173 |
|
|
// https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods#The_Runge%E2%80%93Kutta_method |
- | 125 |
+ 174 |
|
|
std::array<double, 6> nodes = {0.0, 1.0 / 4, 3.0 / 8, 12.0 / 13, |
- | 126 |
+ 175 |
|
|
1.0, 1.0 / 2}; // c coefficients |
- | 127 |
+ 176 |
|
|
std::array<double, 6> CH_vec = {16.0 / 135, 0.0, 6656.0 / 12825, |
- | 128 |
+ 177 |
|
|
28561.0 / 56430, -9.0 / 50, 2.0 / 55}; |
- | 129 |
+ 178 |
|
|
std::array<double, 6> CT_vec = {-1.0 / 360, 0.0, 128.0 / 4275, |
- | 130 |
+ 179 |
|
|
2197.0 / 75240, -1.0 / 50, -2.0 / 55}; |
- | 131 |
+ 180 |
|
|
int s = 6; |
- | 132 |
+ 181 |
|
|
|
- | 133 |
+ 182 |
|
|
MatrixXd RK_matrix = MatrixXd::Zero(s, s); |
- | 134 |
+ 183 |
|
|
RK_matrix(1, 0) = 1.0 / 4; |
- | 135 |
+ 184 |
|
|
RK_matrix(2, 0) = 3.0 / 32; |
- | 136 |
+ 185 |
|
|
RK_matrix(2, 1) = 9.0 / 32; |
- | 137 |
+ 186 |
|
|
RK_matrix(3, 0) = 1932.0 / 2197; |
- | 138 |
+ 187 |
|
|
RK_matrix(3, 1) = -7200.0 / 2197; |
- | 139 |
+ 188 |
|
|
RK_matrix(3, 2) = 7296.0 / 2197; |
- | 140 |
+ 189 |
|
|
RK_matrix(4, 0) = 439.0 / 216; |
- | 141 |
+ 190 |
|
|
RK_matrix(4, 1) = -8.0; |
- | 142 |
+ 191 |
|
|
RK_matrix(4, 2) = 3680.0 / 513; |
- | 143 |
+ 192 |
|
|
RK_matrix(4, 3) = -845.0 / 4104; |
- | 144 |
+ 193 |
|
|
RK_matrix(5, 0) = -8.0 / 27; |
- | 145 |
+ 194 |
|
|
RK_matrix(5, 1) = 2.0; |
- | 146 |
+ 195 |
|
|
RK_matrix(5, 2) = -3544.0 / 2565; |
- | 147 |
+ 196 |
|
|
RK_matrix(5, 3) = 1859.0 / 4104; |
- | 148 |
+ 197 |
|
|
RK_matrix(5, 4) = -11.0 / 40; |
- | 149 |
+ 198 |
|
|
|
- | 150 |
+ 199 |
|
|
std::vector<std::array<double, T>> k_vec_vec = {}; |
- | 151 |
+ 200 |
|
|
|
- | 152 |
+ 201 |
|
|
// Need to populate k_vec (compute vector k_i for i=0...s-1) |
- | 153 |
+ 202 |
|
|
for (size_t k_ind = 0; k_ind < s; k_ind++) { |
- | 154 |
+ 203 |
|
|
double evaluation_time = input_t_n + (nodes.at(k_ind) * input_step_size); |
- | 155 |
+ 204 |
|
|
std::array<double, T> y_n_evaluated_value = y_n; |
- | 156 |
+ 205 |
|
|
std::array<double, T> k_vec_at_this_s; |
- | 157 |
+ 206 |
|
|
for (size_t s_ind = 0; s_ind < k_ind; s_ind++) { |
- | 158 |
+ 207 |
|
|
for (size_t y_val_ind = 0; y_val_ind < y_n.size(); y_val_ind++) { |
- | 159 |
+ 208 |
|
|
y_n_evaluated_value.at(y_val_ind) += RK_matrix(k_ind, s_ind) * |
- | 160 |
+ 209 |
|
|
k_vec_vec.at(s_ind).at(y_val_ind); |
- | 161 |
+ 210 |
|
|
} |
- | 162 |
+ 211 |
|
|
} |
- | 163 |
+ 212 |
|
|
std::array<double, 6> derivative_function_output = |
- | 164 |
+ 213 |
|
|
input_derivative_function(y_n_evaluated_value, input_spacecraft_mass, |
- | 165 |
+ 214 |
|
|
input_list_of_thrust_profiles_LVLH, |
- | 166 |
+ 215 |
|
|
evaluation_time, input_inclination, |
- | 167 |
+ 216 |
|
|
input_arg_of_periapsis, input_true_anomaly, |
- | 168 |
+ 217 |
|
|
perturbation); |
- | 169 |
+ 218 |
|
|
for (size_t y_val_ind = 0; y_val_ind < y_n.size(); y_val_ind++) { |
- | 170 |
+ 219 |
|
|
k_vec_at_this_s.at(y_val_ind) = |
- | 171 |
+ 220 |
|
|
input_step_size * derivative_function_output.at(y_val_ind); |
- | 172 |
+ 221 |
|
|
} |
- | 173 |
+ 222 |
|
|
k_vec_vec.push_back(k_vec_at_this_s); |
- | 174 |
+ 223 |
|
|
} |
- | 175 |
+ 224 |
|
|
|
- | 176 |
+ 225 |
|
|
std::array<double, T> y_nplusone = y_n; |
- | 177 |
+ 226 |
|
|
|
- | 178 |
+ 227 |
|
|
for (size_t s_ind = 0; s_ind < s; s_ind++) { |
- | 179 |
+ 228 |
|
|
for (size_t y_ind = 0; y_ind < y_n.size(); y_ind++) { |
- | 180 |
+ 229 |
|
|
double tmp = CH_vec.at(s_ind) * k_vec_vec.at(s_ind).at(y_ind); |
- | 181 |
+ 230 |
|
|
y_nplusone.at(y_ind) += tmp; |
- | 182 |
+ 231 |
|
|
} |
- | 183 |
+ 232 |
|
|
} |
- | 184 |
+ 233 |
|
|
|
- | 185 |
+ 234 |
|
|
std::array<double, T> TE_vec; |
- | 186 |
+ 235 |
|
|
for (size_t s_ind = 0; s_ind < s; s_ind++) { |
- | 187 |
+ 236 |
|
|
for (size_t y_ind = 0; y_ind < std::size(TE_vec); y_ind++) { |
- | 188 |
+ 237 |
|
|
TE_vec.at(y_ind) += CT_vec.at(s_ind) * k_vec_vec.at(s_ind).at(y_ind); |
- | 189 |
+ 238 |
|
|
} |
- | 190 |
+ 239 |
|
|
} |
- | 191 |
+ 240 |
|
|
|
- | 192 |
+ 241 |
|
|
for (size_t y_ind = 0; y_ind < std::size(TE_vec); y_ind++) { |
- | 193 |
+ 242 |
|
|
TE_vec.at(y_ind) = abs(TE_vec.at(y_ind)); |
- | 194 |
+ 243 |
|
|
} |
- | 195 |
+ 244 |
|
|
// I'm going to use the max TE found across the whole position+velocity vec as |
- | 196 |
+ 245 |
|
|
// the TE in the calculation of the next stepsize |
- | 197 |
+ 246 |
|
|
double max_TE = TE_vec.at( |
- | 198 |
+ 247 |
|
|
std::distance(std::begin(TE_vec), |
- | 199 |
+ 248 |
|
|
std::max_element(std::begin(TE_vec), std::end(TE_vec)))); |
- | 200 |
+ 249 |
|
|
double epsilon_ratio = input_epsilon / max_TE; |
- | 201 |
+ 250 |
|
|
|
- | 202 |
+ 251 |
|
|
double h_new = 0.9 * input_step_size * std::pow(epsilon_ratio, 1.0 / 5); |
- | 203 |
+ 252 |
|
|
|
- | 204 |
+ 253 |
|
|
if (max_TE <= input_epsilon) { |
- | 205 |
+ 254 |
|
|
std::pair<double, double> output_timestep_pair; |
- | 206 |
+ 255 |
|
|
output_timestep_pair.first = |
- | 207 |
+ 256 |
|
|
input_step_size; // First timestep size in this pair is the one |
- | 208 |
+ 257 |
|
|
// successfully used in this calculation |
- | 209 |
+ 258 |
|
|
output_timestep_pair.second = |
- | 210 |
+ 259 |
|
|
h_new; // Second timestep size in this pair is the one to be used in |
- | 211 |
+ 260 |
|
|
// the next step |
- | 212 |
+ 261 |
|
|
std::pair<std::array<double, T>, std::pair<double, double>> output_pair; |
- | 213 |
+ 262 |
|
|
output_pair.first = y_nplusone; |
- | 214 |
+ 263 |
|
|
output_pair.second = output_timestep_pair; |
- | 215 |
+ 264 |
|
|
return output_pair; |
- | 216 |
+ 265 |
|
|
} else { |
- | 217 |
+ 266 |
|
|
return RK45_step<T>( |
- | 218 |
+ 267 |
|
|
y_n, h_new, input_derivative_function, input_spacecraft_mass, |
- | 219 |
+ 268 |
|
|
input_list_of_thrust_profiles_LVLH, input_t_n, input_epsilon, |
- | 220 |
+ 269 |
|
|
input_inclination, input_arg_of_periapsis, input_true_anomaly, |
- | 221 |
+ 270 |
|
|
perturbation); |
- | 222 |
+ 271 |
|
|
} |
- | 223 |
+ 272 |
|
|
} |
- | 224 |
+ 273 |
|
|
|
- | 225 |
+ 274 |
|
|
std::array<double, 3> convert_LVLH_to_ECI_manual( |
- | 226 |
+ 275 |
|
|
const std::array<double, 3> input_LVLH_vec, |
- | 227 |
+ 276 |
|
|
const std::array<double, 3> input_position_vec, |
- | 228 |
+ 277 |
|
|
const std::array<double, 3> input_velocity_vec); |
- | 229 |
+ 278 |
|
|
|
- | 230 |
+ 279 |
|
|
std::array<double, 6> RK45_deriv_function_orbit_position_and_velocity( |
- | 231 |
+ 280 |
|
|
const std::array<double, 6> input_position_and_velocity, |
- | 232 |
+ 281 |
|
|
const double input_spacecraft_mass, |
- | 233 |
+ 282 |
|
|
const std::vector<ThrustProfileLVLH> input_list_of_thrust_profiles_LVLH, |
- | 234 |
+ 283 |
|
|
const double input_evaluation_time, const double input_inclination, |
- | 235 |
+ 284 |
|
|
const double input_arg_of_periapsis, const double input_true_anomaly, |
- | 236 |
+ 285 |
|
|
const double input_F_10, const double input_A_p, const double input_A_s, |
- | 237 |
+ 286 |
|
|
const double input_satellite_mass, const bool perturbation, |
- | 238 |
+ 287 |
|
|
const bool atmospheric_drag); |
- | 239 |
+ 288 |
|
|
|
- | 240 |
+ 289 |
|
|
std::array<double, 3> convert_cylindrical_to_cartesian( |
- | 241 |
+ 290 |
|
|
const double input_r_comp, const double input_theta_comp, |
- | 242 |
+ 291 |
|
|
const double input_z_comp, const double input_theta); |
- | 243 |
+ 292 |
|
|
void sim_and_plot_orbital_elem_gnuplot( |
- | 244 |
+ 293 |
|
|
- std::vector<Satellite> input_satellite_vector, const double input_timestep, |
+ std::vector<Satellite> input_satellite_vector, |
- | 245 |
+ 294 |
|
|
- const double input_total_sim_time, const double input_epsilon, |
+ const SimParameters& input_sim_parameters, |
- | 246 |
+ 295 |
|
|
const std::string input_orbital_element_name, |
- | 247 |
-
- |
- |
- const std::string file_name = "output", |
-
-
- | 248 |
-
- |
- |
- const bool perturbation = true, const bool atmospheric_drag = false, |
-
-
- | 249 |
+ 296 |
|
|
- const std::pair<double, double> drag_elements = {}); |
+ const std::string file_name = "output"); |
- | 250 |
+ 297 |
|
|
void sim_and_plot_attitude_evolution_gnuplot( |
- | 251 |
+ 298 |
|
|
- std::vector<Satellite> input_satellite_vector, const double input_timestep, |
+ std::vector<Satellite> input_satellite_vector, |
- | 252 |
+ 299 |
|
|
- const double input_total_sim_time, const double input_epsilon, |
+ const SimParameters& input_sim_parameters, |
- | 253 |
+ 300 |
|
|
const std::string input_plotted_val_name, |
- | 254 |
-
- |
- |
- const std::string file_name = "output", |
-
-
- | 255 |
-
- |
- |
- const bool perturbation = true, |
-
-
- | 256 |
-
- |
- |
- const bool atmospheric_drag = false, |
-
-
- | 257 |
+ 301 |
|
|
- const std::pair<double, double> drag_elements = {}); |
+ const std::string file_name = "output"); |
- | 258 |
+ 302 |
|
|
|
- | 259 |
+ 303 |
|
|
Matrix3d rollyawpitch_bodyframe_to_LVLH( |
- | 260 |
+ 304 |
|
|
const std::array<double, 3> input_bodyframe_vec, const double input_roll, |
- | 261 |
+ 305 |
|
|
const double input_pitch, const double input_yaw); |
- | 262 |
+ 306 |
|
|
std::array<double, 4> rollyawpitch_angles_to_quaternion( |
- | 263 |
+ 307 |
|
|
const double input_roll, const double input_pitch, const double input_yaw); |
- | 264 |
+ 308 |
|
|
std::array<double, 4> rollpitchyaw_angles_to_quaternion( |
- | 265 |
+ 309 |
|
|
const double input_roll, const double input_pitch, const double input_yaw); |
- | 266 |
+ 310 |
|
|
|
- | 267 |
+ 311 |
|
|
Matrix3d LVLH_to_body_transformation_matrix_from_quaternion( |
- | 268 |
+ 312 |
|
|
const std::array<double, 4> input_bodyframe_quaternion_relative_to_LVLH); |
- | 269 |
+ 313 |
|
|
Vector4d quaternion_multiplication(const Vector4d quaternion_1, |
- | 270 |
+ 314 |
|
|
const Vector4d quaternion_2); |
- | 271 |
+ 315 |
|
|
Vector4d quaternion_kinematics_equation( |
- | 272 |
+ 316 |
|
|
const Vector4d quaternion_of_bodyframe_relative_to_ref_frame, |
- | 273 |
+ 317 |
|
|
const Vector3d angular_velocity_vec_wrt_ref_frame_in_body_frame); |
- | 274 |
+ 318 |
|
|
std::array<double, 7> RK45_satellite_body_angular_deriv_function( |
- | 275 |
+ 319 |
|
|
const std::array<double, 7> combined_bodyframe_angular_array, |
- | 276 |
+ 320 |
|
|
const Matrix3d J_matrix, |
- | 277 |
+ 321 |
|
|
const std::vector<BodyframeTorqueProfile> |
- | 278 |
+ 322 |
|
|
input_bodyframe_torque_profile_list, |
- | 279 |
+ 323 |
|
|
const Vector3d input_omega_I, |
- | 280 |
+ 324 |
|
|
const double input_orbital_angular_acceleration, |
- | 281 |
+ 325 |
|
|
const Matrix3d input_LVLH_to_bodyframe_transformation_matrix, |
- | 282 |
+ 326 |
|
|
const Vector3d input_omega_LVLH_wrt_inertial_in_LVLH, |
- | 283 |
+ 327 |
|
|
const double input_evaluation_time); |
- | 284 |
+ 328 |
|
|
std::array<double, 13> |
- | 285 |
+ 329 |
|
|
RK45_combined_orbit_position_velocity_attitude_deriv_function( |
- | 286 |
+ 330 |
|
|
const std::array<double, 13> |
- | 287 |
+ 331 |
|
|
combined_position_velocity_bodyframe_angular_array, |
- | 288 |
+ 332 |
|
|
const Matrix3d J_matrix, |
- | 289 |
+ 333 |
|
|
const std::vector<BodyframeTorqueProfile> |
- | 290 |
+ 334 |
|
|
input_bodyframe_torque_profile_list, |
- | 291 |
+ 335 |
|
|
const Vector3d input_omega_I, double input_orbital_angular_acceleration, |
- | 292 |
+ 336 |
|
|
const Matrix3d input_LVLH_to_bodyframe_transformation_matrix, |
- | 293 |
+ 337 |
|
|
const Vector3d input_omega_LVLH_wrt_inertial_in_LVLH, |
- | 294 |
+ 338 |
|
|
const double input_spacecraft_mass, |
- | 295 |
+ 339 |
|
|
const std::vector<ThrustProfileLVLH> input_list_of_thrust_profiles_LVLH, |
- | 296 |
+ 340 |
|
|
const double input_evaluation_time, const double input_inclination, |
- | 297 |
+ 341 |
|
|
const double input_arg_of_periapsis, const double input_true_anomaly, |
- | 298 |
+ 342 |
|
|
const double input_F_10, const double input_A_p, const double input_A_s, |
- | 299 |
+ 343 |
|
|
const bool perturbation, const bool atmospheric_drag); |
- | 300 |
+ 344 |
|
|
|
- | 301 |
+ 345 |
|
|
template <int T> |
- | 302 |
+ 346 |
|
9157346 |
std::pair<std::array<double, T>, std::pair<double, double>> RK45_step( |
- | 303 |
+ 347 |
|
|
const std::array<double, T> y_n, const double input_step_size, |
- | 304 |
+ 348 |
|
|
std::function<std::array<double, T>( |
- | 305 |
+ 349 |
|
|
const std::array<double, T>, const Matrix3d, |
- | 306 |
+ 350 |
|
|
const std::vector<BodyframeTorqueProfile>, const Vector3d, const double, |
- | 307 |
+ 351 |
|
|
const Matrix3d, const Vector3d, const double, |
- | 308 |
+ 352 |
|
|
const std::vector<ThrustProfileLVLH>, const double, const double, |
- | 309 |
+ 353 |
|
|
const double, const double, const double, const double, const double, |
- | 310 |
+ 354 |
|
|
const bool, const bool)> |
- | 311 |
+ 355 |
|
|
input_combined_derivative_function, |
- | 312 |
+ 356 |
|
|
const Matrix3d J_matrix, |
- | 313 |
+ 357 |
|
|
const std::vector<BodyframeTorqueProfile> |
- | 314 |
+ 358 |
|
|
input_bodyframe_torque_profile_list, |
- | 315 |
+ 359 |
|
|
const Vector3d input_omega_I, double input_orbital_angular_acceleration, |
- | 316 |
+ 360 |
|
|
const Matrix3d input_LVLH_to_bodyframe_transformation_matrix, |
- | 317 |
+ 361 |
|
|
const Vector3d input_omega_LVLH_wrt_inertial_in_LVLH, |
- | 318 |
+ 362 |
|
|
const double input_spacecraft_mass, |
- | 319 |
+ 363 |
|
|
const std::vector<ThrustProfileLVLH> input_list_of_thrust_profiles_LVLH, |
- | 320 |
+ 364 |
|
|
const double input_inclination, const double input_arg_of_periapsis, |
- | 321 |
+ 365 |
|
|
const double input_true_anomaly, const double input_F_10, |
- | 322 |
+ 366 |
|
|
const double input_A_p, const double input_A_s, const bool perturbation, |
- | 323 |
+ 367 |
|
|
const double atmospheric_drag, const double input_t_n, |
- | 324 |
+ 368 |
|
|
const double input_epsilon) { |
- | 325 |
+ 369 |
|
|
// Version for combined satellite orbital motion and attitude time evolution |
- | 326 |
+ 370 |
|
|
// Implementing RK4(5) method for its adaptive step size |
- | 327 |
+ 371 |
|
|
// Refs:https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta%E2%80%93Fehlberg_method |
- | 328 |
+ 372 |
|
|
// , |
- | 329 |
+ 373 |
|
|
// https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods#The_Runge%E2%80%93Kutta_method |
- | 330 |
+ 374 |
|
|
|
- | 331 |
+ 375 |
|
9157346 |
std::array<double, 6> nodes = {0.0, 1.0 / 4, 3.0 / 8, 12.0 / 13, |
- | 332 |
+ 376 |
|
|
1.0, 1.0 / 2}; // c coefficients |
- | 333 |
+ 377 |
|
9157346 |
std::array<double, 6> CH_vec = {16.0 / 135, 0.0, 6656.0 / 12825, |
- | 334 |
+ 378 |
|
|
28561.0 / 56430, -9.0 / 50, 2.0 / 55}; |
- | 335 |
+ 379 |
|
9157346 |
std::array<double, 6> CT_vec = {-1.0 / 360, 0.0, 128.0 / 4275, |
- | 336 |
+ 380 |
|
|
2197.0 / 75240, -1.0 / 50, -2.0 / 55}; |
- | 337 |
+ 381 |
|
9157346 |
int s = 6; |
- | 338 |
+ 382 |
|
|
|
- | 339 |
+ 383 |
|
9157346 |
MatrixXd RK_matrix = MatrixXd::Zero(s, s); |
- | 340 |
+ 384 |
1/2
@@ -2472,7 +2940,7 @@ GCC Code Coverage Report
RK_matrix(1, 0) = 1.0 / 4; |
|
- | 341 |
+ 385 |
1/2
@@ -2486,7 +2954,7 @@ GCC Code Coverage Report
RK_matrix(2, 0) = 3.0 / 32; |
|
- | 342 |
+ 386 |
1/2
@@ -2500,7 +2968,7 @@ GCC Code Coverage Report
RK_matrix(2, 1) = 9.0 / 32; |
|
- | 343 |
+ 387 |
1/2
@@ -2514,7 +2982,7 @@ GCC Code Coverage Report
RK_matrix(3, 0) = 1932.0 / 2197; |
|
- | 344 |
+ 388 |
1/2
@@ -2528,7 +2996,7 @@ GCC Code Coverage Report
RK_matrix(3, 1) = -7200.0 / 2197; |
|
- | 345 |
+ 389 |
1/2
@@ -2542,7 +3010,7 @@ GCC Code Coverage Report
RK_matrix(3, 2) = 7296.0 / 2197; |
|
- | 346 |
+ 390 |
1/2
@@ -2556,7 +3024,7 @@ GCC Code Coverage Report
RK_matrix(4, 0) = 439.0 / 216; |
|
- | 347 |
+ 391 |
1/2
@@ -2570,7 +3038,7 @@ GCC Code Coverage Report
RK_matrix(4, 1) = -8.0; |
|
- | 348 |
+ 392 |
1/2
@@ -2584,7 +3052,7 @@ GCC Code Coverage Report
RK_matrix(4, 2) = 3680.0 / 513; |
|
- | 349 |
+ 393 |
1/2
@@ -2598,7 +3066,7 @@ GCC Code Coverage Report
RK_matrix(4, 3) = -845.0 / 4104; |
|
- | 350 |
+ 394 |
1/2
@@ -2612,7 +3080,7 @@ GCC Code Coverage Report
RK_matrix(5, 0) = -8.0 / 27; |
|
- | 351 |
+ 395 |
1/2
@@ -2626,7 +3094,7 @@ GCC Code Coverage Report
RK_matrix(5, 1) = 2.0; |
|
- | 352 |
+ 396 |
1/2
@@ -2640,7 +3108,7 @@ GCC Code Coverage Report
RK_matrix(5, 2) = -3544.0 / 2565; |
|
- | 353 |
+ 397 |
1/2
@@ -2654,7 +3122,7 @@ GCC Code Coverage Report
RK_matrix(5, 3) = 1859.0 / 4104; |
|
- | 354 |
+ 398 |
1/2
@@ -2668,35 +3136,35 @@ GCC Code Coverage Report
RK_matrix(5, 4) = -11.0 / 40; |
|
- | 355 |
+ 399 |
|
|
|
- | 356 |
+ 400 |
|
9157346 |
std::vector<std::array<double, T>> k_vec_vec = {}; |
- | 357 |
+ 401 |
|
|
|
- | 358 |
+ 402 |
|
|
// Need to populate k_vec (compute vector k_i for i=0...s-1) |
- | 359 |
+ 403 |
2/2
@@ -2710,7 +3178,7 @@ GCC Code Coverage Report
for (size_t k_ind = 0; k_ind < s; k_ind++) { |
|
- | 360 |
+ 404 |
1/2
@@ -2724,21 +3192,21 @@ GCC Code Coverage Report
double evaluation_time = input_t_n + (nodes.at(k_ind) * input_step_size); |
|
- | 361 |
+ 405 |
|
54944076 |
std::array<double, T> y_n_evaluated_value = y_n; |
- | 362 |
+ 406 |
|
|
std::array<double, T> k_vec_at_this_s; |
- | 363 |
+ 407 |
2/2
@@ -2752,7 +3220,7 @@ GCC Code Coverage Report
for (size_t s_ind = 0; s_ind < k_ind; s_ind++) { |
|
- | 364 |
+ 408 |
2/2
@@ -2766,7 +3234,7 @@ GCC Code Coverage Report
for (size_t y_val_ind = 0; y_val_ind < y_n.size(); y_val_ind++) { |
|
- | 365 |
+ 409 |
1/2
@@ -2780,7 +3248,7 @@ GCC Code Coverage Report
y_n_evaluated_value.at(y_val_ind) += input_step_size * |
|
- | 366 |
+ 410 |
1/2
@@ -2794,7 +3262,7 @@ GCC Code Coverage Report
RK_matrix(k_ind, s_ind) * |
|
- | 367 |
+ 411 |
2/4
@@ -2810,28 +3278,28 @@ GCC Code Coverage Report
k_vec_vec.at(s_ind).at(y_val_ind); |
|
- | 368 |
+ 412 |
|
1785682470 |
} |
- | 369 |
+ 413 |
|
137360190 |
} |
- | 370 |
+ 414 |
|
|
std::array<double, T> derivative_function_output = |
- | 371 |
+ 415 |
1/2
@@ -2845,7 +3313,7 @@ GCC Code Coverage Report
input_combined_derivative_function( |
|
- | 372 |
+ 416 |
2/4
@@ -2861,7 +3329,7 @@ GCC Code Coverage Report
y_n_evaluated_value, J_matrix, input_bodyframe_torque_profile_list, |
|
- | 373 |
+ 417 |
1/2
@@ -2875,7 +3343,7 @@ GCC Code Coverage Report
input_omega_I, input_orbital_angular_acceleration, |
|
- | 374 |
+ 418 |
1/2
@@ -2889,7 +3357,7 @@ GCC Code Coverage Report
input_LVLH_to_bodyframe_transformation_matrix, |
|
- | 375 |
+ 419 |
1/2
@@ -2903,7 +3371,7 @@ GCC Code Coverage Report
input_omega_LVLH_wrt_inertial_in_LVLH, input_spacecraft_mass, |
|
- | 376 |
+ 420 |
1/2
@@ -2917,21 +3385,21 @@ GCC Code Coverage Report
input_list_of_thrust_profiles_LVLH, evaluation_time, |
|
- | 377 |
+ 421 |
|
54944076 |
input_inclination, input_arg_of_periapsis, input_true_anomaly, |
- | 378 |
+ 422 |
|
54944076 |
input_F_10, input_A_p, input_A_s, perturbation, atmospheric_drag); |
- | 379 |
+ 423 |
2/2
@@ -2945,7 +3413,7 @@ GCC Code Coverage Report
for (size_t y_val_ind = 0; y_val_ind < y_n.size(); y_val_ind++) { |
|
- | 380 |
+ 424 |
1/2
@@ -2959,7 +3427,7 @@ GCC Code Coverage Report
k_vec_at_this_s.at(y_val_ind) = |
|
- | 381 |
+ 425 |
1/2
@@ -2973,21 +3441,21 @@ GCC Code Coverage Report
input_step_size * derivative_function_output.at(y_val_ind); |
|
- | 382 |
+ 426 |
|
714272988 |
} |
- | 383 |
+ 427 |
|
|
|
- | 384 |
+ 428 |
1/2
@@ -3001,41 +3469,41 @@ GCC Code Coverage Report
k_vec_vec.push_back(k_vec_at_this_s); |
|
- | 385 |
+ 429 |
|
54944076 |
} |
- | 386 |
+ 430 |
|
|
|
- | 387 |
+ 431 |
|
9157346 |
std::array<double, T> y_nplusone = y_n; |
- | 388 |
+ 432 |
|
|
|
- | 389 |
+ 433 |
2/2
- ✓ Branch 0 taken 54944076 times.
- ✓ Branch 1 taken 9157346 times.
+ ✓ Branch 0 taken 9157346 times.
+ ✓ Branch 1 taken 54944076 times.
|
@@ -3043,7 +3511,7 @@ GCC Code Coverage Report
for (size_t s_ind = 0; s_ind < s; s_ind++) { |
- | 390 |
+ 434 |
2/2
@@ -3057,7 +3525,7 @@ GCC Code Coverage Report
for (size_t y_ind = 0; y_ind < y_n.size(); y_ind++) { |
|
- | 391 |
+ 435 |
3/6
@@ -3075,7 +3543,7 @@ GCC Code Coverage Report
double tmp = CH_vec.at(s_ind) * k_vec_vec.at(s_ind).at(y_ind); |
|
- | 392 |
+ 436 |
1/2
@@ -3089,41 +3557,41 @@ GCC Code Coverage Report
y_nplusone.at(y_ind) += tmp; |
|
- | 393 |
+ 437 |
|
714272988 |
} |
- | 394 |
+ 438 |
|
54944076 |
} |
- | 395 |
+ 439 |
|
|
|
- | 396 |
+ 440 |
|
9157346 |
std::array<double, T> TE_vec = {0}; |
- | 397 |
+ 441 |
2/2
- ✓ Branch 0 taken 119045498 times.
- ✓ Branch 1 taken 9157346 times.
+ ✓ Branch 0 taken 9157346 times.
+ ✓ Branch 1 taken 119045498 times.
|
@@ -3131,7 +3599,7 @@ GCC Code Coverage Report
for (size_t y_ind = 0; y_ind < y_n.size(); y_ind++) { |
- | 398 |
+ 442 |
2/2
@@ -3145,7 +3613,7 @@ GCC Code Coverage Report
for (size_t s_ind = 0; s_ind < s; s_ind++) { |
|
- | 399 |
+ 443 |
4/8
@@ -3165,28 +3633,28 @@ GCC Code Coverage Report
TE_vec.at(y_ind) += CT_vec.at(s_ind) * k_vec_vec.at(s_ind).at(y_ind); |
|
- | 400 |
+ 444 |
|
714272988 |
} |
- | 401 |
+ 445 |
|
119045498 |
} |
- | 402 |
+ 446 |
|
|
|
- | 403 |
+ 447 |
2/2
@@ -3200,7 +3668,7 @@ GCC Code Coverage Report
for (size_t ind = 0; ind < TE_vec.size(); ind++) { |
|
- | 404 |
+ 448 |
2/4
@@ -3216,35 +3684,35 @@ GCC Code Coverage Report
TE_vec.at(ind) = abs(TE_vec.at(ind)); |
|
- | 405 |
+ 449 |
|
119045498 |
} |
- | 406 |
+ 450 |
|
|
|
- | 407 |
+ 451 |
|
|
// I'm going to use the max TE found across the whole position+velocity vec as |
- | 408 |
+ 452 |
|
|
// the TE in the calculation of the next stepsize |
- | 409 |
+ 453 |
1/2
@@ -3258,7 +3726,7 @@ GCC Code Coverage Report
double max_TE = TE_vec.at( |
|
- | 410 |
+ 454 |
2/4
@@ -3274,7 +3742,7 @@ GCC Code Coverage Report
std::distance(std::begin(TE_vec), |
|
- | 411 |
+ 455 |
3/6
@@ -3292,35 +3760,35 @@ GCC Code Coverage Report
std::max_element(std::begin(TE_vec), std::end(TE_vec)))); |
|
- | 412 |
+ 456 |
|
9157346 |
double epsilon_ratio = input_epsilon / max_TE; |
- | 413 |
+ 457 |
|
|
|
- | 414 |
+ 458 |
|
9157346 |
double h_new = 0.9 * input_step_size * std::pow(epsilon_ratio, 1.0 / 5); |
- | 415 |
+ 459 |
|
|
|
- | 416 |
+ 460 |
2/2
@@ -3334,97 +3802,97 @@ GCC Code Coverage Report
if (max_TE <= input_epsilon) { |
|
- | 417 |
+ 461 |
|
8948009 |
std::pair<double, double> output_timestep_pair; |
- | 418 |
+ 462 |
|
8948009 |
output_timestep_pair.first = |
- | 419 |
+ 463 |
|
8948009 |
input_step_size; // First timestep size in this pair is the one |
- | 420 |
+ 464 |
|
|
// successfully used in this calculation |
- | 421 |
+ 465 |
|
8948009 |
output_timestep_pair.second = |
- | 422 |
+ 466 |
|
8948009 |
h_new; // Second timestep size in this pair is the one to be used in |
- | 423 |
+ 467 |
|
|
// the next step |
- | 424 |
+ 468 |
|
8948009 |
std::pair<std::array<double, T>, std::pair<double, double>> output_pair; |
- | 425 |
+ 469 |
|
8948009 |
output_pair.first = y_nplusone; |
- | 426 |
+ 470 |
|
8948009 |
output_pair.second = output_timestep_pair; |
- | 427 |
+ 471 |
|
8948009 |
return output_pair; |
- | 428 |
+ 472 |
|
|
} else { |
- | 429 |
+ 473 |
1/2
- ✗ Branch 0 not taken.
- ✓ Branch 1 taken 209337 times.
+ ✓ Branch 0 taken 209337 times.
+ ✗ Branch 1 not taken.
|
@@ -3432,7 +3900,7 @@ GCC Code Coverage Report
return RK45_step<T>( |
- | 430 |
+ 474 |
2/4
@@ -3448,7 +3916,7 @@ GCC Code Coverage Report
y_n, h_new, input_combined_derivative_function, J_matrix, |
|
- | 431 |
+ 475 |
2/4
@@ -3464,14 +3932,14 @@ GCC Code Coverage Report
input_bodyframe_torque_profile_list, input_omega_I, |
|
- | 432 |
+ 476 |
|
209337 |
input_orbital_angular_acceleration, |
- | 433 |
+ 477 |
1/2
@@ -3485,7 +3953,7 @@ GCC Code Coverage Report
input_LVLH_to_bodyframe_transformation_matrix, |
|
- | 434 |
+ 478 |
1/2
@@ -3499,7 +3967,7 @@ GCC Code Coverage Report
input_omega_LVLH_wrt_inertial_in_LVLH, input_spacecraft_mass, |
|
- | 435 |
+ 479 |
1/2
@@ -3513,287 +3981,294 @@ GCC Code Coverage Report
input_list_of_thrust_profiles_LVLH, input_inclination, |
|
- | 436 |
+ 480 |
|
209337 |
input_arg_of_periapsis, input_true_anomaly, input_F_10, input_A_p, |
- | 437 |
+ 481 |
|
209337 |
input_A_s, perturbation, atmospheric_drag, input_t_n, input_epsilon); |
- | 438 |
+ 482 |
|
|
} |
- | 439 |
+ 483 |
|
9157346 |
} |
- | 440 |
+ 484 |
|
|
Vector3d calculate_omega_I( |
- | 441 |
+ 485 |
|
|
const Vector3d input_bodyframe_ang_vel_vector_wrt_lvlh, |
- | 442 |
+ 486 |
|
|
const Matrix3d input_LVLH_to_bodyframe_transformation_matrix, |
- | 443 |
+ 487 |
|
|
const double input_orbital_rate); |
- | 444 |
+ 488 |
|
|
|
- | 445 |
+ 489 |
|
|
Matrix3d construct_J_matrix(const double input_Jxx, const double input_Jyy, |
- | 446 |
+ 490 |
|
|
const double input_Jzz); |
- | 447 |
+ 491 |
|
|
|
- | 448 |
+ 492 |
|
|
std::array<double, 3> convert_quaternion_to_roll_yaw_pitch_angles( |
- | 449 |
+ 493 |
|
|
const std::array<double, 4>); |
- | 450 |
+ 494 |
|
|
|
- | 451 |
+ 495 |
|
|
std::array<double, 4> normalize_quaternion( |
- | 452 |
+ 496 |
|
|
std::array<double, 4> input_quaternion); |
- | 453 |
+ 497 |
|
|
|
- | 454 |
+ 498 |
|
|
std::array<double, 3> convert_array_from_LVLH_to_bodyframe( |
- | 455 |
+ 499 |
|
|
const std::array<double, 3> input_LVLH_frame_array, const double input_roll, |
- | 456 |
+ 500 |
|
|
const double input_yaw, const double input_pitch); |
- | 457 |
+ 501 |
|
|
|
- | 458 |
+ 502 |
|
|
|
- | 459 |
+ 503 |
|
|
Vector3d convert_lat_long_to_ECEF(const double latitude, const double longitude, const double height); |
- | 460 |
+ 504 |
|
|
Vector3d convert_ECEF_to_ECI(const Vector3d input_ECEF_position, const double input_time); |
- | 461 |
+ 505 |
|
|
|
- | 462 |
+ 506 |
|
|
void sim_and_plot_gs_connectivity_distance_gnuplot(PhasedArrayGroundStation input_ground_station, |
- | 463 |
+ 507 |
|
|
- std::vector<Satellite> input_satellite_vector, const double input_timestep, |
+ std::vector<Satellite> input_satellite_vector, |
- | 464 |
+ 508 |
|
|
- const double input_total_sim_time, const double input_epsilon, |
+ const SimParameters& input_sim_parameters, |
- | 465 |
+ 509 |
|
|
- const std::string file_name = "output", |
+ const std::string file_name = "output"); |
- | 466 |
+ 510 |
|
|
- const bool perturbation = true, const bool atmospheric_drag = false, |
+ |
- | 467 |
+ 511 |
|
|
- const std::pair<double, double> drag_elements = {}); |
+ void sim_and_plot_gs_connectivity_gnuplot(PhasedArrayGroundStation input_ground_station, |
- | 468 |
+ 512 |
|
|
- |
+ std::vector<Satellite> input_satellite_vector, |
- | 469 |
+ 513 |
|
|
- void sim_and_plot_gs_connectivity_gnuplot(PhasedArrayGroundStation input_ground_station, |
+ const SimParameters& input_sim_parameters, |
- | 470 |
+ 514 |
|
|
- std::vector<Satellite> input_satellite_vector, const double input_timestep, |
+ const std::string file_name = "output"); |
- | 471 |
+ 515 |
|
|
- const double input_total_sim_time, const double input_epsilon, |
+ |
- | 472 |
+ 516 |
|
|
- const std::string file_name = "output", |
+ int add_lowthrust_orbit_transfer(Satellite& input_satellite_object, const double final_orbit_semimajor_axis_km, |
- | 473 |
+ 517 |
|
|
- const bool perturbation = true, const bool atmospheric_drag = false, |
+ const double thrust_magnitude, const double transfer_initiation_time = 0); |
- | 474 |
+ 518 |
|
|
- const std::pair<double, double> drag_elements = {}); |
+ |
- | 475 |
+ 519 |
+
+ |
+ |
+ double calibrate_mean_val(Satellite satellite_object, const SimParameters& input_sim_parameters, const std::string input_parameter_name); |
+
+
+ | 520 |
|
|
#endif |
- | 476 |
+ 521 |
|
|
diff --git a/tests/test_coverage_summary.json b/tests/test_coverage_summary.json
index 0dbecbe..8465c80 100644
--- a/tests/test_coverage_summary.json
+++ b/tests/test_coverage_summary.json
@@ -1 +1 @@
-{"root": "..", "gcovr/summary_format_version": "0.6", "files": [{"filename": "include/PhasedArrayGroundStation.h", "line_total": 10, "line_covered": 10, "line_percent": 100.0, "function_total": 3, "function_covered": 3, "function_percent": 100.0, "branch_total": 2, "branch_covered": 1, "branch_percent": 50.0}, {"filename": "include/Satellite.h", "line_total": 175, "line_covered": 175, "line_percent": 100.0, "function_total": 18, "function_covered": 18, "function_percent": 100.0, "branch_total": 174, "branch_covered": 107, "branch_percent": 61.5}, {"filename": "include/utils.h", "line_total": 87, "line_covered": 87, "line_percent": 100.0, "function_total": 1, "function_covered": 1, "function_percent": 100.0, "branch_total": 128, "branch_covered": 74, "branch_percent": 57.8}, {"filename": "src/PhasedArrayGroundStation.cpp", "line_total": 75, "line_covered": 74, "line_percent": 98.7, "function_total": 6, "function_covered": 6, "function_percent": 100.0, "branch_total": 57, "branch_covered": 41, "branch_percent": 71.9}, {"filename": "src/Satellite.cpp", "line_total": 363, "line_covered": 358, "line_percent": 98.6, "function_total": 18, "function_covered": 18, "function_percent": 100.0, "branch_total": 94, "branch_covered": 82, "branch_percent": 87.2}, {"filename": "src/utils.cpp", "line_total": 893, "line_covered": 836, "line_percent": 93.6, "function_total": 27, "function_covered": 27, "function_percent": 100.0, "branch_total": 928, "branch_covered": 511, "branch_percent": 55.1}], "line_total": 1603, "line_covered": 1540, "line_percent": 96.1, "function_total": 73, "function_covered": 73, "function_percent": 100.0, "branch_total": 1383, "branch_covered": 816, "branch_percent": 59.0}
\ No newline at end of file
+{"root": "..", "gcovr/summary_format_version": "0.6", "files": [{"filename": "include/PhasedArrayGroundStation.h", "line_total": 10, "line_covered": 10, "line_percent": 100.0, "function_total": 3, "function_covered": 3, "function_percent": 100.0, "branch_total": 2, "branch_covered": 1, "branch_percent": 50.0}, {"filename": "include/Satellite.h", "line_total": 193, "line_covered": 179, "line_percent": 92.7, "function_total": 20, "function_covered": 19, "function_percent": 95.0, "branch_total": 176, "branch_covered": 107, "branch_percent": 60.8}, {"filename": "include/utils.h", "line_total": 129, "line_covered": 121, "line_percent": 93.8, "function_total": 3, "function_covered": 3, "function_percent": 100.0, "branch_total": 222, "branch_covered": 113, "branch_percent": 50.9}, {"filename": "src/PhasedArrayGroundStation.cpp", "line_total": 75, "line_covered": 74, "line_percent": 98.7, "function_total": 6, "function_covered": 6, "function_percent": 100.0, "branch_total": 57, "branch_covered": 41, "branch_percent": 71.9}, {"filename": "src/Satellite.cpp", "line_total": 388, "line_covered": 365, "line_percent": 94.1, "function_total": 20, "function_covered": 19, "function_percent": 95.0, "branch_total": 108, "branch_covered": 87, "branch_percent": 80.6}, {"filename": "src/utils.cpp", "line_total": 971, "line_covered": 869, "line_percent": 89.5, "function_total": 29, "function_covered": 28, "function_percent": 96.6, "branch_total": 756, "branch_covered": 435, "branch_percent": 57.5}], "line_total": 1766, "line_covered": 1618, "line_percent": 91.6, "function_total": 81, "function_covered": 78, "function_percent": 96.3, "branch_total": 1321, "branch_covered": 784, "branch_percent": 59.3}
\ No newline at end of file