# How to do k-point convergence test?

I'm looking to do a k-point convergence test but I am unsure how to proceed. My current KPOINTS file is:

KPOINTS
0
Gamma
4 1 2
0 0 0


I am aware that it is supposed to converge at 4 1 2 with 160 atoms, but unsure on the process to get there.

Once you do get the results from the convergence test, what would the y-axis values be represented by?

• You should not be trying to learn about stuff with 160 atoms. You should be learning about it with a simple system that can complete the calculations quickly. Commented Jul 27 at 15:24

@naturallyInconsistent's point (that the basics are best learnt on a simple system) are true. Generally, we use the primitive cell of Si (commonly called Si2), as that is just nice, and works very reliably.

The important concepts here is that the concept you are converging is the density of the k-point mesh in reciprocal space. This means that longer reciprocal lattice vectors require more points to achieve the same density. It is worth recalling that the ratios of reciprocal lattice vectors are the inverse of the ratio of the real space lattice vectors, so the smaller the real space lattice, the more points that you will need in that direction. So, generally it is common practice to keep the k-points in the same ratio as the reciprocal lattice vectors, and then scale from there.

The next point is to know what you are converging. The most common quantity you will see being converged is the total energy (however this is not always the most appropriate quantity: for example, when converging to prepare for a phonon calculation you will find that stress is a better proxy for your phonon mode convergence than the total energy of your system).

Accordingly, the first step of converging your k-points is to run your code to extract your chosen convergence parameter for that system. Then note what this was, and run again with a denser k-point mesh. You should find that your answer will not be the same (at least, not the same to N decimal places). Now run it again with an even denser grid. You should find that the answers are not the same, but will be identical to a higher number of decimal places.

The aim of convergence testing is to determine when you can stop increasing your number (in this case, your k-points). This is the point where there is no universal answer. If you are investigating properties on the 10 eV energy scale (for the sake of argument) converging to 10 meV would be sufficient to claim accuracy, whereas for properties on the meV scale, that same threshold would be woeful: it is all about the signal (the property you care about) to noise (uncertainty due to incomplete convergence) ratio. Ultimately, deciding what threshold is "converged" is up to you as a scientist to decide.

Hope that helps,

Rob

Following the recommendations above given by @robert-lawrence, the fast way to implement his advice is to use a script that creates the input files, one at a time, for a given set of k-points. Then optimize the system (or calculate the property you want to converge. From the output files, get the property value and the k-point used and add to a table. Then plot the data.

Below is an old script used to study the convergence of the total energy as a function of the mess cut-off parameter using the SIESTA software.

#!/bin/bash
#rm E_vs_h.dat
tmp=0
# Numero de pontos para fazer a curva Energia vs h
for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
do
tmp=echo "$i" | bc mesh=echo "150+$i*25" | bc
cat > BN_SWNT_MeshCutoff-$i.fdf <<! SystemName BN_SWNT_MeshCutoff-$$i SystemLabel BN_SWNT_MeshCutoff-$$i NumberOfAtoms 120 NumberOfSpecies 2 %block ChemicalSpeciesLabel 1 7 N 2 5 B %endblock ChemicalSpeciesLabel LatticeConstant 1.0 Ang %block LatticeParameters 19.732500 19.732500 12.780000 90.000000 90.000000 90.000000 %endblock LatticeParameters AtomicCoordinatesFormat NotScaledCartesianAng %block AtomicCoordinatesAndAtomicSpecies 13.83449859 9.97218526 0.70792856 2 1 B 13.88703720 9.97257250 2.13204539 1 2 N 13.61137793 11.19419824 2.83801327 2 3 B 13.65851851 11.21138862 0.00237940 1 4 N 13.01712386 12.28595915 0.70829688 2 5 B 13.05936802 12.31769682 2.13195531 1 6 N 12.11345363 13.13753520 2.83848680 2 7 B 12.14392778 13.18244285 0.00236737 1 8 N 10.99327298 13.67347975 0.70812820 2 9 B 11.00710824 13.72275322 2.13209069 1 10 N 9.76028617 13.83450331 2.83806217 2 11 B 9.75995195 13.88703014 0.00214602 1 12 N 8.53829948 13.61137958 0.70789208 2 13 B 8.52112956 13.65852150 2.13227472 1 14 N 7.44655823 13.01713343 2.83841005 2 15 B 7.41480598 13.05935655 0.00210116 1 16 N 6.59497932 12.11345223 0.70832091 2 17 B 6.55004741 12.14393668 2.13227488 1 18 N 6.05902086 10.99330487 2.83822450 2 19 B 6.00975653 11.00706338 0.00225647 1 20 N 5.89800140 9.76031475 0.70792856 2 21 B 5.84546280 9.75992751 2.13204539 1 22 N 6.12112207 8.53830177 2.83801327 2 23 B 6.07398149 8.52111138 0.00237940 1 24 N 6.71537614 7.44654085 0.70829688 2 25 B 6.67313199 7.41480317 2.13195531 1 26 N 7.61904637 6.59496480 2.83848680 2 27 B 7.58857221 6.55005716 0.00236737 1 28 N 8.73922703 6.05902025 0.70812820 2 29 B 8.72539175 6.00974678 2.13209069 1 30 N 9.97221383 5.89799668 2.83806217 2 31 B 9.97254804 5.84546986 0.00214602 1 32 N 11.19420052 6.12112042 0.70789208 2 33 B 11.21137044 6.07397850 2.13227472 1 34 N 12.28594177 6.71536657 2.83841005 2 35 B 12.31769402 6.67314344 0.00210117 1 36 N 13.13752068 7.61904777 0.70832092 2 37 B 13.18245260 7.58856333 2.13227488 1 38 N 13.67347914 8.73919512 2.83822450 2 39 B 13.72274347 8.72543662 0.00225647 1 40 N 13.83449650 9.97219678 4.96797262 2 41 B 13.88703014 9.97254805 6.39214602 1 42 N 13.61137958 11.19420051 7.09789207 2 43 B 13.65849816 11.21137107 4.26236088 1 44 N 13.01710441 12.28596975 4.96825493 2 45 B 13.05935655 12.31769402 6.39210117 1 46 N 12.11345223 13.13752068 7.09832092 2 47 B 12.14395804 13.18243018 4.26239178 1 48 N 10.99329770 13.67348599 4.96808178 2 49 B 11.00706338 13.72274348 6.39225648 1 50 N 9.76031475 13.83449859 7.09792857 2 51 B 9.75990202 13.88703070 4.26218971 1 52 N 8.53830865 13.61138837 4.96787519 2 53 B 8.52111137 13.65851852 6.39237940 1 54 N 7.44654085 13.01712387 7.09829689 2 55 B 7.41478808 13.05934362 4.26211121 1 56 N 6.59498048 12.11347614 4.96833387 2 57 B 6.55005715 12.14392778 6.39236737 1 58 N 6.05902025 10.99327298 7.09812820 2 59 B 6.00976433 11.00710442 4.26224438 1 60 N 5.89800350 9.76030323 4.96797262 2 61 B 5.84546986 9.75995196 6.39214602 1 62 N 6.12112042 8.53829948 7.09789208 2 63 B 6.07400184 8.52112893 4.26236089 1 64 N 6.71539559 7.44653025 4.96825493 2 65 B 6.67314344 7.41480598 6.39210117 1 66 N 7.61904776 6.59497932 7.09832092 2 67 B 7.58854196 6.55006981 4.26239178 1 68 N 8.73920230 6.05901402 4.96808178 2 69 B 8.72543663 6.00975653 6.39225648 1 70 N 9.97218525 5.89800141 7.09792857 2 71 B 9.97259798 5.84546930 4.26218972 1 72 N 11.19419134 6.12111163 4.96787519 2 73 B 11.21138863 6.07398148 6.39237940 1 74 N 12.28595915 6.71537613 7.09829688 2 75 B 12.31771192 6.67315638 4.26211121 1 76 N 13.13751952 7.61902386 4.96833387 2 77 B 13.18244285 7.58857222 6.39236737 1 78 N 13.67347975 8.73922702 7.09812820 2 79 B 13.72273567 8.72539558 4.26224438 1 80 N 13.83450331 9.97221383 9.22806217 2 81 B 13.88703070 9.97259798 10.65218971 1 82 N 13.61138837 11.19419134 11.35787519 2 83 B 13.65852151 11.21137044 8.52227472 1 84 N 13.01713343 12.28594177 9.22841005 2 85 B 13.05934362 12.31771192 10.65211121 1 86 N 12.11347614 13.13751952 11.35833386 2 87 B 12.14393668 13.18245259 8.52227488 1 88 N 10.99330488 13.67347915 9.22822450 2 89 B 11.00710443 13.72273568 10.65224437 1 90 N 9.76030322 13.83449650 11.35797262 2 91 B 9.75992750 13.88703720 8.52204539 1 92 N 8.53830176 13.61137793 9.22801327 2 93 B 8.52112893 13.65849816 10.65236089 1 94 N 7.44653025 13.01710441 11.35825493 2 95 B 7.41480318 13.05936802 8.52195531 1 96 N 6.59496480 12.11345363 9.22848679 2 97 B 6.55006982 12.14395803 10.65239178 1 98 N 6.05901401 10.99329769 11.35808178 2 99 B 6.00974677 11.00710825 8.52209068 1 100 N 5.89799668 9.76028617 9.22806217 2 101 B 5.84546929 9.75990202 10.65218972 1 102 N 6.12111163 8.53830866 11.35787519 2 103 B 6.07397849 8.52112956 8.52227472 1 104 N 6.71536657 7.44655823 9.22841005 2 105 B 6.67315638 7.41478808 10.65211121 1 106 N 7.61902387 6.59498048 11.35833387 2 107 B 7.58856333 6.55004741 8.52227488 1 108 N 8.73919512 6.05902085 9.22822450 2 109 B 8.72539558 6.00976433 10.65224438 1 110 N 9.97219678 5.89800350 11.35797262 2 111 B 9.97257250 5.84546280 8.52204539 1 112 N 11.19419824 6.12112207 9.22801327 2 113 B 11.21137107 6.07400184 10.65236088 1 114 N 12.28596975 6.71539559 11.35825493 2 115 B 12.31769682 6.67313198 8.52195531 1 116 N 13.13753520 7.61904637 9.22848680 2 117 B 13.18243019 7.58854196 10.65239179 1 118 N 13.67348599 8.73920230 11.35808178 2 119 B 13.72275323 8.72539175 8.52209069 1 120 N %endblock AtomicCoordinatesAndAtomicSpecies PAO.BasisSize DZP MD.TypeOfRun CG MD.NumCGsteps 100 MaxSCFIterations 500 SpinPolarized .true. MeshCutoff $$mesh Ry DM.MixingWeight 0.01 DM.NumberPulay 3 XC.functional LDA XC.authors CA SolutionMethod diagon # Fim do input para o SIESTA ! mpirun -np 12 siesta < BN_SWNT_MeshCutoff-$$i.fdf > BN_SWNT_MeshCutoff-$$i.out E=$$(grep "siesta: Total" BN_SWNT_MeshCutoff-$$i.out | grep '='| awk '{printf "%12.6f \n",4}') echo$$mesh $$E$$i >> E_vs_mesh.dat done  In this script: • There is a for loop with 20 points: for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 • The value of the mesh is calculated for each value of the loop: mesh=echo "150+$i*25" | bc
• Export the input file using command cat: cat > BN_SWNT_MeshCutoff-$i.fdf <<! (here is input value has the value of the loop variable at the name). • run the SIESTA calculation for each input file: mpirun -np 12 siesta < BN_SWNT_MeshCutoff-$i.fdf > BN_SWNT_MeshCutoff-$i.out • Extract the total energy value from the corresponding output: E=$(grep "siesta: Total" BN_SWNT_MeshCutoff-$i.out | grep '='| awk '{printf "%12.6f \n",$4}')
• Export the extracted values to a data file: echo $mesh$E \$i >> E_vs_mesh.dat
• Plot the E_vs_mesh.dat`