diff --git a/models/fhw/effectors/rcs_generic/include/rcs_jet.hh b/models/fhw/effectors/rcs_generic/include/rcs_jet.hh index b2fc0a91..f75dc57e 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{0.0}; /* (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..8079aa5f 100644 --- a/models/fhw/effectors/rcs_generic/src/rcs_jet.cc +++ b/models/fhw/effectors/rcs_generic/src/rcs_jet.cc @@ -36,7 +36,9 @@ RcsJet::RcsJet( group(group_), time_step( system.time_step), component_flow_rate( prop_pod.components.size()), - component_consumption( prop_pod.components.size()) + component_consumption( prop_pod.components.size()), + sum_component_consumption( prop_pod.components.size()) + { // Start the command list with an "Off": commands.push_back(false); @@ -853,6 +855,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);