Add component assemblies to BarrowmanCalculator:calculateForceAnalysis

Display component assemblies in ComponentAnalysisDialog
Use "Total" instead of actual component name for Rocket in Stability tab, for consistency with Drag characteristics tab
Use user-specified units instead of internal units for Stability display.
This commit is contained in:
JoePfeiffer 2022-11-03 09:04:36 -06:00
parent d3e872478d
commit 30a49c2f6f
3 changed files with 47 additions and 14 deletions

View File

@ -140,12 +140,11 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
WarningSet warnings) WarningSet warnings)
{ {
// forces for this component, and all forces below it, in the rocket-tree // forces for this component, and all forces below it, in the rocket-tree
// => regardless `if(comp isinstance ComponentAssembly)`, or not.
AerodynamicForces aggregateForces = new AerodynamicForces().zero(); AerodynamicForces aggregateForces = new AerodynamicForces().zero();
aggregateForces.setComponent(comp); aggregateForces.setComponent(comp);
// forces for this component, _only_ // forces for this component, _only_
if(comp.isAerodynamic()) { if(comp.isAerodynamic() || comp instanceof ComponentAssembly) {
RocketComponentCalc calcObj = calcMap.get(comp); RocketComponentCalc calcObj = calcMap.get(comp);
if (null == calcObj) { if (null == calcObj) {
throw new NullPointerException("Could not find a CalculationObject for aerodynamic Component!: " + comp.getComponentName()); throw new NullPointerException("Could not find a CalculationObject for aerodynamic Component!: " + comp.getComponentName());
@ -163,6 +162,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
if (child instanceof AxialStage && !configuration.isStageActive(child.getStageNumber())) { if (child instanceof AxialStage && !configuration.isStageActive(child.getStageNumber())) {
continue; continue;
} }
// forces particular to each component // forces particular to each component
AerodynamicForces childForces = calculateForceAnalysis(configuration, conds, child, instances, eachForces, assemblyForces, warnings); AerodynamicForces childForces = calculateForceAnalysis(configuration, conds, child, instances, eachForces, assemblyForces, warnings);
@ -173,7 +173,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
assemblyForces.put(comp, aggregateForces); assemblyForces.put(comp, aggregateForces);
return eachForces.get(comp); return assemblyForces.get(comp);
} }
@Override @Override
@ -944,7 +944,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
calcMap = new HashMap<>(); calcMap = new HashMap<>();
for (RocketComponent comp: configuration.getAllComponents()) { for (RocketComponent comp: configuration.getAllComponents()) {
if (!comp.isAerodynamic()) { if (!comp.isAerodynamic() && !(comp instanceof ComponentAssembly)) {
continue; continue;
} }

View File

@ -0,0 +1,37 @@
package net.sf.openrocket.aerodynamics.barrowman;
import net.sf.openrocket.aerodynamics.AerodynamicForces;
import net.sf.openrocket.aerodynamics.FlightConditions;
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.util.Transformation;
/*
* Aerodynamic properties of a component assembly. Since an "assembly"
* has no impact except as a summation of its subparts, just returns 0
*
*/
public class ComponentAssemblyCalc extends RocketComponentCalc {
public ComponentAssemblyCalc(RocketComponent c) {
super(c);
}
@Override
public void calculateNonaxialForces(FlightConditions conditions, Transformation transform,
AerodynamicForces forces, WarningSet warnings) {
// empty
}
@Override
public double calculateFrictionCD(FlightConditions conditions, double componentCf, WarningSet warnings) {
return 0;
}
@Override
public double calculatePressureCD(FlightConditions conditions,
double stagnationCD, double baseCD, WarningSet warnings) {
return 0;
}
}

View File

@ -199,6 +199,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
@Override @Override
public Object getValueAt(int row) { public Object getValueAt(int row) {
Object c = stabData.get(row).name; Object c = stabData.get(row).name;
return c.toString(); return c.toString();
} }
@ -237,7 +238,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
@Override @Override
public Object getValueAt(int row) { public Object getValueAt(int row) {
return NOUNIT.toString(stabData.get(row).cpx); return unit.toString(stabData.get(row).cpx);
} }
}, },
new Column("<html>C<sub>N<sub>" + ALPHA + "</sub></sub>") { new Column("<html>C<sub>N<sub>" + ALPHA + "</sub></sub>") {
@ -541,22 +542,17 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
rollData.clear(); rollData.clear();
for(final RocketComponent comp: configuration.getAllComponents()) { for(final RocketComponent comp: configuration.getAllComponents()) {
// // this is actually redundant, because the analysis will not contain inactive stages.
// if (!configuration.isComponentActive(comp)) {
// continue;
// }
CMAnalysisEntry cmEntry = cmMap.get(comp.hashCode()); CMAnalysisEntry cmEntry = cmMap.get(comp.hashCode());
if (null == cmEntry) { if (null == cmEntry) {
log.warn("Could not find massData entry for component: " + comp.getName()); log.warn("Could not find massData entry for component: " + comp.getName());
continue; continue;
} }
if ((comp instanceof ComponentAssembly) && !(comp instanceof Rocket)){ String name = cmEntry.name;
continue; if (cmEntry.source instanceof Rocket) {
name = trans.get("componentanalysisdlg.TOTAL");
} }
LongitudinalStabilityRow row = new LongitudinalStabilityRow(name, cmEntry.source);
LongitudinalStabilityRow row = new LongitudinalStabilityRow(cmEntry.name, cmEntry.source);
stabData.add(row); stabData.add(row);
row.source = cmEntry.source; row.source = cmEntry.source;