本文整理汇总了Python中commopy.Cabinet.write_file方法的典型用法代码示例。如果您正苦于以下问题:Python Cabinet.write_file方法的具体用法?Python Cabinet.write_file怎么用?Python Cabinet.write_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类commopy.Cabinet
的用法示例。
在下文中一共展示了Cabinet.write_file方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prep_run_file
# 需要导入模块: from commopy import Cabinet [as 别名]
# 或者: from commopy.Cabinet import write_file [as 别名]
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
# 需要导入模块: from commopy import Cabinet [as 别名]
# 或者: from commopy.Cabinet import write_file [as 别名]
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: write_poscar
# 需要导入模块: from commopy import Cabinet [as 别名]
# 或者: from commopy.Cabinet import write_file [as 别名]
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))
示例4: make_list_run
# 需要导入模块: from commopy import Cabinet [as 别名]
# 或者: from commopy.Cabinet import write_file [as 别名]
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)
示例5: run_job_and_get_id
# 需要导入模块: from commopy import Cabinet [as 别名]
# 或者: from commopy.Cabinet import write_file [as 别名]
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)
示例6: write_kpoints
# 需要导入模块: from commopy import Cabinet [as 别名]
# 或者: from commopy.Cabinet import write_file [as 别名]
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)
示例7: plt_double
# 需要导入模块: from commopy import Cabinet [as 别名]
# 或者: from commopy.Cabinet import write_file [as 别名]
def plt_double(self, combipara, in_dir1, in_dir2, out_dir):
"""2種の結果のlattice依存性をプロット"""
combi = Combinatorial(*combipara)
combi.set_formula(2, 1)
for composition in combi.compositions:
formula = composition['formula']
formula = ''.join(formula.split('2'))
total_elem = ['Fe'] + composition['elements']
total_num_atoms = [1] + composition['num_atoms']
print(formula)
all_dir_list = glob.glob(os.path.join(in_dir1, formula, 'fixed_*'))
regular = collect_vasp.Energy(all_dir_list, 'POSCAR', 'OSZICAR')
regular['c/a'] /= 2 ** 0.5
fixed_elem = [total_elem[1], total_elem[0], total_elem[2]]
fixed_elem = np.array([fixed_elem] * len(regular['elements']))
regular['elements'] = fixed_elem
regular.set_enthalpy()
regular.set_mae('OSZICAR_SOC001', 'OSZICAR_SOC100')
all_dir_list = glob.glob(os.path.join(in_dir2, formula, 'fixed_*'))
inverse = collect_vasp.Energy(all_dir_list, 'POSCAR', 'OSZICAR')
inverse['c/a'] /= 2 ** 0.5
inverse['elements'] = fixed_elem
inverse.set_enthalpy()
inverse.set_mae('OSZICAR_SOC001', 'OSZICAR_SOC100')
rlines = [str(regular)]
ilines = [str(inverse)]
fname_reg = "Fe2{0[0]}{0[1]}_reg.txt".format(composition['elements'])
fname_inv = "Fe2{0[0]}{0[1]}_inv.txt".format(composition['elements'])
Cabinet.write_file(os.path.join(out_dir, 'text', fname_reg), rlines)
Cabinet.write_file(os.path.join(out_dir, 'text', fname_inv), ilines)
def plot():
plt = grapy.Vertical(3)
plt.set_title("Heusler Fe$_2${0[0]}{0[1]}"
.format(composition['elements']))
plt.set_style('blue')
plt.set123(regular, 'c/a', 'enthalpy', 'mag', 'mae')
plt.set_style('magenta')
plt.set123(inverse, 'c/a', 'enthalpy', 'mag', 'mae')
plt.adjust_auto()
plt.ax2.set_ylim(-0.5, 3)
plt.plot('show')
#fname = "Fe2{0[0]}{0[1]}.eps".format(composition['elements'])
#plt.plot(os.path.join(out_dir, fname))
plot()
示例8: change_conc
# 需要导入模块: from commopy import Cabinet [as 别名]
# 或者: from commopy.Cabinet import write_file [as 别名]
def change_conc():
"""
concを変更する
"""
list1 = [str(i*0.1) for i in range(0, 11)]
list2 = ['001', '100']
list3 = ['0.950', '1.000', '1.050', '1.100', '1.150',
'1.200', '1.250', '1.300', '1.350', '1.400',
'1.450', '1.500']
combi = Combinatorial(list1, list2, list3)
# print(combi.compositions)
comp_list = [x['elements']
for x in combi.compositions]
lines = ""
for comp in comp_list:
lines += "/".join(comp) + " run.sh\n"
print(lines)
Cabinet.write_file('list_run.txt', lines)
示例9: is_running
# 需要导入模块: from commopy import Cabinet [as 别名]
# 或者: from commopy.Cabinet import write_file [as 别名]
def is_running(self):
"""
jobが動作中かどうかcheckする
終了していた場合、running_jobsから削除
"""
cmd = ['qstat']
jobs = Popen(cmd, stdout=PIPE).communicate()[0].split(b'\n')
uname = getpass.getuser()
still_run = []
for job_id in self.running_jobs:
key = r"{0}.*{1}.*".format(job_id[:-1], uname)
meta = re.compile(key)
judge = True
for job in jobs:
if meta.match(job):
judge = None
if not judge:
still_run.append(job_id)
self.running_jobs = still_run
Cabinet.write_file(self.running_jobs_file, self.running_jobs)
示例10: write_incar
# 需要导入模块: from commopy import Cabinet [as 别名]
# 或者: from commopy.Cabinet import write_file [as 别名]
def write_incar(self, fname):
"""Write INCAR file"""
Cabinet.write_file(fname, str(self))
示例11: write_kpoints
# 需要导入模块: from commopy import Cabinet [as 别名]
# 或者: from commopy.Cabinet import write_file [as 别名]
def write_kpoints(self, fname='KPOINTS'):
"""Write KPOINTS file using self.kpoints"""
kp_lines = ('Automatic mesh\n0\nMonkhorst Pack\n'
' {0[0]} {0[1]} {0[2]}\n 0. 0. 0.\n'
.format(self.kpoints))
Cabinet.write_file(fname, kp_lines)