Skip to content

ArrayTrim

xuetaoshi edited this page Apr 11, 2017 · 1 revision

Trim the arrays read by FileRead according to how each type of data was printed out in Gaussian log files. This is necessary due to Gaussian trajectory log file routinely print out additional information at the start and/or the end of the whole calculation in a similar fashion as it would be for the actual time steps.

  • Initialization: ArrayTrim(file_str="", max_pts=-1)
    The initialization of this object will attempt to determine the maximum number of points, aka time steps, in the log file and set up a trim parameter dictionary.

    • Parameters:
      • file_str: string, python File object
        optional. However, if both this and the next optional argument were not passed in during initialization, an error would be raised. This argument corresponds to either string of a log file, or the file handle of such file from which the initialization attempts to determine the maximum number of points if not directly passed in by the next argument.
      • max_pts: integer
        optional, default=-1, which is a flag to signify this value was not directly passed in. This gives the maximum number of points for the Gaussian log files.
  • ArrayTrim.trim_par_dict =

      {
          "Electric Field": (1, 0),
          "Electric Field Alt": (1, 0),
          "Cartesian Coordinates #VarRow": (1, 0),
          "Mass Weighted Velocity #VarRow": (1, 0),
          "Time": (1, 0),
          "Total Energy": (1, 0),
          "Kinetic Energy": (1, 0),
          "Potential Energy": (1, 0),
          "Total Angular Momentum": (1, 0),
          "Angular Momemtum Components": (1, 0),
          "Mulliken Charges #VarRow": (1, 1),
          "Dipole Moment": (1, 1)
      }
    

    Two variables would be needed in the tuples: one for indicating how many points to discard at the beginning and one for how many points to discard at the end. Since not all types of information would be printed out at the beginning, usually sampling step, each type of data may require different number of points to be trimmed. This is true for the end of the log file as well.

  • ArrayTrim.set_extra_trim(ex_par)
    Set additional trimming parameter which acts on top of the orginial ones.

    • Parameters:
      • ex_par: integer
        first argument. Extra number of points to be trimmed from the array. If ex_par > 0, trim from the beginning of the array; if ex_par < 0, trim from the end of the array.
  • ArrayTrim.trim(array, data_type)
    Trim the input array by the number of points based on the data_type.

    • Parameters:
      • array: numpy array
        first argument. The array to be trimmed.
      • data_type: string
        second argument. The string of the key in the trim_par_dict dictionary. An error will be raised if such entry was not added before using this method.

Clone this wiki locally