Sha256: 1904167220fc8ad20b219c01dba41d0f8a66e01b83b7d05cad491456d0257f03

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

#! /usr/bin/env ruby
# coding: utf-8

# Show state of vasp geometry optimization calculations.

#require "vasputils/calcseries.rb"
require "rubygems"
gem "vasputils"
require "vasputils.rb"

#require "vasputils/vaspgeomopt.rb"
#require "vasputils/vaspdir.rb"
require "pp"
#require "optparse"

LONGEST_STATE = :terminated.size
KLASSES = [VaspUtils::VaspDir, VaspUtils::VaspGeometryOptimizer]

dirs = ARGV
dirs = Dir.glob("*").sort if ARGV.empty?

def guess(dir)
  KLASSES.each do |klass|
    begin
      vd = klass.new(dir)
      return klass
    rescue klass::InitializeError
    end
  end
  raise "Cannot identify class for directory #{dir}."
end

dirs.each do |dir|
  next unless File.directory? dir

  begin
    klass = guess(dir)
    klass_name = klass.to_s
  rescue 
    klass_name = "UnknownDir"
  end

  printf "%-11s ", klass_name

  case klass_name
  when "VaspUtils::VaspDir"
    calc = klass.new(dir)
    printf "%-10s ", calc.state
    #pp calc.outcar
    printf "%5s ", ""
    begin
      outcar = calc.outcar
      printf "%8.3f %3d (%3d) ",
        outcar[:totens][-1], outcar[:ionic_steps], outcar[:electronic_steps]
    rescue
      printf "%8s %3s (%3s) ", " "*8, " "*3, " "*3
    end

  when "VaspUtils::VaspGeometryOptimizer"
    calc = klass.new(dir)
    printf "%-10s ", calc.state

    ld = calc.latest_dir
    printf "%5s ", ld.dir.sub(/.*try/, "try")
    begin
      outcar = ld.outcar
      printf "%8.3f %3d (%3d) ",
        outcar[:totens][-1], outcar[:ionic_steps], outcar[:electronic_steps]
    rescue
      printf "%8s %3s (%3s) ", " "*8, " "*3, " "*3
    end

  when "UnknownDir"
    printf "-" * 35
    printf " "

  end
  puts dir

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vasputils-0.0.11 bin/checkvasp
vasputils-0.0.10 bin/checkvasp