Corrected calculatePressureDrag() to iterate through all instances.

Note this required modifying the function to explicitly get the radius
of the forward symmetric component rather than simply iterating
and assuming components would appear in order (as was the case with
iterating through getActiveComponents()).
The getPreviousSymmetricComponent() method contains a warning that it
doesn't account for external pods, so this will probably need to be
revisited and that method modified.
This commit is contained in:
JoePfeiffer 2020-03-20 14:53:39 -06:00
parent 05185ff3d6
commit dd3bda8d7e
2 changed files with 10 additions and 8 deletions

View File

@ -506,7 +506,6 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
Map<RocketComponent, AerodynamicForces> map, WarningSet warnings) { Map<RocketComponent, AerodynamicForces> map, WarningSet warnings) {
double stagnation, base, total; double stagnation, base, total;
double radius = 0;
if (calcMap == null) if (calcMap == null)
buildCalcMap(configuration); buildCalcMap(configuration);
@ -524,33 +523,36 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
// iterate across component instances // iterate across component instances
final ArrayList<InstanceContext> contextList = entry.getValue(); final ArrayList<InstanceContext> contextList = entry.getValue();
for(InstanceContext context: contextList ) { for(InstanceContext context: contextList ) {
// Pressure fore drag // Pressure fore drag
double cd = calcMap.get(c).calculatePressureDragForce(conditions, stagnation, base, double cd = calcMap.get(c).calculatePressureDragForce(conditions, stagnation, base,
warnings); warnings);
total += cd; total += cd;
if (map != null) { if (map != null) {
map.get(c).setPressureCD(cd); map.get(c).setPressureCD(cd);
} }
if(c.isCDOverridden()) continue; if(c.isCDOverridden()) continue;
// Stagnation drag // Stagnation drag
if (c instanceof SymmetricComponent) { if (c instanceof SymmetricComponent) {
SymmetricComponent s = (SymmetricComponent) c; SymmetricComponent s = (SymmetricComponent) c;
double radius = 0;
final SymmetricComponent prevComponent = s.getPreviousSymmetricComponent();
if (prevComponent != null)
radius = prevComponent.getAftRadius();
if (radius < s.getForeRadius()) { if (radius < s.getForeRadius()) {
double area = Math.PI * (pow2(s.getForeRadius()) - pow2(radius)); double area = Math.PI * (pow2(s.getForeRadius()) - pow2(radius));
cd = stagnation * area / conditions.getRefArea(); cd = stagnation * area / conditions.getRefArea();
total += cd; total += cd;
if (map != null) { if (map != null) {
map.get(c).setPressureCD(map.get(c).getPressureCD() + cd); map.get(c).setPressureCD(map.get(c).getPressureCD() + cd);
} }
} }
radius = s.getAftRadius();
} }
} }
} }
@ -558,7 +560,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
return total; return total;
} }
/** /**
* Calculation of drag coefficient due to base * Calculation of drag coefficient due to base
* *

View File

@ -566,7 +566,7 @@ public abstract class SymmetricComponent extends BodyComponent implements Radial
* *
* @return the previous SymmetricComponent, or null. * @return the previous SymmetricComponent, or null.
*/ */
protected final SymmetricComponent getPreviousSymmetricComponent() { public final SymmetricComponent getPreviousSymmetricComponent() {
RocketComponent c; RocketComponent c;
for (c = this.getPreviousComponent(); c != null; c = c.getPreviousComponent()) { for (c = this.getPreviousComponent(); c != null; c = c.getPreviousComponent()) {
if (c instanceof SymmetricComponent) { if (c instanceof SymmetricComponent) {