16
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
|
# File 'bin/kpoints', line 16
def generate
if options[:length]
axes = VaspUtils::Poscar.load_file('POSCAR').axes
lc = CrystalCell::LatticeAxes.axes_to_lc(axes)
l = options[:length].to_f
mesh = []
3.times do |i|
mesh[i] = (l/lc[i]).ceil
end
end
if options[:mesh]
mesh = options[:mesh]
unless mesh.size == 3
puts "Three integers must be indicated as argument of --mesh option. Exit."
exit
end
mesh.map!{|i| i.to_i}
end
if options[:shift]
shift = options[:shift]
unless shift.size == 3
puts "Three integers must be indicated as argument of --shift option. Exit."
exit
end
shift.map!{|i| i.to_f}
end
type = :monkhorst if options[:monkhorst]
mesh ||= [1,1,1]
shift ||= [0.0, 0.0, 0.0]
type ||= :gamma_center
hash = {
:comment => 'Generated by vasputils/bin/kpoints.',
:points => nil,
:scheme => :automatic,
:mesh => mesh ,
:shift => shift,
:type => type
}
kpoints = VaspUtils::Kpoints.new(hash)
kpoints.dump(STDOUT)
end
|