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
|
# File 'lib/aims/cube.rb', line 4
def parse(io)
io.readline
io.readline
natoms, origin_x, origin_y, origin_z = io.readline.split.collect{|s| s.to_f}
n1, n1x, n1y, n1z = io.readline.split.collect{|str| str.to_f}
n2, n2x, n2y, n2z = io.readline.split.collect{|str| str.to_f}
n3, n3x, n3y, n3z = io.readline.split.collect{|str| str.to_f}
natoms.to_i.times do
atomic_number, not_sure, x, y, z = io.readline.split.collect{|str| str.to_f}\
end
vals = Array.new(n1*n2*n3)
nread = 0
offset = 0
io.each_line{|line|
arr = line.split
nread = arr.size
vals[offset...offset+nread] = line.split
offset = offset+nread
}
n1.to_i.times do |i|
n2.to_i.times do |j|
n3.to_i.times do |k|
v = vals.shift.to_f
x = i*n1x + j*n2x + k*n3x
y = i*n1y + j*n2y + k*n3y
z = i*n1z + j*n2z + k*n3z
puts [x, y, z, v].join(" ")
end
end
end
end
|