本文整理汇总了Python中commopy.Cabinet类的典型用法代码示例。如果您正苦于以下问题:Python Cabinet类的具体用法?Python Cabinet怎么用?Python Cabinet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cabinet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prep_run_file
def prep_run_file(self, next_run='next_run.sh'):
"""
run_fileを修正してnext_run.shを作成
run_listの実行したjobをコメントアウト
"""
work_path, fname_exe = self.run_list[0]
key = "cd $PBS_O_WORKDIR\n"
# work_pathが相対pathの場合、絶対pathに修正する
if work_path[0] == '/':
alt = "cd {0}\n".format(os.path.join(work_path))
else:
alt = "cd {0}\n".format(os.path.join(os.getcwd(), work_path))
lines = Cabinet.read_file(fname_exe)
# $PBS_O_WORKDIRの記述が無い場合errorメッセージを出力
try:
pos = lines.index(key)
except ValueError:
print("{0}に'cd $PBS_O_WORKDIR'の記述がありません".format(fname_exe))
exit()
lines[pos] = alt
Cabinet.write_file(next_run, lines)
finished = self.run_list.pop(0)
finished[0] = '#' + finished[0]
self.finished_list.append(finished)
tmp_list = self.finished_list + self.run_list
all_list = [" ".join(x) + "\n" for x in tmp_list]
Cabinet.write_file(self.list_run_file, all_list)
示例2: write_potcar
def write_potcar(self, path, fname='POTCAR'):
"""
Make a combined single POTCAR file
"""
fname = os.path.join(path, fname)
out_lines = [x for y in self.potentials_lines for x in y]
Cabinet.write_file(fname, out_lines)
示例3: __init__
def __init__(self, poscar='POSCAR'):
if type(poscar) is str:
try:
poscar_lines = Cabinet.read_file(poscar)
except IOError:
print("error: vaspy.Poscar could not "
"find '{0}' file !!!".format(poscar))
exit()
elif type(poscar) is list:
poscar_lines = poscar
elif poscar is None:
print("POSCAR was not read !!! (Template POSCAR is loaded !!!)")
poscar = os.path.join(MODULE_DIR,
'../sorce/originalsVASP', 'poscar')
poscar_lines = Cabinet.read_file(poscar)
self.poscar_title = poscar_lines[0]
self.cell_scale = float(poscar_lines[1])
self.cell_lattices = Cabinet.conv_lines2array(poscar_lines[2:5])
# self.cell_latticesはarrayとして読み込む
if poscar_lines[5].split()[0].isdigit(): # vasp4
self.elements = None
self.num_atoms = [int(x) for x in poscar_lines[5].split()]
i = sum(self.num_atoms)
sites = [[float(x) for x in y.split()[0:3]]
for y in poscar_lines[7:7+i]]
self.cell_sites = np.array(sites)
self.vasp_version = 4
else:
self.elements = poscar_lines[5].split() # vasp5
self.num_atoms = [int(x) for x in poscar_lines[6].split()]
i = sum(self.num_atoms)
sites = [[float(x) for x in y.split()[0:3]]
for y in poscar_lines[8:8+i]]
self.cell_sites = np.array(sites)
self.vasp_version = 5
示例4: write_poscar
def write_poscar(self, poscar='POSCAR'):
"""
write_poscar(path)
Make a 'POSCAR' file at 'path'
"""
Cabinet.reserve_file(poscar)
Cabinet.write_file(poscar, str(self))
示例5: make_list
def make_list(keys, run_file='run.sh'):
"""
current directory中のkeyで引っ掛かるpathを
list_run.txtに書き出す
"""
path_list = []
for key in keys:
path_list += glob.glob(key)
path_list = sorted(set(path_list))
Cabinet.make_list_run(path_list, run_file)
示例6: run_job_and_get_id
def run_job_and_get_id(self, fname_exe='next_run.sh'):
"""
jobを走らせる
走らせるファイルはnext_run.sh
"""
cmd = ['qsub', fname_exe]
job_id = Popen(cmd, stdout=PIPE).communicate()[0]
add_line = job_id.split('.')[0] + b'\n'
self.running_jobs.append(add_line)
Cabinet.write_file(self.running_jobs_file, self.running_jobs)
示例7: write_kpoints
def write_kpoints(self, fname='KPOINTS', mode='M'):
"""Write KPOINTS file using self.kpoints"""
if mode == 'M':
mline = "Monkhorst Pack"
elif mode == 'G':
mline = "Gamma"
kp_lines = ("Automatic mesh\n0\n{0}\n"
" {1[0]} {1[1]} {1[2]}\n 0. 0. 0.\n"
.format(mline, self.kpoints))
Cabinet.write_file(fname, kp_lines)
示例8: make_list_run
def make_list_run(self, run_file):
"""
next.py用のlist_run.txtを作成
"""
lines = ""
for param in self.series:
path = param['path']
run_file = os.path.abspath(run_file)
lines += "{0} {1}\n".format(path, run_file)
Cabinet.write_file('list_run', lines)
示例9: append_list_run
def append_list_run(self, run_file):
"""
next.py用のlist_run.txtを追加
"""
lines = ""
for param in self.series:
path = os.path.abspath(param['path'])
run_file = os.path.abspath(run_file)
lines += "{0} {1}\n".format(path, run_file)
Cabinet.append_file('list_run', lines)
示例10: std
def std(src='POSCAR'):
"""
conventional standard cell に変換
"""
srcpos = Poscar.from_file(src)
finder = SpacegroupAnalyzer(srcpos.structure)
std_str = finder.get_conventional_standard_structure()
dstpos = Poscar(std_str)
dst = 'POSCAR_std'
Cabinet.reserve_file(dst)
dstpos.write_file(dst)
示例11: prim
def prim(src):
"""
primitive cell に変換
"""
srcpos = Poscar.from_file(src)
finder = SpacegroupAnalyzer(srcpos.structure)
prim_str = finder.get_primitive_standard_structure()
dstpos = Poscar(prim_str)
dst = 'POSCAR_prim'
Cabinet.reserve_file(dst)
dstpos.write_file(dst)
示例12: standard
def standard(src="POSCAR"):
"""
standardに変換
"""
srcpos = Poscar.from_file(src)
finder = SpacegroupAnalyzer(srcpos.structure)
std = finder.get_conventional_standard_structure()
dstpos = Poscar(std)
dst = "POSCAR_std"
Cabinet.reserve_file(dst)
dstpos.write_file(dst)
示例13: refined
def refined(src="POSCAR"):
"""
refined poscar を 作成する
"""
srcpos = Poscar.from_file(src)
finder = SpacegroupAnalyzer(srcpos.structure, symprec=5e-1, angle_tolerance=8)
std = finder.get_refined_structure()
dstpos = Poscar(std)
dst = "POSCAR_refined"
Cabinet.reserve_file(dst)
dstpos.write_file(dst)
示例14: primitive
def primitive(src="POSCAR"):
"""
primitiveに変換
"""
srcpos = Poscar.from_file(src)
finder = SpacegroupAnalyzer(srcpos.structure)
prim = finder.get_primitive_standard_structure()
dstpos = Poscar(prim)
dst = "POSCAR_prim"
Cabinet.reserve_file(dst)
dstpos.write_file(dst)
示例15: make_list
def make_list(keys, is_file=False, run_file="run.sh"):
"""
current directory中のkeyで引っ掛かるpathを
list_run.txtに書き出す
"""
path_list = []
for key in keys:
path_list += glob.glob(key)
path_list = sorted(set(path_list))
if is_file:
path_list = [os.path.dirname(x) for x in path_list]
Cabinet.make_list_run(path_list, run_file)