Example: DOS and BandStructure from a previous calculation¶
It is quite likely that you did a calculation, but forgot to request the DOS or BandStructure. Or maybe you did but want to use different settings.
Fortunately it is possible to calculate these directly from the previous calculation. The traditional way was to restart the SCF, but this is no longer needed.
With the restart of the DOS it has become possible to calculate the DOS with a finer k-space sampling. In this example it is shown that the DOS calculated this way matches well the DOS obtained from a full calculation with a dense k-grid (for both the SCF and DOS).
The example below features some concepts
use environment variables to control in one place repeated settings
DOS calculated on a fixed grid. This is not really needed, but it makes the comparison between different DOS results much more stable.
KSpace%Regular%DoubleCount
key. Useful when you want to check against a k-grid that is twice as dense.A text report is created, useful for automatic testing.
–delete-old-results. Allow ams to overwrite an existing results folder.
Download RestartDosAndBandStructure.run
#!/bin/bash
# some env. variables to control settings
unr=no
k_quality=Normal
DOSLINE="DOS CalcPDos=true Energies=300 AbsoluteMaxMin=yes Min=-0.3 Max=0.2"
BANDSTTRUCTURELINE="BandStructure Enabled=true DeltaK=0.03"
cat << eor > convergence.inc
SCF Method=DIIS
Convergence Criterion=1e-8
eor
report=report.txt
echo "" > $report
base=test.unr=$unr.k_quality=$k_quality
export AMS_JOBNAME=$base
# First calculation, where we "forget" to request the PDOS and BandStructure, or did not satisfactory settings for those.
$AMSBIN/ams --delete-old-results << eor
Task SinglePoint
System
Atoms
Cu -1.014698231 -0.585836297 0.414248818
Ni 1.014698231 0.585836297 -0.414248818
End
Lattice
4.058792924 0.000000000 0.000000000
2.029396462 3.515017781 0.000000000
End
End
Engine Band
Unrestricted $unr
KSpace Quality=$k_quality
@include convergence.inc
$DOSLINE
$BANDSTTRUCTURELINE
EndEngine
eor
export AMS_JOBNAME=$base.betterk
# We could have done the calculation with a better k-grid
$AMSBIN/ams --delete-old-results << eor
Task SinglePoint
System
Atoms
Cu -1.014698231 -0.585836297 0.414248818
Ni 1.014698231 0.585836297 -0.414248818
End
Lattice
4.058792924 0.000000000 0.000000000
2.029396462 3.515017781 0.000000000
End
End
Engine Band
Unrestricted $unr
KSpace
Quality $k_quality
Regular DoubleCount=1 # use a twice as dense k-grid. You could also use a better KSpace%Quality, or set a more dense grid otherwise.
End
@include convergence.inc
$DOSLINE
$BANDSTTRUCTURELINE
EndEngine
eor
$AMSBIN/amspython $AMSHOME/scripting/tools/comparekf.py --dot-product $base.results/band.rkf $base.betterk.results/band.rkf "DOS%Total DOS" >> $report
# We can request the dos and band structure simply restarting the SCF.
export AMS_JOBNAME=$base.restartscf
$AMSBIN/ams --delete-old-results << eor
Task SinglePoint
LoadSystem
File $base.results/ams.rkf
End
Engine Band
Unrestricted $unr
KSpace Quality=$k_quality
Restart
File $base.results/band.rkf
SCF true
End
@include convergence.inc
$DOSLINE
$BANDSTTRUCTURELINE
EndEngine
eor
# We can also request both the DOS and BandStructure in a restart, avoiding restarting the SCF
export AMS_JOBNAME=$base.restartdos
$AMSBIN/ams --delete-old-results << eor
Task SinglePoint
LoadSystem
File $base.results/ams.rkf
End
Engine Band
Unrestricted $unr
KSpace Quality=$k_quality
Restart
File $base.restartscf.results/band.rkf # can as well be restarted from $base.results/band.rkf. this restart used for the most precise comparison
Dos true
BandStructure true
End
@include convergence.inc
$DOSLINE
$BANDSTTRUCTURELINE
EndEngine
eor
$AMSBIN/amspython $AMSHOME/scripting/tools/comparekf.py --dot-product $base.results/band.rkf $base.restartscf.results/band.rkf "DOS%Total DOS" >> $report
$AMSBIN/amspython $AMSHOME/scripting/tools/comparekf.py --dot-product $base.results/band.rkf $base.restartdos.results/band.rkf "DOS%Total DOS" >> $report
$AMSBIN/amspython $AMSHOME/scripting/tools/comparekf.py --dot-product $base.restartscf.results/band.rkf $base.restartdos.results/band.rkf "DOS%Total DOS" >> $report
# We can even use a better k-space sampling which improves the DOS. BandStructure not affected.
export AMS_JOBNAME=$base.restartdosbetterk
$AMSBIN/ams --delete-old-results << eor
Task SinglePoint
LoadSystem
File $base.results/ams.rkf
End
Engine Band
Unrestricted $unr
KSpace
Quality $k_quality
Regular DoubleCount=1 # use a twice as dense k-grid. You could also use a better KSpace%Quality, or set a more dense grid otherwise.
End
Restart
File $base.results/band.rkf
Dos true
BandStructure true
End
@include convergence.inc
$DOSLINE
$BANDSTTRUCTURELINE
EndEngine
eor
$AMSBIN/amspython $AMSHOME/scripting/tools/comparekf.py --dot-product $base.betterk.results/band.rkf $base.restartdosbetterk.results/band.rkf "DOS%Total DOS" >> $report
echo "begin report"
cat $report
echo "end report"