~albertog/siesta/efield-2.5-jjunquera

« back to all changes in this revision

Viewing changes to Util/PyAtom/atom.py

  • Committer: Alberto Garcia
  • Date: 2007-11-22 21:34:42 UTC
  • mfrom: (unknown (missing))
  • Revision ID: Arch-1:siesta@uam.es--2006%siesta-devel--reference--2.5--patch-2
Optimization enhancements (fire algorithm, step control).

* Step-size control has been add to the Broyden optimizers (Standard, ZM,
  and Cell-only). There is no theoretical justification for this procedure,
  so the Hessian is not likely to improve very much... it is probably best
  to combine a size-limited CG series with another small-Jinv Broyden series.

* New FORCE_STRESS for direct output of the energy, forces, and stress
  (in internal Siesta units).

* Re-implemented the FIRE optimization algorithm, both for geometry
  and (experimentally) for SCF.

  The advantages for the SCF mixing are:

  * Trivial algorithm (also in parallel)
  * Initial dt can be just set to alpha. 
  * Adaptive changes to alpha.
  * There should be no need for kicks.

  (Set DM.FIRE.Mixing to T to enable)
  Could also set DM.Fire.Nmin  to 2, 3, 4  instead of the default 5
  (Actually, this number could be akin to the DM.Number{Pulay,Broyden}...)

* Added .make files for opterons and matgas cluster at ICMAB in parallel.

* Compilation fixes(uncovered by a new version of g95)

  * External statements referring to obsolete names
  * Continuation lines.
  * Statement order.

(replayed patch-2 of outlier branch ref-2.4)


Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
from Numeric import *
5
5
from Scientific.IO.NetCDF import *
6
6
 
7
 
example="Ba.ion.nc"
8
 
 
9
7
class rfunc:
10
8
        def __init__(self,f,delta,cutoff):
11
9
                self.delta = delta
12
10
                self.cutoff = cutoff
13
11
                self.f = f
 
12
        def __str__(self):
 
13
           return ("(rfunc) n: %s delta: %f cutoff: %f" % 
 
14
                    (len(self.f), self.delta, self.cutoff))
 
15
        def dump(self):
 
16
           for i in range(len(self.f)):
 
17
             print i*self.delta, self.f[i] 
 
18
 
14
19
 
15
20
class orbital(rfunc):
16
21
  def __init__(self,f,delta,cutoff,n,l,z):
18
23
     self.l = l
19
24
     self.z = z
20
25
     self.n = n
 
26
 
21
27
  def __str__(self):
22
 
     return ("orb%s_%s" % (self.n,self.l))
23
 
     
 
28
     return ("orb n:%s l:%s z:%s " % (self.n,self.l,self.z) + rfunc.__str__(self))
 
29
  def dump(self):
 
30
     print "# ", str(self)
 
31
     rfunc.dump(self)
24
32
        
25
33
class atom:
26
34
  def __init__(self,filename):
27
35
    f=NetCDFFile(filename)
28
36
    self.element=f.Element
29
37
    vars = f.variables
30
 
    p = vars['vlocal']
31
 
    self.vlocal=rfunc(p[:],p.Vlocal_delta[0], p.Vlocal_cutoff[0])
 
38
    p = vars['vna']
 
39
    self.vna=rfunc(p[:],p.Vna_delta[0], p.Vna_cutoff[0])
32
40
    norbs = f.dimensions['norbs']
33
41
    self.base= []
34
42
    for i in range(norbs):
42
50
      self.base.append(orb)
43
51
    del p, l, n, z, delta, cutoff, norbs, vars
44
52
    del f
45
 
 
46
 
a=atom(example)
 
53
  def dump(self):
 
54
    print "Orbitals:"
 
55
    for i in range(len(self.base)):
 
56
       print self.base[i]
 
57
    print "Vna: ", self.vna
 
58
 
 
59
 
 
60
if __name__ == "__main__":
 
61
  print """
 
62
 
 
63
  If you had used the "-i" flag to python
 
64
  you could now type things such as:
 
65
 
 
66
    a = atom("H.ion.nc")
 
67
    print a.base[0]
 
68
    a.base[0].dump()
 
69
 
 
70
  """
 
71
a = atom("O.ion.nc")
 
72
print a.base[0]
 
73
#    a.base[0].dump()
47
74
 
48
75
49
76
# This file is part of the SIESTA package.