ml-evs / matador

⚗️ matador is an aggregator, manipulator and runner of first-principles calculations, written with a bent towards battery 🔋 electrode materials.
https://matador-db.readthedocs.io
MIT License
29 stars 19 forks source link

k-point sampling grid help #126

Closed sajidurehman closed 4 years ago

sajidurehman commented 4 years ago

Hi Matthew, Is it possible to use grid values for band structure and DOS calculations in .cell file. I tried in following manner but its not working.

kpoints_mp_grid: 4 4 4 spectral_kpoints_mp_grid: 10 10 10 spectral_kpoints_path_spacing: 0.05

Could you please guide me how to use grid values rather than spacing?. Thank you in advance.

ml-evs commented 4 years ago

Hi @sajidurehman, this isn't currently possible as it tends to better to use a spacing over a grid when performing high-throughput calculations. The kpoints_mp_grid should be used for the SCF calculations by run3, but spectral_kpoints_mp_grid will not trigger the DOS calculation; can you just use the spacing corresponding to that grid?

sajidurehman commented 4 years ago

Thank you for reply. Actually i have not a proper idea how to calculate grid from correspond spacing. Could you please let me know how to calculate that?

ml-evs commented 4 years ago

Here are the functions I use to do it:

Calculate spacing from a grid: https://github.com/ml-evs/matador/blob/362996799efd9231e061b8230d609689219b5f27/matador/utils/cell_utils.py#L337-L358

Calculate grid from a spacing: https://github.com/ml-evs/matador/blob/362996799efd9231e061b8230d609689219b5f27/matador/utils/cell_utils.py#L245-L261

For a uniform Monkhorst-Pack grid, just divide the cell lengths of reciprocal lattice (e.g. printed in the CASTEP file alongside the real space lattice) by the desired spacing along each direction in turn, making sure to round up to the nearest integer. CASTEP also includes an extra factor of 2π in their definition (which cancels out in the grid calculation)

Concrete example: Calculating MP grid [n1, n2, n3] for real space cell with lengths a, b, c = (10, 20, 30) and desired kpoint-spacing of 0.05 1/Å.

First get reciprocal space lattice lengths: (2π/10, 2π/12, 2π/8)

n1 = ceiling( (2π/10) / (0.05 * 2 π)) = ceiling(1 / (10 * 0.05)) -> 2 n2 = ceiling(1 / (12 * 0.05)) -> 2 n3 = ceiling(1 / (8 * 0.05)) -> 3

so your spectral_kpoints_mp_grid: 2 2 3. This is the grid that would be used by CASTEP if you just specified spectral_kpoints_mp_spacing: 0.05.

sajidurehman commented 4 years ago

Thank you for such a detailed reply. I tried an example for ZnS with real space cell lengths a=b=c=3.854.

n = ceiling(3.854 / (0.05 * 2 π)) = ceiling(12.267) -> 12

So our spectral_kpoints_mp_grid: 12 12 12. But I tried same ZnS structure in Materials Studio ann got 6 6 6 grid. Is there any problem in my calculation?

ml-evs commented 4 years ago

Whoops, sorry, I meant reciprocal space lengths not real space in my comment above! I'll edit the comment accordingly

ml-evs commented 4 years ago

Following edited comment above: in your case you get (1 / 0.05 * 3.85) = 5.184 -> 6 as expected.

sajidurehman commented 4 years ago

Thank you for clarification. Is it possible to use both functions (spacing to grid and grid to spacing) directly from matador/matador/utils/cell_utils.py? like I just give spacing and got grid and vice versa.

ml-evs commented 4 years ago
> from matador.utils.cell_utils import calc_mp_grid, calc_mp_spacing, abc2cart
> lattice = ((3.854, 3.854, 3.854), (90, 90, 90))
> lattice_cart = abc2cart(lattice)
> calc_mp_grid(lattice_cart, 0.05)
[6, 6, 6]
> calc_mp_spacing(lattice_cart, [6, 6, 6])
0.043
> calc_mp_grid(lattice_cart, 0.02)
[13, 13, 13]
> calc_mp_spacing(lattice_cart, [13, 13, 13])
0.02
sajidurehman commented 4 years ago

Thank you so much. You saved my day.