예제 #1
0
  // ## operation runReactor()
  public void runReactor() {
    // #[ operation runReactor()
    // run reactor
    String dir = System.getProperty("RMG.workingDirectory");

    try {
      // system call for reactor
      String[] command = {dir + "/software/reactorModel/reactor.exe"};
      File runningDir = new File("chemkin");
      Process reactor = Runtime.getRuntime().exec(command, null, runningDir);
      InputStream ips = reactor.getInputStream();
      InputStreamReader is = new InputStreamReader(ips);
      BufferedReader br = new BufferedReader(is);
      String line = null;
      while ((line = br.readLine()) != null) {
        // System.out.println(line);
      }
      int exitValue = reactor.waitFor();
    } catch (Exception e) {
      System.out.println("Error in running reactor!");
      System.out.println(e.getMessage());
      System.exit(0);
    }

    // #]
  }
예제 #2
0
  // ## operation checkChemkinMessage()
  public void checkChemkinMessage() {
    // #[ operation checkChemkinMessage()
    try {
      String dir = System.getProperty("RMG.workingDirectory");
      String filename = "chemkin/chem.message";
      FileReader fr = new FileReader(filename);
      BufferedReader br = new BufferedReader(fr);

      String line = br.readLine().trim();
      if (line.startsWith("NO ERRORS FOUND ON INPUT")) {
        return;
      } else if (line.startsWith("WARNING...THERE IS AN ERROR IN THE LINKING FILE")) {
        System.out.println("Error in chemkin linking to reactor!");
        System.exit(0);
      } else {
        System.out.println("Unknown message in chem.message!");
        System.exit(0);
      }
    } catch (Exception e) {
      System.out.println("Can't read chem.message!");
      System.out.println(e.getMessage());
      System.exit(0);
    }

    // #]
  }