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