How to Calculate Grid Density for Given KSPACING?

Question on input files/tags, interpreting output, etc.

Please check whether the answer to your question is given in the VASP online manual or has been discussed in this forum previously!

Moderators: Global Moderator, Moderator

Post Reply
Message
Author
hszhao.cn@gmail.com
Full Member
Full Member
Posts: 139
Joined: Tue Oct 13, 2020 11:32 pm

How to Calculate Grid Density for Given KSPACING?

#1 Post by hszhao.cn@gmail.com » Tue Mar 26, 2024 12:15 am

Hi here,

I'm currently working on setting up my VASP calculations and trying to understand how to derive the k-point grid mess size based on the KSPACING parameter. Could you guide me on how to calculate or estimate the grid density from a given KSPACING value?

Say, I set the following in INCAR:

Code: Select all

KSPACING = 0.02  in \AA ^-1
Then, I want to know the corresponding n1 * n2 * n3 mesh when using a KPOINTS file.

Any advice or pointers to relevant documentation would be greatly appreciated.

See here for the related discussion.

Thanks,
Zhao

martin.schlipf
Global Moderator
Global Moderator
Posts: 495
Joined: Fri Nov 08, 2019 7:18 am

Re: How to Calculate Grid Density for Given KSPACING?

#2 Post by martin.schlipf » Tue Mar 26, 2024 1:52 pm

If you want to compute the grid by hand, I recommend studying the description of the INCAR tag KSPACING. There it is explained how the grid density is selected based on the value that is set and whether KGAMMA is set or not.

Many times it may be easier to just run VASP to look at the generated mesh though. You may want to use the dry-run mode to skip over the expensive parts of the calculation

Code: Select all

mpirun -np 1 /path/to/vasp_std --dry-run
Then VASP will finish after the k-point mesh has been generated and you will find an output like

Code: Select all

Automatic generation of k-mesh.
 Grid dimensions derived from KSPACING:
 generate k-points for:   10   10   10
in the OUTCAR file that contains the information you need.

hszhao.cn@gmail.com
Full Member
Full Member
Posts: 139
Joined: Tue Oct 13, 2020 11:32 pm

Re: How to Calculate Grid Density for Given KSPACING?

#3 Post by hszhao.cn@gmail.com » Wed Mar 27, 2024 12:59 am

Dear martin.schlipf,

Based on the specification described in INCAR tag KSPACING and source code file mkpoints.F, in this case, NKPX, NKPY, and NKPZ is derived using the lattice norms (BNORM) and the spacing (KSPACING). The optional multiplier (MULTIPL) is also considered if provided. Here's the implementation in Python:

Code: Select all

import math

def calculate_grid_dimensions(bnorm, spacing, multipl=None):
    """
    Calculate the Monkhorst-Pack grid dimensions based on lattice norms and spacing.

    :param bnorm: Lattice norms (list or tuple of three floats).
    :param spacing: KPOINTS spacing (float).
    :param multipl: Optional multiplier (list or tuple of three integers).
    :return: Tuple of grid dimensions (NKPX, NKPY, NKPZ).
    """
    # Calculate initial grid dimensions based on spacing
    nkpx = max(1, math.ceil(bnorm[0] * math.pi * 2 / spacing))
    nkpy = max(1, math.ceil(bnorm[1] * math.pi * 2 / spacing))
    nkpz = max(1, math.ceil(bnorm[2] * math.pi * 2 / spacing))

    # Apply multiplier if provided
    if multipl:
        nkpx *= multipl[0]
        nkpy *= multipl[1]
        nkpz *= multipl[2]

    return nkpx, nkpy, nkpz

# Example usage
bnorm = [1.0, 2.0, 3.0]  # Example lattice norms
spacing = 0.5  # Example KPOINTS spacing
multipl = [2, 2, 2]  # Example multiplier

nkpx, nkpy, nkpz = calculate_grid_dimensions(bnorm, spacing, multipl)
print("Grid dimensions:", nkpx, nkpy, nkpz)
This Python function calculate_grid_dimensions mirrors the Fortran logic for determining the Monkhorst-Pack grid dimensions (NKPX, NKPY, NKPZ) based on the lattice norms (BNORM), the Monkhorst-Pack spacing (KSPACING), and an optional multiplier (MULTIPL).

However, one of my doubts is that the parameter MULTIPL does not seem to be mentioned in the input files of vasp, so I do not know how to provide it to the above function for use. If there are any other logical problems, welcome further communication and correction.

Regards,
Zhao

martin.schlipf
Global Moderator
Global Moderator
Posts: 495
Joined: Fri Nov 08, 2019 7:18 am

Re: How to Calculate Grid Density for Given KSPACING?

#4 Post by martin.schlipf » Wed Mar 27, 2024 8:15 am

I think the only point where the multiplier is used is for cRPA calculations or do you have a calculation which runs multiple times through this routine? In that particular case the multiplier seems to be hard coded looping over 1..36.

hszhao.cn@gmail.com
Full Member
Full Member
Posts: 139
Joined: Tue Oct 13, 2020 11:32 pm

Re: How to Calculate Grid Density for Given KSPACING?

#5 Post by hszhao.cn@gmail.com » Wed Mar 27, 2024 11:26 am

Dear martin.schlipf,

I don't seem to have encountered any such situation before.

Regards,
Zhao

Post Reply