LCOV - code coverage report
Current view: top level - propcalc/eels - corespec_io.f90 (source / functions) Hit Total Coverage
Test: FLEUR test coverage Lines: 29 149 19.5 %
Date: 2024-05-15 04:28:08 Functions: 2 2 100.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------
       2             : ! Copyright (c) 2017 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
       3             : ! This file is part of FLEUR and available as free software under the conditions
       4             : ! of the MIT license as expressed in the LICENSE file in more detail.
       5             : !--------------------------------------------------------------------------------
       6             : 
       7             : MODULE m_corespec_io
       8             : 
       9             :   USE m_corespec
      10             :   USE m_types
      11             :   USE m_juDFT
      12             : 
      13             :   IMPLICIT NONE
      14             : 
      15             :   CONTAINS
      16             : 
      17             : !===============================================================================
      18             : !
      19             : !  S U B R O U T I N E   C O R E S P E C _ I N I T
      20             : !
      21             : !-------------------------------------------------------------------------------
      22             : !
      23        2016 :   SUBROUTINE corespec_init(input,atoms,coreSpecInput)
      24             : 
      25             :     IMPLICIT NONE
      26             : 
      27             :     TYPE(t_input),INTENT(IN)         :: input
      28             :     TYPE(t_atoms),INTENT(IN)         :: atoms
      29             :     TYPE(t_coreSpecInput),INTENT(IN) :: coreSpecInput
      30             : 
      31             :     INTEGER                    :: ui,i
      32             :     LOGICAL                    :: lexist
      33             : 
      34             :     namelist /csinp/ csi
      35             : 
      36        1008 :     l_cs = .false.
      37             : 
      38             : ! initialization of input parameters: type csi
      39             : 
      40        1008 :     csi%verb = 1
      41        1008 :     csi%atomType = 0
      42        1008 :     csi%edge = ""
      43       12096 :     csi%edgeidx = 0
      44        1008 :     csi%lx = -1
      45        1008 :     csi%ek0 = 0.0
      46        1008 :     csi%emn = -2.0
      47        1008 :     csi%emx = 20.0
      48        1008 :     csi%ein = 0.1
      49             : 
      50        1008 :     csi%nqphi = 12
      51        1008 :     csi%nqr = 20
      52        1008 :     csi%alpha_ex=0.1 
      53        1008 :     csi%beta_ex=0.08 
      54        1008 :     csi%I0 = 10 
      55             : 
      56             : ! reading of input parameters from 'corespec_inp' file
      57             : 
      58        1008 :     call iounit(ui)
      59        1008 :     inquire(file="corespec_inp",exist=lexist)
      60        1008 :     if(lexist) then
      61           0 :       open(ui,file="corespec_inp",status='old')
      62           0 :       read(ui,nml=csinp)
      63           0 :       close(ui)
      64        1008 :     else if(input%l_coreSpec) THEN
      65           0 :       csi = coreSpecInput
      66             :     else
      67        1008 :       return
      68             :     endif
      69             : 
      70           0 :     smeno = "corespec_init"
      71             : 
      72           0 :     write(*,'(/,a)') trim(smeno)//ssep
      73             : 
      74           0 :     IF(ANY(atoms%nlo(:).NE.0)) THEN
      75           0 :        WRITE(*,*) 'PLEASE NOTE:'
      76           0 :        WRITE(*,*) 'EELS + LOs is only for experienced users.'
      77           0 :        WRITE(*,*) 'I hope you know what you are doing.'
      78             : !       CALL juDFT_error("EELS + LOs not available at the moment!" ,calledby ="corespec_io")
      79             :     END IF
      80             : 
      81             : ! sanity check of the input parameters; if they are not correct, program stops
      82             : ! unit conversion if necessary
      83             : ! if csi%verb = 1, detailed information is written to stdout
      84             : 
      85             : !   csv%nqphi
      86           0 :     if(csi%nqphi.lt.0) then
      87           0 :       write(*,csmsgs)  trim(smeno),"found csi%nqphi < 0 !"//csmsgerr ; stop
      88             :     endif
      89           0 :     csv%nqphi = csi%nqphi
      90           0 :     if(csi%verb.eq.1) write(*,csmsgsis)  trim(smeno),&
      91           0 :            &"Mesh number of angles: ","csi%nqphi = ",csv%nqphi,"will be used"
      92             :  
      93             : ! csi%nqr
      94           0 :     if(csi%nqr.lt.0) then
      95           0 :       write(*,csmsgs)  trim(smeno),"found csi%nqr < 0 !"//csmsgerr ; stop
      96             :     endif
      97           0 :     csv%nqr = csi%nqr
      98           0 :     if(csi%verb.eq.1) write(*,csmsgsis)  trim(smeno),&
      99           0 :            &"Mesh number of radii: ","csi%nqr = ",csv%nqr,"will be used"
     100             : 
     101             : ! csi%alpha_ex
     102           0 :     if(csi%alpha_ex.lt.0) then
     103           0 :       write(*,csmsgs)  trim(smeno),"found csi%alpha_ex < 0 !"//csmsgerr ; stop
     104             :     endif
     105           0 :     csv%alpha_ex = csi%alpha_ex
     106           0 :     if(csi%verb.eq.1) write(*,csmsgsfs)  trim(smeno),&
     107           0 :            &"Experimental convergence angle of incoming e-: ","csi%alpha_ex = ",csv%alpha_ex,"will be used"
     108             : 
     109             : ! csi%beta_ex
     110           0 :     if(csi%beta_ex.lt.0) then
     111           0 :       write(*,csmsgs)  trim(smeno),"found csi%beta_ex < 0 !"//csmsgerr ; stop
     112             :     endif
     113           0 :     csv%beta_ex = csi%beta_ex
     114           0 :     if(csi%verb.eq.1) write(*,csmsgsfs)  trim(smeno),&
     115           0 :            &"Experimental convergence angle of outgoing e-: ","csi%beta_ex = ",csv%beta_ex,"will be used"
     116             : 
     117             : ! csi%I0
     118           0 :     if(csi%I0.le.0) then
     119           0 :       write(*,csmsgs)  trim(smeno),"found csi%I0 <= 0 !"//csmsgerr ; stop
     120             :     endif
     121           0 :     csv%I0 = csi%I0
     122           0 :     if(csi%verb.eq.1) write(*,csmsgsfs)  trim(smeno),&
     123           0 :            &"Intensity of incoming electrons: ","csi%I0 = ",csv%I0,"will be used"
     124             : 
     125             : 
     126             : 
     127             : ! csi%atomType
     128           0 :     if(csi%atomType.le.0) then
     129           0 :       write(*,csmsgs)  trim(smeno),"found csi%atomType <= 0 !"//csmsgerr ; stop
     130             :     endif
     131           0 :     if(csi%atomType.gt.atoms%ntype) then
     132           0 :       write(*,csmsgs)  trim(smeno),"found csi%atomType > atoms%ntype!"//csmsgerr ; stop
     133             :     endif
     134           0 :     if(csi%verb.eq.1) write(*,csmsgsis)  trim(smeno),&
     135           0 :            &"atomic type: ","csi%atomType = ",csi%atomType,"will be used"
     136             : 
     137             : ! csi%edge -> csv%nc
     138           0 :     csv%nc = 0
     139           0 :     if(len(trim(csi%edge)).ne.0) csv%nc = ichar(csi%edge)-ichar('K')+1
     140           0 :     if(csi%edge.eq."") then
     141           0 :       write(*,csmsgs) trim(smeno),"found empty csi%edge !"//csmsgerr ; stop
     142             :     endif
     143           0 :     if(csv%nc.lt.1.or.csv%nc.gt.6) then
     144           0 :       write(*,csmsgs) trim(smeno),&
     145           0 :            &"specify csi%edge as one of {K,L,M,N,O,P} !"//csmsgerr ; stop
     146             :     endif
     147           0 :     if(csi%verb.eq.1) write(*,csmsgsss)  trim(smeno),&
     148           0 :            &"edge: ","csi%edge = ",csi%edge,"will be used"
     149           0 :     if(csi%verb.eq.1) write(*,csmsgsis)  trim(smeno),&
     150           0 :            &"main quantum no.: ","csv%nc = ",csv%nc,"will be used"
     151             : 
     152             : ! csi%edgeidx(:) -> csv%nljc
     153           0 :     if(maxval(csi%edgeidx).gt.(2*csv%nc-1)) then
     154           0 :       write(*,csmsgs) trim(smeno),&
     155           0 :          &"found csi%edgeidx > 2*csv%nc-1 !"//csmsgerr ; stop
     156             :     endif
     157           0 :     if(count(csi%edgeidx.gt.0).gt.(2*csv%nc-1)) then
     158           0 :       write(*,csmsgs) trim(smeno),&
     159           0 :          &"found more than 2*csv%nc-1 of csi%edgeidx > 0 !"//csmsgerr ; stop
     160             :     endif
     161           0 :     if((csv%nc-1)**2+maxval(csi%edgeidx).gt.atoms%econf(csi%atomType)%num_core_states) then
     162           0 :       write(*,csmsgs) trim(smeno),&
     163           0 :          &"found (csv%nc-1)^2+maxval(csi%edgeidx) > num_core_states(csi%atomType)!"//csmsgerr
     164           0 :       stop
     165             :     endif
     166           0 :     csv%nljc = count(csi%edgeidx.gt.0)
     167           0 :     if(.not.allocated(csv%lc)) allocate(csv%lc(csv%nljc))
     168           0 :     csv%lc = (/(edgel(csi%edgeidx(i)), i = 1,csv%nljc)/)
     169             : !!$    print*,csv%lc
     170           0 :     if(csi%verb.eq.1) write(*,csmsgsis)  trim(smeno),&
     171           0 :            &"nljc edge lines: ","csv%nljc = ",csv%nljc,"will be used"
     172             : 
     173             : ! csi%lx
     174           0 :     if(csi%lx.lt.0) then
     175           0 :       write(*,csmsgs)  trim(smeno),"found csi%lx < 0 !"//csmsgerr ; stop
     176             :     endif
     177           0 :     if(csi%lx.gt.atoms%lmax(csi%atomType)) then
     178           0 :       write(*,csmsgs)  trim(smeno),&
     179           0 :            &"found csi%lx > atoms%lmax(csi%atomType)!"//csmsgerr ; stop
     180             :     endif
     181           0 :     if(csi%verb.eq.1) write(*,csmsgsis)  trim(smeno),&
     182           0 :            &"maximum l: ","csi%lx = ",csi%lx,"will be used"
     183             : 
     184             : ! csi%ek0
     185           0 :     if(csi%ek0.le.0.0) then
     186           0 :       write(*,csmsgs)  trim(smeno),"found csi%ek0 <= 0.0 !"//csmsgerr ; stop
     187             :     endif
     188           0 :     csi%ek0 = csi%ek0*1000.0 ! conversion from keV to eV
     189           0 :     csv%gamma = 1.0+csi%ek0/mec2
     190           0 :     csv%beta = sqrt(1.0-1.0/(csv%gamma**2))
     191           0 :     if(csi%verb.eq.1) then
     192           0 :       write(*,csmsgses)  trim(smeno),&
     193           0 :            &"kinetic energy of incoming electrons: ","csi%ek0 = ",csi%ek0,&
     194           0 :            &"eV will be used"
     195           0 :       write(*,csmsgses)  trim(smeno),&
     196           0 :            &"Lorentz factor (gamma): ","csv%gamma = ",csv%gamma,&
     197           0 :            &"will be used"
     198           0 :       write(*,csmsgses)  trim(smeno),&
     199           0 :            &"v/c factor (beta): ","csv%beta = ",csv%beta,&
     200           0 :            &"will be used"
     201             :     endif
     202             : 
     203             : ! csi%emn csi%emx csi%ein -> csv%nex csv%egrid(0:csv%nex)
     204           0 :     if(csi%emn.gt.csi%emx) then
     205           0 :       write(*,csmsgs)  trim(smeno),"found csi%emn > csi%emx !"//csmsgerr ; stop
     206             :     endif
     207           0 :     if(csi%ein.le.0.0) then
     208           0 :       write(*,csmsgs)  trim(smeno),"found csi%ein <= 0.0 !"//csmsgerr ; stop
     209             :     endif
     210           0 :     if(((csi%emx-csi%emn)/csi%ein)-int((csi%emx-csi%emn)/csi%ein).ne.0) then
     211           0 :       write(*,csmsgs)  trim(smeno),&
     212           0 :            &"found non-integer (csi%emx-csi%emn)/csi%ein !"//csmsgerr ; stop
     213             :     endif
     214           0 :     csv%nex = int((csi%emx-csi%emn)/csi%ein)
     215           0 :     if(.not.allocated(csv%egrid)) allocate(csv%egrid(0:csv%nex))
     216           0 :     csv%egrid = (/(csi%emn+csi%ein*dble(i), i = 0,csv%nex)/)
     217           0 :     csv%nen = 0
     218             : !!$    do i = 0,csv%nex
     219             : !!$      if(csv%egrid(i).ge.0.0) then
     220             : !!$        csv%nen = i
     221             : !!$        exit
     222             : !!$      endif
     223             : !!$    enddo
     224             : 
     225             : !!$    print*,csv%egrid
     226             : !!$    print*,csv%nen
     227           0 :     if(csi%verb.eq.1) write(*,csmsgsfs)  trim(smeno),&
     228           0 :            &"energy spectrum lower bound: ","csi%emn = ",csi%emn,&
     229           0 :            &"eV will be used"
     230           0 :     if(csi%verb.eq.1) write(*,csmsgsfs)  trim(smeno),&
     231           0 :            &"energy spectrum upper bound: ","csi%emx = ",csi%emx,&
     232           0 :            &"eV will be used"
     233           0 :     if(csi%verb.eq.1) write(*,csmsgsfs)  trim(smeno),&
     234           0 :            &"energy spectrum increment: ","csi%ein = ",csi%ein,"eV will be used"
     235           0 :     if(csi%verb.eq.1) write(*,csmsgsis)  trim(smeno),&
     236           0 :            &"no. of energy spectrum grid points: ","csv%nex = 0 : ",&
     237           0 :            &csv%nex,"will be used"
     238           0 :     if(csi%verb.eq.1) write(*,csmsgsis)  trim(smeno),&
     239           0 :            &"minimum index for which egrid >= 0: ","csv%nen = ",&
     240           0 :            &csv%nen,"will be used"
     241             : 
     242           0 :     if(.not.allocated(csv%eedge)) allocate(csv%eedge(csv%nljc))
     243           0 :     csv%eedge = 0.0
     244           0 :     if(.not.allocated(csv%occ)) allocate(csv%occ(csv%nljc))
     245           0 :     csv%occ = 0.0
     246             : 
     247           0 :     l_cs = .true.
     248             : 
     249           0 :     if(csi%verb.eq.1) write(*,*) ""
     250             : 
     251             :   end subroutine corespec_init
     252             : !
     253             : !===============================================================================
     254             : !===============================================================================
     255             : !
     256             : !  S U B R O U T I N E   I O U N I T
     257             : !
     258             : !-------------------------------------------------------------------------------
     259             : !
     260        1008 :   subroutine iounit(unit)
     261             : !
     262             : ! Assignes unused integer to I/O unit
     263             : !
     264             :     implicit none
     265             : !
     266             :     integer, intent(out) :: unit
     267             : !
     268             :     integer :: i
     269             :     logical :: fopen
     270             : !
     271        1008 :     i = 9
     272        1008 :     fopen = .true.
     273        2016 :     do while(fopen)
     274        1008 :       i = i+1
     275        2016 :       inquire(unit=i,opened=fopen)
     276             :     enddo
     277             : !
     278        1008 :     unit = i
     279             : !
     280        1008 :   end subroutine iounit
     281             : !
     282             : !===============================================================================
     283             : 
     284             : 
     285             : 
     286             : end module m_corespec_io

Generated by: LCOV version 1.14