vasputils 0.0.0

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 (209) hide show
  1. data/.document +5 -0
  2. data/Gemfile +18 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.rdoc +19 -0
  5. data/Rakefile +54 -0
  6. data/VERSION +1 -0
  7. data/bin/addVolumeToten.rb +19 -0
  8. data/bin/latticeconstants +14 -0
  9. data/bin/lsvaspdir +60 -0
  10. data/bin/lsvaspseries +95 -0
  11. data/bin/repeatvasp +47 -0
  12. data/bin/symposcar +154 -0
  13. data/lib/vasputils/calcinspector.rb +24 -0
  14. data/lib/vasputils/calcrepeater.rb +27 -0
  15. data/lib/vasputils/calcseries.rb +98 -0
  16. data/lib/vasputils/incar.rb +55 -0
  17. data/lib/vasputils/kpoints.rb +41 -0
  18. data/lib/vasputils/outcar.rb +59 -0
  19. data/lib/vasputils/poscar.rb +168 -0
  20. data/lib/vasputils/potcar.rb +18 -0
  21. data/lib/vasputils/vaspdir.rb +278 -0
  22. data/lib/vasputils.rb +0 -0
  23. data/test/calcseries/dup_finished/try00/CONTCAR +17 -0
  24. data/test/calcseries/dup_finished/try00/INCAR +28 -0
  25. data/test/calcseries/dup_finished/try00/KPOINTS +6 -0
  26. data/test/calcseries/dup_finished/try00/OUTCAR +28 -0
  27. data/test/calcseries/dup_finished/try00/POSCAR +12 -0
  28. data/test/calcseries/dup_finished/try00/POTCAR +2 -0
  29. data/test/calcseries/dup_finished/try00/lock +0 -0
  30. data/test/calcseries/dup_finished/try01/CONTCAR +17 -0
  31. data/test/calcseries/dup_finished/try01/INCAR +28 -0
  32. data/test/calcseries/dup_finished/try01/KPOINTS +6 -0
  33. data/test/calcseries/dup_finished/try01/OUTCAR +28 -0
  34. data/test/calcseries/dup_finished/try01/POSCAR +12 -0
  35. data/test/calcseries/dup_finished/try01/POTCAR +2 -0
  36. data/test/calcseries/dup_finished/try01/lock +0 -0
  37. data/test/calcseries/normal_finished/try00/CONTCAR +17 -0
  38. data/test/calcseries/normal_finished/try00/INCAR +28 -0
  39. data/test/calcseries/normal_finished/try00/KPOINTS +6 -0
  40. data/test/calcseries/normal_finished/try00/OUTCAR +40 -0
  41. data/test/calcseries/normal_finished/try00/POSCAR +12 -0
  42. data/test/calcseries/normal_finished/try00/POTCAR +2 -0
  43. data/test/calcseries/normal_finished/try00/lock +0 -0
  44. data/test/calcseries/normal_finished/try01/CONTCAR +17 -0
  45. data/test/calcseries/normal_finished/try01/INCAR +28 -0
  46. data/test/calcseries/normal_finished/try01/KPOINTS +6 -0
  47. data/test/calcseries/normal_finished/try01/OUTCAR +33 -0
  48. data/test/calcseries/normal_finished/try01/POSCAR +12 -0
  49. data/test/calcseries/normal_finished/try01/POTCAR +2 -0
  50. data/test/calcseries/normal_finished/try01/lock +0 -0
  51. data/test/calcseries/not_finished/try00/CONTCAR +17 -0
  52. data/test/calcseries/not_finished/try00/INCAR +28 -0
  53. data/test/calcseries/not_finished/try00/KPOINTS +6 -0
  54. data/test/calcseries/not_finished/try00/OUTCAR +38 -0
  55. data/test/calcseries/not_finished/try00/POSCAR +12 -0
  56. data/test/calcseries/not_finished/try00/POTCAR +2 -0
  57. data/test/calcseries/not_finished/try00/lock +0 -0
  58. data/test/helper.rb +17 -0
  59. data/test/incar/INCAR.00 +35 -0
  60. data/test/incar/INCAR.01 +28 -0
  61. data/test/kpoints/g123-456 +6 -0
  62. data/test/kpoints/m123-456 +6 -0
  63. data/test/outcar/01-03-INT.OUTCAR +619 -0
  64. data/test/outcar/01-13-FIN.OUTCAR +1436 -0
  65. data/test/outcar/02-05-FIN.OUTCAR +2025 -0
  66. data/test/outcar/03-05-FIN.OUTCAR +2602 -0
  67. data/test/outcar/10-01-FIN.OUTCAR +437 -0
  68. data/test/poscar/NOT_POSCAR +0 -0
  69. data/test/poscar/POSCAR.00 +10 -0
  70. data/test/poscar/POSCAR.01 +12 -0
  71. data/test/poscarparser/POSCAR.00 +10 -0
  72. data/test/poscarparser/POSCAR.01 +12 -0
  73. data/test/potcar/POTCAR +5279 -0
  74. data/test/potcar/POTCAR.allElement +165 -0
  75. data/test/potcar/POTCAR.dummy +3 -0
  76. data/test/repeatVasp/Iter2-Nsw2.00/INCAR +35 -0
  77. data/test/repeatVasp/Iter2-Nsw2.00/KPOINTS +6 -0
  78. data/test/repeatVasp/Iter2-Nsw2.00/POSCAR +12 -0
  79. data/test/repeatVasp/Iter2-Nsw2.00/POTCAR +3151 -0
  80. data/test/repeatVasp/test.sh +3 -0
  81. data/test/test_calcinspector.rb +53 -0
  82. data/test/test_calcrepeater.rb +69 -0
  83. data/test/test_calcseries.rb +77 -0
  84. data/test/test_incar.rb +126 -0
  85. data/test/test_kpoints.rb +110 -0
  86. data/test/test_outcar.rb +162 -0
  87. data/test/test_poscar.rb +209 -0
  88. data/test/test_potcar.rb +65 -0
  89. data/test/test_vaspdir.rb +253 -0
  90. data/test/vaspdir/IBRION-1-NSW000-OUTCAR-Iter1/CONTCAR +17 -0
  91. data/test/vaspdir/IBRION-1-NSW000-OUTCAR-Iter1/INCAR +27 -0
  92. data/test/vaspdir/IBRION-1-NSW000-OUTCAR-Iter1/KPOINTS +6 -0
  93. data/test/vaspdir/IBRION-1-NSW000-OUTCAR-Iter1/OUTCAR +1436 -0
  94. data/test/vaspdir/IBRION-1-NSW000-OUTCAR-Iter1/POSCAR +12 -0
  95. data/test/vaspdir/IBRION-1-NSW000-OUTCAR-Iter1/POTCAR +3151 -0
  96. data/test/vaspdir/IBRION-1-NSW000-OUTCAR-Iter1/lock +0 -0
  97. data/test/vaspdir/ISIF2-NSW000-OUTCAR-Iter1/CONTCAR +17 -0
  98. data/test/vaspdir/ISIF2-NSW000-OUTCAR-Iter1/INCAR +28 -0
  99. data/test/vaspdir/ISIF2-NSW000-OUTCAR-Iter1/KPOINTS +6 -0
  100. data/test/vaspdir/ISIF2-NSW000-OUTCAR-Iter1/OUTCAR +1436 -0
  101. data/test/vaspdir/ISIF2-NSW000-OUTCAR-Iter1/POSCAR +12 -0
  102. data/test/vaspdir/ISIF2-NSW000-OUTCAR-Iter1/POTCAR +3151 -0
  103. data/test/vaspdir/ISIF2-NSW000-OUTCAR-Iter1/lock +0 -0
  104. data/test/vaspdir/ISIF2-NSW001-OUTCAR-Iter1/CONTCAR +17 -0
  105. data/test/vaspdir/ISIF2-NSW001-OUTCAR-Iter1/INCAR +28 -0
  106. data/test/vaspdir/ISIF2-NSW001-OUTCAR-Iter1/KPOINTS +6 -0
  107. data/test/vaspdir/ISIF2-NSW001-OUTCAR-Iter1/OUTCAR +1436 -0
  108. data/test/vaspdir/ISIF2-NSW001-OUTCAR-Iter1/POSCAR +12 -0
  109. data/test/vaspdir/ISIF2-NSW001-OUTCAR-Iter1/POTCAR +3151 -0
  110. data/test/vaspdir/ISIF2-NSW001-OUTCAR-Iter1/lock +0 -0
  111. data/test/vaspdir/ISIF2-NSW100-OUTCAR-Iter1/CONTCAR +17 -0
  112. data/test/vaspdir/ISIF2-NSW100-OUTCAR-Iter1/INCAR +28 -0
  113. data/test/vaspdir/ISIF2-NSW100-OUTCAR-Iter1/KPOINTS +6 -0
  114. data/test/vaspdir/ISIF2-NSW100-OUTCAR-Iter1/OUTCAR +1436 -0
  115. data/test/vaspdir/ISIF2-NSW100-OUTCAR-Iter1/POSCAR +12 -0
  116. data/test/vaspdir/ISIF2-NSW100-OUTCAR-Iter1/POTCAR +3151 -0
  117. data/test/vaspdir/ISIF2-NSW100-OUTCAR-Iter1/lock +0 -0
  118. data/test/vaspdir/ISIF2-NSW100-OUTCAR-Iter3/CONTCAR +17 -0
  119. data/test/vaspdir/ISIF2-NSW100-OUTCAR-Iter3/INCAR +28 -0
  120. data/test/vaspdir/ISIF2-NSW100-OUTCAR-Iter3/KPOINTS +6 -0
  121. data/test/vaspdir/ISIF2-NSW100-OUTCAR-Iter3/OUTCAR +2602 -0
  122. data/test/vaspdir/ISIF2-NSW100-OUTCAR-Iter3/POSCAR +12 -0
  123. data/test/vaspdir/ISIF2-NSW100-OUTCAR-Iter3/POTCAR +3151 -0
  124. data/test/vaspdir/ISIF2-NSW100-OUTCAR-Iter3/lock +0 -0
  125. data/test/vaspdir/ISIF3-NSW000-OUTCAR-Iter1/CONTCAR +17 -0
  126. data/test/vaspdir/ISIF3-NSW000-OUTCAR-Iter1/INCAR +28 -0
  127. data/test/vaspdir/ISIF3-NSW000-OUTCAR-Iter1/KPOINTS +6 -0
  128. data/test/vaspdir/ISIF3-NSW000-OUTCAR-Iter1/OUTCAR +1436 -0
  129. data/test/vaspdir/ISIF3-NSW000-OUTCAR-Iter1/POSCAR +12 -0
  130. data/test/vaspdir/ISIF3-NSW000-OUTCAR-Iter1/POTCAR +3151 -0
  131. data/test/vaspdir/ISIF3-NSW000-OUTCAR-Iter1/lock +0 -0
  132. data/test/vaspdir/ISIF3-NSW001-OUTCAR-Iter1/CONTCAR +17 -0
  133. data/test/vaspdir/ISIF3-NSW001-OUTCAR-Iter1/INCAR +28 -0
  134. data/test/vaspdir/ISIF3-NSW001-OUTCAR-Iter1/KPOINTS +6 -0
  135. data/test/vaspdir/ISIF3-NSW001-OUTCAR-Iter1/OUTCAR +1436 -0
  136. data/test/vaspdir/ISIF3-NSW001-OUTCAR-Iter1/POSCAR +12 -0
  137. data/test/vaspdir/ISIF3-NSW001-OUTCAR-Iter1/POTCAR +3151 -0
  138. data/test/vaspdir/ISIF3-NSW001-OUTCAR-Iter1/lock +0 -0
  139. data/test/vaspdir/ISIF3-NSW002-OUTCAR-Iter2/CONTCAR +17 -0
  140. data/test/vaspdir/ISIF3-NSW002-OUTCAR-Iter2/INCAR +28 -0
  141. data/test/vaspdir/ISIF3-NSW002-OUTCAR-Iter2/KPOINTS +6 -0
  142. data/test/vaspdir/ISIF3-NSW002-OUTCAR-Iter2/OUTCAR +2025 -0
  143. data/test/vaspdir/ISIF3-NSW002-OUTCAR-Iter2/POSCAR +12 -0
  144. data/test/vaspdir/ISIF3-NSW002-OUTCAR-Iter2/POTCAR +3151 -0
  145. data/test/vaspdir/ISIF3-NSW002-OUTCAR-Iter2/lock +0 -0
  146. data/test/vaspdir/ISIF3-NSW100-OUTCAR-Iter1-INT/CONTCAR +0 -0
  147. data/test/vaspdir/ISIF3-NSW100-OUTCAR-Iter1-INT/INCAR +28 -0
  148. data/test/vaspdir/ISIF3-NSW100-OUTCAR-Iter1-INT/KPOINTS +6 -0
  149. data/test/vaspdir/ISIF3-NSW100-OUTCAR-Iter1-INT/OUTCAR +619 -0
  150. data/test/vaspdir/ISIF3-NSW100-OUTCAR-Iter1-INT/POSCAR +12 -0
  151. data/test/vaspdir/ISIF3-NSW100-OUTCAR-Iter1-INT/POTCAR +3151 -0
  152. data/test/vaspdir/ISIF3-NSW100-OUTCAR-Iter1-INT/lock +0 -0
  153. data/test/vaspdir/ISIF3-NSW100-OUTCAR-Iter3/CONTCAR +17 -0
  154. data/test/vaspdir/ISIF3-NSW100-OUTCAR-Iter3/INCAR +28 -0
  155. data/test/vaspdir/ISIF3-NSW100-OUTCAR-Iter3/KPOINTS +6 -0
  156. data/test/vaspdir/ISIF3-NSW100-OUTCAR-Iter3/OUTCAR +2602 -0
  157. data/test/vaspdir/ISIF3-NSW100-OUTCAR-Iter3/POSCAR +12 -0
  158. data/test/vaspdir/ISIF3-NSW100-OUTCAR-Iter3/POTCAR +3151 -0
  159. data/test/vaspdir/ISIF3-NSW100-OUTCAR-Iter3/lock +0 -0
  160. data/test/vaspdir/PI/INCAR +28 -0
  161. data/test/vaspdir/PI/KPOINTS +5 -0
  162. data/test/vaspdir/PI/PI12345 +0 -0
  163. data/test/vaspdir/PI/POSCAR +57 -0
  164. data/test/vaspdir/PI/POTCAR +698 -0
  165. data/test/vaspdir/lack-INCAR/KPOINTS +5 -0
  166. data/test/vaspdir/lack-INCAR/POSCAR +57 -0
  167. data/test/vaspdir/lack-INCAR/POTCAR +698 -0
  168. data/test/vaspdir/lack-KPOINTS/INCAR +28 -0
  169. data/test/vaspdir/lack-KPOINTS/POSCAR +57 -0
  170. data/test/vaspdir/lack-KPOINTS/POTCAR +698 -0
  171. data/test/vaspdir/lack-POSCAR/INCAR +28 -0
  172. data/test/vaspdir/lack-POSCAR/KPOINTS +5 -0
  173. data/test/vaspdir/lack-POSCAR/POTCAR +698 -0
  174. data/test/vaspdir/lack-POTCAR/INCAR +28 -0
  175. data/test/vaspdir/lack-POTCAR/KPOINTS +5 -0
  176. data/test/vaspdir/lack-POTCAR/POSCAR +57 -0
  177. data/test/vaspdir/lock/INCAR +28 -0
  178. data/test/vaspdir/lock/KPOINTS +5 -0
  179. data/test/vaspdir/lock/POSCAR +57 -0
  180. data/test/vaspdir/lock/POTCAR +698 -0
  181. data/test/vaspdir/lock/lock +0 -0
  182. data/test/vaspdir/lock-PI/INCAR +28 -0
  183. data/test/vaspdir/lock-PI/KPOINTS +5 -0
  184. data/test/vaspdir/lock-PI/PI12345 +0 -0
  185. data/test/vaspdir/lock-PI/POSCAR +57 -0
  186. data/test/vaspdir/lock-PI/POTCAR +698 -0
  187. data/test/vaspdir/lock-PI/lock +0 -0
  188. data/test/vaspdir/next-try00/CONTCAR +17 -0
  189. data/test/vaspdir/next-try00/INCAR +28 -0
  190. data/test/vaspdir/next-try00/KPOINTS +6 -0
  191. data/test/vaspdir/next-try00/OUTCAR +2025 -0
  192. data/test/vaspdir/next-try00/POSCAR +12 -0
  193. data/test/vaspdir/next-try00/POTCAR +3151 -0
  194. data/test/vaspdir/next-try00/lock +0 -0
  195. data/test/vaspdir/not-yet-ISIF2/INCAR +28 -0
  196. data/test/vaspdir/not-yet-ISIF2/KPOINTS +5 -0
  197. data/test/vaspdir/not-yet-ISIF2/PI17489 +2 -0
  198. data/test/vaspdir/not-yet-ISIF2/PI17736 +2 -0
  199. data/test/vaspdir/not-yet-ISIF2/PI1858 +2 -0
  200. data/test/vaspdir/not-yet-ISIF2/PI1866 +2 -0
  201. data/test/vaspdir/not-yet-ISIF2/PI2059 +2 -0
  202. data/test/vaspdir/not-yet-ISIF2/POSCAR +57 -0
  203. data/test/vaspdir/not-yet-ISIF2/POTCAR +698 -0
  204. data/test/vaspdir/not-yet-ISIF3/INCAR +28 -0
  205. data/test/vaspdir/not-yet-ISIF3/KPOINTS +5 -0
  206. data/test/vaspdir/not-yet-ISIF3/POSCAR +57 -0
  207. data/test/vaspdir/not-yet-ISIF3/POTCAR +698 -0
  208. data/vasputils.gemspec +272 -0
  209. metadata +409 -0
@@ -0,0 +1,3 @@
1
+ #! /bin/sh
2
+ cp -r Iter2-Nsw2.00 Iter2-Nsw2
3
+ /home/ippei/src/ManageVasp/bin/repeatVasp.rb -s Iter2-Nsw2
@@ -0,0 +1,53 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "test/unit"
5
+ require "vasputils/calcinspector.rb"
6
+
7
+ class YetCalc
8
+ def started? ; return false; end
9
+ def normal_ended? ; return false; end
10
+ def to_be_continued?; return false; end
11
+ def finished? ; return false; end
12
+ end
13
+
14
+ class StartedCalc
15
+ def started? ; return true ; end
16
+ def normal_ended? ; return false; end
17
+ def to_be_continued?; return false; end
18
+ def finished? ; return false; end
19
+ end
20
+
21
+ class NextCalc
22
+ def started? ; return true ; end
23
+ def normal_ended? ; return true ; end
24
+ def to_be_continued?; return true ; end
25
+ def finished? ; return false; end
26
+ end
27
+
28
+ class FinishedCalc
29
+ def started? ; return true ; end
30
+ def normal_ended? ; return true ; end
31
+ def to_be_continued?; return false; end
32
+ def finished? ; return true ; end
33
+ end
34
+
35
+ class TC_ListCalculation < Test::Unit::TestCase
36
+ def setup
37
+ @dc00 = YetCalc.new
38
+ @dc01 = StartedCalc.new
39
+ @dc02 = NextCalc.new
40
+ @dc03 = FinishedCalc.new
41
+ end
42
+
43
+ def test_self_inspect
44
+ assert_equal("YET", CalcInspector.inspect(@dc00))
45
+ assert_equal("STARTED", CalcInspector.inspect(@dc01))
46
+ assert_equal("NEXT", CalcInspector.inspect(@dc02))
47
+ assert_equal("FINISHED", CalcInspector.inspect(@dc03))
48
+ end
49
+
50
+
51
+
52
+ end
53
+
@@ -0,0 +1,69 @@
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
+
@@ -0,0 +1,77 @@
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
+
@@ -0,0 +1,126 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "test/unit"
5
+ require "vasputils/incar.rb"
6
+ require "stringio"
7
+
8
+ # assert_equal( cor, data)
9
+ # assert_in_delta( cor, data, $tolerance )
10
+ # assert_raise( RuntimeError ){}
11
+
12
+ class TC_Incar < Test::Unit::TestCase
13
+ #def setup
14
+ # @k = Incar.new
15
+ #end
16
+
17
+ SAMPLE_PAIRS = {
18
+ "SYSTEM" => "Untitled",
19
+ "PREC" => "High",
20
+ "IBRION" => "2",
21
+ "NSW" => "100",
22
+ "ISIF" => "2",
23
+ "ENCUT" => "400",
24
+ "NELM" => "60",
25
+ "NELMIN" => "2",
26
+ "EDIFF" => "1.0e-05",
27
+ "EDIFFG" => "-0.02",
28
+ "VOSKOWN" => "1",
29
+ "NBLOCK" => "1",
30
+ "ISPIN" => "1",
31
+ "INIWAV" => "1",
32
+ "ISTART" => "1",
33
+ "ICHARG" => "1",
34
+ "LWAVE" => ".TRUE.",
35
+ "LCHARG" => ".TRUE.",
36
+ "ISMEAR" => "0",
37
+ "SIGMA" => "0.1",
38
+ "IALGO" => "38",
39
+ "LREAL" => "Auto",
40
+ "NGX" => "36",
41
+ "NGY" => "36",
42
+ "NGZ" => "42",
43
+ }
44
+
45
+ def test_self_parse
46
+ io = StringIO.new
47
+ io.puts "# SCF input for VASP"
48
+ io.puts "# Note that VASP uses the FIRST occurence of a keyword"
49
+ io.puts "# if single point calc, IBRION = -1, NSW = 0, and comment out ISIF"
50
+ io.puts ""
51
+ io.puts "SYSTEM = Untitled (VASP)"
52
+ io.puts " PREC = High"
53
+ io.puts " IBRION = 2 #-1:atoms not moved, 1:quasi-Newton, 2:conjugate-gradient"
54
+ io.puts " NSW = 100 #maximum number of ionic steps"
55
+ io.puts " ISIF = 2"
56
+ io.puts " ENCUT = 400"
57
+ io.puts " NELM = 60 #maximum number of electronic steps"
58
+ io.puts " NELMIN = 2 #minimum number of electronic steps"
59
+ io.puts " EDIFF = 1.0e-05"
60
+ io.puts " EDIFFG = -0.02"
61
+ io.puts " VOSKOWN = 1"
62
+ io.puts " NBLOCK = 1"
63
+ io.puts " ISPIN = 1 #1:non spin polarized, 2:spin polarized"
64
+ io.puts " INIWAV = 1"
65
+ io.puts " ISTART = 1"
66
+ io.puts " ICHARG = 1"
67
+ io.puts " LWAVE = .TRUE."
68
+ io.puts " LCHARG = .TRUE."
69
+ io.puts " ISMEAR = 0"
70
+ io.puts " SIGMA = 0.1"
71
+ io.puts " IALGO = 38 #38:KosugiAlgorithm, 48:RMM-DIIS"
72
+ io.puts " LREAL = Auto #fast & not accurate"
73
+ io.puts " NGX = 36"
74
+ io.puts " NGY = 36"
75
+ io.puts " NGZ = 42"
76
+ io.rewind
77
+ pairs = Incar.parse(io)
78
+ assert_equal(SAMPLE_PAIRS, pairs)
79
+ end
80
+
81
+ def test_self_load_file
82
+ pairs = Incar.load_file "test/incar/INCAR.00"
83
+ assert_equal(SAMPLE_PAIRS, pairs)
84
+
85
+ corrects = {
86
+ "SYSTEM" => "Untitled",
87
+ "PREC" => "High",
88
+ "IBRION" => "2",
89
+ "NSW" => "0",
90
+ "ISIF" => "2",
91
+ "ENCUT" => "400",
92
+ "NELM" => "60",
93
+ "NELMIN" => "2",
94
+ "EDIFF" => "1.0e-05",
95
+ "EDIFFG" => "-0.02",
96
+ "VOSKOWN" => "1",
97
+ "NBLOCK" => "1",
98
+ "ISPIN" => "1",
99
+ "INIWAV" => "1",
100
+ "ISTART" => "1",
101
+ "ICHARG" => "1",
102
+ "LWAVE" => ".TRUE.",
103
+ "LCHARG" => ".TRUE.",
104
+ "ISMEAR" => "0",
105
+ "SIGMA" => "0.1",
106
+ "IALGO" => "38",
107
+ "LREAL" => "Auto",
108
+ "NGX" => "36",
109
+ "NGY" => "36",
110
+ "NGZ" => "42",
111
+ }
112
+ pairs = Incar.load_file "test/incar/INCAR.01"
113
+ assert_equal(corrects, pairs)
114
+
115
+ # not exist
116
+ assert_raise(Errno::ENOENT){Incar.load_file("")}
117
+ end
118
+
119
+ #def test_dump
120
+ #
121
+ #
122
+ # TODO
123
+ #end
124
+
125
+ end
126
+
@@ -0,0 +1,110 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "test/unit"
5
+ require "stringio"
6
+ require "vasputils/kpoints.rb"
7
+
8
+ class TC_Kpoints < Test::Unit::TestCase
9
+
10
+ $tolerance = 1E-10
11
+
12
+ def test_self_parse
13
+ io = StringIO.new
14
+ io.puts "Automatic mesh"
15
+ io.puts "0"
16
+ io.puts "Monkhorst Pack"
17
+ io.puts " 1 2 3"
18
+ io.puts " 0.4 0.5 0.6"
19
+ io.rewind
20
+ k00 = Kpoints.parse(io)
21
+ assert_equal("Automatic mesh", k00[:comment])
22
+ assert_equal(:monkhorst, k00[:type])
23
+ assert_equal([1, 2, 3], k00[:mesh])
24
+ #pp k00
25
+ assert_in_delta(0.4, k00[:shift][0], $tolerance)
26
+ assert_in_delta(0.5, k00[:shift][1], $tolerance)
27
+ assert_in_delta(0.6, k00[:shift][2], $tolerance)
28
+
29
+ io = StringIO.new
30
+ io.puts "Automatic mesh"
31
+ io.puts "0"
32
+ io.puts "Gamma-Center"
33
+ io.puts " 1 2 3"
34
+ io.puts " 0.4 0.5 0.6"
35
+ io.rewind
36
+ k01 = Kpoints.parse(io)
37
+ assert_equal("Automatic mesh", k01[:comment])
38
+ assert_equal(:gamma_center, k01[:type])
39
+ assert_equal([1, 2, 3], k01[:mesh])
40
+ assert_in_delta(0.4, k01[:shift][0])
41
+ assert_in_delta(0.5, k01[:shift][1])
42
+ assert_in_delta(0.6, k01[:shift][2])
43
+ end
44
+
45
+ def test_self_load_file
46
+ k00 = Kpoints.load_file("test/kpoints/m123-456")
47
+ assert_equal("Automatic mesh", k00[:comment])
48
+ assert_equal(:monkhorst, k00[:type])
49
+ assert_equal([1, 2, 3], k00[:mesh])
50
+ assert_in_delta(0.4, k00[:shift][0])
51
+ assert_in_delta(0.5, k00[:shift][1])
52
+ assert_in_delta(0.6, k00[:shift][2])
53
+
54
+ k01 = Kpoints.load_file("test/kpoints/g123-456")
55
+ assert_equal("Automatic mesh", k01[:comment])
56
+ assert_equal(:gamma_center, k01[:type])
57
+ assert_equal([1, 2, 3], k01[:mesh])
58
+ assert_in_delta(0.4, k01[:shift][0])
59
+ assert_in_delta(0.5, k01[:shift][1])
60
+ assert_in_delta(0.6, k01[:shift][2])
61
+ end
62
+
63
+ def test_dump
64
+ hash = {
65
+ :comment => "Automatic mesh",
66
+ :type => :monkhorst,
67
+ :mesh => [1, 2, 3],
68
+ :shift => [0.4, 0.5, 0.6],
69
+ }
70
+ io = StringIO.new
71
+ Kpoints.dump(hash, io)
72
+ io.rewind
73
+ results = io.readlines
74
+ corrects = [
75
+ "Automatic mesh\n",
76
+ "0\n",
77
+ "Monkhorst\n",
78
+ "1 2 3\n",
79
+ "0.4 0.5 0.6\n",
80
+ ]
81
+ corrects.each_with_index do |line, index|
82
+ assert_equal(line, results[index], "line #{index + 1}")
83
+ end
84
+ assert_equal(corrects.size, results.size)
85
+
86
+ hash = {
87
+ :comment => "Automatic mesh",
88
+ :type => :gamma_center,
89
+ :mesh => [1, 2, 3],
90
+ :shift => [0.4, 0.5, 0.6],
91
+ }
92
+ io = StringIO.new
93
+ Kpoints.dump(hash, io)
94
+ io.rewind
95
+ results = io.readlines
96
+ corrects = [
97
+ "Automatic mesh\n",
98
+ "0\n",
99
+ "Gamma_center\n",
100
+ "1 2 3\n",
101
+ "0.4 0.5 0.6\n",
102
+ ]
103
+ corrects.each_with_index do |line, index|
104
+ assert_equal(line, results[index], "line #{index + 1}")
105
+ end
106
+ assert_equal(corrects.size, results.size)
107
+ end
108
+
109
+ end
110
+
@@ -0,0 +1,162 @@
1
+ #! /usr/bin/ruby
2
+
3
+ require 'test/unit'
4
+ require 'vasputils/outcar.rb'
5
+
6
+ class TC_Outcar < Test::Unit::TestCase
7
+ $tolerance = 10**(-10)
8
+
9
+ def setup
10
+ @o01 = Outcar.load_file( "test/outcar/01-13-FIN.OUTCAR" )
11
+ @o01int = Outcar.load_file( "test/outcar/01-03-INT.OUTCAR" )
12
+ @o02 = Outcar.load_file( "test/outcar/02-05-FIN.OUTCAR" )
13
+ @o03 = Outcar.load_file( "test/outcar/03-05-FIN.OUTCAR" )
14
+ @o04 = Outcar.load_file( "test/outcar/10-01-FIN.OUTCAR" )
15
+ end
16
+
17
+ def test_self_load_file
18
+ assert_raise(Errno::ENOENT){Outcar.load_file( "" )}
19
+ end
20
+
21
+ #def test_nsw
22
+ # assert_equal(100, @o01.nsw )
23
+ # assert_equal(100, @o01int.nsw )
24
+ # assert_equal( 2, @o02.nsw )
25
+ # assert_equal(100, @o03.nsw )
26
+ #end
27
+
28
+ def test_normal_ended?
29
+ assert_equal(true , @o01 [:normal_ended])
30
+ assert_equal(false, @o01int[:normal_ended])
31
+ assert_equal(true , @o02 [:normal_ended])
32
+ assert_equal(true , @o03 [:normal_ended])
33
+ assert_equal(true , @o04 [:normal_ended])
34
+ end
35
+
36
+ def test_ionic_steps
37
+ assert_equal( 1, @o01 [:ionic_steps])
38
+ assert_equal( 1, @o01int[:ionic_steps])
39
+ assert_equal( 2, @o02 [:ionic_steps])
40
+ assert_equal( 3, @o03 [:ionic_steps])
41
+ assert_equal(10, @o04 [:ionic_steps])
42
+ end
43
+
44
+ def test_electronic_steps
45
+ assert_equal(13, @o01 [:electronic_steps])
46
+ assert_equal( 3, @o01int[:electronic_steps])
47
+ assert_equal(18, @o02 [:electronic_steps])
48
+ assert_equal(23, @o03 [:electronic_steps])
49
+ assert_equal(30, @o04 [:electronic_steps])
50
+ end
51
+
52
+ def test_totens
53
+ assert_in_delta( 64.17161363, @o01int[:totens][ 0], $tolerance )
54
+ assert_in_delta( -11.78292768, @o01int[:totens][ 1], $tolerance )
55
+ assert_in_delta( -19.56675908, @o01int[:totens][ 2], $tolerance )
56
+
57
+ assert_in_delta( 64.17161363, @o01 [:totens][ 0], $tolerance)
58
+ assert_in_delta( -11.78292768, @o01 [:totens][ 1], $tolerance)
59
+ assert_in_delta( -19.56675908, @o01 [:totens][ 2], $tolerance)
60
+ assert_in_delta( -19.74290414, @o01 [:totens][ 3], $tolerance)
61
+ assert_in_delta( -19.74509430, @o01 [:totens][ 4], $tolerance)
62
+ assert_in_delta( -15.85257458, @o01 [:totens][ 5], $tolerance)
63
+ assert_in_delta( -15.67846403, @o01 [:totens][ 6], $tolerance)
64
+ assert_in_delta( -15.65919488, @o01 [:totens][ 7], $tolerance)
65
+ assert_in_delta( -15.64209986, @o01 [:totens][ 8], $tolerance)
66
+ assert_in_delta( -15.64268703, @o01 [:totens][ 9], $tolerance)
67
+ assert_in_delta( -15.64251873, @o01 [:totens][10], $tolerance)
68
+ assert_in_delta( -15.64251991, @o01 [:totens][11], $tolerance)
69
+ assert_in_delta( -15.64251763, @o01 [:totens][12], $tolerance)
70
+ assert_in_delta( -15.642518 , @o01 [:totens][13], $tolerance)
71
+
72
+ assert_in_delta( 64.17161363, @o02 [:totens][ 0], $tolerance )
73
+ assert_in_delta( -11.78292768, @o02 [:totens][ 1], $tolerance )
74
+ assert_in_delta( -19.56675908, @o02 [:totens][ 2], $tolerance )
75
+ assert_in_delta( -19.74290414, @o02 [:totens][ 3], $tolerance )
76
+ assert_in_delta( -19.74509430, @o02 [:totens][ 4], $tolerance )
77
+ assert_in_delta( -15.85257458, @o02 [:totens][ 5], $tolerance )
78
+ assert_in_delta( -15.67846403, @o02 [:totens][ 6], $tolerance )
79
+ assert_in_delta( -15.65919488, @o02 [:totens][ 7], $tolerance )
80
+ assert_in_delta( -15.64209986, @o02 [:totens][ 8], $tolerance )
81
+ assert_in_delta( -15.64268703, @o02 [:totens][ 9], $tolerance )
82
+ assert_in_delta( -15.64251873, @o02 [:totens][10], $tolerance )
83
+ assert_in_delta( -15.64251991, @o02 [:totens][11], $tolerance )
84
+ assert_in_delta( -15.64251763, @o02 [:totens][12], $tolerance )
85
+ assert_in_delta( -15.642518 , @o02 [:totens][13], $tolerance )
86
+ assert_in_delta( -15.65990112, @o02 [:totens][14], $tolerance )
87
+ assert_in_delta( -15.64955447, @o02 [:totens][15], $tolerance )
88
+ assert_in_delta( -15.64799040, @o02 [:totens][16], $tolerance )
89
+ assert_in_delta( -15.64765795, @o02 [:totens][17], $tolerance )
90
+ assert_in_delta( -15.64765312, @o02 [:totens][18], $tolerance )
91
+ assert_in_delta( -15.647653 , @o02 [:totens][19], $tolerance )
92
+
93
+ assert_in_delta( 64.17161363, @o03 [:totens][ 0], $tolerance )
94
+ assert_in_delta( -11.78292768, @o03 [:totens][ 1], $tolerance )
95
+ assert_in_delta( -19.56675908, @o03 [:totens][ 2], $tolerance )
96
+ assert_in_delta( -19.74290414, @o03 [:totens][ 3], $tolerance )
97
+ assert_in_delta( -19.74509430, @o03 [:totens][ 4], $tolerance )
98
+ assert_in_delta( -15.85257458, @o03 [:totens][ 5], $tolerance )
99
+ assert_in_delta( -15.67846403, @o03 [:totens][ 6], $tolerance )
100
+ assert_in_delta( -15.65919488, @o03 [:totens][ 7], $tolerance )
101
+ assert_in_delta( -15.64209986, @o03 [:totens][ 8], $tolerance )
102
+ assert_in_delta( -15.64268703, @o03 [:totens][ 9], $tolerance )
103
+ assert_in_delta( -15.64251873, @o03 [:totens][10], $tolerance )
104
+ assert_in_delta( -15.64251991, @o03 [:totens][11], $tolerance )
105
+ assert_in_delta( -15.64251763, @o03 [:totens][12], $tolerance )
106
+ assert_in_delta( -15.642518 , @o03 [:totens][13], $tolerance )
107
+ assert_in_delta( -15.65990112, @o03 [:totens][14], $tolerance )
108
+ assert_in_delta( -15.64955447, @o03 [:totens][15], $tolerance )
109
+ assert_in_delta( -15.64799040, @o03 [:totens][16], $tolerance )
110
+ assert_in_delta( -15.64765795, @o03 [:totens][17], $tolerance )
111
+ assert_in_delta( -15.64765312, @o03 [:totens][18], $tolerance )
112
+ assert_in_delta( -15.647653 , @o03 [:totens][19], $tolerance )
113
+ assert_in_delta( -15.65100443, @o03 [:totens][20], $tolerance )
114
+ assert_in_delta( -15.64889598, @o03 [:totens][21], $tolerance )
115
+ assert_in_delta( -15.64857840, @o03 [:totens][22], $tolerance )
116
+ assert_in_delta( -15.64849678, @o03 [:totens][23], $tolerance )
117
+ assert_in_delta( -15.64849543, @o03 [:totens][24], $tolerance )
118
+ assert_in_delta( -15.648495 , @o03 [:totens][25], $tolerance )
119
+
120
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:549: free energy TOTEN = -51450.70587600
121
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:585: free energy TOTEN = -52760.43385845
122
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:621: free energy TOTEN = -52974.33537688
123
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:657: free energy TOTEN = -53114.51699744
124
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:693: free energy TOTEN = -53178.90296722
125
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:729: free energy TOTEN = -53226.44533651
126
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:772: free energy TOTEN = -53233.03344036
127
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:821: free energy TOTEN = -53232.27944261
128
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:870: free energy TOTEN = -53232.72830304
129
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:919: free energy TOTEN = -53232.71484487
130
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:968: free energy TOTEN = -53232.70895409
131
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:1017: free energy TOTEN = -53232.70751179
132
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:1055: free energy TOTEN = -53232.70759898
133
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:1463: free energy TOTEN = -53232.707599
134
+ end
135
+
136
+ def test_volume
137
+ assert_in_delta( 44.88, @o01 [:volumes][0], $tolerance )
138
+ assert_in_delta( 44.88, @o01 [:volumes][1], $tolerance )
139
+ assert_in_delta( 44.88, @o01int[:volumes][0], $tolerance )
140
+ assert_in_delta( 44.88, @o02 [:volumes][0], $tolerance )
141
+ assert_in_delta( 44.88, @o02 [:volumes][1], $tolerance )
142
+ assert_in_delta( 44.16, @o02 [:volumes][2], $tolerance )
143
+ assert_in_delta( 44.88, @o03 [:volumes][0], $tolerance )
144
+ assert_in_delta( 44.88, @o03 [:volumes][1], $tolerance )
145
+ assert_in_delta( 44.16, @o03 [:volumes][2], $tolerance )
146
+ assert_in_delta( 43.84, @o03 [:volumes][3], $tolerance )
147
+
148
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:343: volume of cell : 1258.66
149
+ #assert_in_delta( Iter1-Nsw0/OUTCAR:1488: volume of cell : 1258.66
150
+
151
+ end
152
+
153
+ def test_elapsed_time
154
+ assert_equal(nil, @o01int[:elapsed_time])
155
+ assert_in_delta(164.134, @o04[:elapsed_time], $tolerance )
156
+ end
157
+
158
+ def test_irreducible_kpoints
159
+ assert_equal(15, @o01[:irreducible_kpoints])
160
+ end
161
+
162
+ end