vasputils 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/Gemfile +1 -1
  2. data/VERSION +1 -1
  3. data/bin/qsubvasp +30 -0
  4. data/lib/vasputils/vaspdir.rb +176 -218
  5. data/test/test_vaspdir.rb +59 -189
  6. data/test/vaspdir/finished/CONTCAR +17 -0
  7. data/test/vaspdir/finished/INCAR +27 -0
  8. data/test/vaspdir/finished/KPOINTS +6 -0
  9. data/test/vaspdir/finished/OUTCAR +1436 -0
  10. data/test/vaspdir/finished/POSCAR +12 -0
  11. data/test/vaspdir/finished/POTCAR +16 -0
  12. data/test/vaspdir/finished/lock +0 -0
  13. data/test/vaspdir/lack-INCAR/KPOINTS +5 -4
  14. data/test/vaspdir/lack-INCAR/POSCAR +11 -56
  15. data/test/vaspdir/lack-INCAR/POTCAR +13 -695
  16. data/test/vaspdir/lack-KPOINTS/INCAR +2 -3
  17. data/test/vaspdir/lack-KPOINTS/POSCAR +11 -56
  18. data/test/vaspdir/lack-KPOINTS/POTCAR +13 -695
  19. data/test/vaspdir/lack-POSCAR/INCAR +2 -3
  20. data/test/vaspdir/lack-POSCAR/KPOINTS +5 -4
  21. data/test/vaspdir/lack-POSCAR/POTCAR +13 -695
  22. data/test/vaspdir/lack-POTCAR/INCAR +2 -3
  23. data/test/vaspdir/lack-POTCAR/KPOINTS +5 -4
  24. data/test/vaspdir/lack-POTCAR/POSCAR +11 -56
  25. data/test/vaspdir/locked/INCAR +28 -0
  26. data/test/vaspdir/locked/KPOINTS +6 -0
  27. data/test/vaspdir/locked/POSCAR +12 -0
  28. data/test/vaspdir/locked/POTCAR +16 -0
  29. data/test/vaspdir/locked/lock +0 -0
  30. data/test/vaspdir/not-yet/INCAR +28 -0
  31. data/test/vaspdir/not-yet/KPOINTS +6 -0
  32. data/test/vaspdir/not-yet/POSCAR +12 -0
  33. data/test/vaspdir/not-yet/POTCAR +16 -0
  34. data/test/vaspdir/started/CONTCAR +17 -0
  35. data/test/vaspdir/started/INCAR +27 -0
  36. data/test/vaspdir/started/KPOINTS +6 -0
  37. data/test/vaspdir/started/OUTCAR +1028 -0
  38. data/test/vaspdir/started/POSCAR +12 -0
  39. data/test/vaspdir/started/POTCAR +16 -0
  40. data/test/vaspdir/started/lock +0 -0
  41. data/vasputils.gemspec +27 -3
  42. metadata +48 -23
data/test/test_vaspdir.rb CHANGED
@@ -3,9 +3,9 @@
3
3
 
4
4
  $TEST = true
5
5
 
6
- class VaspDir
7
- attr_reader :mode
8
- end
6
+ require "rubygems"
7
+ gem "comana"
8
+ require "comana.rb"
9
9
 
10
10
  require "test/unit"
11
11
  require "vasputils/vaspdir.rb"
@@ -14,62 +14,42 @@ require "vasputils/vaspdir.rb"
14
14
  # assert_in_delta( cor, data, $tolerance )
15
15
  # assert_raise( RuntimeError ){}
16
16
 
17
+ class VaspDir < Comana
18
+ attr_reader :mode
19
+ public :finished?
20
+ end
21
+
17
22
 
18
23
  class TC_VaspDir < Test::Unit::TestCase
19
24
 
20
- GENERATED_FILES_VD00 =
21
- [
22
- "test/vaspdir/not-yet-ISIF2/CHG",
23
- "test/vaspdir/not-yet-ISIF2/CHGCAR",
24
- "test/vaspdir/not-yet-ISIF2/CONTCAR",
25
- "test/vaspdir/not-yet-ISIF2/DOSCAR",
26
- "test/vaspdir/not-yet-ISIF2/EIGENVAL",
27
- "test/vaspdir/not-yet-ISIF2/IBZKPT",
28
- "test/vaspdir/not-yet-ISIF2/OSZICAR",
29
- "test/vaspdir/not-yet-ISIF2/OUTCAR",
30
- "test/vaspdir/not-yet-ISIF2/PCDAT",
31
- "test/vaspdir/not-yet-ISIF2/WAVECAR",
32
- "test/vaspdir/not-yet-ISIF2/XDATCAR",
33
- "test/vaspdir/not-yet-ISIF2/machines",
34
- "test/vaspdir/not-yet-ISIF2/vasprun.xml",
35
- "test/vaspdir/not-yet-ISIF2/lock",
25
+ GENERATED_FILES_VD00 = [
26
+ "test/vaspdir/not-yet/CHG",
27
+ "test/vaspdir/not-yet/CHGCAR",
28
+ "test/vaspdir/not-yet/CONTCAR",
29
+ "test/vaspdir/not-yet/DOSCAR",
30
+ "test/vaspdir/not-yet/EIGENVAL",
31
+ "test/vaspdir/not-yet/IBZKPT",
32
+ "test/vaspdir/not-yet/OSZICAR",
33
+ "test/vaspdir/not-yet/OUTCAR",
34
+ "test/vaspdir/not-yet/PCDAT",
35
+ "test/vaspdir/not-yet/WAVECAR",
36
+ "test/vaspdir/not-yet/XDATCAR",
37
+ "test/vaspdir/not-yet/machines",
38
+ "test/vaspdir/not-yet/vasprun.xml",
36
39
  ]
37
40
 
38
41
  def setup
39
- @vd00 = VaspDir.new("test/vaspdir/not-yet-ISIF2")
40
- @vd01 = VaspDir.new("test/vaspdir/not-yet-ISIF3")
41
- @vd02 = VaspDir.new("test/vaspdir/ISIF3-NSW100-OUTCAR-Iter1-INT")
42
- @vd03 = VaspDir.new("test/vaspdir/ISIF2-NSW100-OUTCAR-Iter1")
43
- @vd04 = VaspDir.new("test/vaspdir/ISIF3-NSW002-OUTCAR-Iter2")
44
- @vd05 = VaspDir.new("test/vaspdir/ISIF3-NSW100-OUTCAR-Iter3")
45
- @vd06 = VaspDir.new("test/vaspdir/PI")
46
- @vd07 = VaspDir.new("test/vaspdir/lock")
47
- @vd08 = VaspDir.new("test/vaspdir/lock-PI")
48
- @vd09 = VaspDir.new("test/vaspdir/ISIF2-NSW100-OUTCAR-Iter3")
49
- @vd10 = VaspDir.new("test/vaspdir/next-try00")
50
- @vd11 = VaspDir.new("test/vaspdir/ISIF2-NSW000-OUTCAR-Iter1")
51
- @vd12 = VaspDir.new("test/vaspdir/ISIF2-NSW001-OUTCAR-Iter1")
52
- @vd13 = VaspDir.new("test/vaspdir/ISIF3-NSW000-OUTCAR-Iter1")
53
- @vd14 = VaspDir.new("test/vaspdir/ISIF3-NSW001-OUTCAR-Iter1")
54
- @vd15 = VaspDir.new("test/vaspdir/IBRION-1-NSW000-OUTCAR-Iter1")
42
+ @vd00 = VaspDir.new("test/vaspdir/not-yet")
43
+ @vd01 = VaspDir.new("test/vaspdir/locked")
44
+ @vd02 = VaspDir.new("test/vaspdir/started")
45
+ @vd03 = VaspDir.new("test/vaspdir/finished")
55
46
 
56
47
  GENERATED_FILES_VD00.each do |file|
57
48
  FileUtils.rm file if File.exist? file
58
49
  end
59
- end
60
50
 
61
- def teardown
62
- ["test/vaspdir/next-try01/POSCAR" ,
63
- "test/vaspdir/next-try01/POTCAR" ,
64
- "test/vaspdir/next-try01/INCAR" ,
65
- "test/vaspdir/next-try01/KPOINTS"].each do |filename|
66
- FileUtils.rm(filename) if File.exist?(filename)
67
- end
68
- Dir.rmdir("test/vaspdir/next-try01") if File.exist?("test/vaspdir/next-try01")
69
-
70
- GENERATED_FILES_VD00.each do |file|
71
- FileUtils.rm file if File.exist? file
72
- end
51
+ #lock_dir = "test/vaspdir/not-yet/lock"
52
+ #Dir.rmdir(lock_dir) if Dir.exist?(lock_dir)
73
53
  end
74
54
 
75
55
  def test_initialize
@@ -77,177 +57,67 @@ class TC_VaspDir < Test::Unit::TestCase
77
57
  assert_raise(VaspDir::InitializeError){VaspDir.new("test/vaspdir/lack-KPOINTS")}
78
58
  assert_raise(VaspDir::InitializeError){VaspDir.new("test/vaspdir/lack-POSCAR" )}
79
59
  assert_raise(VaspDir::InitializeError){VaspDir.new("test/vaspdir/lack-POTCAR" )}
80
-
81
- assert_equal(:geom_opt_atoms, @vd00.mode)
82
- assert_equal(:geom_opt_lattice, @vd01.mode)
83
- assert_equal(:geom_opt_lattice, @vd02.mode)
84
- assert_equal(:geom_opt_atoms, @vd03.mode)
85
- end
86
-
87
- def test_name
88
- assert_equal("test/vaspdir/not-yet-ISIF2" , @vd00.name)
89
- assert_equal("test/vaspdir/not-yet-ISIF3" , @vd01.name)
90
- assert_equal("test/vaspdir/ISIF3-NSW100-OUTCAR-Iter1-INT", @vd02.name)
91
- assert_equal("test/vaspdir/ISIF2-NSW100-OUTCAR-Iter1" , @vd03.name)
92
- assert_equal("test/vaspdir/ISIF3-NSW002-OUTCAR-Iter2" , @vd04.name)
93
- assert_equal("test/vaspdir/ISIF3-NSW100-OUTCAR-Iter3" , @vd05.name)
94
- assert_equal("test/vaspdir/PI" , @vd06.name)
95
- assert_equal("test/vaspdir/lock" , @vd07.name)
96
- assert_equal("test/vaspdir/lock-PI" , @vd08.name)
97
- assert_equal("test/vaspdir/ISIF2-NSW100-OUTCAR-Iter3" , @vd09.name)
98
- assert_equal("test/vaspdir/next-try00" , @vd10.name)
99
- assert_equal("test/vaspdir/ISIF2-NSW000-OUTCAR-Iter1" , @vd11.name)
100
- assert_equal("test/vaspdir/ISIF2-NSW001-OUTCAR-Iter1" , @vd12.name)
101
- assert_equal("test/vaspdir/ISIF3-NSW000-OUTCAR-Iter1" , @vd13.name)
102
- assert_equal("test/vaspdir/ISIF3-NSW001-OUTCAR-Iter1" , @vd14.name)
103
- assert_equal("test/vaspdir/IBRION-1-NSW000-OUTCAR-Iter1" , @vd15.name)
104
- end
105
-
106
- def test_started?
107
- assert_equal(false, @vd00.started?)
108
- assert_equal(false, @vd01.started?)
109
- assert_equal(true , @vd02.started?)
110
- assert_equal(true , @vd03.started?)
111
- assert_equal(true , @vd04.started?)
112
- assert_equal(true , @vd05.started?)
113
- assert_equal(false, @vd06.started?)
114
- assert_equal(true , @vd07.started?)
115
- assert_equal(true , @vd08.started?)
116
- assert_equal(true , @vd09.started?)
117
- assert_equal(true , @vd10.started?)
118
- assert_equal(true , @vd11.started?)
119
- assert_equal(true , @vd12.started?)
120
- assert_equal(true , @vd13.started?)
121
- assert_equal(true , @vd14.started?)
122
- assert_equal(true , @vd15.started?)
123
- end
124
-
125
- def test_normal_ended?
126
- assert_equal(false, @vd00.normal_ended?)
127
- assert_equal(false, @vd01.normal_ended?)
128
- assert_equal(false, @vd02.normal_ended?)
129
- assert_equal(true , @vd03.normal_ended?)
130
- assert_equal(true , @vd04.normal_ended?)
131
- assert_equal(true , @vd05.normal_ended?)
132
- assert_equal(false, @vd06.normal_ended?)
133
- assert_equal(false, @vd07.normal_ended?)
134
- assert_equal(false, @vd08.normal_ended?)
135
- assert_equal(true , @vd09.normal_ended?)
136
60
  end
137
61
 
138
- def test_to_be_continued?
139
- assert_equal(false, @vd00.to_be_continued?)
140
- assert_equal(false, @vd01.to_be_continued?)
141
- assert_equal(false, @vd02.to_be_continued?)
142
- assert_equal(false, @vd03.to_be_continued?)
143
- assert_equal(true , @vd04.to_be_continued?)
144
- assert_equal(true , @vd05.to_be_continued?)
145
- assert_equal(false, @vd06.to_be_continued?)
146
- assert_equal(false, @vd07.to_be_continued?)
147
- assert_equal(false, @vd08.to_be_continued?)
148
- assert_equal(false, @vd09.to_be_continued?)
149
- assert_equal(true , @vd10.to_be_continued?)
150
- assert_equal(false, @vd11.to_be_continued?)
151
- assert_equal(false, @vd12.to_be_continued?)
152
- assert_equal(false, @vd13.to_be_continued?)
153
- assert_equal(false, @vd14.to_be_continued?)
154
- assert_equal(false, @vd15.to_be_continued?)
62
+ def test_finished?
63
+ assert_equal(false, @vd00.finished?)
64
+ assert_equal(false, @vd01.finished?)
65
+ assert_equal(false, @vd02.finished?)
66
+ assert_equal(true , @vd03.finished?)
155
67
  end
156
68
 
157
69
  def test_calculate
158
- assert_raise(VaspDir::LockedError){@vd07.calculate}
159
- assert_raise(VaspDir::LockedError){@vd08.calculate}
160
-
161
- #
70
+ lock_dir = "test/vaspdir/not-yet/lock"
71
+ Dir.rmdir(lock_dir) if Dir.exist?(lock_dir)
72
+ #pp @vd00;exit
73
+ #@vd00.calculate
162
74
  assert_nothing_raised{@vd00.calculate}
75
+
163
76
  GENERATED_FILES_VD00.each do |file|
164
77
  assert(FileTest.exist?(file), "#{file} not found.")
165
78
  end
166
- assert(FileTest.exist? "test/vaspdir/not-yet-ISIF2/INCAR")
167
- assert(FileTest.exist? "test/vaspdir/not-yet-ISIF2/KPOINTS")
168
- assert(FileTest.exist? "test/vaspdir/not-yet-ISIF2/POSCAR")
169
- assert(FileTest.exist? "test/vaspdir/not-yet-ISIF2/POTCAR")
170
- #
171
- io = File.open("test/vaspdir/not-yet-ISIF2/lock", "r")
172
- lines = io.readlines
173
- assert_equal("HOST: #{ENV["HOST"]}\n", lines[0])
174
- assert(/^START: / =~ lines[1])
175
- assert_equal("STATUS: normal ended.\n", lines[2])
176
-
177
- io.close
178
- # あとかたづけは teardown にまかせる。
179
- end
180
-
181
- def test_next
182
- assert_raise(VaspDir::NotEndedError){@vd00.next}
183
- assert_raise(VaspDir::NotEndedError){@vd01.next}
184
- assert_raise(VaspDir::NotEndedError){@vd02.next}
185
- assert_raise(VaspDir::ConvergedError){@vd03.next}
186
- assert_raise(VaspDir::NotEndedError){@vd06.next}
187
- assert_raise(VaspDir::NotEndedError){@vd07.next}
188
- assert_raise(VaspDir::NotEndedError){@vd08.next}
189
- assert_raise(VaspDir::ConvergedError){@vd09.next}
190
-
191
- assert_equal(true , FileTest.exist?("test/vaspdir/next-try00"))
192
- assert_equal(false, FileTest.exist?("test/vaspdir/next-try01"))
193
- @vd10.next
194
- assert_equal("test/vaspdir/next-try01", @vd10.name)
195
- assert_equal(true , FileTest.exist?("test/vaspdir/next-try00"))
196
- assert_equal(true , FileTest.exist?("test/vaspdir/next-try01"))
197
- assert_equal(true , FileTest.exist?("test/vaspdir/next-try01/POSCAR"))
198
- assert_equal(true , FileTest.exist?("test/vaspdir/next-try01/POTCAR"))
199
- assert_equal(true , FileTest.exist?("test/vaspdir/next-try01/INCAR"))
200
- assert_equal(true , FileTest.exist?("test/vaspdir/next-try01/KPOINTS"))
201
- assert_equal(4 , Dir.glob("test/vaspdir/next-try01/*").size)
202
- #
203
- poscar_00 = File.open("test/vaspdir/next-try00/POSCAR" ).readlines
204
- contcar_00 = File.open("test/vaspdir/next-try00/CONTCAR").readlines
205
- poscar_01 = File.open("test/vaspdir/next-try01/POSCAR" ).readlines
206
- assert_equal(false, poscar_00 == contcar_00)
207
- assert_equal(true, contcar_00 == poscar_01)
208
- assert_equal(false, poscar_01 == poscar_00)
209
- # あとかたづけは teardown にまかせる。
210
- end
211
-
212
- def test_teardown
213
- # NO TEST
214
- end
215
-
216
- def test_internal_steps
217
- assert_equal(18, @vd10.internal_steps)
218
- end
79
+ assert(FileTest.exist? "test/vaspdir/not-yet/INCAR")
80
+ assert(FileTest.exist? "test/vaspdir/not-yet/KPOINTS")
81
+ assert(FileTest.exist? "test/vaspdir/not-yet/POSCAR")
82
+ assert(FileTest.exist? "test/vaspdir/not-yet/POTCAR")
219
83
 
220
- def test_external_steps
221
- assert_equal(2, @vd10.external_steps)
222
- end
223
-
224
- def test_elapsed_time
225
- assert_in_delta(126.383, @vd10.elapsed_time)
84
+ lock_dir = "test/vaspdir/not-yet/lock"
85
+ Dir.rmdir(lock_dir) if Dir.exist?(lock_dir)
226
86
  end
227
87
 
228
88
  def test_outcar
229
- assert_equal("test/vaspdir/next-try00/OUTCAR", @vd10.outcar[:name])
89
+ assert_equal("test/vaspdir/started/OUTCAR", @vd02.outcar[:name])
90
+ assert_equal("test/vaspdir/finished/OUTCAR", @vd03.outcar[:name])
230
91
  end
231
92
 
232
93
  def test_contcar
233
- t = @vd10.contcar
94
+ t = @vd03.contcar
234
95
  assert_equal(Cell, t.class)
235
- assert_in_delta(3.8678456093562040, t.axes[2][2])
96
+ assert_in_delta(3.8879999999999999, t.axes[2][2])
236
97
 
237
98
  assert_raise(Errno::ENOENT){@vd00.contcar}
238
99
  end
239
100
 
240
101
  def test_incar
241
- t = @vd10.incar
102
+ t = @vd00.incar
242
103
  assert_equal("400", t["ENCUT"])
243
104
  end
244
105
 
245
106
  def test_kpoints
246
- t = @vd10.kpoints
107
+ t = @vd00.kpoints
247
108
  assert_equal("Automatic mesh", t[:comment])
248
109
  end
249
110
 
250
111
  #undef test_next
251
112
 
113
+ def teardown
114
+ GENERATED_FILES_VD00.each do |file|
115
+ FileUtils.rm file if File.exist? file
116
+ end
117
+
118
+ #lock_dir = "test/vaspdir/not-yet/lock"
119
+ #Dir.rmdir(lock_dir) if Dir.exist?(lock_dir)
120
+ end
121
+
252
122
  end
253
123
 
@@ -0,0 +1,17 @@
1
+ Untitled (VASP)
2
+ 1.00000000000000
3
+ 3.6509999999999998 0.0000000000000000 0.0000000000000000
4
+ -1.8254999999999919 3.1618587492169889 0.0000000000000000
5
+ 0.0000000000000000 0.0000000000000000 3.8879999999999999
6
+ 3 1
7
+ Selective dynamics
8
+ Direct
9
+ 0.0000000000000000 0.0000000000000000 0.5000000000000000 T T T
10
+ 0.3333333333333357 0.6666666666666642 0.0000000000000000 T T T
11
+ 0.6666666666666642 0.3333333333333357 0.0000000000000000 T T T
12
+ 0.0000000000000000 0.0000000000000000 0.0000000000000000 F F F
13
+
14
+ 0.00000000E+00 0.00000000E+00 0.00000000E+00
15
+ 0.00000000E+00 0.00000000E+00 0.00000000E+00
16
+ 0.00000000E+00 0.00000000E+00 0.00000000E+00
17
+ 0.00000000E+00 0.00000000E+00 0.00000000E+00
@@ -0,0 +1,27 @@
1
+ # SCF input for VASP
2
+
3
+ SYSTEM = Untitled (VASP)
4
+ PREC = High
5
+ IBRION = -1 #-1:atoms not moved, 1:quasi-Newton, 2:conjugate-gradient
6
+ NSW = 0 #maximum number of ionic steps
7
+ ENCUT = 400
8
+ NELM = 60 #maximum number of electronic steps
9
+ NELMIN = 2 #minimum number of electronic steps
10
+ EDIFF = 1.0e-05
11
+ EDIFFG = -0.02
12
+ VOSKOWN = 1
13
+ NBLOCK = 1
14
+ ISPIN = 1 #1:non spin polarized, 2:spin polarized
15
+ INIWAV = 1
16
+ ISTART = 1
17
+ ICHARG = 1
18
+ LWAVE = .TRUE.
19
+ LCHARG = .TRUE.
20
+ ISMEAR = 0
21
+ SIGMA = 0.1
22
+ IALGO = 38 #38:KosugiAlgorithm, 48:RMM-DIIS
23
+ #LREAL = .FALSE.
24
+ LREAL = Auto #fast & not accurate
25
+ NGX = 36
26
+ NGY = 36
27
+ NGZ = 42
@@ -0,0 +1,6 @@
1
+ Automatic mesh
2
+ 0
3
+ Monkhorst Pack
4
+ 5 5 5
5
+ 0. 0. 0.
6
+