vasputils 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/Gemfile +1 -1
  2. data/VERSION +1 -1
  3. data/bin/lsvasp +90 -0
  4. data/bin/qsubvasp +42 -6
  5. data/bin/runvasp +35 -0
  6. data/lib/vasputils/calcinspector.rb +15 -15
  7. data/lib/vasputils/incar.rb +30 -30
  8. data/lib/vasputils/kpoints.rb +34 -34
  9. data/lib/vasputils/outcar.rb +45 -45
  10. data/lib/vasputils/poscar.rb +145 -145
  11. data/lib/vasputils/potcar.rb +12 -12
  12. data/lib/vasputils/vaspdir.rb +52 -77
  13. data/lib/vasputils/vaspgeomopt.rb +114 -0
  14. data/memo.txt +7 -0
  15. data/test/test_vaspdir.rb +24 -6
  16. data/test/test_vaspgeomopt.rb +95 -0
  17. data/test/{vaspdir/finished/lock → vaspgeomopt/ended-Iter1/try00/CONTCAR} +0 -0
  18. data/test/{vaspdir/locked/lock → vaspgeomopt/ended-Iter1/try00/INCAR} +0 -0
  19. data/test/{vaspdir/started/lock → vaspgeomopt/ended-Iter1/try00/KPOINTS} +0 -0
  20. data/test/vaspgeomopt/ended-Iter1/try00/OUTCAR +0 -0
  21. data/test/vaspgeomopt/ended-Iter1/try00/POSCAR +0 -0
  22. data/test/vaspgeomopt/ended-Iter1/try00/POTCAR +0 -0
  23. data/test/vaspgeomopt/ended-Iter1/try01/INCAR +0 -0
  24. data/test/vaspgeomopt/ended-Iter1/try01/KPOINTS +0 -0
  25. data/test/vaspgeomopt/ended-Iter1/try01/OUTCAR +16 -0
  26. data/test/vaspgeomopt/ended-Iter1/try01/POSCAR +0 -0
  27. data/test/vaspgeomopt/ended-Iter1/try01/POTCAR +0 -0
  28. data/test/vaspgeomopt/ended-Iter2/try00/CONTCAR +0 -0
  29. data/test/vaspgeomopt/ended-Iter2/try00/INCAR +0 -0
  30. data/test/vaspgeomopt/ended-Iter2/try00/KPOINTS +0 -0
  31. data/test/vaspgeomopt/ended-Iter2/try00/OUTCAR +0 -0
  32. data/test/vaspgeomopt/ended-Iter2/try00/POSCAR +0 -0
  33. data/test/vaspgeomopt/ended-Iter2/try00/POTCAR +0 -0
  34. data/test/vaspgeomopt/ended-Iter2/try01/INCAR +0 -0
  35. data/test/vaspgeomopt/ended-Iter2/try01/KPOINTS +0 -0
  36. data/test/vaspgeomopt/ended-Iter2/try01/OUTCAR +18 -0
  37. data/test/vaspgeomopt/ended-Iter2/try01/POSCAR +0 -0
  38. data/test/vaspgeomopt/ended-Iter2/try01/POTCAR +0 -0
  39. data/test/vaspgeomopt/not-yet/try00/INCAR +0 -0
  40. data/test/vaspgeomopt/not-yet/try00/KPOINTS +0 -0
  41. data/test/vaspgeomopt/not-yet/try00/POSCAR +0 -0
  42. data/test/vaspgeomopt/not-yet/try00/POTCAR +0 -0
  43. data/test/vaspgeomopt/prepare_next/try00/CHG +0 -0
  44. data/test/vaspgeomopt/prepare_next/try00/CHGCAR +0 -0
  45. data/test/vaspgeomopt/prepare_next/try00/CONTCAR +0 -0
  46. data/test/vaspgeomopt/prepare_next/try00/DOSCAR +0 -0
  47. data/test/vaspgeomopt/prepare_next/try00/EIGENVAL +0 -0
  48. data/test/vaspgeomopt/prepare_next/try00/INCAR +0 -0
  49. data/test/vaspgeomopt/prepare_next/try00/KPOINTS +0 -0
  50. data/test/vaspgeomopt/prepare_next/try00/OSZICAR +0 -0
  51. data/test/vaspgeomopt/prepare_next/try00/OUTCAR +0 -0
  52. data/test/vaspgeomopt/prepare_next/try00/PCDAT +0 -0
  53. data/test/vaspgeomopt/prepare_next/try00/POSCAR +0 -0
  54. data/test/vaspgeomopt/prepare_next/try00/POTCAR +0 -0
  55. data/test/vaspgeomopt/prepare_next/try00/WAVECAR +0 -0
  56. data/test/vaspgeomopt/prepare_next/try00/XDATCAR +0 -0
  57. data/test/vaspgeomopt/prepare_next/try00/vasprun.xml +0 -0
  58. data/test/vaspgeomopt/started/try00/INCAR +0 -0
  59. data/test/vaspgeomopt/started/try00/KPOINTS +0 -0
  60. data/test/vaspgeomopt/started/try00/POSCAR +0 -0
  61. data/test/vaspgeomopt/started/try00/POTCAR +0 -0
  62. data/test/vaspgeomopt/till01/try00/CONTCAR +0 -0
  63. data/test/vaspgeomopt/till01/try00/INCAR +0 -0
  64. data/test/vaspgeomopt/till01/try00/KPOINTS +0 -0
  65. data/test/vaspgeomopt/till01/try00/OUTCAR +0 -0
  66. data/test/vaspgeomopt/till01/try00/POSCAR +0 -0
  67. data/test/vaspgeomopt/till01/try00/POTCAR +0 -0
  68. data/test/vaspgeomopt/till01/try01/INCAR +0 -0
  69. data/test/vaspgeomopt/till01/try01/KPOINTS +0 -0
  70. data/test/vaspgeomopt/till01/try01/POSCAR +0 -0
  71. data/test/vaspgeomopt/till01/try01/POTCAR +0 -0
  72. data/vasputils.gemspec +66 -14
  73. metadata +86 -33
  74. data/bin/repeatvasp +0 -47
  75. data/lib/vasputils/calcrepeater.rb +0 -27
  76. data/lib/vasputils/calcseries.rb +0 -98
  77. data/test/test_calcrepeater.rb +0 -69
  78. data/test/test_calcseries.rb +0 -77
data/Gemfile CHANGED
@@ -14,6 +14,6 @@ group :development do
14
14
  gem "mageo", ">= 0.0.0"
15
15
  gem "malge", ">= 0.0.1"
16
16
  gem "maset", ">= 0.0.0"
17
- gem "comana", ">= 0.0.4"
17
+ gem "comana", ">= 0.0.5"
18
18
  gem "builtinextension", ">= 0.0.3"
19
19
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
data/bin/lsvasp ADDED
@@ -0,0 +1,90 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ # Show state of vasp geometry optimization calculations.
5
+
6
+ #require "vasputils/calcseries.rb"
7
+ require "vasputils/vaspgeomopt.rb"
8
+ require "optparse"
9
+
10
+ # option analysis
11
+ OPTIONS = Hash.new
12
+ op = OptionParser.new
13
+ op.on("-c", "--cutoff" , "Show cutoff energy. "){ OPTIONS[:cutoff ] = true }
14
+ op.on("-e", "--electronic-steps", "Show electronic-steps." ){ OPTIONS[:e_steps] = true }
15
+ op.on("-i", "--ionic-steps" , "Show ionic-steps." ){ OPTIONS[:i_steps] = true }
16
+ op.on("-k", "--k-mesh" , "Show k-mesh." ){ OPTIONS[:k_mesh] = true }
17
+ op.on("-K", "--irr-kpoints" , "Show irreducible k-points."){ OPTIONS[:irr_k ] = true }
18
+ op.on("-l", "--lattice-const" , "Show lattice constants."){ OPTIONS[:lattice] = true }
19
+ op.on("-t", "--elapsed-time" , "Show elapsed-time." ){ OPTIONS[:time ] = true }
20
+ op.on("-T", "--time-estesp" , "Show time per elec. steps."){ OPTIONS[:time_e] = true }
21
+ op.on("-E", "--toten" , "Show toten." ){ OPTIONS[:toten ] = true }
22
+ op.on("-a", "--all" , "Show all information." ){
23
+ # -a で出力される順序はここで決まる。
24
+ OPTIONS[:cutoff ] = true
25
+ OPTIONS[:irr_k ] = true
26
+ OPTIONS[:k_mesh ] = true
27
+ OPTIONS[:i_steps ] = true
28
+ OPTIONS[:e_steps ] = true
29
+ OPTIONS[:time ] = true
30
+ OPTIONS[:time_e ] = true
31
+ OPTIONS[:lattice ] = true
32
+ OPTIONS[:toten ] = true
33
+ }
34
+
35
+ op.parse!(ARGV)
36
+
37
+ dirs = ARGV
38
+ dirs = Dir.glob("*").sort if ARGV.empty?
39
+
40
+ ## generate headline
41
+ #items = []
42
+ #OPTIONS.each do |key, val|
43
+ # case key
44
+ # when :cutoff then items << sprintf("%6s", "ENCUT")
45
+ # when :k_mesh then items << sprintf("%2s, %2s, %2s, %8s, %8s, %8s",
46
+ # "ka", "kb", "kc", "ka_shift", "kb_shift", "kc_shift")
47
+ # when :irr_k then items << sprintf("%4s", "ir_k")
48
+ # when :lattice then
49
+ # items << sprintf("%9s, %9s, %9s, %9s, %9s, %9s",
50
+ # "a", "b", "c", "alpha", "beta", "gamma")
51
+ # when :e_steps then items << sprintf("%4s", "el_s")
52
+ # when :i_steps then items << sprintf("%4s", "io_s")
53
+ # when :time then items << sprintf("%8s", "time")
54
+ # when :time_e then items << sprintf("%8s", "time/ele")
55
+ # when :toten then items << sprintf("%16s", "TOTEN")
56
+ # end
57
+ #end
58
+ #items << "calc_name"
59
+ #puts "#" + items.join(", ")
60
+
61
+ dirs.each do |dir|
62
+ begin
63
+ ldir = VaspGeomOpt.new(dir).latest_dir
64
+ results = []
65
+ names = []
66
+ OPTIONS.each do |key, val|
67
+ case key
68
+ when :cutoff
69
+ results << sprintf("%6s", ldir.finished_calc.incar["ENCUT"])
70
+ when :k_mesh then results << sprintf("%2d, %2d, %2d, %8.5f, %8.5f, %8.5f",
71
+ * ldir.finished_calc.kpoints[:mesh], * ldir.finished_calc.kpoints[:shift])
72
+ when :irr_k then results << sprintf("%4d", ldir.finished_calc.outcar[:irreducible_kpoints])
73
+ when :lattice then
74
+ results << sprintf("%9.5f, %9.5f, %9.5f, %9.5f, %9.5f, %9.5f",
75
+ * ldir.finished_calc.contcar.axes.get_lattice_constants)
76
+ when :e_steps then results << sprintf("%4d", ldir.internal_steps)
77
+ when :i_steps then results << sprintf("%4d", ldir.external_steps)
78
+ when :time then results << sprintf("%8d", ldir.elapsed_time)
79
+ when :time_e then results << sprintf("%8d", ldir.elapsed_time/ldir.internal_steps)
80
+ when :toten then results << sprintf("%16.4f", ldir.finished_calc.outcar[:totens][-1])
81
+ end
82
+ end
83
+ results << dir
84
+ puts " " + results.join(", ")
85
+ rescue
86
+ puts "Something wrong: #{dir}"
87
+ next
88
+ end
89
+
90
+ end
data/bin/qsubvasp CHANGED
@@ -1,17 +1,24 @@
1
1
  #! /usr/bin/env ruby
2
2
  # coding: utf-8
3
3
 
4
+
5
+ SCRIPT_FILE = "pbs.sh"
6
+ PBS_LOG = "pbs.log"
7
+
8
+
4
9
  require "optparse"
10
+ require "yaml"
11
+ require "pp"
5
12
 
6
13
  ## option analysis
7
14
  OPTS = {}
8
15
  op = OptionParser.new
9
- op.on("-e", "--economy" , "Prior efficiency."){OPTS[:e] = true}
16
+ #op.on("-e", "--economy" , "Prior efficiency."){OPTS[:e] = true}
10
17
  op.on("-s", "--speed" , "Prior speed.") {OPTS[:s] = true}
11
18
 
12
19
  op.on("-g", "--geom-opt" , "Geometry optimization.") {OPTS[:g] = true}
13
- op.on("-n", "--nebm" , "Nudged Elastic Band method."){OPTS[:n] = true}
14
- op.on("-c", "--cond-find", "Condition Finding.") {OPTS[:c] = true}
20
+ #op.on("-n", "--nebm" , "Nudged Elastic Band method."){OPTS[:n] = true}
21
+ #op.on("-c", "--cond-find", "Condition Finding.") {OPTS[:c] = true}
15
22
 
16
23
  op.parse!(ARGV)
17
24
 
@@ -20,11 +27,40 @@ cluster = ARGV[0]
20
27
  #qsub で複数のクラスターを候補に入れることができるか?e.g., Ga, Ge
21
28
  #それによって、ここがかきかわる。
22
29
 
23
- puts "Options -e and -s cannot be duplicated." if OPTS[:e] && OPTS[:s]
24
- if [OPTS[:g], OPTS[:n], OPTS[:c]].select_all(true).size ==
25
- puts "Options -g, -n, and -c cannot be duplicated."
30
+ #puts "Options -e and -s cannot be duplicated." if OPTS[:e] && OPTS[:s]
31
+ #if [OPTS[:g], OPTS[:n], OPTS[:c]].select_all(true).size ==
32
+ # puts "Options -g, -n, and -c cannot be duplicated."
33
+ # exit
34
+ #end
35
+
36
+ yaml = YAML.load_file("#{ENV["HOME"]}/.machineinfo")
37
+ pp yaml
38
+
39
+ if File.exits?(SCRIPT_FILE)
40
+ puts "#{SCRIPT_FILE} already exist. Exit."
26
41
  exit
27
42
  end
28
43
 
44
+ File.open(SCRIPT_FILE, "w") do |io|
45
+ io.puts "#PBS -N task"
46
+ io.puts "#PBS -l nodes=4:ppn=1:Ga"
47
+ io.puts "cd $PBS_O_WORKDIR"
48
+ io.puts "vaspgeomopt"
49
+ #io.puts "#/usr/local/bin/mpiexec /usr/local/bin/vasp5212mpi-ifc11-fast"
50
+ #io.puts "#/home/ippei/local/mpi/mpiexec-0.84/mpiexec /usr/local/calc/bin/vasp5212-mpich2"
51
+ #io.puts "#/usr/local/calc/mpiexec/bin/mpiexec /usr/local/calc/bin/vasp5212-mpich2"
52
+ #io.puts "#~/tmp.rb #OK"
53
+
54
+ #io.puts condition
55
+ #io.puts rsync
56
+ #io.puts run
57
+ #io.puts rsync
58
+ #io.puts mv to trash?
59
+ end
29
60
 
61
+ # Record job_id in pbs. Overwrite if exists.
62
+ job_id = `qsub #{SCRIPT_FILE}`
63
+ File.open(PBS_LOG, "w") do |io|
64
+ io.puts job_id
65
+ end
30
66
 
data/bin/runvasp ADDED
@@ -0,0 +1,35 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+
5
+ require "rubygems"
6
+ gem "vasputils"
7
+ require "vasputils/vaspdir.rb"
8
+ require "vasputils/vaspgeomopt.rb"
9
+
10
+ require "optparse"
11
+
12
+ ## option analysis
13
+ OPTIONS = {}
14
+ op = OptionParser.new
15
+ op.on("-g" , "--geom-opt", "Geometry optimization"){OPTIONS[:g] = true}
16
+ #op.on("-b val", "--bak=val", "descriptionB"){|v| OPTIONS[:bak] = v}
17
+ op.parse!(ARGV)
18
+
19
+
20
+ dir = ARGV[0] || "."
21
+
22
+ if OPTIONS[:g]
23
+ calc_dir = VaspGeomOpt.new(dir)
24
+ else
25
+ calc_dir = VaspDir.new(dir)
26
+ end
27
+
28
+ #pp calc_dir
29
+
30
+ begin
31
+ calc_dir.start
32
+ rescue Comana::AlreadyStartedError
33
+ puts "Already started. Exit."
34
+ exit
35
+ end
@@ -3,22 +3,22 @@
3
3
 
4
4
  # 計算の状態を解析するクラス。
5
5
  class CalcInspector
6
- #
7
- #def initialize
8
- #end
6
+ #
7
+ #def initialize
8
+ #end
9
9
 
10
- # 引数 calc で渡された計算の状態を返す。
11
- # calc は以下のメソッドを持つ必要がある。
12
- # - started?
13
- # - normal_ended?
14
- # - to_be_continued?
15
- def self.inspect(calc)
16
- return "YET" unless calc.started?
17
- return "STARTED" unless calc.normal_ended?
18
- return "NEXT" if calc.to_be_continued?
19
- return "FINISHED"
20
- #raise "must not occur"
21
- end
10
+ # 引数 calc で渡された計算の状態を返す。
11
+ # calc は以下のメソッドを持つ必要がある。
12
+ # - started?
13
+ # - normal_ended?
14
+ # - to_be_continued?
15
+ def self.inspect(calc)
16
+ return "YET" unless calc.started?
17
+ return "STARTED" unless calc.normal_ended?
18
+ return "NEXT" if calc.to_be_continued?
19
+ return "FINISHED"
20
+ #raise "must not occur"
21
+ end
22
22
 
23
23
  end
24
24
 
@@ -18,38 +18,38 @@
18
18
  # まず、自分で使う範囲だけ作る。
19
19
  # あとで余力があれば精密化する。
20
20
  module Incar
21
- #
22
- #def initialize()
23
- #end
24
-
25
- # 与えられた IO を読み込み、INCAR として解析したハッシュを返す。
26
- def self.parse(io)
27
- results = {}
28
- io.each_line do |line|
29
- line.sub!(/\#.*/, "") # コメント文字以降を削除
30
- next unless /=/ =~ line
31
- if /(.*)=(.*)/ =~ line
32
- key = $1.strip
33
- val = $2.strip
34
- val.sub!(/\s.*$/, "")
35
- next if key.empty?
36
- results[key] = val
37
- end
38
- end
39
- return results
40
- end
21
+ #
22
+ #def initialize()
23
+ #end
24
+
25
+ # 与えられた IO を読み込み、INCAR として解析したハッシュを返す。
26
+ def self.parse(io)
27
+ results = {}
28
+ io.each_line do |line|
29
+ line.sub!(/\#.*/, "") # コメント文字以降を削除
30
+ next unless /=/ =~ line
31
+ if /(.*)=(.*)/ =~ line
32
+ key = $1.strip
33
+ val = $2.strip
34
+ val.sub!(/\s.*$/, "")
35
+ next if key.empty?
36
+ results[key] = val
37
+ end
38
+ end
39
+ return results
40
+ end
41
41
 
42
- # 与えられた名前のファイルを INCAR として解析したハッシュを返す。
43
- def self.load_file(file)
44
- io = File.open(file, "r")
45
- return self.parse(io)
46
- end
42
+ # 与えられた名前のファイルを INCAR として解析したハッシュを返す。
43
+ def self.load_file(file)
44
+ io = File.open(file, "r")
45
+ return self.parse(io)
46
+ end
47
47
 
48
- ## 与えられたデータ対(ハッシュ)を io に書き出す。
49
- ## io が nil の場合は INCAR 形式文字列を返す。
50
- ## (改行文字を埋め込んでおり、配列化していない)
51
- #def dump(pairs, io = nil)
52
- #end
48
+ ## 与えられたデータ対(ハッシュ)を io に書き出す。
49
+ ## io が nil の場合は INCAR 形式文字列を返す。
50
+ ## (改行文字を埋め込んでおり、配列化していない)
51
+ #def dump(pairs, io = nil)
52
+ #end
53
53
 
54
54
  end
55
55
 
@@ -3,39 +3,39 @@
3
3
 
4
4
  # Module dearing with KPOINTS.
5
5
  module Kpoints
6
- def self.parse(io)
7
- results = {}
8
- results[:comment] = io.readline.chomp
9
-
10
- raise "Not automatic generating KPOINTS! 2nd line must be 0." unless io.readline == "0\n"
11
-
12
- line = io.readline
13
- case line
14
- when /^m/i; then; results[:type] = :monkhorst
15
- when /^g/i; then; results[:type] = :gamma_center
16
- else
17
- raise "Kpoints module can deal with only monkhorst and gamma-center."
18
- end
19
-
20
- #pp io.readline.strip.split(/\s+/).map{|i| i.to_i}
21
- results[:mesh] = io.readline.strip.split(/\s+/).map{|i| i.to_i}
22
- #pp io.readline.strip.split(/\s+/).map{|i| i.to_f}
23
- results[:shift] = io.readline.strip.split(/\s+/).map{|i| i.to_f}
24
-
25
- return results
26
- end
27
-
28
- #
29
- def self.load_file(file)
30
- self.parse(File.open(file, "r"))
31
- end
32
-
33
- def self.dump(data, io)
34
- io.puts "Automatic mesh"
35
- io.puts "0"
36
- io.puts data[:type].to_s.capitalize
37
- io.puts data[:mesh].join(" ")
38
- io.puts data[:shift].join(" ")
39
- end
6
+ def self.parse(io)
7
+ results = {}
8
+ results[:comment] = io.readline.chomp
9
+
10
+ raise "Not automatic generating KPOINTS! 2nd line must be 0." unless io.readline == "0\n"
11
+
12
+ line = io.readline
13
+ case line
14
+ when /^m/i; then; results[:type] = :monkhorst
15
+ when /^g/i; then; results[:type] = :gamma_center
16
+ else
17
+ raise "Kpoints module can deal with only monkhorst and gamma-center."
18
+ end
19
+
20
+ #pp io.readline.strip.split(/\s+/).map{|i| i.to_i}
21
+ results[:mesh] = io.readline.strip.split(/\s+/).map{|i| i.to_i}
22
+ #pp io.readline.strip.split(/\s+/).map{|i| i.to_f}
23
+ results[:shift] = io.readline.strip.split(/\s+/).map{|i| i.to_f}
24
+
25
+ return results
26
+ end
27
+
28
+ #
29
+ def self.load_file(file)
30
+ self.parse(File.open(file, "r"))
31
+ end
32
+
33
+ def self.dump(data, io)
34
+ io.puts "Automatic mesh"
35
+ io.puts "0"
36
+ io.puts data[:type].to_s.capitalize
37
+ io.puts data[:mesh].join(" ")
38
+ io.puts data[:shift].join(" ")
39
+ end
40
40
  end
41
41
 
@@ -11,49 +11,49 @@
11
11
  # OUTCAR は終了する前も含めてなんか簡単に見るために使う、という位置付けで。
12
12
 
13
13
  module Outcar
14
- #toten は全 electronic and ionic steps のを flat に並べただけのもの。
15
- #必要なら構造化するが、現状その予定はない。
16
- #attr_reader :name
17
- #attr_reader :ionic_steps, :electronic_steps, :totens, :volumes, :elapsed_time
18
-
19
- def self.load_file(file)
20
- results = {}
21
- results[:name] = file
22
- results[:irreducible_kpoints] = nil
23
- results[:electronic_steps ] = 0
24
- results[:ionic_steps ] = 0
25
- results[:totens ] = []
26
- results[:volumes ] = []
27
- results[:elapsed_time ] = nil
28
- results[:normal_ended ] = false
29
-
30
- lines = File.readlines(file)
31
- lines.each do |line|
32
- if /Found\s+(\d+)\s+irreducible k-points/i =~ line
33
- results[:irreducible_kpoints] = $1.to_i
34
- end
35
-
36
- if /^-* Iteration\s+(\d+)/ =~ line
37
- results[:ionic_steps ] = $1.to_i
38
- results[:electronic_steps] += 1
39
- end
40
-
41
- #if /free\s+energy\s+TOTEN\s+=\s(.*)\s+eV/ =~ line
42
- if /TOTEN\s+=\s(.*)\s+eV/ =~ line
43
- results[:totens] << $1.to_f
44
- end
45
-
46
- if /volume of cell :\s+(\d+\.\d+)$/ =~ line
47
- results[:volumes] << $1.to_f
48
- end
49
-
50
- if (/Elapsed time \(sec\):\s+(\d+\.\d+)/ =~ line)
51
- results[:elapsed_time] = $1.to_f
52
- end
53
- end
54
-
55
- results[:normal_ended] = true if (/Voluntary context switches:/ =~ lines[-1])
56
-
57
- results
58
- end
14
+ #toten は全 electronic and ionic steps のを flat に並べただけのもの。
15
+ #必要なら構造化するが、現状その予定はない。
16
+ #attr_reader :name
17
+ #attr_reader :ionic_steps, :electronic_steps, :totens, :volumes, :elapsed_time
18
+
19
+ def self.load_file(file)
20
+ results = {}
21
+ results[:name] = file
22
+ results[:irreducible_kpoints] = nil
23
+ results[:electronic_steps ] = 0
24
+ results[:ionic_steps ] = 0
25
+ results[:totens ] = []
26
+ results[:volumes ] = []
27
+ results[:elapsed_time ] = nil
28
+ results[:normal_ended ] = false
29
+
30
+ lines = File.readlines(file)
31
+ lines.each do |line|
32
+ if /Found\s+(\d+)\s+irreducible k-points/i =~ line
33
+ results[:irreducible_kpoints] = $1.to_i
34
+ end
35
+
36
+ if /^-* Iteration\s+(\d+)/ =~ line
37
+ results[:ionic_steps ] = $1.to_i
38
+ results[:electronic_steps] += 1
39
+ end
40
+
41
+ #if /free\s+energy\s+TOTEN\s+=\s(.*)\s+eV/ =~ line
42
+ if /TOTEN\s+=\s(.*)\s+eV/ =~ line
43
+ results[:totens] << $1.to_f
44
+ end
45
+
46
+ if /volume of cell :\s+(\d+\.\d+)$/ =~ line
47
+ results[:volumes] << $1.to_f
48
+ end
49
+
50
+ if (/Elapsed time \(sec\):\s+(\d+\.\d+)/ =~ line)
51
+ results[:elapsed_time] = $1.to_f
52
+ end
53
+ end
54
+
55
+ results[:normal_ended] = true if (/Voluntary context switches:/ =~ lines[-1])
56
+
57
+ results
58
+ end
59
59
  end