diff --git a/.gitignore b/.gitignore index 02a5729..cc16704 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build/ +data/ .DS_Store .vscode/ *.png diff --git a/.vscode/settings.json b/.vscode/settings.json index 7c5556c..45f2274 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -82,6 +82,7 @@ "semaphore": "cpp", "typeindex": "cpp", "dense": "cpp", - "mprealsupport": "cpp" + "mprealsupport": "cpp", + "hash_map": "cpp" } } \ No newline at end of file diff --git a/example_project/CMakeLists.txt b/example_project/CMakeLists.txt index 506258c..74fa2f1 100644 --- a/example_project/CMakeLists.txt +++ b/example_project/CMakeLists.txt @@ -19,4 +19,4 @@ target_link_libraries(run PRIVATE nlohmann_json::nlohmann_json Eigen3::Eigen ${S set_target_properties(run PROPERTIES BUILD_RPATH "${CMAKE_INSTALL_PREFIX}/lib" INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" - ) + ) \ No newline at end of file diff --git a/example_project/sim_parameters_example.json b/example_project/sim_parameters_example.json index 38addb6..cbde9d2 100644 --- a/example_project/sim_parameters_example.json +++ b/example_project/sim_parameters_example.json @@ -1,6 +1,6 @@ { "Simulation duration": 25000, - "epsilon": 0.000000000001, + "epsilon": 0.00000000000001, "Initial timestep guess": 1, "Perturbation": true, "Drag": false diff --git a/example_project/simulation_setup.cpp b/example_project/simulation_setup.cpp index 956a55b..a06fa11 100644 --- a/example_project/simulation_setup.cpp +++ b/example_project/simulation_setup.cpp @@ -1,14 +1,15 @@ -#include - #include "PhasedArrayGroundStation.h" #include "Satellite.h" #include "utils.h" +#include + int main() { // This file demonstrates a few different ways you can run and // visualize data from satellite simulations. // First let's initialize the struct containing parameters for simulation and // plotting + SimParameters sim_parameters("../sim_parameters_example.json"); // Initialize satellite object from an input JSON file Satellite test_sat_1("../example_satellite_input_files/input.json"); @@ -22,8 +23,8 @@ int main() { t_thrust_start, t_thrust_end); std::array LVLH_thrust_vec_2 = {0.51, 20, -5}; - double t_thrust_2_start = 5500; - double t_thrust_2_end = 6500; + double t_thrust_2_start = 3800; + double t_thrust_2_end = 4500; test_sat_1.add_LVLH_thrust_profile(LVLH_thrust_vec_2, t_thrust_2_start, t_thrust_2_end); @@ -33,7 +34,6 @@ int main() { std::vector satellite_vector_1 = {test_sat_1, test_sat_2, test_sat_3}; - sim_parameters.initial_timestep_guess = 2; sim_parameters.total_sim_time = 25000; sim_parameters.epsilon = pow(10, -12); @@ -69,6 +69,21 @@ int main() { sim_and_plot_attitude_evolution_gnuplot(satellite_vector_3, sim_parameters, "Pitch", file_name); + // Equivalent workflow saving data + std::string pitch_datafile_prefix = "Sim1-"; + sim_and_write_to_file(satellite_vector_3, sim_parameters, pitch_datafile_prefix); + std::string plotted_parameter = "Pitch"; + std::string output_filename_2D = "Pitch_from_file"; + std::vector datafile_name_vector = {}; + for (Satellite sat_object : satellite_vector_3) { + std::string sat_name = sat_object.get_name(); + std::string datafile_name = pitch_datafile_prefix + sat_name; + datafile_name_vector.push_back(datafile_name); + } + plot_2D_from_datafile(datafile_name_vector, + plotted_parameter, + output_filename_2D); + // Now let's demonstrate effect of atmospheric drag approximation Satellite test_sat_8("../example_satellite_input_files/input_8.json"); Satellite test_sat_9("../example_satellite_input_files/input_9.json"); @@ -78,11 +93,11 @@ int main() { double F_10 = 100; // Solar radio ten centimeter flux double A_p = 120; // Geomagnetic A_p index - // Collect drag parameters into a tuple with F_10 first and A_p second - std::pair drag_elements = {F_10, A_p}; sim_parameters.total_sim_time = 10000; sim_parameters.epsilon = pow(10, -14); sim_parameters.drag_bool = true; + sim_parameters.F_10 = F_10; + sim_parameters.A_p = A_p; file_name = "Eccentricity Plot"; sim_and_plot_orbital_elem_gnuplot(satellite_vector_4, sim_parameters, "Eccentricity", file_name); @@ -157,13 +172,6 @@ int main() { sim_and_draw_orbit_gnuplot(orbit_transfer_demo_vec, sim_parameters); // Now let's demonstrate changing the argument of periapsis - // Calibration strategy: there are some inherent oscillations in, e.g., arg of - // periapsis, even in absence of external forces or perturbations This - // oscillation magnitude can be different in initial and final orbits, so - // current strategy is to find the mean val of these oscillations at initial - // and final orbits, use those to get an offset, which can be applied to the - // final argument of periapsis to try to make the oscillations at the final - // orbit be close to the target value Satellite arg_periapsis_change_sat( "../example_satellite_input_files/arg_of_periapsis_test_input.json"); @@ -176,8 +184,7 @@ int main() { double final_arg_of_periapsis_deg = 25; thrust_magnitude = 0.1; // N - // std::cout << "orbital period: " << - // arg_periapsis_change_sat.calculate_orbital_period() << "\n"; + arg_periapsis_change_sat.add_maneuver( "Argument of Periapsis Change", t_thrust_start, final_arg_of_periapsis_deg, thrust_magnitude); @@ -188,5 +195,28 @@ int main() { sim_parameters, "Argument of Periapsis", file_name); + // Now let's demonstrate the workflow if you choose to save simulation data to a data file then plot from the data file(s) + sim_parameters.epsilon = pow(10,-12); + sim_parameters.total_sim_time = 25000; + sim_parameters.x_increment = pow(10,7); + sim_parameters.y_increment = pow(10,7); + sim_parameters.z_increment = 5*pow(10,6); + sim_parameters.drag_bool = false; + std::string datafile_prefix = "Sim2-"; + sim_and_write_to_file(satellite_vector_1, sim_parameters, datafile_prefix); + datafile_name_vector = {}; + for (Satellite sat_object : satellite_vector_1) { + std::string sat_name = sat_object.get_name(); + std::string datafile_name = datafile_prefix + sat_name; + datafile_name_vector.push_back(datafile_name); + } + std::string output_file_name = "sample_output_3D_plot"; + std::string terminal_name = "qt"; + plot_3D_from_datafile(datafile_name_vector, + output_file_name, + terminal_name, + sim_parameters.x_increment, + sim_parameters.y_increment, + sim_parameters.z_increment); return 0; } \ No newline at end of file diff --git a/include/Satellite.h b/include/Satellite.h index edce6f3..13d754d 100644 --- a/include/Satellite.h +++ b/include/Satellite.h @@ -328,16 +328,7 @@ class Satellite { return sqrt(pow(ECI_position_.at(0), 2) + pow(ECI_position_.at(1), 2) + pow(ECI_position_.at(2), 2)); } - double get_total_energy() { - double orbital_radius = get_radius(); - double gravitational_potential_energy = - -G * mass_Earth * m_ / orbital_radius; - - double orbital_speed = get_speed(); - double kinetic_energy = (1.0 / 2.0) * m_ * (orbital_speed * orbital_speed); - - return (gravitational_potential_energy + kinetic_energy); - } + double get_total_energy(); double get_mass() { return m_; } double get_instantaneous_time() { return t_; } std::string get_name() { return name_; } diff --git a/include/utils.h b/include/utils.h index 11409f5..2d32710 100644 --- a/include/utils.h +++ b/include/utils.h @@ -522,4 +522,20 @@ int add_lowthrust_orbit_transfer(Satellite& input_satellite_object, const double final_orbit_semimajor_axis_km, const double thrust_magnitude, const double transfer_initiation_time = 0); + +int sim_and_write_to_file(std::vector input_satellite_vector, + const SimParameters& input_sim_parameters, + const std::string output_file_name_prefix, + const double size_limit = INFINITY); + +void plot_3D_from_datafile(std::vector input_datafile_name_vector, + const std::string output_file_name = "3D plot", + const std::string terminal_name = "qt", + const double x_increment = 0, + const double y_increment = 0, + const double z_increment = 0); + +void plot_2D_from_datafile(std::vector input_datafile_name_vector, + const std::string plotted_parameter, + const std::string output_file_name = "2D plot"); #endif \ No newline at end of file diff --git a/src/Satellite.cpp b/src/Satellite.cpp index 174b75e..915f138 100644 --- a/src/Satellite.cpp +++ b/src/Satellite.cpp @@ -764,4 +764,24 @@ void Satellite::add_maneuver(const std::string maneuver_type, std::pair> maneuver_info = {maneuver_type, maneuver_vals}; maneuvers_awaiting_initiation_.push_back(maneuver_info); +} + +double Satellite::get_total_energy() { + // First, gravitational potential energy + double orbital_radius = get_radius(); + double gravitational_potential_energy = + -G * mass_Earth * m_ / orbital_radius; + + // Next, translational kinetic energy + double orbital_speed = get_speed(); + double translational_kinetic_energy = (1.0 / 2.0) * m_ * (orbital_speed * orbital_speed); + + // Next, rotational kinetic energy + double rotational_kinetic_energy = 0; + std::array body_angular_velocity_vec_wrt_LVLH_in_body_frame = body_angular_velocity_vec_wrt_LVLH_in_body_frame_; + rotational_kinetic_energy += (0.5 * J_11_ * body_angular_velocity_vec_wrt_LVLH_in_body_frame.at(0)*body_angular_velocity_vec_wrt_LVLH_in_body_frame.at(0)); + rotational_kinetic_energy += (0.5 * J_22_ * body_angular_velocity_vec_wrt_LVLH_in_body_frame.at(1)*body_angular_velocity_vec_wrt_LVLH_in_body_frame.at(1)); + rotational_kinetic_energy += (0.5 * J_33_ * body_angular_velocity_vec_wrt_LVLH_in_body_frame.at(2)*body_angular_velocity_vec_wrt_LVLH_in_body_frame.at(2)); + + return (gravitational_potential_energy + translational_kinetic_energy + rotational_kinetic_energy); } \ No newline at end of file diff --git a/src/utils.cpp b/src/utils.cpp index 0590f78..5bdec1c 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -4,6 +4,9 @@ #include #include #include +#include +#include +#include #include "PhasedArrayGroundStation.h" #include "Satellite.h" @@ -385,6 +388,462 @@ std::array RK45_deriv_function_orbit_position_and_velocity( return derivative_of_input_y; } +/// @brief Runs the requested simulation and writes output data to a text file +/// @param input_satellite_vector: The vector of satellite objects to be simulated +/// @param input_sim_parameters: A SimParameters struct containing simulation parameters +/// @param output_file_name_prefix: The prefix of the text file containing simulation data. Individual satellite data files will start with this prefix, followed by the satellite name. +int sim_and_write_to_file(std::vector input_satellite_vector, + const SimParameters& input_sim_parameters, + const std::string output_file_name_prefix, + const double size_limit) { + // Estimate of bytes of output file (NOTE: size on disk may be different): 372.67*n - 189.97 with n the number of timesteps at which there exists data + // This would change if, e.g., the number of values stored at each timestep changed, or the precision at which these values are written are changed + double size_estimate_slope = 372.67; + double size_estimate_y_intercept = -189.97; + double size_estimate = size_estimate_y_intercept; // bytes (this isn't physical at n = 0, but need to account for possibility that no data is written) + // One satellite at a time + for (Satellite current_satellite : input_satellite_vector) { + std::string satellite_name = current_satellite.get_name(); + std::string file_name = "../data/" + output_file_name_prefix + satellite_name; + std::ofstream output_file(file_name.c_str()); + // Get initial values of all stored parameters + double current_satellite_time = + current_satellite.get_instantaneous_time(); + // ECI Position + std::array current_satellite_position_ECI = current_satellite.get_ECI_position(); + double current_satellite_position_ECI_x = current_satellite_position_ECI.at(0); + double current_satellite_position_ECI_y = current_satellite_position_ECI.at(1); + double current_satellite_position_ECI_z = current_satellite_position_ECI.at(2); + // ECI Velocity + std::array current_satellite_velocity_ECI = current_satellite.get_ECI_velocity(); + double current_satellite_velocity_ECI_x = current_satellite_velocity_ECI.at(0); + double current_satellite_velocity_ECI_y = current_satellite_velocity_ECI.at(1); + double current_satellite_velocity_ECI_z = current_satellite_velocity_ECI.at(2); + // Attitude-related values + double current_satellite_roll = current_satellite.get_attitude_val("Roll"); + double current_satellite_pitch = current_satellite.get_attitude_val("Pitch"); + double current_satellite_yaw = current_satellite.get_attitude_val("Yaw"); + double current_satellite_omega_x = current_satellite.get_attitude_val("omega_x"); + double current_satellite_omega_y = current_satellite.get_attitude_val("omega_y"); + double current_satellite_omega_z = current_satellite.get_attitude_val("omega_z"); + double current_satellite_q_0 = current_satellite.get_attitude_val("q_0"); + double current_satellite_q_1 = current_satellite.get_attitude_val("q_1"); + double current_satellite_q_2 = current_satellite.get_attitude_val("q_2"); + double current_satellite_q_3 = current_satellite.get_attitude_val("q_3"); + // Orbit-related parameters + double current_satellite_a = current_satellite.get_orbital_parameter("Semimajor Axis"); + double current_satellite_eccentricity = current_satellite.get_orbital_parameter("Eccentricity"); + double current_satellite_inclination = current_satellite.get_orbital_parameter("Inclination"); + double current_satellite_raan = current_satellite.get_orbital_parameter("RAAN"); + double current_satellite_arg_of_periapsis = current_satellite.get_orbital_parameter("Argument of Periapsis"); + double current_satellite_true_anomaly = current_satellite.get_orbital_parameter("True Anomaly"); + double current_satellite_orbital_rate = current_satellite.get_orbital_parameter("Orbital Rate"); + double current_satellite_orbital_ang_acc = current_satellite.get_orbital_parameter("Orbital Angular Acceleration"); + double current_satellite_total_energy = current_satellite.get_orbital_parameter("Total Energy"); + + int num_digits = 15; + + // Write initial datapoints + output_file << std::setprecision(num_digits) + << current_satellite_time << " " + << current_satellite_position_ECI_x << " " + << current_satellite_position_ECI_y << " " + << current_satellite_position_ECI_z << " " + << current_satellite_velocity_ECI_x << " " + << current_satellite_velocity_ECI_y << " " + << current_satellite_velocity_ECI_z << " " + << current_satellite_roll << " " + << current_satellite_pitch << " " + << current_satellite_yaw << " " + << current_satellite_omega_x << " " + << current_satellite_omega_y << " " + << current_satellite_omega_z << " " + << current_satellite_q_0 << " " + << current_satellite_q_1 << " " + << current_satellite_q_2 << " " + << current_satellite_q_3 << " " + << current_satellite_a << " " + << current_satellite_eccentricity << " " + << current_satellite_inclination << " " + << current_satellite_raan << " " + << current_satellite_arg_of_periapsis << " " + << current_satellite_true_anomaly << " " + << current_satellite_orbital_rate << " " + << current_satellite_orbital_ang_acc << " " + << current_satellite_total_energy << "\n"; + size_estimate += size_estimate_slope; + if (size_estimate >= size_limit) { + std::cout << "Hit estimated number of bytes above input limit, exiting early\n"; + output_file.close(); + return 2; + } + + double timestep_to_use = input_sim_parameters.initial_timestep_guess; + while (current_satellite_time < input_sim_parameters.total_sim_time) { + + std::pair drag_elements = {input_sim_parameters.F_10, + input_sim_parameters.A_p}; + std::pair new_timestep_and_error_code = + current_satellite.evolve_RK45( + input_sim_parameters.epsilon, timestep_to_use, + input_sim_parameters.perturbation_bool, + input_sim_parameters.drag_bool, drag_elements); + double new_timestep = new_timestep_and_error_code.first; + int error_code = new_timestep_and_error_code.second; + + if (error_code != 0) { + std::cout << "Error code " << error_code + << " detected, halting simulation\n"; + output_file << "Error code " << error_code + << " detected, halting simulation\n"; + output_file.close(); + return 1; + } + timestep_to_use = new_timestep; + current_satellite_time = current_satellite.get_instantaneous_time(); + // Get updated parameters + // ECI Position + current_satellite_position_ECI = current_satellite.get_ECI_position(); + current_satellite_position_ECI_x = current_satellite_position_ECI.at(0); + current_satellite_position_ECI_y = current_satellite_position_ECI.at(1); + current_satellite_position_ECI_z = current_satellite_position_ECI.at(2); + // ECI Velocity + current_satellite_velocity_ECI = current_satellite.get_ECI_velocity(); + current_satellite_velocity_ECI_x = current_satellite_velocity_ECI.at(0); + current_satellite_velocity_ECI_y = current_satellite_velocity_ECI.at(1); + current_satellite_velocity_ECI_z = current_satellite_velocity_ECI.at(2); + // Attitude-related values + current_satellite_roll = current_satellite.get_attitude_val("Roll"); + current_satellite_pitch = current_satellite.get_attitude_val("Pitch"); + current_satellite_yaw = current_satellite.get_attitude_val("Yaw"); + current_satellite_omega_x = current_satellite.get_attitude_val("omega_x"); + current_satellite_omega_y = current_satellite.get_attitude_val("omega_y"); + current_satellite_omega_z = current_satellite.get_attitude_val("omega_z"); + current_satellite_q_0 = current_satellite.get_attitude_val("q_0"); + current_satellite_q_1 = current_satellite.get_attitude_val("q_1"); + current_satellite_q_2 = current_satellite.get_attitude_val("q_2"); + current_satellite_q_3 = current_satellite.get_attitude_val("q_3"); + // Orbit-related parameters + current_satellite_a = current_satellite.get_orbital_parameter("Semimajor Axis"); + current_satellite_eccentricity = current_satellite.get_orbital_parameter("Eccentricity"); + current_satellite_inclination = current_satellite.get_orbital_parameter("Inclination"); + current_satellite_raan = current_satellite.get_orbital_parameter("RAAN"); + current_satellite_arg_of_periapsis = current_satellite.get_orbital_parameter("Argument of Periapsis"); + current_satellite_true_anomaly = current_satellite.get_orbital_parameter("True Anomaly"); + current_satellite_orbital_rate = current_satellite.get_orbital_parameter("Orbital Rate"); + current_satellite_orbital_ang_acc = current_satellite.get_orbital_parameter("Orbital Angular Acceleration"); + current_satellite_total_energy = current_satellite.get_orbital_parameter("Total Energy"); + + // Write updated parameters to file + output_file << std::setprecision(num_digits) + << current_satellite_time << " " + << current_satellite_position_ECI_x << " " + << current_satellite_position_ECI_y << " " + << current_satellite_position_ECI_z << " " + << current_satellite_velocity_ECI_x << " " + << current_satellite_velocity_ECI_y << " " + << current_satellite_velocity_ECI_z << " " + << current_satellite_roll << " " + << current_satellite_pitch << " " + << current_satellite_yaw << " " + << current_satellite_omega_x << " " + << current_satellite_omega_y << " " + << current_satellite_omega_z << " " + << current_satellite_q_0 << " " + << current_satellite_q_1 << " " + << current_satellite_q_2 << " " + << current_satellite_q_3 << " " + << current_satellite_a << " " + << current_satellite_eccentricity << " " + << current_satellite_inclination << " " + << current_satellite_raan << " " + << current_satellite_arg_of_periapsis << " " + << current_satellite_true_anomaly << " " + << current_satellite_orbital_rate << " " + << current_satellite_orbital_ang_acc << " " + << current_satellite_total_energy << "\n"; + size_estimate += size_estimate_slope; + if (size_estimate >= size_limit) { + std::cout << "Hit estimated number of bytes above input limit, exiting early\n"; + output_file.close(); + return 2; + } + } + output_file.close(); + } + return 0; +} + + +/// @brief Uses Gnuplot to plot a specified parameter from a specified simulation data file. +/// @param data_file_name: Name of the data file to use +/// @param parameter_to_plot: Parameter you would like to plot. See comments above implementation for details. + +/* +Possible values of "parameter_to_plot": +"3D Position" - makes an interactive 3D plot of the satellite's ECI position [m]. This is the only 3D plot currently supported.alignas +The following are available as 2D plots (the specified parameter will be plotted with respect to simulation time) +"X Velocity" - X component of ECI velocity [m/s] +"Y Velocity" - Y component of ECI velocity [m/s] +"Z Velocity" - Z component of ECI velocity [m/s] +"Roll" - Satellite's roll angle with respect to LVLH frame, represented in the satellite body frame [deg] +"Pitch" - Satellite's pitch angle with respect to LVLH frame, represented in the satellite body frame [deg] +"Yaw" - Satellite's yaw angle with respect to LVLH frame, represented in the satellite body frame [deg] +"omega_x" - x component of satellite's body-frame angular velocity with respect to the LVLH frame [deg/s] +"omega_y" - y component of satellite's body-frame angular velocity with respect to the LVLH frame [deg/s] +"omega_z" - z component of satellite's body-frame angular velocity with respect to the LVLH frame [deg/s] +"q_0" - First (scalar) component of quaternion representing satellite's attitude with respect to the LVLH frame +"q_1" - Second component of quaternion representing satellite's attitude with respect to the LVLH frame +"q_2" - Third component of quaternion representing satellite's attitude with respect to the LVLH frame +"q_3" - Fourth component of quaternion representing satellite's attitude with respect to the LVLH frame +"Semimajor Axis" - Semimajor axis of satellite's orbit [m] +"Eccentricity" - Eccentricity of satellite's orbit +"Inclination" - Inclination of satellite's orbit [deg] +"RAAN" - Right ascension of the ascending node of satellite's orbit [deg] + (assumed to be equivalent to the longitude of the ascending node for Earth-orbiting satellites simulated here) +"Argument of Periapsis" - Argument of periapsis of the satellite's orbit [deg] +"True Anomaly" - True anomaly of the satellite's orbit [deg] +"Orbital Rate" - Rate of change of the true anomaly +"Orbital Angular Acceleration" - Second time derivative of the true anomaly +"Total Energy" - Satellite's total energy + (here taken to be gravitational potential energy + translational kinetic energy + rotational kinetic energy) +*/ +void plot_3D_from_datafile(std::vector input_datafile_name_vector, + const std::string output_file_name, + const std::string terminal_name, + const double x_increment, + const double y_increment, + const double z_increment) { + if (input_datafile_name_vector.size() < 1) { + throw std::invalid_argument("Empty datafile name vector"); + } + // first, open "pipe" to gnuplot + std::string gnuplot_arg_string = "gnuplot"; + if (terminal_name == "qt") { + gnuplot_arg_string += " -persist"; + } + FILE* gnuplot_pipe = popen(gnuplot_arg_string.c_str(), "w"); + + // if it exists + if (gnuplot_pipe) { + fprintf(gnuplot_pipe, "set terminal '%s' size 900,700 font ',14'\n", + terminal_name.c_str()); + if (terminal_name == "png") { + fprintf(gnuplot_pipe, "set output '../%s.png'\n", + output_file_name.c_str()); + } + // formatting + fprintf(gnuplot_pipe, "set xlabel 'x [m]' offset 0,-2\n"); + fprintf(gnuplot_pipe, "set ylabel 'y [m]' offset -2,0\n"); + fprintf(gnuplot_pipe, "set zlabel 'z [m]'\n"); + // fprintf(gnuplot_pipe,"set view 70,1,1,1\n"); + fprintf(gnuplot_pipe, "set view equal xyz\n"); + if (x_increment != 0) { + fprintf(gnuplot_pipe, "set xtics %e offset 0,-1.5\n", + x_increment); + } else { + fprintf(gnuplot_pipe, "set xtics offset 0,-1.5\n"); + } + if (y_increment != 0) { + fprintf(gnuplot_pipe, "set ytics %e offset -1.5,0\n", + y_increment); + } else { + fprintf(gnuplot_pipe, "set ytics offset -1.5,0\n"); + } + if (z_increment != 0) { + fprintf(gnuplot_pipe, "set ztics %e\n", z_increment); + } + fprintf(gnuplot_pipe, "unset colorbox\n"); + fprintf(gnuplot_pipe, "set style fill transparent solid 1.0\n"); + + fprintf(gnuplot_pipe, "set key offset 0,-10\n"); + fprintf(gnuplot_pipe, "set hidden3d front\n"); + + // plotting + // first let's set the stage for plotting the Earth + fprintf(gnuplot_pipe, "R_Earth=%.17g\n", radius_Earth); + fprintf(gnuplot_pipe, "set isosamples 50,50\n"); + fprintf(gnuplot_pipe, "set parametric\n"); + fprintf(gnuplot_pipe, "set urange [-pi/2:pi/2]\n"); + fprintf(gnuplot_pipe, "set vrange [0:2*pi]\n"); + + // first satellite + std::string current_file_name = input_datafile_name_vector.at(0); + if (input_datafile_name_vector.size() == 1) { + fprintf(gnuplot_pipe, "splot '../data/%s' using 2:3:4 with lines lw 1 title '%s' \\\n", + current_file_name.c_str(), + current_file_name.c_str()); + } + + else { + fprintf(gnuplot_pipe, "splot '../data/%s' using 2:3:4 with lines lw 1 title '%s'\\\n", + current_file_name.c_str(), + current_file_name.c_str()); + } + + for (size_t datafile_index = 1; + datafile_index < input_datafile_name_vector.size(); datafile_index++) { + current_file_name = input_datafile_name_vector.at(datafile_index); + if (datafile_index < input_datafile_name_vector.size() - 1) { + fprintf(gnuplot_pipe, ",'../data/%s' using 2:3:4 with lines lw 1 title '%s' \\\n", + current_file_name.c_str(), + current_file_name.c_str()); + } + else { + fprintf(gnuplot_pipe, ",'../data/%s' using 2:3:4 with lines lw 1 title '%s' \\\n", + current_file_name.c_str(), + current_file_name.c_str()); + } + } + fprintf(gnuplot_pipe, + ",R_Earth*cos(u)*cos(v),R_Earth*cos(u)*sin(v),R_Earth*sin(u) " + "notitle with pm3d fillcolor rgbcolor 'navy'\n"); + + if (terminal_name == "qt") { + fprintf(gnuplot_pipe, "pause mouse keypress\n"); + } + fprintf(gnuplot_pipe, "exit \n"); + pclose(gnuplot_pipe); + std::cout << "Done\n"; + + } else { + std::cout << "gnuplot not found"; + } + + return; +} + + + +// Now the 2D version for plotting parameters over time +void plot_2D_from_datafile(std::vector input_datafile_name_vector, + const std::string plotted_parameter, + const std::string output_file_name) { + if (input_datafile_name_vector.size() < 1) { + throw std::invalid_argument("Empty datafile name vector"); + } + + std::unordered_map name_to_units_map; + name_to_units_map["X Velocity"] = "[m/s]"; + name_to_units_map["Y Velocity"] = "[m/s]"; + name_to_units_map["Z Velocity"] = "[m/s]"; + name_to_units_map["Semimajor Axis"] = "[m]"; + name_to_units_map["Eccentricity"] = ""; + name_to_units_map["Inclination"] = "[deg]"; + name_to_units_map["Argument of Periapsis"] = "[deg]"; + name_to_units_map["RAAN"] = "[deg]"; + name_to_units_map["True Anomaly"] = "[deg]"; + name_to_units_map["Roll"] = "[deg]"; + name_to_units_map["Pitch"] = "[deg]"; + name_to_units_map["Yaw"] = "[deg]"; + name_to_units_map["omega_x"] = "[deg/s]"; + name_to_units_map["omega_y"] = "[deg/s]"; + name_to_units_map["omega_z"] = "[deg/s]"; + name_to_units_map["q_0"] = ""; + name_to_units_map["q_1"] = ""; + name_to_units_map["q_2"] = ""; + name_to_units_map["q_3"] = ""; + name_to_units_map["Total Energy"] = "[J]"; + name_to_units_map["Orbital Rate"] = "[rad/s]"; + name_to_units_map["Orbital Angular Acceleration"] = "[rad/s^2]"; + + std::unordered_map name_to_col_map; + name_to_col_map["X Velocity"] = 5; + name_to_col_map["Y Velocity"] = 6; + name_to_col_map["Z Velocity"] = 7; + name_to_col_map["Roll"] = 8; + name_to_col_map["Pitch"] = 9; + name_to_col_map["Yaw"] = 10; + name_to_col_map["omega_x"] = 11; + name_to_col_map["omega_y"] = 12; + name_to_col_map["omega_z"] = 13; + name_to_col_map["q_0"] = 14; + name_to_col_map["q_1"] = 15; + name_to_col_map["q_2"] = 16; + name_to_col_map["q_3"] = 17; + name_to_col_map["Semimajor Axis"] = 18; + name_to_col_map["Eccentricity"] = 19; + name_to_col_map["Inclination"] = 20; + name_to_col_map["RAAN"] = 21; + name_to_col_map["Argument of Periapsis"] = 22; + name_to_col_map["True Anomaly"] = 23; + name_to_col_map["Orbital Rate"] = 24; + name_to_col_map["Orbital Angular Acceleration"] = 25; + name_to_col_map["Total Energy"] = 26; + + // first, open "pipe" to gnuplot + FILE* gnuplot_pipe = popen("gnuplot", "w"); + // if it exists + if (gnuplot_pipe) { + fprintf(gnuplot_pipe, + "set terminal png size 800,500 font ',14' linewidth 2\n"); + // formatting + fprintf(gnuplot_pipe, "set output '../%s.png'\n", output_file_name.c_str()); + fprintf(gnuplot_pipe, "set offsets graph 0, 0, 0.05, 0.05\n"); + fprintf(gnuplot_pipe, "set xlabel 'Time [s]'\n"); + if (name_to_units_map.count(plotted_parameter) == 0) { + throw std::invalid_argument("Unrecognized parameter to plot"); + } + std::string plotted_element_units = name_to_units_map[plotted_parameter]; + int plotted_element_column = name_to_col_map[plotted_parameter]; + fprintf(gnuplot_pipe, "set ylabel '%s %s'\n", + plotted_parameter.c_str(), + plotted_element_units.c_str()); + fprintf(gnuplot_pipe, "set key right bottom\n"); + + // plotting + + // first satellite + std::string current_datafile_name = input_datafile_name_vector.at(0); + if (input_datafile_name_vector.size() == 1) { + fprintf(gnuplot_pipe, + "plot '../data/%s' using 1:%d with lines lw 1 title '%s' \n", + current_datafile_name.c_str(), + plotted_element_column, + current_datafile_name.c_str()); + } + + else { + fprintf(gnuplot_pipe, + "plot '../data/%s' using 1:%d with lines lw 1 title '%s'\\\n", + current_datafile_name.c_str(), + plotted_element_column, + current_datafile_name.c_str()); + + } + + for (size_t datafile_index = 1; + datafile_index < input_datafile_name_vector.size(); datafile_index++) { + current_datafile_name = input_datafile_name_vector.at(datafile_index); + if (datafile_index < input_datafile_name_vector.size() - 1) { + fprintf(gnuplot_pipe, + ",'../data/%s' using 1:%d with lines lw 1 title '%s'\\\n", + current_datafile_name.c_str(), + plotted_element_column, + current_datafile_name.c_str()); + } + + else { + fprintf(gnuplot_pipe, + ",'../data/%s' using 1:%d with lines lw 1 title '%s'\n", + current_datafile_name.c_str(), + plotted_element_column, + current_datafile_name.c_str()); + } + } + + fprintf(gnuplot_pipe, "exit \n"); + pclose(gnuplot_pipe); + std::cout << "Done\n"; + + } else { + std::cout << "gnuplot not found"; + } + + return; +} + + // Objective: simulate the input satellites over the specified total sim time, // and visualize the resulting orbits in an interactive 3D plot using gnuplot void sim_and_draw_orbit_gnuplot(std::vector input_satellite_vector, @@ -581,6 +1040,7 @@ void sim_and_plot_orbital_elem_gnuplot( "set terminal png size 800,500 font ',14' linewidth 2\n"); // formatting fprintf(gnuplot_pipe, "set output '../%s.png'\n", file_name.c_str()); + fprintf(gnuplot_pipe, "set offsets graph 0, 0, 0.05, 0.05\n"); fprintf(gnuplot_pipe, "set xlabel 'Time [s]'\n"); if (input_orbital_element_name == "Semimajor Axis") { fprintf(gnuplot_pipe, "set ylabel '%s [m]'\n", @@ -707,7 +1167,6 @@ void sim_and_plot_orbital_elem_gnuplot( } fprintf(gnuplot_pipe, "e\n"); } - fprintf(gnuplot_pipe, "pause mouse keypress\n"); fprintf(gnuplot_pipe, "exit \n"); pclose(gnuplot_pipe); @@ -763,6 +1222,7 @@ void sim_and_plot_attitude_evolution_gnuplot( "set terminal png size 800,500 font ',14' linewidth 2\n"); // formatting fprintf(gnuplot_pipe, "set output '../%s.png'\n", file_name.c_str()); + fprintf(gnuplot_pipe, "set offsets graph 0, 0, 0.05, 0.05\n"); fprintf(gnuplot_pipe, "set xlabel 'Time [s]'\n"); if ((input_plotted_val_name == "omega_x") || (input_plotted_val_name == "omega_y") || @@ -886,7 +1346,6 @@ void sim_and_plot_attitude_evolution_gnuplot( } fprintf(gnuplot_pipe, "e\n"); } - fprintf(gnuplot_pipe, "pause mouse keypress\n"); fprintf(gnuplot_pipe, "exit \n"); pclose(gnuplot_pipe); diff --git a/test_coverage.sh b/test_coverage.sh index 9a6d1bc..5b692e1 100755 --- a/test_coverage.sh +++ b/test_coverage.sh @@ -1,3 +1,4 @@ +mkdir -p data rm -rf build mkdir build cd build/ @@ -8,4 +9,5 @@ cmake --build . ./gs_tests gcovr -r .. --filter ../src/ --filter ../include/ --json-summary ../tests/test_coverage_summary.json --html-details ../tests/test_coverage_detailed.html cd .. -rm test_plot.png \ No newline at end of file +rm test_plot.png +rm -rf data \ No newline at end of file diff --git a/tests/test_coverage_detailed.PhasedArrayGroundStation.cpp.b1467fc67cdaa758f7764df5452c5918.html b/tests/test_coverage_detailed.PhasedArrayGroundStation.cpp.b1467fc67cdaa758f7764df5452c5918.html index 3460536..9a5ee96 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-05-11 21:11:47 + 2025-05-27 18:19:02 diff --git a/tests/test_coverage_detailed.PhasedArrayGroundStation.h.5b54056581927049d160ff3354b9e6f1.html b/tests/test_coverage_detailed.PhasedArrayGroundStation.h.5b54056581927049d160ff3354b9e6f1.html index c2d5950..3d55025 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-05-11 21:11:47 + 2025-05-27 18:19:02 diff --git a/tests/test_coverage_detailed.Satellite.cpp.bef08eb3aaec087d7cd23d21b2ecdb00.html b/tests/test_coverage_detailed.Satellite.cpp.bef08eb3aaec087d7cd23d21b2ecdb00.html index ec29dd8..0e361dc 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-05-11 21:11:47 + 2025-05-27 18:19:02 @@ -40,15 +40,15 @@

GCC Code Coverage Report

Lines: - 406 - 425 - 95.5% + 418 + 437 + 95.7% Functions: - 21 22 - 95.5% + 23 + 95.7% Branches: @@ -73,25 +73,26 @@

GCC Code Coverage Report

Satellite::add_LVLH_thrust_profile(double, double, double) (line 289)not called0.0% Satellite::add_LVLH_thrust_profile(std::__1::array<double, 3ul>, double, double) (line 249)called 10 times100.0% Satellite::add_LVLH_thrust_profile(std::__1::array<double, 3ul>, double, double, double) (line 264)called 3495723 times100.0% - Satellite::add_arg_of_periapsis_change_thrust() (line 710)called 12466918 times100.0% + Satellite::add_arg_of_periapsis_change_thrust() (line 710)called 12533871 times100.0% Satellite::add_bodyframe_torque_profile(std::__1::array<double, 3ul>, double, double) (line 581)called 10 times100.0% Satellite::add_bodyframe_torque_profile(std::__1::array<double, 3ul>, double, double, double) (line 594)called 10 times85.0% Satellite::add_maneuver(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, double, double, double) (line 758)called 2 times50.0% - Satellite::calculate_instantaneous_orbit_angular_acceleration() (line 635)called 12466975 times100.0% - Satellite::calculate_instantaneous_orbit_rate() (line 615)called 12466975 times100.0% - Satellite::calculate_orbital_period() (line 18)called 58 times100.0% - Satellite::calculate_perifocal_position() (line 25)called 57 times100.0% - Satellite::calculate_perifocal_velocity() (line 44)called 57 times100.0% - Satellite::check_for_maneuvers_to_initialize() (line 734)called 12466918 times87.0% - Satellite::convert_ECI_to_perifocal(std::__1::array<double, 3ul>) (line 112)called 74801508 times100.0% - Satellite::convert_perifocal_to_ECI(std::__1::array<double, 3ul>) (line 62)called 114 times100.0% - Satellite::evolve_RK45(double, double, bool, bool, std::__1::pair<double, double>) (line 406)called 12466918 times84.0% - Satellite::get_attitude_val(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 672)called 96215 times92.0% + Satellite::calculate_instantaneous_orbit_angular_acceleration() (line 635)called 12533943 times100.0% + Satellite::calculate_instantaneous_orbit_rate() (line 615)called 12533943 times100.0% + Satellite::calculate_orbital_period() (line 18)called 73 times100.0% + Satellite::calculate_perifocal_position() (line 25)called 72 times100.0% + Satellite::calculate_perifocal_velocity() (line 44)called 72 times100.0% + Satellite::check_for_maneuvers_to_initialize() (line 734)called 12533871 times87.0% + Satellite::convert_ECI_to_perifocal(std::__1::array<double, 3ul>) (line 112)called 75203226 times100.0% + Satellite::convert_perifocal_to_ECI(std::__1::array<double, 3ul>) (line 62)called 144 times100.0% + Satellite::evolve_RK45(double, double, bool, bool, std::__1::pair<double, double>) (line 406)called 12533871 times84.0% + Satellite::get_attitude_val(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 672)called 765875 times92.0% Satellite::get_orbital_elements() (line 395)called 9 times100.0% - Satellite::get_orbital_parameter(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 555)called 95672 times91.0% - Satellite::initialize_and_normalize_body_quaternion(double, double, double) (line 661)called 59 times100.0% - Satellite::initialize_body_angular_velocity_vec_wrt_LVLH_in_body_frame() (line 701)called 57 times100.0% - Satellite::update_orbital_elements_from_position_and_velocity() (line 298)called 12466920 times81.0% + Satellite::get_orbital_parameter(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 555)called 698366 times91.0% + Satellite::get_total_energy() (line 769)called 76318 times100.0% + Satellite::initialize_and_normalize_body_quaternion(double, double, double) (line 661)called 74 times100.0% + Satellite::initialize_body_angular_velocity_vec_wrt_LVLH_in_body_frame() (line 701)called 72 times100.0% + Satellite::update_orbital_elements_from_position_and_velocity() (line 298)called 12533873 times81.0% @@ -228,7 +229,7 @@

GCC Code Coverage Report

18 - 58 + 73 double Satellite::calculate_orbital_period() { @@ -242,14 +243,14 @@

GCC Code Coverage Report

20 - 58 + 73 double T = 2 * M_PI * sqrt(pow(a_, 3) / (G * mass_Earth)); 21 - 58 + 73 return T; @@ -277,7 +278,7 @@

GCC Code Coverage Report

25 - 57 + 72 std::array<double, 3> Satellite::calculate_perifocal_position() { @@ -298,14 +299,14 @@

GCC Code Coverage Report

28 - 57 + 72 double p = 29 - 57 + 72 a_ * (1 - eccentricity_) * (1 + eccentricity_); // rearranging eq. 1-47 @@ -319,7 +320,7 @@

GCC Code Coverage Report

31 - 57 + 72 double r = p / (1 + eccentricity_ * cos(true_anomaly_)); @@ -333,14 +334,14 @@

GCC Code Coverage Report

33 - 57 + 72 double r_perifocal_P = r * cos(true_anomaly_); 34 - 57 + 72 double r_perifocal_Q = r * sin(true_anomaly_); @@ -354,21 +355,21 @@

GCC Code Coverage Report

36 - 57 + 72 calculated_perifocal_position.at(0) = r_perifocal_P; 37 - 57 + 72 calculated_perifocal_position.at(1) = r_perifocal_Q; 38 - 57 + 72 calculated_perifocal_position.at(2) = 0; // W component is 0 @@ -382,7 +383,7 @@

GCC Code Coverage Report

40 - 57 + 72 return calculated_perifocal_position; @@ -410,7 +411,7 @@

GCC Code Coverage Report

44 - 57 + 72 std::array<double, 3> Satellite::calculate_perifocal_velocity() { @@ -431,42 +432,42 @@

GCC Code Coverage Report

47 - 57 + 72 double p = 48 - 57 + 72 a_ * (1 - eccentricity_) * (1 + eccentricity_); // rearranging eq. 1-47 49 - 57 + 72 const double mu_Earth = G * mass_Earth; 50 - 57 + 72 double v_perifocal_P = sqrt(mu_Earth / p) * (-sin(true_anomaly_)); 51 - 57 + 72 double v_perifocal_Q = 52 - 57 + 72 sqrt(mu_Earth / p) * (eccentricity_ + cos(true_anomaly_)); @@ -480,21 +481,21 @@

GCC Code Coverage Report

54 - 57 + 72 calculated_perifocal_velocity.at(0) = v_perifocal_P; 55 - 57 + 72 calculated_perifocal_velocity.at(1) = v_perifocal_Q; 56 - 57 + 72 calculated_perifocal_velocity.at(2) = 0; // 0 component in the W direction @@ -508,7 +509,7 @@

GCC Code Coverage Report

58 - 57 + 72 return calculated_perifocal_velocity; @@ -536,7 +537,7 @@

GCC Code Coverage Report

62 - 114 + 144 std::array<double, 3> Satellite::convert_perifocal_to_ECI( @@ -571,7 +572,7 @@

GCC Code Coverage Report

67 - 114 + 144 Matrix3d R_tilde_matrix; @@ -585,21 +586,21 @@

GCC Code Coverage Report

69 - 114 + 144 R_tilde_matrix(0, 0) = 70 - 228 + 288 cos(raan_) * cos(arg_of_periapsis_) - 71 - 114 + 144 sin(raan_) * sin(arg_of_periapsis_) * cos(inclination_); @@ -613,21 +614,21 @@

GCC Code Coverage Report

73 - 114 + 144 R_tilde_matrix(0, 1) = 74 - 228 + 288 -cos(raan_) * sin(arg_of_periapsis_) - 75 - 114 + 144 sin(raan_) * cos(arg_of_periapsis_) * cos(inclination_); @@ -641,7 +642,7 @@

GCC Code Coverage Report

77 - 114 + 144 R_tilde_matrix(0, 2) = sin(raan_) * sin(inclination_); @@ -655,21 +656,21 @@

GCC Code Coverage Report

79 - 114 + 144 R_tilde_matrix(1, 0) = 80 - 228 + 288 sin(raan_) * cos(arg_of_periapsis_) + 81 - 114 + 144 cos(raan_) * sin(arg_of_periapsis_) * cos(inclination_); @@ -683,21 +684,21 @@

GCC Code Coverage Report

83 - 114 + 144 R_tilde_matrix(1, 1) = 84 - 228 + 288 -sin(raan_) * sin(arg_of_periapsis_) + 85 - 114 + 144 cos(raan_) * cos(arg_of_periapsis_) * cos(inclination_); @@ -711,7 +712,7 @@

GCC Code Coverage Report

87 - 114 + 144 R_tilde_matrix(1, 2) = -cos(raan_) * sin(inclination_); @@ -725,7 +726,7 @@

GCC Code Coverage Report

89 - 114 + 144 R_tilde_matrix(2, 0) = sin(arg_of_periapsis_) * sin(inclination_); @@ -739,7 +740,7 @@

GCC Code Coverage Report

91 - 114 + 144 R_tilde_matrix(2, 1) = cos(arg_of_periapsis_) * sin(inclination_); @@ -753,7 +754,7 @@

GCC Code Coverage Report

93 - 114 + 144 R_tilde_matrix(2, 2) = cos(inclination_); @@ -781,14 +782,14 @@

GCC Code Coverage Report

97 - 114 + 144 Vector3d vector_ijk(0, 0, 0); 98 - 114 + 144 Vector3d vector_pqw(0, 0, 0); @@ -802,21 +803,21 @@

GCC Code Coverage Report

100 - 114 + 144 vector_pqw(0) = input_perifocal_vec.at(0); 101 - 114 + 144 vector_pqw(1) = input_perifocal_vec.at(1); 102 - 114 + 144 vector_pqw(2) = input_perifocal_vec.at(2); @@ -830,21 +831,21 @@

GCC Code Coverage Report

104 - 114 + 144 vector_ijk = R_tilde_matrix * vector_pqw; 105 - 228 + 288 std::array<double, 3> output_vector_ijk = {vector_ijk(0), vector_ijk(1), 106 - 114 + 144 vector_ijk(2)}; @@ -858,7 +859,7 @@

GCC Code Coverage Report

108 - 114 + 144 return output_vector_ijk; @@ -886,7 +887,7 @@

GCC Code Coverage Report

112 - 74801508 + 75203226 std::array<double, 3> Satellite::convert_ECI_to_perifocal( @@ -921,7 +922,7 @@

GCC Code Coverage Report

117 - 74801508 + 75203226 Matrix3d R_tilde_matrix; @@ -935,21 +936,21 @@

GCC Code Coverage Report

119 - 74801508 + 75203226 R_tilde_matrix(0, 0) = 120 - 149603016 + 150406452 cos(raan_) * cos(arg_of_periapsis_) - 121 - 74801508 + 75203226 sin(raan_) * sin(arg_of_periapsis_) * cos(inclination_); @@ -963,21 +964,21 @@

GCC Code Coverage Report

123 - 74801508 + 75203226 R_tilde_matrix(0, 1) = 124 - 149603016 + 150406452 -cos(raan_) * sin(arg_of_periapsis_) - 125 - 74801508 + 75203226 sin(raan_) * cos(arg_of_periapsis_) * cos(inclination_); @@ -991,7 +992,7 @@

GCC Code Coverage Report

127 - 74801508 + 75203226 R_tilde_matrix(0, 2) = sin(raan_) * sin(inclination_); @@ -1005,21 +1006,21 @@

GCC Code Coverage Report

129 - 74801508 + 75203226 R_tilde_matrix(1, 0) = 130 - 149603016 + 150406452 sin(raan_) * cos(arg_of_periapsis_) + 131 - 74801508 + 75203226 cos(raan_) * sin(arg_of_periapsis_) * cos(inclination_); @@ -1033,21 +1034,21 @@

GCC Code Coverage Report

133 - 74801508 + 75203226 R_tilde_matrix(1, 1) = 134 - 149603016 + 150406452 -sin(raan_) * sin(arg_of_periapsis_) + 135 - 74801508 + 75203226 cos(raan_) * cos(arg_of_periapsis_) * cos(inclination_); @@ -1061,7 +1062,7 @@

GCC Code Coverage Report

137 - 74801508 + 75203226 R_tilde_matrix(1, 2) = -cos(raan_) * sin(inclination_); @@ -1075,7 +1076,7 @@

GCC Code Coverage Report

139 - 74801508 + 75203226 R_tilde_matrix(2, 0) = sin(arg_of_periapsis_) * sin(inclination_); @@ -1089,7 +1090,7 @@

GCC Code Coverage Report

141 - 74801508 + 75203226 R_tilde_matrix(2, 1) = cos(arg_of_periapsis_) * sin(inclination_); @@ -1103,7 +1104,7 @@

GCC Code Coverage Report

143 - 74801508 + 75203226 R_tilde_matrix(2, 2) = cos(inclination_); @@ -1131,35 +1132,35 @@

GCC Code Coverage Report

147 - 74801508 + 75203226 Vector3d vector_ijk(0, 0, 0); 148 - 74801508 + 75203226 Vector3d vector_pqw(0, 0, 0); 149 - 74801508 + 75203226 vector_ijk(0) = input_ECI_vec.at(0); 150 - 74801508 + 75203226 vector_ijk(1) = input_ECI_vec.at(1); 151 - 74801508 + 75203226 vector_ijk(2) = input_ECI_vec.at(2); @@ -1173,21 +1174,21 @@

GCC Code Coverage Report

153 - 74801508 + 75203226 vector_pqw = (R_tilde_matrix.inverse()) * vector_ijk; 154 - 149603016 + 150406452 std::array<double, 3> output_vector_pqw = {vector_pqw(0), vector_pqw(1), 155 - 74801508 + 75203226 vector_pqw(2)}; @@ -1201,7 +1202,7 @@

GCC Code Coverage Report

157 - 74801508 + 75203226 return output_vector_pqw; @@ -2209,7 +2210,7 @@

GCC Code Coverage Report

298 - 12466920 + 12533873 int Satellite::update_orbital_elements_from_position_and_velocity() { @@ -2244,56 +2245,56 @@

GCC Code Coverage Report

303 - 12466920 + 12533873 int error_code = 0; // 0 represents nominal operation 304 - 12466920 + 12533873 double mu_Earth = G * mass_Earth; 305 - 24933840 + 25067746 Vector3d position_vector = {ECI_position_.at(0), ECI_position_.at(1), 306 - 12466920 + 12533873 ECI_position_.at(2)}; 307 - 24933840 + 25067746 Vector3d velocity_vector = {ECI_velocity_.at(0), ECI_velocity_.at(1), 308 - 12466920 + 12533873 ECI_velocity_.at(2)}; 309 - 12466920 + 12533873 Vector3d h_vector = position_vector.cross(velocity_vector); 310 - 12466920 + 12533873 double h = h_vector.norm(); @@ -2307,14 +2308,14 @@

GCC Code Coverage Report

312 - 12466920 + 12533873 Vector3d n_vector = {-h_vector(1), h_vector(0), 0}; 313 - 12466920 + 12533873 double n = n_vector.norm(); @@ -2328,14 +2329,14 @@

GCC Code Coverage Report

315 - 12466920 + 12533873 double v_magnitude = get_speed(); 316 - 12466920 + 12533873 double r_magnitude = get_radius(); @@ -2356,28 +2357,28 @@

GCC Code Coverage Report

319 - 37400760 + 37601619 (1.0 / mu_Earth) * 320 - 24933840 + 25067746 (v_magnitude * v_magnitude - (mu_Earth / r_magnitude)) * position_vector; 321 - 37400760 + 37601619 Vector3d e_vec_component_2 = (1.0 / mu_Earth) * 322 - 24933840 + 25067746 (position_vector.dot(velocity_vector)) * @@ -2391,14 +2392,14 @@

GCC Code Coverage Report

324 - 12466920 + 12533873 Vector3d e_vec = e_vec_component_1 - e_vec_component_2; 325 - 12466920 + 12533873 double calculated_eccentricity = e_vec.norm(); @@ -2412,7 +2413,7 @@

GCC Code Coverage Report

327 - 12466920 + 12533873 double calculated_p = h * h / mu_Earth; @@ -2426,7 +2427,7 @@

GCC Code Coverage Report

329 - 12466920 + 12533873 double calculated_i = acos(h_vector(2) / h); @@ -2440,7 +2441,7 @@

GCC Code Coverage Report

331 - 12466920 + 12533873 double calculated_RAAN = acos(n_vector(0) / n); @@ -2449,12 +2450,12 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 8646325 times.
+
✓ Branch 0 taken 8713278 times.
✓ Branch 1 taken 3820595 times.
- 12466920 + 12533873 if (n_vector(1) < 0) { @@ -2505,26 +2506,26 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 12466916 times.
+
✓ Branch 0 taken 12533869 times.
✓ Branch 1 taken 4 times.
- 12466920 + 12533873 if (calculated_eccentricity > pow(10, -15)) { 340 - 12466916 + 12533869 calculated_arg_of_periapsis = 341 - 12466916 + 12533869 acos(n_vector.dot(e_vec) / (n * calculated_eccentricity)); @@ -2533,40 +2534,40 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 12466768 times.
-
✓ Branch 1 taken 148 times.
+
✓ Branch 0 taken 12512820 times.
+
✓ Branch 1 taken 21049 times.
- 12466916 + 12533869 if (e_vec(2) < 0) { 343 - 148 + 21049 calculated_arg_of_periapsis = 2 * M_PI - calculated_arg_of_periapsis; 344 - 148 + 21049 } 345 - 24933832 + 25067738 calculated_true_anomaly = acos(e_vec.dot(position_vector) / 346 - 12466916 + 12533869 (calculated_eccentricity * r_magnitude)); @@ -2575,12 +2576,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 12466916 times.
+
✓ Branch 0 taken 12533869 times.
✗ Branch 1 not taken.
- 12466916 + 12533869 if (std::isnan(calculated_true_anomaly)) { @@ -2666,26 +2667,26 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 6744257 times.
-
✓ Branch 1 taken 5722659 times.
+
✓ Branch 0 taken 6778678 times.
+
✓ Branch 1 taken 5755191 times.
- 12466916 + 12533869 if (position_vector.dot(velocity_vector) < 0) { 360 - 5722659 + 5755191 calculated_true_anomaly = 2 * M_PI - calculated_true_anomaly; 361 - 5722659 + 5755191 } @@ -2699,7 +2700,7 @@

GCC Code Coverage Report

363 - 12466916 + 12533869 } else { @@ -2825,14 +2826,14 @@

GCC Code Coverage Report

380 - 12466920 + 12533873 double calculated_a = 381 - 12466920 + 12533873 calculated_p / (1.0 - calculated_eccentricity * calculated_eccentricity); @@ -2860,42 +2861,42 @@

GCC Code Coverage Report

385 - 12466920 + 12533873 a_ = calculated_a; 386 - 12466920 + 12533873 eccentricity_ = calculated_eccentricity; 387 - 12466920 + 12533873 inclination_ = calculated_i; 388 - 12466920 + 12533873 raan_ = calculated_RAAN; 389 - 12466920 + 12533873 arg_of_periapsis_ = calculated_arg_of_periapsis; 390 - 12466920 + 12533873 true_anomaly_ = calculated_true_anomaly; @@ -2909,7 +2910,7 @@

GCC Code Coverage Report

392 - 12466920 + 12533873 return error_code; @@ -3007,7 +3008,7 @@

GCC Code Coverage Report

406 - 12466918 + 12533871 std::pair<double, int> Satellite::evolve_RK45( @@ -3154,14 +3155,14 @@

GCC Code Coverage Report

427 - 12466918 + 12533871 double input_F_10 = drag_elements.first; 428 - 12466918 + 12533871 double input_A_p = drag_elements.second; @@ -3189,7 +3190,7 @@

GCC Code Coverage Report

432 - 12466918 + 12533871 check_for_maneuvers_to_initialize(); @@ -3210,7 +3211,7 @@

GCC Code Coverage Report

435 - 12466918 + 12533871 int arg_of_periapsis_code = add_arg_of_periapsis_change_thrust(); @@ -3231,7 +3232,7 @@

GCC Code Coverage Report

438 - 12466918 + 12533871 combined_initial_position_velocity_quaternion_angular_velocity_array = {}; @@ -3245,7 +3246,7 @@

GCC Code Coverage Report

440 - 12466918 + 12533871 output_position_velocity_pair = {}; @@ -3261,33 +3262,33 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 37400754 times.
-
✓ Branch 1 taken 12466918 times.
+
✓ Branch 0 taken 37601613 times.
+
✓ Branch 1 taken 12533871 times.
- 49867672 + 50135484 for (size_t ind = 0; ind < 3; ind++) { 443 - 37400754 + 37601613 combined_initial_position_velocity_quaternion_angular_velocity_array.at( 444 - 74801508 + 75203226 ind) = ECI_position_.at(ind); 445 - 37400754 + 37601613 } @@ -3296,33 +3297,33 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 37400754 times.
-
✓ Branch 1 taken 12466918 times.
+
✓ Branch 0 taken 37601613 times.
+
✓ Branch 1 taken 12533871 times.
- 49867672 + 50135484 for (size_t ind = 3; ind < 6; ind++) { 447 - 37400754 + 37601613 combined_initial_position_velocity_quaternion_angular_velocity_array.at( 448 - 74801508 + 75203226 ind) = ECI_velocity_.at(ind - 3); 449 - 37400754 + 37601613 } @@ -3331,33 +3332,33 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 49867672 times.
-
✓ Branch 1 taken 12466918 times.
+
✓ Branch 0 taken 50135484 times.
+
✓ Branch 1 taken 12533871 times.
- 62334590 + 62669355 for (size_t ind = 6; ind < 10; ind++) { 451 - 49867672 + 50135484 combined_initial_position_velocity_quaternion_angular_velocity_array.at( 452 - 99735344 + 100270968 ind) = quaternion_satellite_bodyframe_wrt_LVLH_.at(ind - 6); 453 - 49867672 + 50135484 } @@ -3373,33 +3374,33 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 37400754 times.
-
✓ Branch 1 taken 12466918 times.
+
✓ Branch 0 taken 37601613 times.
+
✓ Branch 1 taken 12533871 times.
- 49867672 + 50135484 for (size_t ind = 10; ind < 13; ind++) { 456 - 37400754 + 37601613 combined_initial_position_velocity_quaternion_angular_velocity_array.at( 457 - 74801508 + 75203226 ind) = body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(ind - 10); 458 - 37400754 + 37601613 } @@ -3420,14 +3421,14 @@

GCC Code Coverage Report

461 - 12466918 + 12533871 LVLH_to_body_transformation_matrix_from_quaternion( 462 - 12466918 + 12533871 quaternion_satellite_bodyframe_wrt_LVLH_); @@ -3441,28 +3442,28 @@

GCC Code Coverage Report

464 - 12466918 + 12533871 Vector3d body_angular_velocity_vec_wrt_LVLH_in_body_frame_eigenform = { 465 - 12466918 + 12533871 body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(0), 466 - 12466918 + 12533871 body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(1), 467 - 12466918 + 12533871 body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(2)}; @@ -3476,21 +3477,21 @@

GCC Code Coverage Report

469 - 12466918 + 12533871 Vector3d omega_I = calculate_omega_I( 470 - 12466918 + 12533871 body_angular_velocity_vec_wrt_LVLH_in_body_frame_eigenform, 471 - 12466918 + 12533871 LVLH_to_body_transformation_matrix, orbital_rate_); @@ -3504,7 +3505,7 @@

GCC Code Coverage Report

473 - 12466918 + 12533871 Vector3d omega_LVLH_wrt_inertial_in_LVLH = {0, -orbital_rate_, 0}; @@ -3518,7 +3519,7 @@

GCC Code Coverage Report

475 - 12466918 + 12533871 Matrix3d J_matrix = construct_J_matrix(J_11_, J_22_, J_33_); @@ -3541,33 +3542,33 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 12466918 times.
+
✓ Branch 0 taken 12533871 times.
✗ Branch 1 not taken.
- 12466918 + 12533871 RK45_step<13>( 479 - 12466918 + 12533871 combined_initial_position_velocity_quaternion_angular_velocity_array, 480 - 12466918 + 12533871 input_step_size, 481 - 12466918 + 12533871 RK45_combined_orbit_position_velocity_attitude_deriv_function, @@ -3576,16 +3577,16 @@

GCC Code Coverage Report

3/6
-
✓ Branch 0 taken 12466918 times.
+
✓ Branch 0 taken 12533871 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 12466918 times.
+
✓ Branch 2 taken 12533871 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 12466918 times.
+
✓ Branch 4 taken 12533871 times.
✗ Branch 5 not taken.
- 12466918 + 12533871 J_matrix, bodyframe_torque_profile_list_, omega_I, @@ -3594,12 +3595,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 12466918 times.
+
✓ Branch 0 taken 12533871 times.
✗ Branch 1 not taken.
- 12466918 + 12533871 orbital_angular_acceleration_, LVLH_to_body_transformation_matrix, @@ -3608,28 +3609,28 @@

GCC Code Coverage Report

2/4
-
✓ Branch 0 taken 12466918 times.
+
✓ Branch 0 taken 12533871 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 12466918 times.
+
✓ Branch 2 taken 12533871 times.
✗ Branch 3 not taken.
- 12466918 + 12533871 omega_LVLH_wrt_inertial_in_LVLH, m_, thrust_profile_list_, 485 - 12466918 + 12533871 inclination_, arg_of_periapsis_, true_anomaly_, input_F_10, input_A_p, 486 - 12466918 + 12533871 A_s_, perturbation, atmospheric_drag, t_, input_epsilon); @@ -3657,21 +3658,21 @@

GCC Code Coverage Report

490 - 12466918 + 12533871 output_pair.first; 491 - 12466918 + 12533871 double step_size_successfully_used_here = output_pair.second.first; 492 - 12466918 + 12533871 double new_step_size = output_pair.second.second; @@ -3687,54 +3688,54 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 37400754 times.
-
✓ Branch 1 taken 12466918 times.
+
✓ Branch 0 taken 37601613 times.
+
✓ Branch 1 taken 12533871 times.
- 49867672 + 50135484 for (size_t ind = 0; ind < 3; ind++) { 495 - 37400754 + 37601613 ECI_position_.at(ind) = 496 - 37400754 + 37601613 output_combined_position_velocity_quaternion_angular_velocity_array.at( 497 - 37400754 + 37601613 ind); 498 - 37400754 + 37601613 ECI_velocity_.at(ind) = 499 - 37400754 + 37601613 output_combined_position_velocity_quaternion_angular_velocity_array.at( 500 - 37400754 + 37601613 ind + 3); @@ -3748,28 +3749,28 @@

GCC Code Coverage Report

502 - 37400754 + 37601613 perifocal_position_ = convert_ECI_to_perifocal(ECI_position_); 503 - 37400754 + 37601613 perifocal_velocity_ = convert_ECI_to_perifocal(ECI_velocity_); 504 - 37400754 + 37601613 } 505 - 12466918 + 12533871 t_ += step_size_successfully_used_here; @@ -3785,61 +3786,61 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 49867672 times.
-
✓ Branch 1 taken 12466918 times.
+
✓ Branch 0 taken 50135484 times.
+
✓ Branch 1 taken 12533871 times.
- 62334590 + 62669355 for (size_t ind = 0; ind < quaternion_satellite_bodyframe_wrt_LVLH_.size(); 508 - 49867672 + 50135484 ind++) { 509 - 49867672 + 50135484 quaternion_satellite_bodyframe_wrt_LVLH_.at(ind) = 510 - 49867672 + 50135484 output_combined_position_velocity_quaternion_angular_velocity_array.at( 511 - 49867672 + 50135484 ind + 6); 512 - 49867672 + 50135484 } 513 - 12466918 + 12533871 quaternion_satellite_bodyframe_wrt_LVLH_ = 514 - 12466918 + 12533871 normalize_quaternion(quaternion_satellite_bodyframe_wrt_LVLH_); @@ -3853,14 +3854,14 @@

GCC Code Coverage Report

516 - 12466918 + 12533871 convert_quaternion_to_roll_yaw_pitch_angles( 517 - 12466918 + 12533871 quaternion_satellite_bodyframe_wrt_LVLH_); @@ -3874,21 +3875,21 @@

GCC Code Coverage Report

519 - 12466918 + 12533871 roll_angle_ = updated_roll_yaw_pitch.at(0); 520 - 12466918 + 12533871 yaw_angle_ = updated_roll_yaw_pitch.at(1); 521 - 12466918 + 12533871 pitch_angle_ = updated_roll_yaw_pitch.at(2); @@ -3904,47 +3905,47 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 37400754 times.
-
✓ Branch 1 taken 12466918 times.
+
✓ Branch 0 taken 37601613 times.
+
✓ Branch 1 taken 12533871 times.
- 49867672 + 50135484 for (size_t ind = 0; 524 - 49867672 + 50135484 ind < body_angular_velocity_vec_wrt_LVLH_in_body_frame_.size(); ind++) { 525 - 37400754 + 37601613 body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(ind) = 526 - 37400754 + 37601613 output_combined_position_velocity_quaternion_angular_velocity_array.at( 527 - 37400754 + 37601613 ind + 10); 528 - 37400754 + 37601613 } @@ -3965,42 +3966,42 @@

GCC Code Coverage Report

531 - 12466918 + 12533871 int orbit_elems_error_code = 532 - 12466918 + 12533871 update_orbital_elements_from_position_and_velocity(); 533 - 12466918 + 12533871 orbital_rate_ = calculate_instantaneous_orbit_rate(); 534 - 12466918 + 12533871 orbital_angular_acceleration_ = 535 - 12466918 + 12533871 calculate_instantaneous_orbit_angular_acceleration(); 536 - 12466918 + 12533871 std::pair<double, int> evolve_RK45_output_pair; @@ -4014,7 +4015,7 @@

GCC Code Coverage Report

538 - 12466918 + 12533871 double new_orbital_radius = get_radius(); @@ -4023,12 +4024,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 12466918 times.
+
✓ Branch 0 taken 12533871 times.
✗ Branch 1 not taken.
- 12466918 + 12533871 if (new_orbital_radius <= radius_Earth) { @@ -4049,14 +4050,14 @@

GCC Code Coverage Report

542 - 12466918 + 12533871 evolve_RK45_output_pair.first = new_step_size; 543 - 12466918 + 12533871 evolve_RK45_output_pair.second = orbit_elems_error_code; @@ -4093,12 +4094,12 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 8971207 times.
+
✓ Branch 0 taken 9038160 times.
✓ Branch 1 taken 3495711 times.
- 12466918 + 12533871 if (arg_of_periapsis_code == 1) { @@ -4119,7 +4120,7 @@

GCC Code Coverage Report

551 - 12466918 + 12533871 return evolve_RK45_output_pair; @@ -4147,7 +4148,7 @@

GCC Code Coverage Report

555 - 95672 + 698366 double Satellite::get_orbital_parameter( @@ -4163,19 +4164,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9352 times.
-
✓ Branch 1 taken 86320 times.
+
✓ Branch 0 taken 76318 times.
+
✓ Branch 1 taken 622048 times.
- 95672 + 698366 if (orbital_parameter_name == "Semimajor Axis") { 558 - 9352 + 76318 return a_; @@ -4184,19 +4185,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9348 times.
-
✓ Branch 1 taken 76972 times.
+
✓ Branch 0 taken 76314 times.
+
✓ Branch 1 taken 545734 times.
- 86320 + 622048 } else if (orbital_parameter_name == "Eccentricity") { 560 - 9348 + 76314 return eccentricity_; @@ -4205,19 +4206,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9344 times.
-
✓ Branch 1 taken 67628 times.
+
✓ Branch 0 taken 76310 times.
+
✓ Branch 1 taken 469424 times.
- 76972 + 545734 } else if (orbital_parameter_name == "Inclination") { 562 - 9344 + 76310 return inclination_ * (180 / M_PI); // Returns val in degrees @@ -4226,19 +4227,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9344 times.
-
✓ Branch 1 taken 58284 times.
+
✓ Branch 0 taken 76310 times.
+
✓ Branch 1 taken 393114 times.
- 67628 + 469424 } else if (orbital_parameter_name == "RAAN") { 564 - 9344 + 76310 return raan_ * (180.0 / M_PI); // Returns val in degrees @@ -4247,19 +4248,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9348 times.
-
✓ Branch 1 taken 48936 times.
+
✓ Branch 0 taken 76314 times.
+
✓ Branch 1 taken 316800 times.
- 58284 + 393114 } else if (orbital_parameter_name == "Argument of Periapsis") { 566 - 9348 + 76314 return arg_of_periapsis_ * (180.0 / M_PI); // Returns val in degrees @@ -4268,19 +4269,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 20903 times.
-
✓ Branch 1 taken 28033 times.
+
✓ Branch 0 taken 87869 times.
+
✓ Branch 1 taken 228931 times.
- 48936 + 316800 } else if (orbital_parameter_name == "True Anomaly") { 568 - 20903 + 87869 return true_anomaly_ * (180.0 / M_PI); // Returns val in degrees @@ -4289,19 +4290,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9344 times.
-
✓ Branch 1 taken 18689 times.
+
✓ Branch 0 taken 76310 times.
+
✓ Branch 1 taken 152621 times.
- 28033 + 228931 } else if (orbital_parameter_name == "Orbital Rate") { 570 - 9344 + 76310 return orbital_rate_; @@ -4310,19 +4311,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9344 times.
-
✓ Branch 1 taken 9345 times.
+
✓ Branch 0 taken 76310 times.
+
✓ Branch 1 taken 76311 times.
- 18689 + 152621 } else if (orbital_parameter_name == "Orbital Angular Acceleration") { 572 - 9344 + 76310 return orbital_angular_acceleration_; @@ -4331,19 +4332,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9344 times.
+
✓ Branch 0 taken 76310 times.
✓ Branch 1 taken 1 times.
- 9345 + 76311 } else if (orbital_parameter_name == "Total Energy") { 574 - 9344 + 76310 return get_total_energy(); @@ -4378,7 +4379,7 @@

GCC Code Coverage Report

578 - 95671 + 698365 } @@ -4658,7 +4659,7 @@

GCC Code Coverage Report

615 - 12466975 + 12533943 double Satellite::calculate_instantaneous_orbit_rate() { @@ -4707,77 +4708,77 @@

GCC Code Coverage Report

622 - 24933950 + 25067886 Vector3d position_vector = {perifocal_position_.at(0), 623 - 12466975 + 12533943 perifocal_position_.at(1), 624 - 12466975 + 12533943 perifocal_position_.at(2)}; 625 - 24933950 + 25067886 Vector3d velocity_vector = {perifocal_velocity_.at(0), 626 - 12466975 + 12533943 perifocal_velocity_.at(1), 627 - 12466975 + 12533943 perifocal_velocity_.at(2)}; 628 - 12466975 + 12533943 Vector3d h_vector = position_vector.cross(velocity_vector); 629 - 12466975 + 12533943 double h = h_vector.norm(); 630 - 12466975 + 12533943 double r = get_radius(); 631 - 12466975 + 12533943 double orbit_rate = h / (r * r); 632 - 12466975 + 12533943 return orbit_rate; @@ -4798,7 +4799,7 @@

GCC Code Coverage Report

635 - 12466975 + 12533943 double Satellite::calculate_instantaneous_orbit_angular_acceleration() { @@ -4847,91 +4848,91 @@

GCC Code Coverage Report

642 - 24933950 + 25067886 Vector3d position_vector = {perifocal_position_.at(0), 643 - 12466975 + 12533943 perifocal_position_.at(1), 644 - 12466975 + 12533943 perifocal_position_.at(2)}; 645 - 24933950 + 25067886 Vector3d velocity_vector = {perifocal_velocity_.at(0), 646 - 12466975 + 12533943 perifocal_velocity_.at(1), 647 - 12466975 + 12533943 perifocal_velocity_.at(2)}; 648 - 12466975 + 12533943 Vector3d h_vector = position_vector.cross(velocity_vector); 649 - 12466975 + 12533943 double h = h_vector.norm(); 650 - 12466975 + 12533943 double r = get_radius(); 651 - 12466975 + 12533943 Vector3d unit_position_vector = position_vector; 652 - 12466975 + 12533943 unit_position_vector.normalize(); 653 - 12466975 + 12533943 double orbit_angular_acceleration = 654 - 12466975 + 12533943 -2 * h / (r * r * r) * velocity_vector.dot(unit_position_vector); @@ -4959,7 +4960,7 @@

GCC Code Coverage Report

658 - 12466975 + 12533943 return orbit_angular_acceleration; @@ -4980,7 +4981,7 @@

GCC Code Coverage Report

661 - 59 + 74 void Satellite::initialize_and_normalize_body_quaternion( @@ -5001,7 +5002,7 @@

GCC Code Coverage Report

664 - 59 + 74 rollyawpitch_angles_to_quaternion(roll_angle, pitch_angle, yaw_angle); @@ -5015,21 +5016,21 @@

GCC Code Coverage Report

666 - 59 + 74 normalize_quaternion(quaternion); 667 - 59 + 74 quaternion_satellite_bodyframe_wrt_LVLH_ = normalized_quaternion; 668 - 59 + 74 return; @@ -5057,7 +5058,7 @@

GCC Code Coverage Report

672 - 96215 + 765875 double Satellite::get_attitude_val(std::string input_attitude_val_name) { @@ -5066,19 +5067,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9621 times.
-
✓ Branch 1 taken 86594 times.
+
✓ Branch 0 taken 76587 times.
+
✓ Branch 1 taken 689288 times.
- 96215 + 765875 if (input_attitude_val_name == "Roll") { 674 - 9621 + 76587 return roll_angle_ * (180.0 / M_PI); // Returns val in degrees @@ -5087,19 +5088,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9625 times.
-
✓ Branch 1 taken 76969 times.
+
✓ Branch 0 taken 76591 times.
+
✓ Branch 1 taken 612697 times.
- 86594 + 689288 } else if (input_attitude_val_name == "Pitch") { 676 - 9625 + 76591 return pitch_angle_ * (180.0 / M_PI); // Returns val in degrees @@ -5108,19 +5109,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9621 times.
-
✓ Branch 1 taken 67348 times.
+
✓ Branch 0 taken 76587 times.
+
✓ Branch 1 taken 536110 times.
- 76969 + 612697 } else if (input_attitude_val_name == "Yaw") { 678 - 9621 + 76587 return yaw_angle_ * (180.0 / M_PI); // Returns val in degrees @@ -5129,19 +5130,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9621 times.
-
✓ Branch 1 taken 57727 times.
+
✓ Branch 0 taken 76587 times.
+
✓ Branch 1 taken 459523 times.
- 67348 + 536110 } else if (input_attitude_val_name == "omega_x") { 680 - 9621 + 76587 return body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(0) * @@ -5157,19 +5158,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9621 times.
-
✓ Branch 1 taken 48106 times.
+
✓ Branch 0 taken 76587 times.
+
✓ Branch 1 taken 382936 times.
- 57727 + 459523 } else if (input_attitude_val_name == "omega_y") { 683 - 9621 + 76587 return body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(1) * @@ -5185,19 +5186,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9621 times.
-
✓ Branch 1 taken 38485 times.
+
✓ Branch 0 taken 76587 times.
+
✓ Branch 1 taken 306349 times.
- 48106 + 382936 } else if (input_attitude_val_name == "omega_z") { 686 - 9621 + 76587 return body_angular_velocity_vec_wrt_LVLH_in_body_frame_.at(2) * @@ -5213,19 +5214,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9621 times.
-
✓ Branch 1 taken 28864 times.
+
✓ Branch 0 taken 76587 times.
+
✓ Branch 1 taken 229762 times.
- 38485 + 306349 } else if (input_attitude_val_name == "q_0") { 689 - 9621 + 76587 return quaternion_satellite_bodyframe_wrt_LVLH_.at(0); @@ -5234,19 +5235,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9621 times.
-
✓ Branch 1 taken 19243 times.
+
✓ Branch 0 taken 76587 times.
+
✓ Branch 1 taken 153175 times.
- 28864 + 229762 } else if (input_attitude_val_name == "q_1") { 691 - 9621 + 76587 return quaternion_satellite_bodyframe_wrt_LVLH_.at(1); @@ -5255,19 +5256,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9621 times.
-
✓ Branch 1 taken 9622 times.
+
✓ Branch 0 taken 76587 times.
+
✓ Branch 1 taken 76588 times.
- 19243 + 153175 } else if (input_attitude_val_name == "q_2") { 693 - 9621 + 76587 return quaternion_satellite_bodyframe_wrt_LVLH_.at(2); @@ -5276,19 +5277,19 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 9621 times.
+
✓ Branch 0 taken 76587 times.
✓ Branch 1 taken 1 times.
- 9622 + 76588 } else if (input_attitude_val_name == "q_3") { 695 - 9621 + 76587 return quaternion_satellite_bodyframe_wrt_LVLH_.at(3); @@ -5323,7 +5324,7 @@

GCC Code Coverage Report

699 - 96214 + 765874 } @@ -5337,49 +5338,49 @@

GCC Code Coverage Report

701 - 57 + 72 void Satellite::initialize_body_angular_velocity_vec_wrt_LVLH_in_body_frame() { 702 - 57 + 72 std::array<double, 3> initial_body_angular_velocity_in_LVLH_frame = { 703 - 57 + 72 0, orbital_rate_, 0}; 704 - 57 + 72 body_angular_velocity_vec_wrt_LVLH_in_body_frame_ = 705 - 57 + 72 convert_array_from_LVLH_to_bodyframe( 706 - 57 + 72 initial_body_angular_velocity_in_LVLH_frame, roll_angle_, yaw_angle_, 707 - 57 + 72 pitch_angle_); // Because LVLH is always rotating around y axis to @@ -5393,14 +5394,14 @@

GCC Code Coverage Report

709 - 57 + 72 } 710 - 12466918 + 12533871 int Satellite::add_arg_of_periapsis_change_thrust() { @@ -5430,12 +5431,12 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 8971207 times.
+
✓ Branch 0 taken 9038160 times.
✓ Branch 1 taken 11210535 times.
- 20181742 + 20248695 for (ThrustProfileLVLH thrust_profile : thrust_profile_list_) { @@ -5577,21 +5578,21 @@

GCC Code Coverage Report

732 - 8971207 + 9038160 return 0; 733 - 12466918 + 12533871 } 734 - 12466918 + 12533871 void Satellite::check_for_maneuvers_to_initialize() { @@ -5601,18 +5602,18 @@

GCC Code Coverage Report

2/2
✓ Branch 0 taken 2 times.
-
✓ Branch 1 taken 12466918 times.
+
✓ Branch 1 taken 12533871 times.
- 12466920 + 12533873 for (size_t maneuver_index = 0; 736 - 12466920 + 12533873 maneuver_index < maneuvers_awaiting_initiation_.size(); @@ -5805,7 +5806,7 @@

GCC Code Coverage Report

756 - 12466918 + 12533871 } @@ -5899,6 +5900,146 @@

GCC Code Coverage Report

+ + 769 + + + 76318 + double Satellite::get_total_energy() { + + + 770 + + + + // First, gravitational potential energy + + + 771 + + + 76318 + double orbital_radius = get_radius(); + + + 772 + + + 76318 + double gravitational_potential_energy = + + + 773 + + + 76318 + -G * mass_Earth * m_ / orbital_radius; + + + 774 + + + + + + + 775 + + + + // Next, translational kinetic energy + + + 776 + + + 76318 + double orbital_speed = get_speed(); + + + 777 + + + 76318 + double translational_kinetic_energy = (1.0 / 2.0) * m_ * (orbital_speed * orbital_speed); + + + 778 + + + + + + + 779 + + + + // Next, rotational kinetic energy + + + 780 + + + 76318 + double rotational_kinetic_energy = 0; + + + 781 + + + 76318 + std::array<double,3> body_angular_velocity_vec_wrt_LVLH_in_body_frame = body_angular_velocity_vec_wrt_LVLH_in_body_frame_; + + + 782 + + + 76318 + rotational_kinetic_energy += (0.5 * J_11_ * body_angular_velocity_vec_wrt_LVLH_in_body_frame.at(0)*body_angular_velocity_vec_wrt_LVLH_in_body_frame.at(0)); + + + 783 + + + 76318 + rotational_kinetic_energy += (0.5 * J_22_ * body_angular_velocity_vec_wrt_LVLH_in_body_frame.at(1)*body_angular_velocity_vec_wrt_LVLH_in_body_frame.at(1)); + + + 784 + + + 76318 + rotational_kinetic_energy += (0.5 * J_33_ * body_angular_velocity_vec_wrt_LVLH_in_body_frame.at(2)*body_angular_velocity_vec_wrt_LVLH_in_body_frame.at(2)); + + + 785 + + + + + + + 786 + + + 76318 + return (gravitational_potential_energy + translational_kinetic_energy + rotational_kinetic_energy); + + + 787 + + + + } + + + 788 + + + + +
diff --git a/tests/test_coverage_detailed.Satellite.h.016907876294210b00a2d880adf10425.html b/tests/test_coverage_detailed.Satellite.h.016907876294210b00a2d880adf10425.html index b61a902..a13a42a 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-05-11 21:11:47 + 2025-05-27 18:19:02 @@ -40,8 +40,8 @@

GCC Code Coverage Report

Lines: - 201 - 201 + 195 + 195 100.0% @@ -73,19 +73,19 @@

GCC Code Coverage Report

BodyframeTorqueProfile::BodyframeTorqueProfile(double, double, std::__1::array<double, 3ul>) (line 92)called 42 times100.0% BodyframeTorqueProfile::BodyframeTorqueProfile(double, double, std::__1::array<double, 3ul>, double) (line 98)called 2 times100.0% BodyframeTorqueProfile::operator==(BodyframeTorqueProfile const&) (line 109)called 1 time100.0% - Satellite::Satellite(Satellite const&) (line 118)called 26974378 times100.0% - Satellite::Satellite(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 188)called 132 times100.0% - Satellite::get_ECI_position() (line 307)called 13489787 times100.0% - Satellite::get_instantaneous_time() (line 342)called 25941200 times100.0% - Satellite::get_mass() (line 341)called 4 times100.0% - Satellite::get_name() (line 343)called 2737 times100.0% - Satellite::get_radius() (line 320)called 49877272 times100.0% + Satellite::Satellite(Satellite const&) (line 118)called 26974510 times100.0% + Satellite::Satellite(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 188)called 162 times100.0% + Satellite::get_ECI_position() (line 307)called 13556753 times100.0% + Satellite::get_ECI_velocity() (line 308)called 66966 times100.0% + Satellite::get_instantaneous_time() (line 333)called 26008166 times100.0% + Satellite::get_mass() (line 332)called 4 times100.0% + Satellite::get_name() (line 334)called 2758 times100.0% + Satellite::get_radius() (line 320)called 50212080 times100.0% Satellite::get_radius_ECI() (line 327)called 2 times100.0% - Satellite::get_speed() (line 309)called 12476282 times100.0% + Satellite::get_speed() (line 309)called 12610201 times100.0% Satellite::get_speed_ECI() (line 316)called 2 times100.0% - Satellite::get_total_energy() (line 331)called 9352 times100.0% Satellite::operator=(Satellite const&) (line 118)called 2052 times100.0% - Satellite::~Satellite() (line 118)called 26974492 times100.0% + Satellite::~Satellite() (line 118)called 26974654 times100.0% ThrustProfileLVLH::ThrustProfileLVLH(double, double, double, double, double, double, double) (line 50)called 4 times100.0% ThrustProfileLVLH::ThrustProfileLVLH(double, double, std::__1::array<double, 3ul>) (line 33)called 22 times100.0% ThrustProfileLVLH::ThrustProfileLVLH(double, double, std::__1::array<double, 3ul>, double) (line 39)called 6991448 times100.0% @@ -977,22 +977,22 @@

GCC Code Coverage Report

6/12
-
✓ Branch 0 taken 13487189 times.
+
✓ Branch 0 taken 13487255 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 13487189 times.
+
✓ Branch 2 taken 13487255 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 13487189 times.
+
✓ Branch 4 taken 13487255 times.
✗ Branch 5 not taken.
-
✓ Branch 6 taken 13487189 times.
+
✓ Branch 6 taken 13487255 times.
✗ Branch 7 not taken.
-
✓ Branch 8 taken 13487189 times.
+
✓ Branch 8 taken 13487255 times.
✗ Branch 9 not taken.
-
✓ Branch 10 taken 13487189 times.
+
✓ Branch 10 taken 13487255 times.
✗ Branch 11 not taken.
- 13487189 + 13487255 class Satellite { @@ -1006,14 +1006,14 @@

GCC Code Coverage Report

120 - 66 + 81 double inclination_ = {0}; 121 - 66 + 81 double raan_ = {0}; @@ -1034,42 +1034,42 @@

GCC Code Coverage Report

124 - 66 + 81 double arg_of_periapsis_ = {0}; 125 - 66 + 81 double eccentricity_ = {0}; 126 - 66 + 81 double a_ = {0}; 127 - 66 + 81 double true_anomaly_ = {0}; 128 - 66 + 81 double orbital_period_ = {0}; 129 - 66 + 81 double m_ = {1}; @@ -1104,7 +1104,7 @@

GCC Code Coverage Report

134 - 66 + 81 double t_ = {0}; @@ -1118,7 +1118,7 @@

GCC Code Coverage Report

136 - 66 + 81 double orbital_rate_ = {0}; @@ -1132,7 +1132,7 @@

GCC Code Coverage Report

138 - 66 + 81 double orbital_angular_acceleration_ = {0}; @@ -1160,21 +1160,21 @@

GCC Code Coverage Report

142 - 66 + 81 double J_11_ = {1}; 143 - 66 + 81 double J_22_ = {1}; 144 - 66 + 81 double J_33_ = {1}; @@ -1195,21 +1195,21 @@

GCC Code Coverage Report

147 - 66 + 81 double pitch_angle_ = {0}; 148 - 66 + 81 double roll_angle_ = {0}; 149 - 66 + 81 double yaw_angle_ = {0}; @@ -1237,7 +1237,7 @@

GCC Code Coverage Report

153 - 66 + 81 double A_s_ = {0}; @@ -1265,14 +1265,14 @@

GCC Code Coverage Report

157 - 66 + 81 std::array<double, 3> body_angular_velocity_vec_wrt_LVLH_in_body_frame_ 158 - 66 + 81 = {0, 0, 0}; @@ -1314,7 +1314,7 @@

GCC Code Coverage Report

164 - 66 + 81 std::string name_ = ""; @@ -1328,14 +1328,14 @@

GCC Code Coverage Report

166 - 66 + 81 std::array<double, 3> perifocal_position_ = {0, 0, 0}; 167 - 66 + 81 std::array<double, 3> perifocal_velocity_ = {0, 0, 0}; @@ -1349,14 +1349,14 @@

GCC Code Coverage Report

169 - 66 + 81 std::array<double, 3> ECI_position_ = {0, 0, 0}; 170 - 66 + 81 std::array<double, 3> ECI_velocity_ = {0, 0, 0}; @@ -1370,14 +1370,14 @@

GCC Code Coverage Report

172 - 66 + 81 std::vector<ThrustProfileLVLH> thrust_profile_list_ = {}; 173 - 66 + 81 std::vector<BodyframeTorqueProfile> bodyframe_torque_profile_list_ = {}; @@ -1391,21 +1391,21 @@

GCC Code Coverage Report

175 - 66 + 81 std::vector<std::array<double, 3>> list_of_LVLH_forces_at_this_time_ = {}; 176 - 66 + 81 std::vector<std::array<double, 3>> list_of_ECI_forces_at_this_time_ = {}; 177 - 66 + 81 std::vector<std::array<double, 3>> list_of_body_frame_torques_at_this_time_ = @@ -1426,14 +1426,14 @@

GCC Code Coverage Report

180 - 66 + 81 maneuvers_awaiting_initiation_ = {}; 181 - 66 + 81 double drag_surface_area = {0}; // Surface area of satellite used for @@ -1477,19 +1477,19 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 66 times.
+
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
- 66 + 81 std::string plotting_color_ = ""; 188 - 198 + 243 Satellite(const std::string input_file_name) { @@ -1519,12 +1519,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 66 times.
+
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
- 66 + 81 std::ifstream input_filestream(input_file_name); @@ -1533,12 +1533,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 66 times.
+
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
- 66 + 81 json input_data = json::parse(input_filestream); @@ -1554,14 +1554,14 @@

GCC Code Coverage Report

3/4
-
✓ Branch 0 taken 65 times.
+
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 1 times.
-
✓ Branch 2 taken 65 times.
+
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
- 66 + 81 inclination_ = input_data.at("Inclination"); @@ -1575,7 +1575,7 @@

GCC Code Coverage Report

197 - 65 + 80 inclination_ *= (M_PI / 180.0); @@ -1584,12 +1584,12 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 64 times.
+
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 1 times.
- 65 + 80 if (inclination_ == 0) { @@ -1635,14 +1635,14 @@

GCC Code Coverage Report

3/4
-
✓ Branch 0 taken 63 times.
+
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1 times.
-
✓ Branch 2 taken 63 times.
+
✓ Branch 2 taken 78 times.
✗ Branch 3 not taken.
- 64 + 79 raan_ = input_data.at("RAAN"); @@ -1656,7 +1656,7 @@

GCC Code Coverage Report

205 - 63 + 78 raan_ *= (M_PI / 180.0); @@ -1672,14 +1672,14 @@

GCC Code Coverage Report

3/4
-
✓ Branch 0 taken 62 times.
+
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 1 times.
-
✓ Branch 2 taken 62 times.
+
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
- 63 + 78 arg_of_periapsis_ = input_data.at("Argument of Periapsis"); @@ -1693,7 +1693,7 @@

GCC Code Coverage Report

209 - 62 + 77 arg_of_periapsis_ *= (M_PI / 180.0); @@ -1709,14 +1709,14 @@

GCC Code Coverage Report

3/4
-
✓ Branch 0 taken 61 times.
+
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 1 times.
-
✓ Branch 2 taken 61 times.
+
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
- 62 + 77 eccentricity_ = input_data.at("Eccentricity"); @@ -1739,26 +1739,26 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 47 times.
-
✓ Branch 1 taken 14 times.
+
✓ Branch 0 taken 58 times.
+
✓ Branch 1 taken 18 times.
- 61 + 76 if (eccentricity_ == 0) { 215 - 14 + 18 arg_of_periapsis_ = 0; 216 - 14 + 18 } @@ -1774,21 +1774,21 @@

GCC Code Coverage Report

3/4
-
✓ Branch 0 taken 60 times.
+
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 1 times.
-
✓ Branch 2 taken 60 times.
+
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
- 61 + 76 a_ = input_data.at("Semimajor Axis"); 219 - 60 + 75 a_ *= 1000.0; // converting from km to m @@ -1804,14 +1804,14 @@

GCC Code Coverage Report

3/4
-
✓ Branch 0 taken 59 times.
+
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 1 times.
-
✓ Branch 2 taken 59 times.
+
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
- 60 + 75 true_anomaly_ = input_data.at("True Anomaly"); @@ -1825,7 +1825,7 @@

GCC Code Coverage Report

223 - 59 + 74 true_anomaly_ *= (M_PI / 180.0); @@ -1848,16 +1848,16 @@

GCC Code Coverage Report

4/6
-
✓ Branch 0 taken 59 times.
+
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 59 times.
+
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
-
✓ Branch 5 taken 51 times.
+
✓ Branch 5 taken 66 times.
- 59 + 74 if (input_data.find("Initial Pitch Angle") != input_data.end()) { @@ -1910,16 +1910,16 @@

GCC Code Coverage Report

4/6
-
✓ Branch 0 taken 59 times.
+
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 59 times.
+
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
-
✓ Branch 5 taken 51 times.
+
✓ Branch 5 taken 66 times.
- 59 + 74 if (input_data.find("Initial Roll Angle") != input_data.end()) { @@ -1972,16 +1972,16 @@

GCC Code Coverage Report

4/6
-
✓ Branch 0 taken 59 times.
+
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 59 times.
+
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
-
✓ Branch 5 taken 51 times.
+
✓ Branch 5 taken 66 times.
- 59 + 74 if (input_data.find("Initial Yaw Angle") != input_data.end()) { @@ -2034,21 +2034,21 @@

GCC Code Coverage Report

2/4
-
✓ Branch 0 taken 59 times.
+
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 59 times.
+
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
- 118 + 148 initialize_and_normalize_body_quaternion(roll_angle_, pitch_angle_, 245 - 59 + 74 yaw_angle_); @@ -2064,14 +2064,14 @@

GCC Code Coverage Report

3/4
-
✓ Branch 0 taken 58 times.
+
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 1 times.
-
✓ Branch 2 taken 58 times.
+
✓ Branch 2 taken 73 times.
✗ Branch 3 not taken.
- 59 + 74 m_ = input_data.at("Mass"); @@ -2080,14 +2080,14 @@

GCC Code Coverage Report

3/4
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1 times.
-
✓ Branch 2 taken 57 times.
+
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
- 58 + 73 name_ = input_data.at("Name"); @@ -2110,16 +2110,16 @@

GCC Code Coverage Report

4/6
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 57 times.
+
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
-
✓ Branch 5 taken 45 times.
+
✓ Branch 5 taken 60 times.
- 57 + 72 if (input_data.find("Plotting Color") != input_data.end()) { @@ -2172,16 +2172,16 @@

GCC Code Coverage Report

4/6
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 57 times.
+
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
-
✓ Branch 5 taken 43 times.
+
✓ Branch 5 taken 58 times.
- 57 + 72 if (input_data.find("A_s") != input_data.end()) { @@ -2218,7 +2218,7 @@

GCC Code Coverage Report

261 - 57 + 72 t_ = 0; // for now, assuming satellites are initialized at time t=0; @@ -2234,12 +2234,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
- 57 + 72 orbital_period_ = calculate_orbital_period(); @@ -2262,12 +2262,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
- 57 + 72 perifocal_position_ = calculate_perifocal_position(); @@ -2276,12 +2276,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
- 57 + 72 perifocal_velocity_ = calculate_perifocal_velocity(); @@ -2297,12 +2297,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
- 57 + 72 ECI_position_ = convert_perifocal_to_ECI(perifocal_position_); @@ -2311,12 +2311,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
- 57 + 72 ECI_velocity_ = convert_perifocal_to_ECI(perifocal_velocity_); @@ -2332,12 +2332,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
- 57 + 72 orbital_rate_ = calculate_instantaneous_orbit_rate(); @@ -2346,12 +2346,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
- 57 + 72 initialize_body_angular_velocity_vec_wrt_LVLH_in_body_frame(); @@ -2367,16 +2367,16 @@

GCC Code Coverage Report

4/6
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 57 times.
+
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
-
✓ Branch 5 taken 49 times.
+
✓ Branch 5 taken 64 times.
- 57 + 72 if (input_data.find("Initial omega_x") != input_data.end()) { @@ -2457,16 +2457,16 @@

GCC Code Coverage Report

4/6
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 57 times.
+
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
-
✓ Branch 5 taken 49 times.
+
✓ Branch 5 taken 64 times.
- 57 + 72 if (input_data.find("Initial omega_y") != input_data.end()) { @@ -2554,16 +2554,16 @@

GCC Code Coverage Report

4/6
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 57 times.
+
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
-
✓ Branch 5 taken 49 times.
+
✓ Branch 5 taken 64 times.
- 57 + 72 if (input_data.find("Initial omega_z") != input_data.end()) { @@ -2642,7 +2642,7 @@

GCC Code Coverage Report

303 - 57 + 72 orbital_angular_acceleration_ = @@ -2651,19 +2651,19 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
- 57 + 72 calculate_instantaneous_orbit_angular_acceleration(); 305 - 132 + 162 } @@ -2677,21 +2677,21 @@

GCC Code Coverage Report

307 - 13489787 + 13556753 std::array<double, 3> get_ECI_position() { return ECI_position_; } 308 - - std::array<double, 3> get_ECI_velocity() { return ECI_velocity_; } + 66966 + std::array<double, 3> get_ECI_velocity() { return ECI_velocity_; } 309 - 12476282 + 12610201 double get_speed() { @@ -2719,14 +2719,14 @@

GCC Code Coverage Report

313 - 24952564 + 25220402 return sqrt(pow(perifocal_velocity_.at(0), 2) + 314 - 12476282 + 12610201 pow(perifocal_velocity_.at(1), 2)); @@ -2768,7 +2768,7 @@

GCC Code Coverage Report

320 - 49877272 + 50212080 double get_radius() { @@ -2796,14 +2796,14 @@

GCC Code Coverage Report

324 - 99754544 + 100424160 return sqrt(pow(perifocal_position_.at(0), 2) + 325 - 49877272 + 50212080 pow(perifocal_position_.at(1), 2)); @@ -2845,536 +2845,473 @@

GCC Code Coverage Report

331 - 9352 - double get_total_energy() { + + double get_total_energy(); 332 - 9352 - double orbital_radius = get_radius(); + 4 + double get_mass() { return m_; } 333 - 9352 - double gravitational_potential_energy = + 26008166 + double get_instantaneous_time() { return t_; } 334 - 9352 - -G * mass_Earth * m_ / orbital_radius; + 2758 + std::string get_name() { return name_; } 335 - - - - 336 - - - 9352 - double orbital_speed = get_speed(); - - - 337 - - - 9352 - double kinetic_energy = (1.0 / 2.0) * m_ * (orbital_speed * orbital_speed); - - - 338 - - - - - - - 339 - - - 9352 - return (gravitational_potential_energy + kinetic_energy); - - - 340 - - - - } - - - 341 - - - 4 - double get_mass() { return m_; } - - - 342 - - - 25941200 - double get_instantaneous_time() { return t_; } - - - 343 - - - 2737 - std::string get_name() { return name_; } - - - 344 - - - // void evolve_RK4(const double input_timestep); - 345 + 336 - 346 + 337 std::array<double, 3> body_frame_to_ECI( - 347 + 338 const std::array<double, 3> input_vector); - 348 + 339 - 349 + 340 std::array<double, 3> ECI_to_body_frame( - 350 + 341 const std::array<double, 3> input_vector); - 351 + 342 - 352 + 343 std::array<double, 3> calculate_perifocal_position(); - 353 + 344 - 354 + 345 std::array<double, 3> calculate_perifocal_velocity(); - 355 + 346 - 356 + 347 std::array<double, 3> convert_perifocal_to_ECI( - 357 + 348 const std::array<double, 3> input_perifocal_vec); - 358 + 349 std::array<double, 3> convert_ECI_to_perifocal( - 359 + 350 const std::array<double, 3> input_ECI_vec); - 360 + 351 - 361 + 352 // std::array<double,3> convert_LVLH_to_ECI(std::array<double,3> - 362 + 353 // input_LVLH_vec); - 363 + 354 - 364 + 355 void add_LVLH_thrust_profile( - 365 + 356 const std::array<double, 3> input_LVLH_normalized_thrust_direction, - 366 + 357 const double input_LVLH_thrust_magnitude, - 367 + 358 const double input_thrust_start_time, const double input_thrust_end_time); - 368 + 359 void add_LVLH_thrust_profile( - 369 + 360 const std::array<double, 3> input_LVLH_thrust_vector, - 370 + 361 const double input_thrust_start_time, const double input_thrust_end_time); - 371 + 362 void add_LVLH_thrust_profile(const double input_thrust_start_time, - 372 + 363 const double final_arg_of_periapsis, - 373 + 364 const double input_thrust_magnitude); - 374 + 365 void add_bodyframe_torque_profile( - 375 + 366 const std::array<double, 3> input_bodyframe_direction_unit_vec, - 376 + 367 const double input_bodyframe_torque_magnitude, - 377 + 368 const double input_torque_start_time, const double input_torque_end_time); - 378 + 369 void add_bodyframe_torque_profile( - 379 + 370 const std::array<double, 3> input_bodyframe_torque_vector, - 380 + 371 const double input_torque_start_time, const double input_torque_end_time); - 381 + 372 - 382 + 373 int update_orbital_elements_from_position_and_velocity(); - 383 + 374 std::array<double, 6> get_orbital_elements(); - 384 + 375 - 385 + 376 std::pair<double, int> evolve_RK45( - 386 + 377 const double input_epsilon, const double input_initial_timestep, - 387 + 378 const bool perturbation = true, const bool atmospheric_drag = false, - 388 + 379 std::pair<double, double> drag_elements = {}); - 389 + 380 - 390 + 381 double get_orbital_parameter(const std::string orbital_parameter_name); - 391 + 382 double calculate_instantaneous_orbit_rate(); - 392 + 383 double calculate_instantaneous_orbit_angular_acceleration(); - 393 + 384 void initialize_and_normalize_body_quaternion(const double roll_angle, - 394 + 385 const double pitch_angle, - 395 + 386 const double yaw_angle); - 396 + 387 double get_attitude_val(const std::string input_attitude_val_name); - 397 + 388 double calculate_orbital_period(); - 398 + 389 int add_arg_of_periapsis_change_thrust(); - 399 + 390 void check_for_maneuvers_to_initialize(); - 400 + 391 void add_maneuver(const std::string maneuver_type, - 401 + 392 const double maneuver_start_time, - 402 + 393 const double final_parameter_val, - 403 + 394 const double thrust_magnitude); - 404 + 395 }; - 405 + 396 - 406 + 397 #endif - 407 + 398 diff --git a/tests/test_coverage_detailed.functions.html b/tests/test_coverage_detailed.functions.html index 3fcc3be..3f46d8f 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-05-11 21:11:47 + 2025-05-27 18:19:02 @@ -37,21 +37,21 @@

GCC Code Coverage Report

Lines: - 1730 - 1841 - 94.0% + 2028 + 2165 + 93.7% Functions: - 81 - 82 + 85 + 86 98.8% Branches: - 806 - 1335 - 60.4% + 1179 + 2092 + 56.4% @@ -70,7 +70,7 @@

GCC Code Coverage Report

BodyframeTorqueProfile::BodyframeTorqueProfile(double, double, std::__1::array<double, 3ul>) (include/Satellite.h:92)called 42 times100.0% BodyframeTorqueProfile::BodyframeTorqueProfile(double, double, std::__1::array<double, 3ul>, double) (include/Satellite.h:98)called 2 times100.0% BodyframeTorqueProfile::operator==(BodyframeTorqueProfile const&) (include/Satellite.h:109)called 1 time100.0% - LVLH_to_body_transformation_matrix_from_quaternion(std::__1::array<double, 4ul>) (src/utils.cpp:940)called 12466918 times81.0% + LVLH_to_body_transformation_matrix_from_quaternion(std::__1::array<double, 4ul>) (src/utils.cpp:1399)called 12533871 times81.0% PhasedArrayGroundStation::PhasedArrayGroundStation(PhasedArrayGroundStation const&) (include/PhasedArrayGroundStation.h:12)called 648 times100.0% PhasedArrayGroundStation::PhasedArrayGroundStation(double, double, double, double, int) (include/PhasedArrayGroundStation.h:32)called 10 times100.0% PhasedArrayGroundStation::angle_to_satellite_from_normal(Satellite) (src/PhasedArrayGroundStation.cpp:39)called 8749080 times100.0% @@ -80,75 +80,79 @@

GCC Code Coverage Report

PhasedArrayGroundStation::num_sats_connected_at_this_time(double) (src/PhasedArrayGroundStation.cpp:79)called 8747784 times84.0% PhasedArrayGroundStation::update_linked_sats_map(unsigned long, double, double) (src/PhasedArrayGroundStation.cpp:124)called 714942 times77.0% PhasedArrayGroundStation::~PhasedArrayGroundStation() (include/PhasedArrayGroundStation.h:12)called 658 times100.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:1116)called 81831276 times88.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:352)called 81831276 times83.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:1048)called 81831276 times87.0% - Satellite::Satellite(Satellite const&) (include/Satellite.h:118)called 26974378 times100.0% - Satellite::Satellite(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (include/Satellite.h:188)called 132 times100.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:1575)called 82233540 times88.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:355)called 82233540 times83.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:1507)called 82233540 times87.0% + Satellite::Satellite(Satellite const&) (include/Satellite.h:118)called 26974510 times100.0% + Satellite::Satellite(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (include/Satellite.h:188)called 162 times100.0% Satellite::add_LVLH_thrust_profile(double, double, double) (src/Satellite.cpp:289)not called0.0% Satellite::add_LVLH_thrust_profile(std::__1::array<double, 3ul>, double, double) (src/Satellite.cpp:249)called 10 times100.0% Satellite::add_LVLH_thrust_profile(std::__1::array<double, 3ul>, double, double, double) (src/Satellite.cpp:264)called 3495723 times100.0% - Satellite::add_arg_of_periapsis_change_thrust() (src/Satellite.cpp:710)called 12466918 times100.0% + Satellite::add_arg_of_periapsis_change_thrust() (src/Satellite.cpp:710)called 12533871 times100.0% Satellite::add_bodyframe_torque_profile(std::__1::array<double, 3ul>, double, double) (src/Satellite.cpp:581)called 10 times100.0% Satellite::add_bodyframe_torque_profile(std::__1::array<double, 3ul>, double, double, double) (src/Satellite.cpp:594)called 10 times85.0% Satellite::add_maneuver(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, double, double, double) (src/Satellite.cpp:758)called 2 times50.0% - Satellite::calculate_instantaneous_orbit_angular_acceleration() (src/Satellite.cpp:635)called 12466975 times100.0% - Satellite::calculate_instantaneous_orbit_rate() (src/Satellite.cpp:615)called 12466975 times100.0% - Satellite::calculate_orbital_period() (src/Satellite.cpp:18)called 58 times100.0% - Satellite::calculate_perifocal_position() (src/Satellite.cpp:25)called 57 times100.0% - Satellite::calculate_perifocal_velocity() (src/Satellite.cpp:44)called 57 times100.0% - Satellite::check_for_maneuvers_to_initialize() (src/Satellite.cpp:734)called 12466918 times87.0% - Satellite::convert_ECI_to_perifocal(std::__1::array<double, 3ul>) (src/Satellite.cpp:112)called 74801508 times100.0% - Satellite::convert_perifocal_to_ECI(std::__1::array<double, 3ul>) (src/Satellite.cpp:62)called 114 times100.0% - Satellite::evolve_RK45(double, double, bool, bool, std::__1::pair<double, double>) (src/Satellite.cpp:406)called 12466918 times84.0% - Satellite::get_ECI_position() (include/Satellite.h:307)called 13489787 times100.0% - Satellite::get_attitude_val(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/Satellite.cpp:672)called 96215 times92.0% - Satellite::get_instantaneous_time() (include/Satellite.h:342)called 25941200 times100.0% - Satellite::get_mass() (include/Satellite.h:341)called 4 times100.0% - Satellite::get_name() (include/Satellite.h:343)called 2737 times100.0% + Satellite::calculate_instantaneous_orbit_angular_acceleration() (src/Satellite.cpp:635)called 12533943 times100.0% + Satellite::calculate_instantaneous_orbit_rate() (src/Satellite.cpp:615)called 12533943 times100.0% + Satellite::calculate_orbital_period() (src/Satellite.cpp:18)called 73 times100.0% + Satellite::calculate_perifocal_position() (src/Satellite.cpp:25)called 72 times100.0% + Satellite::calculate_perifocal_velocity() (src/Satellite.cpp:44)called 72 times100.0% + Satellite::check_for_maneuvers_to_initialize() (src/Satellite.cpp:734)called 12533871 times87.0% + Satellite::convert_ECI_to_perifocal(std::__1::array<double, 3ul>) (src/Satellite.cpp:112)called 75203226 times100.0% + Satellite::convert_perifocal_to_ECI(std::__1::array<double, 3ul>) (src/Satellite.cpp:62)called 144 times100.0% + Satellite::evolve_RK45(double, double, bool, bool, std::__1::pair<double, double>) (src/Satellite.cpp:406)called 12533871 times84.0% + Satellite::get_ECI_position() (include/Satellite.h:307)called 13556753 times100.0% + Satellite::get_ECI_velocity() (include/Satellite.h:308)called 66966 times100.0% + Satellite::get_attitude_val(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/Satellite.cpp:672)called 765875 times92.0% + Satellite::get_instantaneous_time() (include/Satellite.h:333)called 26008166 times100.0% + Satellite::get_mass() (include/Satellite.h:332)called 4 times100.0% + Satellite::get_name() (include/Satellite.h:334)called 2758 times100.0% Satellite::get_orbital_elements() (src/Satellite.cpp:395)called 9 times100.0% - Satellite::get_orbital_parameter(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/Satellite.cpp:555)called 95672 times91.0% - Satellite::get_radius() (include/Satellite.h:320)called 49877272 times100.0% + Satellite::get_orbital_parameter(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/Satellite.cpp:555)called 698366 times91.0% + Satellite::get_radius() (include/Satellite.h:320)called 50212080 times100.0% Satellite::get_radius_ECI() (include/Satellite.h:327)called 2 times100.0% - Satellite::get_speed() (include/Satellite.h:309)called 12476282 times100.0% + Satellite::get_speed() (include/Satellite.h:309)called 12610201 times100.0% Satellite::get_speed_ECI() (include/Satellite.h:316)called 2 times100.0% - Satellite::get_total_energy() (include/Satellite.h:331)called 9352 times100.0% - Satellite::initialize_and_normalize_body_quaternion(double, double, double) (src/Satellite.cpp:661)called 59 times100.0% - Satellite::initialize_body_angular_velocity_vec_wrt_LVLH_in_body_frame() (src/Satellite.cpp:701)called 57 times100.0% + Satellite::get_total_energy() (src/Satellite.cpp:769)called 76318 times100.0% + Satellite::initialize_and_normalize_body_quaternion(double, double, double) (src/Satellite.cpp:661)called 74 times100.0% + Satellite::initialize_body_angular_velocity_vec_wrt_LVLH_in_body_frame() (src/Satellite.cpp:701)called 72 times100.0% Satellite::operator=(Satellite const&) (include/Satellite.h:118)called 2052 times100.0% - Satellite::update_orbital_elements_from_position_and_velocity() (src/Satellite.cpp:298)called 12466920 times81.0% - Satellite::~Satellite() (include/Satellite.h:118)called 26974492 times100.0% - SimParameters::SimParameters(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (include/utils.h:32)called 10 times100.0% - SimParameters::~SimParameters() (include/utils.h:19)called 10 times100.0% + Satellite::update_orbital_elements_from_position_and_velocity() (src/Satellite.cpp:298)called 12533873 times81.0% + Satellite::~Satellite() (include/Satellite.h:118)called 26974654 times100.0% + SimParameters::SimParameters(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (include/utils.h:32)called 24 times100.0% + SimParameters::~SimParameters() (include/utils.h:19)called 24 times100.0% ThrustProfileLVLH::ThrustProfileLVLH(double, double, double, double, double, double, double) (include/Satellite.h:50)called 4 times100.0% ThrustProfileLVLH::ThrustProfileLVLH(double, double, std::__1::array<double, 3ul>) (include/Satellite.h:33)called 22 times100.0% ThrustProfileLVLH::ThrustProfileLVLH(double, double, std::__1::array<double, 3ul>, double) (include/Satellite.h:39)called 6991448 times100.0% ThrustProfileLVLH::operator==(ThrustProfileLVLH const&) (include/Satellite.h:79)called 1 time100.0% - add_lowthrust_orbit_transfer(Satellite&, double, double, double) (src/utils.cpp:1626)called 2 times55.0% - calculate_omega_I(Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, double) (src/utils.cpp:1093)called 12466918 times100.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:159)called 81831276 times97.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:961)called 81831276 times100.0% - construct_J_matrix(double, double, double) (src/utils.cpp:1106)called 12466918 times100.0% - convert_ECEF_to_ECI(Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (src/utils.cpp:1252)called 13480446 times100.0% - convert_LVLH_to_ECI_manual(std::__1::array<double, 3ul>, std::__1::array<double, 3ul>, std::__1::array<double, 3ul>) (src/utils.cpp:39)called 32144804 times75.0% - convert_array_from_LVLH_to_bodyframe(std::__1::array<double, 3ul>, double, double, double) (src/utils.cpp:1220)called 57 times100.0% - convert_cylindrical_to_cartesian(double, double, double, double) (src/utils.cpp:138)called 36697704 times100.0% - convert_lat_long_to_ECEF(double, double, double) (src/utils.cpp:1234)called 5 times100.0% - convert_quaternion_to_roll_yaw_pitch_angles(std::__1::array<double, 4ul>) (src/utils.cpp:1189)called 12466918 times100.0% - normalize_quaternion(std::__1::array<double, 4ul>) (src/utils.cpp:1177)called 12466977 times100.0% - quaternion_kinematics_equation(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>) (src/utils.cpp:1019)called 81831276 times77.0% - quaternion_multiplication(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 4, 1, 0, 4, 1>) (src/utils.cpp:17)called 118 times77.0% - rollyawpitch_angles_to_quaternion(double, double, double) (src/utils.cpp:924)called 59 times100.0% - rollyawpitch_bodyframe_to_LVLH_matrix(double, double, double) (src/utils.cpp:902)called 57 times100.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:390)called 18 times79.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:749)called 180 times82.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:1270)called 162 times77.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:1447)called 162 times81.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:567)called 162 times81.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:348)called 13638546 times87.0% - x_rot_matrix(double) (src/utils.cpp:739)called 57 times81.0% - y_rot_matrix(double) (src/utils.cpp:731)called 57 times81.0% - z_rot_matrix(double) (src/utils.cpp:723)called 13480503 times81.0% + add_lowthrust_orbit_transfer(Satellite&, double, double, double) (src/utils.cpp:2085)called 2 times55.0% + calculate_omega_I(Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, double) (src/utils.cpp:1552)called 12533871 times100.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:162)called 82233540 times97.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:1420)called 82233540 times100.0% + construct_J_matrix(double, double, double) (src/utils.cpp:1565)called 12533871 times100.0% + convert_ECEF_to_ECI(Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (src/utils.cpp:1711)called 13480446 times100.0% + convert_LVLH_to_ECI_manual(std::__1::array<double, 3ul>, std::__1::array<double, 3ul>, std::__1::array<double, 3ul>) (src/utils.cpp:42)called 32144804 times75.0% + convert_array_from_LVLH_to_bodyframe(std::__1::array<double, 3ul>, double, double, double) (src/utils.cpp:1679)called 72 times100.0% + convert_cylindrical_to_cartesian(double, double, double, double) (src/utils.cpp:141)called 37099968 times100.0% + convert_lat_long_to_ECEF(double, double, double) (src/utils.cpp:1693)called 5 times100.0% + convert_quaternion_to_roll_yaw_pitch_angles(std::__1::array<double, 4ul>) (src/utils.cpp:1648)called 12533871 times100.0% + normalize_quaternion(std::__1::array<double, 4ul>) (src/utils.cpp:1636)called 12533945 times100.0% + plot_2D_from_datafile(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<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>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (src/utils.cpp:719)called 2 times69.0% + plot_3D_from_datafile(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<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>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, double, double, double) (src/utils.cpp:611)called 2 times66.0% + quaternion_kinematics_equation(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>) (src/utils.cpp:1478)called 82233540 times77.0% + quaternion_multiplication(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 4, 1, 0, 4, 1>) (src/utils.cpp:20)called 148 times77.0% + rollyawpitch_angles_to_quaternion(double, double, double) (src/utils.cpp:1383)called 74 times100.0% + rollyawpitch_bodyframe_to_LVLH_matrix(double, double, double) (src/utils.cpp:1361)called 72 times100.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:849)called 18 times79.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:1208)called 180 times82.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:1729)called 162 times77.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:1906)called 162 times81.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:1026)called 162 times81.0% + sim_and_write_to_file(std::__1::vector<Satellite, std::__1::allocator<Satellite>>, SimParameters const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, double) (src/utils.cpp:395)called 7 times79.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:348)called 13705590 times87.0% + x_rot_matrix(double) (src/utils.cpp:1198)called 72 times81.0% + y_rot_matrix(double) (src/utils.cpp:1190)called 72 times81.0% + z_rot_matrix(double) (src/utils.cpp:1182)called 13480518 times81.0%
diff --git a/tests/test_coverage_detailed.html b/tests/test_coverage_detailed.html index 8306fe9..14f4da2 100644 --- a/tests/test_coverage_detailed.html +++ b/tests/test_coverage_detailed.html @@ -22,7 +22,7 @@

GCC Code Coverage Report

Date: - 2025-05-11 21:11:47 + 2025-05-27 18:19:02 Coverage: @@ -45,21 +45,21 @@

GCC Code Coverage Report

Lines: - 1730 - 1841 - 94.0% + 2028 + 2165 + 93.7% Functions: - 81 - 82 + 85 + 86 98.8% Branches: - 806 - 1335 - 60.4% + 1179 + 2092 + 56.4% @@ -108,7 +108,7 @@

GCC Code Coverage Report

100.0 100.0% - 201 / 201 + 195 / 195 100.0% 20 / 20 61.8% @@ -153,12 +153,12 @@

GCC Code Coverage Report

src/Satellite.cpp - 95.5 + 95.7 - 95.5% - 406 / 425 - 95.5% - 21 / 22 + 95.7% + 418 / 437 + 95.7% + 22 / 23 80.0% 104 / 130 @@ -172,11 +172,11 @@

GCC Code Coverage Report

91.7 91.7% - 913 / 996 + 1205 / 1314 100.0% - 28 / 28 - 58.6% - 437 / 746 + 31 / 31 + 53.9% + 810 / 1503 diff --git a/tests/test_coverage_detailed.utils.cpp.4d3039dff574b788948119de402ca8d9.html b/tests/test_coverage_detailed.utils.cpp.4d3039dff574b788948119de402ca8d9.html index b137e23..8cff8a8 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-05-11 21:11:47 + 2025-05-27 18:19:02 @@ -40,21 +40,21 @@

GCC Code Coverage Report

Lines: - 913 - 996 + 1205 + 1314 91.7% Functions: - 28 - 28 + 31 + 31 100.0% Branches: - 437 - 746 - 58.6% + 810 + 1503 + 53.9% @@ -70,34 +70,37 @@

GCC Code Coverage Report

Call count Block coverage - LVLH_to_body_transformation_matrix_from_quaternion(std::__1::array<double, 4ul>) (line 940)called 12466918 times81.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 1116)called 81831276 times88.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 352)called 81831276 times83.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 1048)called 81831276 times87.0% - add_lowthrust_orbit_transfer(Satellite&, double, double, double) (line 1626)called 2 times55.0% - calculate_omega_I(Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, double) (line 1093)called 12466918 times100.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 159)called 81831276 times97.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 961)called 81831276 times100.0% - construct_J_matrix(double, double, double) (line 1106)called 12466918 times100.0% - convert_ECEF_to_ECI(Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (line 1252)called 13480446 times100.0% - convert_LVLH_to_ECI_manual(std::__1::array<double, 3ul>, std::__1::array<double, 3ul>, std::__1::array<double, 3ul>) (line 39)called 32144804 times75.0% - convert_array_from_LVLH_to_bodyframe(std::__1::array<double, 3ul>, double, double, double) (line 1220)called 57 times100.0% - convert_cylindrical_to_cartesian(double, double, double, double) (line 138)called 36697704 times100.0% - convert_lat_long_to_ECEF(double, double, double) (line 1234)called 5 times100.0% - convert_quaternion_to_roll_yaw_pitch_angles(std::__1::array<double, 4ul>) (line 1189)called 12466918 times100.0% - normalize_quaternion(std::__1::array<double, 4ul>) (line 1177)called 12466977 times100.0% - quaternion_kinematics_equation(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>) (line 1019)called 81831276 times77.0% - quaternion_multiplication(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 4, 1, 0, 4, 1>) (line 17)called 118 times77.0% - rollyawpitch_angles_to_quaternion(double, double, double) (line 924)called 59 times100.0% - rollyawpitch_bodyframe_to_LVLH_matrix(double, double, double) (line 902)called 57 times100.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 390)called 18 times79.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 749)called 180 times82.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 1270)called 162 times77.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 1447)called 162 times81.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 567)called 162 times81.0% - x_rot_matrix(double) (line 739)called 57 times81.0% - y_rot_matrix(double) (line 731)called 57 times81.0% - z_rot_matrix(double) (line 723)called 13480503 times81.0% + LVLH_to_body_transformation_matrix_from_quaternion(std::__1::array<double, 4ul>) (line 1399)called 12533871 times81.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 1575)called 82233540 times88.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 355)called 82233540 times83.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 1507)called 82233540 times87.0% + add_lowthrust_orbit_transfer(Satellite&, double, double, double) (line 2085)called 2 times55.0% + calculate_omega_I(Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, double) (line 1552)called 12533871 times100.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 162)called 82233540 times97.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 1420)called 82233540 times100.0% + construct_J_matrix(double, double, double) (line 1565)called 12533871 times100.0% + convert_ECEF_to_ECI(Eigen::Matrix<double, 3, 1, 0, 3, 1>, double) (line 1711)called 13480446 times100.0% + convert_LVLH_to_ECI_manual(std::__1::array<double, 3ul>, std::__1::array<double, 3ul>, std::__1::array<double, 3ul>) (line 42)called 32144804 times75.0% + convert_array_from_LVLH_to_bodyframe(std::__1::array<double, 3ul>, double, double, double) (line 1679)called 72 times100.0% + convert_cylindrical_to_cartesian(double, double, double, double) (line 141)called 37099968 times100.0% + convert_lat_long_to_ECEF(double, double, double) (line 1693)called 5 times100.0% + convert_quaternion_to_roll_yaw_pitch_angles(std::__1::array<double, 4ul>) (line 1648)called 12533871 times100.0% + normalize_quaternion(std::__1::array<double, 4ul>) (line 1636)called 12533945 times100.0% + plot_2D_from_datafile(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<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>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 719)called 2 times69.0% + plot_3D_from_datafile(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<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>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, double, double, double) (line 611)called 2 times66.0% + quaternion_kinematics_equation(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>) (line 1478)called 82233540 times77.0% + quaternion_multiplication(Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 4, 1, 0, 4, 1>) (line 20)called 148 times77.0% + rollyawpitch_angles_to_quaternion(double, double, double) (line 1383)called 74 times100.0% + rollyawpitch_bodyframe_to_LVLH_matrix(double, double, double) (line 1361)called 72 times100.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 849)called 18 times79.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 1208)called 180 times82.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 1729)called 162 times77.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 1906)called 162 times81.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 1026)called 162 times81.0% + sim_and_write_to_file(std::__1::vector<Satellite, std::__1::allocator<Satellite>>, SimParameters const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, double) (line 395)called 7 times79.0% + x_rot_matrix(double) (line 1198)called 72 times81.0% + y_rot_matrix(double) (line 1190)called 72 times81.0% + z_rot_matrix(double) (line 1182)called 13480518 times81.0% @@ -158,21 +161,21 @@

GCC Code Coverage Report

- + #include <fstream> 8 - #include "PhasedArrayGroundStation.h" + #include <iomanip> 9 - #include "Satellite.h" + #include <stdexcept> 10 @@ -186,326 +189,347 @@

GCC Code Coverage Report

- using Eigen::Matrix3d; + #include "PhasedArrayGroundStation.h" 12 - using Eigen::Matrix4d; + #include "Satellite.h" 13 - using Eigen::Quaterniond; + 14 - using Eigen::Vector3d; + using Eigen::Matrix3d; 15 - using Eigen::Vector4d; + using Eigen::Matrix4d; 16 - + using Eigen::Quaterniond; 17 - 118 - Vector4d quaternion_multiplication(const Vector4d quaternion_1, + + using Eigen::Vector3d; 18 - const Vector4d quaternion_2) { + using Eigen::Vector4d; 19 - // Ref: https://en.wikipedia.org/wiki/Quaternion#Scalar_and_vector_parts + 20 - 118 - Vector3d quat_1_vec_component = { + 148 + Vector4d quaternion_multiplication(const Vector4d quaternion_1, 21 - 118 - quaternion_1(1), quaternion_1(2), + + const Vector4d quaternion_2) { 22 - 118 - quaternion_1(3)}; // Here adopting convention that scalar part is first + + // Ref: https://en.wikipedia.org/wiki/Quaternion#Scalar_and_vector_parts 23 + 148 + Vector3d quat_1_vec_component = { + + + 24 + + + 148 + quaternion_1(1), quaternion_1(2), + + + 25 + + + 148 + quaternion_1(3)}; // Here adopting convention that scalar part is first + + + 26 + + // element of quaternion - 24 + 27 - 236 + 296 Vector3d quat_2_vec_component = {quaternion_2(1), quaternion_2(2), - 25 + 28 - 118 + 148 quaternion_2(3)}; - 26 + 29 Vector3d vec_part_of_result = - 27 + 30 - 354 + 444 quaternion_1(0) * quat_2_vec_component + - 28 + 31 - 236 + 296 quaternion_2(0) * quat_1_vec_component + - 29 + 32 - 118 + 148 quat_1_vec_component.cross(quat_2_vec_component); - 30 + 33 - 118 + 148 Vector4d result; - 31 + 34 - 354 + 444 result << quaternion_1(0) * quaternion_2(0) - - 32 + 35
1/2
-
✓ Branch 0 taken 118 times.
+
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
- 118 + 148 quat_1_vec_component.dot(quat_2_vec_component), - 33 + 36
5/10
-
✓ Branch 0 taken 118 times.
+
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 118 times.
+
✓ Branch 2 taken 148 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 118 times.
+
✓ Branch 4 taken 148 times.
✗ Branch 5 not taken.
-
✓ Branch 6 taken 118 times.
+
✓ Branch 6 taken 148 times.
✗ Branch 7 not taken.
-
✓ Branch 8 taken 118 times.
+
✓ Branch 8 taken 148 times.
✗ Branch 9 not taken.
- 236 + 296 vec_part_of_result(0), vec_part_of_result(1), vec_part_of_result(2); - 34 + 37 - 118 + 148 return result; - 35 + 38} - 36 + 39 - 37 + 40 //"manual" version, via dot products and cross products with position and - 38 + 41 // velocity vectors - 39 + 42 32144804 std::array<double, 3> convert_LVLH_to_ECI_manual( - 40 + 43 const std::array<double, 3> input_LVLH_vec, - 41 + 44 const std::array<double, 3> input_position_vec, - 42 + 45 const std::array<double, 3> input_velocity_vec) { - 43 + 46 // LVLH x-axis is defined as in the direction of motion - 44 + 47 // LVLH z-axis is defined as pointing back towards Earth, so along the - 45 + 48 // reversed direction of the position vector from the center of the Earth - 46 + 49 // y-axis determined from a cross product - 47 + 50 - 48 + 51 32144804 Vector3d ECI_unit_vec_x = {1.0, 0.0, 0.0}; - 49 + 52 32144804 Vector3d ECI_unit_vec_y = {0.0, 1.0, 0.0}; - 50 + 53 32144804 Vector3d ECI_unit_vec_z = {0.0, 0.0, 1.0}; - 51 + 54 - 52 + 55 32144804 std::array<double, 3> current_ECI_position_array = input_position_vec; - 53 + 56 32144804 Vector3d current_ECI_position_unit_vec; - 54 + 57
1/2 @@ -519,7 +543,7 @@

GCC Code Coverage Report

current_ECI_position_unit_vec << current_ECI_position_array.at(0), - 55 + 58
3/6 @@ -537,42 +561,42 @@

GCC Code Coverage Report

current_ECI_position_array.at(1), current_ECI_position_array.at(2); - 56 + 59 current_ECI_position_unit_vec - 57 + 60 32144804 .normalize(); // to make it actually a unit vector - 58 + 61 - 59 + 62 32144804 std::array<double, 3> current_ECI_velocity_array = input_velocity_vec; - 60 + 63 32144804 Vector3d current_ECI_velocity_unit_vec; - 61 + 64
1/2 @@ -586,7 +610,7 @@

GCC Code Coverage Report

current_ECI_velocity_unit_vec << current_ECI_velocity_array.at(0), - 62 + 65
3/6 @@ -604,1022 +628,1022 @@

GCC Code Coverage Report

current_ECI_velocity_array.at(1), current_ECI_velocity_array.at(2); - 63 + 66 32144804 current_ECI_velocity_unit_vec.normalize(); - 64 + 67 - 65 + 68 32144804 Vector3d LVLH_x_unit_vec = current_ECI_velocity_unit_vec; - 66 + 69 32144804 Vector3d LVLH_z_unit_vec = (-1) * current_ECI_position_unit_vec; - 67 + 70 - 68 + 71 32144804 Vector3d LVLH_y_unit_vec = LVLH_z_unit_vec.cross(LVLH_x_unit_vec); - 69 + 72 // Should already be normalized, just in case though - 70 + 73 32144804 LVLH_y_unit_vec.normalize(); - 71 + 74 - 72 + 75 96434412 double v_x_ECI = input_LVLH_vec.at(0) * ECI_unit_vec_x.dot(LVLH_x_unit_vec) + - 73 + 76 64289608 input_LVLH_vec.at(1) * ECI_unit_vec_x.dot(LVLH_y_unit_vec) + - 74 + 77 32144804 input_LVLH_vec.at(2) * ECI_unit_vec_x.dot(LVLH_z_unit_vec); - 75 + 78 - 76 + 79 96434412 double v_y_ECI = input_LVLH_vec.at(0) * ECI_unit_vec_y.dot(LVLH_x_unit_vec) + - 77 + 80 64289608 input_LVLH_vec.at(1) * ECI_unit_vec_y.dot(LVLH_y_unit_vec) + - 78 + 81 32144804 input_LVLH_vec.at(2) * ECI_unit_vec_y.dot(LVLH_z_unit_vec); - 79 + 82 - 80 + 83 96434412 double v_z_ECI = input_LVLH_vec.at(0) * ECI_unit_vec_z.dot(LVLH_x_unit_vec) + - 81 + 84 64289608 input_LVLH_vec.at(1) * ECI_unit_vec_z.dot(LVLH_y_unit_vec) + - 82 + 85 32144804 input_LVLH_vec.at(2) * ECI_unit_vec_z.dot(LVLH_z_unit_vec); - 83 + 86 - 84 + 87 32144804 std::array<double, 3> output_ECI_arr = {v_x_ECI, v_y_ECI, v_z_ECI}; - 85 + 88 32144804 return output_ECI_arr; - 86 + 89} - 87 + 90 - 88 + 91 // baselining cartesian coordinates in ECI frame - 89 + 92 - 90 + 93 // std::array<double, 3> calculate_orbital_acceleration( - 91 + 94 // const std::array<double, 3> input_r_vec, const double - 92 + 95 // input_spacecraft_mass, const std::vector<std::array<double, 3>> - 93 + 96 // input_vec_of_force_vectors_in_ECI) { - 94 + 97 // // Note: this is the version used in the RK4 solver - 95 + 98 // // orbital acceleration = -G m_Earth/distance^3 * r_vec (just based on - 96 + 99 // // rearranging F=ma with a the acceleration due to gravitational attraction - 97 + 100 // // between satellite and Earth - 98 + 101 // // https://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation) - 99 + 102 // // going to be assuming Earth's position doesn't change for now - 100 + 103 // // also assuming Earth is spherical, can loosen this assumption in the - 101 + 104 // future - 102 + 105 // // note: this is in ECI frame - 103 + 106 - 104 + 107 // std::array<double, 3> acceleration_vec_due_to_gravity = - 105 + 108 // input_r_vec; // shouldn't need to explicitly call copy function - 106 + 109 // because - 107 + 110 // // input_r_vec is passed by value not ref - 108 + 111 - 109 + 112 // // F=ma - 110 + 113 // // a=F/m = (F_grav + F_ext)/m = (F_grav/m) + (F_ext/m) = - 111 + 114 // -G*M_Earth/distance^3 - 112 + 115 // // + ... - 113 + 116 - 114 + 117 // const double distance = sqrt(input_r_vec.at(0) * input_r_vec.at(0) + - 115 + 118 // input_r_vec.at(1) * input_r_vec.at(1) + - 116 + 119 // input_r_vec.at(2) * input_r_vec.at(2)); - 117 + 120 // const double overall_factor = -G * mass_Earth / pow(distance, 3); - 118 + 121 - 119 + 122 // for (size_t ind = 0; ind < input_r_vec.size(); ind++) { - 120 + 123 // acceleration_vec_due_to_gravity.at(ind) *= overall_factor; - 121 + 124 // } - 122 + 125 - 123 + 126 // // now add effects from externally-applied forces, e.g., thrusters, if any - 124 + 127 // std::array<double, 3> acceleration_vec = acceleration_vec_due_to_gravity; - 125 + 128 - 126 + 129 // for (std::array<double, 3> external_force_vec_in_ECI : - 127 + 130 // input_vec_of_force_vectors_in_ECI) { - 128 + 131 // acceleration_vec.at(0) += - 129 + 132 // (external_force_vec_in_ECI.at(0) / input_spacecraft_mass); - 130 + 133 // acceleration_vec.at(1) += - 131 + 134 // (external_force_vec_in_ECI.at(1) / input_spacecraft_mass); - 132 + 135 // acceleration_vec.at(2) += - 133 + 136 // (external_force_vec_in_ECI.at(2) / input_spacecraft_mass); - 134 + 137 // } - 135 + 138 // return acceleration_vec; - 136 + 139 // } - 137 + 140 - 138 + 141 - 36697704 + 37099968 std::array<double, 3> convert_cylindrical_to_cartesian( - 139 + 142 const double input_r_comp, const double input_theta_comp, - 140 + 143 const double input_z_comp, const double input_theta) { - 141 + 144 - 36697704 + 37099968 std::array<double, 3> output_cartesian_vec = {0, 0, 0}; - 142 + 145 - 143 + 146 // Dot product method - 144 + 147 // See - 145 + 148 // https://en.wikipedia.org/wiki/Vector_fields_in_cylindrical_and_spherical_coordinates - 146 + 149 // for relation between unit vectors - 147 + 150 - 36697704 + 37099968 double x_comp = - 148 + 151 - 36697704 + 37099968 input_r_comp * cos(input_theta) + input_theta_comp * (-sin(input_theta)); - 149 + 152 - 36697704 + 37099968 double y_comp = - 150 + 153 - 36697704 + 37099968 input_r_comp * sin(input_theta) + input_theta_comp * (cos(input_theta)); - 151 + 154 - 36697704 + 37099968 double z_comp = input_z_comp; - 152 + 155 - 153 + 156 - 36697704 + 37099968 output_cartesian_vec.at(0) = x_comp; - 154 + 157 - 36697704 + 37099968 output_cartesian_vec.at(1) = y_comp; - 155 + 158 - 36697704 + 37099968 output_cartesian_vec.at(2) = z_comp; - 156 + 159 - 36697704 + 37099968 return output_cartesian_vec; - 157 + 160 } - 158 + 161 - 159 + 162 - 81831276 + 82233540 std::array<double, 3> calculate_orbital_acceleration( - 160 + 163 const std::array<double, 3> input_r_vec, const double input_spacecraft_mass, - 161 + 164 const std::vector<ThrustProfileLVLH> input_list_of_thrust_profiles_LVLH, - 162 + 165 const double input_evaluation_time, - 163 + 166 const std::array<double, 3> input_velocity_vec, - 164 + 167 const double input_inclination, const double input_arg_of_periapsis, - 165 + 168 const double input_true_anomaly, const double input_F_10, - 166 + 169 const double input_A_p, const double input_A_s, - 167 + 170 const double input_satellite_mass, const bool perturbation, - 168 + 171 const bool atmospheric_drag) { - 169 + 172 // Note: this is the version used in the RK45 solver (this has a more updated - 170 + 173 // workflow) orbital acceleration = -G m_Earth/distance^3 * r_vec (just based - 171 + 174 // on rearranging F=ma with a the acceleration due to gravitational attraction - 172 + 175 // between satellite and Earth - 173 + 176 // https://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation) - 174 + 177 // going to be assuming Earth's position doesn't change for now - 175 + 178 // also assuming Earth is spherical, can loosen this assumption in the future - 176 + 179 // note: this is in ECI frame (r_vec and velocity vec should also be in ECI - 177 + 180 // frame) - 178 + 181 - 179 + 182 std::array<double, 3> acceleration_vec_due_to_gravity = - 180 + 183 - 81831276 + 82233540 input_r_vec; // shouldn't need to explicitly call copy function because - 181 + 184 // input_r_vec is passed by value not ref - 182 + 185 - 183 + 186 // F=ma - 184 + 187 // a=F/m = (F_grav + F_ext)/m = (F_grav/m) + (F_ext/m) = -G*M_Earth/distance^3 - 185 + 188 // + ... - 186 + 189 - 187 + 190 - 245493828 + 246700620 const double distance = sqrt(input_r_vec.at(0) * input_r_vec.at(0) + - 188 + 191 - 163662552 + 164467080 input_r_vec.at(1) * input_r_vec.at(1) + - 189 + 192 - 81831276 + 82233540 input_r_vec.at(2) * input_r_vec.at(2)); - 190 + 193 - 81831276 + 82233540 const double overall_factor = -G * mass_Earth / pow(distance, 3); - 191 + 194 - 192 + 195
2/2
-
✓ Branch 0 taken 245493828 times.
-
✓ Branch 1 taken 81831276 times.
+
✓ Branch 0 taken 246700620 times.
+
✓ Branch 1 taken 82233540 times.
- 327325104 + 328934160 for (size_t ind = 0; ind < input_r_vec.size(); ind++) { - 193 + 196 - 245493828 + 246700620 acceleration_vec_due_to_gravity.at(ind) *= overall_factor; - 194 + 197 - 245493828 + 246700620 } - 195 + 198 - 196 + 199 - 81831276 + 82233540 std::array<double, 3> acceleration_vec = acceleration_vec_due_to_gravity; - 197 + 200 - 198 + 201 // now add effects from externally-applied forces, e.g., thrusters, if any - 199 + 202 - 200 + 203 std::vector<std::array<double, 3>> list_of_LVLH_forces_at_evaluation_time = - 201 + 204 - 81831276 + 82233540 {}; - 202 + 205 - 81831276 + 82233540 std::vector<std::array<double, 3>> list_of_ECI_forces_at_evaluation_time = {}; - 203 + 206 - 204 + 207
2/2
✓ Branch 0 taken 101916690 times.
-
✓ Branch 1 taken 81831276 times.
+
✓ Branch 1 taken 82233540 times.
- 183747966 + 184150230 for (const ThrustProfileLVLH thrust_profile : - 205 + 208 - 81831276 + 82233540 input_list_of_thrust_profiles_LVLH) { - 206 + 209
4/4 @@ -1635,7 +1659,7 @@

GCC Code Coverage Report

if ((input_evaluation_time >= thrust_profile.t_start_) && - 207 + 210
2/2 @@ -1649,14 +1673,14 @@

GCC Code Coverage Report

(input_evaluation_time <= thrust_profile.t_end_) && - 208 + 211 55358254 (thrust_profile.arg_of_periapsis_change_thrust_profile == false)) { - 209 + 212
1/2 @@ -1670,14 +1694,14 @@

GCC Code Coverage Report

list_of_LVLH_forces_at_evaluation_time.push_back( - 210 + 213 28649083 thrust_profile.LVLH_force_vec_); - 211 + 214
1/2 @@ -1691,14 +1715,14 @@

GCC Code Coverage Report

std::array<double, 3> ECI_thrust_vector = convert_LVLH_to_ECI_manual( - 212 + 215 28649083 thrust_profile.LVLH_force_vec_, input_r_vec, input_velocity_vec); - 213 + 216
1/2 @@ -1712,49 +1736,49 @@

GCC Code Coverage Report

list_of_ECI_forces_at_evaluation_time.push_back(ECI_thrust_vector); - 214 + 217 28649083 } - 215 + 218 } - 216 + 219 - 217 + 220
2/2
✓ Branch 0 taken 28649083 times.
-
✓ Branch 1 taken 81831276 times.
+
✓ Branch 1 taken 82233540 times.
- 110480359 + 110882623 for (std::array<double, 3> external_force_vec_in_ECI : - 218 + 221 - 81831276 + 82233540 list_of_ECI_forces_at_evaluation_time) { - 219 + 222
1/2 @@ -1768,7 +1792,7 @@

GCC Code Coverage Report

acceleration_vec.at(0) += - 220 + 223
1/2 @@ -1782,7 +1806,7 @@

GCC Code Coverage Report

(external_force_vec_in_ECI.at(0) / input_spacecraft_mass); - 221 + 224
1/2 @@ -1796,7 +1820,7 @@

GCC Code Coverage Report

acceleration_vec.at(1) += - 222 + 225
1/2 @@ -1810,7 +1834,7 @@

GCC Code Coverage Report

(external_force_vec_in_ECI.at(1) / input_spacecraft_mass); - 223 + 226
1/2 @@ -1824,7 +1848,7 @@

GCC Code Coverage Report

acceleration_vec.at(2) += - 224 + 227
1/2 @@ -1838,407 +1862,407 @@

GCC Code Coverage Report

(external_force_vec_in_ECI.at(2) / input_spacecraft_mass); - 225 + 228 } - 226 + 229 - 227 + 230
2/2
-
✓ Branch 0 taken 36697704 times.
+
✓ Branch 0 taken 37099968 times.
✓ Branch 1 taken 45133572 times.
- 81831276 + 82233540 if (perturbation) { - 228 + 231 // If accounting for J2 perturbation - 229 + 232 - 230 + 233 // Now let's add the additional acceleration components due to the J2 - 231 + 234 // perturbation Ref: - 232 + 235 // https://vatankhahghadim.github.io/AER506/Notes/6%20-%20Orbital%20Perturbations.pdf - 233 + 236 - 36697704 + 37099968 double J2 = 1.083 * pow(10, -3); - 234 + 237 - 36697704 + 37099968 const double mu_Earth = G * mass_Earth; - 235 + 238 - 73395408 + 74199936 double C = 3 * mu_Earth * J2 * radius_Earth * radius_Earth / - 236 + 239 - 36697704 + 37099968 (2 * pow(distance, 4)); - 237 + 240
1/2
-
✓ Branch 0 taken 36697704 times.
+
✓ Branch 0 taken 37099968 times.
✗ Branch 1 not taken.
- 36697704 + 37099968 double x = input_r_vec.at(0); - 238 + 241
1/2
-
✓ Branch 0 taken 36697704 times.
+
✓ Branch 0 taken 37099968 times.
✗ Branch 1 not taken.
- 36697704 + 37099968 double y = input_r_vec.at(1); - 239 + 242 - 36697704 + 37099968 double rho = sqrt(pow(x, 2) + pow(y, 2)); - 240 + 243 double theta; - 241 + 244 // Ref: - 242 + 245 // https://en.wikipedia.org/wiki/Cylindrical_coordinate_system#Line_and_volume_elements - 243 + 246
2/2
-
✓ Branch 0 taken 14214099 times.
-
✓ Branch 1 taken 22483605 times.
+
✓ Branch 0 taken 14342319 times.
+
✓ Branch 1 taken 22757649 times.
- 36697704 + 37099968 if (x >= 0) { - 244 + 247 - 14214099 + 14342319 theta = asin( - 245 + 248 - 14214099 + 14342319 y / rho); // Note: here setting theta=0 even if both x and y are - 246 + 249 // zero, whereas it should technically be indeterminate, - 247 + 250 // but I'm going to assume this edge condition won't be hit - 248 + 251 // and I don't want undefined behavior - 249 + 252 - 14214099 + 14342319 } else { - 250 + 253
2/2
-
✓ Branch 0 taken 11762631 times.
-
✓ Branch 1 taken 10720974 times.
+
✓ Branch 0 taken 11868990 times.
+
✓ Branch 1 taken 10888659 times.
- 22483605 + 22757649 if (y >= 0) { - 251 + 254 - 11762631 + 11868990 theta = -asin(y / rho) + M_PI; - 252 + 255 - 11762631 + 11868990 } else { - 253 + 256 - 10720974 + 10888659 theta = -asin(y / rho) - M_PI; - 254 + 257 } - 255 + 258 } - 256 + 259 - 257 + 260 - 36697704 + 37099968 double a_r = - 258 + 261 - 73395408 + 74199936 C * (3 * pow(sin(input_inclination), 2) * - 259 + 262 - 36697704 + 37099968 pow(sin(input_arg_of_periapsis + input_true_anomaly), 2) - - 260 + 263 1); - 261 + 264 - 73395408 + 74199936 double a_theta = -C * pow(sin(input_inclination), 2) * - 262 + 265 - 36697704 + 37099968 sin(2 * (input_arg_of_periapsis + input_true_anomaly)); - 263 + 266 - 73395408 + 74199936 double a_z = -C * sin(2 * input_inclination) * - 264 + 267 - 36697704 + 37099968 sin(input_arg_of_periapsis + input_true_anomaly); - 265 + 268 std::array<double, 3> cartesian_acceleration_components = - 266 + 269
1/2
-
✓ Branch 0 taken 36697704 times.
+
✓ Branch 0 taken 37099968 times.
✗ Branch 1 not taken.
- 36697704 + 37099968 convert_cylindrical_to_cartesian(a_r, a_theta, a_z, theta); - 267 + 270 - 268 + 271
2/2
-
✓ Branch 0 taken 36697704 times.
-
✓ Branch 1 taken 110093112 times.
+
✓ Branch 0 taken 37099968 times.
+
✓ Branch 1 taken 111299904 times.
- 146790816 + 148399872 for (size_t ind = 0; ind < 3; ind++) { - 269 + 272
2/4
-
✓ Branch 0 taken 110093112 times.
+
✓ Branch 0 taken 111299904 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 110093112 times.
+
✓ Branch 2 taken 111299904 times.
✗ Branch 3 not taken.
- 110093112 + 111299904 acceleration_vec.at(ind) += cartesian_acceleration_components.at(ind); - 270 + 273 - 110093112 + 111299904 } - 271 + 274 - 36697704 + 37099968 } - 272 + 275 - 81831276 + 82233540 double altitude = (distance - radius_Earth) / 1000.0; // km - 273 + 276
5/6
✓ Branch 0 taken 18323160 times.
-
✓ Branch 1 taken 63508116 times.
+
✓ Branch 1 taken 63910380 times.
✓ Branch 2 taken 18323160 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 178356 times.
@@ -2246,25 +2270,25 @@

GCC Code Coverage Report

- 81831276 + 82233540 if ((atmospheric_drag) && (altitude >= 140) && (altitude <= 400)) { - 274 + 277 // Refs: https://angeo.copernicus.org/articles/39/397/2021/ - 275 + 278 // https://www.spaceacademy.net.au/watch/debris/atmosmod.htm - 276 + 279
1/2 @@ -2278,7 +2302,7 @@

GCC Code Coverage Report

double speed = sqrt(pow(input_velocity_vec.at(0), 2) + - 277 + 280
1/2 @@ -2292,7 +2316,7 @@

GCC Code Coverage Report

pow(input_velocity_vec.at(1), 2) + - 278 + 281
1/2 @@ -2306,21 +2330,21 @@

GCC Code Coverage Report

pow(input_velocity_vec.at(2), 2)); - 279 + 282 // First, esimate atmospheric density - 280 + 283 178356 double rho = {0}; - 281 + 284
2/2 @@ -2334,196 +2358,196 @@

GCC Code Coverage Report

if (altitude < 180) { - 282 + 285 552 double a0 = 7.001985 * pow(10, -2); - 283 + 286 552 double a1 = -4.336216 * pow(10, -3); - 284 + 287 552 double a2 = -5.009831 * pow(10, -3); - 285 + 288 552 double a3 = 1.621827 * pow(10, -4); - 286 + 289 552 double a4 = -2.471283 * pow(10, -6); - 287 + 290 552 double a5 = 1.904383 * pow(10, -8); - 288 + 291 552 double a6 = -7.189421 * pow(10, -11); - 289 + 292 552 double a7 = 1.060067 * pow(10, -13); - 290 + 293 1656 double fit_val = a0 + a1 * altitude + a2 * pow(altitude, 2) + - 291 + 294 1656 a3 * pow(altitude, 3) + a4 * pow(altitude, 4) + - 292 + 295 1656 a5 * pow(altitude, 5) + a6 * pow(altitude, 6) + - 293 + 296 552 a7 * pow(altitude, 7); - 294 + 297 - 295 + 298 552 rho = pow(10, fit_val); - 296 + 299 552 } else { - 297 + 300 177804 double T = 900 + 2.5 * (input_F_10 - 70) + 1.5 * input_A_p; - 298 + 301 177804 double new_mu = 27 - 0.012 * (altitude - 200); - 299 + 302 177804 double H = T / new_mu; - 300 + 303 177804 rho = 6 * pow(10, -10) * exp(-(altitude - 175) / H); - 301 + 304 } - 302 + 305 - 303 + 306 // Now estimate the satellite's ballistic coefficient B - 304 + 307 178356 double C_d = 2.2; - 305 + 308 178356 double B = C_d * input_A_s / input_satellite_mass; - 306 + 309 178356 double drag_deceleration = (1.0 / 2.0) * rho * B * pow(speed, 2); - 307 + 310 // Should act in direction directly opposite to velocity - 308 + 311 178356 std::array<double, 3> velocity_unit_vec = {0.0, 0.0, 0.0}; - 309 + 312
2/2 @@ -2537,7 +2561,7 @@

GCC Code Coverage Report

for (size_t ind = 0; ind < 3; ind++) { - 310 + 313
2/4 @@ -2553,21 +2577,21 @@

GCC Code Coverage Report

velocity_unit_vec.at(ind) = input_velocity_vec.at(ind) / speed; - 311 + 314 535068 } - 312 + 315 178356 std::array<double, 3> drag_acceleration_vec = {0.0, 0.0, 0.0}; - 313 + 316
2/2 @@ -2581,7 +2605,7 @@

GCC Code Coverage Report

for (size_t ind = 0; ind < 3; ind++) { - 314 + 317
1/2 @@ -2595,7 +2619,7 @@

GCC Code Coverage Report

drag_acceleration_vec.at(ind) = - 315 + 318
1/2 @@ -2609,28 +2633,28 @@

GCC Code Coverage Report

drag_deceleration * (-1) * velocity_unit_vec.at(ind); - 316 + 319 // Factor of (-1) because this acceleration acts in direction opposite to - 317 + 320 // velocity - 318 + 321 535068 } - 319 + 322
2/2 @@ -2644,7 +2668,7 @@

GCC Code Coverage Report

for (size_t ind = 0; ind < 3; ind++) { - 320 + 323
2/4 @@ -2660,532 +2684,5429 @@

GCC Code Coverage Report

acceleration_vec.at(ind) += drag_acceleration_vec.at(ind); - 321 + 324 535068 } - 322 + 325 178356 } - 323 + 326 - 324 + 327 return acceleration_vec; - 325 + 328 - 81831276 + 82233540 } - 326 + 329 - 327 + 330 // std::array<double, 6> RK4_deriv_function_orbit_position_and_velocity( - 328 + 331 // const std::array<double, 6> input_position_and_velocity, - 329 + 332 // const double input_spacecraft_mass, - 330 + 333 // const std::vector<std::array<double, 3>> - 331 + 334 // input_vec_of_force_vectors_in_ECI) { - 332 + 335 // std::array<double, 6> derivative_of_input_y = {}; - 333 + 336 // std::array<double, 3> position_array = {}; - 334 + 337 - 335 + 338 // for (size_t ind = 0; ind < 3; ind++) { - 336 + 339 // derivative_of_input_y.at(ind) = input_position_and_velocity.at(ind + 3); - 337 + 340 // position_array.at(ind) = input_position_and_velocity.at(ind); - 338 + 341 // } - 339 + 342 - 340 + 343 // std::array<double, 3> calculated_orbital_acceleration = - 341 + 344 // calculate_orbital_acceleration(position_array, input_spacecraft_mass, - 342 + 345 // input_vec_of_force_vectors_in_ECI); - 343 + 346 - 344 + 347 // for (size_t ind = 3; ind < 6; ind++) { - 345 + 348 // derivative_of_input_y.at(ind) = calculated_orbital_acceleration.at(ind - - 346 + 349 // 3); - 347 + 350 // } - 348 + 351 - 349 + 352 // return derivative_of_input_y; - 350 + 353 // } - 351 + 354 - 352 + 355 - 81831276 + 82233540 std::array<double, 6> RK45_deriv_function_orbit_position_and_velocity( - 353 + 356 const std::array<double, 6> input_position_and_velocity, - 354 + 357 const double input_spacecraft_mass, - 355 + 358 const std::vector<ThrustProfileLVLH> input_list_of_thrust_profiles_LVLH, - 356 + 359 const double input_evaluation_time, const double input_inclination, - 357 + 360 const double input_arg_of_periapsis, const double input_true_anomaly, - 358 + 361 const double input_F_10, const double input_A_p, const double input_A_s, - 359 + 362 const double input_satellite_mass, const bool perturbation, - 360 + 363 const bool atmospheric_drag) { - 361 + 364 // std::cout << "In RK45 deriv function orbit position and velocity, received - 362 + 365 // perturbation bool: " << perturbation << "\n"; - 363 + 366 - 81831276 + 82233540 std::array<double, 6> derivative_of_input_y = {}; - 364 + 367 - 81831276 + 82233540 std::array<double, 3> position_array = {}; - 365 + 368 - 81831276 + 82233540 std::array<double, 3> velocity_array = {}; - 366 + 369 - 367 + 370
2/2
-
✓ Branch 0 taken 245493828 times.
-
✓ Branch 1 taken 81831276 times.
+
✓ Branch 0 taken 246700620 times.
+
✓ Branch 1 taken 82233540 times.
- 327325104 + 328934160 for (size_t ind = 0; ind < 3; ind++) { - 368 + 371 - 245493828 + 246700620 derivative_of_input_y.at(ind) = input_position_and_velocity.at(ind + 3); - 369 + 372 - 245493828 + 246700620 velocity_array.at(ind) = input_position_and_velocity.at(ind + 3); - 370 + 373 - 245493828 + 246700620 position_array.at(ind) = input_position_and_velocity.at(ind); - 371 + 374 - 245493828 + 246700620 } - 372 + 375 - 373 + 376 std::array<double, 3> calculated_orbital_acceleration = - 374 + 377
1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 calculate_orbital_acceleration( - 375 + 378 - 81831276 + 82233540 position_array, input_spacecraft_mass, - 376 + 379 - 81831276 + 82233540 input_list_of_thrust_profiles_LVLH, input_evaluation_time, - 377 + 380 - 81831276 + 82233540 velocity_array, input_inclination, input_arg_of_periapsis, - 378 + 381 - 81831276 + 82233540 input_true_anomaly, input_F_10, input_A_p, input_A_s, - 379 + 382 - 81831276 + 82233540 input_satellite_mass, perturbation, atmospheric_drag); - 380 + 383 - 381 + 384
2/2
-
✓ Branch 0 taken 245493828 times.
-
✓ Branch 1 taken 81831276 times.
+
✓ Branch 0 taken 246700620 times.
+
✓ Branch 1 taken 82233540 times.
- 327325104 + 328934160 for (size_t ind = 3; ind < 6; ind++) { - 382 + 385 - 245493828 + 246700620 derivative_of_input_y.at(ind) = calculated_orbital_acceleration.at(ind - 3); - 383 + 386 - 245493828 + 246700620 } - 384 + 387 + + + + + + + 388 + + + 82233540 + return derivative_of_input_y; + + + 389 + + + ✗ + } + + + 390 + + + + + + + 391 + + + + /// @brief Runs the requested simulation and writes output data to a text file + + + 392 + + + + /// @param input_satellite_vector: The vector of satellite objects to be simulated + + + 393 + + + + /// @param input_sim_parameters: A SimParameters struct containing simulation parameters + + + 394 + + + + /// @param output_file_name_prefix: The prefix of the text file containing simulation data. Individual satellite data files will start with this prefix, followed by the satellite name. + + + 395 + + + 7 + int sim_and_write_to_file(std::vector<Satellite> input_satellite_vector, + + + 396 + + + + const SimParameters& input_sim_parameters, + + + 397 + + + + const std::string output_file_name_prefix, + + + 398 + + + + const double size_limit) { + + + 399 + + + + // Estimate of bytes of output file (NOTE: size on disk may be different): 372.67*n - 189.97 with n the number of timesteps at which there exists data + + + 400 + + + + // This would change if, e.g., the number of values stored at each timestep changed, or the precision at which these values are written are changed + + + 401 + + + 7 + double size_estimate_slope = 372.67; + + + 402 + + + 7 + double size_estimate_y_intercept = -189.97; + + + 403 + + + 7 + double size_estimate = size_estimate_y_intercept; // bytes (this isn't physical at n = 0, but need to account for possibility that no data is written) + + + 404 + + + + // One satellite at a time + + + 405 + +
+ 2/2 +
+
✓ Branch 0 taken 6 times.
+
✓ Branch 1 taken 13 times.
+
+
+ + 19 + for (Satellite current_satellite : input_satellite_vector) { + + + 406 + +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 13 times.
+
+
+ + 13 + std::string satellite_name = current_satellite.get_name(); + + + 407 + +
+ 2/4 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 13 times.
+
✗ Branch 2 not taken.
+
✓ Branch 3 taken 13 times.
+
+
+ + 13 + std::string file_name = "../data/" + output_file_name_prefix + satellite_name; + + + 408 + +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 13 times.
+
+
+ + 13 + std::ofstream output_file(file_name.c_str()); + + + 409 + + + + // Get initial values of all stored parameters + + + 410 + + + 13 + double current_satellite_time = + + + 411 + +
+ 1/2 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
+
+ + 13 + current_satellite.get_instantaneous_time(); + + + 412 + + + + // ECI Position + + + 413 + +
+ 1/2 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
+
+ + 13 + std::array<double,3> current_satellite_position_ECI = current_satellite.get_ECI_position(); + + + 414 + +
+ 1/2 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
+
+ + 13 + double current_satellite_position_ECI_x = current_satellite_position_ECI.at(0); + + + 415 + +
+ 1/2 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
+
+ + 13 + double current_satellite_position_ECI_y = current_satellite_position_ECI.at(1); + + + 416 + +
+ 1/2 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
+
+ + 13 + double current_satellite_position_ECI_z = current_satellite_position_ECI.at(2); + + + 417 + + + + // ECI Velocity + + + 418 + +
+ 1/2 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
+
+ + 13 + std::array<double,3> current_satellite_velocity_ECI = current_satellite.get_ECI_velocity(); + + + 419 + +
+ 1/2 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
+
+ + 13 + double current_satellite_velocity_ECI_x = current_satellite_velocity_ECI.at(0); + + + 420 + +
+ 1/2 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
+
+ + 13 + double current_satellite_velocity_ECI_y = current_satellite_velocity_ECI.at(1); + + + 421 + +
+ 1/2 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
+
+ + 13 + double current_satellite_velocity_ECI_z = current_satellite_velocity_ECI.at(2); + + + 422 + + + + // Attitude-related values + + + 423 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_roll = current_satellite.get_attitude_val("Roll"); + + + 424 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_pitch = current_satellite.get_attitude_val("Pitch"); + + + 425 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_yaw = current_satellite.get_attitude_val("Yaw"); + + + 426 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_omega_x = current_satellite.get_attitude_val("omega_x"); + + + 427 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_omega_y = current_satellite.get_attitude_val("omega_y"); + + + 428 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_omega_z = current_satellite.get_attitude_val("omega_z"); + + + 429 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_q_0 = current_satellite.get_attitude_val("q_0"); + + + 430 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_q_1 = current_satellite.get_attitude_val("q_1"); + + + 431 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_q_2 = current_satellite.get_attitude_val("q_2"); + + + 432 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_q_3 = current_satellite.get_attitude_val("q_3"); + + + 433 + + + + // Orbit-related parameters + + + 434 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_a = current_satellite.get_orbital_parameter("Semimajor Axis"); + + + 435 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_eccentricity = current_satellite.get_orbital_parameter("Eccentricity"); + + + 436 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_inclination = current_satellite.get_orbital_parameter("Inclination"); + + + 437 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_raan = current_satellite.get_orbital_parameter("RAAN"); + + + 438 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_arg_of_periapsis = current_satellite.get_orbital_parameter("Argument of Periapsis"); + + + 439 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_true_anomaly = current_satellite.get_orbital_parameter("True Anomaly"); + + + 440 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_orbital_rate = current_satellite.get_orbital_parameter("Orbital Rate"); + + + 441 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_orbital_ang_acc = current_satellite.get_orbital_parameter("Orbital Angular Acceleration"); + + + 442 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + double current_satellite_total_energy = current_satellite.get_orbital_parameter("Total Energy"); + + + 443 + + + + + + + 444 + + + 13 + int num_digits = 15; + + + 445 + + + + + + + 446 + + + + // Write initial datapoints + + + 447 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + output_file << std::setprecision(num_digits) + + + 448 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_time << " " + + + 449 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_position_ECI_x << " " + + + 450 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_position_ECI_y << " " + + + 451 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_position_ECI_z << " " + + + 452 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_velocity_ECI_x << " " + + + 453 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_velocity_ECI_y << " " + + + 454 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_velocity_ECI_z << " " + + + 455 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_roll << " " + + + 456 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_pitch << " " + + + 457 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_yaw << " " + + + 458 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_omega_x << " " + + + 459 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_omega_y << " " + + + 460 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_omega_z << " " + + + 461 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_q_0 << " " + + + 462 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_q_1 << " " + + + 463 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_q_2 << " " + + + 464 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_q_3 << " " + + + 465 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_a << " " + + + 466 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_eccentricity << " " + + + 467 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_inclination << " " + + + 468 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_raan << " " + + + 469 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_arg_of_periapsis << " " + + + 470 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_true_anomaly << " " + + + 471 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_orbital_rate << " " + + + 472 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_orbital_ang_acc << " " + + + 473 + +
+ 2/4 +
+
✓ Branch 0 taken 13 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 13 times.
+
✗ Branch 3 not taken.
+
+
+ + 13 + << current_satellite_total_energy << "\n"; + + + 474 + + + 13 + size_estimate += size_estimate_slope; + + + 475 + +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 13 times.
+
+
+ + 13 + if (size_estimate >= size_limit) { + + + 476 + + + ✗ + std::cout << "Hit estimated number of bytes above input limit, exiting early\n"; + + + 477 + + + ✗ + output_file.close(); + + + 478 + + + ✗ + return 2; + + + 479 + + + + } + + + 480 + + + + + + + 481 + + + 13 + double timestep_to_use = input_sim_parameters.initial_timestep_guess; + + + 482 + +
+ 2/2 +
+
✓ Branch 0 taken 12 times.
+
✓ Branch 1 taken 66953 times.
+
+
+ + 66965 + while (current_satellite_time < input_sim_parameters.total_sim_time) { + + + 483 + + + + + + + 484 + + + 133906 + std::pair<double, double> drag_elements = {input_sim_parameters.F_10, + + + 485 + + + 66953 + input_sim_parameters.A_p}; + + + 486 + + + + std::pair<double, int> new_timestep_and_error_code = + + + 487 + +
+ 1/2 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
+
+ + 66953 + current_satellite.evolve_RK45( + + + 488 + + + 66953 + input_sim_parameters.epsilon, timestep_to_use, + + + 489 + + + 66953 + input_sim_parameters.perturbation_bool, + + + 490 + + + 66953 + input_sim_parameters.drag_bool, drag_elements); + + + 491 + + + 66953 + double new_timestep = new_timestep_and_error_code.first; + + + 492 + + + 66953 + int error_code = new_timestep_and_error_code.second; + + + 493 + + + + + + + 494 + +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 66953 times.
+
+
+ + 66953 + if (error_code != 0) { + + + 495 + + + ✗ + std::cout << "Error code " << error_code + + + 496 + + + ✗ + << " detected, halting simulation\n"; + + + 497 + + + ✗ + output_file << "Error code " << error_code + + + 498 + + + ✗ + << " detected, halting simulation\n"; + + + 499 + + + ✗ + output_file.close(); + + + 500 + + + ✗ + return 1; + + + 501 + + + + } + + + 502 + + + 66953 + timestep_to_use = new_timestep; + + + 503 + +
+ 1/2 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
+
+ + 66953 + current_satellite_time = current_satellite.get_instantaneous_time(); + + + 504 + + + + // Get updated parameters + + + 505 + + + + // ECI Position + + + 506 + +
+ 1/2 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
+
+ + 66953 + current_satellite_position_ECI = current_satellite.get_ECI_position(); + + + 507 + +
+ 1/2 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
+
+ + 66953 + current_satellite_position_ECI_x = current_satellite_position_ECI.at(0); + + + 508 + +
+ 1/2 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
+
+ + 66953 + current_satellite_position_ECI_y = current_satellite_position_ECI.at(1); + + + 509 + +
+ 1/2 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
+
+ + 66953 + current_satellite_position_ECI_z = current_satellite_position_ECI.at(2); + + + 510 + + + + // ECI Velocity + + + 511 + +
+ 1/2 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
+
+ + 66953 + current_satellite_velocity_ECI = current_satellite.get_ECI_velocity(); + + + 512 + +
+ 1/2 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
+
+ + 66953 + current_satellite_velocity_ECI_x = current_satellite_velocity_ECI.at(0); + + + 513 + +
+ 1/2 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
+
+ + 66953 + current_satellite_velocity_ECI_y = current_satellite_velocity_ECI.at(1); + + + 514 + +
+ 1/2 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
+
+ + 66953 + current_satellite_velocity_ECI_z = current_satellite_velocity_ECI.at(2); + + + 515 + + + + // Attitude-related values + + + 516 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_roll = current_satellite.get_attitude_val("Roll"); + + + 517 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_pitch = current_satellite.get_attitude_val("Pitch"); + + + 518 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_yaw = current_satellite.get_attitude_val("Yaw"); + + + 519 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_omega_x = current_satellite.get_attitude_val("omega_x"); + + + 520 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_omega_y = current_satellite.get_attitude_val("omega_y"); + + + 521 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_omega_z = current_satellite.get_attitude_val("omega_z"); + + + 522 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_q_0 = current_satellite.get_attitude_val("q_0"); + + + 523 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_q_1 = current_satellite.get_attitude_val("q_1"); + + + 524 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_q_2 = current_satellite.get_attitude_val("q_2"); + + + 525 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_q_3 = current_satellite.get_attitude_val("q_3"); + + + 526 + + + + // Orbit-related parameters + + + 527 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_a = current_satellite.get_orbital_parameter("Semimajor Axis"); + + + 528 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_eccentricity = current_satellite.get_orbital_parameter("Eccentricity"); + + + 529 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_inclination = current_satellite.get_orbital_parameter("Inclination"); + + + 530 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_raan = current_satellite.get_orbital_parameter("RAAN"); + + + 531 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_arg_of_periapsis = current_satellite.get_orbital_parameter("Argument of Periapsis"); + + + 532 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_true_anomaly = current_satellite.get_orbital_parameter("True Anomaly"); + + + 533 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_orbital_rate = current_satellite.get_orbital_parameter("Orbital Rate"); + + + 534 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_orbital_ang_acc = current_satellite.get_orbital_parameter("Orbital Angular Acceleration"); + + + 535 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + current_satellite_total_energy = current_satellite.get_orbital_parameter("Total Energy"); + + + 536 + + + + + + + 537 + + + + // Write updated parameters to file + + + 538 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + output_file << std::setprecision(num_digits) + + + 539 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_time << " " + + + 540 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_position_ECI_x << " " + + + 541 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_position_ECI_y << " " + + + 542 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_position_ECI_z << " " + + + 543 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_velocity_ECI_x << " " + + + 544 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_velocity_ECI_y << " " + + + 545 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_velocity_ECI_z << " " + + + 546 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_roll << " " + + + 547 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_pitch << " " + + + 548 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_yaw << " " + + + 549 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_omega_x << " " + + + 550 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_omega_y << " " + + + 551 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_omega_z << " " + + + 552 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_q_0 << " " + + + 553 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_q_1 << " " + + + 554 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_q_2 << " " + + + 555 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_q_3 << " " + + + 556 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_a << " " + + + 557 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_eccentricity << " " + + + 558 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_inclination << " " + + + 559 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_raan << " " + + + 560 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_arg_of_periapsis << " " + + + 561 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_true_anomaly << " " + + + 562 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_orbital_rate << " " + + + 563 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_orbital_ang_acc << " " + + + 564 + +
+ 2/4 +
+
✓ Branch 0 taken 66953 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 66953 times.
+
✗ Branch 3 not taken.
+
+
+ + 66953 + << current_satellite_total_energy << "\n"; + + + 565 + + + 66953 + size_estimate += size_estimate_slope; + + + 566 + +
+ 2/2 +
+
✓ Branch 0 taken 1 times.
+
✓ Branch 1 taken 66952 times.
+
+
+ + 66953 + if (size_estimate >= size_limit) { + + + 567 + +
+ 1/2 +
+
✓ Branch 0 taken 1 times.
+
✗ Branch 1 not taken.
+
+
+ + 1 + std::cout << "Hit estimated number of bytes above input limit, exiting early\n"; + + + 568 + +
+ 1/2 +
+
✓ Branch 0 taken 1 times.
+
✗ Branch 1 not taken.
+
+
+ + 1 + output_file.close(); + + + 569 + + + 1 + return 2; + + + 570 + + + + } + + + 571 + + + + } + + + 572 + +
+ 1/2 +
+
✓ Branch 0 taken 12 times.
+
✗ Branch 1 not taken.
+
+
+ + 12 + output_file.close(); + + + 573 + +
+ 4/5 +
+
✓ Branch 0 taken 1 times.
+
✓ Branch 1 taken 12 times.
+
✗ Branch 2 not taken.
+
✓ Branch 3 taken 1 times.
+
✓ Branch 4 taken 12 times.
+
+
+ + 13 + } + + + 574 + + + 6 + return 0; + + + 575 + + + 7 + } + + + 576 + + + + + + + 577 + + + + + + + 578 + + + + /// @brief Uses Gnuplot to plot a specified parameter from a specified simulation data file. + + + 579 + + + + /// @param data_file_name: Name of the data file to use + + + 580 + + + + /// @param parameter_to_plot: Parameter you would like to plot. See comments above implementation for details. + + + 581 + + + + + + + 582 + + + + /* + + + 583 + + + + Possible values of "parameter_to_plot": + + + 584 + + + + "3D Position" - makes an interactive 3D plot of the satellite's ECI position [m]. This is the only 3D plot currently supported.alignas + + + 585 + + + + The following are available as 2D plots (the specified parameter will be plotted with respect to simulation time) + + + 586 + + + + "X Velocity" - X component of ECI velocity [m/s] + + + 587 + + + + "Y Velocity" - Y component of ECI velocity [m/s] + + + 588 + + + + "Z Velocity" - Z component of ECI velocity [m/s] + + + 589 + + + + "Roll" - Satellite's roll angle with respect to LVLH frame, represented in the satellite body frame [deg] + + + 590 + + + + "Pitch" - Satellite's pitch angle with respect to LVLH frame, represented in the satellite body frame [deg] + + + 591 + + + + "Yaw" - Satellite's yaw angle with respect to LVLH frame, represented in the satellite body frame [deg] + + + 592 + + + + "omega_x" - x component of satellite's body-frame angular velocity with respect to the LVLH frame [deg/s] + + + 593 + + + + "omega_y" - y component of satellite's body-frame angular velocity with respect to the LVLH frame [deg/s] + + + 594 + + + + "omega_z" - z component of satellite's body-frame angular velocity with respect to the LVLH frame [deg/s] + + + 595 + + + + "q_0" - First (scalar) component of quaternion representing satellite's attitude with respect to the LVLH frame + + + 596 + + + + "q_1" - Second component of quaternion representing satellite's attitude with respect to the LVLH frame + + + 597 + + + + "q_2" - Third component of quaternion representing satellite's attitude with respect to the LVLH frame + + + 598 + + + + "q_3" - Fourth component of quaternion representing satellite's attitude with respect to the LVLH frame + + + 599 + + + + "Semimajor Axis" - Semimajor axis of satellite's orbit [m] + + + 600 + + + + "Eccentricity" - Eccentricity of satellite's orbit + + + 601 + + + + "Inclination" - Inclination of satellite's orbit [deg] + + + 602 + + + + "RAAN" - Right ascension of the ascending node of satellite's orbit [deg] + + + 603 + + + + (assumed to be equivalent to the longitude of the ascending node for Earth-orbiting satellites simulated here) + + + 604 + + + + "Argument of Periapsis" - Argument of periapsis of the satellite's orbit [deg] + + + 605 + + + + "True Anomaly" - True anomaly of the satellite's orbit [deg] + + + 606 + + + + "Orbital Rate" - Rate of change of the true anomaly + + + 607 + + + + "Orbital Angular Acceleration" - Second time derivative of the true anomaly + + + 608 + + + + "Total Energy" - Satellite's total energy + + + 609 + + + + (here taken to be gravitational potential energy + translational kinetic energy + rotational kinetic energy) + + + 610 + + + + */ + + + 611 + + + 2 + void plot_3D_from_datafile(std::vector<std::string> input_datafile_name_vector, + + + 612 + + + + const std::string output_file_name, + + + 613 + + + + const std::string terminal_name, + + + 614 + + + + const double x_increment, + + + 615 + + + + const double y_increment, + + + 616 + + + + const double z_increment) { + + + 617 + +
+ 1/2 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
+
+ + 2 + if (input_datafile_name_vector.size() < 1) { + + + 618 + + + ✗ + throw std::invalid_argument("Empty datafile name vector"); + + + 619 + + + + } + + + 620 + + + + // first, open "pipe" to gnuplot + + + 621 + + + 2 + std::string gnuplot_arg_string = "gnuplot"; + + + 622 + +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 2 times.
+
+
+ + 2 + if (terminal_name == "qt") { + + + 623 + + + ✗ + gnuplot_arg_string += " -persist"; + + + 624 + + + ✗ + } + + + 625 + +
+ 1/2 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
+
+ + 2 + FILE* gnuplot_pipe = popen(gnuplot_arg_string.c_str(), "w"); + + + 626 + + + + + + + 627 + + + + // if it exists + + + 628 + +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 2 times.
+
+
+ + 2 + if (gnuplot_pipe) { + + + 629 + + + 4 + fprintf(gnuplot_pipe, "set terminal '%s' size 900,700 font ',14'\n", + + + 630 + + + 2 + terminal_name.c_str()); + + + 631 + +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 2 times.
+
+
+ + 2 + if (terminal_name == "png") { + + + 632 + + + 4 + fprintf(gnuplot_pipe, "set output '../%s.png'\n", + + + 633 + + + 2 + output_file_name.c_str()); + + + 634 + + + 2 + } + + + 635 + + + + // formatting + + + 636 + + + 2 + fprintf(gnuplot_pipe, "set xlabel 'x [m]' offset 0,-2\n"); + + + 637 + + + 2 + fprintf(gnuplot_pipe, "set ylabel 'y [m]' offset -2,0\n"); + + + 638 + + + 2 + fprintf(gnuplot_pipe, "set zlabel 'z [m]'\n"); + + + 639 + + + + // fprintf(gnuplot_pipe,"set view 70,1,1,1\n"); + + + 640 + + + 2 + fprintf(gnuplot_pipe, "set view equal xyz\n"); + + + 641 + +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 2 times.
+
+
+ + 2 + if (x_increment != 0) { + + + 642 + + + ✗ + fprintf(gnuplot_pipe, "set xtics %e offset 0,-1.5\n", + + + 643 + + + ✗ + x_increment); + + + 644 + + + ✗ + } else { + + + 645 + + + 2 + fprintf(gnuplot_pipe, "set xtics offset 0,-1.5\n"); + + + 646 + + + + } + + + 647 + +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 2 times.
+
+
+ + 2 + if (y_increment != 0) { + + + 648 + + + ✗ + fprintf(gnuplot_pipe, "set ytics %e offset -1.5,0\n", + + + 649 + + + ✗ + y_increment); + + + 650 + + + ✗ + } else { + + + 651 + + + 2 + fprintf(gnuplot_pipe, "set ytics offset -1.5,0\n"); + + + 652 + + + + } + + + 653 + +
+ 1/2 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
+
+ + 2 + if (z_increment != 0) { + + + 654 + + + ✗ + fprintf(gnuplot_pipe, "set ztics %e\n", z_increment); + + + 655 + + + ✗ + } + + + 656 + + + 2 + fprintf(gnuplot_pipe, "unset colorbox\n"); + + + 657 + + + 2 + fprintf(gnuplot_pipe, "set style fill transparent solid 1.0\n"); + + + 658 + + + + + + + 659 + + + 2 + fprintf(gnuplot_pipe, "set key offset 0,-10\n"); + + + 660 + + + 2 + fprintf(gnuplot_pipe, "set hidden3d front\n"); + + + 661 + + + + + + + 662 + + + + // plotting + + + 663 + + + + // first let's set the stage for plotting the Earth + + + 664 + + + 2 + fprintf(gnuplot_pipe, "R_Earth=%.17g\n", radius_Earth); + + + 665 + + + 2 + fprintf(gnuplot_pipe, "set isosamples 50,50\n"); + + + 666 + + + 2 + fprintf(gnuplot_pipe, "set parametric\n"); + + + 667 + + + 2 + fprintf(gnuplot_pipe, "set urange [-pi/2:pi/2]\n"); + + + 668 + + + 2 + fprintf(gnuplot_pipe, "set vrange [0:2*pi]\n"); + + + 669 + + + + + + + 670 + + + + // first satellite + + + 671 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + std::string current_file_name = input_datafile_name_vector.at(0); + + + 672 + +
+ 2/2 +
+
✓ Branch 0 taken 1 times.
+
✓ Branch 1 taken 1 times.
+
+
+ + 2 + if (input_datafile_name_vector.size() == 1) { + + + 673 + + + 2 + fprintf(gnuplot_pipe, "splot '../data/%s' using 2:3:4 with lines lw 1 title '%s' \\\n", + + + 674 + + + 1 + current_file_name.c_str(), + + + 675 + + + 1 + current_file_name.c_str()); + + + 676 + + + 1 + } + + + 677 + + + + + + + 678 + + + + else { + + + 679 + + + 2 + fprintf(gnuplot_pipe, "splot '../data/%s' using 2:3:4 with lines lw 1 title '%s'\\\n", + + + 680 + + + 1 + current_file_name.c_str(), + + + 681 + + + 1 + current_file_name.c_str()); + + + 682 + + + + } + + + 683 + + + + + + + 684 + +
+ 2/2 +
+
✓ Branch 0 taken 2 times.
+
✓ Branch 1 taken 2 times.
+
+
+ + 4 + for (size_t datafile_index = 1; + + + 685 + + + 4 + datafile_index < input_datafile_name_vector.size(); datafile_index++) { + + + 686 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + current_file_name = input_datafile_name_vector.at(datafile_index); + + + 687 + +
+ 2/2 +
+
✓ Branch 0 taken 1 times.
+
✓ Branch 1 taken 1 times.
+
+
+ + 2 + if (datafile_index < input_datafile_name_vector.size() - 1) { + + + 688 + + + 2 + fprintf(gnuplot_pipe, ",'../data/%s' using 2:3:4 with lines lw 1 title '%s' \\\n", + + + 689 + + + 1 + current_file_name.c_str(), + + + 690 + + + 1 + current_file_name.c_str()); + + + 691 + + + 1 + } + + + 692 + + + + else { + + + 693 + + + 2 + fprintf(gnuplot_pipe, ",'../data/%s' using 2:3:4 with lines lw 1 title '%s' \\\n", + + + 694 + + + 1 + current_file_name.c_str(), + + + 695 + + + 1 + current_file_name.c_str()); + + + 696 + + + + } + + + 697 + + + 2 + } + + + 698 + + + 2 + fprintf(gnuplot_pipe, + + + 699 + + + + ",R_Earth*cos(u)*cos(v),R_Earth*cos(u)*sin(v),R_Earth*sin(u) " + + + 700 + + + + "notitle with pm3d fillcolor rgbcolor 'navy'\n"); + + + 701 + + + + + + + 702 + +
+ 1/2 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
+
+ + 2 + if (terminal_name == "qt") { + + + 703 + + + ✗ + fprintf(gnuplot_pipe, "pause mouse keypress\n"); + + + 704 + + + ✗ + } + + + 705 + + + 2 + fprintf(gnuplot_pipe, "exit \n"); + + + 706 + +
+ 1/2 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
+
+ + 2 + pclose(gnuplot_pipe); + + + 707 + +
+ 1/2 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
+
+ + 2 + std::cout << "Done\n"; + + + 708 + + + + + + + 709 + + + 2 + } else { + + + 710 + + + ✗ + std::cout << "gnuplot not found"; + + + 711 + + + + } + + + 712 + + + + + + + 713 + + + + return; + + + 714 + + + 2 + } + + + 715 + + + + + + + 716 + + + + + + + 717 + + + + + + + 718 + + + + // Now the 2D version for plotting parameters over time + + + 719 + + + 2 + void plot_2D_from_datafile(std::vector<std::string> input_datafile_name_vector, + + + 720 + + + + const std::string plotted_parameter, + + + 721 + + + + const std::string output_file_name) { + + + 722 + +
+ 1/2 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
+
+ + 2 + if (input_datafile_name_vector.size() < 1) { + + + 723 + + + ✗ + throw std::invalid_argument("Empty datafile name vector"); + + + 724 + + + + } + + + 725 + + + + + + + 726 + + + 2 + std::unordered_map<std::string,std::string> name_to_units_map; + + + 727 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["X Velocity"] = "[m/s]"; + + + 728 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["Y Velocity"] = "[m/s]"; + + + 729 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["Z Velocity"] = "[m/s]"; + + + 730 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["Semimajor Axis"] = "[m]"; + + + 731 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["Eccentricity"] = ""; + + + 732 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["Inclination"] = "[deg]"; + + + 733 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["Argument of Periapsis"] = "[deg]"; + + + 734 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["RAAN"] = "[deg]"; + + + 735 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["True Anomaly"] = "[deg]"; + + + 736 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["Roll"] = "[deg]"; + + + 737 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["Pitch"] = "[deg]"; + + + 738 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["Yaw"] = "[deg]"; + + + 739 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["omega_x"] = "[deg/s]"; + + + 740 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["omega_y"] = "[deg/s]"; + + + 741 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["omega_z"] = "[deg/s]"; + + + 742 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["q_0"] = ""; + + + 743 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["q_1"] = ""; + + + 744 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["q_2"] = ""; + + + 745 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["q_3"] = ""; + + + 746 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["Total Energy"] = "[J]"; + + + 747 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["Orbital Rate"] = "[rad/s]"; + + + 748 + +
+ 3/6 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
✓ Branch 4 taken 2 times.
+
✗ Branch 5 not taken.
+
+
+ + 2 + name_to_units_map["Orbital Angular Acceleration"] = "[rad/s^2]"; + + + 749 + + + + + + + 750 + + + 2 + std::unordered_map<std::string,int> name_to_col_map; + + + 751 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["X Velocity"] = 5; + + + 752 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["Y Velocity"] = 6; + + + 753 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["Z Velocity"] = 7; + + + 754 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["Roll"] = 8; + + + 755 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["Pitch"] = 9; + + + 756 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["Yaw"] = 10; + + + 757 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["omega_x"] = 11; + + + 758 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["omega_y"] = 12; + + + 759 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["omega_z"] = 13; + + + 760 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["q_0"] = 14; + + + 761 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["q_1"] = 15; + + + 762 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["q_2"] = 16; + + + 763 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["q_3"] = 17; + + + 764 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["Semimajor Axis"] = 18; + + + 765 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["Eccentricity"] = 19; + + + 766 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["Inclination"] = 20; + + + 767 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["RAAN"] = 21; + + + 768 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["Argument of Periapsis"] = 22; + + + 769 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["True Anomaly"] = 23; + + + 770 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["Orbital Rate"] = 24; + + + 771 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["Orbital Angular Acceleration"] = 25; + + + 772 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + name_to_col_map["Total Energy"] = 26; + + + 773 + + + + + + + 774 + + + + // first, open "pipe" to gnuplot + + + 775 + +
+ 1/2 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
+
+ + 2 + FILE* gnuplot_pipe = popen("gnuplot", "w"); + + + 776 + + + + // if it exists + + + 777 + +
+ 1/2 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
+
+ + 2 + if (gnuplot_pipe) { + + + 778 + + + 2 + fprintf(gnuplot_pipe, + + + 779 + + + + "set terminal png size 800,500 font ',14' linewidth 2\n"); + + + 780 + + + + // formatting + + + 781 + + + 2 + fprintf(gnuplot_pipe, "set output '../%s.png'\n", output_file_name.c_str()); + + + 782 + + + 2 + fprintf(gnuplot_pipe, "set offsets graph 0, 0, 0.05, 0.05\n"); + + + 783 + + + 2 + fprintf(gnuplot_pipe, "set xlabel 'Time [s]'\n"); + + + 784 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + if (name_to_units_map.count(plotted_parameter) == 0) { + + + 785 + + + ✗ + throw std::invalid_argument("Unrecognized parameter to plot"); + + + 786 + + + + } + + + 787 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + std::string plotted_element_units = name_to_units_map[plotted_parameter]; + + + 788 + +
+ 1/2 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
+
+ + 2 + int plotted_element_column = name_to_col_map[plotted_parameter]; + + + 789 + + + 4 + fprintf(gnuplot_pipe, "set ylabel '%s %s'\n", + + + 790 + + + 2 + plotted_parameter.c_str(), + + + 791 + + + 2 + plotted_element_units.c_str()); + + + 792 + + + 2 + fprintf(gnuplot_pipe, "set key right bottom\n"); + + + 793 + + + + + + + 794 + + + + // plotting + + + 795 + + + + + + + 796 + + + + // first satellite + + + 797 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + std::string current_datafile_name = input_datafile_name_vector.at(0); + + + 798 + +
+ 2/2 +
+
✓ Branch 0 taken 1 times.
+
✓ Branch 1 taken 1 times.
+
+
+ + 2 + if (input_datafile_name_vector.size() == 1) { + + + 799 + + + 2 + fprintf(gnuplot_pipe, + + + 800 + + + + "plot '../data/%s' using 1:%d with lines lw 1 title '%s' \n", + + + 801 + + + 1 + current_datafile_name.c_str(), + + + 802 + + + 1 + plotted_element_column, + + + 803 + + + 1 + current_datafile_name.c_str()); + + + 804 + + + 1 + } + + + 805 + + + + + + + 806 + + + + else { + + + 807 + + + 2 + fprintf(gnuplot_pipe, + + + 808 + + + + "plot '../data/%s' using 1:%d with lines lw 1 title '%s'\\\n", + + + 809 + + + 1 + current_datafile_name.c_str(), + + + 810 + + + 1 + plotted_element_column, + + + 811 + + + 1 + current_datafile_name.c_str()); + + + 812 + + + + + + + 813 + + + + } + + + 814 + + + + + + + 815 + +
+ 2/2 +
+
✓ Branch 0 taken 2 times.
+
✓ Branch 1 taken 2 times.
+
+
+ + 4 + for (size_t datafile_index = 1; + + + 816 + + + 4 + datafile_index < input_datafile_name_vector.size(); datafile_index++) { + + + 817 + +
+ 2/4 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
✓ Branch 2 taken 2 times.
+
✗ Branch 3 not taken.
+
+
+ + 2 + current_datafile_name = input_datafile_name_vector.at(datafile_index); + + + 818 + +
+ 2/2 +
+
✓ Branch 0 taken 1 times.
+
✓ Branch 1 taken 1 times.
+
+
+ + 2 + if (datafile_index < input_datafile_name_vector.size() - 1) { + + + 819 + + + 2 + fprintf(gnuplot_pipe, + + + 820 + + + + ",'../data/%s' using 1:%d with lines lw 1 title '%s'\\\n", + + + 821 + + + 1 + current_datafile_name.c_str(), + + + 822 + + + 1 + plotted_element_column, + + + 823 + + + 1 + current_datafile_name.c_str()); + + + 824 + + + 1 + } + + + 825 + + + + + + + 826 + + + + else { + + + 827 + + + 2 + fprintf(gnuplot_pipe, + + + 828 + + + + ",'../data/%s' using 1:%d with lines lw 1 title '%s'\n", + + + 829 + + + 1 + current_datafile_name.c_str(), + + + 830 + + + 1 + plotted_element_column, + + + 831 + + + 1 + current_datafile_name.c_str()); + + + 832 + + + + } + + + 833 + + + 2 + } + + + 834 - 385 + 835 - 81831276 - return derivative_of_input_y; + 2 + fprintf(gnuplot_pipe, "exit \n"); - 386 + 836 + +
+ 1/2 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
+
+ + 2 + pclose(gnuplot_pipe); + + + 837 + +
+ 1/2 +
+
✓ Branch 0 taken 2 times.
+
✗ Branch 1 not taken.
+
+
+ + 2 + std::cout << "Done\n"; + + + 838 + + + + + + + 839 + + + 2 + } else { + + + 840 ✗ - } + std::cout << "gnuplot not found"; - 387 + 841 + + + + } + + + 842 - 388 + 843 + + + + return; + + + 844 + + + 2 + } + + + 845 + + + + + + + 846 + + + + + + + 847 // Objective: simulate the input satellites over the specified total sim time, - 389 + 848 // and visualize the resulting orbits in an interactive 3D plot using gnuplot - 390 + 849 18 void sim_and_draw_orbit_gnuplot(std::vector<Satellite> input_satellite_vector, - 391 + 850 const SimParameters& input_sim_parameters, - 392 + 851 const std::string output_file_name) { - 393 + 852
1/2 @@ -3199,42 +8120,42 @@

GCC Code Coverage Report

if (input_satellite_vector.size() < 1) { - 394 + 853 std::cout << "No input Satellite objects\n"; - 395 + 854 return; - 396 + 855 } - 397 + 856 // first, open "pipe" to gnuplot - 398 + 857 18 std::string gnuplot_arg_string = "gnuplot"; - 399 + 858
1/2 @@ -3248,21 +8169,21 @@

GCC Code Coverage Report

if (input_sim_parameters.terminal_name_3D == "qt") { - 400 + 859 gnuplot_arg_string += " -persist"; - 401 + 860 } - 402 + 861
1/2 @@ -3276,21 +8197,21 @@

GCC Code Coverage Report

FILE* gnuplot_pipe = popen(gnuplot_arg_string.c_str(), "w"); - 403 + 862 - 404 + 863 // if it exists - 405 + 864
1/2 @@ -3304,21 +8225,21 @@

GCC Code Coverage Report

if (gnuplot_pipe) { - 406 + 865 36 fprintf(gnuplot_pipe, "set terminal '%s' size 900,700 font ',14'\n", - 407 + 866 18 input_sim_parameters.terminal_name_3D.c_str()); - 408 + 867
1/2 @@ -3332,91 +8253,91 @@

GCC Code Coverage Report

if (input_sim_parameters.terminal_name_3D == "png") { - 409 + 868 36 fprintf(gnuplot_pipe, "set output '../%s.png'\n", - 410 + 869 18 output_file_name.c_str()); - 411 + 870 18 } - 412 + 871 // formatting - 413 + 872 18 fprintf(gnuplot_pipe, "set xlabel 'x [m]' offset 0,-2\n"); - 414 + 873 18 fprintf(gnuplot_pipe, "set ylabel 'y [m]' offset -2,0\n"); - 415 + 874 18 fprintf(gnuplot_pipe, "set zlabel 'z [m]'\n"); - 416 + 875 36 fprintf(gnuplot_pipe, - 417 + 876 "set title 'Simulated orbits up to time %.2f s' offset 0,-7.5\n", - 418 + 877 18 input_sim_parameters.total_sim_time); - 419 + 878 // fprintf(gnuplot_pipe,"set view 70,1,1,1\n"); - 420 + 879 18 fprintf(gnuplot_pipe, "set view equal xyz\n"); - 421 + 880
1/2 @@ -3430,42 +8351,42 @@

GCC Code Coverage Report

if (input_sim_parameters.x_increment != 0) { - 422 + 881 fprintf(gnuplot_pipe, "set xtics %e offset 0,-1.5\n", - 423 + 882 input_sim_parameters.x_increment); - 424 + 883 } else { - 425 + 884 18 fprintf(gnuplot_pipe, "set xtics offset 0,-1.5\n"); - 426 + 885 } - 427 + 886
1/2 @@ -3479,42 +8400,42 @@

GCC Code Coverage Report

if (input_sim_parameters.y_increment != 0) { - 428 + 887 fprintf(gnuplot_pipe, "set ytics %e offset -1.5,0\n", - 429 + 888 input_sim_parameters.y_increment); - 430 + 889 } else { - 431 + 890 18 fprintf(gnuplot_pipe, "set ytics offset -1.5,0\n"); - 432 + 891 } - 433 + 892
1/2 @@ -3528,126 +8449,126 @@

GCC Code Coverage Report

if (input_sim_parameters.z_increment != 0) { - 434 + 893 fprintf(gnuplot_pipe, "set ztics %e\n", input_sim_parameters.z_increment); - 435 + 894 } - 436 + 895 18 fprintf(gnuplot_pipe, "unset colorbox\n"); - 437 + 896 18 fprintf(gnuplot_pipe, "set style fill transparent solid 1.0\n"); - 438 + 897 - 439 + 898 18 fprintf(gnuplot_pipe, "set key offset 0,-10\n"); - 440 + 899 18 fprintf(gnuplot_pipe, "set hidden3d front\n"); - 441 + 900 - 442 + 901 // plotting - 443 + 902 // first let's set the stage for plotting the Earth - 444 + 903 18 fprintf(gnuplot_pipe, "R_Earth=%.17g\n", radius_Earth); - 445 + 904 18 fprintf(gnuplot_pipe, "set isosamples 50,50\n"); - 446 + 905 18 fprintf(gnuplot_pipe, "set parametric\n"); - 447 + 906 18 fprintf(gnuplot_pipe, "set urange [-pi/2:pi/2]\n"); - 448 + 907 18 fprintf(gnuplot_pipe, "set vrange [0:2*pi]\n"); - 449 + 908 - 450 + 909 // first satellite - 451 + 910
2/4 @@ -3663,7 +8584,7 @@

GCC Code Coverage Report

Satellite current_satellite = input_satellite_vector.at(0); - 452 + 911
2/2 @@ -3677,7 +8598,7 @@

GCC Code Coverage Report

if (input_satellite_vector.size() == 1) { - 453 + 912
2/2 @@ -3691,28 +8612,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 454 + 913 3 fprintf(gnuplot_pipe, - 455 + 914 "splot '-' with lines lw 1 lc rgb '%s' title '%s' \\\n", - 456 + 915 3 current_satellite.plotting_color_.c_str(), - 457 + 916
1/2 @@ -3726,21 +8647,21 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 458 + 917 3 } else { - 459 + 918 3 fprintf(gnuplot_pipe, "splot '-' with lines lw 1 title '%s' \\\n", - 460 + 919
1/2 @@ -3754,42 +8675,42 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 461 + 920 } - 462 + 921 - 463 + 922 6 } - 464 + 923 - 465 + 924 else { - 466 + 925
2/2 @@ -3803,28 +8724,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 467 + 926 6 fprintf(gnuplot_pipe, - 468 + 927 "splot '-' with lines lw 1 lc rgb '%s' title '%s'\\\n", - 469 + 928 6 current_satellite.plotting_color_.c_str(), - 470 + 929
1/2 @@ -3838,21 +8759,21 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 471 + 930 6 } else { - 472 + 931 6 fprintf(gnuplot_pipe, "splot '-' with lines lw 1 title '%s'\\\n", - 473 + 932
1/2 @@ -3866,28 +8787,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 474 + 933 } - 475 + 934 } - 476 + 935 - 477 + 936
2/2 @@ -3901,14 +8822,14 @@

GCC Code Coverage Report

for (size_t satellite_index = 1; - 478 + 937 72 satellite_index < input_satellite_vector.size(); satellite_index++) { - 479 + 938
2/4 @@ -3924,7 +8845,7 @@

GCC Code Coverage Report

current_satellite = input_satellite_vector.at(satellite_index); - 480 + 939
2/2 @@ -3938,7 +8859,7 @@

GCC Code Coverage Report

if (satellite_index < input_satellite_vector.size() - 1) { - 481 + 940
2/2 @@ -3952,28 +8873,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 482 + 941 18 fprintf(gnuplot_pipe, - 483 + 942 ",'-' with lines lw 1 lc rgb '%s' title '%s' \\\n", - 484 + 943 18 current_satellite.plotting_color_.c_str(), - 485 + 944
1/2 @@ -3987,21 +8908,21 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 486 + 945 18 } else { - 487 + 946 24 fprintf(gnuplot_pipe, ",'-' with lines lw 1 title '%s' \\\n", - 488 + 947
1/2 @@ -4015,42 +8936,42 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 489 + 948 } - 490 + 949 - 491 + 950 42 } - 492 + 951 - 493 + 952 else { - 494 + 953
2/2 @@ -4064,28 +8985,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 495 + 954 6 fprintf(gnuplot_pipe, - 496 + 955 ",'-' with lines lw 1 lc rgb '%s' title '%s'\\\n", - 497 + 956 6 current_satellite.plotting_color_.c_str(), - 498 + 957
1/2 @@ -4099,21 +9020,21 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 499 + 958 6 } else { - 500 + 959 6 fprintf(gnuplot_pipe, ",'-' with lines lw 1 title '%s'\\\n", - 501 + 960
1/2 @@ -4127,63 +9048,63 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 502 + 961 } - 503 + 962 } - 504 + 963 54 } - 505 + 964 18 fprintf(gnuplot_pipe, - 506 + 965 ",R_Earth*cos(u)*cos(v),R_Earth*cos(u)*sin(v),R_Earth*sin(u) " - 507 + 966 "notitle with pm3d fillcolor rgbcolor 'navy'\n"); - 508 + 967 - 509 + 968 // now the orbit data, inline, one satellite at a time - 510 + 969
1/2 @@ -4197,7 +9118,7 @@

GCC Code Coverage Report

std::cout << "Running simulation...\n"; - 511 + 970
2/2 @@ -4211,14 +9132,14 @@

GCC Code Coverage Report

for (size_t satellite_index = 0; - 512 + 971 90 satellite_index < input_satellite_vector.size(); satellite_index++) { - 513 + 972
2/4 @@ -4234,14 +9155,14 @@

GCC Code Coverage Report

Satellite current_satellite = input_satellite_vector.at(satellite_index); - 514 + 973 std::array<double, 3> initial_position = - 515 + 974
1/2 @@ -4255,7 +9176,7 @@

GCC Code Coverage Report

current_satellite.get_ECI_position(); - 516 + 975
1/2 @@ -4269,7 +9190,7 @@

GCC Code Coverage Report

fprintf(gnuplot_pipe, "%.17g %.17g %.17g\n", initial_position.at(0), - 517 + 976
2/4 @@ -4285,42 +9206,42 @@

GCC Code Coverage Report

initial_position.at(1), initial_position.at(2)); - 518 + 977 - 519 + 978 72 std::array<double, 3> evolved_position = {}; - 520 + 979 - 521 + 980 72 double timestep_to_use = input_sim_parameters.initial_timestep_guess; - 522 + 981 72 double current_satellite_time = - 523 + 982
1/2 @@ -4334,7 +9255,7 @@

GCC Code Coverage Report

current_satellite.get_instantaneous_time(); - 524 + 983
2/2 @@ -4348,28 +9269,28 @@

GCC Code Coverage Report

while (current_satellite_time < input_sim_parameters.total_sim_time) { - 525 + 984 18544 std::pair<double, double> drag_elements = {input_sim_parameters.F_10, - 526 + 985 9272 input_sim_parameters.A_p}; - 527 + 986 std::pair<double, int> new_timestep_and_error_code = - 528 + 987
1/2 @@ -4383,42 +9304,42 @@

GCC Code Coverage Report

current_satellite.evolve_RK45( - 529 + 988 9272 input_sim_parameters.epsilon, timestep_to_use, - 530 + 989 9272 input_sim_parameters.perturbation_bool, - 531 + 990 9272 input_sim_parameters.drag_bool, drag_elements); - 532 + 991 9272 double new_timestep = new_timestep_and_error_code.first; - 533 + 992 9272 int error_code = new_timestep_and_error_code.second; - 534 + 993
1/2 @@ -4432,63 +9353,63 @@

GCC Code Coverage Report

if (error_code != 0) { - 535 + 994 std::cout << "Error code " << error_code - 536 + 995 << " detected, halting visualization\n"; - 537 + 996 fprintf(gnuplot_pipe, "e\n"); - 538 + 997 fprintf(gnuplot_pipe, "exit \n"); - 539 + 998 pclose(gnuplot_pipe); - 540 + 999 return; - 541 + 1000 } - 542 + 1001 9272 timestep_to_use = new_timestep; - 543 + 1002
1/2 @@ -4502,7 +9423,7 @@

GCC Code Coverage Report

evolved_position = current_satellite.get_ECI_position(); - 544 + 1003
1/2 @@ -4516,7 +9437,7 @@

GCC Code Coverage Report

current_satellite_time = current_satellite.get_instantaneous_time(); - 545 + 1004
1/2 @@ -4530,7 +9451,7 @@

GCC Code Coverage Report

fprintf(gnuplot_pipe, "%.17g %.17g %.17g\n", evolved_position.at(0), - 546 + 1005
2/4 @@ -4546,21 +9467,21 @@

GCC Code Coverage Report

evolved_position.at(1), evolved_position.at(2)); - 547 + 1006 } - 548 + 1007 72 fprintf(gnuplot_pipe, "e\n"); - 549 + 1008
1/2 @@ -4574,14 +9495,14 @@

GCC Code Coverage Report

} - 550 + 1009 - 551 + 1010
1/2 @@ -4595,28 +9516,28 @@

GCC Code Coverage Report

if (input_sim_parameters.terminal_name_3D == "qt") { - 552 + 1011 fprintf(gnuplot_pipe, "pause mouse keypress\n"); - 553 + 1012 } - 554 + 1013 18 fprintf(gnuplot_pipe, "exit \n"); - 555 + 1014
1/2 @@ -4630,7 +9551,7 @@

GCC Code Coverage Report

pclose(gnuplot_pipe); - 556 + 1015
1/2 @@ -4644,14 +9565,14 @@

GCC Code Coverage Report

std::cout << "Done\n"; - 557 + 1016 - 558 + 1017
1/2 @@ -4665,91 +9586,91 @@

GCC Code Coverage Report

} else { - 559 + 1018 std::cout << "gnuplot not found"; - 560 + 1019 } - 561 + 1020 - 562 + 1021 18 return; - 563 + 1022 18 } - 564 + 1023 - 565 + 1024 // Objective: simulate the input satellites over the specified total sim time, - 566 + 1025 // and plot a specific orbital element over time - 567 + 1026 162 void sim_and_plot_orbital_elem_gnuplot( - 568 + 1027 std::vector<Satellite> input_satellite_vector, - 569 + 1028 const SimParameters& input_sim_parameters, - 570 + 1029 std::string input_orbital_element_name, const std::string file_name) { - 571 + 1030
1/2 @@ -4763,56 +9684,56 @@

GCC Code Coverage Report

if (input_satellite_vector.size() < 1) { - 572 + 1031 std::cout << "No input Satellite objects\n"; - 573 + 1032 return; - 574 + 1033 } - 575 + 1034 - 576 + 1035 // first, open "pipe" to gnuplot - 577 + 1036 162 FILE* gnuplot_pipe = popen("gnuplot", "w"); - 578 + 1037 // if it exists - 579 + 1038
1/2 @@ -4826,42 +9747,49 @@

GCC Code Coverage Report

if (gnuplot_pipe) { - 580 + 1039 162 fprintf(gnuplot_pipe, - 581 + 1040 "set terminal png size 800,500 font ',14' linewidth 2\n"); - 582 + 1041 // formatting - 583 + 1042 162 fprintf(gnuplot_pipe, "set output '../%s.png'\n", file_name.c_str()); - 584 + 1043 + + + 162 + fprintf(gnuplot_pipe, "set offsets graph 0, 0, 0.05, 0.05\n"); + + + 1044 162 fprintf(gnuplot_pipe, "set xlabel 'Time [s]'\n"); - 585 + 1045
2/2 @@ -4875,21 +9803,21 @@

GCC Code Coverage Report

if (input_orbital_element_name == "Semimajor Axis") { - 586 + 1046 36 fprintf(gnuplot_pipe, "set ylabel '%s [m]'\n", - 587 + 1047 18 input_orbital_element_name.c_str()); - 588 + 1048
2/2 @@ -4903,112 +9831,112 @@

GCC Code Coverage Report

} else if (input_orbital_element_name == "Eccentricity") { - 589 + 1049 36 fprintf(gnuplot_pipe, "set ylabel '%s'\n", - 590 + 1050 18 input_orbital_element_name.c_str()); - 591 + 1051 18 } else { - 592 + 1052 252 fprintf(gnuplot_pipe, "set ylabel '%s [deg]'\n", - 593 + 1053 126 input_orbital_element_name.c_str()); - 594 + 1054 } - 595 + 1055 324 fprintf(gnuplot_pipe, "set title '%s simulated up to time %.2f s'\n", - 596 + 1056 162 input_orbital_element_name.c_str(), - 597 + 1057 162 input_sim_parameters.total_sim_time); - 598 + 1058 162 fprintf(gnuplot_pipe, "set key right bottom\n"); - 599 + 1059 - 600 + 1060 // plotting - 601 + 1061 - 602 + 1062 // first satellite - 603 + 1063 162 Satellite current_satellite = input_satellite_vector.at(0); - 604 + 1064
2/2 @@ -5022,7 +9950,7 @@

GCC Code Coverage Report

if (input_satellite_vector.size() == 1) { - 605 + 1065
2/2 @@ -5036,28 +9964,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 606 + 1066 27 fprintf(gnuplot_pipe, - 607 + 1067 "plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \n", - 608 + 1068 27 current_satellite.plotting_color_.c_str(), - 609 + 1069
1/2 @@ -5071,28 +9999,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 610 + 1070 27 } else { - 611 + 1071 27 fprintf(gnuplot_pipe, - 612 + 1072 "plot '-' using 1:2 with lines lw 1 title '%s' \n", - 613 + 1073
1/2 @@ -5106,42 +10034,42 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 614 + 1074 } - 615 + 1075 - 616 + 1076 54 } - 617 + 1077 - 618 + 1078 else { - 619 + 1079
2/2 @@ -5155,28 +10083,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 620 + 1080 54 fprintf(gnuplot_pipe, - 621 + 1081 "plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\\\n", - 622 + 1082 54 current_satellite.plotting_color_.c_str(), - 623 + 1083
1/2 @@ -5190,28 +10118,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 624 + 1084 54 } else { - 625 + 1085 54 fprintf(gnuplot_pipe, - 626 + 1086 "plot '-' using 1:2 with lines lw 1 title '%s'\\\n", - 627 + 1087
1/2 @@ -5225,28 +10153,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 628 + 1088 } - 629 + 1089 } - 630 + 1090 - 631 + 1091
2/2 @@ -5260,14 +10188,14 @@

GCC Code Coverage Report

for (size_t satellite_index = 1; - 632 + 1092 648 satellite_index < input_satellite_vector.size(); satellite_index++) { - 633 + 1093
2/4 @@ -5283,7 +10211,7 @@

GCC Code Coverage Report

current_satellite = input_satellite_vector.at(satellite_index); - 634 + 1094
2/2 @@ -5297,7 +10225,7 @@

GCC Code Coverage Report

if (satellite_index < input_satellite_vector.size() - 1) { - 635 + 1095
2/2 @@ -5311,28 +10239,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 636 + 1096 162 fprintf(gnuplot_pipe, - 637 + 1097 ",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \\\n", - 638 + 1098 162 current_satellite.plotting_color_.c_str(), - 639 + 1099
1/2 @@ -5346,28 +10274,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 640 + 1100 162 } else { - 641 + 1101 216 fprintf(gnuplot_pipe, - 642 + 1102 ",'-' using 1:2 with lines lw 1 title '%s' \\\n", - 643 + 1103
1/2 @@ -5381,42 +10309,42 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 644 + 1104 } - 645 + 1105 - 646 + 1106 378 } - 647 + 1107 - 648 + 1108 else { - 649 + 1109
2/2 @@ -5430,28 +10358,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 650 + 1110 54 fprintf(gnuplot_pipe, - 651 + 1111 ",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\n", - 652 + 1112 54 current_satellite.plotting_color_.c_str(), - 653 + 1113
1/2 @@ -5465,21 +10393,21 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 654 + 1114 54 } else { - 655 + 1115 54 fprintf(gnuplot_pipe, ",'-' using 1:2 with lines lw 1 title '%s'\n", - 656 + 1116
1/2 @@ -5493,42 +10421,42 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 657 + 1117 } - 658 + 1118 } - 659 + 1119 486 } - 660 + 1120 - 661 + 1121 // now the orbit data, inline, one satellite at a time - 662 + 1122
1/2 @@ -5542,7 +10470,7 @@

GCC Code Coverage Report

std::cout << "Running simulation...\n"; - 663 + 1123
2/2 @@ -5556,14 +10484,14 @@

GCC Code Coverage Report

for (size_t satellite_index = 0; - 664 + 1124 810 satellite_index < input_satellite_vector.size(); satellite_index++) { - 665 + 1125
2/4 @@ -5579,14 +10507,14 @@

GCC Code Coverage Report

Satellite current_satellite = input_satellite_vector.at(satellite_index); - 666 + 1126 648 double val = - 667 + 1127
2/4 @@ -5602,14 +10530,14 @@

GCC Code Coverage Report

current_satellite.get_orbital_parameter(input_orbital_element_name); - 668 + 1128 648 double current_satellite_time = - 669 + 1129
1/2 @@ -5623,42 +10551,42 @@

GCC Code Coverage Report

current_satellite.get_instantaneous_time(); - 670 + 1130 648 fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, val); - 671 + 1131 - 672 + 1132 648 double evolved_val = {0}; - 673 + 1133 - 674 + 1134 648 double timestep_to_use = input_sim_parameters.initial_timestep_guess; - 675 + 1135
1/2 @@ -5672,7 +10600,7 @@

GCC Code Coverage Report

current_satellite_time = current_satellite.get_instantaneous_time(); - 676 + 1136
2/2 @@ -5686,56 +10614,56 @@

GCC Code Coverage Report

while (current_satellite_time < input_sim_parameters.total_sim_time) { - 677 + 1137 // std::cout << - 678 + 1138 // "========================================================\n"; - 679 + 1139 // std::cout << "Running an evolve step at satellite time " << - 680 + 1140 // current_satellite_time << "\n"; - 681 + 1141 166896 std::pair<double, double> drag_elements = {input_sim_parameters.F_10, - 682 + 1142 83448 input_sim_parameters.A_p}; - 683 + 1143 std::pair<double, int> new_timestep_and_error_code = - 684 + 1144
1/2 @@ -5749,49 +10677,49 @@

GCC Code Coverage Report

current_satellite.evolve_RK45( - 685 + 1145 83448 input_sim_parameters.epsilon, timestep_to_use, - 686 + 1146 83448 input_sim_parameters.perturbation_bool, - 687 + 1147 83448 input_sim_parameters.drag_bool, drag_elements); - 688 + 1148 83448 double new_timestep = new_timestep_and_error_code.first; - 689 + 1149 83448 int error_code = new_timestep_and_error_code.second; - 690 + 1150 - 691 + 1151
1/2 @@ -5805,70 +10733,70 @@

GCC Code Coverage Report

if (error_code != 0) { - 692 + 1152 std::cout << "Error code " << error_code - 693 + 1153 << " detected, halting visualization\n"; - 694 + 1154 fprintf(gnuplot_pipe, "e\n"); - 695 + 1155 fprintf(gnuplot_pipe, "exit \n"); - 696 + 1156 pclose(gnuplot_pipe); - 697 + 1157 return; - 698 + 1158 } - 699 + 1159 83448 timestep_to_use = new_timestep; - 700 + 1160 83448 evolved_val = - 701 + 1161
2/4 @@ -5884,7 +10812,7 @@

GCC Code Coverage Report

current_satellite.get_orbital_parameter(input_orbital_element_name); - 702 + 1162
1/2 @@ -5898,49 +10826,49 @@

GCC Code Coverage Report

current_satellite_time = current_satellite.get_instantaneous_time(); - 703 + 1163 // printf("%.17g %.17g\n", current_satellite_time, - 704 + 1164 // evolved_val); - 705 + 1165 166896 fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, - 706 + 1166 83448 evolved_val); - 707 + 1167 } - 708 + 1168 648 fprintf(gnuplot_pipe, "e\n"); - 709 + 1169
1/2 @@ -5954,28 +10882,21 @@

GCC Code Coverage Report

} - 710 - - - 162 - fprintf(gnuplot_pipe, "pause mouse keypress\n"); - - - 711 + 1170 - 712 + 1171 162 fprintf(gnuplot_pipe, "exit \n"); - 713 + 1172
1/2 @@ -5989,7 +10910,7 @@

GCC Code Coverage Report

pclose(gnuplot_pipe); - 714 + 1173
1/2 @@ -6003,14 +10924,14 @@

GCC Code Coverage Report

std::cout << "Done\n"; - 715 + 1174 - 716 + 1175
1/3 @@ -6025,337 +10946,337 @@

GCC Code Coverage Report

} else { - 717 + 1176 std::cout << "gnuplot not found"; - 718 + 1177 } - 719 + 1178 - 720 + 1179 162 return; - 721 + 1180 162 } - 722 + 1181 - 723 + 1182 - 13480503 + 13480518 Matrix3d z_rot_matrix(const double input_angle) { - 724 + 1183 - 13480503 + 13480518 Matrix3d z_rotation_matrix; - 725 + 1184
4/8
-
✓ Branch 0 taken 13480503 times.
+
✓ Branch 0 taken 13480518 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 13480503 times.
+
✓ Branch 2 taken 13480518 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 13480503 times.
+
✓ Branch 4 taken 13480518 times.
✗ Branch 5 not taken.
-
✓ Branch 6 taken 13480503 times.
+
✓ Branch 6 taken 13480518 times.
✗ Branch 7 not taken.
- 26961006 + 26961036 z_rotation_matrix << cos(input_angle), -sin(input_angle), 0, sin(input_angle), - 726 + 1185
4/8
-
✓ Branch 0 taken 13480503 times.
+
✓ Branch 0 taken 13480518 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 13480503 times.
+
✓ Branch 2 taken 13480518 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 13480503 times.
+
✓ Branch 4 taken 13480518 times.
✗ Branch 5 not taken.
-
✓ Branch 6 taken 13480503 times.
+
✓ Branch 6 taken 13480518 times.
✗ Branch 7 not taken.
- 13480503 + 13480518 cos(input_angle), 0, 0, 0, 1; - 727 + 1186 - 728 + 1187 - 13480503 + 13480518 return z_rotation_matrix; - 729 + 1188} - 730 + 1189 - 731 + 1190 - 57 + 72 Matrix3d y_rot_matrix(const double input_angle) { - 732 + 1191 - 57 + 72 Matrix3d y_rotation_matrix; - 733 + 1192
6/12
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 57 times.
+
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 57 times.
+
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
-
✓ Branch 6 taken 57 times.
+
✓ Branch 6 taken 72 times.
✗ Branch 7 not taken.
-
✓ Branch 8 taken 57 times.
+
✓ Branch 8 taken 72 times.
✗ Branch 9 not taken.
-
✓ Branch 10 taken 57 times.
+
✓ Branch 10 taken 72 times.
✗ Branch 11 not taken.
- 114 + 144 y_rotation_matrix << cos(input_angle), 0, sin(input_angle), 0, 1, 0, - 734 + 1193
2/4
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 57 times.
+
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
- 57 + 72 -sin(input_angle), 0, cos(input_angle); - 735 + 1194 - 736 + 1195 - 57 + 72 return y_rotation_matrix; - 737 + 1196} - 738 + 1197 - 739 + 1198 - 57 + 72 Matrix3d x_rot_matrix(const double input_angle) { - 740 + 1199 - 57 + 72 Matrix3d x_rotation_matrix; - 741 + 1200
7/14
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 57 times.
+
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 57 times.
+
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
-
✓ Branch 6 taken 57 times.
+
✓ Branch 6 taken 72 times.
✗ Branch 7 not taken.
-
✓ Branch 8 taken 57 times.
+
✓ Branch 8 taken 72 times.
✗ Branch 9 not taken.
-
✓ Branch 10 taken 57 times.
+
✓ Branch 10 taken 72 times.
✗ Branch 11 not taken.
-
✓ Branch 12 taken 57 times.
+
✓ Branch 12 taken 72 times.
✗ Branch 13 not taken.
- 114 + 144 x_rotation_matrix << 1, 0, 0, 0, cos(input_angle), -sin(input_angle), 0, - 742 + 1201
1/2
-
✓ Branch 0 taken 57 times.
+
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
- 57 + 72 sin(input_angle), cos(input_angle); - 743 + 1202 - 744 + 1203 - 57 + 72 return x_rotation_matrix; - 745 + 1204} - 746 + 1205 - 747 + 1206 // Objective: simulate the input satellites over the specified total sim time, - 748 + 1207 // and plot a specific attitude-related value over time - 749 + 1208 180 void sim_and_plot_attitude_evolution_gnuplot( - 750 + 1209 std::vector<Satellite> input_satellite_vector, - 751 + 1210 const SimParameters& input_sim_parameters, - 752 + 1211 const std::string input_plotted_val_name, const std::string file_name) { - 753 + 1212
1/2 @@ -6369,56 +11290,56 @@

GCC Code Coverage Report

if (input_satellite_vector.size() < 1) { - 754 + 1213 std::cout << "No input Satellite objects\n"; - 755 + 1214 return; - 756 + 1215 } - 757 + 1216 - 758 + 1217 // first, open "pipe" to gnuplot - 759 + 1218 180 FILE* gnuplot_pipe = popen("gnuplot", "w"); - 760 + 1219 // if it exists - 761 + 1220
1/2 @@ -6432,42 +11353,49 @@

GCC Code Coverage Report

if (gnuplot_pipe) { - 762 + 1221 180 fprintf(gnuplot_pipe, - 763 + 1222 "set terminal png size 800,500 font ',14' linewidth 2\n"); - 764 + 1223 // formatting - 765 + 1224 180 fprintf(gnuplot_pipe, "set output '../%s.png'\n", file_name.c_str()); - 766 + 1225 + + + 180 + fprintf(gnuplot_pipe, "set offsets graph 0, 0, 0.05, 0.05\n"); + + + 1226 180 fprintf(gnuplot_pipe, "set xlabel 'Time [s]'\n"); - 767 + 1227
4/4 @@ -6483,7 +11411,7 @@

GCC Code Coverage Report

if ((input_plotted_val_name == "omega_x") || - 768 + 1228
2/2 @@ -6497,28 +11425,28 @@

GCC Code Coverage Report

(input_plotted_val_name == "omega_y") || - 769 + 1229 144 (input_plotted_val_name == "omega_z")) { - 770 + 1230 108 fprintf(gnuplot_pipe, "set ylabel '%s [deg/s]'\n", - 771 + 1231 54 input_plotted_val_name.c_str()); - 772 + 1232
4/4 @@ -6534,7 +11462,7 @@

GCC Code Coverage Report

} else if ((input_plotted_val_name == "Roll") || - 773 + 1233
2/2 @@ -6548,119 +11476,119 @@

GCC Code Coverage Report

(input_plotted_val_name == "Pitch") || - 774 + 1234 90 (input_plotted_val_name == "Yaw")) { - 775 + 1235 108 fprintf(gnuplot_pipe, "set ylabel '%s [deg]'\n", - 776 + 1236 54 input_plotted_val_name.c_str()); - 777 + 1237 54 } else { - 778 + 1238 144 fprintf(gnuplot_pipe, "set ylabel '%s'\n", - 779 + 1239 72 input_plotted_val_name.c_str()); - 780 + 1240 } - 781 + 1241 360 fprintf(gnuplot_pipe, "set title '%s simulated up to time %.2f s'\n", - 782 + 1242 180 input_plotted_val_name.c_str(), - 783 + 1243 180 input_sim_parameters.total_sim_time); - 784 + 1244 180 fprintf(gnuplot_pipe, "set key right bottom\n"); - 785 + 1245 - 786 + 1246 // plotting - 787 + 1247 - 788 + 1248 // first satellite - 789 + 1249 180 Satellite current_satellite = input_satellite_vector.at(0); - 790 + 1250
2/2 @@ -6674,7 +11602,7 @@

GCC Code Coverage Report

if (input_satellite_vector.size() == 1) { - 791 + 1251
2/2 @@ -6688,28 +11616,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 792 + 1252 30 fprintf(gnuplot_pipe, - 793 + 1253 "plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \n", - 794 + 1254 30 current_satellite.plotting_color_.c_str(), - 795 + 1255
1/2 @@ -6723,28 +11651,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 796 + 1256 30 } else { - 797 + 1257 30 fprintf(gnuplot_pipe, - 798 + 1258 "plot '-' using 1:2 with lines lw 1 title '%s' \n", - 799 + 1259
1/2 @@ -6758,42 +11686,42 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 800 + 1260 } - 801 + 1261 - 802 + 1262 60 } - 803 + 1263 - 804 + 1264 else { - 805 + 1265
2/2 @@ -6807,28 +11735,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 806 + 1266 60 fprintf(gnuplot_pipe, - 807 + 1267 "plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\\\n", - 808 + 1268 60 current_satellite.plotting_color_.c_str(), - 809 + 1269
1/2 @@ -6842,28 +11770,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 810 + 1270 60 } else { - 811 + 1271 60 fprintf(gnuplot_pipe, - 812 + 1272 "plot '-' using 1:2 with lines lw 1 title '%s'\\\n", - 813 + 1273
1/2 @@ -6877,28 +11805,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 814 + 1274 } - 815 + 1275 } - 816 + 1276 - 817 + 1277
2/2 @@ -6912,14 +11840,14 @@

GCC Code Coverage Report

for (size_t satellite_index = 1; - 818 + 1278 720 satellite_index < input_satellite_vector.size(); satellite_index++) { - 819 + 1279
2/4 @@ -6935,7 +11863,7 @@

GCC Code Coverage Report

current_satellite = input_satellite_vector.at(satellite_index); - 820 + 1280
2/2 @@ -6949,7 +11877,7 @@

GCC Code Coverage Report

if (satellite_index < input_satellite_vector.size() - 1) { - 821 + 1281
2/2 @@ -6963,28 +11891,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 822 + 1282 180 fprintf(gnuplot_pipe, - 823 + 1283 ",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \\\n", - 824 + 1284 180 current_satellite.plotting_color_.c_str(), - 825 + 1285
1/2 @@ -6998,28 +11926,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 826 + 1286 180 } else { - 827 + 1287 240 fprintf(gnuplot_pipe, - 828 + 1288 ",'-' using 1:2 with lines lw 1 title '%s' \\\n", - 829 + 1289
1/2 @@ -7033,42 +11961,42 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 830 + 1290 } - 831 + 1291 - 832 + 1292 420 } - 833 + 1293 - 834 + 1294 else { - 835 + 1295
2/2 @@ -7082,28 +12010,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 836 + 1296 60 fprintf(gnuplot_pipe, - 837 + 1297 ",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\n", - 838 + 1298 60 current_satellite.plotting_color_.c_str(), - 839 + 1299
1/2 @@ -7117,21 +12045,21 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 840 + 1300 60 } else { - 841 + 1301 60 fprintf(gnuplot_pipe, ",'-' using 1:2 with lines lw 1 title '%s'\n", - 842 + 1302
1/2 @@ -7145,42 +12073,42 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 843 + 1303 } - 844 + 1304 } - 845 + 1305 540 } - 846 + 1306 - 847 + 1307 // now the orbit data, inline, one satellite at a time - 848 + 1308
1/2 @@ -7194,7 +12122,7 @@

GCC Code Coverage Report

std::cout << "Running simulation...\n"; - 849 + 1309
2/2 @@ -7208,14 +12136,14 @@

GCC Code Coverage Report

for (size_t satellite_index = 0; - 850 + 1310 900 satellite_index < input_satellite_vector.size(); satellite_index++) { - 851 + 1311
2/4 @@ -7231,7 +12159,7 @@

GCC Code Coverage Report

Satellite current_satellite = input_satellite_vector.at(satellite_index); - 852 + 1312
2/4 @@ -7247,14 +12175,14 @@

GCC Code Coverage Report

double val = current_satellite.get_attitude_val(input_plotted_val_name); - 853 + 1313 720 double current_satellite_time = - 854 + 1314
1/2 @@ -7268,42 +12196,42 @@

GCC Code Coverage Report

current_satellite.get_instantaneous_time(); - 855 + 1315 720 fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, val); - 856 + 1316 - 857 + 1317 720 double evolved_val = {0}; - 858 + 1318 - 859 + 1319 720 double timestep_to_use = input_sim_parameters.initial_timestep_guess; - 860 + 1320
1/2 @@ -7317,7 +12245,7 @@

GCC Code Coverage Report

current_satellite_time = current_satellite.get_instantaneous_time(); - 861 + 1321
2/2 @@ -7331,28 +12259,28 @@

GCC Code Coverage Report

while (current_satellite_time < input_sim_parameters.total_sim_time) { - 862 + 1322 190980 std::pair<double, double> drag_elements = {input_sim_parameters.F_10, - 863 + 1323 95490 input_sim_parameters.A_p}; - 864 + 1324 std::pair<double, int> new_timestep_and_error_code = - 865 + 1325
1/2 @@ -7366,49 +12294,49 @@

GCC Code Coverage Report

current_satellite.evolve_RK45( - 866 + 1326 95490 input_sim_parameters.epsilon, timestep_to_use, - 867 + 1327 95490 input_sim_parameters.perturbation_bool, - 868 + 1328 95490 input_sim_parameters.drag_bool, drag_elements); - 869 + 1329 95490 double new_timestep = new_timestep_and_error_code.first; - 870 + 1330 95490 int error_code = new_timestep_and_error_code.second; - 871 + 1331 - 872 + 1332
1/2 @@ -7422,70 +12350,70 @@

GCC Code Coverage Report

if (error_code != 0) { - 873 + 1333 std::cout << "Error code " << error_code - 874 + 1334 << " detected, halting visualization\n"; - 875 + 1335 fprintf(gnuplot_pipe, "e\n"); - 876 + 1336 fprintf(gnuplot_pipe, "exit \n"); - 877 + 1337 pclose(gnuplot_pipe); - 878 + 1338 return; - 879 + 1339 } - 880 + 1340 95490 timestep_to_use = new_timestep; - 881 + 1341 95490 evolved_val = - 882 + 1342
2/4 @@ -7501,7 +12429,7 @@

GCC Code Coverage Report

current_satellite.get_attitude_val(input_plotted_val_name); - 883 + 1343
1/2 @@ -7515,35 +12443,35 @@

GCC Code Coverage Report

current_satellite_time = current_satellite.get_instantaneous_time(); - 884 + 1344 190980 fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, - 885 + 1345 95490 evolved_val); - 886 + 1346 } - 887 + 1347 720 fprintf(gnuplot_pipe, "e\n"); - 888 + 1348
1/2 @@ -7557,28 +12485,21 @@

GCC Code Coverage Report

} - 889 - - - 180 - fprintf(gnuplot_pipe, "pause mouse keypress\n"); - - - 890 + 1349 - 891 + 1350 180 fprintf(gnuplot_pipe, "exit \n"); - 892 + 1351
1/2 @@ -7592,7 +12513,7 @@

GCC Code Coverage Report

pclose(gnuplot_pipe); - 893 + 1352
1/2 @@ -7606,14 +12527,14 @@

GCC Code Coverage Report

std::cout << "Done\n"; - 894 + 1353 - 895 + 1354
1/3 @@ -7628,652 +12549,652 @@

GCC Code Coverage Report

} else { - 896 + 1355 std::cout << "gnuplot not found"; - 897 + 1356 } - 898 + 1357 - 899 + 1358 180 return; - 900 + 1359 180 } - 901 + 1360 - 902 + 1361 - 57 + 72 Matrix3d rollyawpitch_bodyframe_to_LVLH_matrix(const double input_roll, - 903 + 1362 const double input_pitch, - 904 + 1363 const double input_yaw) { - 905 + 1364 // Going off convention in - 906 + 1365 // https://ntrs.nasa.gov/api/citations/19770024112/downloads/19770024112.pdf - 907 + 1366 // which appears to be first rotating by pitch, then yaw, then roll - 908 + 1367 // This is a convention where the rotations are performed as: v_body = - 909 + 1368 // R_x(roll)R_z(yaw)R_y(pitch)v_LVLH That's an intrinsic Tait-Bryan xzy - 910 + 1369 // sequence, following convention described in - 911 + 1370 // https://en.wikipedia.org/wiki/Rotation_matrix To my understanding, this is - 912 + 1371 // equivalent to an extrinsic Tait-Bryan yzx sequence - 913 + 1372 - 914 + 1373 // First going to construct LVLH_to_bodyframe matrix, then take transpose to - 915 + 1374 // make it the bodyframe_to_LVLH matrix - 916 + 1375 - 171 + 216 Matrix3d bodyframe_to_LVLH_matrix = x_rot_matrix(input_roll) * - 917 + 1376 - 114 + 144 z_rot_matrix(input_yaw) * - 918 + 1377 - 57 + 72 y_rot_matrix(input_pitch); - 919 + 1378 - 57 + 72 bodyframe_to_LVLH_matrix.transpose(); - 920 + 1379 - 921 + 1380 - 57 + 72 return bodyframe_to_LVLH_matrix; - 922 + 1381 } - 923 + 1382 - 924 + 1383 - 59 + 74 std::array<double, 4> rollyawpitch_angles_to_quaternion( - 925 + 1384 const double input_roll, const double input_pitch, const double input_yaw) { - 926 + 1385 // Refs : - 927 + 1386 // https://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/Euler%20to%20quat.pdf - 928 + 1387 // and - 929 + 1388 // https://ntrs.nasa.gov/api/citations/19770024112/downloads/19770024112.pdf - 930 + 1389 - 59 + 74 Vector4d q_pitch = {cos(input_pitch / 2), 0.0, sin(input_pitch / 2), 0.0}; - 931 + 1390 - 59 + 74 Vector4d q_yaw = {cos(input_yaw / 2), 0.0, 0.0, sin(input_yaw / 2)}; - 932 + 1391 - 59 + 74 Vector4d q_roll = {cos(input_roll / 2), sin(input_roll / 2), 0.0, 0.0}; - 933 + 1392 - 59 + 74 Vector4d q_tot = quaternion_multiplication( - 934 + 1393 - 59 + 74 q_roll, quaternion_multiplication(q_yaw, q_pitch)); - 935 + 1394 - 118 + 148 std::array<double, 4> output_quaternion = {q_tot(0), q_tot(1), q_tot(2), - 936 + 1395 - 59 + 74 q_tot(3)}; - 937 + 1396 - 59 + 74 return output_quaternion; - 938 + 1397 } - 939 + 1398 - 940 + 1399 - 12466918 + 12533871 Matrix3d LVLH_to_body_transformation_matrix_from_quaternion( - 941 + 1400 const std::array<double, 4> input_bodyframe_quaternion_relative_to_LVLH) { - 942 + 1401 // Ref: - 943 + 1402 // https://ntrs.nasa.gov/api/citations/20240009554/downloads/Space%20Attitude%20Development%20Control.pdf - 944 + 1403 // section 4.3.1 - 945 + 1404 - 12466918 + 12533871 double q0 = input_bodyframe_quaternion_relative_to_LVLH.at(0); - 946 + 1405 - 12466918 + 12533871 double q1 = input_bodyframe_quaternion_relative_to_LVLH.at(1); - 947 + 1406 - 12466918 + 12533871 double q2 = input_bodyframe_quaternion_relative_to_LVLH.at(2); - 948 + 1407 - 12466918 + 12533871 double q3 = input_bodyframe_quaternion_relative_to_LVLH.at(3); - 949 + 1408 - 950 + 1409 - 12466918 + 12533871 Matrix3d LVLH_to_body_mat; - 951 + 1410
2/4
-
✓ Branch 0 taken 12466918 times.
+
✓ Branch 0 taken 12533871 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 12466918 times.
+
✓ Branch 2 taken 12533871 times.
✗ Branch 3 not taken.
- 24933836 + 25067742 LVLH_to_body_mat << 2 * q0 * q0 - 1 + 2 * q1 * q1, 2 * q1 * q2 + 2 * q0 * q3, - 952 + 1411
2/4
-
✓ Branch 0 taken 12466918 times.
+
✓ Branch 0 taken 12533871 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 12466918 times.
+
✓ Branch 2 taken 12533871 times.
✗ Branch 3 not taken.
- 12466918 + 12533871 2 * q1 * q3 - 2 * q0 * q2, 2 * q1 * q2 - 2 * q0 * q3, - 953 + 1412
2/4
-
✓ Branch 0 taken 12466918 times.
+
✓ Branch 0 taken 12533871 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 12466918 times.
+
✓ Branch 2 taken 12533871 times.
✗ Branch 3 not taken.
- 12466918 + 12533871 2 * q0 * q0 - 1 + 2 * q2 * q2, 2 * q2 * q3 + 2 * q0 * q1, - 954 + 1413
2/4
-
✓ Branch 0 taken 12466918 times.
+
✓ Branch 0 taken 12533871 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 12466918 times.
+
✓ Branch 2 taken 12533871 times.
✗ Branch 3 not taken.
- 12466918 + 12533871 2 * q1 * q3 + 2 * q0 * q2, 2 * q2 * q3 - 2 * q0 * q1, - 955 + 1414 - 12466918 + 12533871 2 * q0 * q0 - 1 + 2 * q3 * q3; - 956 + 1415 - 957 + 1416 - 12466918 + 12533871 return LVLH_to_body_mat; - 958 + 1417} - 959 + 1418 - 960 + 1419 // Objective: compute time derivatives of bodyframe angular velocities - 961 + 1420 - 81831276 + 82233540 std::array<double, 3> calculate_spacecraft_bodyframe_angular_acceleration( - 962 + 1421 const Matrix3d J_matrix, - 963 + 1422 const std::vector<BodyframeTorqueProfile> - 964 + 1423 input_bodyframe_torque_profile_list, - 965 + 1424 const Vector3d input_omega_I, - 966 + 1425 const double input_orbital_angular_acceleration, - 967 + 1426 const Vector3d input_omega_bodyframe_wrt_LVLH_in_body_frame, - 968 + 1427 const Matrix3d input_LVLH_to_bodyframe_transformation_matrix, - 969 + 1428 const Vector3d input_omega_LVLH_wrt_inertial_in_LVLH, - 970 + 1429 const double input_evaluation_time) { - 971 + 1430 // Using approach from - 972 + 1431 // https://ntrs.nasa.gov/api/citations/20240009554/downloads/Space%20Attitude%20Development%20Control.pdf - 973 + 1432 // , Ch. 4 especially Objective: calculate omega_dot in spacecraft body frame - 974 + 1433 // w.r.t. the LVLH frame, expressed in the spacecraft body frame Disturbance - 975 + 1434 // torques, if eventually added in, should just be more torque profiles in the - 976 + 1435 // satellite object's list of torque profiles So the input_torques vector - 977 + 1436 // includes both disturbance and control torques - 978 + 1437 - 81831276 + 82233540 Vector3d bodyframe_torque_vec = {0, 0, 0}; - 979 + 1438 - 980 + 1439
2/2
✓ Branch 0 taken 45576600 times.
-
✓ Branch 1 taken 81831276 times.
+
✓ Branch 1 taken 82233540 times.
- 127407876 + 127810140 for (const BodyframeTorqueProfile bodyframe_torque_profile : - 981 + 1440 - 81831276 + 82233540 input_bodyframe_torque_profile_list) { - 982 + 1441
4/4 @@ -8289,14 +13210,14 @@

GCC Code Coverage Report

if ((input_evaluation_time >= bodyframe_torque_profile.t_start_) && - 983 + 1442 44255510 (input_evaluation_time <= bodyframe_torque_profile.t_end_)) { - 984 + 1443
2/2 @@ -8310,2194 +13231,2194 @@

GCC Code Coverage Report

for (size_t ind = 0; ind < 3; ind++) { - 985 + 1444 616800 bodyframe_torque_vec(ind) += - 986 + 1445 616800 bodyframe_torque_profile.bodyframe_torque_list.at(ind); - 987 + 1446 616800 } - 988 + 1447 205600 } - 989 + 1448 } - 990 + 1449 - 991 + 1450 - 81831276 + 82233540 Vector3d omega_lvlh_dot = {0, -input_orbital_angular_acceleration, 0}; - 992 + 1451 - 81831276 + 82233540 Matrix3d inverted_J_matrix = J_matrix; - 993 + 1452 - 81831276 + 82233540 inverted_J_matrix.inverse(); - 994 + 1453 - 995 + 1454 Vector3d comp1 = - 996 + 1455 - 81831276 + 82233540 -inverted_J_matrix * (input_omega_I.cross(J_matrix * input_omega_I)); - 997 + 1456 - 81831276 + 82233540 Vector3d comp2 = inverted_J_matrix * bodyframe_torque_vec; - 998 + 1457 - 81831276 + 82233540 Vector3d comp3 = input_omega_bodyframe_wrt_LVLH_in_body_frame.cross( - 999 + 1458 - 81831276 + 82233540 input_LVLH_to_bodyframe_transformation_matrix * - 1000 + 1459 input_omega_LVLH_wrt_inertial_in_LVLH); - 1001 + 1460 - 81831276 + 82233540 Vector3d omega_dot_vec_LVLH_wrt_inertial_in_ECI = { - 1002 + 1461 - 81831276 + 82233540 0, -input_orbital_angular_acceleration, 0}; - 1003 + 1462 - 81831276 + 82233540 Vector3d comp4 = -input_LVLH_to_bodyframe_transformation_matrix * - 1004 + 1463 omega_dot_vec_LVLH_wrt_inertial_in_ECI; - 1005 + 1464 - 1006 + 1465 Vector3d angular_acceleration_bodyframe_wrt_LVLH_in_bodyframe = - 1007 + 1466 - 81831276 + 82233540 comp1 + comp2 + comp3 + comp4; - 1008 + 1467 std::array<double, 3> - 1009 + 1468 - 81831276 + 82233540 angular_acceleration_bodyframe_wrt_LVLH_in_bodyframe_array = { - 1010 + 1469 - 245493828 + 246700620 angular_acceleration_bodyframe_wrt_LVLH_in_bodyframe(0), - 1011 + 1470 - 81831276 + 82233540 angular_acceleration_bodyframe_wrt_LVLH_in_bodyframe(1), - 1012 + 1471 - 81831276 + 82233540 angular_acceleration_bodyframe_wrt_LVLH_in_bodyframe(2)}; - 1013 + 1472 - 1014 + 1473 - 81831276 + 82233540 return angular_acceleration_bodyframe_wrt_LVLH_in_bodyframe_array; - 1015 + 1474 } - 1016 + 1475 - 1017 + 1476 // Objective: compute time derivatives of components of quaternion describing - 1018 + 1477 // orientation of satellite body frame with respect to LVLH frame - 1019 + 1478 - 81831276 + 82233540 Vector4d quaternion_kinematics_equation( - 1020 + 1479 const Vector4d quaternion_of_bodyframe_relative_to_ref_frame, - 1021 + 1480 const Vector3d angular_velocity_vec_wrt_ref_frame_in_body_frame) { - 1022 + 1481 // Ref: - 1023 + 1482 // https://ntrs.nasa.gov/api/citations/20240009554/downloads/Space%20Attitude%20Development%20Control.pdf - 1024 + 1483 // Section 4.1.2 - 1025 + 1484 - 1026 + 1485 // Here assuming scalar component is first in quaternion - 1027 + 1486 - 81831276 + 82233540 Vector3d vec_component_of_quaternion = { - 1028 + 1487 - 81831276 + 82233540 quaternion_of_bodyframe_relative_to_ref_frame(1), - 1029 + 1488 - 81831276 + 82233540 quaternion_of_bodyframe_relative_to_ref_frame(2), - 1030 + 1489 - 81831276 + 82233540 quaternion_of_bodyframe_relative_to_ref_frame(3)}; - 1031 + 1490 - 81831276 + 82233540 double q_0_dot = - 1032 + 1491 - 81831276 + 82233540 (-0.5) * angular_velocity_vec_wrt_ref_frame_in_body_frame.dot( - 1033 + 1492 vec_component_of_quaternion); - 1034 + 1493 Vector3d vec_q_dot = - 1035 + 1494 - 163662552 + 164467080 (-0.5) * angular_velocity_vec_wrt_ref_frame_in_body_frame.cross( - 1036 + 1495 - 81831276 + 82233540 vec_component_of_quaternion) + - 1037 + 1496 - 81831276 + 82233540 (0.5) * quaternion_of_bodyframe_relative_to_ref_frame(0) * - 1038 + 1497 angular_velocity_vec_wrt_ref_frame_in_body_frame; - 1039 + 1498 - 1040 + 1499 - 81831276 + 82233540 Vector4d quaternion_derivative; - 1041 + 1500
6/12
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 81831276 times.
+
✓ Branch 2 taken 82233540 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 81831276 times.
+
✓ Branch 4 taken 82233540 times.
✗ Branch 5 not taken.
-
✓ Branch 6 taken 81831276 times.
+
✓ Branch 6 taken 82233540 times.
✗ Branch 7 not taken.
-
✓ Branch 8 taken 81831276 times.
+
✓ Branch 8 taken 82233540 times.
✗ Branch 9 not taken.
-
✓ Branch 10 taken 81831276 times.
+
✓ Branch 10 taken 82233540 times.
✗ Branch 11 not taken.
- 81831276 + 82233540 quaternion_derivative << q_0_dot, vec_q_dot(0), vec_q_dot(1), vec_q_dot(2); - 1042 + 1501 - 1043 + 1502 - 81831276 + 82233540 return quaternion_derivative; - 1044 + 1503} - 1045 + 1504 - 1046 + 1505 // Computes time derivative of combined satellite quaternion + angular velocity - 1047 + 1506 // vector - 1048 + 1507 - 81831276 + 82233540 std::array<double, 7> RK45_satellite_body_angular_deriv_function( - 1049 + 1508 const std::array<double, 7> combined_bodyframe_angular_array, - 1050 + 1509 const Matrix3d J_matrix, - 1051 + 1510 const std::vector<BodyframeTorqueProfile> - 1052 + 1511 input_bodyframe_torque_profile_list, - 1053 + 1512 const Vector3d input_omega_I, double input_orbital_angular_acceleration, - 1054 + 1513 const Matrix3d input_LVLH_to_bodyframe_transformation_matrix, - 1055 + 1514 const Vector3d input_omega_LVLH_wrt_inertial_in_LVLH, - 1056 + 1515 const double input_evaluation_time) { - 1057 + 1516 // Setting this up for an RK45 step with - 1058 + 1517 // y={q_0,q_1,q_2,q_3,omega_1,omega_2,omega_3} Objective is to produce dy/dt - 1059 + 1518 // Input quaternion should be quaternion of bodyframe relative to LVLH - 1060 + 1519 - 81831276 + 82233540 std::array<double, 7> combined_angular_derivative_array = {0, 0, 0, 0, - 1061 + 1520 0, 0, 0}; - 1062 + 1521 - 163662552 + 164467080 Vector4d quaternion = {combined_bodyframe_angular_array.at(0), - 1063 + 1522 - 81831276 + 82233540 combined_bodyframe_angular_array.at(1), - 1064 + 1523 - 81831276 + 82233540 combined_bodyframe_angular_array.at(2), - 1065 + 1524 - 81831276 + 82233540 combined_bodyframe_angular_array.at(3)}; - 1066 + 1525 - 81831276 + 82233540 Vector3d body_angular_velocity_vec_wrt_LVLH_in_body_frame = { - 1067 + 1526 - 81831276 + 82233540 combined_bodyframe_angular_array.at(4), - 1068 + 1527 - 81831276 + 82233540 combined_bodyframe_angular_array.at(5), - 1069 + 1528 - 81831276 + 82233540 combined_bodyframe_angular_array.at(6)}; - 1070 + 1529 - 81831276 + 82233540 Vector4d quaternion_derivative = quaternion_kinematics_equation( - 1071 + 1530 - 81831276 + 82233540 quaternion, body_angular_velocity_vec_wrt_LVLH_in_body_frame); - 1072 + 1531 std::array<double, 3> body_angular_acceleration_vec_wrt_LVLH_in_body_frame = - 1073 + 1532
1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 calculate_spacecraft_bodyframe_angular_acceleration( - 1074 + 1533
1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 J_matrix, input_bodyframe_torque_profile_list, input_omega_I, - 1075 + 1534 - 81831276 + 82233540 input_orbital_angular_acceleration, - 1076 + 1535
1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 body_angular_velocity_vec_wrt_LVLH_in_body_frame, - 1077 + 1536
1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 input_LVLH_to_bodyframe_transformation_matrix, - 1078 + 1537
1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 input_omega_LVLH_wrt_inertial_in_LVLH, input_evaluation_time); - 1079 + 1538 - 1080 + 1539
2/2
-
✓ Branch 0 taken 327325104 times.
-
✓ Branch 1 taken 81831276 times.
+
✓ Branch 0 taken 328934160 times.
+
✓ Branch 1 taken 82233540 times.
- 409156380 + 411167700 for (size_t ind = 0; ind < 4; ind++) { - 1081 + 1540 - 327325104 + 328934160 combined_angular_derivative_array.at(ind) = quaternion_derivative(ind); - 1082 + 1541 - 327325104 + 328934160 } - 1083 + 1542
2/2
-
✓ Branch 0 taken 245493828 times.
-
✓ Branch 1 taken 81831276 times.
+
✓ Branch 0 taken 246700620 times.
+
✓ Branch 1 taken 82233540 times.
- 327325104 + 328934160 for (size_t ind = 4; ind < 7; ind++) { - 1084 + 1543 - 245493828 + 246700620 combined_angular_derivative_array.at(ind) = - 1085 + 1544 - 245493828 + 246700620 body_angular_acceleration_vec_wrt_LVLH_in_body_frame.at(ind - 4); - 1086 + 1545 - 245493828 + 246700620 } - 1087 + 1546 - 1088 + 1547 - 81831276 + 82233540 return combined_angular_derivative_array; - 1089 + 1548} - 1090 + 1549 - 1091 + 1550 // Calculate angular velocity of spacecraft body frame with respect to - 1092 + 1551 // inertial (ECI) frame - 1093 + 1552 - 12466918 + 12533871 Vector3d calculate_omega_I( - 1094 + 1553 const Vector3d input_bodyframe_ang_vel_vector_wrt_lvlh, - 1095 + 1554 const Matrix3d input_LVLH_to_bodyframe_transformation_matrix, - 1096 + 1555 const double input_orbital_rate) { - 1097 + 1556 // Eq. 4.17 in - 1098 + 1557 // https://ntrs.nasa.gov/api/citations/20240009554/downloads/Space%20Attitude%20Development%20Control.pdf - 1099 + 1558 - 12466918 + 12533871 Vector3d omega_LVLH_wrt_inertial_in_LVLH = {0, -input_orbital_rate, 0}; - 1100 + 1559 - 12466918 + 12533871 Vector3d omega_I = input_bodyframe_ang_vel_vector_wrt_lvlh + - 1101 + 1560 - 12466918 + 12533871 input_LVLH_to_bodyframe_transformation_matrix * - 1102 + 1561 omega_LVLH_wrt_inertial_in_LVLH; - 1103 + 1562 - 12466918 + 12533871 return omega_I; - 1104 + 1563 } - 1105 + 1564 - 1106 + 1565 - 12466918 + 12533871 Matrix3d construct_J_matrix(const double input_Jxx, const double input_Jyy, - 1107 + 1566 const double input_Jzz) { - 1108 + 1567 - 12466918 + 12533871 Matrix3d J_matrix = Matrix3d::Zero(); - 1109 + 1568 - 12466918 + 12533871 J_matrix(0, 0) = input_Jxx; - 1110 + 1569 - 12466918 + 12533871 J_matrix(1, 1) = input_Jyy; - 1111 + 1570 - 12466918 + 12533871 J_matrix(2, 2) = input_Jzz; - 1112 + 1571 - 12466918 + 12533871 return J_matrix; - 1113 + 1572 } - 1114 + 1573 - 1115 + 1574 std::array<double, 13> - 1116 + 1575 - 81831276 + 82233540 RK45_combined_orbit_position_velocity_attitude_deriv_function( - 1117 + 1576 const std::array<double, 13> - 1118 + 1577 combined_position_velocity_bodyframe_angular_array, - 1119 + 1578 const Matrix3d J_matrix, - 1120 + 1579 const std::vector<BodyframeTorqueProfile> - 1121 + 1580 input_bodyframe_torque_profile_list, - 1122 + 1581 const Vector3d input_omega_I, double input_orbital_angular_acceleration, - 1123 + 1582 const Matrix3d input_LVLH_to_bodyframe_transformation_matrix, - 1124 + 1583 const Vector3d input_omega_LVLH_wrt_inertial_in_LVLH, - 1125 + 1584 const double input_spacecraft_mass, - 1126 + 1585 const std::vector<ThrustProfileLVLH> input_list_of_thrust_profiles_LVLH, - 1127 + 1586 const double input_evaluation_time, const double input_inclination, - 1128 + 1587 const double input_arg_of_periapsis, const double input_true_anomaly, - 1129 + 1588 const double input_F_10, const double input_A_p, const double input_A_s, - 1130 + 1589 const bool perturbation, const bool atmospheric_drag) { - 1131 + 1590 // Input vector is in the form of {ECI_position, - 1132 + 1591 // ECI_velocity,bodyframe_quaternion_to_LVLH,bodyframe_omega_wrt_LVLH} - 1133 + 1592 // Objective is to output derivative of that vector - 1134 + 1593 std::array<double, 13> derivative_vec; - 1135 + 1594 std::array<double, 6> combined_position_and_velocity_array; - 1136 + 1595 std::array<double, 7> combined_angular_array; - 1137 + 1596 - 1138 + 1597
2/2
-
✓ Branch 0 taken 490987656 times.
-
✓ Branch 1 taken 81831276 times.
+
✓ Branch 0 taken 493401240 times.
+
✓ Branch 1 taken 82233540 times.
- 572818932 + 575634780 for (size_t ind = 0; ind < combined_position_and_velocity_array.size(); - 1139 + 1598 - 490987656 + 493401240 ind++) { - 1140 + 1599 - 490987656 + 493401240 combined_position_and_velocity_array.at(ind) = - 1141 + 1600 - 490987656 + 493401240 combined_position_velocity_bodyframe_angular_array.at(ind); - 1142 + 1601 - 490987656 + 493401240 } - 1143 + 1602
2/2
-
✓ Branch 0 taken 572818932 times.
-
✓ Branch 1 taken 81831276 times.
+
✓ Branch 0 taken 575634780 times.
+
✓ Branch 1 taken 82233540 times.
- 654650208 + 657868320 for (size_t ind = 0; ind < combined_angular_array.size(); ind++) { - 1144 + 1603 - 572818932 + 575634780 combined_angular_array.at(ind) = - 1145 + 1604 - 572818932 + 575634780 combined_position_velocity_bodyframe_angular_array.at( - 1146 + 1605 - 572818932 + 575634780 ind + combined_position_and_velocity_array.size()); - 1147 + 1606 - 572818932 + 575634780 } - 1148 + 1607 std::array<double, 6> orbital_position_and_velocity_derivative_array = - 1149 + 1608
1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 RK45_deriv_function_orbit_position_and_velocity( - 1150 + 1609 - 81831276 + 82233540 combined_position_and_velocity_array, input_spacecraft_mass, - 1151 + 1610 - 81831276 + 82233540 input_list_of_thrust_profiles_LVLH, input_evaluation_time, - 1152 + 1611 - 81831276 + 82233540 input_inclination, input_arg_of_periapsis, input_true_anomaly, - 1153 + 1612 - 81831276 + 82233540 input_F_10, input_A_p, input_A_s, input_spacecraft_mass, perturbation, - 1154 + 1613 - 81831276 + 82233540 atmospheric_drag); - 1155 + 1614 - 1156 + 1615 std::array<double, 7> angular_derivative_array = - 1157 + 1616
1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 RK45_satellite_body_angular_deriv_function( - 1158 + 1617 - 81831276 + 82233540 combined_angular_array, J_matrix, input_bodyframe_torque_profile_list, - 1159 + 1618
1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 input_omega_I, input_orbital_angular_acceleration, - 1160 + 1619
1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 input_LVLH_to_bodyframe_transformation_matrix, - 1161 + 1620
1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 input_omega_LVLH_wrt_inertial_in_LVLH, input_evaluation_time); - 1162 + 1621 - 1163 + 1622
2/2
-
✓ Branch 0 taken 490987656 times.
-
✓ Branch 1 taken 81831276 times.
+
✓ Branch 0 taken 493401240 times.
+
✓ Branch 1 taken 82233540 times.
- 572818932 + 575634780 for (size_t ind = 0; - 1164 + 1623 - 572818932 + 575634780 ind < orbital_position_and_velocity_derivative_array.size(); ind++) { - 1165 + 1624 - 490987656 + 493401240 derivative_vec.at(ind) = - 1166 + 1625 - 490987656 + 493401240 orbital_position_and_velocity_derivative_array.at(ind); - 1167 + 1626 - 490987656 + 493401240 } - 1168 + 1627
2/2
-
✓ Branch 0 taken 572818932 times.
-
✓ Branch 1 taken 81831276 times.
+
✓ Branch 0 taken 575634780 times.
+
✓ Branch 1 taken 82233540 times.
- 654650208 + 657868320 for (size_t ind = 0; ind < angular_derivative_array.size(); ind++) { - 1169 + 1628 - 1145637864 + 1151269560 derivative_vec.at(ind + - 1170 + 1629 - 1145637864 + 1151269560 orbital_position_and_velocity_derivative_array.size()) = - 1171 + 1630 - 572818932 + 575634780 angular_derivative_array.at(ind); - 1172 + 1631 - 572818932 + 575634780 } - 1173 + 1632 - 1174 + 1633 - 81831276 + 82233540 return derivative_vec; - 1175 + 1634} - 1176 + 1635 - 1177 + 1636 - 12466977 + 12533945 std::array<double, 4> normalize_quaternion( - 1178 + 1637 std::array<double, 4> input_quaternion) { - 1179 + 1638 - 12466977 + 12533945 double length = 0; - 1180 + 1639
2/2
-
✓ Branch 0 taken 49867908 times.
-
✓ Branch 1 taken 12466977 times.
+
✓ Branch 0 taken 50135780 times.
+
✓ Branch 1 taken 12533945 times.
- 62334885 + 62669725 for (size_t ind = 0; ind < input_quaternion.size(); ind++) { - 1181 + 1640 - 49867908 + 50135780 length += (input_quaternion.at(ind) * input_quaternion.at(ind)); - 1182 + 1641 - 49867908 + 50135780 } - 1183 + 1642
2/2
-
✓ Branch 0 taken 49867908 times.
-
✓ Branch 1 taken 12466977 times.
+
✓ Branch 0 taken 50135780 times.
+
✓ Branch 1 taken 12533945 times.
- 62334885 + 62669725 for (size_t ind = 0; ind < input_quaternion.size(); ind++) { - 1184 + 1643 - 49867908 + 50135780 input_quaternion.at(ind) /= sqrt(length); - 1185 + 1644 - 49867908 + 50135780 } - 1186 + 1645 - 12466977 + 12533945 return input_quaternion; - 1187 + 1646 } - 1188 + 1647 - 1189 + 1648 - 12466918 + 12533871 std::array<double, 3> convert_quaternion_to_roll_yaw_pitch_angles( - 1190 + 1649 const std::array<double, 4> input_quaternion) { - 1191 + 1650 // Based on approach in - 1192 + 1651 // https://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/quat_2_euler_paper_ver2-1.pdf - 1193 + 1652 // Again, here I'm going off the pitch-yaw-roll sequence used in - 1194 + 1653 // https://ntrs.nasa.gov/api/citations/19770024112/downloads/19770024112.pdf - 1195 + 1654 // Where the angles which defined the orbiter attitude with respect to LVLH - 1196 + 1655 // are [A]_from_LVLH_to_BY = Rx(roll)*R_z(yaw)*R_y(pitch) - 1197 + 1656 - 1198 + 1657 - 24933836 + 25067742 Vector3d v3 = {0, 1, - 1199 + 1658 - 12466918 + 12533871 0}; // unit vector in direction of last rotation performed, - 1200 + 1659 // which in this sequence is the y unit vector - 1201 + 1660 - 24933836 + 25067742 Quaterniond eigen_quaternion(input_quaternion.at(0), input_quaternion.at(1), - 1202 + 1661 - 12466918 + 12533871 input_quaternion.at(2), input_quaternion.at(3)); - 1203 + 1662 - 12466918 + 12533871 eigen_quaternion.normalize(); // Just in case - 1204 + 1663 - 12466918 + 12533871 Matrix3d rotation_matrix = eigen_quaternion.toRotationMatrix(); - 1205 + 1664 - 12466918 + 12533871 Vector3d euler_angles = rotation_matrix.eulerAngles( - 1206 + 1665 0, 2, - 1207 + 1666 1); // Eigen uses intrinsic convention, so this is an intrinsic XZY - 1208 + 1667 // (denoted x-z'-y'' in the notation Wikipedia uses) or extrinsic YZX - 1209 + 1668 // sequence corresponding to R_x R_z R_y (e.g., see - 1210 + 1669 // https://arg.usask.ca/docs/skplatform/appendices/rotation_matrices.html) - 1211 + 1670 - 1212 + 1671 - 12466918 + 12533871 double roll = euler_angles(0); - 1213 + 1672 - 12466918 + 12533871 double yaw = euler_angles(1); - 1214 + 1673 - 12466918 + 12533871 double pitch = euler_angles(2); - 1215 + 1674 - 1216 + 1675 - 12466918 + 12533871 std::array<double, 3> output_angle_vec = {roll, yaw, pitch}; - 1217 + 1676 - 12466918 + 12533871 return output_angle_vec; - 1218 + 1677 } - 1219 + 1678 - 1220 + 1679 - 57 + 72 std::array<double, 3> convert_array_from_LVLH_to_bodyframe( - 1221 + 1680 const std::array<double, 3> input_LVLH_frame_array, const double input_roll, - 1222 + 1681 const double input_yaw, const double input_pitch) { - 1223 + 1682 Matrix3d transformation_matrix = - 1224 + 1683 - 57 + 72 rollyawpitch_bodyframe_to_LVLH_matrix(input_roll, input_pitch, input_yaw); - 1225 + 1684 - 114 + 144 Vector3d input_LVLH_frame_vector = {input_LVLH_frame_array.at(0), - 1226 + 1685 - 57 + 72 input_LVLH_frame_array.at(1), - 1227 + 1686 - 57 + 72 input_LVLH_frame_array.at(2)}; - 1228 + 1687 - 57 + 72 Vector3d bodyframe_vec = transformation_matrix * input_LVLH_frame_vector; - 1229 + 1688 - 114 + 144 std::array<double, 3> bodyframe_arr = {bodyframe_vec(0), bodyframe_vec(1), - 1230 + 1689 - 57 + 72 bodyframe_vec(2)}; - 1231 + 1690 - 57 + 72 return bodyframe_arr; - 1232 + 1691 } - 1233 + 1692 - 1234 + 1693 5 Vector3d convert_lat_long_to_ECEF(const double latitude, const double longitude, - 1235 + 1694 const double height) { - 1236 + 1695 5 double a = 6378137; // Equatorial radius [m] - 1237 + 1696 5 double b = 6356752; // Polar radius [m] - 1238 + 1697 - 1239 + 1698 // Refs: - 1240 + 1699 // https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#From_geodetic_to_ECEF_coordinates - 1241 + 1700 // https://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html - 1242 + 1701 5 double e = 1 - ((b * b) / (a * a)); - 1243 + 1702 5 double N = - 1244 + 1703 5 a / (sqrt(1 - ((e * e) / (1 + pow(cos(latitude) / sin(latitude), 2))))); - 1245 + 1704 5 double x = (N + height) * cos(latitude) * cos(longitude); - 1246 + 1705 5 double y = (N + height) * cos(latitude) * sin(longitude); - 1247 + 1706 5 double z = ((1 - e * e) * N + height) * sin(latitude); - 1248 + 1707 5 Vector3d output_ECEF_array = {x, y, z}; - 1249 + 1708 5 return output_ECEF_array; - 1250 + 1709 } - 1251 + 1710 - 1252 + 1711 13480446 Vector3d convert_ECEF_to_ECI(const Vector3d input_ECEF_position, - 1253 + 1712 const double input_time) { - 1254 + 1713 // Simple rotation-based conversion, not yet accounting for higher-fidelity - 1255 + 1714 // effects like changes to Earth axes Ref: - 1256 + 1715 // https://x-lumin.com/wp-content/uploads/2020/09/Coordinate_Transforms.pdf - 1257 + 1716 // https://space.stackexchange.com/questions/43187/is-this-commonly-attributed-eci-earth-centered-inertial-to-ecef-earth-centere - 1258 + 1717 // https://space.stackexchange.com/questions/38807/transform-eci-to-ecef - 1259 + 1718 13480446 double omega_Earth = - 1260 + 1719 0.261799387799149 * (1.0 / 3600.0); // [radians / second] - 1261 + 1720 13480446 double ERA_at_J200 = 280.46 * (M_PI / 180); // radians - 1262 + 1721 // Going to be assuming, for simplicity, that satellites start orbiting at the - 1263 + 1722 // J200 epoch - 1264 + 1723 13480446 double theta_g = ERA_at_J200 + omega_Earth * input_time; - 1265 + 1724 13480446 Matrix3d rotation_matrix = z_rot_matrix(theta_g); - 1266 + 1725 13480446 Vector3d ECI_array = rotation_matrix * input_ECEF_position; - 1267 + 1726 13480446 return ECI_array; - 1268 + 1727 } - 1269 + 1728 - 1270 + 1729 162 void sim_and_plot_gs_connectivity_distance_gnuplot( - 1271 + 1730 PhasedArrayGroundStation input_ground_station, - 1272 + 1731 std::vector<Satellite> input_satellite_vector, - 1273 + 1732 const SimParameters& input_sim_parameters, const std::string file_name) { - 1274 + 1733 // Objective: given an input ground station and satellite vector, - 1275 + 1734 // plot contact distances between ground station and satellites over time - 1276 + 1735 - 1277 + 1736
1/2 @@ -10511,56 +15432,56 @@

GCC Code Coverage Report

if (input_satellite_vector.size() < 1) { - 1278 + 1737 std::cout << "No input Satellite objects\n"; - 1279 + 1738 return; - 1280 + 1739 } - 1281 + 1740 - 1282 + 1741 // first, open "pipe" to gnuplot - 1283 + 1742 162 FILE* gnuplot_pipe = popen("gnuplot", "w"); - 1284 + 1743 // if it exists - 1285 + 1744
1/2 @@ -10574,140 +15495,140 @@

GCC Code Coverage Report

if (gnuplot_pipe) { - 1286 + 1745 162 fprintf(gnuplot_pipe, - 1287 + 1746 "set terminal png size 800,500 font ',14' linewidth 2\n"); - 1288 + 1747 // formatting - 1289 + 1748 162 fprintf(gnuplot_pipe, "set output '../%s.png'\n", file_name.c_str()); - 1290 + 1749 162 fprintf(gnuplot_pipe, "set xlabel 'Time [s]'\n"); - 1291 + 1750 162 fprintf(gnuplot_pipe, "set ylabel 'Distance [m]'\n"); - 1292 + 1751 - 1293 + 1752 324 fprintf(gnuplot_pipe, - 1294 + 1753 "set title 'Phased array ground station connectivity " - 1295 + 1754 "with %d beams'\n", - 1296 + 1755 162 input_ground_station.num_beams_); - 1297 + 1756 162 fprintf(gnuplot_pipe, "set key outside\n"); - 1298 + 1757 162 int x_max_plot_window = - 1299 + 1758 162 std::floor(input_sim_parameters.total_sim_time * 1.05); - 1300 + 1759 162 fprintf(gnuplot_pipe, "set xrange[0:%d]\n", x_max_plot_window); - 1301 + 1760 // plotting - 1302 + 1761 - 1303 + 1762 // first satellite - 1304 + 1763 162 Satellite current_satellite = input_satellite_vector.at(0); - 1305 + 1764
2/2 @@ -10721,7 +15642,7 @@

GCC Code Coverage Report

if (input_satellite_vector.size() == 1) { - 1306 + 1765
2/2 @@ -10735,28 +15656,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 1307 + 1766 27 fprintf(gnuplot_pipe, - 1308 + 1767 "plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \n", - 1309 + 1768 27 current_satellite.plotting_color_.c_str(), - 1310 + 1769
1/2 @@ -10770,28 +15691,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1311 + 1770 27 } else { - 1312 + 1771 27 fprintf(gnuplot_pipe, - 1313 + 1772 "plot '-' using 1:2 with lines lw 1 title '%s' \n", - 1314 + 1773
1/2 @@ -10805,42 +15726,42 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1315 + 1774 } - 1316 + 1775 - 1317 + 1776 54 } - 1318 + 1777 - 1319 + 1778 else { - 1320 + 1779
2/2 @@ -10854,28 +15775,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 1321 + 1780 54 fprintf(gnuplot_pipe, - 1322 + 1781 "plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\\\n", - 1323 + 1782 54 current_satellite.plotting_color_.c_str(), - 1324 + 1783
1/2 @@ -10889,28 +15810,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1325 + 1784 54 } else { - 1326 + 1785 54 fprintf(gnuplot_pipe, - 1327 + 1786 "plot '-' using 1:2 with lines lw 1 title '%s'\\\n", - 1328 + 1787
1/2 @@ -10924,28 +15845,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1329 + 1788 } - 1330 + 1789 } - 1331 + 1790 - 1332 + 1791
2/2 @@ -10959,14 +15880,14 @@

GCC Code Coverage Report

for (size_t satellite_index = 1; - 1333 + 1792 648 satellite_index < input_satellite_vector.size(); satellite_index++) { - 1334 + 1793
2/4 @@ -10982,7 +15903,7 @@

GCC Code Coverage Report

current_satellite = input_satellite_vector.at(satellite_index); - 1335 + 1794
2/2 @@ -10996,7 +15917,7 @@

GCC Code Coverage Report

if (satellite_index < input_satellite_vector.size() - 1) { - 1336 + 1795
2/2 @@ -11010,28 +15931,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 1337 + 1796 162 fprintf(gnuplot_pipe, - 1338 + 1797 ",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \\\n", - 1339 + 1798 162 current_satellite.plotting_color_.c_str(), - 1340 + 1799
1/2 @@ -11045,28 +15966,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1341 + 1800 162 } else { - 1342 + 1801 216 fprintf(gnuplot_pipe, - 1343 + 1802 ",'-' using 1:2 with lines lw 1 title '%s' \\\n", - 1344 + 1803
1/2 @@ -11080,42 +16001,42 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1345 + 1804 } - 1346 + 1805 - 1347 + 1806 378 } - 1348 + 1807 - 1349 + 1808 else { - 1350 + 1809
2/2 @@ -11129,28 +16050,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 1351 + 1810 54 fprintf(gnuplot_pipe, - 1352 + 1811 ",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\n", - 1353 + 1812 54 current_satellite.plotting_color_.c_str(), - 1354 + 1813
1/2 @@ -11164,21 +16085,21 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1355 + 1814 54 } else { - 1356 + 1815 54 fprintf(gnuplot_pipe, ",'-' using 1:2 with lines lw 1 title '%s'\n", - 1357 + 1816
1/2 @@ -11192,42 +16113,42 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1358 + 1817 } - 1359 + 1818 } - 1360 + 1819 486 } - 1361 + 1820 - 1362 + 1821 // now the orbit data, inline, one satellite at a time - 1363 + 1822
1/2 @@ -11241,7 +16162,7 @@

GCC Code Coverage Report

std::cout << "Running simulation...\n"; - 1364 + 1823
2/2 @@ -11255,14 +16176,14 @@

GCC Code Coverage Report

for (size_t satellite_index = 0; - 1365 + 1824 810 satellite_index < input_satellite_vector.size(); satellite_index++) { - 1366 + 1825
2/4 @@ -11278,14 +16199,14 @@

GCC Code Coverage Report

Satellite current_satellite = input_satellite_vector.at(satellite_index); - 1367 + 1826 648 double current_satellite_time = - 1368 + 1827
1/2 @@ -11299,21 +16220,21 @@

GCC Code Coverage Report

current_satellite.get_instantaneous_time(); - 1369 + 1828 648 double previous_time = current_satellite_time - 1; - 1370 + 1829 648 double ground_station_beam_angle = - 1371 + 1830
1/2 @@ -11327,7 +16248,7 @@

GCC Code Coverage Report

input_ground_station.angle_to_satellite_from_normal( - 1372 + 1831
1/2 @@ -11341,14 +16262,14 @@

GCC Code Coverage Report

current_satellite); - 1373 + 1832 double initial_distance; - 1374 + 1833
2/4 @@ -11364,91 +16285,91 @@

GCC Code Coverage Report

if (ground_station_beam_angle > - 1375 + 1834 648 input_ground_station.max_beam_angle_from_normal_) { - 1376 + 1835 648 fprintf(gnuplot_pipe, "%.17g NaN\n", current_satellite_time); - 1377 + 1836 648 } else { - 1378 + 1837 initial_distance = - 1379 + 1838 input_ground_station.distance_to_satellite(current_satellite); - 1380 + 1839 fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, - 1381 + 1840 initial_distance); - 1382 + 1841 } - 1383 + 1842 - 1384 + 1843 648 double evolved_distance = {0}; - 1385 + 1844 - 1386 + 1845 648 double timestep_to_use = input_sim_parameters.initial_timestep_guess; - 1387 + 1846
1/2 @@ -11462,7 +16383,7 @@

GCC Code Coverage Report

current_satellite_time = current_satellite.get_instantaneous_time(); - 1388 + 1847
2/2 @@ -11476,28 +16397,28 @@

GCC Code Coverage Report

while (current_satellite_time < input_sim_parameters.total_sim_time) { - 1389 + 1848 8747784 std::pair<double, double> drag_elements = {input_sim_parameters.F_10, - 1390 + 1849 4373892 input_sim_parameters.A_p}; - 1391 + 1850 std::pair<double, int> new_timestep_and_error_code = - 1392 + 1851
1/2 @@ -11511,49 +16432,49 @@

GCC Code Coverage Report

current_satellite.evolve_RK45( - 1393 + 1852 4373892 input_sim_parameters.epsilon, timestep_to_use, - 1394 + 1853 4373892 input_sim_parameters.perturbation_bool, - 1395 + 1854 4373892 input_sim_parameters.drag_bool, drag_elements); - 1396 + 1855 4373892 double new_timestep = new_timestep_and_error_code.first; - 1397 + 1856 4373892 int error_code = new_timestep_and_error_code.second; - 1398 + 1857 - 1399 + 1858
1/2 @@ -11567,70 +16488,70 @@

GCC Code Coverage Report

if (error_code != 0) { - 1400 + 1859 std::cout << "Error code " << error_code - 1401 + 1860 << " detected, halting visualization\n"; - 1402 + 1861 fprintf(gnuplot_pipe, "e\n"); - 1403 + 1862 fprintf(gnuplot_pipe, "exit \n"); - 1404 + 1863 pclose(gnuplot_pipe); - 1405 + 1864 return; - 1406 + 1865 } - 1407 + 1866 4373892 timestep_to_use = new_timestep; - 1408 + 1867 4373892 evolved_distance = - 1409 + 1868
2/4 @@ -11646,14 +16567,14 @@

GCC Code Coverage Report

input_ground_station.distance_to_satellite(current_satellite); - 1410 + 1869 4373892 previous_time = current_satellite_time; - 1411 + 1870
1/2 @@ -11667,14 +16588,14 @@

GCC Code Coverage Report

current_satellite_time = current_satellite.get_instantaneous_time(); - 1412 + 1871 4373892 ground_station_beam_angle = - 1413 + 1872
1/2 @@ -11688,7 +16609,7 @@

GCC Code Coverage Report

input_ground_station.angle_to_satellite_from_normal( - 1414 + 1873
1/2 @@ -11702,21 +16623,21 @@

GCC Code Coverage Report

current_satellite); - 1415 + 1874 // Check number of existing connections to ground station at this point - 1416 + 1875 4373892 int num_sats_at_this_time = - 1417 + 1876
1/2 @@ -11730,14 +16651,14 @@

GCC Code Coverage Report

input_ground_station.num_sats_connected_at_this_time( - 1418 + 1877 4373892 current_satellite_time); - 1419 + 1878
2/2 @@ -11751,7 +16672,7 @@

GCC Code Coverage Report

if ((ground_station_beam_angle > - 1420 + 1879
4/4 @@ -11767,35 +16688,35 @@

GCC Code Coverage Report

input_ground_station.max_beam_angle_from_normal_) || - 1421 + 1880 412353 (num_sats_at_this_time == input_ground_station.num_beams_)) { - 1422 + 1881 4016421 fprintf(gnuplot_pipe, "%.17g NaN\n", current_satellite_time); - 1423 + 1882 4016421 } else { - 1424 + 1883 357471 evolved_distance = - 1425 + 1884
2/4 @@ -11811,21 +16732,21 @@

GCC Code Coverage Report

input_ground_station.distance_to_satellite(current_satellite); - 1426 + 1885 714942 fprintf(gnuplot_pipe, "%.17g %.17g\n", current_satellite_time, - 1427 + 1886 357471 evolved_distance); - 1428 + 1887
1/2 @@ -11839,35 +16760,35 @@

GCC Code Coverage Report

input_ground_station.update_linked_sats_map( - 1429 + 1888 357471 satellite_index, current_satellite_time, previous_time); - 1430 + 1889 } - 1431 + 1890 } - 1432 + 1891 648 fprintf(gnuplot_pipe, "e\n"); - 1433 + 1892
1/2 @@ -11881,28 +16802,28 @@

GCC Code Coverage Report

} - 1434 + 1893 162 fprintf(gnuplot_pipe, "pause mouse keypress\n"); - 1435 + 1894 - 1436 + 1895 162 fprintf(gnuplot_pipe, "exit \n"); - 1437 + 1896
1/2 @@ -11916,7 +16837,7 @@

GCC Code Coverage Report

pclose(gnuplot_pipe); - 1438 + 1897
1/2 @@ -11930,14 +16851,14 @@

GCC Code Coverage Report

std::cout << "Done\n"; - 1439 + 1898 - 1440 + 1899
1/3 @@ -11952,98 +16873,98 @@

GCC Code Coverage Report

} else { - 1441 + 1900 std::cout << "gnuplot not found"; - 1442 + 1901 } - 1443 + 1902 - 1444 + 1903 162 return; - 1445 + 1904 162 } - 1446 + 1905 - 1447 + 1906 162 void sim_and_plot_gs_connectivity_gnuplot( - 1448 + 1907 PhasedArrayGroundStation input_ground_station, - 1449 + 1908 std::vector<Satellite> input_satellite_vector, - 1450 + 1909 const SimParameters& input_sim_parameters, const std::string file_name) { - 1451 + 1910 // Objective: given an input ground station and satellite vector, - 1452 + 1911 // plot contact distances between ground station and satellites over time - 1453 + 1912 - 1454 + 1913
1/2 @@ -12057,56 +16978,56 @@

GCC Code Coverage Report

if (input_satellite_vector.size() < 1) { - 1455 + 1914 std::cout << "No input Satellite objects\n"; - 1456 + 1915 return; - 1457 + 1916 } - 1458 + 1917 - 1459 + 1918 // first, open "pipe" to gnuplot - 1460 + 1919 162 FILE* gnuplot_pipe = popen("gnuplot", "w"); - 1461 + 1920 // if it exists - 1462 + 1921
1/2 @@ -12120,161 +17041,161 @@

GCC Code Coverage Report

if (gnuplot_pipe) { - 1463 + 1922 162 fprintf(gnuplot_pipe, - 1464 + 1923 "set terminal png size 800,500 font ',14' linewidth 2\n"); - 1465 + 1924 // formatting - 1466 + 1925 162 fprintf(gnuplot_pipe, "set output '../%s.png'\n", file_name.c_str()); - 1467 + 1926 162 fprintf(gnuplot_pipe, "set xlabel 'Time [s]'\n"); - 1468 + 1927 162 fprintf(gnuplot_pipe, "set ylabel 'Satellite Index'\n"); - 1469 + 1928 - 1470 + 1929 324 fprintf(gnuplot_pipe, - 1471 + 1930 "set title 'Phased array ground station connectivity " - 1472 + 1931 "with %d beams'\n", - 1473 + 1932 162 input_ground_station.num_beams_); - 1474 + 1933 162 fprintf(gnuplot_pipe, "set key outside\n"); - 1475 + 1934 162 int x_max_plot_window = - 1476 + 1935 162 std::floor(input_sim_parameters.total_sim_time * 1.05); - 1477 + 1936 162 fprintf(gnuplot_pipe, "set xrange[0:%d]\n", x_max_plot_window); - 1478 + 1937 324 fprintf(gnuplot_pipe, "set yrange[-0.5:%lu]\n", - 1479 + 1938 162 input_satellite_vector.size()); - 1480 + 1939 - 1481 + 1940 // plotting - 1482 + 1941 - 1483 + 1942 // first satellite - 1484 + 1943 162 Satellite current_satellite = input_satellite_vector.at(0); - 1485 + 1944
2/2 @@ -12288,7 +17209,7 @@

GCC Code Coverage Report

if (input_satellite_vector.size() == 1) { - 1486 + 1945
2/2 @@ -12302,28 +17223,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 1487 + 1946 27 fprintf(gnuplot_pipe, - 1488 + 1947 "plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \n", - 1489 + 1948 27 current_satellite.plotting_color_.c_str(), - 1490 + 1949
1/2 @@ -12337,28 +17258,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1491 + 1950 27 } else { - 1492 + 1951 27 fprintf(gnuplot_pipe, - 1493 + 1952 "plot '-' using 1:2 with lines lw 1 title '%s' \n", - 1494 + 1953
1/2 @@ -12372,42 +17293,42 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1495 + 1954 } - 1496 + 1955 - 1497 + 1956 54 } - 1498 + 1957 - 1499 + 1958 else { - 1500 + 1959
2/2 @@ -12421,28 +17342,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 1501 + 1960 54 fprintf(gnuplot_pipe, - 1502 + 1961 "plot '-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\\\n", - 1503 + 1962 54 current_satellite.plotting_color_.c_str(), - 1504 + 1963
1/2 @@ -12456,28 +17377,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1505 + 1964 54 } else { - 1506 + 1965 54 fprintf(gnuplot_pipe, - 1507 + 1966 "plot '-' using 1:2 with lines lw 1 title '%s'\\\n", - 1508 + 1967
1/2 @@ -12491,28 +17412,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1509 + 1968 } - 1510 + 1969 } - 1511 + 1970 - 1512 + 1971
2/2 @@ -12526,14 +17447,14 @@

GCC Code Coverage Report

for (size_t satellite_index = 1; - 1513 + 1972 648 satellite_index < input_satellite_vector.size(); satellite_index++) { - 1514 + 1973
2/4 @@ -12549,7 +17470,7 @@

GCC Code Coverage Report

current_satellite = input_satellite_vector.at(satellite_index); - 1515 + 1974
2/2 @@ -12563,7 +17484,7 @@

GCC Code Coverage Report

if (satellite_index < input_satellite_vector.size() - 1) { - 1516 + 1975
2/2 @@ -12577,28 +17498,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 1517 + 1976 162 fprintf(gnuplot_pipe, - 1518 + 1977 ",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s' \\\n", - 1519 + 1978 162 current_satellite.plotting_color_.c_str(), - 1520 + 1979
1/2 @@ -12612,28 +17533,28 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1521 + 1980 162 } else { - 1522 + 1981 216 fprintf(gnuplot_pipe, - 1523 + 1982 ",'-' using 1:2 with lines lw 1 title '%s' \\\n", - 1524 + 1983
1/2 @@ -12647,42 +17568,42 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1525 + 1984 } - 1526 + 1985 - 1527 + 1986 378 } - 1528 + 1987 - 1529 + 1988 else { - 1530 + 1989
2/2 @@ -12696,28 +17617,28 @@

GCC Code Coverage Report

if (current_satellite.plotting_color_.size() > 0) { - 1531 + 1990 54 fprintf(gnuplot_pipe, - 1532 + 1991 ",'-' using 1:2 with lines lw 1 lc rgb '%s' title '%s'\n", - 1533 + 1992 54 current_satellite.plotting_color_.c_str(), - 1534 + 1993
1/2 @@ -12731,21 +17652,21 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1535 + 1994 54 } else { - 1536 + 1995 54 fprintf(gnuplot_pipe, ",'-' using 1:2 with lines lw 1 title '%s'\n", - 1537 + 1996
1/2 @@ -12759,42 +17680,42 @@

GCC Code Coverage Report

current_satellite.get_name().c_str()); - 1538 + 1997 } - 1539 + 1998 } - 1540 + 1999 486 } - 1541 + 2000 - 1542 + 2001 // now the orbit data, inline, one satellite at a time - 1543 + 2002
1/2 @@ -12808,7 +17729,7 @@

GCC Code Coverage Report

std::cout << "Running simulation...\n"; - 1544 + 2003
2/2 @@ -12822,14 +17743,14 @@

GCC Code Coverage Report

for (size_t satellite_index = 0; - 1545 + 2004 810 satellite_index < input_satellite_vector.size(); satellite_index++) { - 1546 + 2005
2/4 @@ -12845,14 +17766,14 @@

GCC Code Coverage Report

Satellite current_satellite = input_satellite_vector.at(satellite_index); - 1547 + 2006 648 double current_satellite_time = - 1548 + 2007
1/2 @@ -12866,21 +17787,21 @@

GCC Code Coverage Report

current_satellite.get_instantaneous_time(); - 1549 + 2008 648 double previous_time = current_satellite_time - 1; - 1550 + 2009 648 double ground_station_beam_angle = - 1551 + 2010
1/2 @@ -12894,7 +17815,7 @@

GCC Code Coverage Report

input_ground_station.angle_to_satellite_from_normal( - 1552 + 2011
1/2 @@ -12908,14 +17829,14 @@

GCC Code Coverage Report

current_satellite); - 1553 + 2012 - 1554 + 2013
2/4 @@ -12931,63 +17852,63 @@

GCC Code Coverage Report

if (ground_station_beam_angle > - 1555 + 2014 648 input_ground_station.max_beam_angle_from_normal_) { - 1556 + 2015 648 fprintf(gnuplot_pipe, "%.17g NaN\n", current_satellite_time); - 1557 + 2016 648 } else { - 1558 + 2017 fprintf(gnuplot_pipe, "%.17g %lu\n", current_satellite_time, - 1559 + 2018 satellite_index); - 1560 + 2019 } - 1561 + 2020 - 1562 + 2021 648 double timestep_to_use = input_sim_parameters.initial_timestep_guess; - 1563 + 2022
1/2 @@ -13001,7 +17922,7 @@

GCC Code Coverage Report

current_satellite_time = current_satellite.get_instantaneous_time(); - 1564 + 2023
2/2 @@ -13015,28 +17936,28 @@

GCC Code Coverage Report

while (current_satellite_time < input_sim_parameters.total_sim_time) { - 1565 + 2024 8747784 std::pair<double, double> drag_elements = {input_sim_parameters.F_10, - 1566 + 2025 4373892 input_sim_parameters.A_p}; - 1567 + 2026 std::pair<double, int> new_timestep_and_error_code = - 1568 + 2027
1/2 @@ -13050,49 +17971,49 @@

GCC Code Coverage Report

current_satellite.evolve_RK45( - 1569 + 2028 4373892 input_sim_parameters.epsilon, timestep_to_use, - 1570 + 2029 4373892 input_sim_parameters.perturbation_bool, - 1571 + 2030 4373892 input_sim_parameters.drag_bool, drag_elements); - 1572 + 2031 4373892 double new_timestep = new_timestep_and_error_code.first; - 1573 + 2032 4373892 int error_code = new_timestep_and_error_code.second; - 1574 + 2033 - 1575 + 2034
1/2 @@ -13106,70 +18027,70 @@

GCC Code Coverage Report

if (error_code != 0) { - 1576 + 2035 std::cout << "Error code " << error_code - 1577 + 2036 << " detected, halting visualization\n"; - 1578 + 2037 fprintf(gnuplot_pipe, "e\n"); - 1579 + 2038 fprintf(gnuplot_pipe, "exit \n"); - 1580 + 2039 pclose(gnuplot_pipe); - 1581 + 2040 return; - 1582 + 2041 } - 1583 + 2042 4373892 timestep_to_use = new_timestep; - 1584 + 2043 4373892 previous_time = current_satellite_time; - 1585 + 2044
1/2 @@ -13183,14 +18104,14 @@

GCC Code Coverage Report

current_satellite_time = current_satellite.get_instantaneous_time(); - 1586 + 2045 4373892 ground_station_beam_angle = - 1587 + 2046
1/2 @@ -13204,7 +18125,7 @@

GCC Code Coverage Report

input_ground_station.angle_to_satellite_from_normal( - 1588 + 2047
1/2 @@ -13218,21 +18139,21 @@

GCC Code Coverage Report

current_satellite); - 1589 + 2048 // Check number of existing connections to ground station at this point - 1590 + 2049 4373892 int num_sats_at_this_time = - 1591 + 2050
1/2 @@ -13246,14 +18167,14 @@

GCC Code Coverage Report

input_ground_station.num_sats_connected_at_this_time( - 1592 + 2051 4373892 current_satellite_time); - 1593 + 2052
2/2 @@ -13267,7 +18188,7 @@

GCC Code Coverage Report

if ((ground_station_beam_angle > - 1594 + 2053
4/4 @@ -13283,42 +18204,42 @@

GCC Code Coverage Report

input_ground_station.max_beam_angle_from_normal_) || - 1595 + 2054 412353 (num_sats_at_this_time == input_ground_station.num_beams_)) { - 1596 + 2055 4016421 fprintf(gnuplot_pipe, "%.17g NaN\n", current_satellite_time); - 1597 + 2056 4016421 } else { - 1598 + 2057 714942 fprintf(gnuplot_pipe, "%.17g %lu\n", current_satellite_time, - 1599 + 2058 357471 satellite_index); - 1600 + 2059
1/2 @@ -13332,35 +18253,35 @@

GCC Code Coverage Report

input_ground_station.update_linked_sats_map( - 1601 + 2060 357471 satellite_index, current_satellite_time, previous_time); - 1602 + 2061 } - 1603 + 2062 } - 1604 + 2063 648 fprintf(gnuplot_pipe, "e\n"); - 1605 + 2064
1/2 @@ -13374,77 +18295,77 @@

GCC Code Coverage Report

} - 1606 + 2065 // for (auto key_val_pair : input_ground_station.linked_sats_map_) { - 1607 + 2066 // std::cout << "==========================================\n"; - 1608 + 2067 // std::cout << "Satellite index " << key_val_pair.first << "\n"; - 1609 + 2068 // for (std::pair<double,double> range : key_val_pair.second) { - 1610 + 2069 // std::cout << "{" << range.first << "," << range.second << "}\n"; - 1611 + 2070 // } - 1612 + 2071 // } - 1613 + 2072 162 fprintf(gnuplot_pipe, "pause mouse keypress\n"); - 1614 + 2073 - 1615 + 2074 162 fprintf(gnuplot_pipe, "exit \n"); - 1616 + 2075
1/2 @@ -13458,7 +18379,7 @@

GCC Code Coverage Report

pclose(gnuplot_pipe); - 1617 + 2076
1/2 @@ -13472,14 +18393,14 @@

GCC Code Coverage Report

std::cout << "Done\n"; - 1618 + 2077 - 1619 + 2078
1/3 @@ -13494,105 +18415,105 @@

GCC Code Coverage Report

} else { - 1620 + 2079 std::cout << "gnuplot not found"; - 1621 + 2080 } - 1622 + 2081 - 1623 + 2082 162 return; - 1624 + 2083 162 } - 1625 + 2084 - 1626 + 2085 2 int add_lowthrust_orbit_transfer(Satellite& input_satellite_object, - 1627 + 2086 const double final_orbit_semimajor_axis_km, - 1628 + 2087 const double input_thrust_magnitude, - 1629 + 2088 const double transfer_initiation_time) { - 1630 + 2089 // Only transfers between circular orbits are supported at this time - 1631 + 2090 // Ref: https://prussing.ae.illinois.edu/AE402/low.thrust.pdf - 1632 + 2091 2 int error_code = 0; - 1633 + 2092 2 double initial_eccentricity = - 1634 + 2093
1/2 @@ -13606,7 +18527,7 @@

GCC Code Coverage Report

input_satellite_object.get_orbital_parameter("Eccentricity"); - 1635 + 2094
2/2 @@ -13620,35 +18541,35 @@

GCC Code Coverage Report

if (initial_eccentricity != 0) { - 1636 + 2095 1 std::cout << "Satellite's initial orbit was not circular\n"; - 1637 + 2096 1 error_code = 1; - 1638 + 2097 1 } - 1639 + 2098 2 double satellite_mass = input_satellite_object.get_mass(); - 1640 + 2099
1/2 @@ -13662,49 +18583,49 @@

GCC Code Coverage Report

if (satellite_mass <= 0) { - 1641 + 2100 std::cout << "Error: satellite mass was <= 0\n"; - 1642 + 2101 error_code = 2; - 1643 + 2102 } - 1644 + 2103 2 double thrust_acceleration = input_thrust_magnitude / satellite_mass; - 1645 + 2104 2 double semimajor_axis_final = 1000 * final_orbit_semimajor_axis_km; // m - 1646 + 2105 2 double semimajor_axis_initial = - 1647 + 2106
1/2 @@ -13718,63 +18639,63 @@

GCC Code Coverage Report

input_satellite_object.get_orbital_parameter("Semimajor Axis"); - 1648 + 2107 2 const double mu_Earth = G * mass_Earth; - 1649 + 2108 2 double comp1 = sqrt(mu_Earth / semimajor_axis_initial); - 1650 + 2109 2 double comp2 = sqrt(mu_Earth / semimajor_axis_final); - 1651 + 2110 2 double time_to_burn = (comp1 - comp2) / thrust_acceleration; - 1652 + 2111 - 1653 + 2112 // Thrust is purely co-linear with velocity vector, so in the +- x direction - 1654 + 2113 // of the LVLH frame (along +x if raising orbit, -x if lowering orbit) - 1655 + 2114 std::array<double, 3> LVLH_thrust_direction; - 1656 + 2115
1/2 @@ -13788,14 +18709,14 @@

GCC Code Coverage Report

if (semimajor_axis_initial < semimajor_axis_final) { - 1657 + 2116 2 LVLH_thrust_direction = {1, 0, 0}; - 1658 + 2117
0/2 @@ -13809,63 +18730,63 @@

GCC Code Coverage Report

} else if (semimajor_axis_initial > semimajor_axis_final) { - 1659 + 2118 LVLH_thrust_direction = {-1, 0, 0}; - 1660 + 2119 time_to_burn = - 1661 + 2120 (-1) * time_to_burn; // Since this would have otherwise been negative - 1662 + 2121 } else { - 1663 + 2122 std::cout << "Error: initial and final semimajor axes were equal.\n"; - 1664 + 2123 error_code = 3; // Arbitrarily choose a burn direction in this scenario, - 1665 + 2124 // since it shouldn't matter - 1666 + 2125 } - 1667 + 2126
2/2 @@ -13879,49 +18800,49 @@

GCC Code Coverage Report

if (error_code == 0) { - 1668 + 2127 2 input_satellite_object.add_LVLH_thrust_profile( - 1669 + 2128 1 LVLH_thrust_direction, input_thrust_magnitude, transfer_initiation_time, - 1670 + 2129 1 transfer_initiation_time + time_to_burn); - 1671 + 2130 1 } - 1672 + 2131 2 return error_code; - 1673 + 2132} - 1674 + 2133 diff --git a/tests/test_coverage_detailed.utils.h.0924fa377d356c0f9a6a386ccdf5fa6d.html b/tests/test_coverage_detailed.utils.h.0924fa377d356c0f9a6a386ccdf5fa6d.html index 739a3f1..6bec577 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-05-11 21:11:47 + 2025-05-27 18:19:02 @@ -70,9 +70,9 @@

GCC Code Coverage Report

Call count Block coverage - SimParameters::SimParameters(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 32)called 10 times100.0% - SimParameters::~SimParameters() (line 19)called 10 times100.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 348)called 13638546 times87.0% + SimParameters::SimParameters(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) (line 32)called 24 times100.0% + SimParameters::~SimParameters() (line 19)called 24 times100.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 348)called 13705590 times87.0%
@@ -223,77 +223,77 @@

GCC Code Coverage Report

20 - 5 + 12 double initial_timestep_guess = 1; 21 - 5 + 12 double total_sim_time = 10; 22 - 5 + 12 double epsilon = pow(10, -8); 23 - 5 + 12 bool perturbation_bool = true; 24 - 5 + 12 bool drag_bool = false; 25 - 5 + 12 double x_increment = 0; 26 - 5 + 12 double y_increment = 0; 27 - 5 + 12 double z_increment = 0; 28 - 5 + 12 double F_10 = 0; // Solar radio ten centimeter flux 29 - 5 + 12 double A_p = 0; // Geomagnetic A_p index 30 - 5 + 12 std::string terminal_name_3D = "qt"; @@ -307,7 +307,7 @@

GCC Code Coverage Report

32 - 10 + 24 SimParameters(const std::string parameter_json_file_name) { @@ -316,12 +316,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
- 5 + 12 std::ifstream input_filestream(parameter_json_file_name); @@ -330,12 +330,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
- 5 + 12 json input_data = json::parse(input_filestream); @@ -351,16 +351,16 @@

GCC Code Coverage Report

3/6
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 5 times.
+
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 5 times.
+
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
- 5 + 12 if (input_data.find("Initial timestep guess") != input_data.end()) { @@ -369,21 +369,21 @@

GCC Code Coverage Report

2/4
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 5 times.
+
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
- 5 + 12 initial_timestep_guess = input_data.at("Initial timestep guess"); 38 - 5 + 12 } @@ -392,16 +392,16 @@

GCC Code Coverage Report

3/6
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 5 times.
+
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 5 times.
+
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
- 5 + 12 if (input_data.find("Simulation duration") != input_data.end()) { @@ -410,21 +410,21 @@

GCC Code Coverage Report

2/4
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 5 times.
+
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
- 5 + 12 total_sim_time = input_data.at("Simulation duration"); 41 - 5 + 12 } @@ -433,16 +433,16 @@

GCC Code Coverage Report

3/6
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 5 times.
+
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 5 times.
+
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
- 5 + 12 if (input_data.find("epsilon") != input_data.end()) { @@ -451,21 +451,21 @@

GCC Code Coverage Report

2/4
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 5 times.
+
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
- 5 + 12 epsilon = input_data.at("epsilon"); 44 - 5 + 12 } @@ -474,16 +474,16 @@

GCC Code Coverage Report

3/6
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 5 times.
+
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 5 times.
+
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
- 5 + 12 if (input_data.find("Perturbation") != input_data.end()) { @@ -492,21 +492,21 @@

GCC Code Coverage Report

2/4
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 5 times.
+
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
- 5 + 12 perturbation_bool = input_data.at("Perturbation"); 47 - 5 + 12 } @@ -515,16 +515,16 @@

GCC Code Coverage Report

3/6
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 5 times.
+
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 5 times.
+
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
- 5 + 12 if (input_data.find("Drag") != input_data.end()) { @@ -533,21 +533,21 @@

GCC Code Coverage Report

2/4
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 5 times.
+
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
- 5 + 12 drag_bool = input_data.at("Drag"); 50 - 5 + 12 } @@ -556,16 +556,16 @@

GCC Code Coverage Report

3/6
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 5 times.
+
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
-
✓ Branch 5 taken 5 times.
+
✓ Branch 5 taken 12 times.
- 5 + 12 if (input_data.find("X increment") != input_data.end()) { @@ -588,16 +588,16 @@

GCC Code Coverage Report

3/6
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 5 times.
+
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
-
✓ Branch 5 taken 5 times.
+
✓ Branch 5 taken 12 times.
- 5 + 12 if (input_data.find("Y increment") != input_data.end()) { @@ -620,16 +620,16 @@

GCC Code Coverage Report

3/6
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 5 times.
+
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
-
✓ Branch 5 taken 5 times.
+
✓ Branch 5 taken 12 times.
- 5 + 12 if (input_data.find("Z increment") != input_data.end()) { @@ -652,16 +652,16 @@

GCC Code Coverage Report

3/6
-
✓ Branch 0 taken 5 times.
+
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 5 times.
+
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
-
✓ Branch 5 taken 5 times.
+
✓ Branch 5 taken 12 times.
- 5 + 12 if (input_data.find("3D plotting terminal") != input_data.end()) { @@ -682,7 +682,7 @@

GCC Code Coverage Report

63 - 10 + 24 } @@ -2677,7 +2677,7 @@

GCC Code Coverage Report

348 - 13638546 + 13705590 std::pair<std::array<double, T>, std::pair<double, double>> RK45_step( @@ -2880,7 +2880,7 @@

GCC Code Coverage Report

377 - 13638546 + 13705590 std::array<double, 6> nodes = {0.0, 1.0 / 4, 3.0 / 8, 12.0 / 13, @@ -2894,7 +2894,7 @@

GCC Code Coverage Report

379 - 13638546 + 13705590 std::array<double, 6> CH_vec = {16.0 / 135, 0.0, 6656.0 / 12825, @@ -2908,7 +2908,7 @@

GCC Code Coverage Report

381 - 13638546 + 13705590 std::array<double, 6> CT_vec = {-1.0 / 360, 0.0, 128.0 / 4275, @@ -2922,7 +2922,7 @@

GCC Code Coverage Report

383 - 13638546 + 13705590 int s = 6; @@ -2936,7 +2936,7 @@

GCC Code Coverage Report

385 - 13638546 + 13705590 MatrixXd RK_matrix = MatrixXd::Zero(s, s); @@ -2945,12 +2945,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(1, 0) = 1.0 / 4; @@ -2959,12 +2959,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(2, 0) = 3.0 / 32; @@ -2973,12 +2973,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(2, 1) = 9.0 / 32; @@ -2987,12 +2987,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(3, 0) = 1932.0 / 2197; @@ -3001,12 +3001,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(3, 1) = -7200.0 / 2197; @@ -3015,12 +3015,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(3, 2) = 7296.0 / 2197; @@ -3029,12 +3029,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(4, 0) = 439.0 / 216; @@ -3043,12 +3043,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(4, 1) = -8.0; @@ -3057,12 +3057,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(4, 2) = 3680.0 / 513; @@ -3071,12 +3071,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(4, 3) = -845.0 / 4104; @@ -3085,12 +3085,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(5, 0) = -8.0 / 27; @@ -3099,12 +3099,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(5, 1) = 2.0; @@ -3113,12 +3113,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(5, 2) = -3544.0 / 2565; @@ -3127,12 +3127,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(5, 3) = 1859.0 / 4104; @@ -3141,12 +3141,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 RK_matrix(5, 4) = -11.0 / 40; @@ -3160,7 +3160,7 @@

GCC Code Coverage Report

402 - 13638546 + 13705590 std::vector<std::array<double, T>> k_vec_vec = {}; @@ -3183,12 +3183,12 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 81831276 times.
-
✓ Branch 1 taken 13638546 times.
+
✓ Branch 0 taken 82233540 times.
+
✓ Branch 1 taken 13705590 times.
- 95469822 + 95939130 for (size_t k_ind = 0; k_ind < s; k_ind++) { @@ -3197,19 +3197,19 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 double evaluation_time = input_t_n + (nodes.at(k_ind) * input_step_size); 407 - 81831276 + 82233540 std::array<double, T> y_n_evaluated_value = y_n; @@ -3225,12 +3225,12 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 81831276 times.
-
✓ Branch 1 taken 204578190 times.
+
✓ Branch 0 taken 82233540 times.
+
✓ Branch 1 taken 205583850 times.
- 286409466 + 287817390 for (size_t s_ind = 0; s_ind < k_ind; s_ind++) { @@ -3239,12 +3239,12 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 2659516470 times.
-
✓ Branch 1 taken 204578190 times.
+
✓ Branch 0 taken 2672590050 times.
+
✓ Branch 1 taken 205583850 times.
- 2864094660 + 2878173900 for (size_t y_val_ind = 0; y_val_ind < y_n.size(); y_val_ind++) { @@ -3253,12 +3253,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 2659516470 times.
+
✓ Branch 0 taken 2672590050 times.
✗ Branch 1 not taken.
- 2659516470 + 2672590050 y_n_evaluated_value.at(y_val_ind) += @@ -3267,12 +3267,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 2659516470 times.
+
✓ Branch 0 taken 2672590050 times.
✗ Branch 1 not taken.
- 2659516470 + 2672590050 input_step_size * RK_matrix(k_ind, s_ind) @@ -3281,28 +3281,28 @@

GCC Code Coverage Report

2/4
-
✓ Branch 0 taken 2659516470 times.
+
✓ Branch 0 taken 2672590050 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 2659516470 times.
+
✓ Branch 2 taken 2672590050 times.
✗ Branch 3 not taken.
- 2659516470 + 2672590050 * k_vec_vec.at(s_ind).at(y_val_ind); 414 - 2659516470 + 2672590050 } 415 - 204578190 + 205583850 } @@ -3318,12 +3318,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 input_combined_derivative_function( @@ -3332,14 +3332,14 @@

GCC Code Coverage Report

2/4
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 81831276 times.
+
✓ Branch 2 taken 82233540 times.
✗ Branch 3 not taken.
- 81831276 + 82233540 y_n_evaluated_value, J_matrix, input_bodyframe_torque_profile_list, @@ -3348,12 +3348,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 input_omega_I, input_orbital_angular_acceleration, @@ -3362,12 +3362,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 input_LVLH_to_bodyframe_transformation_matrix, @@ -3376,12 +3376,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 input_omega_LVLH_wrt_inertial_in_LVLH, input_spacecraft_mass, @@ -3390,26 +3390,26 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 input_list_of_thrust_profiles_LVLH, evaluation_time, 423 - 81831276 + 82233540 input_inclination, input_arg_of_periapsis, input_true_anomaly, 424 - 81831276 + 82233540 input_F_10, input_A_p, input_A_s, perturbation, atmospheric_drag); @@ -3418,12 +3418,12 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 81831276 times.
-
✓ Branch 1 taken 1063806588 times.
+
✓ Branch 0 taken 82233540 times.
+
✓ Branch 1 taken 1069036020 times.
- 1145637864 + 1151269560 for (size_t y_val_ind = 0; y_val_ind < y_n.size(); y_val_ind++) { @@ -3432,12 +3432,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 1063806588 times.
+
✓ Branch 0 taken 1069036020 times.
✗ Branch 1 not taken.
- 1063806588 + 1069036020 k_vec_at_this_s.at(y_val_ind) = @@ -3446,19 +3446,19 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 1063806588 times.
+
✓ Branch 0 taken 1069036020 times.
✗ Branch 1 not taken.
- 1063806588 + 1069036020 input_step_size * derivative_function_output.at(y_val_ind); 428 - 1063806588 + 1069036020 } @@ -3474,19 +3474,19 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 81831276 times.
+
✓ Branch 0 taken 82233540 times.
✗ Branch 1 not taken.
- 81831276 + 82233540 k_vec_vec.push_back(k_vec_at_this_s); 431 - 81831276 + 82233540 } @@ -3500,7 +3500,7 @@

GCC Code Coverage Report

433 - 13638546 + 13705590 std::array<double, T> y_nplusone = y_n; @@ -3516,12 +3516,12 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 13638546 times.
-
✓ Branch 1 taken 81831276 times.
+
✓ Branch 0 taken 13705590 times.
+
✓ Branch 1 taken 82233540 times.
- 95469822 + 95939130 for (size_t s_ind = 0; s_ind < s; s_ind++) { @@ -3530,12 +3530,12 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 1063806588 times.
-
✓ Branch 1 taken 81831276 times.
+
✓ Branch 0 taken 1069036020 times.
+
✓ Branch 1 taken 82233540 times.
- 1145637864 + 1151269560 for (size_t y_ind = 0; y_ind < y_n.size(); y_ind++) { @@ -3544,16 +3544,16 @@

GCC Code Coverage Report

3/6
-
✓ Branch 0 taken 1063806588 times.
+
✓ Branch 0 taken 1069036020 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 1063806588 times.
+
✓ Branch 2 taken 1069036020 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 1063806588 times.
+
✓ Branch 4 taken 1069036020 times.
✗ Branch 5 not taken.
- 1063806588 + 1069036020 double tmp = CH_vec.at(s_ind) * k_vec_vec.at(s_ind).at(y_ind); @@ -3562,26 +3562,26 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 1063806588 times.
+
✓ Branch 0 taken 1069036020 times.
✗ Branch 1 not taken.
- 1063806588 + 1069036020 y_nplusone.at(y_ind) += tmp; 439 - 1063806588 + 1069036020 } 440 - 81831276 + 82233540 } @@ -3595,7 +3595,7 @@

GCC Code Coverage Report

442 - 13638546 + 13705590 std::array<double, T> TE_vec = {0}; @@ -3604,12 +3604,12 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 13638546 times.
-
✓ Branch 1 taken 177301098 times.
+
✓ Branch 0 taken 13705590 times.
+
✓ Branch 1 taken 178172670 times.
- 190939644 + 191878260 for (size_t y_ind = 0; y_ind < y_n.size(); y_ind++) { @@ -3618,12 +3618,12 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 1063806588 times.
-
✓ Branch 1 taken 177301098 times.
+
✓ Branch 0 taken 1069036020 times.
+
✓ Branch 1 taken 178172670 times.
- 1241107686 + 1247208690 for (size_t s_ind = 0; s_ind < s; s_ind++) { @@ -3632,32 +3632,32 @@

GCC Code Coverage Report

4/8
-
✓ Branch 0 taken 1063806588 times.
+
✓ Branch 0 taken 1069036020 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 1063806588 times.
+
✓ Branch 2 taken 1069036020 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 1063806588 times.
+
✓ Branch 4 taken 1069036020 times.
✗ Branch 5 not taken.
-
✓ Branch 6 taken 1063806588 times.
+
✓ Branch 6 taken 1069036020 times.
✗ Branch 7 not taken.
- 1063806588 + 1069036020 TE_vec.at(y_ind) += CT_vec.at(s_ind) * k_vec_vec.at(s_ind).at(y_ind); 446 - 1063806588 + 1069036020 } 447 - 177301098 + 178172670 } @@ -3673,12 +3673,12 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 13638546 times.
-
✓ Branch 1 taken 177301098 times.
+
✓ Branch 0 taken 13705590 times.
+
✓ Branch 1 taken 178172670 times.
- 190939644 + 191878260 for (size_t ind = 0; ind < TE_vec.size(); ind++) { @@ -3687,21 +3687,21 @@

GCC Code Coverage Report

2/4
-
✓ Branch 0 taken 177301098 times.
+
✓ Branch 0 taken 178172670 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 177301098 times.
+
✓ Branch 2 taken 178172670 times.
✗ Branch 3 not taken.
- 177301098 + 178172670 TE_vec.at(ind) = abs(TE_vec.at(ind)); 451 - 177301098 + 178172670 } @@ -3731,12 +3731,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
- 13638546 + 13705590 double max_TE = TE_vec.at( @@ -3745,14 +3745,14 @@

GCC Code Coverage Report

2/4
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 13638546 times.
+
✓ Branch 2 taken 13705590 times.
✗ Branch 3 not taken.
- 27277092 + 27411180 std::distance(std::begin(TE_vec), @@ -3761,23 +3761,23 @@

GCC Code Coverage Report

3/6
-
✓ Branch 0 taken 13638546 times.
+
✓ Branch 0 taken 13705590 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 13638546 times.
+
✓ Branch 2 taken 13705590 times.
✗ Branch 3 not taken.
-
✓ Branch 4 taken 13638546 times.
+
✓ Branch 4 taken 13705590 times.
✗ Branch 5 not taken.
- 13638546 + 13705590 std::max_element(std::begin(TE_vec), std::end(TE_vec)))); 458 - 13638546 + 13705590 double epsilon_ratio = input_epsilon / max_TE; @@ -3791,7 +3791,7 @@

GCC Code Coverage Report

460 - 13638546 + 13705590 double h_new = 0.9 * input_step_size * std::pow(epsilon_ratio, 1.0 / 5); @@ -3807,33 +3807,33 @@

GCC Code Coverage Report

2/2
-
✓ Branch 0 taken 1171628 times.
-
✓ Branch 1 taken 12466918 times.
+
✓ Branch 0 taken 1171719 times.
+
✓ Branch 1 taken 12533871 times.
- 13638546 + 13705590 if (max_TE <= input_epsilon) { 463 - 12466918 + 12533871 std::pair<double, double> output_timestep_pair; 464 - 12466918 + 12533871 output_timestep_pair.first = 465 - 12466918 + 12533871 input_step_size; // First timestep size in this pair is the one @@ -3847,14 +3847,14 @@

GCC Code Coverage Report

467 - 12466918 + 12533871 output_timestep_pair.second = 468 - 12466918 + 12533871 h_new; // Second timestep size in this pair is the one to be used in @@ -3868,28 +3868,28 @@

GCC Code Coverage Report

470 - 12466918 + 12533871 std::pair<std::array<double, T>, std::pair<double, double>> output_pair; 471 - 12466918 + 12533871 output_pair.first = y_nplusone; 472 - 12466918 + 12533871 output_pair.second = output_timestep_pair; 473 - 12466918 + 12533871 return output_pair; @@ -3905,12 +3905,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 1171628 times.
+
✓ Branch 0 taken 1171719 times.
✗ Branch 1 not taken.
- 1171628 + 1171719 return RK45_step<T>( @@ -3919,14 +3919,14 @@

GCC Code Coverage Report

2/4
-
✓ Branch 0 taken 1171628 times.
+
✓ Branch 0 taken 1171719 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 1171628 times.
+
✓ Branch 2 taken 1171719 times.
✗ Branch 3 not taken.
- 1171628 + 1171719 y_n, h_new, input_combined_derivative_function, J_matrix, @@ -3935,21 +3935,21 @@

GCC Code Coverage Report

2/4
-
✓ Branch 0 taken 1171628 times.
+
✓ Branch 0 taken 1171719 times.
✗ Branch 1 not taken.
-
✓ Branch 2 taken 1171628 times.
+
✓ Branch 2 taken 1171719 times.
✗ Branch 3 not taken.
- 1171628 + 1171719 input_bodyframe_torque_profile_list, input_omega_I, 478 - 1171628 + 1171719 input_orbital_angular_acceleration, @@ -3958,12 +3958,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 1171628 times.
+
✓ Branch 0 taken 1171719 times.
✗ Branch 1 not taken.
- 1171628 + 1171719 input_LVLH_to_bodyframe_transformation_matrix, @@ -3972,12 +3972,12 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 1171628 times.
+
✓ Branch 0 taken 1171719 times.
✗ Branch 1 not taken.
- 1171628 + 1171719 input_omega_LVLH_wrt_inertial_in_LVLH, input_spacecraft_mass, @@ -3986,26 +3986,26 @@

GCC Code Coverage Report

1/2
-
✓ Branch 0 taken 1171628 times.
+
✓ Branch 0 taken 1171719 times.
✗ Branch 1 not taken.
- 1171628 + 1171719 input_list_of_thrust_profiles_LVLH, input_inclination, 482 - 1171628 + 1171719 input_arg_of_periapsis, input_true_anomaly, input_F_10, input_A_p, 483 - 1171628 + 1171719 input_A_s, perturbation, atmospheric_drag, input_t_n, input_epsilon); @@ -4019,7 +4019,7 @@

GCC Code Coverage Report

485 - 13638546 + 13705590 } @@ -4300,13 +4300,125 @@

GCC Code Coverage Report

- #endif + 526 + int sim_and_write_to_file(std::vector<Satellite> input_satellite_vector, + + + 527 + + + + const SimParameters& input_sim_parameters, + + + 528 + + + + const std::string output_file_name_prefix, + + + 529 + + + + const double size_limit = INFINITY); + + + 530 + + + + + + + 531 + + + + void plot_3D_from_datafile(std::vector<std::string> input_datafile_name_vector, + + + 532 + + + + const std::string output_file_name = "3D plot", + + + 533 + + + + const std::string terminal_name = "qt", + + + 534 + + + + const double x_increment = 0, + + + 535 + + + + const double y_increment = 0, + + + 536 + + + + const double z_increment = 0); + + + 537 + + + + + + + 538 + + + + void plot_2D_from_datafile(std::vector<std::string> input_datafile_name_vector, + + + 539 + + + + const std::string plotted_parameter, + + + 540 + + + + const std::string output_file_name = "2D plot"); + + + 541 + + + + #endif + + + 542 + + + diff --git a/tests/test_coverage_summary.json b/tests/test_coverage_summary.json index 46b986c..055aa11 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": 11, "line_covered": 11, "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": 201, "line_covered": 201, "line_percent": 100.0, "function_total": 20, "function_covered": 20, "function_percent": 100.0, "branch_total": 178, "branch_covered": 110, "branch_percent": 61.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": 79, "line_covered": 78, "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": 425, "line_covered": 406, "line_percent": 95.5, "function_total": 22, "function_covered": 21, "function_percent": 95.5, "branch_total": 130, "branch_covered": 104, "branch_percent": 80.0}, {"filename": "src/utils.cpp", "line_total": 996, "line_covered": 913, "line_percent": 91.7, "function_total": 28, "function_covered": 28, "function_percent": 100.0, "branch_total": 746, "branch_covered": 437, "branch_percent": 58.6}], "line_total": 1841, "line_covered": 1730, "line_percent": 94.0, "function_total": 82, "function_covered": 81, "function_percent": 98.8, "branch_total": 1335, "branch_covered": 806, "branch_percent": 60.4} \ No newline at end of file +{"root": "..", "gcovr/summary_format_version": "0.6", "files": [{"filename": "include/PhasedArrayGroundStation.h", "line_total": 11, "line_covered": 11, "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": 195, "line_covered": 195, "line_percent": 100.0, "function_total": 20, "function_covered": 20, "function_percent": 100.0, "branch_total": 178, "branch_covered": 110, "branch_percent": 61.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": 79, "line_covered": 78, "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": 437, "line_covered": 418, "line_percent": 95.7, "function_total": 23, "function_covered": 22, "function_percent": 95.7, "branch_total": 130, "branch_covered": 104, "branch_percent": 80.0}, {"filename": "src/utils.cpp", "line_total": 1314, "line_covered": 1205, "line_percent": 91.7, "function_total": 31, "function_covered": 31, "function_percent": 100.0, "branch_total": 1503, "branch_covered": 810, "branch_percent": 53.9}], "line_total": 2165, "line_covered": 2028, "line_percent": 93.7, "function_total": 86, "function_covered": 85, "function_percent": 98.8, "branch_total": 2092, "branch_covered": 1179, "branch_percent": 56.4} \ No newline at end of file diff --git a/tests/utils_tests.cpp b/tests/utils_tests.cpp index d2537ae..838d93d 100644 --- a/tests/utils_tests.cpp +++ b/tests/utils_tests.cpp @@ -547,4 +547,125 @@ TEST(UtilsTests, LowThrustTransferTest2) { EXPECT_TRUE(error_code == 1) << "Non-circular orbit should have been thrown here\n"; +} + +TEST(UtilsTests, DataSavingTest1) { + SimParameters sim_parameters("../tests/sim_parameters_baseline.json"); + Satellite test_sat("../tests/elliptical_orbit_test_1.json"); + std::string datafile_prefix = "utils_test"; + std::vector test_vec = {test_sat}; + int file_writing_error_code = sim_and_write_to_file(test_vec, sim_parameters, datafile_prefix); + EXPECT_TRUE(file_writing_error_code == 0); +} + +TEST(UtilsTests, DataSavingTest2) { + SimParameters sim_parameters("../tests/sim_parameters_baseline.json"); + Satellite test_sat("../tests/elliptical_orbit_test_1.json"); + Satellite test_sat2("../tests/circular_orbit_test_2_input.json"); + Satellite test_sat3("../tests/input_2.json"); + std::string datafile_prefix = "utils_test"; + std::vector test_vec = {test_sat,test_sat2,test_sat3}; + int file_writing_error_code = sim_and_write_to_file(test_vec, sim_parameters, datafile_prefix); + EXPECT_TRUE(file_writing_error_code == 0); +} + +TEST(UtilsTests, DataSavingOverflowTest) { + SimParameters sim_parameters("../tests/sim_parameters_baseline.json"); + Satellite test_sat("../tests/elliptical_orbit_test_1.json"); + Satellite test_sat2("../tests/circular_orbit_test_2_input.json"); + Satellite test_sat3("../tests/input_2.json"); + std::string datafile_prefix = "utils_test"; + std::vector test_vec = {test_sat,test_sat2,test_sat3}; + sim_parameters.total_sim_time = 1000000; + double size_limit = 50000; + int file_writing_error_code = sim_and_write_to_file(test_vec, sim_parameters, datafile_prefix, size_limit); + EXPECT_TRUE(file_writing_error_code == 2); +} + +TEST(UtilsTests, PlottingFromDataFile2D_Test1) { + SimParameters sim_parameters("../tests/sim_parameters_baseline.json"); + Satellite test_sat("../tests/elliptical_orbit_test_1.json"); + std::string datafile_prefix = "Test-"; + std::vector test_vec = {test_sat}; + int file_writing_error_code = sim_and_write_to_file(test_vec, sim_parameters, datafile_prefix); + EXPECT_TRUE(file_writing_error_code == 0); + std::string plotted_parameter = "Semimajor Axis"; + std::string output_filename_2D = "2D_plot_example"; + std::vector datafile_name_vector = {}; + for (Satellite sat_object : test_vec) { + std::string sat_name = sat_object.get_name(); + std::string datafile_name = datafile_prefix + sat_name; + datafile_name_vector.push_back(datafile_name); + } + plot_2D_from_datafile(datafile_name_vector, + plotted_parameter, + output_filename_2D); +} + +TEST(UtilsTests, PlottingFromDataFile2D_Test2) { + SimParameters sim_parameters("../tests/sim_parameters_baseline.json"); + Satellite test_sat("../tests/elliptical_orbit_test_1.json"); + Satellite test_sat2("../tests/circular_orbit_test_2_input.json"); + Satellite test_sat3("../tests/input_2.json"); + std::string datafile_prefix = "Test-"; + std::vector test_vec = {test_sat,test_sat2,test_sat3}; + int file_writing_error_code = sim_and_write_to_file(test_vec, sim_parameters, datafile_prefix); + EXPECT_TRUE(file_writing_error_code == 0); + std::string plotted_parameter = "Semimajor Axis"; + std::string output_filename_2D = "2D_plot_example"; + std::vector datafile_name_vector = {}; + for (Satellite sat_object : test_vec) { + std::string sat_name = sat_object.get_name(); + std::string datafile_name = datafile_prefix + sat_name; + datafile_name_vector.push_back(datafile_name); + } + plot_2D_from_datafile(datafile_name_vector, + plotted_parameter, + output_filename_2D); +} + +TEST(UtilsTests, PlottingFromDataFile3D_Test1) { + SimParameters sim_parameters("../tests/sim_parameters_baseline.json"); + Satellite test_sat("../tests/elliptical_orbit_test_1.json"); + std::string datafile_prefix = "Test-"; + std::vector test_vec = {test_sat}; + int file_writing_error_code = sim_and_write_to_file(test_vec, sim_parameters, datafile_prefix); + EXPECT_TRUE(file_writing_error_code == 0); + std::string plotted_parameter = "Semimajor Axis"; + std::string output_filename_2D = "2D_plot_example"; + std::vector datafile_name_vector = {}; + for (Satellite sat_object : test_vec) { + std::string sat_name = sat_object.get_name(); + std::string datafile_name = datafile_prefix + sat_name; + datafile_name_vector.push_back(datafile_name); + } + std::string output_file_name = "test_plot"; + std::string terminal_name = "png"; + plot_3D_from_datafile(datafile_name_vector, + output_file_name, + terminal_name); +} + +TEST(UtilsTests, PlottingFromDataFile3D_Test2) { + SimParameters sim_parameters("../tests/sim_parameters_baseline.json"); + Satellite test_sat("../tests/elliptical_orbit_test_1.json"); + Satellite test_sat2("../tests/circular_orbit_test_2_input.json"); + Satellite test_sat3("../tests/input_2.json"); + std::string datafile_prefix = "Test-"; + std::vector test_vec = {test_sat, test_sat2, test_sat3}; + int file_writing_error_code = sim_and_write_to_file(test_vec, sim_parameters, datafile_prefix); + EXPECT_TRUE(file_writing_error_code == 0); + std::string plotted_parameter = "Semimajor Axis"; + std::string output_filename_2D = "2D_plot_example"; + std::vector datafile_name_vector = {}; + for (Satellite sat_object : test_vec) { + std::string sat_name = sat_object.get_name(); + std::string datafile_name = datafile_prefix + sat_name; + datafile_name_vector.push_back(datafile_name); + } + std::string output_file_name = "test_plot"; + std::string terminal_name = "png"; + plot_3D_from_datafile(datafile_name_vector, + output_file_name, + terminal_name); } \ No newline at end of file