removed commented sysout lines
[debian/openrocket] / src / net / sf / openrocket / aerodynamics / BarrowmanCalculator.java
index 4b243389a418f8132cc3e4a1e59bf962c075fbc9..dac1c83d99401e6d05ccbd52bf0cf4c4a60f9bfd 100644 (file)
@@ -12,10 +12,10 @@ import net.sf.openrocket.aerodynamics.barrowman.FinSetCalc;
 import net.sf.openrocket.aerodynamics.barrowman.RocketComponentCalc;
 import net.sf.openrocket.rocketcomponent.Configuration;
 import net.sf.openrocket.rocketcomponent.ExternalComponent;
+import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
 import net.sf.openrocket.rocketcomponent.FinSet;
 import net.sf.openrocket.rocketcomponent.RocketComponent;
 import net.sf.openrocket.rocketcomponent.SymmetricComponent;
-import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
 import net.sf.openrocket.util.Coordinate;
 import net.sf.openrocket.util.MathUtil;
 import net.sf.openrocket.util.PolyInterpolator;
@@ -140,6 +140,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
                total.setCm(total.getCm() - total.getPitchDampingMoment());
                total.setCyaw(total.getCyaw() - total.getYawDampingMoment());
                
+
                return total;
        }
        
@@ -205,7 +206,6 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
                        calcMap.get(component).calculateNonaxialForces(conditions, forces, warnings);
                        forces.setCP(component.toAbsolute(forces.getCP())[0]);
                        forces.setCm(forces.getCN() * forces.getCP().x / conditions.getRefLength());
-                       //                      System.out.println("  CN="+forces.CN+" cp.x="+forces.cp.x+" Cm="+forces.Cm);
                        
                        if (map != null) {
                                AerodynamicForces f = map.get(component);
@@ -255,25 +255,19 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
                Re = conditions.getVelocity() * configuration.getLength() /
                                conditions.getAtmosphericConditions().getKinematicViscosity();
                
-               //              System.out.printf("Re=%.3e   ", Re);
-               
                // Calculate the skin friction coefficient (assume non-roughness limited)
                if (configuration.getRocket().isPerfectFinish()) {
                        
-                       //                      System.out.printf("Perfect finish: Re=%f ",Re);
                        // Assume partial laminar layer.  Roughness-limitation is checked later.
                        if (Re < 1e4) {
                                // Too low, constant
                                Cf = 1.33e-2;
-                               //                              System.out.printf("constant Cf=%f ",Cf);
                        } else if (Re < 5.39e5) {
                                // Fully laminar
-                               Cf = 1.328 / Math.sqrt(Re);
-                               //                              System.out.printf("basic Cf=%f ",Cf);
+                               Cf = 1.328 / MathUtil.safeSqrt(Re);
                        } else {
                                // Transitional
                                Cf = 1.0 / pow2(1.50 * Math.log(Re) - 5.6) - 1700 / Re;
-                               //                              System.out.printf("transitional Cf=%f ",Cf);
                        }
                        
                        // Compressibility correction
@@ -298,7 +292,6 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
                                }
                        }
                        
-                       //                      System.out.printf("c1=%f c2=%f\n", c1,c2);
                        // Applying continuously around Mach 1
                        if (mach < 0.9) {
                                Cf *= c1;
@@ -308,19 +301,16 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
                                Cf *= c2;
                        }
                        
-                       //                      System.out.printf("M=%f Cf=%f (smooth)\n",mach,Cf);
-                       
+
                } else {
                        
                        // Assume fully turbulent.  Roughness-limitation is checked later.
                        if (Re < 1e4) {
                                // Too low, constant
                                Cf = 1.48e-2;
-                               //                              System.out.printf("LOW-TURB  ");
                        } else {
                                // Turbulent
                                Cf = 1.0 / pow2(1.50 * Math.log(Re) - 5.6);
-                               //                              System.out.printf("NORMAL-TURB  ");
                        }
                        
                        // Compressibility correction
@@ -340,8 +330,6 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
                                Cf *= c2;
                        }
                        
-                       //                      System.out.printf("M=%f, Cd=%f (turbulent)\n", mach,Cf);
-                       
                }
                
                // Roughness-limited value correction term
@@ -356,8 +344,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
                        roughnessCorrection = c2 * (mach - 0.9) / 0.2 + c1 * (1.1 - mach) / 0.2;
                }
                
-               //              System.out.printf("Cf=%.3f  ", Cf);
-               
+
 
                /*
                 * Calculate the friction drag coefficient.
@@ -387,9 +374,6 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
                                roughnessLimited[finish.ordinal()] =
                                                0.032 * Math.pow(finish.getRoughnessSize() / configuration.getLength(), 0.2) *
                                                                roughnessCorrection;
-                               
-                               //                              System.out.printf("roughness["+finish+"]=%.3f  ", 
-                               //                                              roughnessLimited[finish.ordinal()]);
                        }
                        
                        /*
@@ -402,14 +386,8 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
                                // For perfect finish require Re > 1e6
                                if ((Re > 1.0e6) && (roughnessLimited[finish.ordinal()] > Cf)) {
                                        componentCf = roughnessLimited[finish.ordinal()];
-                                       //                                      System.out.printf("    rl=%f Cf=%f (perfect=%b)\n",
-                                       //                                      roughnessLimited[finish.ordinal()], 
-                                       //                                      Cf,rocket.isPerfectFinish());
-                                       
-                                       //                                      System.out.printf("LIMITED  ");
                                } else {
                                        componentCf = Cf;
-                                       //                                      System.out.printf("NORMAL  ");
                                }
                                
                        } else {
@@ -419,9 +397,6 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
                                
                        }
                        
-                       //                      System.out.printf("compCf=%.3f  ", componentCf);
-                       
-
 
 
                        // Calculate the friction drag:
@@ -470,7 +445,6 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
                        }
                }
                
-               //              System.out.printf("\n");
                return (finFriction + correction * bodyFriction) / conditions.getRefArea();
        }
        
@@ -648,19 +622,12 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
                double yaw = conditions.getYawRate();
                double vel = conditions.getVelocity();
                
-               //                      double Cm = total.Cm - total.CN * total.cg.x / conditions.getRefLength();
-               //                      System.out.printf("Damping pitch/yaw, mul=%.4f pitch rate=%.4f "+
-               //                                      "Cm=%.4f / %.4f effect=%.4f aoa=%.4f\n", mul, pitch, total.Cm, Cm, 
-               //                                      -(mul * MathUtil.sign(pitch) * pow2(pitch/vel)), 
-               //                                      conditions.getAOA()*180/Math.PI);
+               vel = MathUtil.max(vel, 1);
                
                mul *= 3; // TODO: Higher damping yields much more realistic apogee turn
                
-               //                      total.Cm -= mul * pitch / pow2(vel);
-               //                      total.Cyaw -= mul * yaw / pow2(vel);
                total.setPitchDampingMoment(mul * MathUtil.sign(pitch) * pow2(pitch / vel));
                total.setYawDampingMoment(mul * MathUtil.sign(yaw) * pow2(yaw / vel));
-               
        }
        
        // TODO: MEDIUM: Are the rotation etc. being added correctly?  sin/cos theta?