Page 1 of 1

How many KPOINTS for Relax Calculation

Posted: Wed Mar 27, 2024 3:50 am
by asgharali_jan
If a am using 21 21 1 mesh for scf calcualtions....do I need same k mesh for relax calculation with ISIF = 3 ?
is it ok if i use less kpoints in relax calculation and what would be consequence of it?

Thanks in advance

Re: How many KPOINTS for Relax Calculation

Posted: Wed Mar 27, 2024 8:25 am
by martin.schlipf
There is no general rule for this you would need to study the convergence of the property that you are interested in. But I can provide some recommendations that typically apply on how to select the k-point mesh.
  • Start your initial tests with a small mesh to get a feeling for how the system behaves. It should be just dense enough to capture the correct physics of the system.
  • You may even prerelax the structure with this coarse mesh if you have reason to believe that your structure may be very different from the relaxed one, e.g., because you manually constructed an interface.
  • Once, you have a preliminary understanding of the structure and its physics, compute the quantity that you are interested in, e.g. the structure or the bandgap.
  • Increase the density of the k-point mesh and recompute the property of interest until it doesn't change beyond what you consider an acceptable error.
So for your particular question: Yes, it may be possible to relax with a coarser mesh. But depending on the system it may change the properties more than what you want to accept as an error bar. As a rule of thumb, relaxations need a bit tighter convergence settings than scf calculations.

Re: How many KPOINTS for Relax Calculation

Posted: Wed Mar 27, 2024 11:54 am
by asgharali_jan
Thanks Dear Martin

Re: How many KPOINTS for Relax Calculation

Posted: Thu Mar 28, 2024 2:19 am
by hszhao.cn@gmail.com
Hi here,

I would like to add the following comments on the issues discussed here:

1. K-point grid mesh is related to KSPACING tag, say, in pymatgen, the following rule of thumb is used: MP uses 0.22 for metals and 0.44 for insulators with smooth interpolation in between based on band gap.

2. For the different types of relaxations, the relationship between the cell size and the K-point grid mesh size used does not always follow the same relationship, as shown in the following example:

Code: Select all

$ cat ./1_MgNi2_geo/POSCAR
Mg4 Ni8
1.0
   4.7933793068000004    0.0000000000000000    0.0000000000000000
  -2.3966896534000002    4.1511882496999997    0.0000000000000000
   0.0000000000000000    0.0000000000000000    7.8603634833999996
Mg Ni
4 8
direct
   0.6666666870000000    0.3333333430000000    0.5626903770000000 Mg
   0.3333333430000000    0.6666666870000000    0.0626903920000000 Mg
   0.3333333430000000    0.6666666870000000    0.4373096230000000 Mg
   0.6666666870000000    0.3333333430000000    0.9373096230000000 Mg
   0.0000000000000000    0.0000000000000000    0.5000000000000000 Ni
   0.0000000000000000    0.0000000000000000    0.0000000000000000 Ni
   0.8311911230000000    0.6623821850000000    0.2500000000000000 Ni
   0.1688089070000000    0.8311911230000000    0.7500000000000000 Ni
   0.6623821850000000    0.8311911230000000    0.7500000000000000 Ni
   0.3376178150000000    0.1688089070000000    0.2500000000000000 Ni
   0.8311911230000000    0.1688089070000000    0.2500000000000000 Ni
   0.1688089070000000    0.3376178150000000    0.7500000000000000 Ni

In [3]: from pymatgen.io.vasp.sets import MPMDSet
   ...: from pymatgen.core import Structure
   ...: from pymatgen.io.vasp.inputs import Kpoints
   ...: 
   ...: # Load the structure from a CIF file
   ...: structure = Structure.from_file("./1_MgNi2_geo/POSCAR")
   ...: 
   ...: # Define user INCAR settings
   ...: user_incar_settings = {
   ...:     'ALGO': 'N',
   ...:     'GGA': 'pe',
   ...:     "ISPIN": 1,
   ...: }
   ...: 
   ...: # Define a list of scaling factors for generating supercells
   ...: scaling_factors = [1, 2, 3]  # Example: Generate 1x1x1, 2x2x2, and 3x3x3 supercells
   ...: 
   ...: for scale in scaling_factors:
   ...:     # Generate the supercell
   ...:     supercell = structure.copy()
   ...:     supercell.make_supercell([scale, scale, scale])
   ...: 
   ...:     # Create VASP input files for the supercell
   ...:     vasp_input = MPMDSet(supercell, user_potcar_functional="PBE_64", user_incar_settings=user_incar_settings)
   ...: 
   ...:     # The Kpoints are automatically generated based on the supercell size by MPMetalRelaxSet
   ...:     # To directly observe and modify the k-point mesh, you might extract it from vasp_input if necessary
   ...: 
   ...:     # Print the mesh size for the current supercell for verification
   ...:     # Note: This approach assumes you're using a method to visualize or extract the kpoints directly.
   ...:     # Adjust the code as necessary to match your method of handling Kpoints.
   ...: 
   ...:     # The following line is a placeholder for where you would extract or check the k-point mesh:
   ...:     print(f"Supercell {scale}x{scale}x{scale} - Kpoints mesh: {vasp_input.kpoints.kpts}")
   ...: 
   ...:     # Write VASP input files to a directory named after the supercell size
   ...:     #output_dir = f"./supercell_{scale}x{scale}x{scale}"
   ...:     #vasp_input.write_input(output_dir)
/home/werner/Public/repo/github.com/materialsproject/pymatgen.git/pymatgen/io/vasp/sets.py:415: BadInputSetWarning: Overriding the POTCAR functional is generally not recommended  as it significantly affect the results of calculations and compatibility with other calculations done with the same input set. Note that some POTCAR symbols specified in the configuration file may not be available in the selected functional.
  warnings.warn(
Supercell 1x1x1 - Kpoints mesh: [(1, 1, 1)]
Supercell 2x2x2 - Kpoints mesh: [(1, 1, 1)]
Supercell 3x3x3 - Kpoints mesh: [(1, 1, 1)]

In [4]: from pymatgen.io.vasp.sets import MPMetalRelaxSet
   ...: from pymatgen.core import Structure
   ...: from pymatgen.io.vasp.inputs import Kpoints
   ...: 
   ...: # Load the structure from a CIF file
   ...: structure = Structure.from_file("./1_MgNi2_geo/POSCAR")
   ...: 
   ...: # Define user INCAR settings
   ...: user_incar_settings = {
   ...:     'ALGO': 'N',
   ...:     'GGA': 'pe',
   ...:     "ISPIN": 1,
   ...: }
   ...: 
   ...: # Define a list of scaling factors for generating supercells
   ...: scaling_factors = [1, 2, 3]  # Example: Generate 1x1x1, 2x2x2, and 3x3x3 supercells
   ...: 
   ...: for scale in scaling_factors:
   ...:     # Generate the supercell
   ...:     supercell = structure.copy()
   ...:     supercell.make_supercell([scale, scale, scale])
   ...: 
   ...:     # Create VASP input files for the supercell
   ...:     vasp_input = MPMetalRelaxSet(supercell, user_potcar_functional="PBE_64", user_incar_settings=user_incar_settings)
   ...: 
   ...:     # The Kpoints are automatically generated based on the supercell size by MPMetalRelaxSet
   ...:     # To directly observe and modify the k-point mesh, you might extract it from vasp_input if necessary
   ...: 
   ...:     # Print the mesh size for the current supercell for verification
   ...:     # Note: This approach assumes you're using a method to visualize or extract the kpoints directly.
   ...:     # Adjust the code as necessary to match your method of handling Kpoints.
   ...: 
   ...:     # The following line is a placeholder for where you would extract or check the k-point mesh:
   ...:     print(f"Supercell {scale}x{scale}x{scale} - Kpoints mesh: {vasp_input.kpoints.kpts}")
   ...: 
   ...:     # Write VASP input files to a directory named after the supercell size
   ...:     #output_dir = f"./supercell_{scale}x{scale}x{scale}"
   ...:     #vasp_input.write_input(output_dir)
/home/werner/Public/repo/github.com/materialsproject/pymatgen.git/pymatgen/io/vasp/sets.py:415: BadInputSetWarning: Overriding the POTCAR functional is generally not recommended  as it significantly affect the results of calculations and compatibility with other calculations done with the same input set. Note that some POTCAR symbols specified in the configuration file may not be available in the selected functional.
  warnings.warn(
Supercell 1x1x1 - Kpoints mesh: [[8, 8, 4]]
Supercell 2x2x2 - Kpoints mesh: [[4, 4, 2]]
Supercell 3x3x3 - Kpoints mesh: [[2, 2, 1]]
As you can see, as a rule of thumb, a 1 * 1 * 1 k-point mesh is usually enough for an AIMD relaxation computation, but this is generally not the case for other types of relaxation.

Regards,
Zhao