~jose-soler/siesta/unfolding

« back to all changes in this revision

Viewing changes to Pseudo/atom/pseudoXML.f

  • Committer: Alberto Garcia
  • Date: 2016-01-25 16:00:16 UTC
  • mto: (483.3.1 rel-4.0)
  • mto: This revision was merged to the branch mainline in revision 485.
  • Revision ID: albertog@icmab.es-20160125160016-c1qivg1zw06kgyfd
Prepare GPL release

* Include proper headers

* Add Docs/Contributors.txt and NOTICE.txt files.

* Update READMEs and LICENSE files in several directories.

* Remove Pseudo/atom, Util/test-xml

* Remove DOM files from Src/xmlparser

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
 
3
 
      subroutine pseudoXML( ray, npotd, npotu, zion, zratio )
4
 
 
5
 
      use FoX_wxml
6
 
      use FoX_common
7
 
 
8
 
      implicit none
9
 
 
10
 
      include 'param.h'
11
 
      include 'radial.h'
12
 
      include 'ion.h'
13
 
      include 'orbital.h'
14
 
      include 'charge.h'
15
 
      include 'pseudowave.h'
16
 
 
17
 
      type(xmlf_t) :: xf
18
 
 
19
 
      integer npotd, npotu
20
 
      double precision  :: zion, zratio
21
 
 
22
 
      character*4      :: polattrib, relattrib, coreattrib
23
 
      character*10     :: ray(6)
24
 
      character*30 xcfuntype, xcfunparam
25
 
      character*30 gridtype, gridunits, gridscale, gridstep, gridnpoint
26
 
      character*30 slpotunits, slpotformat, slpotndown, slpotnup
27
 
      character*30 slwfnunits, slwfnformat, slwfndown, slwfnup
28
 
      integer                        :: ivps, ip
29
 
      double precision, allocatable   :: chval(:)
30
 
 
31
 
!
32
 
!     These determine the format for ASCII files
33
 
!
34
 
      character(len=*), parameter ::  
35
 
     .         fmt_int = "(tr1,i2)" ,                  
36
 
     .         fmt_nam = "(tr1,a2,tr1,a2,tr1,a3,tr1,a4)", 
37
 
     .         fmt_met = "(tr1,6a10,/,tr1,a70)" ,       
38
 
     .         fmt_pot= "(tr1,2i3,i5,3g20.12)" ,      
39
 
     .         fmt_rad = "(4(g20.12))"        ,      
40
 
     .         fmt_txt = "(tr1,a)"
41
 
 
42
 
 
43
 
! Digest and dump the information about the exchange and correlation functional
44
 
      select case(icorr) 
45
 
 
46
 
        case('ca') 
47
 
          xcfuntype    = 'LDA'
48
 
          xcfunparam   = 'Ceperley-Alder'
49
 
 
50
 
        case('pw') 
51
 
          xcfuntype    = 'LDA'
52
 
          xcfunparam   = 'Perdew-Wang-92'
53
 
 
54
 
        case('wi') 
55
 
          xcfuntype    = 'LDA'
56
 
          xcfunparam   = 'Wigner'
57
 
 
58
 
        case('hl') 
59
 
          xcfuntype    = 'LDA'
60
 
          xcfunparam   = 'Hedin-Lundqvist'
61
 
 
62
 
        case('gl') 
63
 
          xcfuntype    = 'LDA'
64
 
          xcfunparam   = 'Gunnarson-Lundqvist'
65
 
 
66
 
        case('bh') 
67
 
          xcfuntype    = 'LDA'
68
 
          xcfunparam   = 'von Barth-Hedin'
69
 
 
70
 
        case('pb') 
71
 
          xcfuntype    = 'GGA'
72
 
          xcfunparam   = 'Perdew-Burke-Ernzerhof'
73
 
 
74
 
        case('rp') 
75
 
          xcfuntype    = 'GGA'
76
 
          xcfunparam   = 'RPBE - Hammer et al'
77
 
 
78
 
        case('rv') 
79
 
          xcfuntype    = 'GGA'
80
 
          xcfunparam   = 'revPBE Zhang+Yang'
81
 
 
82
 
        case('bl') 
83
 
          xcfuntype    = 'GGA'
84
 
          xcfunparam   = 'Becke-Lee-Yang-Parr'
85
 
 
86
 
        case('wc') 
87
 
          xcfuntype    = 'GGA'
88
 
          xcfunparam   = 'Wu-Cohen'
89
 
 
90
 
        case('ps') 
91
 
          xcfuntype    = 'GGA'
92
 
          xcfunparam   = 'Perdew-Burke-Ernzerhof-solid'
93
 
 
94
 
        case('am') 
95
 
          xcfuntype    = 'GGA'
96
 
          xcfunparam   = 'Armiento-Mattsson-05'
97
 
 
98
 
        case('wp') 
99
 
          xcfuntype    = 'GGA'
100
 
          xcfunparam   = 'Perdew-Wang-91'
101
 
 
102
 
        case('jo') 
103
 
          xcfuntype    = 'GGA'
104
 
          xcfunparam   = 'Capelle-et-al--PBE-Js-Jr-LO'
105
 
 
106
 
        case('jh') 
107
 
          xcfuntype    = 'GGA'
108
 
          xcfunparam   = 'Capelle-et-al--PBE-Js-Jr-HEG'
109
 
 
110
 
        case('go') 
111
 
          xcfuntype    = 'GGA'
112
 
          xcfunparam   = 'Capelle-et-al--PBE-Gc-Gx-LO'
113
 
 
114
 
        case('gh') 
115
 
          xcfuntype    = 'GGA'
116
 
          xcfunparam   = 'Capelle-et-al--PBE-Gc-Gx-HEG'
117
 
 
118
 
        case('vw','vf') 
119
 
          xcfuntype    = 'VDW'
120
 
          xcfunparam   = 'Dion-et-al--DRSLL'
121
 
 
122
 
        case('vl') 
123
 
          xcfuntype    = 'VDW'
124
 
          xcfunparam   = 'Lee-et-al--LMKLL'
125
 
 
126
 
        case('vk') 
127
 
          xcfuntype    = 'VDW'
128
 
          xcfunparam   = 'Klimes-et-al--KBM'
129
 
 
130
 
        case('vc') 
131
 
          xcfuntype    = 'VDW'
132
 
          xcfunparam   = 'Cooper--C09'
133
 
 
134
 
        case('vb') 
135
 
          xcfuntype    = 'VDW'
136
 
          xcfunparam   = 'Berland-Hyldgaard--BH'
137
 
 
138
 
        case('vv') 
139
 
          xcfuntype    = 'VDW'
140
 
          xcfunparam   = 'Vydrov-VanVoorhis--VV'
141
 
 
142
 
      end select
143
 
 
144
 
! Digest and dump the information about the pseudopotential flavor
145
 
      select case(irel) 
146
 
 
147
 
        case('isp') 
148
 
          polattrib   = 'yes'
149
 
          relattrib   = 'no'
150
 
 
151
 
        case('rel') 
152
 
          polattrib   = 'yes'
153
 
          relattrib   = 'yes'
154
 
 
155
 
        case('nrl') 
156
 
          polattrib   = 'no'
157
 
          relattrib   = 'no'
158
 
 
159
 
      end select
160
 
 
161
 
! Digest and dump the information about the non-linear core corrections
162
 
      select case(nicore) 
163
 
 
164
 
        case('pcec') 
165
 
          coreattrib  = 'yes'
166
 
 
167
 
        case('fcec') 
168
 
          coreattrib  = 'yes'
169
 
 
170
 
        case('fche') 
171
 
          coreattrib  = 'yes'
172
 
 
173
 
        case('pche') 
174
 
          coreattrib  = 'yes'
175
 
 
176
 
        case default
177
 
          coreattrib  = 'no'
178
 
 
179
 
      end select
180
 
 
181
 
! Digest and dump the information about the grid
182
 
      gridtype    = 'log'
183
 
      gridunits   = 'bohr'
184
 
      gridscale   = str(a)
185
 
      gridstep    = str(b)
186
 
      gridnpoint  = str(nr-1)
187
 
      
188
 
! Digest and dump the information about the semilocal components
189
 
      slpotunits  = 'rydberg'
190
 
      slpotformat = 'r*V'
191
 
      slpotndown  = str(npotd)
192
 
      slpotnup    = str(npotu)
193
 
 
194
 
! Digest and dump the information about the pseudowave functions
195
 
      slwfnunits  = 'electrons/bohr^(-3/2)'
196
 
      slwfnformat = 'u_n,l (r) = 1/r R_n,l (r)'
197
 
      slwfndown  = str(npotd)
198
 
      slwfnup    = str(npotu)
199
 
 
200
 
! Allocate and define the valence charge density
201
 
      allocate(chval(1:nr))
202
 
 
203
 
      do ip = 2, nr
204
 
        chval(ip) = zratio * (cdd(ip)+cdu(ip))
205
 
      enddo
206
 
                                                                                
207
 
 
208
 
! ---------------------------------------------------------------------
209
 
                                                                                
210
 
      call xml_OpenFile("VPSXML",xf, pretty_print=.true.)
211
 
 
212
 
!     call xml_AddXMLDeclaration(xf,"UTF-8")
213
 
 
214
 
      call xml_NewElement(xf,"pseudo")
215
 
 
216
 
        call xml_NewElement(xf,"header")
217
 
          call my_add_attribute(xf,"symbol",nameat)
218
 
          call my_add_attribute(xf,"atomic-number",str(znuc))
219
 
          call my_add_attribute(xf,"zval",str(zion))
220
 
          call my_add_attribute(xf,"creator",ray(1))
221
 
          call my_add_attribute(xf,"date",ray(2))
222
 
          call my_add_attribute(xf,"flavor",ray(3)//ray(4))
223
 
          call my_add_attribute(xf,"relativistic",relattrib)
224
 
          call my_add_attribute(xf,"polarized",polattrib)
225
 
          call my_add_attribute(xf,"core-corrections",coreattrib)
226
 
          call my_add_attribute(xf,"xc-functional-type",xcfuntype)
227
 
          call my_add_attribute(xf,"xc-functional-parametrization",
228
 
     .                          xcfunparam)
229
 
        call xml_EndElement(xf,"header")
230
 
 
231
 
        call xml_NewElement(xf,"grid")
232
 
          call my_add_attribute(xf,"type",gridtype)
233
 
          call my_add_attribute(xf,"units",gridunits)
234
 
          call my_add_attribute(xf,"scale",gridscale)
235
 
          call my_add_attribute(xf,"step",gridstep)
236
 
          call my_add_attribute(xf,"npts",gridnpoint)
237
 
        call xml_EndElement(xf,"grid")
238
 
 
239
 
        call xml_NewElement(xf,"semilocal")
240
 
          call my_add_attribute(xf,"units",slpotunits)
241
 
          call my_add_attribute(xf,"format",slpotformat)
242
 
          call my_add_attribute(xf,"npots-down",slpotndown)
243
 
          call my_add_attribute(xf,"npots-up",slpotnup)
244
 
  
245
 
! Down pseudopotentials follows
246
 
 
247
 
      vpsd: do ivps = 1, lmax
248
 
           if (indd(ivps) .eq. 0) cycle
249
 
           call xml_NewElement(xf,"vps")
250
 
             call my_add_attribute(xf,"principal-n",str(no(indd(ivps))))
251
 
             call my_add_attribute(xf,"l",il(ivps))
252
 
             call my_add_attribute(xf,"cutoff",str(rc(ivps)))
253
 
             call my_add_attribute(xf,"occupation",str(zo(indd(ivps))))
254
 
! JMS/AG 2009/04/02: to be checked which one works better
255
 
!             call my_add_attribute(xf,"spin",str(int(-1)))
256
 
             call my_add_attribute(xf,"spin","-1")
257
 
 
258
 
             call xml_NewElement(xf,"radfunc")
259
 
               call xml_NewElement(xf,"grid")
260
 
                 call my_add_attribute(xf,"type",gridtype)
261
 
                 call my_add_attribute(xf,"units",gridunits)
262
 
                 call my_add_attribute(xf,"scale",gridscale)
263
 
                 call my_add_attribute(xf,"step",gridstep)
264
 
                 call my_add_attribute(xf,"npts",gridnpoint)
265
 
               call xml_EndElement(xf,"grid")
266
 
 
267
 
               call xml_NewElement(xf,"data")
268
 
                 call xml_AddCharacters(xf,viod(ivps,2:nr))
269
 
               call xml_EndElement(xf,"data")
270
 
             call xml_EndElement(xf,"radfunc")
271
 
           call xml_EndElement(xf,"vps")
272
 
         enddo vpsd
273
 
 
274
 
! Up pseudopotentials follows
275
 
 
276
 
         vpsu: do ivps = 1, lmax
277
 
           if (indu(ivps) .eq. 0) cycle
278
 
           call xml_NewElement(xf,"vps")
279
 
             call my_add_attribute(xf,"principal-n",str(no(indu(ivps))))
280
 
             call my_add_attribute(xf,"l",il(ivps))
281
 
             call my_add_attribute(xf,"cutoff",str(rc(ivps)))
282
 
             call my_add_attribute(xf,"occupation",str(zo(indu(ivps))))
283
 
! JMS/AG 2009/04/02: to be checked which one works better
284
 
!             call my_add_attribute(xf,"spin",str(int(+1)))
285
 
             call my_add_attribute(xf,"spin","+1")
286
 
 
287
 
             call xml_NewElement(xf,"radfunc")
288
 
               call xml_NewElement(xf,"grid")
289
 
                 call my_add_attribute(xf,"type",gridtype)
290
 
                 call my_add_attribute(xf,"units",gridunits)
291
 
                 call my_add_attribute(xf,"scale",gridscale)
292
 
                 call my_add_attribute(xf,"step",gridstep)
293
 
                 call my_add_attribute(xf,"npts",gridnpoint)
294
 
               call xml_EndElement(xf,"grid")
295
 
 
296
 
               call xml_NewElement(xf,"data")
297
 
                 call xml_AddCharacters(xf,viou(ivps,2:nr))
298
 
               call xml_EndElement(xf,"data")
299
 
             call xml_EndElement(xf,"radfunc")
300
 
           call xml_EndElement(xf,"vps")
301
 
        enddo vpsu
302
 
        call xml_EndElement(xf,"semilocal")
303
 
 
304
 
! Dump of the pseudowave functions
305
 
        call xml_NewElement(xf,"pseudowave-functions")
306
 
          call my_add_attribute(xf,"units",slwfnunits)
307
 
          call my_add_attribute(xf,"format",slwfnformat)
308
 
          call my_add_attribute(xf,"n-pseudowave-functions-down",
309
 
     .                          slwfndown)
310
 
          call my_add_attribute(xf,"n-pseudowave-functions-up",
311
 
     .                          slwfnup)
312
 
  
313
 
! Down pseudowave function follows
314
 
 
315
 
        pswfd: do ivps = 1, lmax
316
 
           if (indd(ivps) .eq. 0) cycle
317
 
           call xml_NewElement(xf,"pswf")
318
 
             call my_add_attribute(xf,"principal-n",str(no(indd(ivps))))
319
 
             call my_add_attribute(xf,"l",il(ivps))
320
 
             call my_add_attribute(xf,"spin","-1")
321
 
 
322
 
             call xml_NewElement(xf,"radfunc")
323
 
               call xml_NewElement(xf,"grid")
324
 
                 call my_add_attribute(xf,"type",gridtype)
325
 
                 call my_add_attribute(xf,"units",gridunits)
326
 
                 call my_add_attribute(xf,"scale",gridscale)
327
 
                 call my_add_attribute(xf,"step",gridstep)
328
 
                 call my_add_attribute(xf,"npts",gridnpoint)
329
 
               call xml_EndElement(xf,"grid")
330
 
 
331
 
               call xml_NewElement(xf,"data")
332
 
                 call xml_AddCharacters(xf,pswfnrd(ivps,2:nr))
333
 
               call xml_EndElement(xf,"data")
334
 
             call xml_EndElement(xf,"radfunc")
335
 
           call xml_EndElement(xf,"pswf")
336
 
        enddo pswfd
337
 
 
338
 
! Up pseudowavefunction follows
339
 
 
340
 
       pswfu: do ivps = 1, lmax
341
 
           if (indu(ivps) .eq. 0) cycle
342
 
           call xml_NewElement(xf,"pswf")
343
 
             call my_add_attribute(xf,"principal-n",str(no(indu(ivps))))
344
 
             call my_add_attribute(xf,"l",il(ivps))
345
 
             call my_add_attribute(xf,"spin","+1")
346
 
 
347
 
             call xml_NewElement(xf,"radfunc")
348
 
               call xml_NewElement(xf,"grid")
349
 
                 call my_add_attribute(xf,"type",gridtype)
350
 
                 call my_add_attribute(xf,"units",gridunits)
351
 
                 call my_add_attribute(xf,"scale",gridscale)
352
 
                 call my_add_attribute(xf,"step",gridstep)
353
 
                 call my_add_attribute(xf,"npts",gridnpoint)
354
 
               call xml_EndElement(xf,"grid")
355
 
 
356
 
               call xml_NewElement(xf,"data")
357
 
                 call xml_AddCharacters(xf,pswfnru(ivps,2:nr))
358
 
               call xml_EndElement(xf,"data")
359
 
             call xml_EndElement(xf,"radfunc")
360
 
           call xml_EndElement(xf,"pswf")
361
 
        enddo pswfu
362
 
        call xml_EndElement(xf,"pseudowave-functions")
363
 
 
364
 
        call xml_NewElement(xf,"valence-charge")
365
 
          call xml_NewElement(xf,"radfunc")
366
 
            call xml_NewElement(xf,"grid")
367
 
              call my_add_attribute(xf,"type",gridtype)
368
 
              call my_add_attribute(xf,"units",gridunits)
369
 
              call my_add_attribute(xf,"scale",gridscale)
370
 
              call my_add_attribute(xf,"step",gridstep)
371
 
              call my_add_attribute(xf,"npts",gridnpoint)
372
 
            call xml_EndElement(xf,"grid")
373
 
 
374
 
            call xml_NewElement(xf,"data")
375
 
              call xml_AddCharacters(xf,chval(2:nr))
376
 
            call xml_EndElement(xf,"data")
377
 
          call xml_EndElement(xf,"radfunc")
378
 
        call xml_EndElement(xf,"valence-charge")
379
 
 
380
 
        call xml_NewElement(xf,"pseudocore-charge")
381
 
          call xml_NewElement(xf,"radfunc")
382
 
            call xml_NewElement(xf,"grid")
383
 
              call my_add_attribute(xf,"type",gridtype)
384
 
              call my_add_attribute(xf,"units",gridunits)
385
 
              call my_add_attribute(xf,"scale",gridscale)
386
 
              call my_add_attribute(xf,"step",gridstep)
387
 
              call my_add_attribute(xf,"npts",gridnpoint)
388
 
            call xml_EndElement(xf,"grid")
389
 
 
390
 
            call xml_NewElement(xf,"data")
391
 
              call xml_AddCharacters(xf,cdc(2:nr))
392
 
            call xml_EndElement(xf,"data")
393
 
          call xml_EndElement(xf,"radfunc")
394
 
        call xml_EndElement(xf,"pseudocore-charge")
395
 
 
396
 
        call xml_EndElement(xf,"pseudo")
397
 
      call xml_Close(xf)
398
 
 
399
 
      deallocate(chval)
400
 
 
401
 
      CONTAINS
402
 
 
403
 
      subroutine my_add_attribute(xf,name,value)
404
 
      type(xmlf_t), intent(inout)   :: xf
405
 
      character(len=*), intent(in)  :: name
406
 
      character(len=*), intent(in)  :: value
407
 
 
408
 
       call xml_AddAttribute(xf,name,trim(value))
409
 
      end subroutine my_add_attribute
410
 
 
411
 
      end subroutine pseudoXML
412