% ============================================================================
% UpdateMass.m
% Author: Brent Dingle, Ph.D.
% Creation Date: 2020
%
% rock.thrust must be set correctly prior to calling this functon
% ============================================================================
function mass = UpdateMass(sim, rock)
burnRate = rock.fuelRatePerN * rock.thrust; % (kg/s) = (kg/s)/N * N
massBurned = burnRate * sim.dt; % kg = kg/s * s
% TODO: could flag an error if massBurned > rock.fuelMass
% Assumed: because dt is small this error should be equally small
newMass = rock.fuelMass - massBurned;
if (newMass < 0.0)
newMass = 0;
endif
mass = newMass;
endfunction