types_field.F90 5.26 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
!--------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------

MODULE m_types_field
  !*************************************************************
  !     This module contains definitions for electric and magnetic field -types
  !*************************************************************
11
  USE m_juDFT
Daniel Wortmann's avatar
Daniel Wortmann committed
12
  USE m_types_fleurinput_base
13
  IMPLICIT NONE
14
  PRIVATE
15
  TYPE:: t_efield
16
     REAL    :: zsigma  = 10.0  ! Distance to the charged plates
Daniel Wortmann's avatar
Daniel Wortmann committed
17
     REAL    :: sigma   ! charge at the plates
18 19 20 21 22 23 24 25 26 27
     REAL    :: sig_b(2)=  0.0  ! Extra charge for the top/bottom plate
     REAL,    ALLOCATABLE :: sigEF(:,:,:) ! (nx, ny, nvac)
     COMPLEX, ALLOCATABLE :: rhoEF(:,:)   ! (g_||, nvac)
     COMPLEX, ALLOCATABLE :: C1(:), C2(:) ! Coeff. for Dirichlet bnd.cond.
     LOGICAL :: l_segmented = .FALSE.
     LOGICAL :: plot_charge = .FALSE. ! Plot charge as inputted
     LOGICAL :: plot_rho    = .FALSE. ! Plot Fourier-transformed charge
     LOGICAL :: autocomp    = .TRUE.  ! Auto-compensate film charge
     LOGICAL :: dirichlet = .FALSE. ! Dirichlet vs. Neumann boundary cond.
     LOGICAL :: l_dirichlet_coeff = .FALSE. ! For MPI, true if C1/C2 set
28 29
     LOGICAL :: l_eV =.FALSE. !Input in eV
     CHARACTER(len=50),ALLOCATABLE :: shapes(:)
30 31
  END TYPE t_efield

32
  TYPE,EXTENDS(t_fleurinput_base):: t_field
33
     TYPE(t_efield)   :: efield
34
     LOGICAL          :: l_b_field=.FALSE.
35 36 37 38
     REAL             :: b_field
     REAL,ALLOCATABLE :: b_field_mt(:)
   CONTAINS
     PROCEDURE :: init=>init_field
39 40
     PROCEDURE :: read_xml=>read_xml_field
     PROCEDURE :: mpi_bc=>mpi_bc_field
41 42 43 44
  END TYPE t_field

  PUBLIC t_field,t_efield
CONTAINS
45 46 47 48 49 50 51 52 53

  SUBROUTINE mpi_bc_field(this,mpi_comm,irank)
    USE m_mpi_bc_tool
    CLASS(t_field),INTENT(INOUT)::this
    INTEGER,INTENT(IN):: mpi_comm
    INTEGER,INTENT(IN),OPTIONAL::irank
    INTEGER ::rank
    IF (PRESENT(irank)) THEN
       rank=irank
54 55
    ELSE
       rank=0
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
    END IF

    CALL mpi_bc(this%l_b_field,rank,mpi_comm)
    CALL mpi_bc(this%b_field,rank,mpi_comm)
    CALL mpi_bc(this%b_field_mt,rank,mpi_comm)

    CALL mpi_bc(this%efield%zsigma  ,rank,mpi_comm)
    CALL mpi_bc(this%efield%sigma   ,rank,mpi_comm)
    CALL mpi_bc(this%efield%sig_b(1),rank,mpi_comm)
    CALL mpi_bc(this%efield%sig_b(2),rank,mpi_comm)
    CALL mpi_bc(this%efield%sigEF ,rank,mpi_comm)
    CALL mpi_bc(this%efield%rhoEF   ,rank,mpi_comm)
    CALL MPI_BC(THIS%EFIELD%C1,RANK,MPI_COMM)
    CALL mpi_bc(this%efield%C2 ,rank,mpi_comm)
    CALL mpi_bc(this%efield%l_segmented ,rank,mpi_comm)
    CALL mpi_bc(this%efield%plot_charge ,rank,mpi_comm)
    CALL mpi_bc(this%efield%plot_rho    ,rank,mpi_comm)
    CALL mpi_bc(this%efield%autocomp    ,rank,mpi_comm)
    CALL mpi_bc(this%efield%dirichlet ,rank,mpi_comm)
    CALL mpi_bc(this%efield%l_dirichlet_coeff ,rank,mpi_comm)
    CALL mpi_bc(this%efield%l_eV ,rank,mpi_comm)



  END SUBROUTINE mpi_bc_field

Daniel Wortmann's avatar
Daniel Wortmann committed
82 83
  SUBROUTINE init_field(this)
    !USE m_types_setup
84 85
    IMPLICIT NONE
    CLASS(t_field),INTENT(INOUT)::this
Daniel Wortmann's avatar
Daniel Wortmann committed
86 87 88
    !TYPE(t_input),INTENT(INOUT) ::input
    !input%sigma => sigma
    !this%efield%sigma=>sigma
89
  END SUBROUTINE init_field
90

91
  SUBROUTINE read_xml_field(this,xml)
92
    USE m_types_xml
93
    CLASS(t_field),INTENT(INOUT)::this
94
    TYPE(t_xml),INTENT(INOUT)::xml
95 96 97

    CHARACTER(len=100)::xpatha,xpathb
    INTEGER:: numberNodes,i
98 99

    allocate(this%b_field_mt(xml%get_ntype()));this%b_field_mt=0.0
100 101 102 103
    xPathA = '/fleurInput/calculationSetup/fields'
    numberNodes = xml%GetNumberOfNodes(xPathA)
    IF (numberNodes.EQ.1) THEN
       IF (xml%GetNumberOfNodes(TRIM(ADJUSTL(xPathA))//'/@b_field')>0) THEN
Daniel Wortmann's avatar
Daniel Wortmann committed
104 105
          this%b_field=evaluateFirstOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'//@b_field'))
          this%l_b_field=.TRUE.
106
       ENDIF
Daniel Wortmann's avatar
Daniel Wortmann committed
107 108 109 110 111 112 113 114
       this%efield%zsigma = evaluateFirstOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@zsigma'))
       this%efield%sig_b(1) = evaluateFirstOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@sig_b_1'))
       this%efield%sig_b(2) = evaluateFirstOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@sig_b_2'))
       this%efield%plot_charge = evaluateFirstBoolOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@plot_charge'))
       this%efield%plot_rho = evaluateFirstBoolOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@plot_rho'))
       this%efield%autocomp = evaluateFirstBoolOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@autocomp'))
       this%efield%dirichlet = evaluateFirstBoolOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@dirichlet'))
       this%efield%l_eV = evaluateFirstBoolOnly(xml%GetAttributeValue(TRIM(ADJUSTL(xPathA))//'/@eV'))
115

116
       numberNodes=xml%GetNumberOfNodes(TRIM(ADJUSTL(xPathA))//'/shape')
Daniel Wortmann's avatar
Daniel Wortmann committed
117
       ALLOCATE(this%efield%shapes(numberNodes))
118 119
       DO i=1,numberNodes
          WRITE(xPathB,"(a,a,i0,a)") TRIM(ADJUSTL(xpathA)),'/shape[',i,']'
Daniel Wortmann's avatar
Daniel Wortmann committed
120
          this%efield%shapes(i)=TRIM(ADJUSTL(xml%GetAttributeValue(TRIM(ADJUSTL(xPathB)))))
121 122
       ENDDO
    ELSE
Daniel Wortmann's avatar
Daniel Wortmann committed
123
       ALLOCATE(this%efield%shapes(0))
124
    END IF
125
  END SUBROUTINE read_xml_field
126
END MODULE m_types_field