pwtools.batch.conv_table

pwtools.batch.conv_table(xx, yy, ffmt='%15.4f', sfmt='%15s', mode='last', orig=False, absdiff=False)[source]

Convergence table. Assume that quantity xx was varied, resulting in yy values. Return a string (table) listing:

x, dy1, dy2, ...

Useful for quickly viewing the results of a convergence study, where we assume that the sequence of yy values converges to a constant value.

Parameters:
  • xx (1d sequence) –

  • yy (1d sequence, nested 1d sequences, 2d array) – Values varied with xx. Each row is one parameter.

  • ffmt (str) – Format strings for floats (ffmt) and strings (sfmt)

  • sfmt (str) – Format strings for floats (ffmt) and strings (sfmt)

  • mode (str) – ‘next’ or ‘last’. Difference to the next value y[i+1] - y[i] or to the last y[-1] - y[i].

  • orig (bool) – Print original yy data as well.

  • absdiff (bool) – absolute values of differences

Examples

>>> kpoints = ['2 2 2', '4 4 4', '8 8 8']
>>> etot = [-300.0, -310.0, -312.0]
>>> forces_rms = [0.3, 0.2, 0.1]
>>> print(batch.conv_table(kpoints, etot, mode='last'))
      2 2 2       -12.0000
      4 4 4        -2.0000
      8 8 8         0.0000
>>> print(batch.conv_table(kpoints, [etot,forces_rms], mode='last'))
      2 2 2       -12.0000        -0.2000
      4 4 4        -2.0000        -0.1000
      8 8 8         0.0000         0.0000
>>> print(batch.conv_table(kpoints, [etot,forces_rms], mode='last', orig=True))
      2 2 2       -12.0000      -300.0000        -0.2000         0.3000
      4 4 4        -2.0000      -310.0000        -0.1000         0.2000
      8 8 8         0.0000      -312.0000         0.0000         0.1000
>>> print(batch.conv_table(kpoints, np.array([etot,forces_rms]), mode='next'))
      2 2 2       -10.0000        -0.1000
      4 4 4        -2.0000        -0.1000
      8 8 8         0.0000         0.0000