LCOV - code coverage report
Current view: top level - src/62_ctqmc - m_CtqmcoffdiagInterface.F90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 81 0
Test Date: 2026-09-21 19:39:32 Functions: 0.0 % 7 0

            Line data    Source code
       1              : 
       2              : #if defined HAVE_CONFIG_H
       3              : #include "config.h"
       4              : #endif
       5              : !!****m* ABINIT/m_CtqmcoffdiagInterface
       6              : !! NAME
       7              : !!  m_CtqmcoffdiagInterface
       8              : !!
       9              : !! FUNCTION
      10              : !!  Manage a ctqmc simulation.
      11              : !!  friendly interface for the user
      12              : !!
      13              : !! COPYRIGHT
      14              : !!  Copyright (C) 2013-2026 ABINIT group (J. Bieder, B. Amadon, J. Denier)
      15              : !!  This file is distributed under the terms of the
      16              : !!  GNU General Public License, see ~abinit/COPYING
      17              : !!  or http://www.gnu.org/copyleft/gpl.txt .
      18              : !!
      19              : !! NOTES
      20              : !!
      21              : !! SOURCE
      22              : 
      23              : #include "defs.h"
      24              : MODULE m_CtqmcoffdiagInterface
      25              : USE m_Ctqmcoffdiag
      26              : use defs_basis
      27              : 
      28              : IMPLICIT NONE
      29              : 
      30              : !!***
      31              : 
      32              : !!****t* m_CtqmcoffdiagInterface/CtqmcoffdiagInterface
      33              : !! NAME
      34              : !!  CtqmcoffdiagInterface
      35              : !!
      36              : !! FUNCTION
      37              : !!  This structured datatype contains the necessary data
      38              : !!
      39              : !! COPYRIGHT
      40              : !!  Copyright (C) 2013-2026 ABINIT group (J. Bieder)
      41              : !!  This file is distributed under the terms of the
      42              : !!  GNU General Public License, see ~abinit/COPYING
      43              : !!  or http://www.gnu.org/copyleft/gpl.txt .
      44              : !!
      45              : !! SOURCE
      46              : 
      47              : TYPE CtqmcoffdiagInterface
      48              :   TYPE(Ctqmcoffdiag) :: Hybrid
      49              :   INTEGER :: opt_fk       = 0
      50              :   INTEGER :: opt_order    = 0
      51              :   INTEGER :: opt_histo    = 0
      52              :   INTEGER :: opt_movie    = 0
      53              :   INTEGER :: opt_analysis = 0
      54              :   INTEGER :: opt_check    = 0
      55              :   INTEGER :: opt_spectra  = 0
      56              :   INTEGER :: opt_noise    = 0
      57              :   INTEGER :: opt_gMove    = 0
      58              : END TYPE CtqmcoffdiagInterface
      59              : !!***
      60              : 
      61              : CONTAINS
      62              : !!***
      63              : 
      64              : !!****f* ABINIT/m_CtqmcoffdiagInterface/CtqmcoffdiagInterface_init
      65              : !! NAME
      66              : !!  CtqmcoffdiagInterface_init
      67              : !!
      68              : !! FUNCTION
      69              : !!  Initialize with permanent parameters
      70              : !!
      71              : !! COPYRIGHT
      72              : !!  Copyright (C) 2013-2026 ABINIT group (J. Bieder)
      73              : !!  This file is distributed under the terms of the
      74              : !!  GNU General Public License, see ~abinit/COPYING
      75              : !!  or http://www.gnu.org/copyleft/gpl.txt .
      76              : !!
      77              : !! INPUTS
      78              : !!  op=ctqmcinterface
      79              : !!  iseed=seed for rng
      80              : !!  sweeps=number of sweeps for the run
      81              : !!  thermalization=number of sweeps to thermalize
      82              : !!  measurements=how often we measure (modulo)
      83              : !!  flavors=number of orbitals (spin degenerated)
      84              : !!  samples=imaginary time slices
      85              : !!  beta=inverse temperature
      86              : !!  U=interaction parameter
      87              : !!  ostream=where to write output
      88              : !!  MPI_COMM=mpi communicator for the run
      89              : !!  nspinor=number of spinor
      90              : !!
      91              : !! OUTPUT
      92              : !!
      93              : !! SIDE EFFECTS
      94              : !!
      95              : !! NOTES
      96              : !!
      97              : !! SOURCE
      98              : 
      99            0 : SUBROUTINE CtqmcoffdiagInterface_init(op,iseed,sweeps,thermalization,&
     100              : &measurements,flavors,samples,beta,U,ostream,MPI_COMM,opt_nondiag,nspinor)
     101              : 
     102              : !Arguments ------------------------------------
     103              :   TYPE(CtqmcoffdiagInterface), INTENT(INOUT) :: op
     104              :   INTEGER, OPTIONAL, INTENT(IN) :: MPI_COMM
     105              :   INTEGER, INTENT(IN) :: iseed
     106              :   DOUBLE PRECISION, INTENT(IN) :: sweeps
     107              :   INTEGER, INTENT(IN) :: thermalization
     108              :   INTEGER, INTENT(IN) :: measurements
     109              :   INTEGER, INTENT(IN) :: flavors
     110              :   INTEGER, INTENT(IN) :: samples
     111              :   !INTEGER, INTENT(IN) :: Wmax
     112              :   INTEGER, INTENT(IN) :: ostream
     113              :   INTEGER, INTENT(IN) :: opt_nondiag
     114              :   DOUBLE PRECISION, INTENT(IN) :: beta
     115              :   DOUBLE PRECISION, INTENT(IN) :: u
     116              :   INTEGER, INTENT(IN) :: nspinor
     117              :   !DOUBLE PRECISION, INTENT(IN) :: mu
     118              : !Local arguements -----------------------------
     119              :   INTEGER          :: ifstream
     120              :   DOUBLE PRECISION, DIMENSION(1:11) :: buffer
     121              : 
     122            0 :   ifstream = 42
     123              : 
     124            0 :   buffer(1)=DBLE(iseed)
     125            0 :   buffer(2)=sweeps
     126            0 :   buffer(3)=DBLE(thermalization)
     127            0 :   buffer(4)=DBLE(measurements)
     128            0 :   buffer(5)=DBLE(flavors)
     129            0 :   buffer(6)=DBLE(samples)
     130            0 :   buffer(7)=beta
     131            0 :   buffer(8)=U
     132            0 :   buffer(9)=GREENHYB_TAU
     133            0 :   buffer(10)=DBLE(opt_nondiag)
     134            0 :   buffer(11)=nspinor
     135              :   !buffer(9)=0.d0!mu
     136              :   !buffer(9)=DBLE(Wmax)
     137              : 
     138            0 :   IF ( PRESENT( MPI_COMM ) ) THEN
     139            0 :     CALL Ctqmcoffdiag_init(op%Hybrid, ostream, ifstream, .FALSE., MPI_COMM,buffer)
     140              :   ELSE
     141            0 :     CALL Ctqmcoffdiag_init(op%Hybrid, ostream, ifstream, .FALSE.,iBuffer=buffer)
     142              :   END IF
     143            0 :   op%opt_fk       = 0
     144            0 :   op%opt_order    = 0
     145            0 :   op%opt_histo    = 0
     146            0 :   op%opt_movie    = 0
     147            0 :   op%opt_analysis = 0
     148            0 :   op%opt_check    = 0
     149            0 :   op%opt_noise    = 0
     150            0 :   op%opt_spectra  = 0
     151            0 : END SUBROUTINE CtqmcoffdiagInterface_init
     152              : !!***
     153              : 
     154              : !!****f* ABINIT/m_CtqmcoffdiagInterface/CtqmcoffdiagInterface_setOpts
     155              : !! NAME
     156              : !!  CtqmcoffdiagInterface_setOpts
     157              : !!
     158              : !! FUNCTION
     159              : !!  Set and save options for many runs
     160              : !!
     161              : !! COPYRIGHT
     162              : !!  Copyright (C) 2013-2026 ABINIT group (J. Bieder)
     163              : !!  This file is distributed under the terms of the
     164              : !!  GNU General Public License, see ~abinit/COPYING
     165              : !!  or http://www.gnu.org/copyleft/gpl.txt .
     166              : !!
     167              : !! INPUTS
     168              : !!  op=ctqmcinterface
     169              : !!  opt_Fk=0 if we give us Gw0 and 1 if 1/Gw0+iwn
     170              : !!  opt_order=maximal perturbation order to scope(>0)
     171              : !!  opt_movie=print a latex file (0 or 1)
     172              : !!  opt_analysis=measure correlations (0 or 1)
     173              : !!  opt_check=check fast calculation :0 nothing
     174              : !!                                    1 Impurity
     175              : !!                                    2 Bath
     176              : !!                                    3 Both
     177              : !!  opt_noise=calculate noise ofr green functions(0 ro 1)
     178              : !!  opt_spectra=fourier transform of time evolution of number of electrons
     179              : !!               (0 or 1)
     180              : !!  opt_gMove=number of global moves (>0)
     181              : !!
     182              : !! OUTPUT
     183              : !!
     184              : !! SIDE EFFECTS
     185              : !!
     186              : !! NOTES
     187              : !!
     188              : !! SOURCE
     189              : 
     190            0 : SUBROUTINE CtqmcoffdiagInterface_setOpts(op,opt_Fk,opt_order,opt_histo,opt_movie,&
     191              : & opt_analysis,opt_check, opt_noise, opt_spectra, opt_gMove)
     192              : 
     193              : !Arguments ------------------------------------
     194              :   TYPE(CtqmcoffdiagInterface), INTENT(INOUT) :: op
     195              :   INTEGER , OPTIONAL  , INTENT(IN   ) :: opt_Fk
     196              :   INTEGER , OPTIONAL  , INTENT(IN   ) :: opt_order
     197              :   INTEGER , OPTIONAL  , INTENT(IN   ) :: opt_histo
     198              :   INTEGER , OPTIONAL  , INTENT(IN   ) :: opt_movie
     199              :   INTEGER , OPTIONAL  , INTENT(IN   ) :: opt_analysis
     200              :   INTEGER , OPTIONAL  , INTENT(IN   ) :: opt_check
     201              :   INTEGER , OPTIONAL  , INTENT(IN   ) :: opt_noise
     202              :   INTEGER , OPTIONAL  , INTENT(IN   ) :: opt_spectra
     203              :   INTEGER , OPTIONAL  , INTENT(IN   ) :: opt_gMove
     204              : 
     205            0 :   IF ( PRESENT(opt_Fk) ) &
     206            0 :     op%opt_Fk = opt_fk
     207            0 :   IF ( PRESENT(opt_order) ) &
     208            0 :     op%opt_order = opt_order
     209            0 :   IF ( PRESENT(opt_histo) ) &
     210            0 :     op%opt_histo = opt_histo
     211            0 :   IF ( PRESENT(opt_analysis) ) &
     212            0 :     op%opt_analysis = opt_analysis
     213            0 :   IF ( PRESENT(opt_check) ) &
     214            0 :     op%opt_check = opt_check
     215            0 :   IF ( PRESENT(opt_movie) ) &
     216            0 :     op%opt_movie = opt_movie
     217            0 :   IF ( PRESENT(opt_noise) ) &
     218            0 :     op%opt_noise = opt_noise
     219            0 :   IF ( PRESENT(opt_spectra) ) &
     220            0 :     op%opt_spectra = opt_spectra
     221            0 :   IF ( PRESENT(opt_gMove) ) &
     222            0 :     op%opt_gMove = opt_gMove
     223              : 
     224            0 : END SUBROUTINE CtqmcoffdiagInterface_setOpts
     225              : !!***
     226              : 
     227              : !!****f* ABINIT/m_CtqmcoffdiagInterface/CtqmcoffdiagInterface_run
     228              : !! NAME
     229              : !!  CtqmcoffdiagInterface_run
     230              : !!
     231              : !! FUNCTION
     232              : !!  run a ctqmc simu and get results
     233              : !!
     234              : !! COPYRIGHT
     235              : !!  Copyright (C) 2013-2026 ABINIT group (J. Bieder)
     236              : !!  This file is distributed under the terms of the
     237              : !!  GNU General Public License, see ~abinit/COPYING
     238              : !!  or http://www.gnu.org/copyleft/gpl.txt .
     239              : !!
     240              : !! INPUTS
     241              : !!  op=ctqmcinterface
     242              : !!  G0omega=Gw0 (according to opt_Fk)
     243              : !!  matU=interaction matrice
     244              : !!  opt_sym=weight factors to symmetrise G
     245              : !!  opt_levels=energy for each level (with respect to fermi level)
     246              : !!
     247              : !! OUTPUT
     248              : !!  Gtau=G(tau)
     249              : !!  Gw=fourier transform of Gtau
     250              : !!  D=full double occupancy
     251              : !!  E=Interaction energy
     252              : !!  Noise=Noise on E
     253              : !!
     254              : !! SIDE EFFECTS
     255              : !!
     256              : !! NOTES
     257              : !!
     258              : !! SOURCE
     259              : 
     260            0 : SUBROUTINE CtqmcoffdiagInterface_run(op,G0omega, Gtau, Gw, D,E,Noise,matU,Docc,opt_sym,opt_levels,hybri_limit,Magmom_orb,&
     261            0 : &Magmom_spin,Magmom_tot,Iatom,fname,jmjbasis)
     262              : 
     263              : !Arguments ------------------------------------
     264              :   TYPE(CtqmcoffdiagInterface), INTENT(INOUT) :: op
     265              :   COMPLEX(KIND=8)      , DIMENSION(:,:,:), INTENT(IN ) :: G0omega
     266              :   DOUBLE PRECISION, DIMENSION(:,:,:), OPTIONAL, INTENT(OUT) :: Gtau
     267              :   COMPLEX(KIND=8)      , DIMENSION(:,:,:), OPTIONAL, INTENT(INOUT) :: Gw
     268              :   DOUBLE PRECISION, OPTIONAL      , INTENT(OUT) :: D
     269              :   DOUBLE PRECISION, OPTIONAL      , INTENT(OUT) :: E
     270              :   DOUBLE PRECISION, OPTIONAL      , INTENT(OUT) :: Noise
     271              :   DOUBLE PRECISION, DIMENSION(:,:),OPTIONAL,  INTENT(IN ) :: matU
     272              :   DOUBLE PRECISION, DIMENSION(:,:),OPTIONAL,  INTENT(OUT ) :: Docc
     273              :   DOUBLE PRECISION, DIMENSION(:,:),OPTIONAL,  INTENT(IN ) :: opt_sym
     274              :   DOUBLE PRECISION, DIMENSION(:),OPTIONAL,  INTENT(IN ) :: opt_levels
     275              :   COMPLEX(KIND=8) , DIMENSION(:,:),OPTIONAL,  INTENT(IN ) :: hybri_limit
     276              :   DOUBLE PRECISION, DIMENSION(:,:),OPTIONAL, INTENT(IN ) :: Magmom_orb
     277              :   DOUBLE PRECISION, DIMENSION(:,:),OPTIONAL, INTENT(IN ) :: Magmom_spin
     278              :   DOUBLE PRECISION, DIMENSION(:,:),OPTIONAL, INTENT(IN ) :: Magmom_tot
     279              :   INTEGER, INTENT(IN ) :: Iatom
     280              :   INTEGER, OPTIONAL, INTENT(IN )  :: jmjbasis
     281              :   character(len=fnlen), INTENT(INOUT) :: fname
     282              : !local variables--------------------------------
     283              : !  INTEGER :: iflavor1,iflavor2
     284              : 
     285              :  ! do iflavor1=1,10
     286              :  !   do iflavor2=1,10
     287              :  !      if(iflavor1==iflavor2) THEN
     288              :  !        write(6,*) iflavor1, iflavor2, Magmom(iflavor1,iflavor2)
     289              :  !      end if
     290              :  !   end do
     291              :  ! end do
     292              : 
     293            0 :   CALL Ctqmcoffdiag_reset(op%Hybrid)
     294              : 
     295              : !  ifstream = 42
     296              : !
     297              : !  OPEN(UNIT=ifstream, FILE="Gw.dat")
     298              : !  CALL Ctqmcoffdiag_setG0w(Hybrid, ifstream)
     299              : !  CLOSE(ifstream)
     300              : !
     301              : 
     302            0 :   IF ( PRESENT(opt_levels)) &
     303            0 :     CALL Ctqmcoffdiag_setMu(op%Hybrid, opt_levels)
     304              : 
     305            0 :   IF ( PRESENT(hybri_limit)) &
     306            0 :     CALL Ctqmcoffdiag_sethybri_limit(op%Hybrid, hybri_limit)
     307              : 
     308              :      !call xmpi_barrier(op%Hybrid%MY_COMM)
     309            0 :   CALL Ctqmcoffdiag_setG0wTab(op%Hybrid, G0omega,op%opt_fk,fname)
     310              :      !call xmpi_barrier(op%Hybrid%MY_COMM)
     311              : 
     312            0 :   IF ( PRESENT(matU) ) &
     313            0 :     CALL Ctqmcoffdiag_setU(op%Hybrid, matU)
     314              :      !call xmpi_barrier(op%Hybrid%MY_COMM)
     315              : 
     316            0 :   IF ( PRESENT(Magmom_orb) ) &
     317            0 :     CALL Ctqmcoffdiag_setMagmom(op%Hybrid, Magmom_orb, Magmom_spin, Magmom_tot)
     318              :      !call xmpi_barrier(op%Hybrid%MY_COMM)
     319              : 
     320              : 
     321              :   CALL Ctqmcoffdiag_run(op%Hybrid,opt_order=op%opt_order, &
     322              :                            opt_histo=op%opt_histo, &
     323              :                            opt_movie=op%opt_movie, &
     324              :                            opt_analysis=op%opt_analysis, &
     325              :                            opt_check=op%opt_check, &
     326              :                            opt_noise=op%opt_noise, &
     327              :                            opt_spectra=op%opt_spectra, &
     328            0 :                            opt_gMove=op%opt_gMove)
     329              :      !call xmpi_barrier(op%Hybrid%MY_COMM)
     330              : 
     331              :  ! write(6,*) "op%Hybrid%stats",op%Hybrid%stats
     332              :  ! write(6,*) "opt_gMove",op%opt_gMove
     333              : 
     334            0 :   CALL Ctqmcoffdiag_getResult(op%Hybrid,Iatom,fname,jmjbasis)
     335              : 
     336            0 :   IF ( PRESENT(opt_sym) ) THEN
     337            0 :     CALL Ctqmcoffdiag_symmetrizeGreen(op%Hybrid,opt_sym)
     338              :   END IF
     339              : 
     340              :  ! write(6,*) "op%Hybrid%stats",op%Hybrid%stats
     341              : 
     342            0 :   IF ( PRESENT(Gtau) .AND. PRESENT(Gw) ) THEN
     343            0 :     CALL Ctqmcoffdiag_getGreen(op%Hybrid, Gtau=Gtau, Gw=Gw)
     344              :   !      write(6,*) "size",size(Gw,dim=1),size(gw,dim=2)
     345              :   !      IF ( hybrid%rank .EQ. 0 ) write(389,*) Gw(:,hybrid%flavors+1)
     346              :   !      call flush(389)
     347            0 :   ELSE IF ( PRESENT(Gtau) .AND. .NOT. PRESENT(Gw) ) THEN
     348            0 :     CALL Ctqmcoffdiag_getGreen(op%Hybrid, Gtau=Gtau)
     349            0 :   ELSE IF ( .NOT. PRESENT(Gtau) .AND. PRESENT(Gw) ) THEN
     350            0 :     CALL Ctqmcoffdiag_getGreen(op%Hybrid, Gw=Gw)
     351              :   END IF
     352              : 
     353              :   !write(6,*) "op%Hybrid%stats",op%Hybrid%stats
     354              : 
     355            0 :   IF ( PRESENT(D) ) &
     356            0 :   CALL Ctqmcoffdiag_getD(op%Hybrid, D)
     357            0 :   Docc=op%Hybrid%measDE
     358              : 
     359              :   !write(6,*) "op%Hybrid%stats",op%Hybrid%stats
     360              : 
     361            0 :   IF ( PRESENT(E) .AND. PRESENT(Noise) ) &
     362            0 :   CALL Ctqmcoffdiag_getE(op%Hybrid, E, Noise)
     363              : 
     364            0 :   CALL Ctqmcoffdiag_printAll(op%Hybrid)
     365              :   !CALL Ctqmcoffdiag_printQMC(op%Hybrid)
     366              : 
     367            0 : END SUBROUTINE CtqmcoffdiagInterface_run
     368              : !!***
     369              : 
     370              : !!****f* ABINIT/m_CtqmcoffdiagInterface/CtqmcoffdiagInterface_setSweeps
     371              : !! NAME
     372              : !!  CtqmcoffdiagInterface_setSweeps
     373              : !!
     374              : !! FUNCTION
     375              : !!  change sweeps on the fly
     376              : !!
     377              : !! COPYRIGHT
     378              : !!  Copyright (C) 2013-2026 ABINIT group (J. Bieder)
     379              : !!  This file is distributed under the terms of the
     380              : !!  GNU General Public License, see ~abinit/COPYING
     381              : !!  or http://www.gnu.org/copyleft/gpl.txt .
     382              : !!
     383              : !! INPUTS
     384              : !!  op=ctqmcinterface
     385              : !!  sweeps=new number of sweeps
     386              : !!
     387              : !! OUTPUT
     388              : !!
     389              : !! SIDE EFFECTS
     390              : !!
     391              : !! NOTES
     392              : !!
     393              : !! SOURCE
     394              : 
     395            0 : SUBROUTINE CtqmcoffdiagInterface_setSweeps(op, sweeps)
     396              : 
     397              : !Arguments ------------------------------------
     398              :   TYPE(CtqmcoffdiagInterface), INTENT(INOUT) :: op
     399              :   DOUBLE PRECISION, INTENT(IN) :: sweeps
     400              : 
     401            0 :   CALL Ctqmcoffdiag_setSweeps(op%Hybrid,sweeps)
     402            0 : END SUBROUTINE CtqmcoffdiagInterface_setSweeps
     403              : !!***
     404              : 
     405              : !!****f* ABINIT/m_CtqmcoffdiagInterface/CtqmcoffdiagInterface_finalize
     406              : !! NAME
     407              : !!  CtqmcoffdiagInterface_finalize
     408              : !!
     409              : !! FUNCTION
     410              : !!  Destroy simulation
     411              : !!
     412              : !! COPYRIGHT
     413              : !!  Copyright (C) 2013-2026 ABINIT group (J. Bieder)
     414              : !!  This file is distributed under the terms of the
     415              : !!  GNU General Public License, see ~abinit/COPYING
     416              : !!  or http://www.gnu.org/copyleft/gpl.txt .
     417              : !!
     418              : !! INPUTS
     419              : !!  op=ctqmcinterface
     420              : !!
     421              : !! OUTPUT
     422              : !!
     423              : !! SIDE EFFECTS
     424              : !!
     425              : !! NOTES
     426              : !!
     427              : !! SOURCE
     428              : 
     429            0 : SUBROUTINE CtqmcoffdiagInterface_finalize(op)
     430              : 
     431              : !Arguments ------------------------------------
     432              :   TYPE(CtqmcoffdiagInterface), INTENT(INOUT) :: op
     433              : 
     434              :   !IF ( op%Hybrid%init .EQV. .TRUE. ) THEN
     435              : !    CALL Ctqmcoffdiag_printAll(op%Hybrid)
     436              :          !write(6,*) "before ctqmc_destroy in Ctqmcoffdiaginterface_finalize"
     437            0 :     CALL Ctqmcoffdiag_destroy(op%Hybrid)
     438              :   !END IF
     439              : 
     440            0 : END SUBROUTINE CtqmcoffdiagInterface_finalize
     441              : !!***
     442              : 
     443            0 : END MODULE m_CtqmcoffdiagInterface
     444              : !!***
        

Generated by: LCOV version 2.3-1