forked from bjmorgan/VASP-Utilities
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmkmurn
executable file
·54 lines (41 loc) · 1.42 KB
/
mkmurn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
#! /usr/bin/ruby
class Datum
attr_reader :scaling, :energy
def initialize( scaling, energy )
@scaling = scaling
@energy = energy
end
end
data = []
murn_dirs = Dir.entries(".").select{ |dir| ( dir =~ /\d/ ) == 0 }
murn_dirs.each do |dir|
Dir.chdir( dir ) do
abort( "POSCAR not found in ./#{dir}" ) unless FileTest.exist?( "POSCAR" )
poscar = File.new( "POSCAR", "r" )
scaling = poscar.readlines[1].to_f
poscar.close
abort( "OUTCAR not found in ./#{dir}" ) unless FileTest.exist?( "OUTCAR" )
outcar = File.new( "OUTCAR", "r" )
final_energy = outcar.readlines.grep( /sigma/ )[-1]
if final_energy.nil? then
warn("No energy found in directory ./#{dir}")
elsif
energy = final_energy.strip.split(" ")[-1].to_f
data << Datum.new( scaling, energy )
end
outcar.close
end
end
abort("No directories found") if data.empty?
data.sort! { |a,b| a.scaling <=> b.scaling }
data[1..-2].each_with_index do | d, i | # check data set is concave at all internal points
if data[i+1].energy > ( data[i].energy + data[i+2].energy ) / 2.0 then
warn "Not concave at lattice points:
#{data[i].scaling} #{data[i].energy}
#{data[i+1].scaling} #{data[i+1].energy}
#{data[i+2].scaling} #{data[i+2].energy}"
end
end
puts "2\n1 1\n#{ data[0].scaling } #{ data[-1].scaling } 20"
puts "#{data.size}"
data.each{ |d| puts "#{ d.scaling } #{ d.energy }" }