1 package net.sf.openrocket.aerodynamics;
3 import net.sf.openrocket.util.PolyInterpolator;
5 public class ConeDragTest {
7 private static final double DELTA = 0.01;
8 private static final double SUBSONIC = 0.0;
9 private static final double SUPERSONIC = 1.3;
12 private static final PolyInterpolator polyInt2 = new PolyInterpolator(
13 new double[] {1.0, SUPERSONIC}
14 ,new double[] {1.0, SUPERSONIC}
15 ,new double[] {SUPERSONIC}
18 private final double angle;
19 private final double sin;
20 private final double ratio;
22 private final double[] int2;
24 // Coefficients for subsonic interpolation a * M^b + c
25 private final double a, b, c;
29 public ConeDragTest(double angle) {
31 this.sin = Math.sin(angle);
32 this.ratio = 1.0 / (2*Math.tan(angle));
34 double dsuper = (supersonic(SUPERSONIC+DELTA) - supersonic(SUPERSONIC))/DELTA;
39 b = sonicDerivative() / a;
42 int2 = polyInt2.interpolator(
43 sonic(), supersonic(SUPERSONIC)
44 , sonicDerivative(), dsuper
48 System.err.println("At mach1: CD="+sin+" dCD/dM="+(4.0/2.4*(1-0.5*sin)));
52 private double subsonic(double m) {
53 return 0.8*sin*sin/Math.sqrt(1-m*m);
56 private double sonic() {
60 private double sonicDerivative() {
61 return 4.0/2.4*(1-0.5*sin);
64 private double supersonic(double m) {
65 return 2.1 * sin*sin + 0.5*sin/Math.sqrt(m*m-1);
71 public double getCD(double m) {
76 return a * Math.pow(m,b) + c;
77 return PolyInterpolator.eval(m, int2);
79 // return PolyInterpolator.eval(m, interpolator);
84 public static void main(String[] arg) {
86 ConeDragTest cone10 = new ConeDragTest(10.0*Math.PI/180);
87 ConeDragTest cone20 = new ConeDragTest(20.0*Math.PI/180);
88 ConeDragTest cone30 = new ConeDragTest(30.0*Math.PI/180);
90 ConeDragTest coneX = new ConeDragTest(5.0*Math.PI/180);
92 for (double m=0; m < 4.0001; m+=0.02) {
93 System.out.println(m + " "
94 + cone10.getCD(m) + " "
95 + cone20.getCD(m) + " "
96 + cone30.getCD(m) + " "