Ejemplo n.º 1
0
  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("-----------------------------------------------------");
  }
  // ------------------------------------------------------------------------------------------
  // MAIN:
  public static void main(String[] args)
      throws HDF5LibraryException, NullPointerException, CmdLineException {

    // --------------------------------------------------------------------------------------
    // Arguments check and initial activities
    if (args.length == 0) {
      System.err.println("NO INPUT FILE GIVEN --> TERMINATING");
      return;
    }

    System.out.println("------------------------------------------------------------");
    System.out.println("PayloadRangeCalc_Test :: TURBOPROP");
    System.out.println("------------------------------------------------------------");
    System.out.println(" ");

    PayloadRange_Test_TP_SA main = new PayloadRange_Test_TP_SA();
    System.out.println("Input variable usage:");
    main.theCmdLineParser.printUsage(System.out);
    System.out.println("-----------------------------------------------------------");
    main.theCmdLineParser.parseArgument(args);

    String path = main.get_inputFile().getAbsolutePath();
    JPADXmlReader reader = new JPADXmlReader(path);
    System.out.println("-----------------------------------------------------------");
    System.out.println("XML File Path : " + path);
    System.out.println("-----------------------------------------------------------");
    System.out.println("Initialize reading \n");

    // --------------------------------------------------------------------------------------
    // Input data
    Amount<Angle> sweepLEEquivalent =
        (Amount<Angle>) reader.getXMLAmountWithUnitByPath("//ATR72/SweepLE");
    Amount<Mass> maxTakeOffMass =
        (Amount<Mass>) reader.getXMLAmountWithUnitByPath("//ATR72/Maximum_take_off_mass");
    Amount<Mass> operatingEmptyMass =
        (Amount<Mass>) reader.getXMLAmountWithUnitByPath("//ATR72/Operating_empty_mass");
    Amount<Mass> maxFuelMass =
        (Amount<Mass>) reader.getXMLAmountWithUnitByPath("//ATR72/Maximum_fuel_mass");
    Amount<Area> surface =
        (Amount<Area>) reader.getXMLAmountWithUnitByPath("//ATR72/Planform_surface");
    List<String> cd0_property = reader.getXMLPropertiesByPath("//ATR72/CD0");
    double cd0 = Double.valueOf(cd0_property.get(0));
    List<String> oswald_property = reader.getXMLPropertiesByPath("//ATR72/OswaldFactor");
    double oswald = Double.valueOf(oswald_property.get(0));
    List<String> ar_property = reader.getXMLPropertiesByPath("//ATR72/AspectRatio");
    double ar = Double.valueOf(ar_property.get(0));
    List<String> cl_property = reader.getXMLPropertiesByPath("//ATR72/Current_lift_coefficient");
    double cl = Double.valueOf(cl_property.get(0));
    List<String> tcMax_property = reader.getXMLPropertiesByPath("//ATR72/Mean_maximum_thickness");
    double tcMax = Double.valueOf(tcMax_property.get(0));
    List<String> altitude_property = reader.getXMLPropertiesByPath("//ATR72/Altitude");
    double altitude = Double.valueOf(altitude_property.get(0));
    List<String> eta_property = reader.getXMLPropertiesByPath("//ATR72/Propeller_efficiency");
    double eta = Double.valueOf(eta_property.get(0));
    List<String> currentMach_property = reader.getXMLPropertiesByPath("//ATR72/Mach_number");
    double currentMach = Double.valueOf(currentMach_property.get(0));
    List<String> byPassRatio_property = reader.getXMLPropertiesByPath("//ATR72/ByPassRatio");
    double byPassRatio = Double.valueOf(byPassRatio_property.get(0));
    List<String> nPassMax_property =
        reader.getXMLPropertiesByPath("//ATR72/Maximum_number_of_passengers");
    double nPassMax = Double.valueOf(nPassMax_property.get(0));
    List<String> taperRatioEquivalent_property =
        reader.getXMLPropertiesByPath("//ATR72/TaperRatio");
    double taperRatioEquivalent = Double.valueOf(taperRatioEquivalent_property.get(0));

    Amount<Angle> sweepHalfChordEquivalent =
        LSGeometryCalc.calculateSweep(
            ar,
            taperRatioEquivalent,
            sweepLEEquivalent.to(SI.RADIAN).getEstimatedValue(),
            0.5,
            0.0);

    // --------------------------------------------------------------------------------------
    // the next step is necessary to calculate CL and Speed at point E (or A) of the parabolic polar
    ACAerodynamicsManager analysis = new ACAerodynamicsManager();
    analysis.calculateDragPolarPoints(
        ar,
        oswald,
        cd0,
        AtmosphereCalc.getDensity(altitude),
        maxTakeOffMass.getEstimatedValue() * 9.81,
        surface.getEstimatedValue());

    // --------------------------------------------------------------------------------------
    // Assign all default folders
    MyConfiguration.initWorkingDirectoryTree();

    // --------------------------------------------------------------------------------------
    // Setup database(s)
    String databaseFolderPath = MyConfiguration.getDir(FoldersEnum.DATABASE_DIR);
    String fuelFractionDatabaseFileName = "FuelFractions.h5";
    FuelFractionDatabaseReader fuelFractionReader =
        new FuelFractionDatabaseReader(databaseFolderPath, fuelFractionDatabaseFileName);

    // --------------------------------------------------------------------------------------
    // Creating calculator object
    PayloadRangeCalc test =
        new PayloadRangeCalc(
            maxTakeOffMass,
            operatingEmptyMass,
            maxFuelMass,
            sweepHalfChordEquivalent,
            nPassMax,
            cl,
            tcMax,
            AirplaneType.TURBOPROP_REGIONAL,
            EngineTypeEnum.TURBOPROP,
            AirfoilTypeEnum.CONVENTIONAL,
            analysis,
            fuelFractionReader);

    // -----------------------CRITICAL MACH NUMBER CHECK----------------------------

    boolean check = test.checkCriticalMach(currentMach);

    if (check)
      System.out.println(
          "\n\n-----------------------------------------------------------"
              + "\nCurrent Mach is lower then critical Mach number."
              + "\nCurrent Mach = "
              + currentMach
              + "\nCritical Mach = "
              + test.getCriticalMach()
              + "\n\n\t CHECK PASSED --> PROCEDING TO CALCULATION "
              + "\n\n"
              + "-----------------------------------------------------------");
    else {
      System.err.println(
          "\n\n-----------------------------------------------------------"
              + "\nCurrent Mach is bigger then critical Mach number."
              + "\nCurrent Mach = "
              + currentMach
              + "\nCritical Mach = "
              + test.getCriticalMach()
              + "\n\n\t CHECK NOT PASSED --> TERMINATING "
              + "\n\n"
              + "-----------------------------------------------------------");
      return;
    }

    // ------------------------MTOM PARAMETERIZATION---------------------------------

    test.createPayloadRangeMatrices(
        sweepHalfChordEquivalent,
        surface,
        cd0,
        oswald,
        cl,
        ar,
        tcMax,
        byPassRatio,
        eta,
        altitude,
        currentMach,
        false);

    // ------------------------------PLOTTING-----------------------------------------------
    // MTOM parameterization:

    test.createPayloadRangeCharts_MaxTakeOffMass(test.getRangeMatrix(), test.getPayloadMatrix());
  }