本文整理汇总了Python中vasp.Vasp.write_db方法的典型用法代码示例。如果您正苦于以下问题:Python Vasp.write_db方法的具体用法?Python Vasp.write_db怎么用?Python Vasp.write_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vasp.Vasp
的用法示例。
在下文中一共展示了Vasp.write_db方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test0
# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import write_db [as 别名]
def test0():
atoms = Atoms([Atom('O', [4, 5, 5], magmom=1),
Atom('C', [5, 5, 5], magmom=2),
Atom('O', [6, 5, 5], magmom=3)],
cell=(10, 10, 10))
calc = Vasp('vasp',
sigma=0.01,
atoms=atoms)
calc.write_db(fname='DB.db', append=False)
with connect('DB.db') as con:
data = con.get(1).data
assert data['parameters']['sigma'] == 0.01
print 'done'
示例2: db_update
# 需要导入模块: from vasp import Vasp [as 别名]
# 或者: from vasp.Vasp import write_db [as 别名]
def db_update(db_path, dft_path, delete=False, silent=False):
"""Update the database to include Vasp() calculations nested in dft_path."""
VASPRC['mode'] = None
db = connect(db_path)
old_size = sum(1 for _ in db.select())
db_paths = []
for d in db.select():
try:
db_paths.append(d.data.path)
except:
pass
for path in utils.calc_paths(dft_path):
if os.path.abspath(path) in db_paths:
continue
calc = Vasp(path)
if not calc.in_queue() and calc.potential_energy is None:
for output_file in utils.calc_output_files(path):
dead_file = os.path.join(path, output_file)
if delete:
os.remove(dead_file)
if not silent:
print("Dead output file: {}. Deleted: {}".format(dead_file, delete))
else:
ctime = calc.get_elapsed_time()
# The write_db method throws an AttributeError for new calcs. Remove this to debug.
old_stdout = sys.stdout
sys.stdout = open(os.devnull, "w")
calc.write_db(db_path, parser='=',
overwrite=False,
data={'ctime': ctime})
sys.stdout.close()
sys.stdout = old_stdout
if not silent:
print("Added calc to DB: {}".format(path))
new_size = sum(1 for _ in db.select())
added = new_size - old_size
if not silent:
print("{} total entries. {} new entries added.".format(new_size, added))