1! 2! Copyright (C) 2001-2018 Quantum ESPRESSO group 3! This file is distributed under the terms of the 4! GNU General Public License. See the file `License' 5! in the root directory of the present distribution, 6! or http://www.gnu.org/copyleft/gpl.txt . 7! 8!---------------------------------------------------------------------------- 9! 10! ... Common variables for the phonon program 11! 12MODULE modes 13 USE kinds, ONLY : DP 14 ! 15 ! ... The variables needed to describe the modes and the small group of q 16 ! 17 SAVE 18 ! 19 INTEGER :: nirr, nmodes 20 ! number of irreducible representations contained in the dynamical matrix 21 ! number of modes 22 INTEGER, ALLOCATABLE, TARGET :: npert(:) !3 * nat ) 23 ! the number of perturbations per IR 24 INTEGER :: npertx 25 ! max number of perturbations per IR 26 COMPLEX (DP), POINTER :: & 27 u(:,:), &! 3 * nat, 3 * nat), 28 t(:,:,:,:), &! npertx, npertx, 48,3 * nat), 29 tmq(:,:,:) ! npertx, npertx, 3 * nat) 30 ! the transformation modes patterns 31 ! the mode for deltarho 32 ! the symmetry in the base of the pattern 33 ! the symmetry q<->-q in the base of the pa 34 35 CHARACTER(15), ALLOCATABLE :: name_rap_mode(:) ! symmetry type of each mode 36 INTEGER, ALLOCATABLE :: num_rap_mode(:) ! number of the representation for 37 ! each mode 38 ! 39END MODULE modes 40! 41MODULE cryst_ph 42 ! 43 USE kinds, ONLY : DP 44 ! 45 SAVE 46 ! 47 ! This modeule contains the variables that describe properties of the 48 ! crystal that are needed by the phonon program and are not in pw data 49 ! probably these variables should be in the common of pw 50 ! These variables are sets immediately after reading the pw variables 51 ! 52 LOGICAL :: magnetic_sym ! true in the non-collinear magnetic case 53 54END MODULE cryst_ph 55! 56MODULE dynmat 57 USE kinds, ONLY : DP 58 ! 59 ! ... The dynamical matrix 60 ! 61 SAVE 62 ! 63 COMPLEX (DP), ALLOCATABLE :: & 64 dyn00(:,:), &! 3 * nat, 3 * nat), 65 dyn(:,:), &! 3 * nat, 3 * nat) 66 dyn_rec(:,:) ! 3 * nat, 3 * nat) 67 ! the initial dynamical matrix 68 ! the dynamical matrix 69 ! the contribution of each representation to the dynamical matrix 70 REAL (DP), ALLOCATABLE :: & 71 w2(:) ! 3 * nat) 72 ! omega^2 73 ! 74 ! DFPT+U 75 COMPLEX(DP), ALLOCATABLE :: dyn_hub_bare(:,:) ! (3*nat,*3nat) 76 COMPLEX(DP), ALLOCATABLE :: dyn_hub_scf(:,:) ! (3*nat,*3nat) 77 ! the bare part of the Hubbard dynamical matrix 78 ! the scf part of the Hubbard dynamical matrix 79 ! 80END MODULE dynmat 81! 82! 83MODULE efield_mod 84 USE kinds, ONLY : DP 85 ! 86 ! ... the variables for the electric field perturbation 87 ! 88 SAVE 89 ! 90 REAL (DP) :: epsilon (3, 3) 91 REAL (DP), ALLOCATABLE :: & 92 zstareu(:,:,:), &! 3, 3, nat), 93 zstarue(:,:,:) ! 3, nat, 3) 94 ! the dielectric constant 95 ! the effective charges Z(E,Us) (E=scf,Us=bare) 96 ! the effective charges Z(Us,E) (Us=scf,E=bare) 97 COMPLEX (DP), ALLOCATABLE :: & 98 zstareu0(:,:), &! 3, 3 * nat), 99 zstarue0(:,:), &! 3 * nat, 3) 100 zstarue0_rec(:,:) ! 3 * nat, 3) 101 ! the effective charges 102 ! 103END MODULE efield_mod 104! 105! 106MODULE nlcc_ph 107 USE kinds, ONLY : DP 108 ! 109 ! ... The variables needed for non-linear core correction 110 ! 111 SAVE 112 ! 113 COMPLEX (DP), ALLOCATABLE, TARGET :: drc(:,:) ! ngm, ntyp) 114 ! contain the rhoc (without structure fac) for all atomic types 115 ! 116END MODULE nlcc_ph 117! 118! 119MODULE phus 120 USE kinds, ONLY : DP 121 USE becmod, ONLY : bec_type 122 ! 123 ! ... These are additional variables needed for the linear response 124 ! ... program with the US pseudopotentials 125 ! 126 SAVE 127 ! 128 REAL (DP), ALLOCATABLE :: & 129 alphasum(:,:,:,:) ! nhm*(nhm+1)/2,3,nat,nspin) 130 ! used to compute modes 131 ! alphasum contains \sum_i <psi_i| d/du (|\beta_n><beta_m|) | psi_i> + (m-n) 132 ! dipole moment of each Q 133 COMPLEX (DP), ALLOCATABLE :: & 134 int1(:,:,:,:,:), &! nhm, nhm, 3, nat, nspin),& 135 int2(:,:,:,:,:), &! nhm, nhm, 3,nat, nat),& 136 int4(:,:,:,:,:), &! nhm*(nhm+1)/2, 3, 3, nat, nspin),& 137 int5(:,:,:,:,:), &! nhm*(nhm+1)/2, 3, 3, nat, nat),& 138 int1_nc(:,:,:,:,:), &! nhm, nhm, 3, nat, nspin),& 139 int2_so(:,:,:,:,:,:), &! nhm, nhm, 3, nat,nat,nspin),& 140 int4_nc(:,:,:,:,:,:), &! nhm, nhm, 3, 3, nat, nspin),& 141 int5_so(:,:,:,:,:,:,:), &! nhm*(nhm+1)/2, 3, 3, nat, nat, nspin),& 142! 143! These variables contains the five integrals defined in PRB 64, 35118 (2001) 144! int1 -> \int V_eff d/du (Q) d^3r 145! int2 -> \int d/du (V_loc) Q d^3r 146! int3 -> \int d\du (V_Hxc) Q d^3r .... generalized to Delta V_Hxc and move to lr_us in LR_Modules 147! int4 -> \int V_eff d^2/dudu (Q) d^3r 148! int5 -> \int d/du (V_loc) d/du (Q) d^3r 149! 150 becsum_nc(:,:,:,:), &! nhm*(nhm+1)/2,nat,npol,npol) 151 becsumort(:,:,:,:), &! nhm*(nhm+1)/2,nat,nspin,3*nat) 152 alphasum_nc(:,:,:,:,:) ! nhm*(nhm+1)/2,3,nat,npol,npol) 153! 154! becsum contains \sum_i <\psi_i | \beta_n><\beta_m| \psi_i > + (m-n) 155! besumort contains alphasum+\sum_i <\psi_i | \beta_n><\beta_m| \delta \psi_i > 156! 157 type (bec_type), ALLOCATABLE, TARGET :: & 158 alphap(:,:) ! nkbtot, nbnd, 3, nksq) 159 ! 160 ! alphap contains < d\du (\beta_n) | psi_i> 161 ! 162END MODULE phus 163! 164! 165MODULE partial 166 USE kinds, ONLY : DP 167 ! 168 ! ... the variables needed for partial computation of dynamical matrix 169 ! 170 SAVE 171 ! 172 INTEGER, ALLOCATABLE :: & 173 atomo(:) ! (nat) : list of the atoms that moves 174 INTEGER :: nat_todo, & ! number of atoms to compute 175 nat_todo_input ! nat_todo given in input 176 LOGICAL, ALLOCATABLE :: & 177 comp_irr(:), &! (3*nat) : .true. if this irr.rep. has to be computed 178 done_irr(:) ! (3*nat) : .true. if this irr.rep. has been done 179 LOGICAL :: all_comp ! if .TRUE. all representation have been computed 180 ! 181END MODULE partial 182! 183MODULE gamma_gamma 184 INTEGER, ALLOCATABLE :: & 185 has_equivalent(:), & ! 0 if the atom has to be calculated 186 with_symmetry(:), & ! calculated by symmetry 187 n_equiv_atoms(:), & ! number of equivalent atoms 188 equiv_atoms(:,:) ! which atoms are equivalent 189 190 INTEGER :: n_diff_sites, & ! Number of different sites 191 nasr ! atom calculated with asr 192 ! 193 LOGICAL :: asr ! if true apply the asr 194 195END MODULE gamma_gamma 196! 197MODULE control_ph 198 USE kinds, ONLY : DP 199 USE parameters, ONLY: npk 200 ! 201 ! ... the variable controlling the phonon run 202 ! 203 SAVE 204 ! 205 INTEGER, PARAMETER :: maxter = 100 ! maximum number of iterations 206 INTEGER :: niter_ph, & ! maximum number of iterations (read from input) 207 nmix_ph, & ! mixing type 208 start_irr, & ! initial representation 209 last_irr, & ! last representation of this run 210 current_iq, & ! current q point 211 start_q, last_q ! initial q in the list, last_q in the list 212 REAL(DP) :: tr2_ph ! threshold for phonon calculation 213 REAL(DP) :: alpha_mix(maxter) ! the mixing parameter 214 CHARACTER(LEN=10) :: where_rec='no_recover'! where the ph run recovered 215 CHARACTER(LEN=12) :: electron_phonon 216 CHARACTER(LEN=256) :: flmixdpot, tmp_dir_ph, tmp_dir_phq 217 INTEGER :: rec_code=-1000, & ! code for recover 218 rec_code_read=-1000 ! code for recover. Not changed during the run 219 LOGICAL :: lgamma_gamma,&! if .TRUE. this is a q=0 computation with k=0 only 220 convt, &! if .TRUE. the phonon has converged 221 epsil, &! if .TRUE. computes dielec. const and eff. charges 222 done_epsil=.FALSE., &! .TRUE. when diel. constant is available 223 trans, &! if .TRUE. computes phonons 224 zue, &! if .TRUE. computes eff. charges as induced polarization 225 done_zue=.FALSE., &! .TRUE. when the eff. charges are available 226 zeu, &! if .TRUE. computes eff. charges as induced forces 227 done_zeu=.FALSE., &! .TRUE. when the eff. charges are available 228 done_start_zstar=.FALSE., &! 229 only_wfc=.FALSE., &! if .TRUE. computes only bands 230 only_init=.FALSE., &! if .TRUE. computes only initial stuff 231 with_ext_images=.FALSE., & ! if .TRUE. use an external driver 232 ! to decide what each image does. 233 always_run=.FALSE., & ! if .TRUE. the code do not stop after 234 ! doing partial representations 235 !always_run=.TRUE., & ! only for testing purposes 236 recover, &! if .TRUE. the run restarts 237 low_directory_check=.FALSE., & ! if .TRUE. search on the phsave 238 ! directory only the representations requested 239 ! in input. 240 ext_restart, &! if .TRUE. there is a restart file 241 ext_recover, &! if .TRUE. there is a recover file 242 lnoloc, &! if .TRUE. calculates the dielectric constant 243 ! neglecting local field effects 244 search_sym=.TRUE., &! if .TRUE. search the mode symmetry 245 search_sym_save=.TRUE., &! save search symmetry 246 lnscf, &! if .TRUE. the run makes first a nscf calculation 247 ldisp, &! if .TRUE. the run calculates full phonon dispersion 248 reduce_io, &! if .TRUE. reduces needed I/O 249 done_bands, &! if .TRUE. the bands have been calculated 250 bands_computed=.FALSE., & ! if .TRUE. the bands were computed 251 ! in this run 252 nogg, &! if .TRUE. gamma_gamma tricks are disabled 253 u_from_file=.FALSE., & ! if true the u are on file 254 recover_read=.FALSE., & ! if true the recover data have been read 255 ldiag=.FALSE., & ! if true force the diagonalization 256 lqdir=.FALSE., & ! if true each q writes in its directory 257 qplot=.FALSE., & ! if true the q are read from input 258 xmldyn=.FALSE., & ! if true the dynamical matrix is in xml form 259 all_done ! if .TRUE. all representations have been done 260 ! 261 LOGICAL :: newgrid=.FALSE. ! if .TRUE. use new k-point grid nk1,nk2,nk3 262 INTEGER :: nk1,nk2,nk3, k1,k2,k3 ! new Monkhorst-Pack k-point grid 263 ! 264END MODULE control_ph 265! 266! 267MODULE freq_ph 268 ! 269 USE kinds, ONLY : DP 270 ! 271 SAVE 272 ! 273 ! ... the variables for computing frequency dependent dielectric constant 274 ! 275 LOGICAL :: fpol, & ! if .TRUE. dynamic dielectric constant is computed 276 done_fpol ! if .TRUE. all dynamic dielectric constant is computed 277 ! 278 INTEGER :: nfs ! # of frequencies 279 ! 280 INTEGER :: current_iu ! the current frequency 281 ! 282 REAL (KIND=DP), ALLOCATABLE :: fiu(:) ! values of frequency 283 ! 284 REAL (KIND=DP), ALLOCATABLE :: polar(:,:,:) ! values of frequency 285 286 LOGICAL, ALLOCATABLE :: comp_iu(:) ! values of frequency to calculate in this ru 287 ! 288 LOGICAL, ALLOCATABLE :: done_iu(:) ! values of frequency already calculated 289 290 ! 291END MODULE freq_ph 292! 293! 294MODULE units_ph 295 ! 296 ! ... the units of the files and the record lengths 297 ! 298 SAVE 299 ! 300 INTEGER :: & 301 iuvkb, & ! unit with vkb 302 iubar, & ! unit with the part DV_{bare} 303 lrbar, & ! length of the DV_{bare} 304 iuebar, & ! unit with the part DV_{bare} for the electric field 305 lrebar, & ! length of the DV_{bare} fro the electric field 306 iudwf, & ! unit with D psi 307 iupsir, & ! unit with evc in real space 308 lrdwf, & ! length of D psi record 309 iudrhous, lrdrhous, & 310 iudyn, & ! the unit for the dynamical matrix 311 iupdyn, & ! the unit for the partial dynamical matrix 312 iunrec, & ! the unit with the recover data 313 iudvscf, & ! the unit where the delta Vscf is written 314 iudrho, & ! the unit where the delta rho is written 315 lrdrho, & ! the length of the deltarho files 316 iucom, & ! the unit of the bare commutator in US case 317 lrcom, & ! the length of the bare commutator in US case 318 iudvkb3, lrdvkb3, & 319 iuint3paw, & ! the unit of the int3_paw coefficients 320 lint3paw, & ! the length of the int3_paw coefficients 321 iundnsscf, & ! the unit of dnsscf, for DFPT+U 322 iudvpsi, & ! unit of DV_{SCF} * psi 323 lrdvpsi, & ! length of DV_{SCF} * psi 324 iugauge ! Unit for reading and writing gauge information in ahc.f90 325 326 logical, ALLOCATABLE :: this_dvkb3_is_on_file(:), & 327 this_pcxpsi_is_on_file(:,:) 328 ! 329END MODULE units_ph 330! 331! 332MODULE output 333 ! 334 ! ... the name of the files 335 ! 336 SAVE 337 ! 338 CHARACTER (LEN=256) :: fildyn, fildvscf, fildrho 339 ! output file for the dynamical matrix 340 ! output file for deltavscf 341 ! output file for deltarho 342 ! 343END MODULE output 344! 345! 346MODULE disp 347 ! 348 USE kinds, ONLY: DP 349 ! 350 SAVE 351 ! 352 INTEGER :: nq1, nq2, nq3 ! number of q-points in each direction 353 INTEGER :: nqs ! number of q points to be calculated 354 REAL(DP), ALLOCATABLE :: x_q(:,:), & ! coordinates of the q points 355 wq(:) ! for plot 356 357 REAL(DP), ALLOCATABLE :: omega_disp(:,:) 358 359 LOGICAL, ALLOCATABLE :: & 360 lgamma_iq(:), &! if .true. this q is gamma. 361 done_iq(:), &! if .true. this q point has been already calculated 362 comp_iq(:) ! if .true. this q point has to be calculated 363 ! 364END MODULE disp 365 366MODULE grid_irr_iq 367 368 INTEGER, ALLOCATABLE :: & 369 npert_irr_iq(:,:),&! for each q and irr: the number of perturbations 370 irr_iq(:), &! number of irreducible representation per q point 371 nsymq_iq(:) ! dimension of the small group of q for each q 372 373 LOGICAL, ALLOCATABLE :: & 374 comp_irr_iq(:,:), & ! for each q and irr: if .TRUE. this 375 ! representation has to be calculated 376 done_irr_iq(:,:), & ! for each q and irr: if .TRUE. this 377 ! representation has been already calculated 378 done_elph_iq(:,:), & ! for each q and irr: if .TRUE. the elph of this 379 ! representation has been already calculated 380 done_bands(:) ! nqs, if .TRUE. the bands of this q have been 381 ! calculated 382END MODULE grid_irr_iq 383 384MODULE ldaU_ph 385 ! 386 USE kinds, ONLY : DP 387 USE parameters, ONLY : ntypx 388 ! 389 SAVE 390 ! 391 ! atomic wfc's at k 392 COMPLEX(DP), ALLOCATABLE, TARGET :: wfcatomk(:,:), & ! atomic wfc at k 393 swfcatomk(:,:), & ! S * atomic wfc at k 394 dwfcatomk(:,:,:), & ! derivative of atomic wfc at k 395 sdwfcatomk(:,:) ! S * derivative of atomic wfc at k 396 ! atomic wfc's at k+q 397 COMPLEX(DP), POINTER :: wfcatomkpq(:,:), & ! atomic wfc at k+q 398 swfcatomkpq(:,:), & ! S * atomic wfc at k+q 399 dwfcatomkpq(:,:,:), & ! derivative of atomic wfc at k+q 400 sdwfcatomkpq(:,:) ! S * derivative of atomic wfc at k+q 401 ! 402 COMPLEX(DP), ALLOCATABLE, TARGET :: dvkb(:,:,:) ! derivative of beta funtions at k 403 COMPLEX(DP), POINTER :: vkbkpq(:,:), & ! beta funtions at k+q 404 dvkbkpq(:,:,:) ! derivative of beta funtions at k+q 405 ! 406 ! Various arrays for the response occupation matrix 407 COMPLEX(DP), ALLOCATABLE :: dnsbare(:,:,:,:,:,:), & ! bare derivative of ns 408 dnsbare_all_modes(:,:,:,:,:), & ! bare derivative of ns for all modes 409 dnsscf(:,:,:,:,:), & ! SCF derivative of ns 410 dnsscf_all_modes(:,:,:,:,:), & ! SCF derivative of ns for all modes 411 dnsorth(:,:,:,:,:), & ! valence component of dns 412 dnsorth_cart(:,:,:,:,:,:) ! same as above, but in cart. coordinates 413 ! 414 COMPLEX (DP), ALLOCATABLE :: proj1(:,:), & 415 proj2(:,:), & 416 projpb(:,:), & 417 projpdb(:,:,:) 418 ! Arrays to store scalar products between vectors 419 ! projpb = <psi|beta> 420 ! projpdb = <psi|dbeta> 421 ! 422 ! 423 REAL(DP) :: effU(ntypx) 424 ! effective Hubbard parameter: effU = Hubbard_U - Hubbard_J0 425 LOGICAL :: read_dns_bare 426 ! if .true. read the first bare derivative of ns from file 427 CHARACTER(LEN=4) :: d2ns_type 428 ! type of approximation to compute the second bare derivative 429 ! of atomic occupation matrix ns 430 ! 431END MODULE ldaU_ph 432 433MODULE nc_mag_aux 434 USE kinds, ONLY : DP 435 SAVE 436 437 COMPLEX (DP), ALLOCATABLE :: & 438 deeq_nc_save(:,:,:,:,:), & 439 int1_nc_save(:,:,:,:,:,:), & 440 int3_save(:, :, :, :, :, :) 441END MODULE nc_mag_aux 442 443!MODULE qpoint_aux 444! USE kinds, ONLY : DP 445! USE becmod, ONLY : bec_type 446! SAVE 447 448! INTEGER, ALLOCATABLE :: ikmks(:) ! index of -k for magnetic calculations 449 450! INTEGER, ALLOCATABLE :: ikmkmqs(:) ! index of -k-q for magnetic calculations 451 452! TYPE(bec_type), ALLOCATABLE :: becpt(:), alphapt(:,:) 453 454!END MODULE qpoint_aux 455 456MODULE phcom 457 USE dynmat 458 USE eqv 459 USE efield_mod 460 USE nlcc_ph 461 USE phus 462 USE partial 463 USE control_ph 464 USE freq_ph 465 USE units_ph 466 USE output 467 USE gamma_gamma 468 USE disp 469 USE grid_irr_iq 470 USE ldaU_ph 471 USE nc_mag_aux 472! USE qpoint_aux 473END MODULE phcom 474