Merge pull request #507 from teyrana/fix_387_cp
Increase accuracy of Center-Of-Pressure calculations
This commit is contained in:
commit
7b0724ab0a
@ -411,6 +411,9 @@ public class AerodynamicForces implements Cloneable, Monitorable {
|
||||
public AerodynamicForces multiplex(final int instanceCount) {
|
||||
|
||||
this.cp = cp.setWeight(cp.weight*instanceCount);
|
||||
if(1 < instanceCount) {
|
||||
this.cp = cp.setY(0f).setZ(0f);
|
||||
}
|
||||
this.CNa = CNa*instanceCount;
|
||||
this.CN = CN*instanceCount;
|
||||
this.Cm = Cm*instanceCount;
|
||||
|
@ -207,7 +207,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
||||
Coordinate cp_weighted = cp_comp.setWeight(cp_comp.weight);
|
||||
Coordinate cp_absolute = component.toAbsolute(cp_weighted)[0];
|
||||
if(1 < component.getInstanceCount()) {
|
||||
cp_absolute = cp_absolute.setY(0.);
|
||||
cp_absolute = cp_absolute.setY(0.).setZ(0.);
|
||||
}
|
||||
|
||||
componentForces.setCP(cp_absolute);
|
||||
@ -215,19 +215,18 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
||||
componentForces.setCm(CN_instanced * componentForces.getCP().x / conditions.getRefLength());
|
||||
|
||||
// if( 0.0001 < Math.abs(componentForces.getCNa())){
|
||||
// System.err.println(String.format("%s....Component.CNa: %g @ CP: %g, %g", indent, componentForces.getCNa(), componentForces.getCP().x, componentForces.getCP().y));
|
||||
// final Coordinate cp = assemblyForces.getCP();
|
||||
// System.err.println(String.format("%s....Component.CNa: %g @ CP: { %f, %f, %f}", indent, componentForces.getCNa(), cp.x, cp.y, cp.z));
|
||||
// }
|
||||
|
||||
assemblyForces.merge(componentForces);
|
||||
}
|
||||
|
||||
// if( 0.0001 < Math.abs(0 - assemblyForces.getCNa())){
|
||||
// System.err.println(String.format("%s....Assembly.CNa: %g @ CPx: %g", indent, assemblyForces.getCNa(), assemblyForces.getCP().x));
|
||||
// final Coordinate cp = assemblyForces.getCP();
|
||||
// System.err.println(String.format("%s....Assembly.CNa: %g @ CP: { %f, %f, %f}", indent, assemblyForces.getCNa(), cp.x, cp.y, cp.z));
|
||||
// }
|
||||
|
||||
// fetches instanced versions
|
||||
// int instanceCount = component.getLocations().length;
|
||||
|
||||
if( component.allowsChildren() && (component.getInstanceCount() > 1)) {
|
||||
return assemblyForces.multiplex(component.getInstanceCount());
|
||||
}else {
|
||||
|
@ -15,12 +15,12 @@ import net.sf.openrocket.ServicesForTesting;
|
||||
import net.sf.openrocket.plugin.PluginModule;
|
||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.NoseCone;
|
||||
import net.sf.openrocket.rocketcomponent.ParallelStage;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.TestRockets;
|
||||
@ -97,7 +97,6 @@ public class BarrowmanCalculatorTest {
|
||||
FlightConditions conditions = new FlightConditions(config);
|
||||
WarningSet warnings = new WarningSet();
|
||||
|
||||
|
||||
// calculated from OpenRocket 15.03:
|
||||
//double expCPx = 0.225;
|
||||
// verified from the equations:
|
||||
@ -110,19 +109,39 @@ public class BarrowmanCalculatorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCPDoubleStrapOn() {
|
||||
Rocket rocket = TestRockets.makeFalcon9Heavy();
|
||||
FlightConfiguration config = rocket.getSelectedConfiguration();
|
||||
BarrowmanCalculator calc = new BarrowmanCalculator();
|
||||
FlightConditions conditions = new FlightConditions(config);
|
||||
WarningSet warnings = new WarningSet();
|
||||
|
||||
double expCPx = 1.04662388;
|
||||
double expCNa = 21.5111598;
|
||||
Coordinate calcCP = calc.getCP(config, conditions, warnings);
|
||||
|
||||
assertEquals(" Falcon 9 Heavy CP x value is incorrect:", expCPx, calcCP.x, EPSILON);
|
||||
assertEquals(" Falcon 9 Heavy CNa value is incorrect:", expCNa, calcCP.weight, EPSILON);
|
||||
public void testCPParallelBoosters() {
|
||||
final Rocket rocket = TestRockets.makeFalcon9Heavy();
|
||||
final ParallelStage boosterStage = (ParallelStage) rocket.getChild(1).getChild(0).getChild(0);
|
||||
final TrapezoidFinSet boosterFins = (TrapezoidFinSet) boosterStage.getChild(1).getChild(1);
|
||||
final FlightConfiguration config = rocket.getSelectedConfiguration();
|
||||
final BarrowmanCalculator calc = new BarrowmanCalculator();
|
||||
final FlightConditions conditions = new FlightConditions(config);
|
||||
final WarningSet warnings = new WarningSet();
|
||||
|
||||
{
|
||||
boosterFins.setFinCount(3);
|
||||
final Coordinate cp_3fin = calc.getCP(config, conditions, warnings);
|
||||
assertEquals(" Falcon 9 Heavy CNa value is incorrect:", 21.5111598, cp_3fin.weight, EPSILON);
|
||||
assertEquals(" Falcon 9 Heavy CP x value is incorrect:", 1.04662388, cp_3fin.x, EPSILON);
|
||||
assertEquals(" Falcon 9 Heavy CP y value is incorrect:", 0.0, cp_3fin.y, EPSILON);
|
||||
assertEquals(" Falcon 9 Heavy CP z value is incorrect:", 0.0, cp_3fin.z, EPSILON);
|
||||
}{
|
||||
boosterFins.setFinCount(2);
|
||||
final Coordinate cp_2fin = calc.getCP(config, conditions, warnings);
|
||||
assertEquals(" Falcon 9 Heavy CNa value is incorrect:", 15.43711197, cp_2fin.weight, EPSILON);
|
||||
assertEquals(" Falcon 9 Heavy CP x value is incorrect:", 0.99464238, cp_2fin.x, EPSILON);
|
||||
assertEquals(" Falcon 9 Heavy CP y value is incorrect:", 0.0, cp_2fin.y, EPSILON);
|
||||
assertEquals(" Falcon 9 Heavy CP z value is incorrect:", 0.0, cp_2fin.z, EPSILON);
|
||||
}{
|
||||
boosterFins.setFinCount(1);
|
||||
final Coordinate cp_1fin = calc.getCP(config, conditions, warnings);
|
||||
assertEquals(" Falcon 9 Heavy CNa value is incorrect:", 9.36306412, cp_1fin.weight, EPSILON);
|
||||
assertEquals(" Falcon 9 Heavy CP x value is incorrect:", 0.87521867, cp_1fin.x, EPSILON);
|
||||
assertEquals(" Falcon 9 Heavy CP y value is incorrect:", 0f, cp_1fin.y, EPSILON);
|
||||
assertEquals(" Falcon 9 Heavy CP z value is incorrect:", 0f, cp_1fin.z, EPSILON);
|
||||
}{
|
||||
// absent -- 3.28901627g @[0.31469937,0.05133333,0.00000000]
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -152,7 +171,6 @@ public class BarrowmanCalculatorTest {
|
||||
assertTrue("Estes Alpha III should be continous: ", calc.isContinuous( rocket));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testContinuousRocketWithStrapOns() {
|
||||
Rocket rocket = TestRockets.makeFalcon9Heavy();
|
||||
|
Loading…
x
Reference in New Issue
Block a user