//------------------------------------------------------------------------------ // void DecrementMass() //------------------------------------------------------------------------------ void ImpulsiveBurn::DecrementMass() { #ifdef DEBUG_IMPBURN_DECMASS MessageInterface::ShowMessage (wxT("ImpulsiveBurn::DecrementMass() <%p>'%s' entered. There are %d tank(s)\n"), this, instanceName.c_str(), tankMap.size()); #endif totalTankMass = spacecraft->GetRealParameter(wxT("TotalMass")); #ifdef DEBUG_IMPBURN_DECMASS MessageInterface::ShowMessage (wxT(" Now decrementing mass\n before maneuver totalTankMass = %f\n"), totalTankMass); #endif Real dv = sqrt( deltaV[0]*deltaV[0] + deltaV[1]*deltaV[1] + deltaV[2]*deltaV[2]); deltaTankMass = totalTankMass * (exp(-dv * 1000/(isp * gravityAccel)) - 1.0); #ifdef DEBUG_IMPBURN_DECMASS MessageInterface::ShowMessage (wxT(" after maneuver deltaTankMass = %f\n"), deltaTankMass); #endif totalTankMass = totalTankMass + deltaTankMass; #ifdef DEBUG_IMPBURN_DECMASS MessageInterface::ShowMessage (wxT(" after maneuver totalTankMass = %f\n"), totalTankMass); #endif // Update tank mass if (!tankMap.empty()) { for (ObjectMap::iterator tankPos = tankMap.begin(); tankPos != tankMap.end(); ++tankPos) { GmatBase *currTank = tankPos->second; #ifdef DEBUG_IMPBURN_DECMASS MessageInterface::ShowMessage (wxT(" Decrementing tank mass for <%p>'%s'\n"), currTank, (tankPos->first).c_str()); #endif Integer paramID = currTank->GetParameterID(wxT("FuelMass")); Real oldTankMass = currTank->GetRealParameter(paramID); Real currTankMass = oldTankMass + deltaTankMass; #ifdef DEBUG_IMPBURN_DECMASS MessageInterface::ShowMessage (wxT(" it was %f, it is now %f\n"), oldTankMass, currTankMass); #endif //@todo What should we do if decremented tank mass is below zero? currTank->SetRealParameter(paramID, currTankMass); } } #ifdef DEBUG_IMPBURN_DECMASS MessageInterface::ShowMessage (wxT("ImpulsiveBurn::DecrementMass() <%p>'%s' returning\n"), this, GetName().c_str()); #endif }
//------------------------------------------------------------------------------ // void DecrementMass() //------------------------------------------------------------------------------ void ImpulsiveBurn::DecrementMass(bool backwards) { #ifdef DEBUG_IMPBURN_DECMASS MessageInterface::ShowMessage ("ImpulsiveBurn::DecrementMass() <%p>'%s' entered. There are %d tank(s)\n", this, instanceName.c_str(), tankMap.size()); #endif totalTankMass = spacecraft->GetRealParameter("TotalMass"); #ifdef DEBUG_IMPBURN_DECMASS MessageInterface::ShowMessage (" Now decrementing mass\n before maneuver totalTankMass = %f\n", totalTankMass); #endif Real dv = sqrt( deltaV[0]*deltaV[0] + deltaV[1]*deltaV[1] + deltaV[2]*deltaV[2]); if (!backwards) deltaTankMass = totalTankMass * (exp(-dv * 1000/(isp * gravityAccel)) - 1.0); else deltaTankMass = totalTankMass * (exp(dv * 1000/(isp * gravityAccel)) - 1.0); #ifdef DEBUG_IMPBURN_DECMASS MessageInterface::ShowMessage (" after maneuver deltaTankMass = %f\n", deltaTankMass); #endif totalTankMass = totalTankMass + deltaTankMass; #ifdef DEBUG_IMPBURN_DECMASS MessageInterface::ShowMessage (" after maneuver totalTankMass = %f\n", totalTankMass); #endif // Update tank mass if (!tankMap.empty()) { if (tankMap.size() > 1) throw BurnException("The ImpulsiveBorn object " + instanceName + " is configured to draw mass from multiple tanks, but only one " "tank is supported in the current implementation."); // This code is set up to draw from multiple tanks, but the amount drawn // is not calculated to draw proportionally. Instead, it reduces each // tank by deltaTankMass. We need to check this code before enabling // mass reduction from multiple tanks in a single impulsive burn. for (ObjectMap::iterator tankPos = tankMap.begin(); tankPos != tankMap.end(); ++tankPos) { GmatBase *currTank = tankPos->second; #ifdef DEBUG_IMPBURN_DECMASS MessageInterface::ShowMessage (" Decrementing tank mass for <%p>'%s'\n", currTank, (tankPos->first).c_str()); #endif Integer paramID = currTank->GetParameterID("FuelMass"); Real oldTankMass = currTank->GetRealParameter(paramID); Real currTankMass = oldTankMass + deltaTankMass; #ifdef DEBUG_IMPBURN_DECMASS MessageInterface::ShowMessage (" it was %f, it is now %f\n", oldTankMass, currTankMass); #endif //@todo What should we do if decremented tank mass is below zero? currTank->SetRealParameter(paramID, currTankMass); } } else throw BurnException("Impulsive Burn " + instanceName + " is set to decrement mass from a tank named " + tankNames[0] + ", but the Spacecraft " + spacecraft->GetName() + " does not have the selected fuel tank."); #ifdef DEBUG_IMPBURN_DECMASS MessageInterface::ShowMessage ("ImpulsiveBurn::DecrementMass() <%p>'%s' returning\n", this, GetName().c_str()); #endif }