Avoid division by 0 by just setting railbutton pressure CD when moving very slow

Note CD really doesn't matter when velocity is 0, since there's no drag force anyway.
This commit is contained in:
JoePfeiffer 2023-03-18 10:47:50 -06:00
parent 769ac69300
commit 206603e865

View File

@ -58,8 +58,10 @@ public class RailButtonCalc extends RocketComponentCalc {
final double notchArea = (button.getOuterDiameter() - button.getInnerDiameter()) * button.getInnerHeight(); final double notchArea = (button.getOuterDiameter() - button.getInnerDiameter()) * button.getInnerHeight();
final double refArea = outerArea - notchArea; final double refArea = outerArea - notchArea;
// accumulate Cd contribution from each rail button // accumulate Cd contribution from each rail button. If velocity is 0 just set CDmul to a value previously
// competed for velocity MathUtil.EPSILON and skip the loop to avoid division by 0
double CDmul = 0.0; double CDmul = 0.0;
if (conditions.getMach() > MathUtil.EPSILON) {
for (int i = 0; i < button.getInstanceCount(); i++) { for (int i = 0; i < button.getInstanceCount(); i++) {
// compute boundary layer height at button location. I can't find a good reference for the // compute boundary layer height at button location. I can't find a good reference for the
@ -95,12 +97,18 @@ public class RailButtonCalc extends RocketComponentCalc {
// add to CDmul // add to CDmul
CDmul += cd; CDmul += cd;
} }
// since we'll be multiplying by the instance count up in BarrowmanCalculator, // since we'll be multiplying by the instance count up in BarrowmanCalculator,
// we want to return the mean CD instead of the total // we want to return the mean CD instead of the total
CDmul /= button.getInstanceCount(); CDmul /= button.getInstanceCount();
} else {
// value at velocity of MathUtil.EPSILON
CDmul = 8.786395072609939E-4;
}
return CDmul * stagnationCD * refArea / conditions.getRefArea(); return CDmul * stagnationCD * refArea / conditions.getRefArea();
} }
} }