本文整理汇总了C++中GmatBase::SetRealParameter方法的典型用法代码示例。如果您正苦于以下问题:C++ GmatBase::SetRealParameter方法的具体用法?C++ GmatBase::SetRealParameter怎么用?C++ GmatBase::SetRealParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GmatBase
的用法示例。
在下文中一共展示了GmatBase::SetRealParameter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DecrementMass
//------------------------------------------------------------------------------
// 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
}
示例2: DecrementMass
//------------------------------------------------------------------------------
// 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
}