Class: VaspGeomOptCommand
- Inherits:
-
Thor
- Object
- Thor
- VaspGeomOptCommand
- Defined in:
- bin/vaspgeomopt
Overview
Command template
Instance Method Summary collapse
- #execute(*args) ⇒ Object
- #init(*args) ⇒ Object
- #latest(*args) ⇒ Object
- #next(*args) ⇒ Object
- #qsub(*args) ⇒ Object
- #show(*args) ⇒ Object
Instance Method Details
#execute(*args) ⇒ Object
88 89 90 |
# File 'bin/vaspgeomopt', line 88 def execute(* args) VaspUtils::VaspGeometryOptimizer.execute(args) end |
#init(*args) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'bin/vaspgeomopt', line 134 def init(* args) targets = args targets = [ENV['PWD']] if targets.empty? targets.each do |tgt_dir| puts "Directory: #{tgt_dir}" # Check tgt_dir is VaspDir? begin tgt = VaspUtils::VaspGeometryOptimizer.new(tgt_dir) rescue VaspUtils::VaspGeometryOptimizer::NoVaspDirError puts " Not VaspGeometryOptimizer: #{tgt_dir}" next end puts " Back to init: #{tgt_dir}" tgt.reset_initialize end end |
#latest(*args) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'bin/vaspgeomopt', line 71 def latest(* args) targets = args targets = ["."] if args.empty? targets.each do |target| klass_name = "VaspGeomOpt" begin calc = VaspUtils::VaspGeometryOptimizer.new(target) rescue next end puts calc.latest_dir.dir end end |
#next(*args) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'bin/vaspgeomopt', line 109 def next(* args) targets = args targets = [ENV['PWD']] if targets.empty? targets.each do |tgt_dir| puts "Directory: #{tgt_dir}" # Check tgt_dir is VaspDir? begin tgt = VaspUtils::VaspGeometryOptimizer.new(tgt_dir) rescue VaspUtils::VaspGeometryOptimizer::NoVaspDirError puts " Not VaspGeometryOptimizer: #{tgt_dir}" next end puts " Generate next: #{tgt_dir}" begin tgt.reset_next rescue VaspUtils::VaspGeometryOptimizer::NoContcarError puts " CONTCAR not exist in latest_dir: #{tgt_dir}" end end end |
#qsub(*args) ⇒ Object
101 102 103 104 105 |
# File 'bin/vaspgeomopt', line 101 def qsub(* args) = Marshal.load(Marshal.dump()) [:command] = "#{__FILE__} execute" VaspUtils::VaspGeometryOptimizer.qsub(args, ) end |
#show(*args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'bin/vaspgeomopt', line 17 def show(* args) show_dir_states = [] show_dir_states << :finished if [:finished] show_dir_states << :yet if [:yet] show_dir_states << :terminated if [:terminated] show_dir_states << :started if [:started] if show_dir_states.empty? show_dir_states = [:finished, :yet, :terminated, :started] end dirs = args dirs = ["."] if args.empty? format_str = "%-11s %-10s %14s %9s %15s %s\n" unless [:files_with_matches] printf(format_str, "TYPE", "STATE", "TOTEN", "LATEST", "MODIFIED_TIME", "DIR") puts "="*80 end dirs.each do |dir| next unless File.directory? dir begin calc = VaspUtils::VaspGeometryOptimizer.new(dir) klass_name = "VaspGeomOpt" state = calc.state ld = calc.latest_dir next unless show_dir_states.include?(state) begin outcar = ld.outcar toten = sprintf("%14.6f", outcar[:totens][-1].to_f) ld_str = ld.dir.sub("#{dir}/", "") time = calc.latest_modified_time.strftime("%Y%m%d-%H%M%S") rescue toten = time = ld_str = "" end rescue VaspUtils::VaspGeometryOptimizer::InitializeError klass_name = "-------" state = toten = ld_str = "---" end if [:files_with_matches] puts dir else printf(format_str, klass_name, state, toten, ld_str, time, dir) end end end |