From 5dee382961bb572519debf7b5d01561c7f09c64e Mon Sep 17 00:00:00 2001 From: SiboVG Date: Thu, 30 Jun 2022 14:45:53 +0200 Subject: [PATCH] [#1440] Add all context drags to component drag --- .../aerodynamics/BarrowmanCalculator.java | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java index b1d2f3bfc..4453dd60e 100644 --- a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java +++ b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java @@ -390,6 +390,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { } // iterate across component instances + double componentFrictionCDTotal = 0; // Total friction drag of the component final ArrayList contextList = entry.getValue(); for(InstanceContext context: contextList ) { double componentFrictionCD = calcMap.get(c).calculateFrictionCD(conditions, componentCf, warningSet); @@ -411,9 +412,11 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { otherFrictionCD += componentFrictionCD; } - if (map != null) { - map.get(c).setFrictionCD(componentFrictionCD); - } + componentFrictionCDTotal += componentFrictionCD; + } + + if (map != null) { + map.get(c).setFrictionCD(componentFrictionCDTotal); } } @@ -590,17 +593,17 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { continue; // iterate across component instances + double pressureCDTotal = 0; // Total pressure drag for this component final ArrayList contextList = entry.getValue(); for(InstanceContext context: contextList ) { // Pressure drag - double cd = calcMap.get(c).calculatePressureCD(conditions, stagnation, base, + double pressureCD = calcMap.get(c).calculatePressureCD(conditions, stagnation, base, warningSet); - total += cd; - - if (forceMap != null) { - forceMap.get(c).setPressureCD(cd); - } + pressureCDTotal += pressureCD; + + // Total pressure drag of the rocket + total += pressureCD; if(c.isCDOverridden()) continue; @@ -616,15 +619,16 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { if (radius < s.getForeRadius()) { double area = Math.PI * (pow2(s.getForeRadius()) - pow2(radius)); - cd = stagnation * area / conditions.getRefArea(); - total += cd; - - if (forceMap != null) { - forceMap.get(c).setPressureCD(forceMap.get(c).getPressureCD() + cd); - } + pressureCD = stagnation * area / conditions.getRefArea(); + pressureCDTotal += pressureCD; + total += pressureCD; } } } + + if (forceMap != null) { + forceMap.get(c).setPressureCD(pressureCDTotal); + } } return total; @@ -678,10 +682,10 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { if (radius > s.getForeRadius()) { double area = Math.PI * (pow2(radius) - pow2(s.getForeRadius())); - double cd = base * area / conditions.getRefArea(); - total += cd; + double baseCD = base * area / conditions.getRefArea(); + total += baseCD; if ((map != null) && (prevComponent != null)) { - map.get(prevComponent).setBaseCD(cd); + map.get(prevComponent).setBaseCD(baseCD); } } @@ -691,10 +695,10 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { final SymmetricComponent n = s.getNextSymmetricComponent(); if ((n == null) || !configuration.isStageActive(n.getStageNumber())) { double area = Math.PI * pow2(s.getAftRadius()); - double cd = base * area / conditions.getRefArea(); - total += cd; + double baseCD = base * area / conditions.getRefArea(); + total += baseCD; if (map != null) { - map.get(s).setBaseCD(cd); + map.get(s).setBaseCD(baseCD); } } }