LCOV - code coverage report
Current view: top level - src/nonlinear_optics - nlo_types.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:123285f) Lines: 85.7 % 7 6
Test Date: 2026-11-04 00:58:17 Functions: 25.0 % 4 1

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : !> \brief Nonlinear optical environment: input parameters and data shared by calculation stages.
       9              : ! **************************************************************************************************
      10              : MODULE nlo_types
      11              :    USE cell_types,                      ONLY: cell_type
      12              :    USE kinds,                           ONLY: dp
      13              :    USE kpoint_types,                    ONLY: kpoint_release,&
      14              :                                               kpoint_type
      15              :    USE message_passing,                 ONLY: mp_para_env_type
      16              :    USE qs_mo_types,                     ONLY: mo_set_type
      17              : #include "../base/base_uses.f90"
      18              : 
      19              :    IMPLICIT NONE
      20              : 
      21              :    PRIVATE
      22              : 
      23              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'nlo_types'
      24              : 
      25              :    PUBLIC                                            :: release_nlo_environment
      26              :    ! A frequency is either a regular energy grid or a signed link to an earlier field.
      27              :    TYPE, PUBLIC                                      :: nlo_frequency_type
      28              :       REAL(KIND=dp)                                  :: start_ev = 0.0_dp, &
      29              :                                                         step_ev = 0.0_dp
      30              :       INTEGER                                        :: n_values = 0, &
      31              :                                                         reference = 0, &
      32              :                                                         sign = 1
      33              :    END TYPE nlo_frequency_type
      34              : 
      35              :    ! One instance, nlo_env, owns the input and the data shared by the five main stages.
      36              :    TYPE, PUBLIC                                      :: nlo_type
      37              :       INTEGER                                        :: order = 0, &
      38              :                                                         k_mesh(3) = 0
      39              :       LOGICAL, ALLOCATABLE                           :: elements(:, :)
      40              :       REAL(KIND=dp)                                  :: t1_au = 0.0_dp
      41              :       REAL(KIND=dp)                                  :: t2_au = 0.0_dp
      42              :       REAL(KIND=dp)                                  :: transition_width_au = 0.0_dp
      43              :       TYPE(nlo_frequency_type)                       :: frequency(5)
      44              :       ! Number of independent tuples formed from FREQ_1,...,FREQ_ORDER.
      45              :       INTEGER                                        :: n_frequency_combinations = 0
      46              :       ! Data shared by preparation, Brillouin-zone integration and output.
      47              :       INTEGER                                        :: n_bands = 0, &
      48              :                                                         n_ao = 0, &
      49              :                                                         n_images = 0, &
      50              :                                                         n_kpoints = 0, &
      51              :                                                         n_spin = 0
      52              : 
      53              :       REAL(KIND=dp)                                  :: min_direct_gap = 0.0_dp, &
      54              :                                                         projection_error = 0.0_dp
      55              :       ! AO matrices at lattice image R: H, S, and dipole d.
      56              :       ! Indices: (spin or Cartesian component, AO row, AO column, R).
      57              :       REAL(KIND=dp), ALLOCATABLE                     :: h_ao_R(:, :, :, :), &
      58              :                                                         s_ao_R(:, :, :, :), &
      59              :                                                         d_ao_R(:, :, :, :)
      60              : 
      61              :       ! Integrated current: (output direction, input-direction code, frequency combination).
      62              :       COMPLEX(dp), ALLOCATABLE                       :: current_spectrum(:, :, :)
      63              : 
      64              :       ! Temporary matrices for one k point, allocated once for the integration stage.
      65              :       COMPLEX(dp), ALLOCATABLE                       :: band_connection_derivatives(:, :, :, :), &
      66              :                                                         band_hamiltonian_derivatives(:, :, :), &
      67              :                                                         current_flat(:, :), &
      68              :                                                         position_derivatives(:, :, :, :), &
      69              :                                                         hamiltonian_derivatives(:, :, :), &
      70              :                                                         rho0_derivatives(:, :, :), &
      71              :                                                         overlap_derivatives(:, :, :), &
      72              :                                                         velocity(:, :, :)
      73              :       INTEGER, ALLOCATABLE                           :: occupied(:)
      74              :       REAL(KIND=dp), ALLOCATABLE                     :: energies(:)
      75              : 
      76              :       ! Number of spin/k-point tasks assigned to the reporting rank.
      77              :       INTEGER                                        :: progress_done = 0, &
      78              :                                                         progress_next = 1, &
      79              :                                                         progress_total = 0
      80              :       REAL(KIND=dp)                                  :: progress_start = 0.0_dp
      81              : 
      82              :       TYPE(cell_type), POINTER                       :: cell => NULL()
      83              :       TYPE(kpoint_type), POINTER                     :: images => NULL()
      84              :       TYPE(mo_set_type), POINTER                     :: mos(:) => NULL()
      85              :       TYPE(mp_para_env_type), POINTER                :: para_env => NULL()
      86              :    END TYPE nlo_type
      87              : 
      88              : CONTAINS
      89              : 
      90              : ! **************************************************************************************************
      91              : !> \brief Release NLO-owned matrices and the auxiliary k-point environment, if created.
      92              : !> \param nlo_env NLO settings and owned arrays to release
      93              : ! **************************************************************************************************
      94           22 :    SUBROUTINE release_nlo_environment(nlo_env)
      95              :       TYPE(nlo_type), INTENT(INOUT)                      :: nlo_env
      96              : 
      97           22 :       CALL kpoint_release(nlo_env%images)
      98           22 :       NULLIFY (nlo_env%cell, nlo_env%mos, nlo_env%para_env)
      99           22 :       DEALLOCATE (nlo_env%h_ao_R, nlo_env%s_ao_R, nlo_env%d_ao_R, nlo_env%current_spectrum)
     100           22 :       IF (ALLOCATED(nlo_env%elements)) DEALLOCATE (nlo_env%elements)
     101              : 
     102           22 :    END SUBROUTINE release_nlo_environment
     103              : 
     104            0 : END MODULE nlo_types
        

Generated by: LCOV version 2.0-1