Remove old stuff

parent bbb78e65
Pipeline #21494786 passed with stage
in 3 minutes and 10 seconds
from myqueue.job import Job
def workflow():
jobs = [Job('g2_dzp.py+{}@4x13h'.format(i)) for i in range(10)]
return jobs + [Job('g2_dzp_csv.py', deps=jobs)]
import time
import ase.db
import ase.optimize
from ase.collections import g2
from gpaw import GPAW, Mixer
optimizers = ['BFGS', 'BFGSLineSearch',
'FIRE', 'GoodOldQuasiNewton',
'LBFGS', 'LBFGSLineSearch']
con = ase.db.connect('g2_dzp.db')
for name, atoms in zip(g2.names, g2):
if len(atoms) == 1:
continue
atoms.center(vacuum=3.5)
for optimizer in optimizers:
id = con.reserve(name=name, optimizer=optimizer)
if id is None:
continue
mol = atoms.copy()
mol.calc = GPAW(mode='lcao',
basis='dzp',
h=0.17,
xc='PBE',
mixer=Mixer(0.05, 2),
txt='{0}-{1}.txt'.format(name, optimizer))
Optimizer = getattr(ase.optimize, optimizer)
opt = Optimizer(mol)
t = time.time()
try:
opt.run(fmax=0.05, steps=50)
except Exception as ex:
print(name, optimizer, ex)
continue
con.write(mol, name=name, optimizer=optimizer,
steps=opt.nsteps, time=time.time() - t)
del con[id]
# Creates: g2_dzp.csv
from __future__ import print_function
import numpy as np
import ase.db
con = ase.db.connect('g2_dzp.db')
N = 6 # number of optimizers
M = len(con) // N # number of molecules
data = []
for row in con.select():
data.append((row.optimizer,
row.name,
row.get('time', 42),
row.get('steps', 42),
row.get('energy', 42),
row.get('fmax', 42)))
data.sort()
optimizers = [x[0] for x in data[::M]]
data = np.array([x[2:] for x in data]).reshape((N, M, 4))
e0 = data[:, :, 2].min(0)
results = []
for opt, d in zip(optimizers, data):
ok = (d[:, 3] < 0.05) & (d[:, 2] < e0 + 0.1)
failed = M - sum(ok)
time, niter = d[ok, :2].mean(0)
results.append((failed, time, niter, opt))
with open('g2_dzp.csv', 'w') as f:
for failed, time, niter, opt in sorted(results):
print('{0}, {1}, {2:.1f}, {3:.1f}'.format(opt, failed, time, niter),
file=f)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment