From dd3bda8d7e3a7084a649c2e2b68e8a94ab4663ec Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Fri, 20 Mar 2020 14:53:39 -0600 Subject: [PATCH] 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. --- .../aerodynamics/BarrowmanCalculator.java | 16 +++++++++------- .../rocketcomponent/SymmetricComponent.java | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java index 6cbf1ca04..880db8151 100644 --- a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java +++ b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java @@ -506,7 +506,6 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { Map map, WarningSet warnings) { double stagnation, base, total; - double radius = 0; if (calcMap == null) buildCalcMap(configuration); @@ -524,33 +523,36 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { // iterate across component instances final ArrayList contextList = entry.getValue(); for(InstanceContext context: contextList ) { - + // Pressure fore drag double cd = calcMap.get(c).calculatePressureDragForce(conditions, stagnation, base, warnings); total += cd; - + if (map != null) { map.get(c).setPressureCD(cd); } if(c.isCDOverridden()) continue; - // Stagnation drag if (c instanceof SymmetricComponent) { SymmetricComponent s = (SymmetricComponent) c; + + double radius = 0; + final SymmetricComponent prevComponent = s.getPreviousSymmetricComponent(); + if (prevComponent != null) + radius = prevComponent.getAftRadius(); if (radius < s.getForeRadius()) { double area = Math.PI * (pow2(s.getForeRadius()) - pow2(radius)); cd = stagnation * area / conditions.getRefArea(); total += cd; + if (map != null) { map.get(c).setPressureCD(map.get(c).getPressureCD() + cd); } } - - radius = s.getAftRadius(); } } } @@ -558,7 +560,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { return total; } - + /** * Calculation of drag coefficient due to base * diff --git a/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java b/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java index a530bfe94..35957c459 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java @@ -566,7 +566,7 @@ public abstract class SymmetricComponent extends BodyComponent implements Radial * * @return the previous SymmetricComponent, or null. */ - protected final SymmetricComponent getPreviousSymmetricComponent() { + public final SymmetricComponent getPreviousSymmetricComponent() { RocketComponent c; for (c = this.getPreviousComponent(); c != null; c = c.getPreviousComponent()) { if (c instanceof SymmetricComponent) {