<HTML><HEAD><TITLE>LMTO-FP extension package (v6.14) </TITLE></HEAD><BODY bgcolor="#cccccc">
<H1><B><FONT size="+2">FP tutorial to demonstrate optimization of basis (v6.14)</FONT></B></H1>

This tutorial uses the SrTiO3 input file <A
href="FPsamples/ctrl.srtio3">ctrl.srtio3</A> found in directory
`doc/fp/samples.'  (Output files are also in this directory.)  It
assumes you have read the <A href="fp.html">FP documentation</A> and
the <A href="lmto.html">ASA documentation</A>.  This tutorial's
purpose is limited to demonstration of the automatic basis
optimization option in lmf.  It assumes that you have gone through the
basic <A href="FPtutorial.html">FP tutorial</A> and <A
href="ASAtutorial.html">ASA tutorial</A>.

<BR><BR> To follow this tutorial, start in the top-level directory.
Copy file <A href="FPsamples/ctrl.srtio3">doc/FPsamples/ctrl.srtio3</A> to
this directory.

In addition to making each sphere self-consistent, program
<strong>lmfa</strong> also finds parameters RSMH and EH for each
occupied orbital of each free atom, by minimizing the free-atom total
energy.  While this is not in general an optimum basis for the solid,
it provides a reasonable choice, and thus a reasonable starting guess.

You may tell <strong>lmf</strong> to read parameters of a basis from a
separate input file, overriding the parameters specified in the ctrl
file.  Do this using token <TT> --rdbasp[:fn=name].  </TT> The part in
brackets is optional, to specify which file the parameters are to be
read from.  If you don't specify a name, <strong>lmf</strong> uses
file <TT> basp </TT> (an extension is automatically appended to the
name)

In this case, we will use as starting values parameters generated by 
<strong>lmfa</strong>, which stores the data in file 
<TT> atm.srtio3 </TT>.  
Note that the input file uses local orbitals for the Ti 
<EM>p</EM> and Sr <EM>p</EM> orbitals.  (see input files, tokens
<TT> PZ=0,4.9 </TT> for Sr and <TT> PZ=0,3.9 </TT> for Ti.

<BR><BR> We begin by invoking <strong>lmfa</strong> : <pre>
  lmfa srtio3 </pre> 
which makes each sphere self-consistent, and stores the
free-atom data in file <TT> atm.srtio3 </TT> along with the parameters
RSMH and EH it determined for the free atom.  The latter data is found
at the end of file <TT> atm.srtio3 </TT>: <pre>
BASIS:
 Sr RSMH= 3.1 1.185 1.873 -1 EH= -0.114 -1.202 -0.1 0
 Ti RSMH= 2.335 0.815 1.137 -1 EH= -0.12 -2.057 -0.1 0
 O RSMH= 0.854 0.767 -1 EH= -1.289 -0.33 0
</pre>

Note that the starting values EH for the Sr and Ti <EM>p</EM> orbitals
are very deep.  This is because turning on local orbitals in these
channels causes <strong>lmfa</strong> to treat these channels (Sr 4p
and Ti 3p) as valence states.  <strong>lmfa</strong> also restricts
RSMH not to exceed the MT radius for any orbital; that is why RSMH for
the Sr <EM>s</EM> orbital is 3.1.  <BR><BR>

At this point we can carry out an optimization by minimizing
the total energy using the Harris-Foulkes functional of the
(non-self-consistent) density constructed out of a superposition of
free-atom densities (Mattheis construction).  Instead of doing that,
let's make the density self-consistent using the basis generated by
<strong>lmfa</strong>.  We use a very small number of
<EM>k</EM>-divisions because we are only interested in a potential
resembling the potential of the crystal, for purposes of finding an
optimum basis.  The Mattheis construction for oxides is a little too
crude because of the large charge transfer effects. <pre>
 lmf -vnk=2 srtio3 --rdbasp:fn=atm </pre> 
The output can be found in <A href="FPsamples/out.srtio3.lmf0">out.srtio3.lmf0</A>.
<BR><BR>

Now we can optimize the basis using this (approximately
self-consistent) density.  Once again, there is little point in
converging everything to a high precision.  We use 2 <EM>k</EM>-divisions
as before.  To tell <strong>lmf</strong> to optimize the basis, use a
command-line switch <TT>--optbas</TT>.  When <TT>--optbas</TT> is
invoked, <strong>lmf</strong> will not attempt to make the output
density, but instead just computes the Harris-Foulkes total energy
while varying basis parameters you specify until an optimum is
reached.  The optimizer is not sophisticated; it minimizes the energy
varying one parameter at a time, running through all the parameters you
specify.  This means that the order of optimization matters somewhat,
though in practice it doesn't seem to matter much.  The syntax for
optimization is <pre>
  --optbas[:sort]:spec=spec-name[,rs][,e][,l=list]:spec=...
</pre>
Some notes about the syntax of --optbas:
<OL>
<LI> At least one species must be specified.  For example, for species
     O, use <TT>:spec=O</TT>
     <BR><BR>

<LI> You tell lmf whether to optimize wrt to RSM by using <TT>,rs</TT>
     or EH by using <TT>,e</TT>.  You can specify both by e,g. for
     species O, use <TT>:spec=O,rs,e,...</TT>
     <BR><BR>

<LI> You specify which <EM>l</EM> orbitals to optimize with the ,l=list.
     Here list consists of a list of integers strung together.  For
     example, to optimize the O RSM for both <EM>s</EM> and <EM>p</EM> orbitals, use
     <TT>:spec=O,rs,l=01</TT>.
     <BR><BR>

<LI> Optional <TT>:sort</TT> tells <strong>lmf</strong> to choose for
     itself the order in which parameters are taken for optimization.
     It will pick smoothing radii first, because usually the total
     energy is more sensitive to RSMH than to EH.  It orders the
     parameters from smallest (which correspond to more atomic-like
     states) to largest because the total energy is more sensitive to
     small-RSM orbitals.
     <BR><BR>

</OL>

Just for fun, let's optimize wrt most of the orbitals we have. 
(With only 1 irreducible <EM>k</EM>-point, <strong>lmf</strong>
runs pretty fast.) Note that we still need to read the basis from file atm. <pre>
  lmf -vnk=2 srtio3 --optbas:sort:spec=O,rs,e,l=01:spec=Ti,rs,e,l=012:spec=Sr,rs,e,l=012 --rdbasp:fn=atm
</pre>

Early in the output you should see the following table: <pre>
 LMFOPB:  optimizing energy wrt 16 parameters:
   spec       l  type     start
   3:O        1   rsm     0.767
   2:Ti       1   rsm     0.815
   3:O        0   rsm     0.854
   2:Ti       2   rsm     1.137
   1:Sr       1   rsm     1.185
   1:Sr       2   rsm     1.873
   2:Ti       0   rsm     2.335
   1:Sr       0   rsm     3.100
   2:Ti       1   eh     -2.057
   3:O        0   eh     -1.289
   1:Sr       1   eh     -1.202
   3:O        1   eh     -0.330
   2:Ti       0   eh     -0.120
   1:Sr       0   eh     -0.114
   2:Ti       2   eh     -0.100
   1:Sr       2   eh     -0.100
</pre>

<strong>lmf</strong> optimizes the total energy wrt each variable, in
order shown.  (lmf changed the order because of the <TT>:sort</TT> option).
The output can be found in <A href="FPsamples/out.srtio3.lmfopt">out.srtio3.lmfopt</A>.
<BR><BR>

The part of the <A href="FPsamples/out.srtio3.lmfopt">output</A>
connected with basis optimization can be found in lines beginning with
<TT>LMFOPB:</TT>, e.g. <pre>
 LMFOPB: continue optimization of var #2, species Ti val=0.888867
 MNBRAK:  found=T   x,f=      0.81500000     -2.65965498
 MNBRAK:  found=T   x,f=      1.01500000     -2.65785139
 MNBRAK:  found=T   x,f=      0.93860680     -2.65933813
 MNBRAK:  found=T   x,f=      0.86163389     -2.65967351
 BRENT:   found=T   x,f=      0.88886657     -2.65963089

 LMFOPB: var #2 converged in 5 iterations to 0.862:  ehf=-2.659674 ... writing file basp
</pre>

After optimization is complete, lmf will (1) write the optimized basis
to file <TT>basp.srtio3</TT>, (2) print out how much the energy
changed on account of the optimization: <pre>
 LMFOPB:  before optimization ehf=-2.5815.  After optimization ehf=-2.7009
</pre>
and exit.  
<BR><BR>

You might repeat this optimization, since the optimization
consisted of a series of independent optimizations one followed after
another.  In that case, don't read the basis from the file
<TT>atm</TT> but from file <TT>basp</TT>: <pre>
  lmf -vnk=2 srtio3 --optbas:sort:spec=O,rs,e,l=01:spec=Ti,rs,e,l=012:spec=Sr,rs,e,l=012 --rdbasp
</pre>

After the second optimization, the energy changes to:
 <pre>
 LMFOPB:  before optimization ehf=-2.7011.  After optimization ehf=-2.7203
</pre>
Repeating the optimization still once more lowers the energy slightly:
 <pre>
 LMFOPB:  before optimization ehf=-2.7211.  After optimization ehf=-2.7267
</pre>

File basp contains a reasonably optimized basis:
<pre>
BASIS:
 Sr RSMH= 3.1 1.345 2.013 EH= -0.02 -1.175 -0.518
 Ti RSMH= 0.9 0.962 1.142 EH= -0.02 -2.597 -0.411
 O RSMH= 0.922 0.802 EH= -1.104 -0.02
</pre>
It is interesting to compare this basis to the initial one selected by
<strong>lmfa</strong>.

<BR><BR>
You can use your text editor to cut and paste this basis into your
ctrl file.  Alternatively you can carry around file <TT>basp.srtio3</TT> and
always remember to invoke <strong>lmf</strong> with <TT>--basp</TT>.

<BR><BR>
The procedure just outlined has the advantage that it is completely
automatic.  However, there are a couple of pitfalls. There is a
possibility that it will get stuck in local minima.  Also, some
orbitals, e.g. the Sr <EM>d</EM> orbital and the O <EM>p</EM> orbitals
have no occupation in the free atom, so they were left out of the
basis.  They do, however, contribute in a non-negligible way to the
energy.  Optimizing the basis with these orbitals included generates
the following
<pre>
BASIS:
 Sr RSMH= 0.948 1 1.847 1 EH= -0.086 -1.046 -0.347 -0.1
 Ti RSMH= 1 0.8 1.052 0 EH= -0.073 -2 -0.279 0
 O RSMH= 0.899 0.8 2.4 EH= -0.956 -0.065 -0.1
</pre>
This was obtained by using the basis supplied by the input file, and
optimizing it:
<pre>
  lmf -vnk=2 srtio3 --optbas:sort:spec=O,rs,e,l=01:spec=Ti,rs,e,l=012:spec=Sr,rs,e,l=012
</pre>
It produced
<pre>
 LMFOPB:  before optimization ehf=-2.7507.  After optimization ehf=-2.7607
</pre>
One could go further, choosing a still larger basis (one is supplied
by the input file, which is used if you invoke <strong>lmf</strong>
with <TT>-vbigbas=t</TT>)
<pre>
  lmf -vnk=2 srtio3 --optbas:sort:spec=O,rs,e,l=01:spec=Ti,rs,e,l=012:spec=Sr,rs,e,l=012 -vbigbas=t
</pre>
which produced
<pre>
 LMFOPB:  before optimization ehf=-2.7711.  After optimization ehf=-2.7888
</pre>
This energy (-2.7888 Ry), is not so much larger than the minimal-basis energy
(-2.7267) --- it is deeper by 12 mRy/atom.  Thus, the minimal basis is
quite reasonable.

</HTML>
