Skip to content

Commit

Permalink
Modify rotation mode input
Browse files Browse the repository at this point in the history
  • Loading branch information
200km committed Oct 10, 2023
1 parent 67cb9ba commit a82868b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 32 deletions.
26 changes: 11 additions & 15 deletions data/sample/initialize_files/sample_simulation_base.ini
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ inertial_frame = J2000
center_object = EARTH
aberration_correction = NONE

// Earth Rotation model
// Idle:no motion, Simple:Z-axis rotation only, Full:full-dynamics
earth_rotation_mode = Simple

// Definition of calculation celestial bodies
number_of_selected_body = 3
selected_body_name(0) = EARTH
Expand All @@ -105,17 +101,17 @@ selected_body_name(10) = PLUTO

// Celestial rotation mode
// Currently, s2e-core supports Earth and Moon only
is_enable_body_rotation(0) = Full
is_enable_body_rotation(1) = DISABLE
is_enable_body_rotation(2) = Simple
is_enable_body_rotation(3) = DISABLE
is_enable_body_rotation(4) = DISABLE
is_enable_body_rotation(5) = DISABLE
is_enable_body_rotation(6) = DISABLE
is_enable_body_rotation(7) = DISABLE
is_enable_body_rotation(8) = DISABLE
is_enable_body_rotation(9) = DISABLE
is_enable_body_rotation(10) = DISABLE
rotation_mode(0) = FULL // EARTH IDLE:no motion, SIMPLE:Z-axis rotation only, FULL:full-dynamics
rotation_mode(1) = DISABLE
rotation_mode(2) = SIMPLE // MOON IDLE:no motion, SIMPLE:Mean Earth and Principal Axis, IAU_MOON: IAU_MOON frame by SPICE
rotation_mode(3) = DISABLE
rotation_mode(4) = DISABLE
rotation_mode(5) = DISABLE
rotation_mode(6) = DISABLE
rotation_mode(7) = DISABLE
rotation_mode(8) = DISABLE
rotation_mode(9) = DISABLE
rotation_mode(10) = DISABLE

[CSPICE_KERNELS]
// CSPICE Kernel files definition
Expand Down
12 changes: 4 additions & 8 deletions src/environment/global/celestial_information.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include "library/logger/log_utility.hpp"

CelestialInformation::CelestialInformation(const std::string inertial_frame_name, const std::string aberration_correction_setting,
const std::string center_body_name, const EarthRotationMode earth_rotation_mode,
const unsigned int number_of_selected_body, int* selected_body_ids,
const std::string center_body_name, const unsigned int number_of_selected_body, int* selected_body_ids,
const std::vector<std::string> rotation_mode_list)
: number_of_selected_bodies_(number_of_selected_body),
selected_body_ids_(selected_body_ids),
Expand Down Expand Up @@ -65,7 +64,7 @@ CelestialInformation::CelestialInformation(const std::string inertial_frame_name
}

// Initialize rotation
earth_rotation_ = new EarthRotation(earth_rotation_mode);
earth_rotation_ = new EarthRotation(ConvertEarthRotationMode(GetRotationMode("EARTH")));
moon_rotation_ = new MoonRotation(*this, ConvertMoonRotationMode(GetRotationMode("MOON")));
}

Expand Down Expand Up @@ -235,13 +234,10 @@ CelestialInformation* InitCelestialInformation(std::string file_name) {
}

// Read Rotation setting
std::string rotation_mode_string = ini_file.ReadString(section, "earth_rotation_mode");
EarthRotationMode rotation_mode = ConvertEarthRotationMode(rotation_mode_string);
std::vector<std::string> rotation_mode_list = ini_file.ReadVectorString(section, "is_enable_body_rotation", num_of_selected_body);
std::vector<std::string> rotation_mode_list = ini_file.ReadVectorString(section, "rotation_mode", num_of_selected_body);

CelestialInformation* celestial_info;
celestial_info =
new CelestialInformation(inertial_frame, aber_cor, center_obj, rotation_mode, num_of_selected_body, selected_body, rotation_mode_list);
celestial_info = new CelestialInformation(inertial_frame, aber_cor, center_obj, num_of_selected_body, selected_body, rotation_mode_list);

// log setting
celestial_info->is_log_enabled_ = ini_file.ReadEnable(section, INI_LOG_LABEL);
Expand Down
4 changes: 1 addition & 3 deletions src/environment/global/celestial_information.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ class CelestialInformation : public ILoggable {
* @param [in] inertial_frame_name: Definition of inertial frame
* @param [in] aberration_correction_setting: Stellar aberration correction
* @param [in] center_body_name: Center body name of inertial frame
* @param [in] earth_rotation_mode: Designation of rotation model
* @param [in] number_of_selected_body: Number of selected body
* @param [in] selected_body_ids: SPICE IDs of selected bodies
* @param [in] rotation_mode_list: Rotation mode list for planets
*/
CelestialInformation(const std::string inertial_frame_name, const std::string aberration_correction_setting, const std::string center_body_name,
const EarthRotationMode earth_rotation_mode, const unsigned int number_of_selected_body, int* selected_body_ids,
const std::vector<std::string> rotation_mode_list);
const unsigned int number_of_selected_body, int* selected_body_ids, const std::vector<std::string> rotation_mode_list);
/**
* @fn CelestialInformation
* @brief Copy constructor
Expand Down
6 changes: 3 additions & 3 deletions src/environment/global/earth_rotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ libra::Matrix<3, 3> EarthRotation::PolarMotion(const double x_p, const double y_

EarthRotationMode ConvertEarthRotationMode(const std::string mode) {
EarthRotationMode rotation_mode;
if (mode == "Idle") {
if (mode == "IDLE") {
rotation_mode = EarthRotationMode::kIdle;
} else if (mode == "Simple") {
} else if (mode == "SIMPLE") {
rotation_mode = EarthRotationMode::kSimple;
} else if (mode == "Full") {
} else if (mode == "FULL") {
rotation_mode = EarthRotationMode::kFull;
} else // if rotation_mode is neither Idle, Simple, nor Full, set rotation_mode to Idle
{
Expand Down
6 changes: 3 additions & 3 deletions src/environment/global/moon_rotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ void MoonRotation::Update(const SimulationTime& simulation_time) {

MoonRotationMode ConvertMoonRotationMode(const std::string mode) {
MoonRotationMode rotation_mode;
if (mode == "Idle") {
if (mode == "IDLE") {
rotation_mode = MoonRotationMode::kIdle;
} else if (mode == "Simple") {
} else if (mode == "SIMPLE") {
rotation_mode = MoonRotationMode::kSimple;
} else if (mode == "IauMoon") {
} else if (mode == "IAU_MOON") {
rotation_mode = MoonRotationMode::kIauMoon;
} else // if rotation_mode is neither Idle, Simple, nor Full, set rotation_mode to Idle
{
Expand Down

0 comments on commit a82868b

Please sign in to comment.