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)
{
// 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();
aggregateForces.setComponent(comp);
// forces for this component, _only_
if(comp.isAerodynamic()) {
if(comp.isAerodynamic() || comp instanceof ComponentAssembly) {
RocketComponentCalc calcObj = calcMap.get(comp);
if (null == calcObj) {
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())) {
continue;
}
// forces particular to each component
AerodynamicForces childForces = calculateForceAnalysis(configuration, conds, child, instances, eachForces, assemblyForces, warnings);
@ -173,7 +173,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
assemblyForces.put(comp, aggregateForces);
return eachForces.get(comp);
return assemblyForces.get(comp);
}
@Override
@ -944,7 +944,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
calcMap = new HashMap<>();
for (RocketComponent comp: configuration.getAllComponents()) {
if (!comp.isAerodynamic()) {
if (!comp.isAerodynamic() && !(comp instanceof ComponentAssembly)) {
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
public Object getValueAt(int row) {
Object c = stabData.get(row).name;
return c.toString();
}
@ -237,7 +238,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
@Override
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>") {
@ -541,22 +542,17 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
rollData.clear();
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());
if (null == cmEntry) {
log.warn("Could not find massData entry for component: " + comp.getName());
continue;
}
if ((comp instanceof ComponentAssembly) && !(comp instanceof Rocket)){
continue;
String name = cmEntry.name;
if (cmEntry.source instanceof Rocket) {
name = trans.get("componentanalysisdlg.TOTAL");
}
LongitudinalStabilityRow row = new LongitudinalStabilityRow(cmEntry.name, cmEntry.source);
LongitudinalStabilityRow row = new LongitudinalStabilityRow(name, cmEntry.source);
stabData.add(row);
row.source = cmEntry.source;