-
Notifications
You must be signed in to change notification settings - Fork 19
Feature/add earth ir and fix albedo to thermal calc #755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
68bcfc6
5254ebe
d24ab04
d8e071a
996fd7a
ae3b26b
ca09574
229d0f8
99d6c69
48c1b14
20c3a93
dc829bb
8f1e681
c5803f2
42a401c
86b1034
ff7f434
ea55067
7a2be93
5a9dae8
b13daf1
78eb863
347055c
8c5f133
6018ce9
c636092
16a73f9
4e7b6a9
3de2e54
19c6065
7333c30
a6b16e4
176a3b7
35191a5
f641c34
ea148f7
b9a1b6a
054162d
8740bf0
613e51b
096b237
1bc3b09
ca18f4b
6c633de
60c61f4
32a2165
1564190
3ff089e
ceafc84
bcfa86f
aa8ee5a
aeeb258
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| NodeID/Times[s],0,500,501,1000,1001,1500 | ||
| 0,10,10,20,20,10,10 | ||
| 1,0,0,0,0,0,0 | ||
| 2,0,0,0,0,0,0 | ||
| 2,0,0,0,0,0,0 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [NITS] 必要ない修正に見えます。 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| Node_id,Node_label,"node_type (0: diffusive, 1: boundary, 2: arithmetic)",heater_node_id,capacity[J/K],alpha,area[m^2],normal_v_b_x,normal_v_b_y,normal_v_b_z,initial_temperature[K] | ||
| 0,BUS,0,1,880,0.2,0.06,1,0,0,300 | ||
| 1,SAP,0,0,100,0,0.02,0,0,1,250 | ||
| 2,SPACE,1,0,0,0,0,0,0,0,2.73 | ||
| Node_id,Node_label,node_type (0: diffusive 1: boundary 2: arithmetic),heater_node_id,capacity[J/K],alpha,epsilon,area[m^2],normal_v_b_x,normal_v_b_y,normal_v_b_z,initial_temperature[K] | ||
| 0,BUS,0,1,880,0.2,0.7,0.06,1,0,0,300 | ||
| 1,SAP,0,0,100,0,0,0.02,0,0,1,250 | ||
| 2,SPACE,1,0,0,0,0,0,0,0,0,2.73 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,26 +8,29 @@ | |
| #include <cassert> | ||
| #include <cmath> | ||
| #include <environment/global/physical_constants.hpp> | ||
| #include <math_physics/math/constants.hpp> | ||
|
|
||
| using namespace std; | ||
| using namespace s2e::math; | ||
|
|
||
| namespace s2e::dynamics::thermal { | ||
|
|
||
| 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, math::Vector<3> normal_vector_b) | ||
| const double capacity_J_K, const double alpha, const double epsilon, const double area_m2, math::Vector<3> normal_vector_b) | ||
| : node_id_(node_id), | ||
| node_name_(node_name), | ||
| heater_id_(heater_id), | ||
| temperature_K_(temperature_ini_K), | ||
| capacity_J_K_(capacity_J_K), | ||
| alpha_(alpha), | ||
| epsilon_(epsilon), | ||
| area_m2_(area_m2), | ||
| node_type_(node_type), | ||
| normal_vector_b_(normal_vector_b) { | ||
| AssertNodeParams(); | ||
| solar_radiation_W_ = 0.0; | ||
| albedo_radiation_W_ = 0.0; | ||
| earth_infrared_W_ = 0.0; | ||
| } | ||
|
|
||
| Node::~Node() {} | ||
|
|
@@ -43,20 +46,91 @@ double Node::CalcSolarRadiation_W(math::Vector<3> sun_direction_b, double solar_ | |
| return solar_radiation_W_; | ||
| } | ||
|
|
||
| double Node::CalcAlbedoRadiation_W(math::Vector<3> earth_position_b_m, double earth_albedo_W_m2) { | ||
| math::Vector<3> earth_direction_b = earth_position_b_m.CalcNormalizedVector(); | ||
| double Node::CalcAlbedoRadiation_W(math::Vector<3> earth_position_b_m, math::Vector<3> sun_direction_b, double earth_albedo_W_m2) { | ||
| math::Vector<3> sat2earth_direction_b = earth_position_b_m.CalcNormalizedVector(); | ||
| math::Vector<3> sat2sun_direction_b = sun_direction_b; | ||
|
|
||
| double cos_theta_albedo = InnerProduct(earth_direction_b, normal_vector_b_); | ||
| math::Vector<3> vec_a = -sat2earth_direction_b; | ||
| math::Vector<3> vec_b = (sat2sun_direction_b - sat2earth_direction_b).CalcNormalizedVector(); | ||
|
|
||
| // albedo radiation calculation; earth_albedo_W_m2 reflects the shadow coefficient. | ||
| if (cos_theta_albedo > 0.0) { | ||
| albedo_radiation_W_ = earth_albedo_W_m2 * area_m2_ * alpha_ * cos_theta_albedo; | ||
| double cos_theta = InnerProduct(vec_a, vec_b); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [IMO] この辺りのローカル変数はその後変更する予定が無いものなら、 |
||
| double lamda = acos(InnerProduct(sat2earth_direction_b, normal_vector_b_)); | ||
| double h = earth_position_b_m.CalcNorm() - environment::earth_equatorial_radius_m; | ||
| double H = earth_position_b_m.CalcNorm() / environment::earth_equatorial_radius_m; | ||
| double phi_m = asin(1.0 / H); | ||
| double b = sqrt(H * H - 1.0); | ||
| double view_factor; | ||
|
|
||
| // Calc view factor | ||
| // ref)POWER INPUT TO A SMALL FLAT PLATE FROM A DIFFUSELY RADIATING SPHERE WITH APPLICATION TO EARTH SATELLITES: THE SPINNING PLATE | ||
| if (h < 1732e3) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [MUST] マジックナンバーは最低限コメントが欲しい。もしくは、 |
||
| if (lamda <= math::pi / 2.0 - phi_m) { | ||
| view_factor = cos(lamda) / H / H; | ||
| } else if (lamda <= math::pi / 2.0 + phi_m) { | ||
| view_factor = 1.0 / 2.0 - 1.0 / math::pi * asin(b / (H * sin(lamda))) + | ||
| 1.0 / (math::pi * pow(H, 2.0)) * (cos(lamda) * acos(-b / tan(lamda)) - b * sqrt(1.0 - pow(H * cos(lamda), 2.0))); | ||
| } else { | ||
| view_factor = 0.0; | ||
| } | ||
| } else { | ||
| albedo_radiation_W_ = 0.0; | ||
| if (lamda < math::pi / 2.0) { | ||
| // Consider in terms of steradian | ||
| view_factor = 0.25 / H / H; | ||
| } else { | ||
| view_factor = 0.0; | ||
| } | ||
| } | ||
|
|
||
| // Banister's approximation. ref) RADIATION GEOMETRY FACTOR BETWEEN THE EARTH AND A SATELLITE | ||
| if (cos_theta > 0.0) { | ||
| // TODO: correlate the value of the exponent with the view factor | ||
| view_factor *= pow(cos_theta, 3.0); | ||
| } else { | ||
| view_factor = 0.0; | ||
| } | ||
|
|
||
| // albedo radiation calculation; earth_albedo_W_m2 reflects the shadow coefficient. | ||
| albedo_radiation_W_ = earth_albedo_W_m2 * area_m2_ * alpha_ * view_factor; | ||
|
|
||
| return albedo_radiation_W_; | ||
| } | ||
|
|
||
| double Node::CalcEarthInfraredRadiation_W(math::Vector<3> earth_position_b_m, double earth_infrared_W_m2) { | ||
| math::Vector<3> earth_direction_b = earth_position_b_m.CalcNormalizedVector(); | ||
|
|
||
| double lamda = acos(InnerProduct(earth_direction_b, normal_vector_b_)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [IMO] こちらの関数も上のものと同様のコメント |
||
| double h = earth_position_b_m.CalcNorm() - environment::earth_equatorial_radius_m; | ||
| double H = earth_position_b_m.CalcNorm() / environment::earth_equatorial_radius_m; | ||
| double phi_m = asin(1.0 / H); | ||
| double b = sqrt(H * H - 1.0); | ||
| double view_factor; | ||
|
|
||
| // Calc view factor | ||
| // ref)POWER INPUT TO A SMALL FLAT PLATE FROM A DIFFUSELY RADIATING SPHERE WITH APPLICATION TO EARTH SATELLITES: THE SPINNING PLATE | ||
| if (h < 1732e3) { | ||
| if (lamda <= math::pi / 2.0 - phi_m) { | ||
| view_factor = cos(lamda) / H / H; | ||
| } else if (lamda <= math::pi / 2.0 + phi_m) { | ||
| view_factor = 1.0 / 2.0 - 1.0 / math::pi * asin(b / (H * sin(lamda))) + | ||
| 1.0 / (math::pi * pow(H, 2.0)) * (cos(lamda) * acos(-b / tan(lamda)) - b * sqrt(1.0 - pow(H * cos(lamda), 2.0))); | ||
| } else { | ||
| view_factor = 0.0; | ||
| } | ||
| } else { | ||
| if (lamda < math::pi / 2.0) { | ||
| // Consider in terms of steradian | ||
| view_factor = 0.25 / H / H; | ||
| } else { | ||
| view_factor = 0.0; | ||
| } | ||
| } | ||
|
|
||
| // earth infrared radiation calculation | ||
| earth_infrared_W_ = earth_infrared_W_m2 * area_m2_ * epsilon_ * view_factor; | ||
|
|
||
| return earth_infrared_W_; | ||
| } | ||
|
|
||
| void Node::PrintParam(void) { | ||
| string node_type_str = ""; | ||
| if (node_type_ == NodeType::kDiffusive) { | ||
|
|
@@ -70,6 +144,7 @@ void Node::PrintParam(void) { | |
| cout << " node_name : " << node_name_ << endl; | ||
| cout << " temperature : " << temperature_K_ << endl; | ||
| cout << " alpha : " << alpha_ << endl; | ||
| cout << " epsilon : " << epsilon_ << endl; | ||
| cout << " capacity : " << capacity_J_K_ << endl; | ||
| cout << " node type : " << node_type_str << endl; | ||
| cout << " heater id : " << heater_id_ << endl; | ||
|
|
@@ -99,6 +174,14 @@ void Node::AssertNodeParams(void) { | |
| std::cerr << "The value is set as 0.0." << std::endl; | ||
| alpha_ = 0.0; | ||
| } | ||
|
|
||
| // epsilon must be between 0 and 1 | ||
| if (epsilon_ < 0.0 || epsilon_ > 1.0) { | ||
| std::cerr << "[WARNING] node: epsilon is over the range [0, 1]." << std::endl; | ||
| std::cerr << "The value is set as 0.0." << std::endl; | ||
| epsilon_ = 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; | ||
|
|
@@ -116,16 +199,17 @@ column 3: Node_type(int, 0: diffusive, 1: boundary), Arithmetic node to be imple | |
| column 4: Heater No | ||
| column 5: capacity | ||
| column 6: alpha | ||
| column 7: area | ||
| column 8,9,10: normal vector of surface(body frame) | ||
| column 11: initial temperature(K) | ||
| column 7: epsilon | ||
| column 8: area | ||
| column 9,10,11: normal vector of surface(body frame) | ||
| column 12: initial temperature(K) | ||
|
|
||
| First row is for Header, data begins from the second row | ||
| Ex. | ||
| Node_id,Node_label,node_type,heater_id,capacity,alpha,area,normal_v_b_x,normal_v_b_y,normal_v_b_z,initial_temperature | ||
| 0,BUS,0,1,880,0.2,0.06,1,0,0,300 | ||
| 1,SAP,0,0,100,0,0.02,0,0,1,250 | ||
| 2,SPACE,1,0,0,0,0,0,0,0,2.73 | ||
| Node_id,Node_label,node_type,heater_id,capacity,alpha,epsilon,area,normal_v_b_x,normal_v_b_y,normal_v_b_z,initial_temperature | ||
| 0,BUS,0,1,880,0.2,0.1,0.06,1,0,0,300 | ||
| 1,SAP,0,0,100,0,0.8,0.02,0,0,1,250 | ||
| 2,SPACE,1,0,0,0,0,0,0,0,0,2.73 | ||
|
|
||
| Be sure to include at least one boundary node to avoid divergence | ||
| */ | ||
|
|
@@ -134,7 +218,7 @@ Node InitNode(const std::vector<std::string>& node_str) { | |
| using std::stod; | ||
| using std::stoi; | ||
|
|
||
| size_t node_str_size_defined = 11; // Correct size of node_str | ||
| size_t node_str_size_defined = 12; // Correct size of node_str | ||
| assert(node_str.size() == node_str_size_defined); // Check if size of node_str is correct | ||
|
|
||
| size_t node_id = 0; // node number | ||
|
|
@@ -144,6 +228,7 @@ Node InitNode(const std::vector<std::string>& node_str) { | |
| double temperature_K = 0.0; // [K] | ||
| double capacity_J_K = 0.0; // [J/K] | ||
| double alpha = 0.0; // [] | ||
| double epsilon = 0.0; // [] | ||
| double area_m2 = 0.0; // [m^2] | ||
|
|
||
| // Index to read from node_str for each parameter | ||
|
|
@@ -153,16 +238,18 @@ Node InitNode(const std::vector<std::string>& node_str) { | |
| 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; | ||
| size_t index_epsilon = 6; | ||
| size_t index_area = 7; | ||
| size_t index_normal_v_b_head = 8; | ||
| size_t index_temperature = 11; | ||
|
|
||
| node_id = stoi(node_str[index_node_id]); | ||
| node_label = node_str[index_node_label]; | ||
| node_type_int = stoi(node_str[index_node_type]); | ||
| heater_id = stoi(node_str[index_heater_id]); | ||
| capacity_J_K = stod(node_str[index_capacity]); | ||
| alpha = stod(node_str[index_alpha]); | ||
| epsilon = stod(node_str[index_epsilon]); | ||
| area_m2 = stod(node_str[index_area]); | ||
| math::Vector<3> normal_v_b; | ||
| for (size_t i = 0; i < 3; i++) { | ||
|
|
@@ -185,7 +272,7 @@ Node InitNode(const std::vector<std::string>& node_str) { | |
| } else if (node_type_int == 2) { | ||
| node_type = NodeType::kArithmetic; | ||
| } | ||
| Node node(node_id, node_label, node_type, heater_id, temperature_K, capacity_J_K, alpha, area_m2, normal_v_b); | ||
| Node node(node_id, node_label, node_type, heater_id, temperature_K, capacity_J_K, alpha, epsilon, area_m2, normal_v_b); | ||
| return node; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[NITS] 変数の最後に
Kという単位をつけてください。