lib/vasputils/vaspdir.rb in vasputils-0.0.4 vs lib/vasputils/vaspdir.rb in vasputils-0.0.5
- old
+ new
@@ -26,19 +26,22 @@
#
# ルール
# try00 形式の postfix がついていることを前提とする。
# 00 の部分には CONTCAR を POSCAR にする手続きで連続して行う計算の番号を示す。
#
-class VaspDir < Comana
+class VaspDir < ComputationManager
class InitializeError < Exception; end
+ class NoVaspBinaryError < Exception; end
+ class PrepareNextError < Exception; end
#INCAR 解析とかして、モードを調べる。
#- 格子定数の構造最適化モード(ISIF = 3)
#- 格子定数を固定した構造最適化モード(ISIF = 2)
##- k 点探索モードは無理だろう。
def initialize(dir)
super(dir)
+ @lockdir = "lock_vaspdir"
%w(INCAR KPOINTS POSCAR POTCAR).each do |file|
infile = "#{@dir}/#{file}"
raise InitializeError, infile unless FileTest.exist? infile
end
end
@@ -94,61 +97,32 @@
# mpirun で投げる場合は
# machinefile を生成しないとどのホストで計算するか、安定しない。
# そのうち mpiexec from torque に対応するが、
# まずは mpirun で動くように作る。
def calculate
- #File.open(lock_file, "w") do |lock_io|
- # lock_io.puts "HOST: #{ENV["HOST"]}"
- # lock_io.puts "START: #{Time.now.to_s}"
- # lock_io.flush
-
- # num_cores = 4 if /^Se\d\d/ =~ ENV["HOST"]
- # num_cores = 4 if /^Ge\d\d/ =~ ENV["HOST"]
- # num_cores = 4 if /^Ga\d\d/ =~ ENV["HOST"]
- # num_cores = 4 if /^At$/ =~ ENV["HOST"]
- # num_cores = 2 if /^yggdrasil$/ =~ ENV["HOST"]
-
- # # machines を生成
- # File.open("#{@dir}/machines", "w") do |io|
- # io.puts "localhost:#{num_cores}"
- # end
- #end
- #num_cores = 4
-
- #settings = YAML.load_file("#{ENV["HOME"]}/.machineinfo")
- #setting = settings[ENV["HOST"]]
begin
- hi = MachineInfo.load_file("#{ENV["HOME"]}/.machineinfo").get_host(ENV["HOST"])
- vasp = hi["vasp"]
+ info =
+ MachineInfo.load_file("#{ENV["HOME"]}/.machineinfo").get_info(ENV["HOST"])
+ vasp = info["vasp"]
rescue
- vasp = "vasp"
+ #vasp = "vasp"
+ raise NoVaspBinaryError, "No vasp path in #{ENV["HOME"]}/.machineinfo"
end
command = "cd #{@dir};"
command += vasp
command += "> stdout"
- #if ENV["PBS_JOBID"]
- # command += "/usr/local/calc/mpiexec/bin/mpiexec /usr/local/calc/bin/vasp5212-mpich2"
- #else
- # /usr/local/calc/bin/vasp5212-mpich2"
- ## command = "cd #{@dir};" +
- ## "/usr/local/calc/mpich-1.2.7-ifc7/bin/mpirun " +
- ## "-np #{num_cores} " +
- ## "-machinefile machines " +
- ## "/usr/local/calc/vasp/vasp4631mpi" +
- ## "> stdout"
- #end
-
system command
end
def prepare_next
#do_nothing
+ raise PrepareNextError, "VaspDir doesn't need next."
end
end
-#class VaspGeometryOptimization < Comana
+#class VaspGeometryOptimization < ComputationManager
# # 次の計算ディレクトリを作成し、
# # その VaspDir クラスで self を置き換える。
# # 計算が正常終了していなければ、例外 VaspDirNotEndedError を生じる。
# # 次の計算ディレクトリが既に存在していれば例外 Errno::EEXIST が投げられる。
# def next