Unverified Commit 6420ccaf authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

fix bugs with not properly detecting/selecting unit conversions

parent 22d8d0d0
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -359,14 +359,13 @@ double PairTable::init_one(int i, int j)

void PairTable::read_table(Table *tb, char *file, char *keyword)
{
  TableFileReader reader(lmp, file, "pair");
  TableFileReader reader(lmp, file, "pair", unit_convert_flag);

  // transparently convert units for supported conversions

  int unit_convert = reader.get_unit_convert();
  double conversion_factor = utils::get_conversion_factor(utils::ENERGY,
                                                          unit_convert);

  char *line = reader.find_section_start(keyword);

  if (!line) {
+10 −9
Original line number Diff line number Diff line
@@ -153,23 +153,24 @@ TextFileReader * PotentialFileReader::open_potential(const std::string& path) {
    std::string date       = utils::get_potential_date(filepath, filetype);
    std::string units      = utils::get_potential_units(filepath, filetype);

    if (!date.empty()) {
      utils::logmesg(lmp, fmt::format("Reading potential file {} with DATE: {}\n", filename, date));
    }
    if (!date.empty())
      utils::logmesg(lmp, fmt::format("Reading {} file {} with DATE: {}\n",
                                      filetype, filename, date));

    if (units.empty()) {
      unit_convert == utils::NOCONVERT;
      unit_convert = utils::NOCONVERT;
    } else {
      if (units == unit_style) {
        unit_convert = utils::NOCONVERT;
      } else {
        if ((units == "metal") && (unit_style == "real") && (unit_convert | utils::METAL2REAL)) {
        if ((units == "metal") && (unit_style == "real") && (unit_convert & utils::METAL2REAL)) {
          unit_convert = utils::METAL2REAL;
        } else if ((units == "real") && (unit_style == "metal") && (unit_convert | utils::REAL2METAL)) {
        } else if ((units == "real") && (unit_style == "metal") && (unit_convert & utils::REAL2METAL)) {
          unit_convert = utils::REAL2METAL;
        } else {
          lmp->error->one(FLERR, fmt::format("Potential file {} requires {} units "
                                             "but {} units are in use",filename, units, unit_style));
          lmp->error->one(FLERR, fmt::format("{} file {} requires {} units "
                                             "but {} units are in use", filetype,
                                             filename, units, unit_style));
        }
      }
    }