def test_conv_table(): xx1 = ['a', 'b', 'c'] xx2 = np.array([1, 2, 3]) * np.pi yy1 = [1, 2, 3] yy2 = [1.2, 2.3, 3.4] yy3 = [1.666, 2.777, 3.888] for xx in [xx1, xx2]: for mode in ['next', 'last']: st1 = conv_table(xx, yy1, mode=mode) st2 = conv_table(xx, [yy1], mode=mode) assert st1 == st2 st1 = conv_table(xx, [yy1, yy2], mode=mode) st2 = conv_table(xx, np.array([yy1, yy2]), mode=mode) assert st1 == st2 st1 = conv_table(xx, [yy1, yy2, yy3], mode=mode) st2 = conv_table(xx, np.array([yy1, yy2, yy3]), mode=mode) assert st1 == st2 # API conv_table(xx, [yy1, yy2, yy3], mode='last', orig=True)
def test_conv_table(): xx1 = ['a', 'b', 'c'] xx2 = np.array([1,2,3])*np.pi yy1 = [1,2,3] yy2 = [1.2,2.3,3.4] yy3 = [1.666,2.777,3.888] for xx in [xx1, xx2]: for mode in ['next','last']: st1 = conv_table(xx, yy1, mode=mode) st2 = conv_table(xx, [yy1], mode=mode) assert st1 == st2 st1 = conv_table(xx, [yy1,yy2], mode=mode) st2 = conv_table(xx, np.array([yy1,yy2]), mode=mode) assert st1 == st2 st1 = conv_table(xx, [yy1,yy2,yy3], mode=mode) st2 = conv_table(xx, np.array([yy1,yy2,yy3]), mode=mode) assert st1 == st2 # API conv_table(xx, [yy1,yy2,yy3], mode='last', orig=True)
#!/usr/bin/python # Print result of convergence study: differences of etot, pressure from pwtools import sql, batch, mpl db = sql.SQLiteDB('calc.db') etot_fac = 1000.0/4 # eV -> meV/atom, 4 atoms data = db.get_array("select ecutwfc,etot,pressure from calc order by ecutwfc") print "ecutwfc, diff(etot) [meV/atom], diff(pressure) [GPa]" print batch.conv_table(data[:,0], [data[:,1]*etot_fac, data[:,2]], mode='last', orig=False) # plotting fig,ax = mpl.fig_ax() ax.plot(data[:,0], (data[:,1]-data[-1,1])*etot_fac, label='etot', color='b') ax.set_ylabel('diff(etot) [meV/atom]') ax.set_xlabel('ecutwfc [Ry]') ax.legend() mpl.plt.show()
#!/usr/bin/python # Print result of convergence study: differences of etot, pressure from pwtools import sql, batch, mpl db = sql.SQLiteDB('calc.db') etot_fac = 1000.0 / 4 # eV -> meV/atom, 4 atoms data = db.get_array("select ecutwfc,etot,pressure from calc order by ecutwfc") print("ecutwfc, diff(etot) [meV/atom], diff(pressure) [GPa]") print( batch.conv_table(data[:, 0], [data[:, 1] * etot_fac, data[:, 2]], mode='last', orig=False)) # plotting fig, ax = mpl.fig_ax() ax.plot(data[:, 0], (data[:, 1] - data[-1, 1]) * etot_fac, label='etot', color='b') ax.set_ylabel('diff(etot) [meV/atom]') ax.set_xlabel('ecutwfc [Ry]') ax.legend() mpl.plt.show()