Example: LDOS (STM) for a BN slab
*********************************

The Local DOS (LDOS) is the partial density due to bands withing a
certain energy interval. It has been related to STM images.

"Download BNSlabLDOS.run"


   # The BN slab has a band gap
   # The bottom of the conduction band  (BOCB, 0.05 hartree above the fermi level)  consists of p_z orbitals on B
   # The top of the valence band (TOVB, 0.2 hartree under the fermi level)  consists of p_z oribtals on N

   # It is recommended to inspect BNSlab.results with amsbands
   # and BNSlab.ldos.tovb.results with amsview (and the same for bocb)

   system=BNSlab

   export AMS_JOBNAME=$system

   rm -rf $AMS_JOBNAME.results

   $AMSBIN/ams<<EOF

   Task SinglePoint

   System
      Atoms
   		B      -0.615000000    -0.355070416     0.000000000
   		N       0.615000000     0.355070416     0.000000000
       End
   	Lattice
   	     2.460000000     0.000000000     0.000000000
   	     1.230000000     2.130422493     0.000000000
   End

   End

   Engine Band
   	BandStructure Enabled=yes
   	Dos CalcPDOS=yes
   	kspace quality=good
   EndEngine

   EOF

   fermi_energy=`$AMSBIN/amsreport $AMS_JOBNAME.results/band.rkf -r "BandStructure%FermiEnergy"`
   bcb=`$AMSBIN/amsreport $AMS_JOBNAME.results/band.rkf -r "BandStructure%BottomConductionBand"`
   tvb=`$AMSBIN/amsreport $AMS_JOBNAME.results/band.rkf -r "BandStructure%TopValenceBand"`

   echo "Fermi energy (Hartree): $fermi_energy"
   echo "tvb (Hartree): $tvb"
   echo "bcb (Hartree): $bcb"

   rel_tvb=`$AMSBIN/amspython -c "print($fermi_energy-$tvb)"`
   rel_bcb=`$AMSBIN/amspython -c "print($bcb-$fermi_energy)"`

   echo "rel_bcb (Hartree): $rel_bcb"
   echo "rel_tvb (Hartree): $rel_tvb"

   # we want to sample just a bit above/below the bcb and tvb: both need a margin
   # the applied margins here are quite arbitrary, but ensure that the example works exactly as before

   rel_tvb_with_margin=`$AMSBIN/amspython -c "print($rel_tvb+0.0585153984080739)"`
   rel_bcb_with_margin=`$AMSBIN/amspython -c "print($rel_bcb+0.0205273425101303)"`

   echo "rel_bcb_with_margin (Hartree): $rel_bcb_with_margin"
   echo "rel_tvb_with_margin (Hartree): $rel_tvb_with_margin"


   export AMS_JOBNAME=$system.ldos.bocb

   rm -rf $AMS_JOBNAME.results


   $AMSBIN/ams  --delete-old-results << EOF
   Task SinglePoint

   LoadSystem 
       File $system.results/ams.rkf
   End

   Engine BAND
   Restart
      File $system.results/band.rkf
      DensityPlot
   End

   Grid
      Type Coarse
   End

   DensityPlot
      LDOS
   End

   LDOS
      DeltaNeg 0.0 # fermi energy, halfway the gap
      DeltaPos $rel_bcb_with_margin   # bit above the bcb
   End
   EndEngine
   EOF



   export AMS_JOBNAME=$system.ldos.tovb

   rm -rf $AMS_JOBNAME.results


   $AMSBIN/ams  --delete-old-results << EOF
   Task SinglePoint

   LoadSystem 
       File $system.results/ams.rkf
   End

   Engine BAND
   Restart
      File $system.results/band.rkf
      DensityPlot
   End

   Grid
      Type Coarse
   End

   DensityPlot
      LDOS
   End

   LDOS
      DeltaNeg $rel_tvb_with_margin  # bit below the tvb
      DeltaPos 0.0 # fermi energy, halfway the gap
   End
   EndEngine
   EOF


   echo "Begin TOC of tape41 (tovb)"

   $AMSBIN/dmpkf -n 1 $system.ldos.tovb.results/TAPE41 --toc | grep LDOS

   echo "End TOC of tape41"


   echo "Begin TOC of tape41 (bocb)"

   $AMSBIN/dmpkf -n 1 $system.ldos.bocb.results/TAPE41 --toc | grep LDOS

   echo "End TOC of tape41"

