~albertog/siesta/efield-2.5-jjunquera

« back to all changes in this revision

Viewing changes to Src/state_analysis.F

  • Committer: Alberto Garcia
  • Date: 2007-11-21 11:45:49 UTC
  • mfrom: (192.1.67)
  • Revision ID: Arch-1:siesta@uam.es--2006%siesta-devel--reference--2.3--patch-1
Direct merge into master branch of initial BSC changes
The changes along the BSC branches, up to the end of the restructuring
of siesta.F and associated changes, have been merged into a direct
descendant of the main development line. The BSC work originally
started as a branch of siesta-devel--reference--2.1--patch-29. Development
along 2.1 continued, and a new continuation branch 2.3 has been created
specifically for this merge.

Main patches applied:

 * ref@bsc--2007/siesta-bsc--master--2.1--base-0
   tag of siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-7

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-1
   Use of xalast in analysis routines. Exit of geometry loop

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-2
   Creation of a module to hold the siesta options

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-3
   New geometry module

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-4
   New stub module for sparse matrices

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-5
   More options for running tests

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-6
   Encapsulation of k-point handling

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-7
   Initialize iza in struct_init

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-8
   Siesta_todo slimming by M. Quero

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-9
   Fix import of no_l in born_charge

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-10
   Some conversions to Fortran90 by M. Quero

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-11
   Fourth session at the BSC

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-12
   Clarification of the scope of the stress variables

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-13
   Creation of siesta_forces

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-14
   Replacement of some allocatables by pointers and automatics

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-15
   New m_energies and m_steps modules. Back to old k-point behavior

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-16
   Merge of removal of integer and real variables from siesta_todo

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-17
   Fixes for troublesome bugs in reference code

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-18
   Final cleanup of siesta_todo

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-19
   Add character(len=*) routines to alloc.F90

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-20
   Pointers in fixed and setspatial. si2x1h test added to bsc-Makefile

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-21
   Re-organization of pulay module

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-22
   Reorganization of hsparse/xijorb calls with new neighbor module

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-23
   VPATH-aware compilation for multiple executable versions

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-24
   Allocatables to pointers  I

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-25
   Allocatables to pointers  II

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-26
   Allocatables to pointers III

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-27
   Allocatables to pointers IV -- new neighbor code + nspecies fix

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-28
   Explicit array-ness in calls in initatom and cellxc

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-29
   Fix wrong allocations in cellxc.F

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-30
   Explicit array extents in initatom.f

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-31
   Avoid shrinking of density-matrix arrays for extrapol.

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-32
   Fix typo in state_init.F

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-33
   Execute SCF loop when nscf=1

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-34
   Clarify bounds of SCF loop in siesta_forces.

 * ref@bsc--2007/siesta-bsc--master--2.2--base-0
   tag of ref@bsc--2007/siesta-bsc--master--2.1--patch-31

 * ref@bsc--2007/siesta-bsc--master--2.3--base-0
   tag of ref@bsc--2007/siesta-bsc--master--2.2--base-0

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-1
   Prepare CHANGES file

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-2
   Merge patch-log for patch-30 from 2.1

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-3
   New treatment of fractional atoms in VCA. Bug fix in lmxo

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-4
   Re-enabling of kgrid update in variable-cell calculations

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-5
   Fix typo in state_init.F

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-6
   Merge filtering package by Eduardo Anglada

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-7
   Add graphite_c6_full test for more realistic vdW test

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-8
   Add patchlog for k-point fix

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-9
   Fix of zmatrix code to deal with degenerate case

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-10
   Units conversion in Util/Optical/optical.f. Scripts. Cosmetics

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-11
   Implementation of basis_enthalpy calculation. Zmatrix dependency

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-12
   Option to use fractional rc's for multiple zeta

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-13
   Sync vpath changes. Update siesta.tex

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-14
   Fix tag in MPI send/receive in mulliken

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-15
   Option to use fractional rc's for multiple zeta

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-16
   Merge of XML tester by Eduardo Anglada. Portability fixes

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-17
   Fix marenostrum-mpi.make. Syntax in compare_m.f90

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-18
   MareNostrum fixes. zdrot to blas. obj_setup. compare_m syntax

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-19
   Sync to bsc--2.1. Change banner in CHANGES to bsc--2.3

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-20
   Execute SCF loop when nscf=1

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-21
   Refinements of XML tester. New ioncat program

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-22
   Undef var in kgridinit, iohs MPI write, pdosg array bound, Origin shift

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-23
   Zmatrix optimization enhancements. Sign change in MM stress.

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-24
   Clarify bounds of SCF loop in siesta_forces.

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-25
   Avoid MP-grid permutations in trivial gamma case

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-26
   Sync to reference--2.1

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--base-0
   tag of siesta@uam.es--2006/siesta-devel--reference--2.1--patch-29

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-1
   First stage of siesta.F splitting at BSC

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-2
   Created struct_init for initial geometry setup. New test force_2

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-3
   Consolidate geometry updates at the end of loop

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-4
   Initialize vol2 correctly in m_check_supercell.f

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-5
   Kgrid setup streamlined. Bands. Proximity check. Hsparse allocation 

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-6
   Work by Manuel Quero before the meeting on Feb 7th

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-7
   Moved the Born-effective-charge code




Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
      MODULE m_state_analysis
 
2
      use write_subs
 
3
 
 
4
      private
 
5
      public :: state_analysis
 
6
 
 
7
      CONTAINS
 
8
 
 
9
      subroutine state_analysis( istep  )
 
10
      use siesta_cml
 
11
      use m_born_charge, only: born_charge
 
12
      use parallel, only: IOnode
 
13
      use m_wallclock, only : wallclock
 
14
      use zmatrix,      only: lUseZmatrix, iofaZmat, write_Zmatrix,
 
15
     .                        CartesianForce_to_ZmatForce,
 
16
     .                        write_canonical_ucell_and_Zmatrix
 
17
      use m_iostruct,   only: write_struct
 
18
      use sparse_matrices
 
19
      use atomlist, only: iaorb, iphorb, iza, amass, no_u, lasto, superx
 
20
      use siesta_geom
 
21
      USE siesta_options
 
22
      use m_stress
 
23
      use m_energies, only: Etot
 
24
      use m_ntm
 
25
      use m_spin,     only: nspin
 
26
      use m_forces
 
27
 
 
28
      implicit none
 
29
 
 
30
      integer  :: istep
 
31
      integer  :: ia, jx, ix
 
32
      real(dp) :: volume
 
33
      logical  :: eggbox_block=.true. ! Read eggbox info from data file?
 
34
 
 
35
      external :: eggbox, mulliken, fixed
 
36
      real(dp), external :: volcel
 
37
 
 
38
!------------------------------------------------------------------------- BEGIN
 
39
! Write final Kohn-Sham Energy 
 
40
      if (cml_p) call cmlStartPropertyList(mainXML,
 
41
     .                                   title='Final KS Energy')
 
42
      if (IOnode) then
 
43
        if ( .not. harrisfun) 
 
44
     .    write(6,"(/a,f14.4)")  'siesta: E_KS(eV) =        ', Etot/eV
 
45
        if (cml_p) call cmlAddProperty(xf=mainXML, property=Etot/eV,
 
46
     .       dictref='siesta:E_KS', units='siestaUnits:eV', 
 
47
     .       fmt='(f14.6)')
 
48
      endif
 
49
 
 
50
! Substract egg box effect form energy 
 
51
      if (eggbox_block) then
 
52
        call eggbox('energy',ucell,na_u,isa,ntm,xa,fa,Etot,
 
53
     .               eggbox_block)
 
54
        if (IOnode)
 
55
     .    write(6,"(/a,f14.4)") 'siesta: E_KS - E_eggbox = ',Etot/eV
 
56
        if (cml_p) call cmlAddProperty(xf=mainXML, property=Etot/eV,
 
57
     .         dictref='siesta:E_KS_egg', units='siestaUnits:eV', 
 
58
     .         fmt='(f14.6)')
 
59
      endif
 
60
      if (cml_p) call cmlEndPropertyList(mainXML)
 
61
 
 
62
! Substract egg box effect from the forces 
 
63
      if (eggbox_block) then
 
64
        call eggbox('forces',ucell,na_u,isa,ntm,xa,fa,Etot,eggbox_block)
 
65
      endif
 
66
 
 
67
      !  Compute stress without internal molecular pressure
 
68
      call remove_intramol_pressure(ucell,stress,na_u,xa,fa,mstress)
 
69
 
 
70
C Impose constraints to atomic movements by changing forces ...........
 
71
      if (RemoveIntraMolecularPressure) then
 
72
         ! Consider intramolecular pressure-removal as another
 
73
         ! kind of constraint
 
74
         call fixed(ucell,mstress,na_u,isa, amass, xa, fa,
 
75
     $        cstress, cfa, ntcon )
 
76
      else
 
77
         call fixed(ucell,stress,na_u,isa, amass, xa, fa,
 
78
     $        cstress, cfa, ntcon )
 
79
      endif
 
80
C ...................
 
81
 
 
82
! Calculate and output Zmatrix forces
 
83
      if (lUseZmatrix) then
 
84
        call CartesianForce_to_ZmatForce(na_u,xa,fa)
 
85
        if (IOnode) call iofaZmat()
 
86
      endif
 
87
 
 
88
      !  Compute kinetic contribution to stress
 
89
      kin_stress(1:3,1:3) = 0.0_dp
 
90
      volume = volcel(ucell)
 
91
      do ia = 1,na_u
 
92
        do jx = 1,3
 
93
          do ix = 1,3
 
94
            kin_stress(ix,jx) = kin_stress(ix,jx) -
 
95
     .             amu * amass(ia) * va(ix,ia) * va(jx,ia) / volume
 
96
          enddo
 
97
        enddo
 
98
      enddo
 
99
      !  Add kinetic term to stress tensor
 
100
      tstress = stress + kin_stress
 
101
 
 
102
! Force output 
 
103
      if (IOnode) then
 
104
        call siesta_write_forces()
 
105
        call siesta_write_stress_pressure()
 
106
        call wallclock('--- end of geometry step')
 
107
      endif
 
108
 
 
109
! Mulliken population analysis 
 
110
      call mulliken( mullipop, nspin, na_u, no_u, maxnh,
 
111
     .               numh, listhptr, listh, S, Dscf, isa, 
 
112
     .               lasto, iaorb, iphorb )
 
113
!
 
114
!     Save structural information in crystallographic format,
 
115
!     and canonical Zmatrix (if applicable) before moving the atoms
 
116
!
 
117
      if (IOnode) then
 
118
         call write_struct( ucell, na_u, isa, iza, xa )
 
119
         if (lUseZmatrix) then
 
120
            call write_canonical_ucell_and_Zmatrix()
 
121
         endif
 
122
      endif
 
123
!
 
124
!     Call the born effective charge routine only in those steps (even) 
 
125
!     in which the dx  is positive.
 
126
      if (bornz .and. (mod(istep,2) .eq. 0)) then
 
127
         call born_charge()
 
128
      endif
 
129
!--------------------------------------------------------------------------- END
 
130
      END subroutine state_analysis
 
131
 
 
132
      END MODULE m_state_analysis