Corrected calculateBaseDrag to iterate through all instances of components
Corrected getPreviousSymmetricComponent and getNextSymmetricComponent to stop searching and return null when a PodSet is encountered in search (so it only returns the previous/next component if it's a child of the same pod).
This commit is contained in:
parent
dd3bda8d7e
commit
5e5ce3d06e
@ -571,11 +571,9 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private double calculateBaseDrag(FlightConfiguration configuration, FlightConditions conditions,
|
private double calculateBaseDrag(FlightConfiguration configuration, FlightConditions conditions,
|
||||||
Map<RocketComponent, AerodynamicForces> map, WarningSet warnings) {
|
Map<RocketComponent, AerodynamicForces> map, WarningSet warnings) {
|
||||||
|
|
||||||
double base, total;
|
double base, total;
|
||||||
double radius = 0;
|
|
||||||
RocketComponent prevComponent = null;
|
|
||||||
|
|
||||||
if (calcMap == null)
|
if (calcMap == null)
|
||||||
buildCalcMap(configuration);
|
buildCalcMap(configuration);
|
||||||
@ -583,36 +581,51 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
|||||||
base = calculateBaseCD(conditions.getMach());
|
base = calculateBaseCD(conditions.getMach());
|
||||||
total = 0;
|
total = 0;
|
||||||
|
|
||||||
for (RocketComponent c : configuration.getActiveComponents()) {
|
final InstanceMap imap = configuration.getActiveInstances();
|
||||||
|
for(Map.Entry<RocketComponent, ArrayList<InstanceContext>> entry: imap.entrySet() ) {
|
||||||
|
final RocketComponent c = entry.getKey();
|
||||||
|
|
||||||
if (!(c instanceof SymmetricComponent))
|
if (!(c instanceof SymmetricComponent))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SymmetricComponent s = (SymmetricComponent) c;
|
SymmetricComponent s = (SymmetricComponent) c;
|
||||||
|
|
||||||
if(c.isCDOverridden()) {
|
// iterate across component instances
|
||||||
total += c.getOverrideCD();
|
final ArrayList<InstanceContext> contextList = entry.getValue();
|
||||||
continue;
|
for(InstanceContext context: contextList ) {
|
||||||
}
|
if(c.isCDOverridden()) {
|
||||||
|
total += c.getOverrideCD();
|
||||||
if (radius > s.getForeRadius()) {
|
continue;
|
||||||
double area = Math.PI * (pow2(radius) - pow2(s.getForeRadius()));
|
|
||||||
double cd = base * area / conditions.getRefArea();
|
|
||||||
total += cd;
|
|
||||||
if (map != null) {
|
|
||||||
map.get(prevComponent).setBaseCD(cd);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
radius = s.getAftRadius();
|
// if aft radius of previous component is greater than my forward radius, set
|
||||||
prevComponent = c;
|
// its aft CD
|
||||||
}
|
double radius = 0;
|
||||||
|
final SymmetricComponent prevComponent = s.getPreviousSymmetricComponent();
|
||||||
|
if (prevComponent != null) {
|
||||||
|
radius = prevComponent.getAftRadius();
|
||||||
|
}
|
||||||
|
|
||||||
if (radius > 0) {
|
if (radius > s.getForeRadius()) {
|
||||||
double area = Math.PI * pow2(radius);
|
double area = Math.PI * (pow2(radius) - pow2(s.getForeRadius()));
|
||||||
double cd = base * area / conditions.getRefArea();
|
double cd = base * area / conditions.getRefArea();
|
||||||
total += cd;
|
total += cd;
|
||||||
if (map != null) {
|
if ((map != null) && (prevComponent != null)) {
|
||||||
map.get(prevComponent).setBaseCD(cd);
|
map.get(prevComponent).setBaseCD(cd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if I'm the last componenet, set my base CD
|
||||||
|
// note I can't depend on the iterator serving up components in order,
|
||||||
|
// so I can't just do this after the last iteration.
|
||||||
|
if (s.getNextSymmetricComponent() == null) {
|
||||||
|
double area = Math.PI * pow2(s.getAftRadius());
|
||||||
|
double cd = base * area / conditions.getRefArea();
|
||||||
|
total += cd;
|
||||||
|
if (map != null) {
|
||||||
|
map.get(s).setBaseCD(cd);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.sf.openrocket.preset.ComponentPreset;
|
import net.sf.openrocket.preset.ComponentPreset;
|
||||||
|
import net.sf.openrocket.rocketcomponent.PodSet;
|
||||||
import net.sf.openrocket.rocketcomponent.position.AxialMethod;
|
import net.sf.openrocket.rocketcomponent.position.AxialMethod;
|
||||||
import net.sf.openrocket.util.Coordinate;
|
import net.sf.openrocket.util.Coordinate;
|
||||||
import net.sf.openrocket.util.MathUtil;
|
import net.sf.openrocket.util.MathUtil;
|
||||||
@ -561,34 +562,37 @@ public abstract class SymmetricComponent extends BodyComponent implements Radial
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the previous symmetric component, or null if none exists.
|
* Return the previous symmetric component, or null if none exists.
|
||||||
* NOTE: This method currently assumes that there are no external
|
|
||||||
* "pods".
|
|
||||||
*
|
*
|
||||||
* @return the previous SymmetricComponent, or null.
|
* @return the previous SymmetricComponent, or null.
|
||||||
*/
|
*/
|
||||||
public 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 PodSet) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (c instanceof SymmetricComponent) {
|
if (c instanceof SymmetricComponent) {
|
||||||
return (SymmetricComponent) c;
|
return (SymmetricComponent) c;
|
||||||
}
|
}
|
||||||
if (!(c instanceof AxialStage) &&
|
if (!(c instanceof AxialStage) &&
|
||||||
(c.axialMethod == AxialMethod.AFTER))
|
(c.axialMethod == AxialMethod.AFTER)) {
|
||||||
return null; // Bad component type as "parent"
|
return null; // Bad component type as "parent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the next symmetric component, or null if none exists.
|
* Return the next symmetric component, or null if none exists.
|
||||||
* NOTE: This method currently assumes that there are no external
|
|
||||||
* "pods".
|
|
||||||
*
|
*
|
||||||
* @return the next SymmetricComponent, or null.
|
* @return the next SymmetricComponent, or null.
|
||||||
*/
|
*/
|
||||||
protected final SymmetricComponent getNextSymmetricComponent() {
|
public final SymmetricComponent getNextSymmetricComponent() {
|
||||||
RocketComponent c;
|
RocketComponent c;
|
||||||
for (c = this.getNextComponent(); c != null; c = c.getNextComponent()) {
|
for (c = this.getNextComponent(); c != null; c = c.getNextComponent()) {
|
||||||
|
if (c instanceof PodSet) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (c instanceof SymmetricComponent) {
|
if (c instanceof SymmetricComponent) {
|
||||||
return (SymmetricComponent) c;
|
return (SymmetricComponent) c;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user