Modify FinSetCalc to only produce result for one fin, to be summed in
BarrowmanCalculator Modify BarrowmanCalculator to actually sum fin nonaxial forces Modify FinSetCalcTest to sum fins in test3Fin() and test4Fin() Extra bonus: if at some point we allow fins to be other than radially symmetrical, this code should still work (not tested)
This commit is contained in:
parent
13f7c583fd
commit
eb3a129e67
core
src/net/sf/openrocket/aerodynamics
test/net/sf/openrocket/aerodynamics
@ -392,7 +392,6 @@ public class AerodynamicForces implements Cloneable, Monitorable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AerodynamicForces merge(AerodynamicForces other) {
|
public AerodynamicForces merge(AerodynamicForces other) {
|
||||||
|
|
||||||
this.cp = cp.average(other.getCP());
|
this.cp = cp.average(other.getCP());
|
||||||
this.CNa = CNa + other.getCNa();
|
this.CNa = CNa + other.getCNa();
|
||||||
this.CN = CN + other.getCN();
|
this.CN = CN + other.getCN();
|
||||||
|
@ -194,27 +194,20 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
|||||||
final ArrayList<InstanceContext> contextList = entry.getValue();
|
final ArrayList<InstanceContext> contextList = entry.getValue();
|
||||||
|
|
||||||
for(InstanceContext context: contextList ) {
|
for(InstanceContext context: contextList ) {
|
||||||
// since FinSetCalc calculates forces for entire FinSet
|
AerodynamicForces instanceForces = new AerodynamicForces().zero();
|
||||||
// only consider first fin in each set (happily,
|
|
||||||
// in each instance of a PodSet or similar
|
calcObj.calculateNonaxialForces(conditions, context.transform, instanceForces, warnings);
|
||||||
// instanceable RocketComponent with childre, the
|
Coordinate cp_comp = instanceForces.getCP();
|
||||||
// child FinSets all start numbering with 0
|
|
||||||
if (!(comp instanceof FinSet) || (context.instanceNumber == 0)) {
|
Coordinate cp_abs = context.transform.transform(cp_comp);
|
||||||
AerodynamicForces instanceForces = new AerodynamicForces().zero();
|
if ((comp instanceof FinSet) && (((FinSet)comp).getFinCount() > 2))
|
||||||
|
cp_abs = cp_abs.setY(0.0).setZ(0.0);
|
||||||
calcObj.calculateNonaxialForces(conditions, context.transform, instanceForces, warnings);
|
|
||||||
Coordinate cp_comp = instanceForces.getCP();
|
instanceForces.setCP(cp_abs);
|
||||||
|
double CN_instanced = instanceForces.getCN();
|
||||||
Coordinate cp_abs = context.transform.transform(cp_comp);
|
instanceForces.setCm(CN_instanced * instanceForces.getCP().x / conditions.getRefLength());
|
||||||
if ((comp instanceof FinSet) && (((FinSet)comp).getFinCount() > 2))
|
// System.err.println("instanceForces=" + instanceForces);
|
||||||
cp_abs = cp_abs.setY(0.0).setZ(0.0);
|
assemblyForces.merge(instanceForces);
|
||||||
|
|
||||||
instanceForces.setCP(cp_abs);
|
|
||||||
double CN_instanced = instanceForces.getCN();
|
|
||||||
instanceForces.setCm(CN_instanced * instanceForces.getCP().x / conditions.getRefLength());
|
|
||||||
// System.err.println("instanceForces=" + instanceForces);
|
|
||||||
assemblyForces.merge(instanceForces);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,18 +117,7 @@ public class FinSetCalc extends RocketComponentCalc {
|
|||||||
double angle = baseRotation + transform.getXrotation();
|
double angle = baseRotation + transform.getXrotation();
|
||||||
|
|
||||||
// Compute basic CNa without interference effects
|
// Compute basic CNa without interference effects
|
||||||
if (finCount == 1 || finCount == 2) {
|
cna = cna1 * MathUtil.pow2(Math.sin(theta - angle));
|
||||||
// Basic CNa from geometry
|
|
||||||
double mul = 0;
|
|
||||||
for (int i = 0; i < finCount; i++) {
|
|
||||||
mul += MathUtil.pow2(Math.sin(theta - angle));
|
|
||||||
angle += 2 * Math.PI / finCount;
|
|
||||||
}
|
|
||||||
cna = cna1 * mul;
|
|
||||||
} else {
|
|
||||||
// Basic CNa assuming full efficiency
|
|
||||||
cna = cna1 * finCount / 2.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// logger.debug("Component cna = {}", cna);
|
// logger.debug("Component cna = {}", cna);
|
||||||
|
|
||||||
|
@ -38,6 +38,27 @@ public class FinSetCalcTest {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private AerodynamicForces sumFins(TrapezoidFinSet fins, Rocket rocket)
|
||||||
|
{
|
||||||
|
FlightConfiguration config = rocket.getSelectedConfiguration();
|
||||||
|
FlightConditions conditions = new FlightConditions(config);
|
||||||
|
WarningSet warnings = new WarningSet();
|
||||||
|
AerodynamicForces assemblyForces = new AerodynamicForces().zero();
|
||||||
|
AerodynamicForces componentForces = new AerodynamicForces();
|
||||||
|
|
||||||
|
FinSetCalc calcObj = new FinSetCalc( fins );
|
||||||
|
|
||||||
|
// Need to sum forces for fins
|
||||||
|
for (Integer i = 0; i < fins.getFinCount(); i++) {
|
||||||
|
calcObj.calculateNonaxialForces(conditions,
|
||||||
|
Transformation.rotate_x(Math.PI * i / fins.getFinCount()),
|
||||||
|
componentForces, warnings);
|
||||||
|
assemblyForces.merge(componentForces);
|
||||||
|
}
|
||||||
|
|
||||||
|
return assemblyForces;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test3Fin() {
|
public void test3Fin() {
|
||||||
Rocket rocket = TestRockets.makeEstesAlphaIII();
|
Rocket rocket = TestRockets.makeEstesAlphaIII();
|
||||||
@ -49,19 +70,10 @@ public class FinSetCalcTest {
|
|||||||
assertEquals(" Estes Alpha III fins have wrong tip chord:", 0.03, fins.getTipChord(), EPSILON);
|
assertEquals(" Estes Alpha III fins have wrong tip chord:", 0.03, fins.getTipChord(), EPSILON);
|
||||||
assertEquals(" Estes Alpha III fins have wrong sweep: ", 0.02, fins.getSweep(), EPSILON);
|
assertEquals(" Estes Alpha III fins have wrong sweep: ", 0.02, fins.getSweep(), EPSILON);
|
||||||
assertEquals(" Estes Alpha III fins have wrong height: ", 0.05, fins.getHeight(), EPSILON);
|
assertEquals(" Estes Alpha III fins have wrong height: ", 0.05, fins.getHeight(), EPSILON);
|
||||||
|
|
||||||
FlightConfiguration config = rocket.getSelectedConfiguration();
|
// get the forces for the three fins
|
||||||
Transformation transform = Transformation.IDENTITY;
|
AerodynamicForces forces = sumFins(fins, rocket);
|
||||||
FlightConditions conditions = new FlightConditions(config);
|
|
||||||
WarningSet warnings = new WarningSet();
|
|
||||||
AerodynamicForces forces = new AerodynamicForces();
|
|
||||||
FinSetCalc calcObj = new FinSetCalc( fins );
|
|
||||||
|
|
||||||
|
|
||||||
// vvv TEST MEH! vvv
|
|
||||||
calcObj.calculateNonaxialForces(conditions, transform, forces, warnings);
|
|
||||||
// ^^^
|
|
||||||
|
|
||||||
double exp_cna_fins = 24.146933;
|
double exp_cna_fins = 24.146933;
|
||||||
double exp_cpx_fins = 0.0193484;
|
double exp_cpx_fins = 0.0193484;
|
||||||
|
|
||||||
@ -84,18 +96,9 @@ public class FinSetCalcTest {
|
|||||||
assertEquals(" Estes Alpha III fins have wrong tip chord:", 0.03, fins.getTipChord(), EPSILON);
|
assertEquals(" Estes Alpha III fins have wrong tip chord:", 0.03, fins.getTipChord(), EPSILON);
|
||||||
assertEquals(" Estes Alpha III fins have wrong sweep: ", 0.02, fins.getSweep(), EPSILON);
|
assertEquals(" Estes Alpha III fins have wrong sweep: ", 0.02, fins.getSweep(), EPSILON);
|
||||||
assertEquals(" Estes Alpha III fins have wrong height: ", 0.05, fins.getHeight(), EPSILON);
|
assertEquals(" Estes Alpha III fins have wrong height: ", 0.05, fins.getHeight(), EPSILON);
|
||||||
|
|
||||||
FlightConfiguration config = rocket.getSelectedConfiguration();
|
// get the forces for the four fins
|
||||||
Transformation transform = Transformation.IDENTITY;
|
AerodynamicForces forces = sumFins(fins, rocket);
|
||||||
FlightConditions conditions = new FlightConditions(config);
|
|
||||||
WarningSet warnings = new WarningSet();
|
|
||||||
AerodynamicForces forces = new AerodynamicForces();
|
|
||||||
FinSetCalc calcObj = new FinSetCalc( fins );
|
|
||||||
|
|
||||||
|
|
||||||
// vvv TEST MEH! vvv
|
|
||||||
calcObj.calculateNonaxialForces(conditions, transform, forces, warnings);
|
|
||||||
// ^^^
|
|
||||||
|
|
||||||
double exp_cna_fins = 32.195911;
|
double exp_cna_fins = 32.195911;
|
||||||
double exp_cpx_fins = 0.0193484;
|
double exp_cpx_fins = 0.0193484;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user