public void calculateClvsAlpha() { int nValue = 50; double alphaMin = Math.toRadians(-5); double alphaMax = Math.toRadians(25); alphaArray.linspace(alphaMin, alphaMax, nValue); double alpha; double q = _clStar - _clAlpha.getEstimatedValue() * _alphaStar.getEstimatedValue(); clAirfoil = new double[nValue]; for (int i = 0; i < nValue; i++) { alpha = alphaArray.get(i); if (alpha < _alphaStar.getEstimatedValue()) { clAirfoil[i] = _clAlpha.getEstimatedValue() * alpha + q; } else { double[][] matrixData = { { Math.pow(_alphaStall.getEstimatedValue(), 3), Math.pow(_alphaStall.getEstimatedValue(), 2), _alphaStall.getEstimatedValue(), 1.0 }, { 3 * Math.pow(_alphaStall.getEstimatedValue(), 2), 2 * _alphaStall.getEstimatedValue(), 1.0, 0.0 }, { 3 * Math.pow(_alphaStar.getEstimatedValue(), 2), 2 * _alphaStar.getEstimatedValue(), 1.0, 0.0 }, { Math.pow(_alphaStar.getEstimatedValue(), 3), Math.pow(_alphaStar.getEstimatedValue(), 2), _alphaStar.getEstimatedValue(), 1.0 } }; RealMatrix m = MatrixUtils.createRealMatrix(matrixData); double[] vector = {_clMax, 0, _clAlpha.getEstimatedValue(), _clStar}; double[] solSystem = MyMathUtils.solveLinearSystem(m, vector); double a = solSystem[0]; double b = solSystem[1]; double c = solSystem[2]; double d = solSystem[3]; clAirfoil[i] = a * Math.pow(alpha, 3) + b * Math.pow(alpha, 2) + c * alpha + d; } } }
/** * This function plots the airfoil drag polar using a parabolic approssimation. * * @author Manuela Ruocco */ public void plotPolar() { System.out.println("\n \n-----------------------------------------------------"); System.out.println("STARTING PLOT AIRFOIL DRAG POLAR"); System.out.println("-----------------------------------------------------"); MyArray alphaArray = new MyArray(); int _numberOfAlpha = 40; double[] cdArrayPolar = new double[_numberOfAlpha]; double[] clArrayPolar = new double[_numberOfAlpha]; Amount<Angle> alphaActualAmount; Amount<Angle> alphaStart = Amount.valueOf(toRadians(-6.), SI.RADIAN); Amount<Angle> alphaEnd = Amount.valueOf(toRadians(12.), SI.RADIAN); alphaArray.setDouble( MyArrayUtils.linspace( alphaStart.getEstimatedValue(), alphaEnd.getEstimatedValue(), _numberOfAlpha)); String folderPathPolar = MyConfiguration.currentDirectoryString + File.separator + "out" + File.separator; String subfolderPathPolar = JPADStaticWriteUtils.createNewFolder(folderPathPolar + "Polar_Airfoil" + File.separator); for (int i = 0; i < _numberOfAlpha; i++) { alphaActualAmount = Amount.valueOf(alphaArray.get(i), SI.RADIAN); clArrayPolar[i] = calculateClAtAlpha(alphaActualAmount.getEstimatedValue()); cdArrayPolar[i] = calculateCdAtAlpha(alphaActualAmount); } MyChartToFileUtils.plotNoLegend( cdArrayPolar, clArrayPolar, null, null, null, null, "Cd", "Cl", "", "", subfolderPathPolar, "Polar_Airfoil "); System.out.println("\n \n-----------------------------------------------------"); System.out.println("DONE"); System.out.println("-----------------------------------------------------"); }
public void plotClvsAlpha(String subfolderPath, String name) { System.out.println("\n \n-----------------------------------------------------"); System.out.println("STARTING PLOT AIRFOIL CL vs ALPHA CURVE " + name); System.out.println("-----------------------------------------------------"); MyArray alphaArray = new MyArray(); int _numberOfAlpha = 60; double[] clArray = new double[_numberOfAlpha]; double[] alphaArrayDeg = new double[_numberOfAlpha]; Amount<Angle> alphaActualAmount; Amount<Angle> alphaStart = Amount.valueOf(toRadians(-6.), SI.RADIAN); Amount<Angle> alphaEnd = Amount.valueOf(toRadians(25.0), SI.RADIAN); alphaArray.setDouble( MyArrayUtils.linspace( alphaStart.getEstimatedValue(), alphaEnd.getEstimatedValue(), _numberOfAlpha)); for (int i = 0; i < _numberOfAlpha; i++) { alphaActualAmount = Amount.valueOf(alphaArray.get(i), SI.RADIAN); clArray[i] = calculateClAtAlpha(alphaActualAmount.getEstimatedValue()); alphaArrayDeg[i] = alphaActualAmount.to(NonSI.DEGREE_ANGLE).getEstimatedValue(); } MyChartToFileUtils.plotNoLegend( alphaArrayDeg, clArray, null, null, null, null, "alpha", "CL", "deg", "", subfolderPath, "CL vs alpha Airfoil" + name); System.out.println("-----------------------------------------------------"); System.out.println("\n DONE"); System.out.println("-----------------------------------------------------"); }