From 27ed563fbc62f79d5dafdb4e6cd62dbc92514c03 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 15:13:54 +0200 Subject: [PATCH 01/20] Fix initialize order --- src/dynamics/thermal/node.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dynamics/thermal/node.hpp b/src/dynamics/thermal/node.hpp index 6999b09ce..a00cb53c7 100644 --- a/src/dynamics/thermal/node.hpp +++ b/src/dynamics/thermal/node.hpp @@ -37,9 +37,9 @@ class Node { double capacity_J_K_; double alpha_; double area_m2_; - libra::Vector<3> normal_vector_b_; double solar_radiation_W_; NodeType node_type_; + libra::Vector<3> normal_vector_b_; public: /** From 007c4444c790e0152d41f7863cbf4d8565c73652 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 15:14:23 +0200 Subject: [PATCH 02/20] Remove unnecessary assertion --- src/dynamics/thermal/node.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/dynamics/thermal/node.cpp b/src/dynamics/thermal/node.cpp index 586bd6c51..670adc2c2 100644 --- a/src/dynamics/thermal/node.cpp +++ b/src/dynamics/thermal/node.cpp @@ -64,8 +64,6 @@ void Node::PrintParam(void) { } void Node::AssertNodeParams(void) { - assert(node_id_ >= 0); // Node ID should be larger than 0 - assert(heater_id_ >= 0); // Heater ID should be larger than 0 assert(temperature_K_ >= environment::absolute_zero_degC); // Temperature must be larger than zero kelvin assert(capacity_J_K_ >= 0); // Capacity must be larger than 0, use 0 when node is boundary or arithmetic assert(0 <= alpha_ && alpha_ <= 1); // alpha must be between 0 and 1 From 4d378885aba6626b34c19caf6fe6d878025a31a4 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 15:17:26 +0200 Subject: [PATCH 03/20] Remove unnecessary SRP constructor --- .../local/solar_radiation_pressure_environment.cpp | 2 -- .../local/solar_radiation_pressure_environment.hpp | 6 ------ 2 files changed, 8 deletions(-) diff --git a/src/environment/local/solar_radiation_pressure_environment.cpp b/src/environment/local/solar_radiation_pressure_environment.cpp index 449ecd56a..846e42342 100644 --- a/src/environment/local/solar_radiation_pressure_environment.cpp +++ b/src/environment/local/solar_radiation_pressure_environment.cpp @@ -20,8 +20,6 @@ SolarRadiationPressureEnvironment::SolarRadiationPressureEnvironment(LocalCelest sun_radius_m_ = local_celestial_information_->GetGlobalInformation().GetMeanRadiusFromName_m("SUN"); } -SolarRadiationPressureEnvironment::SolarRadiationPressureEnvironment() {} - void SolarRadiationPressureEnvironment::UpdateAllStates() { if (!IsCalcEnabled) return; diff --git a/src/environment/local/solar_radiation_pressure_environment.hpp b/src/environment/local/solar_radiation_pressure_environment.hpp index 0e9a26fab..e50c06189 100644 --- a/src/environment/local/solar_radiation_pressure_environment.hpp +++ b/src/environment/local/solar_radiation_pressure_environment.hpp @@ -24,12 +24,6 @@ class SolarRadiationPressureEnvironment : public ILoggable { */ SolarRadiationPressureEnvironment(LocalCelestialInformation* local_celestial_information); - /** - * @fn SolarRadiationPressureEnvironment - * @brief Constructor (Use for constructing Temperature with no params) - */ - SolarRadiationPressureEnvironment(); - /** * @fn ~SolarRadiationPressureEnvironment * @brief Destructor From 6c04dbc0b5f274bd0721a8ab396f6111fd3f2fcf Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 15:22:21 +0200 Subject: [PATCH 04/20] Move to private function --- src/dynamics/thermal/node.hpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/dynamics/thermal/node.hpp b/src/dynamics/thermal/node.hpp index a00cb53c7..9a569948f 100644 --- a/src/dynamics/thermal/node.hpp +++ b/src/dynamics/thermal/node.hpp @@ -29,18 +29,6 @@ enum class NodeType { * @brief Class for managing each node of model */ class Node { - protected: - unsigned int node_id_; - std::string node_name_; - unsigned int heater_id_; - double temperature_K_; - double capacity_J_K_; - double alpha_; - double area_m2_; - double solar_radiation_W_; - NodeType node_type_; - libra::Vector<3> normal_vector_b_; - public: /** * @fn Node @@ -138,6 +126,18 @@ class Node { */ void PrintParam(void); + protected: + unsigned int node_id_; + std::string node_name_; + unsigned int heater_id_; + double temperature_K_; + double capacity_J_K_; + double alpha_; + double area_m2_; + double solar_radiation_W_; + NodeType node_type_; + libra::Vector<3> normal_vector_b_; + /** * @fn AssertNodeParams * @brief Check if Node Parameters are Correct From a04aee4cb60161273feec85d4f3ce0be5d06d577 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 15:31:36 +0200 Subject: [PATCH 05/20] Fix assertion in node class --- src/dynamics/thermal/node.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/dynamics/thermal/node.cpp b/src/dynamics/thermal/node.cpp index 670adc2c2..b3982cf51 100644 --- a/src/dynamics/thermal/node.cpp +++ b/src/dynamics/thermal/node.cpp @@ -64,8 +64,28 @@ void Node::PrintParam(void) { } void Node::AssertNodeParams(void) { - assert(temperature_K_ >= environment::absolute_zero_degC); // Temperature must be larger than zero kelvin - assert(capacity_J_K_ >= 0); // Capacity must be larger than 0, use 0 when node is boundary or arithmetic - assert(0 <= alpha_ && alpha_ <= 1); // alpha must be between 0 and 1 - assert(area_m2_ >= 0); // Area must be larger than 0 + // Temperature must be larger than zero kelvin + if (temperature_K_ >= 0.0) { + std::cerr << "WARNING! Node temperature is less than zero [K]." << std::endl; + std::cerr << "The value is set as 0.0." << std::endl; + temperature_K_ = 0.0; + } + // Capacity must be larger than 0, use 0 when node is boundary or arithmetic + if (capacity_J_K_ >= 0.0) { + std::cerr << "WARNING! Node capacity is less than zero [J/K]." << std::endl; + std::cerr << "The value is set as 0.0." << std::endl; + capacity_J_K_ = 0.0; + } + // alpha must be between 0 and 1 + if (0.0 <= alpha_ && alpha_ <= 1.0) { + std::cerr << "WARNING! Node alpha is over the range [0, 1]." << std::endl; + std::cerr << "The value is set as 0.0." << std::endl; + alpha_ = 0.0; + } + // Area must be larger than 0 + if (area_m2_ >= 0.0) { + std::cerr << "WARNING! Node area is less than zero [m2]." << std::endl; + std::cerr << "The value is set as 0.0." << std::endl; + area_m2_ = 0.0; + } } From 6d17d40b20466de6af0992d4a974782a71d35377 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 15:32:31 +0200 Subject: [PATCH 06/20] Move private function --- src/dynamics/thermal/heater_controller.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dynamics/thermal/heater_controller.hpp b/src/dynamics/thermal/heater_controller.hpp index db271ec84..8f89310ed 100644 --- a/src/dynamics/thermal/heater_controller.hpp +++ b/src/dynamics/thermal/heater_controller.hpp @@ -14,10 +14,6 @@ #include "heater.hpp" class HeaterController { - protected: - double lower_threshold_degC_; // Lower Threshold of Heater Control [degC] - double upper_threshold_degC_; // Upper Threshold of Heater Control [degC] - public: /** * @fn HeaterController @@ -74,6 +70,10 @@ class HeaterController { */ void ControlHeater(Heater* p_heater, double temperature_degC); + protected: + double lower_threshold_degC_; // Lower Threshold of Heater Control [degC] + double upper_threshold_degC_; // Upper Threshold of Heater Control [degC] + /** * @fn AssertHeaterControllerParams * @brief Check Parameters of HeaterController From f1d8b4dd8f07cb185fa80d86b1b24d41741f08b0 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 15:35:18 +0200 Subject: [PATCH 07/20] Fix assertion in heater controller class --- src/dynamics/thermal/heater_controller.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/dynamics/thermal/heater_controller.cpp b/src/dynamics/thermal/heater_controller.cpp index 10280528d..38b25f0bf 100644 --- a/src/dynamics/thermal/heater_controller.cpp +++ b/src/dynamics/thermal/heater_controller.cpp @@ -25,4 +25,11 @@ void HeaterController::ControlHeater(Heater* p_heater, double temperature_degC) } } -void HeaterController::AssertHeaterControllerParams() { assert(upper_threshold_degC_ > lower_threshold_degC_); } +void HeaterController::AssertHeaterControllerParams() { + if (upper_threshold_degC_ > lower_threshold_degC_) { + std::cerr << "[WARNING] heater_controller: the upper threshold is smaller than the lower threshold. " << std::endl; + double auto_set_upper_threshold_degC = lower_threshold_degC_ + 10.0; + std::cerr << "The the upper threshold set as" << auto_set_upper_threshold_degC << std::endl; + upper_threshold_degC_ = auto_set_upper_threshold_degC; + } +} From e6eabad77006632d34fd3f352457431799956a60 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 15:35:53 +0200 Subject: [PATCH 08/20] Fix small --- src/dynamics/thermal/node.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dynamics/thermal/node.cpp b/src/dynamics/thermal/node.cpp index b3982cf51..6d8fc1fb0 100644 --- a/src/dynamics/thermal/node.cpp +++ b/src/dynamics/thermal/node.cpp @@ -66,25 +66,25 @@ void Node::PrintParam(void) { void Node::AssertNodeParams(void) { // Temperature must be larger than zero kelvin if (temperature_K_ >= 0.0) { - std::cerr << "WARNING! Node temperature is less than zero [K]." << std::endl; + std::cerr << "[WARNING] node: temperature is less than zero [K]." << std::endl; std::cerr << "The value is set as 0.0." << std::endl; temperature_K_ = 0.0; } // Capacity must be larger than 0, use 0 when node is boundary or arithmetic if (capacity_J_K_ >= 0.0) { - std::cerr << "WARNING! Node capacity is less than zero [J/K]." << std::endl; + std::cerr << "[WARNING] node: capacity is less than zero [J/K]." << std::endl; std::cerr << "The value is set as 0.0." << std::endl; capacity_J_K_ = 0.0; } // alpha must be between 0 and 1 if (0.0 <= alpha_ && alpha_ <= 1.0) { - std::cerr << "WARNING! Node alpha is over the range [0, 1]." << std::endl; + std::cerr << "[WARNING] node: alpha is over the range [0, 1]." << std::endl; std::cerr << "The value is set as 0.0." << std::endl; alpha_ = 0.0; } // Area must be larger than 0 if (area_m2_ >= 0.0) { - std::cerr << "WARNING! Node area is less than zero [m2]." << std::endl; + std::cerr << "[WARNING] node: area is less than zero [m2]." << std::endl; std::cerr << "The value is set as 0.0." << std::endl; area_m2_ = 0.0; } From 9462cbe866727d8cf5a6f9fa7eedfb2807d05d1b Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 15:37:03 +0200 Subject: [PATCH 09/20] Remove include --- src/dynamics/thermal/heater_controller.cpp | 1 - src/dynamics/thermal/node.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/src/dynamics/thermal/heater_controller.cpp b/src/dynamics/thermal/heater_controller.cpp index 38b25f0bf..f4e7786a3 100644 --- a/src/dynamics/thermal/heater_controller.cpp +++ b/src/dynamics/thermal/heater_controller.cpp @@ -1,6 +1,5 @@ #include "heater_controller.hpp" -#include #include using namespace std; diff --git a/src/dynamics/thermal/node.cpp b/src/dynamics/thermal/node.cpp index 6d8fc1fb0..b2f131eea 100644 --- a/src/dynamics/thermal/node.cpp +++ b/src/dynamics/thermal/node.cpp @@ -5,7 +5,6 @@ #include "node.hpp" -#include #include #include From b216cef73c0dcd0d5b84082947dac944f41bc64a Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 15:37:45 +0200 Subject: [PATCH 10/20] Move to private function --- src/dynamics/thermal/heater.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dynamics/thermal/heater.hpp b/src/dynamics/thermal/heater.hpp index 6472a6615..c858a3951 100644 --- a/src/dynamics/thermal/heater.hpp +++ b/src/dynamics/thermal/heater.hpp @@ -26,13 +26,6 @@ enum class HeaterStatus { * @brief class for heater hardware */ class Heater { - protected: - unsigned int heater_id_; // heater id (Use values over 1) - double power_rating_W_; // Power Rating (100% Duty) [W] - - HeaterStatus heater_status_; // Power Status of Heater - double power_output_W_; // Power Output of Heater [W] - public: /** * @fn Heater @@ -84,6 +77,13 @@ class Heater { */ void PrintParam(void); + protected: + unsigned int heater_id_; // heater id (Use values over 1) + double power_rating_W_; // Power Rating (100% Duty) [W] + + HeaterStatus heater_status_; // Power Status of Heater + double power_output_W_; // Power Output of Heater [W] + /** * @fn AssertHeaterParams * @brief Check Heater Parameters From 48dc46158d11c403189d84fc9f83b2e19f4dd602 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 15:41:43 +0200 Subject: [PATCH 11/20] Fix assertion in heater class --- src/dynamics/thermal/heater.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/dynamics/thermal/heater.cpp b/src/dynamics/thermal/heater.cpp index 37b956121..43d180996 100644 --- a/src/dynamics/thermal/heater.cpp +++ b/src/dynamics/thermal/heater.cpp @@ -1,6 +1,5 @@ #include "heater.hpp" -#include #include using namespace std; @@ -30,6 +29,16 @@ void Heater::PrintParam(void) { } void Heater::AssertHeaterParams(void) { - assert(heater_id_ >= 1); // Heater ID must be larger than 1 - assert(power_rating_W_ >= 0); // Power rating must be larger than 0 + // Heater ID must be larger than 1 + if (heater_id_ >= 1) { + std::cerr << "[WARNING] heater: heater ID is smaller than 1. " << std::endl; + heater_id_ += 1; + std::cerr << "The heater ID is set as " << heater_id_ << std::endl; + } + // Power rating must be larger than 0 + if (power_rating_W_ >= 0) { + std::cerr << "[WARNING] heater: power rating is smaller than 0.0 [W]. " << std::endl; + std::cerr << "The value is set as 0.0." << std::endl; + power_rating_W_ = 0.0; + } } From 45cc51515b6c231762429ab433015300ec8a6135 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 15:42:43 +0200 Subject: [PATCH 12/20] Fix typo --- src/dynamics/thermal/heater_controller.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dynamics/thermal/heater_controller.hpp b/src/dynamics/thermal/heater_controller.hpp index 8f89310ed..d7f8674f8 100644 --- a/src/dynamics/thermal/heater_controller.hpp +++ b/src/dynamics/thermal/heater_controller.hpp @@ -31,22 +31,22 @@ class HeaterController { // Getter /** * @fn GetLowerThreshold_degC - * @brief Return Lower Thershold [degC] + * @brief Return Lower Threshold [degC] */ inline double GetLowerThreshold_degC(void) const { return lower_threshold_degC_; } /** * @fn GetUpperThreshold_degC - * @brief Return Upper Thershold [degC] + * @brief Return Upper Threshold [degC] */ inline double GetUpperThreshold_degC(void) const { return upper_threshold_degC_; } /** * @fn GetLowerThreshold_K - * @brief Return Lower Thershold [K] + * @brief Return Lower Threshold [K] */ inline double GetLowerThreshold_K(void) const { return degC2K(lower_threshold_degC_); } /** * @fn GetUpperThreshold_K - * @brief Return Upper Thershold [K] + * @brief Return Upper Threshold [K] */ inline double GetUpperThreshold_K(void) const { return degC2K(upper_threshold_degC_); } From 8aae1732576b18d9537936c9a9da8dbb92a1b224 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 15:47:00 +0200 Subject: [PATCH 13/20] Move to private function --- src/dynamics/thermal/heatload.hpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/dynamics/thermal/heatload.hpp b/src/dynamics/thermal/heatload.hpp index 805b1456b..e5712cf7d 100644 --- a/src/dynamics/thermal/heatload.hpp +++ b/src/dynamics/thermal/heatload.hpp @@ -15,21 +15,6 @@ * @brief Class for calculating heatload value for Node class object at elapsed time */ class Heatload { - protected: - double elapsed_time_s_; // Elapsed time [s] - unsigned int node_id_; // Node ID to apply heatload - std::vector time_table_s_; // Times that internal heatload values are defined [s] - std::vector internal_heatload_table_W_; // Defined internal heatload values [W] - - unsigned int elapsed_time_idx_; // index of time_table_s_ that is closest to elapsed_time_s_ - double solar_heatload_W_; // Heatload from solar flux [W] - double internal_heatload_W_; // Heatload from internal dissipation [W] - double heater_heatload_W_; // Heatload from heater [W] - double total_heatload_W_; // Total heatload [W] - - double time_table_period_s_; // Value of last element of time_table_s_, which represents the period of the heatload table [s] - double residual_elapsed_time_s_; // Residual of dividing elapsed_time_s_ by time_table_period_s_ [s] - public: /** * @fn Heatload @@ -100,6 +85,21 @@ class Heatload { */ inline void SetHeaterHeatload_W(double heater_heatload_W) { heater_heatload_W_ = heater_heatload_W; } + protected: + double elapsed_time_s_; // Elapsed time [s] + unsigned int node_id_; // Node ID to apply heatload + std::vector time_table_s_; // Times that internal heatload values are defined [s] + std::vector internal_heatload_table_W_; // Defined internal heatload values [W] + + unsigned int elapsed_time_idx_; // index of time_table_s_ that is closest to elapsed_time_s_ + double solar_heatload_W_; // Heatload from solar flux [W] + double internal_heatload_W_; // Heatload from internal dissipation [W] + double heater_heatload_W_; // Heatload from heater [W] + double total_heatload_W_; // Total heatload [W] + + double time_table_period_s_; // Value of last element of time_table_s_, which represents the period of the heatload table [s] + double residual_elapsed_time_s_; // Residual of dividing elapsed_time_s_ by time_table_period_s_ [s] + /** * @fn AssertHeatloadParams * @brief Check if Heatload Parameters are Correct From b96e1779a841913754d31399b98b50dc9a442468 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 16:23:48 +0200 Subject: [PATCH 14/20] Fix to use size_t --- src/dynamics/thermal/temperature.cpp | 38 ++++++++++++++-------------- src/dynamics/thermal/temperature.hpp | 12 ++++----- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/dynamics/thermal/temperature.cpp b/src/dynamics/thermal/temperature.cpp index 1c31f7398..d1ab42e8d 100644 --- a/src/dynamics/thermal/temperature.cpp +++ b/src/dynamics/thermal/temperature.cpp @@ -14,7 +14,7 @@ using namespace std; Temperature::Temperature(const vector> conductance_matrix_W_K, const vector> radiation_matrix_m2, vector nodes, - vector heatloads, vector heaters, vector heater_controllers, const int node_num, + vector heatloads, vector heaters, vector heater_controllers, const size_t node_num, const double propagation_step_s, const SolarRadiationPressureEnvironment* srp_environment, const bool is_calc_enabled, const SolarCalcSetting solar_calc_setting, const bool debug) : conductance_matrix_W_K_(conductance_matrix_W_K), @@ -83,9 +83,9 @@ void Temperature::Propagate(libra::Vector<3> sun_position_b_m, const double time } } -void Temperature::CalcRungeOneStep(double time_now_s, double time_step_s, libra::Vector<3> sun_direction_b, int node_num) { +void Temperature::CalcRungeOneStep(double time_now_s, double time_step_s, libra::Vector<3> sun_direction_b, size_t node_num) { vector temperatures_now_K(node_num); - for (int i = 0; i < node_num; i++) { + for (size_t i = 0; i < node_num; i++) { temperatures_now_K[i] = nodes_[i].GetTemperature_K(); } @@ -93,38 +93,38 @@ void Temperature::CalcRungeOneStep(double time_now_s, double time_step_s, libra: vector xk2(node_num), xk3(node_num), xk4(node_num); k1 = CalcTemperatureDifferentials(temperatures_now_K, time_now_s, sun_direction_b, node_num); - for (int i = 0; i < node_num; i++) { + for (size_t i = 0; i < node_num; i++) { xk2[i] = temperatures_now_K[i] + (time_step_s / 2.0) * k1[i]; } k2 = CalcTemperatureDifferentials(xk2, (time_now_s + time_step_s / 2.0), sun_direction_b, node_num); - for (int i = 0; i < node_num; i++) { + for (size_t i = 0; i < node_num; i++) { xk3[i] = temperatures_now_K[i] + (time_step_s / 2.0) * k2[i]; } k3 = CalcTemperatureDifferentials(xk3, (time_now_s + time_step_s / 2.0), sun_direction_b, node_num); - for (int i = 0; i < node_num; i++) { + for (size_t i = 0; i < node_num; i++) { xk4[i] = temperatures_now_K[i] + time_step_s * k3[i]; } k4 = CalcTemperatureDifferentials(xk4, (time_now_s + time_step_s), sun_direction_b, node_num); vector temperatures_next_K(node_num); - for (int i = 0; i < node_num; i++) { + for (size_t i = 0; i < node_num; i++) { temperatures_next_K[i] = temperatures_now_K[i] + (time_step_s / 6.0) * (k1[i] + 2.0 * k2[i] + 2.0 * k3[i] + k4[i]); } - for (int i = 0; i < node_num; i++) { + for (size_t i = 0; i < node_num; i++) { nodes_[i].SetTemperature_K(temperatures_next_K[i]); } } -vector Temperature::CalcTemperatureDifferentials(vector temperatures_K, double t, libra::Vector<3> sun_direction_b, int node_num) { +vector Temperature::CalcTemperatureDifferentials(vector temperatures_K, double t, libra::Vector<3> sun_direction_b, size_t node_num) { // TODO: consider the following unused arguments are really needed UNUSED(temperatures_K); vector differentials_K_s(node_num); - for (int i = 0; i < node_num; i++) { + for (size_t i = 0; i < node_num; i++) { heatloads_[i].SetElapsedTime_s(t); if (nodes_[i].GetNodeType() == NodeType::kDiffusive) { double solar_flux_W_m2 = srp_environment_->GetPowerDensity_W_m2(); @@ -140,7 +140,7 @@ vector Temperature::CalcTemperatureDifferentials(vector temperat double conductive_heat_input_W = 0; double radiative_heat_input_W = 0; - for (int j = 0; j < node_num; j++) { + for (size_t j = 0; j < node_num; j++) { conductive_heat_input_W += conductance_matrix_W_K_[i][j] * (nodes_[j].GetTemperature_K() - nodes_[i].GetTemperature_K()); radiative_heat_input_W += environment::stefan_boltzmann_constant_W_m2K4 * radiation_matrix_m2_[i][j] * (pow(nodes_[j].GetTemperature_K(), 4) - pow(nodes_[i].GetTemperature_K(), 4)); @@ -176,14 +176,14 @@ void Temperature::UpdateHeaterStatus(void) { string Temperature::GetLogHeader() const { string str_tmp = ""; - for (int i = 0; i < node_num_; i++) { + for (size_t i = 0; i < node_num_; i++) { // Do not retrieve boundary node values if (nodes_[i].GetNodeType() != NodeType::kBoundary) { string str_node = "temp_" + to_string(nodes_[i].GetNodeId()) + " (" + nodes_[i].GetNodeName() + ")"; str_tmp += WriteScalar(str_node, "deg"); } } - for (int i = 0; i < node_num_; i++) { + for (size_t i = 0; i < node_num_; i++) { // Do not retrieve boundary node values if (nodes_[i].GetNodeType() != NodeType::kBoundary) { string str_node = "heat_" + to_string(nodes_[i].GetNodeId()) + " (" + nodes_[i].GetNodeName() + ")"; @@ -195,13 +195,13 @@ string Temperature::GetLogHeader() const { string Temperature::GetLogValue() const { string str_tmp = ""; - for (int i = 0; i < node_num_; i++) { + for (size_t i = 0; i < node_num_; i++) { // Do not retrieve boundary node values if (nodes_[i].GetNodeType() != NodeType::kBoundary) { str_tmp += WriteScalar(nodes_[i].GetTemperature_degC()); } } - for (int i = 0; i < node_num_; i++) { + for (size_t i = 0; i < node_num_; i++) { // Do not retrieve boundary node values if (nodes_[i].GetNodeType() != NodeType::kBoundary) { str_tmp += WriteScalar(heatloads_[i].GetTotalHeatload_W()); @@ -223,15 +223,15 @@ void Temperature::PrintParams(void) { } cout << std::fixed; cout << "Cij:" << endl; - for (int i = 0; i < (node_num_); i++) { - for (int j = 0; j < (node_num_); j++) { + for (size_t i = 0; i < (node_num_); i++) { + for (size_t j = 0; j < (node_num_); j++) { cout << std::setprecision(4) << conductance_matrix_W_K_[i][j] << " "; } cout << endl; } cout << "Rij:" << endl; - for (int i = 0; i < (node_num_); i++) { - for (int j = 0; j < (node_num_); j++) { + for (size_t i = 0; i < (node_num_); i++) { + for (size_t j = 0; j < (node_num_); j++) { cout << std::setprecision(4) << radiation_matrix_m2_[i][j] << " "; } cout << endl; diff --git a/src/dynamics/thermal/temperature.hpp b/src/dynamics/thermal/temperature.hpp index ca0af4265..d0b72cc39 100644 --- a/src/dynamics/thermal/temperature.hpp +++ b/src/dynamics/thermal/temperature.hpp @@ -37,7 +37,7 @@ class Temperature : public ILoggable { std::vector heatloads_; // vector of heatloads std::vector heaters_; // vector of heaters std::vector heater_controllers_; // vector of heater controllers - int node_num_; // number of nodes + size_t node_num_; // number of nodes double propagation_step_s_; // propagation step [s] double propagation_time_s_; // Incremented time inside class Temperature [s], finish propagation when reaching end_time const SolarRadiationPressureEnvironment* srp_environment_; // SolarRadiationPressureEnvironment for calculating solar flux @@ -54,7 +54,7 @@ class Temperature : public ILoggable { * @param[in] sun_direction_b: Sun position in body frame [m] * @param[in] node_num: Number of nodes */ - void CalcRungeOneStep(double time_now_s, double time_step_s, libra::Vector<3> sun_direction_b, int node_num); + void CalcRungeOneStep(double time_now_s, double time_step_s, libra::Vector<3> sun_direction_b, size_t node_num); /** * @fn CalcTemperatureDifferentials * @brief Calculate differential of thermal equilibrium equation @@ -66,7 +66,7 @@ class Temperature : public ILoggable { * @return std::vector: Differential of thermal equilibrium equation at time now */ std::vector CalcTemperatureDifferentials(std::vector temperatures_K, double time_now_s, const libra::Vector<3> sun_direction_b, - int node_num); + size_t node_num); public: /** @@ -75,7 +75,7 @@ class Temperature : public ILoggable { * * @param conductance_matrix_W_K: (node_num x node_num) matrix with heat conductance values [W/K] * @param radiation_matrix_m2: (node_num x node_num) matrix with radiative connection values [m2] - * @param nodes: Vector of all nodes inculded in calculation + * @param nodes: Vector of all nodes included in calculation * @param heatloads: Vector of all heatloads included in calculation * @param heaters: Vector of all heaters included in calculation * @param heater_controllers: Vector of all heater controllers included in calculation @@ -87,7 +87,7 @@ class Temperature : public ILoggable { */ Temperature(const std::vector> conductance_matrix_W_K, const std::vector> radiation_matrix_m2, std::vector nodes, std::vector heatloads, std::vector heaters, std::vector heater_controllers, - const int node_num, const double propagation_step_s, const SolarRadiationPressureEnvironment* srp_environment, + const size_t node_num, const double propagation_step_s, const SolarRadiationPressureEnvironment* srp_environment, const bool is_calc_enabled, const SolarCalcSetting solar_calc_setting, const bool debug); /** * @fn Temperature @@ -145,7 +145,7 @@ class Temperature : public ILoggable { /** * @fn PrintParams - * @brief Print parameters of tempearture in debug console + * @brief Print parameters of temperature in debug console */ void PrintParams(void); }; From deaa797f4ca42723ff9335bc954d20575185b1b6 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 16:30:31 +0200 Subject: [PATCH 15/20] Fix typo --- .../thermal/initialize_temperature.cpp | 20 ++++++------------- src/dynamics/thermal/temperature.cpp | 4 ++-- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/dynamics/thermal/initialize_temperature.cpp b/src/dynamics/thermal/initialize_temperature.cpp index ca68bb419..3b05cdf30 100644 --- a/src/dynamics/thermal/initialize_temperature.cpp +++ b/src/dynamics/thermal/initialize_temperature.cpp @@ -14,7 +14,7 @@ #include "initialize_heatload.hpp" #include "initialize_node.hpp" -/* Import node properties, heatload_list and Cij/Rij Datas by reading CSV File (node.csv, +/* Import node properties, heatload_list and Cij/Rij Data by reading CSV File (node.csv, heatload.csv, cij.csv, rij.csv) Detailed process of reading node properties from CSV File, and CSV file formats of node properties is written in Init_Node.cpp @@ -47,14 +47,6 @@ First row is time data Rij units: m^2 (Equivalent to Ai * Bij * eps_i * eps_j) */ -/* Parameters - mainIni : main Ini file(simBase.ini) - file_path : directory of Thermal Input files(read from SimBase.ini) - propstep : time step interval for temperature propagation integration(read - from SimBase.ini) mainstepSec: time step interval for Main Routin integration - (= temperature.end_time_) - */ - using std::string; using std::vector; @@ -100,7 +92,7 @@ Temperature* InitTemperature(const std::string file_name, const double rk_prop_s IniAccess conf_heatload(filepath_heatload); conf_heatload.ReadCsvString(heatload_str_list, 100); /*since we don't know the number of node_list yet, set node_num=100 temporary. - Recall that Nodes_num are given to this function only to reseve memory*/ + Recall that Nodes_num are given to this function only to reserve memory*/ heatload_num = heatload_str_list.size() - 1; auto times_itr = heatload_str_list.begin(); // First Row is Time Data @@ -113,7 +105,7 @@ Temperature* InitTemperature(const std::string file_name, const double rk_prop_s IniAccess conf_node(filepath_node); conf_node.ReadCsvString(node_str_list, 100); /*since we don't know the number of node_list yet, set node_num=100 temporary. - Recall that Nodes_num are given to this function only to reseve memory*/ + Recall that Nodes_num are given to this function only to reserve memory*/ node_num = node_str_list.size() - 1; // First Row is for Header(not data) node_list.reserve(node_num); // reserve memory @@ -128,10 +120,10 @@ Temperature* InitTemperature(const std::string file_name, const double rk_prop_s IniAccess conf_heater(filepath_heater); conf_heater.ReadCsvString(heater_str_list, 100); /*since we don't know the number of heater_list yet, set heater_num=100 temporary. - Recall that heater_num are given to this function only to reseve memory*/ + Recall that heater_num are given to this function only to reserve memory*/ - heater_num = heater_str_list.size() - 1; // First Row is for Header(not data) - heater_list.reserve(heater_num); // reserve memory + heater_num = heater_str_list.size() - 1; // First Row is for Header(not data) + heater_list.reserve(heater_num); // reserve memory heater_controller_list.reserve(heater_num); for (auto itr = heater_str_list.begin() + 1; itr != heater_str_list.end(); ++itr) { // first row is for labels heater_list.push_back(InitHeater(*itr)); diff --git a/src/dynamics/thermal/temperature.cpp b/src/dynamics/thermal/temperature.cpp index d1ab42e8d..fc17811b7 100644 --- a/src/dynamics/thermal/temperature.cpp +++ b/src/dynamics/thermal/temperature.cpp @@ -213,11 +213,11 @@ string Temperature::GetLogValue() const { void Temperature::PrintParams(void) { cout << "< Print Thermal Parameters >" << endl; cout << "IsCalcEnabled: " << is_calc_enabled_ << endl; - cout << "Vnodes:" << endl; + cout << "V nodes:" << endl; for (auto itr = nodes_.begin(); itr != nodes_.end(); ++itr) { itr->PrintParam(); } - cout << "Vheaters:" << endl; + cout << "V heaters:" << endl; for (auto itr = heaters_.begin(); itr != heaters_.end(); ++itr) { itr->PrintParam(); } From cf8547f6136029eea23aeafd9514fea6611bbb30 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 16:30:57 +0200 Subject: [PATCH 16/20] Fix typo --- src/dynamics/thermal/initialize_heatload.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dynamics/thermal/initialize_heatload.hpp b/src/dynamics/thermal/initialize_heatload.hpp index 7dbb8a55e..fa5455f2a 100644 --- a/src/dynamics/thermal/initialize_heatload.hpp +++ b/src/dynamics/thermal/initialize_heatload.hpp @@ -10,7 +10,7 @@ /** * @fn InitHeatload - * @brief Intialize Heatload object from csv file + * @brief Initialize Heatload object from csv file * @param[in] time_str: str representing time table, read from csv file * @param[in] internal_heatload_str: str representing internal heatload table, read from csv file * @return Heatload From 215ad60ff5e11d5aa55472cc26848c90eca08310 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 16:43:23 +0200 Subject: [PATCH 17/20] Fix to use size_t --- src/dynamics/thermal/initialize_heater.cpp | 10 +++---- src/dynamics/thermal/initialize_heatload.cpp | 2 +- src/dynamics/thermal/initialize_node.cpp | 28 ++++++++++---------- src/dynamics/thermal/node.cpp | 4 +-- src/dynamics/thermal/node.hpp | 8 +++--- src/dynamics/thermal/temperature.cpp | 10 +++---- src/dynamics/thermal/temperature.hpp | 2 +- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/dynamics/thermal/initialize_heater.cpp b/src/dynamics/thermal/initialize_heater.cpp index fb488ad54..3c4f53458 100644 --- a/src/dynamics/thermal/initialize_heater.cpp +++ b/src/dynamics/thermal/initialize_heater.cpp @@ -25,12 +25,12 @@ Heater InitHeater(const std::vector& heater_str) { size_t heater_str_size_defined = 4; // Correct size of heater_str assert(heater_str.size() == heater_str_size_defined); // Check if size of heater_str is correct - int heater_id = 0; + size_t heater_id = 0; double power_rating_W = 0; // [W] // Index to read from heater_str for each parameter - int index_heater_id = 0; - int index_power_rating = 1; + size_t index_heater_id = 0; + size_t index_power_rating = 1; heater_id = stoi(heater_str[index_heater_id]); power_rating_W = stod(heater_str[index_power_rating]); @@ -46,8 +46,8 @@ HeaterController InitHeaterController(const std::vector& heater_str assert(heater_str.size() == heater_str_size_defined); // Check if size of heater_str is correct // Index to read from heater_str for each parameter - int index_lower_threshold = 2; - int index_upper_threshold = 3; + size_t index_lower_threshold = 2; + size_t index_upper_threshold = 3; double lower_threshold_degC = 0; // [degC] double upper_threshold_degC = 0; // [degC] diff --git a/src/dynamics/thermal/initialize_heatload.cpp b/src/dynamics/thermal/initialize_heatload.cpp index a0e16176e..5b9367970 100644 --- a/src/dynamics/thermal/initialize_heatload.cpp +++ b/src/dynamics/thermal/initialize_heatload.cpp @@ -41,7 +41,7 @@ Heatload InitHeatload(const std::vector& time_str, const std::vecto int node_id = stoi(internal_heatload_str[0]); // First data of internal_heatload_str is node id // read table - for (unsigned int i = 0; i < time_str.size() - 1; ++i) { + for (size_t i = 0; i < time_str.size() - 1; ++i) { time_table_s[i] = stod(time_str[i + 1]); internal_heatload_table_W[i] = stod(internal_heatload_str[i + 1]); } diff --git a/src/dynamics/thermal/initialize_node.cpp b/src/dynamics/thermal/initialize_node.cpp index 25b51775c..865e1947c 100644 --- a/src/dynamics/thermal/initialize_node.cpp +++ b/src/dynamics/thermal/initialize_node.cpp @@ -42,25 +42,25 @@ Node InitNode(const std::vector& node_str) { size_t node_str_size_defined = 11; // Correct size of node_str assert(node_str.size() == node_str_size_defined); // Check if size of node_str is correct - int node_id = 0; // node number + size_t node_id = 0; // node number std::string node_label = "temp"; // node name - int node_type_int = 0; // node type - int heater_id = 0; // heater node index + size_t node_type_int = 0; // node type + size_t heater_id = 0; // heater node index double temperature_K = 0; // [K] double capacity_J_K = 0; // [J/K] double alpha = 0; // [] double area_m2 = 0; // [m^2] // Index to read from node_str for each parameter - int index_node_id = 0; - int index_node_label = 1; - int index_node_type = 2; - int index_heater_id = 3; - int index_capacity = 4; - int index_alpha = 5; - int index_area = 6; - int index_normal_v_b_head = 7; - int index_temperature = 10; + size_t index_node_id = 0; + size_t index_node_label = 1; + size_t index_node_type = 2; + size_t index_heater_id = 3; + size_t index_capacity = 4; + size_t index_alpha = 5; + size_t index_area = 6; + size_t index_normal_v_b_head = 7; + size_t index_temperature = 10; node_id = stoi(node_str[index_node_id]); node_label = node_str[index_node_label]; @@ -70,14 +70,14 @@ Node InitNode(const std::vector& node_str) { alpha = stod(node_str[index_alpha]); area_m2 = stod(node_str[index_area]); libra::Vector<3> normal_v_b; - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { normal_v_b[i] = stod(node_str[index_normal_v_b_head + i]); } // Normalize Norm Vector (Except for Boundary and Arithmetic Nodes) if (node_type_int == 0) { double norm = normal_v_b.CalcNorm(); - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { normal_v_b[i] = normal_v_b[i] / norm; } } diff --git a/src/dynamics/thermal/node.cpp b/src/dynamics/thermal/node.cpp index b2f131eea..33cc3051e 100644 --- a/src/dynamics/thermal/node.cpp +++ b/src/dynamics/thermal/node.cpp @@ -11,7 +11,7 @@ using namespace std; using namespace libra; -Node::Node(const int node_id, const string node_name, const NodeType node_type, const int heater_id, const double temperature_ini_K, +Node::Node(const size_t node_id, const string node_name, const NodeType node_type, const size_t heater_id, const double temperature_ini_K, const double capacity_J_K, const double alpha, const double area_m2, libra::Vector<3> normal_vector_b) : node_id_(node_id), node_name_(node_name), @@ -56,7 +56,7 @@ void Node::PrintParam(void) { cout << " node type : " << node_type_str << endl; cout << " heater id : " << heater_id_ << endl; cout << " Normal Vector: "; - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { cout << normal_vector_b_[i] << " "; } cout << endl; diff --git a/src/dynamics/thermal/node.hpp b/src/dynamics/thermal/node.hpp index 9a569948f..3ff02f8cd 100644 --- a/src/dynamics/thermal/node.hpp +++ b/src/dynamics/thermal/node.hpp @@ -44,7 +44,7 @@ class Node { * @param[in] area_m2: Area of face with possibility of solar incidence [m^2] * @param[in] normal_vector_b: Normal vector of face with possibility of solar incidence (Body frame) */ - Node(const int node_id, const std::string node_name, const NodeType node_type, const int heater_id, const double temperature_ini_K, + Node(const size_t node_id, const std::string node_name, const NodeType node_type, const size_t heater_id, const double temperature_ini_K, const double capacity_J_K, const double alpha, const double area_m2, libra::Vector<3> normal_vector_b); /** * @fn ~Node @@ -78,7 +78,7 @@ class Node { * @brief Return Heater Id * @return int: Heater ID */ - inline int GetHeaterId(void) const { return heater_id_; } + inline size_t GetHeaterId(void) const { return heater_id_; } /** * @fn GetTemperature_K * @brief Get temperature of node in Kelvin @@ -127,9 +127,9 @@ class Node { void PrintParam(void); protected: - unsigned int node_id_; + size_t node_id_; std::string node_name_; - unsigned int heater_id_; + size_t heater_id_; double temperature_K_; double capacity_J_K_; double alpha_; diff --git a/src/dynamics/thermal/temperature.cpp b/src/dynamics/thermal/temperature.cpp index fc17811b7..91d9e6926 100644 --- a/src/dynamics/thermal/temperature.cpp +++ b/src/dynamics/thermal/temperature.cpp @@ -50,7 +50,7 @@ void Temperature::Propagate(libra::Vector<3> sun_position_b_m, const double time if (!is_calc_enabled_) return; double sun_distance_m = sun_position_b_m.CalcNorm(); libra::Vector<3> sun_direction_b; - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { sun_direction_b[i] = sun_position_b_m[i] / sun_distance_m; } while (time_end_s - propagation_time_s_ - propagation_step_s_ > 1.0e-6) { @@ -72,7 +72,7 @@ void Temperature::Propagate(libra::Vector<3> sun_position_b_m, const double time cout << setprecision(4) << itr->GetSolarRadiation_W() << " "; } cout << "SunDir: "; - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { cout << setprecision(3) << sun_direction_b[i] << " "; } cout << "Heatload: "; @@ -154,8 +154,8 @@ vector Temperature::CalcTemperatureDifferentials(vector temperat return differentials_K_s; } -double Temperature::GetHeaterPower_W(int node_id) { - int heater_id = nodes_[node_id].GetHeaterId(); +double Temperature::GetHeaterPower_W(size_t node_id) { + size_t heater_id = nodes_[node_id].GetHeaterId(); double heater_power_W = 0.0; if (heater_id > 0) { heater_power_W = heaters_[heater_id - 1].GetPowerOutput_W(); @@ -165,7 +165,7 @@ double Temperature::GetHeaterPower_W(int node_id) { void Temperature::UpdateHeaterStatus(void) { for (auto itr = nodes_.begin(); itr != nodes_.end(); ++itr) { - int heater_id = itr->GetHeaterId(); + size_t heater_id = itr->GetHeaterId(); if (heater_id > 0) { double temperature_degC = itr->GetTemperature_degC(); Heater* p_heater = &heaters_[heater_id - 1]; diff --git a/src/dynamics/thermal/temperature.hpp b/src/dynamics/thermal/temperature.hpp index d0b72cc39..19fab924a 100644 --- a/src/dynamics/thermal/temperature.hpp +++ b/src/dynamics/thermal/temperature.hpp @@ -123,7 +123,7 @@ class Temperature : public ILoggable { * @param node_id: Node number to return heater power * @return double: Heater power [W] */ - double GetHeaterPower_W(int node_id); + double GetHeaterPower_W(size_t node_id); /** * @fn GetLogHeader * @brief Return Log Header From d06720bc4ac76e311fa2dda6f1c3821e59e2adb7 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Wed, 27 Sep 2023 16:50:28 +0200 Subject: [PATCH 18/20] Fix to use size_t --- src/dynamics/thermal/node.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dynamics/thermal/node.hpp b/src/dynamics/thermal/node.hpp index 3ff02f8cd..515f1883f 100644 --- a/src/dynamics/thermal/node.hpp +++ b/src/dynamics/thermal/node.hpp @@ -64,9 +64,9 @@ class Node { /** * @fn GetNodeId * @brief Return Node Id - * @return int: Node ID + * @return size_t: Node ID */ - inline int GetNodeId(void) const { return node_id_; } + inline size_t GetNodeId(void) const { return node_id_; } /** * @fn GetNodeName * @brief Return Node Name From 642229c6be7f1b6720b137d4f5bd08edab5edcb7 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Thu, 28 Sep 2023 07:34:26 +0200 Subject: [PATCH 19/20] Fix assertion --- src/dynamics/thermal/heater.cpp | 4 ++-- src/dynamics/thermal/heater_controller.cpp | 2 +- src/dynamics/thermal/node.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dynamics/thermal/heater.cpp b/src/dynamics/thermal/heater.cpp index 43d180996..2399f2b65 100644 --- a/src/dynamics/thermal/heater.cpp +++ b/src/dynamics/thermal/heater.cpp @@ -30,13 +30,13 @@ void Heater::PrintParam(void) { void Heater::AssertHeaterParams(void) { // Heater ID must be larger than 1 - if (heater_id_ >= 1) { + if (heater_id_ < 1) { std::cerr << "[WARNING] heater: heater ID is smaller than 1. " << std::endl; heater_id_ += 1; std::cerr << "The heater ID is set as " << heater_id_ << std::endl; } // Power rating must be larger than 0 - if (power_rating_W_ >= 0) { + if (power_rating_W_ < 0.0) { std::cerr << "[WARNING] heater: power rating is smaller than 0.0 [W]. " << std::endl; std::cerr << "The value is set as 0.0." << std::endl; power_rating_W_ = 0.0; diff --git a/src/dynamics/thermal/heater_controller.cpp b/src/dynamics/thermal/heater_controller.cpp index f4e7786a3..1d45623e2 100644 --- a/src/dynamics/thermal/heater_controller.cpp +++ b/src/dynamics/thermal/heater_controller.cpp @@ -25,7 +25,7 @@ void HeaterController::ControlHeater(Heater* p_heater, double temperature_degC) } void HeaterController::AssertHeaterControllerParams() { - if (upper_threshold_degC_ > lower_threshold_degC_) { + if (upper_threshold_degC_ < lower_threshold_degC_) { std::cerr << "[WARNING] heater_controller: the upper threshold is smaller than the lower threshold. " << std::endl; double auto_set_upper_threshold_degC = lower_threshold_degC_ + 10.0; std::cerr << "The the upper threshold set as" << auto_set_upper_threshold_degC << std::endl; diff --git a/src/dynamics/thermal/node.cpp b/src/dynamics/thermal/node.cpp index 33cc3051e..f213295c0 100644 --- a/src/dynamics/thermal/node.cpp +++ b/src/dynamics/thermal/node.cpp @@ -64,25 +64,25 @@ void Node::PrintParam(void) { void Node::AssertNodeParams(void) { // Temperature must be larger than zero kelvin - if (temperature_K_ >= 0.0) { + if (temperature_K_ < 0.0) { std::cerr << "[WARNING] node: temperature is less than zero [K]." << std::endl; std::cerr << "The value is set as 0.0." << std::endl; temperature_K_ = 0.0; } // Capacity must be larger than 0, use 0 when node is boundary or arithmetic - if (capacity_J_K_ >= 0.0) { + if (capacity_J_K_ < 0.0) { std::cerr << "[WARNING] node: capacity is less than zero [J/K]." << std::endl; std::cerr << "The value is set as 0.0." << std::endl; capacity_J_K_ = 0.0; } // alpha must be between 0 and 1 - if (0.0 <= alpha_ && alpha_ <= 1.0) { + if (alpha_ < 0.0 && alpha_ > 1.0) { std::cerr << "[WARNING] node: alpha is over the range [0, 1]." << std::endl; std::cerr << "The value is set as 0.0." << std::endl; alpha_ = 0.0; } // Area must be larger than 0 - if (area_m2_ >= 0.0) { + if (area_m2_ < 0.0) { std::cerr << "[WARNING] node: area is less than zero [m2]." << std::endl; std::cerr << "The value is set as 0.0." << std::endl; area_m2_ = 0.0; From 0d6d0cb2c7481895dcf0b1139e7a23a3cd717013 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari <19573779+200km@users.noreply.github.com> Date: Thu, 5 Oct 2023 09:35:03 +0200 Subject: [PATCH 20/20] Update src/dynamics/thermal/node.cpp Co-authored-by: Toshihiro Suzuki <93800108+suzuki-toshihir0@users.noreply.github.com> --- src/dynamics/thermal/node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dynamics/thermal/node.cpp b/src/dynamics/thermal/node.cpp index f213295c0..2e3f47032 100644 --- a/src/dynamics/thermal/node.cpp +++ b/src/dynamics/thermal/node.cpp @@ -76,7 +76,7 @@ void Node::AssertNodeParams(void) { capacity_J_K_ = 0.0; } // alpha must be between 0 and 1 - if (alpha_ < 0.0 && alpha_ > 1.0) { + if (alpha_ < 0.0 || alpha_ > 1.0) { std::cerr << "[WARNING] node: alpha is over the range [0, 1]." << std::endl; std::cerr << "The value is set as 0.0." << std::endl; alpha_ = 0.0;