From 765d1df28381dad2eec55c9e516518cabc2a9ce5 Mon Sep 17 00:00:00 2001 From: minsoo Date: Mon, 21 Sep 2026 15:01:57 -0500 Subject: [PATCH 1/2] Add component consumption logic from ramtares_main --- models/fhw/effectors/rcs_generic/include/rcs_jet.hh | 10 ++++++++++ models/fhw/effectors/rcs_generic/src/rcs_group.cc | 10 ++++++++-- models/fhw/effectors/rcs_generic/src/rcs_jet.cc | 9 +++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/models/fhw/effectors/rcs_generic/include/rcs_jet.hh b/models/fhw/effectors/rcs_generic/include/rcs_jet.hh index b2fc0a91..93f2de36 100644 --- a/models/fhw/effectors/rcs_generic/include/rcs_jet.hh +++ b/models/fhw/effectors/rcs_generic/include/rcs_jet.hh @@ -48,6 +48,13 @@ class RcsJet { std::vector component_consumption;/* (kg) Work space for prop consumption during delta_time_on maximum for each propellant component */ + std::vector sum_component_consumption;/* (kg) + Accumulated values of component_consumption, provides pre-component + consumption over the duration of the simulation.*/ + double sum_consumption; /* (kg) + accumulated values of component_consumption across all components. + Provides total consumption by the jet over the duration of the + simulation.*/ double force_hat[3]{}; /* (--) Unit-vector force direction. */ @@ -227,6 +234,9 @@ class RcsJet { void scale_self_impingement(); void set_isp( double isp_); double get_isp() const {return isp;} + + const double & get_sum_consumption() const {return sum_consumption;} + protected: void compute_component_flow_rates(); void blow_down(); diff --git a/models/fhw/effectors/rcs_generic/src/rcs_group.cc b/models/fhw/effectors/rcs_generic/src/rcs_group.cc index 89bae1f8..a85202bd 100644 --- a/models/fhw/effectors/rcs_generic/src/rcs_group.cc +++ b/models/fhw/effectors/rcs_generic/src/rcs_group.cc @@ -58,8 +58,14 @@ RcsJetGroup::initialize( // buffer size is the number of full time-steps necessary before a command // will be seen - buffer_on_size = static_cast(total_on_delay / time_step); - buffer_off_size = static_cast(total_off_delay / time_step); + buffer_on_size = static_cast( + MathUtils::divide_protected( total_on_delay, + time_step, + 0.0, true)); + buffer_off_size = static_cast( + MathUtils::divide_protected( total_off_delay, + time_step, + 0.0, true)); /* delay time = remainder of last time_step before jet is turned on or off */ delay_time_on = total_on_delay - buffer_on_size * time_step; diff --git a/models/fhw/effectors/rcs_generic/src/rcs_jet.cc b/models/fhw/effectors/rcs_generic/src/rcs_jet.cc index 0abe0e60..5499f967 100644 --- a/models/fhw/effectors/rcs_generic/src/rcs_jet.cc +++ b/models/fhw/effectors/rcs_generic/src/rcs_jet.cc @@ -37,6 +37,9 @@ RcsJet::RcsJet( time_step( system.time_step), component_flow_rate( prop_pod.components.size()), component_consumption( prop_pod.components.size()) + sum_component_consumption( prop_pod.components.size()), + sum_consumption(0.0), + { // Start the command list with an "Off": commands.push_back(false); @@ -853,6 +856,12 @@ RcsJet::compute_prop_consumption() } } } + + // Accumulate component consumption: + for (unsigned int ii = 0; ii < component_consumption.size(); ++ii) { + sum_component_consumption[ii] += component_consumption[ii]; + sum_consumption += component_consumption[ii]; + } // Add this jet's prop consumption (per component) to the pod prop_pod.increment_mass_consumption( component_consumption); From 094eaeb307895c1d52c6dfad7d6efd666b079058 Mon Sep 17 00:00:00 2001 From: Minsoo Kang Date: Thu, 1 Oct 2026 14:27:21 -0500 Subject: [PATCH 2/2] Fix syntax error and converted sum_consumption to a member initializer from initializer list --- models/fhw/effectors/rcs_generic/include/rcs_jet.hh | 2 +- models/fhw/effectors/rcs_generic/src/rcs_jet.cc | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/models/fhw/effectors/rcs_generic/include/rcs_jet.hh b/models/fhw/effectors/rcs_generic/include/rcs_jet.hh index 93f2de36..f75dc57e 100644 --- a/models/fhw/effectors/rcs_generic/include/rcs_jet.hh +++ b/models/fhw/effectors/rcs_generic/include/rcs_jet.hh @@ -51,7 +51,7 @@ class RcsJet { std::vector sum_component_consumption;/* (kg) Accumulated values of component_consumption, provides pre-component consumption over the duration of the simulation.*/ - double sum_consumption; /* (kg) + double sum_consumption{0.0}; /* (kg) accumulated values of component_consumption across all components. Provides total consumption by the jet over the duration of the simulation.*/ diff --git a/models/fhw/effectors/rcs_generic/src/rcs_jet.cc b/models/fhw/effectors/rcs_generic/src/rcs_jet.cc index 5499f967..8079aa5f 100644 --- a/models/fhw/effectors/rcs_generic/src/rcs_jet.cc +++ b/models/fhw/effectors/rcs_generic/src/rcs_jet.cc @@ -36,9 +36,8 @@ RcsJet::RcsJet( group(group_), time_step( system.time_step), component_flow_rate( prop_pod.components.size()), - component_consumption( prop_pod.components.size()) - sum_component_consumption( prop_pod.components.size()), - sum_consumption(0.0), + component_consumption( prop_pod.components.size()), + sum_component_consumption( prop_pod.components.size()) { // Start the command list with an "Off":