Merge pull request #1573 from JoePfeiffer/optimize-drag
Multiply component drag by number of instances
This commit is contained in:
commit
e3c7ccc035
@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.barrowman.FinSetCalc;
|
||||
import net.sf.openrocket.aerodynamics.barrowman.RocketComponentCalc;
|
||||
import net.sf.openrocket.rocketcomponent.position.AxialMethod;
|
||||
import net.sf.openrocket.rocketcomponent.ComponentAssembly;
|
||||
import net.sf.openrocket.rocketcomponent.ExternalComponent;
|
||||
import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
|
||||
@ -370,8 +371,9 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
||||
for(Map.Entry<RocketComponent, ArrayList<InstanceContext>> entry: imap.entrySet() ) {
|
||||
final RocketComponent c = entry.getKey();
|
||||
|
||||
if (!c.isAerodynamic())
|
||||
if (!c.isAerodynamic()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle Overriden CD for Whole Rocket
|
||||
if(c.isCDOverridden()) {
|
||||
@ -407,17 +409,15 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
||||
|
||||
}
|
||||
|
||||
// iterate across component instances
|
||||
double componentFrictionCDTotal = 0; // Total friction drag of the component
|
||||
final ArrayList<InstanceContext> contextList = entry.getValue();
|
||||
for(InstanceContext context: contextList ) {
|
||||
double componentFrictionCD = calcMap.get(c).calculateFrictionCD(conditions, componentCf, warningSet);
|
||||
|
||||
int instanceCount = entry.getValue().size();
|
||||
if (c instanceof SymmetricComponent) {
|
||||
SymmetricComponent s = (SymmetricComponent) c;
|
||||
bodyFrictionCD += componentFrictionCD;
|
||||
|
||||
final double componentMinX = context.getLocation().x;
|
||||
bodyFrictionCD += instanceCount * componentFrictionCD;
|
||||
|
||||
final double componentMinX = c.getAxialOffset(AxialMethod.ABSOLUTE);
|
||||
minX = Math.min(minX, componentMinX);
|
||||
|
||||
final double componentMaxX = componentMinX + c.getLength();
|
||||
@ -427,14 +427,11 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
||||
maxR = Math.max(maxR, componentMaxR);
|
||||
|
||||
} else {
|
||||
otherFrictionCD += componentFrictionCD;
|
||||
}
|
||||
|
||||
componentFrictionCDTotal += componentFrictionCD;
|
||||
otherFrictionCD += instanceCount * componentFrictionCD;
|
||||
}
|
||||
|
||||
if (map != null) {
|
||||
map.get(c).setFrictionCD(componentFrictionCDTotal);
|
||||
map.get(c).setFrictionCD(componentFrictionCD);
|
||||
}
|
||||
}
|
||||
|
||||
@ -594,8 +591,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
||||
private double calculatePressureCD(FlightConfiguration configuration, FlightConditions conditions,
|
||||
Map<RocketComponent, AerodynamicForces> forceMap, WarningSet warningSet) {
|
||||
|
||||
double stagnation, base, total;
|
||||
|
||||
double total, stagnation, base;
|
||||
if (calcMap == null)
|
||||
buildCalcMap(configuration);
|
||||
|
||||
@ -607,26 +603,29 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
||||
for(Map.Entry<RocketComponent, ArrayList<InstanceContext>> entry: imap.entrySet() ) {
|
||||
final RocketComponent c = entry.getKey();
|
||||
|
||||
if (!c.isAerodynamic())
|
||||
if (!c.isAerodynamic()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// iterate across component instances
|
||||
double pressureCDTotal = 0; // Total pressure drag for this component
|
||||
final ArrayList<InstanceContext> contextList = entry.getValue();
|
||||
for(InstanceContext context: contextList ) {
|
||||
if(c.isCDOverridden()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Pressure drag
|
||||
double pressureCD = calcMap.get(c).calculatePressureCD(conditions, stagnation, base,
|
||||
int instanceCount = entry.getValue().size();
|
||||
|
||||
// Pressure drag of this component
|
||||
double cd = calcMap.get(c).calculatePressureCD(conditions, stagnation, base,
|
||||
warningSet);
|
||||
pressureCDTotal += pressureCD;
|
||||
|
||||
// Total pressure drag of the rocket
|
||||
total += pressureCD;
|
||||
if (forceMap != null) {
|
||||
forceMap.get(c).setPressureCD(cd);
|
||||
}
|
||||
|
||||
if(c.isCDOverridden())
|
||||
continue;
|
||||
total += cd * instanceCount;
|
||||
|
||||
// Stagnation drag
|
||||
// Stagnation drag caused by difference in radius between this component
|
||||
// and previous component (increasing radii. Decreasing radii handled in
|
||||
// base drag calculation
|
||||
if (c instanceof SymmetricComponent) {
|
||||
SymmetricComponent s = (SymmetricComponent) c;
|
||||
|
||||
@ -637,15 +636,13 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
||||
|
||||
if (radius < s.getForeRadius()) {
|
||||
double area = Math.PI * (pow2(s.getForeRadius()) - pow2(radius));
|
||||
pressureCD = stagnation * area / conditions.getRefArea();
|
||||
pressureCDTotal += pressureCD;
|
||||
total += pressureCD;
|
||||
}
|
||||
}
|
||||
}
|
||||
cd = stagnation * area / conditions.getRefArea();
|
||||
total += instanceCount * cd;
|
||||
|
||||
if (forceMap != null) {
|
||||
forceMap.get(c).setPressureCD(pressureCDTotal);
|
||||
forceMap.get(c).setPressureCD(forceMap.get(c).getPressureCD() + cd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -677,16 +674,16 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
||||
for(Map.Entry<RocketComponent, ArrayList<InstanceContext>> entry: imap.entrySet() ) {
|
||||
final RocketComponent c = entry.getKey();
|
||||
|
||||
if (!(c instanceof SymmetricComponent))
|
||||
if (!(c instanceof SymmetricComponent)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SymmetricComponent s = (SymmetricComponent) c;
|
||||
|
||||
// iterate across component instances
|
||||
final ArrayList<InstanceContext> contextList = entry.getValue();
|
||||
for(InstanceContext context: contextList ) {
|
||||
int instanceCount = entry.getValue().size();
|
||||
|
||||
if(c.isCDOverridden()) {
|
||||
total += c.getOverrideCD();
|
||||
total += instanceCount * c.getOverrideCD();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -700,10 +697,10 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
||||
|
||||
if (radius > s.getForeRadius()) {
|
||||
double area = Math.PI * (pow2(radius) - pow2(s.getForeRadius()));
|
||||
double baseCD = base * area / conditions.getRefArea();
|
||||
total += baseCD;
|
||||
double cd = base * area / conditions.getRefArea();
|
||||
total += instanceCount * cd;
|
||||
if ((map != null) && (prevComponent != null)) {
|
||||
map.get(prevComponent).setBaseCD(baseCD);
|
||||
map.get(prevComponent).setBaseCD(cd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -713,11 +710,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 baseCD = base * area / conditions.getRefArea();
|
||||
total += baseCD;
|
||||
double cd = base * area / conditions.getRefArea();
|
||||
total += instanceCount * cd;
|
||||
if (map != null) {
|
||||
map.get(s).setBaseCD(baseCD);
|
||||
}
|
||||
map.get(s).setBaseCD(cd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -889,8 +885,9 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
||||
calcMap = new HashMap<>();
|
||||
|
||||
for (RocketComponent comp: configuration.getAllComponents()) {
|
||||
if (!comp.isAerodynamic())
|
||||
if (!comp.isAerodynamic()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RocketComponentCalc calcObj = (RocketComponentCalc) Reflection.construct(BARROWMAN_PACKAGE, comp, BARROWMAN_SUFFIX, comp);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user