vasputils 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,27 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require "pp"
5
- #
6
- #
7
- #
8
- class CalcRepeater
9
-
10
- #def initialize
11
- #end
12
-
13
- # 引数 calc は以下のメソッドを持っている必要がある。
14
- def repeat(calc, io = STDOUT)
15
- while true
16
- io.puts "Calculation started: #{calc.name}."
17
- calc.calculate
18
- break unless calc.normal_ended?
19
- break unless calc.to_be_continued?
20
- calc.next
21
- io.puts "Next to #{calc.name}."
22
- end
23
- calc.teardown
24
- puts "Calculation got converged: #{calc.name}."
25
- end
26
- end
27
-
@@ -1,98 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require "vasputils/vaspdir.rb"
5
-
6
- # 連続性のある一連の計算を表現するクラス。
7
- # 収束までに何度も繰り返すような計算を想定し、
8
- # これらが1つのディレクトリにまとめられていることを前提とする。
9
- # 計算は ASCII ソートできる順に
10
- # 名前が付けられていることを前提とする。
11
- class CalcSeries
12
-
13
- class FinishedCalcError < Exception; end
14
-
15
- #
16
- def initialize(dir)
17
- @dir = dir
18
- @calculations = belonged_calculations
19
- end
20
-
21
- # Guess and return calculation type of an rgument 'file'.
22
- # Argument 'file' can be a normal file or a directory.
23
- # Return a calc class instance, e.g., VaspDir.
24
- # If the file is unknown type, raise CalcSeriesUnknownCalcError
25
- #
26
- # MEMO: Now, always return VaspDir.
27
- def self.guess(file)
28
- return VaspDir
29
- end
30
-
31
- # Return the final calculation that achieve to be convergence,
32
- # whose state is FINISHED.
33
- # If there are multiple FINISHED calcs,
34
- # raise CalcSeriesMultipleFinishedError.
35
- # If there is no FINISHED calcs, return nil.
36
- def finished_calc
37
- #tmp = @calculations.select{|calc| calc.normal_ended? && (! calc.to_be_continued?)}
38
- tmp = @calculations.select{|calc| (! calc.to_be_continued?)}
39
- #pp tmp.size
40
- if tmp.size > 1
41
- message = "Multiplicated finished calcs; #{tmp.map{|calc| calc.name}.join(', ')}"
42
- raise FinishedCalcError, message
43
- elsif tmp.size == 0
44
- message = "No finished calc."
45
- raise FinishedCalcError, message
46
- else
47
- return tmp[0]
48
- end
49
- end
50
-
51
- # Return sum of number of 'internal steps',
52
- # whish is returned by 'internal_steps' of each calculation.
53
- # E.g., in case of VaspDir/try01, try02,...
54
- # internal_steps of VaspDir/try01 was 10,
55
- # internal_steps of VaspDir/try02 was 3,
56
- def internal_steps
57
- @calculations.inject(0.0) do |sum, item|
58
- sum += item.internal_steps
59
- end
60
- end
61
-
62
- # 外部ループ。
63
- # vaspdir では ionic steps を返す筈。
64
- def external_steps
65
- @calculations.inject(0.0) do |sum, item|
66
- sum += item.external_steps
67
- end
68
- end
69
-
70
- # 全ての経過時間の合計を返す。
71
- def elapsed_time
72
- @calculations.inject(0.0) do |sum, item|
73
- sum += item.elapsed_time
74
- end
75
- end
76
-
77
- # 最後の計算が normal_ended ならば true。
78
- # それ以外は false
79
- def normal_ended?
80
- begin
81
- #pp finished_calc
82
- return finished_calc.normal_ended?
83
- rescue FinishedCalcError
84
- return false
85
- end
86
- end
87
-
88
- private
89
-
90
- # 配下の calculation を VaspDir のようなインスタンスにし、
91
- # それらをまとめた配列を返す。
92
- def belonged_calculations
93
- Dir.glob("#{@dir}/*").sort.map do |file|
94
- self.class.guess(file).new(file)
95
- end
96
- end
97
- end
98
-
@@ -1,69 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require "test/unit"
5
- require "stringio"
6
- require "vasputils/calcrepeater.rb"
7
-
8
- # assert_equal( cor, data)
9
- # assert_in_delta( cor, data, $tolerance )
10
- # assert_raise( RuntimeError ){}
11
-
12
- class DummyCalc
13
- attr_reader :num
14
-
15
- def initialize
16
- @num = 0
17
- @internal_steps = 0
18
- @lock = false
19
- end
20
-
21
- def calculatable?
22
- return (! @lock)
23
- end
24
-
25
- def calculate
26
- @lock = true
27
- # calculate
28
- 10.times { @internal_steps += 1 }
29
- end
30
-
31
- def normal_ended?
32
- return @internal_steps == 10
33
- end
34
-
35
- def to_be_continued?
36
- return @num < 3
37
- end
38
-
39
- def next
40
- @num += 1
41
- @lock = false
42
- @internal_steps = 0
43
- end
44
-
45
- def teardown
46
- # do nothing
47
- end
48
-
49
- def name
50
- "calc00"
51
- end
52
- end
53
-
54
- class TC_CalcRepeater < Test::Unit::TestCase
55
- def setup
56
- @cr00 = CalcRepeater.new
57
- @dc00 = DummyCalc.new
58
- end
59
-
60
- def test_repeat
61
- io = StringIO.new
62
- assert_equal(0, @dc00.num)
63
- @cr00.repeat(@dc00, io)
64
- assert_equal(3, @dc00.num)
65
- end
66
-
67
-
68
- end
69
-
@@ -1,77 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require "test/unit"
5
- require "vasputils/calcseries.rb"
6
-
7
- class CalcSeries
8
- public :belonged_calculations
9
- end
10
-
11
- class TC_CalcSeries < Test::Unit::TestCase
12
- def setup
13
- @cs00 = CalcSeries.new("test/calcseries/dup_finished" )
14
- @cs01 = CalcSeries.new("test/calcseries/normal_finished")
15
- @cs02 = CalcSeries.new("test/calcseries/not_finished" )
16
- end
17
-
18
- def test_self_guess
19
- assert_equal(VaspDir, CalcSeries.guess("test/calcseries/dup_finished" ))
20
- assert_equal(VaspDir, CalcSeries.guess("test/calcseries/normal_finished"))
21
- assert_equal(VaspDir, CalcSeries.guess("test/calcseries/not_finished" ))
22
- end
23
-
24
- def test_finished_calc
25
- assert_raise(CalcSeries::FinishedCalcError){@cs00.finished_calc}
26
- assert_equal("test/calcseries/normal_finished/try01", @cs01.finished_calc.name)
27
- assert_raise(CalcSeries::FinishedCalcError){@cs02.finished_calc}
28
- end
29
-
30
- # def test_internal_steps
31
- # assert_equal(26, @cs00.internal_steps)
32
- # assert_equal(36, @cs01.internal_steps)
33
- # assert_equal(23, @cs02.internal_steps)
34
- # end
35
- #
36
- # def test_external_steps
37
- # assert_equal(2, @cs00.external_steps)
38
- # assert_equal(4, @cs01.external_steps)
39
- # assert_equal(3, @cs02.external_steps)
40
- # end
41
- #
42
- # def test_elapsed_time
43
- # assert_in_delta(328.268, @cs00.elapsed_time)
44
- # assert_in_delta(328.268, @cs01.elapsed_time)
45
- # assert_in_delta(164.134, @cs02.elapsed_time)
46
- # end
47
- #
48
- # def test_belonged_calculations
49
- # t = @cs00.belonged_calculations
50
- # assert_equal(2, t.size)
51
- # assert_equal(VaspDir, t[0].class)
52
- # assert_equal(VaspDir, t[1].class)
53
- # #pp t
54
- # assert_equal("test/calcseries/dup_finished/try00", t[0].name)
55
- # assert_equal("test/calcseries/dup_finished/try01", t[1].name)
56
- #
57
- # t = @cs01.belonged_calculations
58
- # assert_equal(2, t.size)
59
- # assert_equal(VaspDir, t[0].class)
60
- # assert_equal(VaspDir, t[1].class)
61
- # assert_equal("test/calcseries/normal_finished/try00", t[0].name)
62
- # assert_equal("test/calcseries/normal_finished/try01", t[1].name)
63
- #
64
- # t = @cs02.belonged_calculations
65
- # assert_equal(1, t.size)
66
- # assert_equal(VaspDir, t[0].class)
67
- # assert_equal("test/calcseries/not_finished/try00", t[0].name)
68
- # end
69
- #
70
- # def test_normal_ended?
71
- # assert_equal(false, @cs00.normal_ended?)
72
- # assert_equal(true , @cs01.normal_ended?)
73
- # assert_equal(false, @cs02.normal_ended?)
74
- # end
75
-
76
- end
77
-