Пример #1
0
  public static void writeChemkinInputFile(ReactionSystem rs) {
    // #[ operation writeChemkinInputFile(ReactionModel,SystemSnapshot)

    StringBuilder result = new StringBuilder();
    result.append(writeChemkinHeader());
    result.append(writeChemkinElement());
    double start = System.currentTimeMillis();
    result.append(writeChemkinSpecies(rs.reactionModel, rs.initialStatus));
    result.append(writeChemkinThermo(rs.reactionModel));
    Global.chemkinThermo = Global.chemkinThermo + (System.currentTimeMillis() - start) / 1000 / 60;
    start = System.currentTimeMillis();
    result.append(writeChemkinPdepReactions(rs));
    Global.chemkinReaction =
        Global.chemkinReaction + (System.currentTimeMillis() - start) / 1000 / 60;

    String dir = System.getProperty("RMG.workingDirectory");
    if (!dir.endsWith("/")) dir += "/";
    dir += "software/reactorModel/";
    String file = "chemkin/chem.inp";

    try {
      FileWriter fw = new FileWriter(file);
      fw.write(result.toString());
      fw.close();
    } catch (Exception e) {
      System.out.println("Error in writing chemkin input file chem.inp!");
      System.out.println(e.getMessage());
      System.exit(0);
    }

    // #]
  }
Пример #2
0
  // ## operation writeChemkinInputFile(ReactionModel,SystemSnapshot)
  public static void writeChemkinInputFile(
      final ReactionModel p_reactionModel, SystemSnapshot p_beginStatus) {
    // #[ operation writeChemkinInputFile(ReactionModel,SystemSnapshot)

    StringBuilder result = new StringBuilder();
    result.append(writeChemkinHeader());
    result.append(writeChemkinElement());
    double start = System.currentTimeMillis();
    result.append(writeChemkinSpecies(p_reactionModel, p_beginStatus));
    result.append(writeChemkinThermo(p_reactionModel));
    Global.chemkinThermo = Global.chemkinThermo + (System.currentTimeMillis() - start) / 1000 / 60;
    start = System.currentTimeMillis();
    result.append(
        writeChemkinPdepReactions(
            p_reactionModel, p_beginStatus)); // 10/26/07 gmagoon: changed to pass p_beginStatus
    // result.append(writeChemkinPdepReactions(p_reactionModel));
    Global.chemkinReaction =
        Global.chemkinReaction + (System.currentTimeMillis() - start) / 1000 / 60;

    String dir = System.getProperty("RMG.workingDirectory");
    if (!dir.endsWith("/")) dir += "/";
    dir += "software/reactorModel/";
    String file = "chemkin/chem.inp";

    try {
      FileWriter fw = new FileWriter(file);
      fw.write(result.toString());
      fw.close();
    } catch (Exception e) {
      System.out.println("Error in writing chemkin input file chem.inp!");
      System.out.println(e.getMessage());
      System.exit(0);
    }

    if (PDepRateConstant.getMode() == Mode.CHEBYSHEV
        || PDepRateConstant.getMode() == Mode.PDEPARRHENIUS
        || PDepRateConstant.getMode() == Mode.RATE) {
      StringBuilder gridOfRateCoeffs = new StringBuilder();
      gridOfRateCoeffs.append(writeGridOfRateCoeffs(p_reactionModel));
      String newFile = "chemkin/tableOfRateCoeffs.txt";
      try {
        FileWriter fw = new FileWriter(newFile);
        fw.write(gridOfRateCoeffs.toString());
        fw.close();
      } catch (Exception e) {
        System.out.println("Error in writing tableOfRateCoeffs.txt");
        System.out.println(e.getMessage());
        System.exit(0);
      }
    }

    // #]
  }
Пример #3
0
  public static TemplateReaction makeTemplateReaction(
      Structure p_structureSp,
      Kinetics[] p_kinetics,
      ReactionTemplate p_template,
      Structure p_structure) {
    double PT = System.currentTimeMillis();
    // Look for pre-existing reaction in Template's reactionDictionaryByStructure.
    TemplateReaction reaction = p_template.getReactionFromStructure(p_structureSp);
    Global.getReacFromStruc =
        Global.getReacFromStruc + (System.currentTimeMillis() - PT) / 1000 / 60;

    if (reaction == null) {
      // Create a new reaction.
      reaction = new TemplateReaction(p_structureSp, p_kinetics, p_template);
      if (reaction.isBackward()) {
        Logger.info(
            "Created new reverse " + p_template.getName() + " reaction: " + reaction.toString());
        TemplateReaction reverse =
            reaction.generateReverseForBackwardReaction(p_structure, p_structureSp);
        if (reverse == null) return null;
        reaction.setReverseReaction(reverse);
      } else {
        Logger.info(
            "Created new forwards " + p_template.getName() + " reaction: " + reaction.toString());
        ReactionTemplate fRT = reaction.getReactionTemplate();
        ReactionTemplate rRT = null;
        if (fRT.isNeutral()) rRT = fRT;
        else rRT = fRT.getReverseReactionTemplate();
        if (rRT != null) {
          TemplateReaction reverse =
              new TemplateReaction(p_structureSp.generateReverseStructure(), p_kinetics, rRT);
          reaction.setReverseReaction(reverse);
          reverse.setReverseReaction(reaction);
          rRT.addReaction(reverse);
        }
      }
      if (!reaction.repOk()) {
        throw new InvalidTemplateReactionException();
      }

      p_template.addReaction(reaction);
    }
    Global.makeTR += (System.currentTimeMillis() - PT) / 1000 / 60;

    if (!reaction.repOk()) {
      throw new InvalidTemplateReactionException();
    }
    return reaction;
  }