31#include "./base/base_uses.f90"
37 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'pao_param_exp'
53 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_param_init_exp'
55 INTEGER :: acol, arow, handle, iatom, n
57 REAL(
dp),
DIMENSION(:),
POINTER :: h_evals
58 REAL(
dp),
DIMENSION(:, :),
POINTER :: block_h, block_h0, block_n, block_u0, &
63 CALL timeset(routinen, handle)
69 name=
"PAO matrix_U0", &
71 dist=pao%diag_distribution, &
72 template=matrix_s(1)%matrix)
81 iatom = arow; cpassert(arow == acol)
82 CALL dbcsr_get_block_p(matrix=pao%matrix_H0, row=iatom, col=iatom, block=block_h0, found=found)
83 CALL dbcsr_get_block_p(matrix=pao%matrix_N_diag, row=iatom, col=iatom, block=block_n, found=found)
84 cpassert(
ASSOCIATED(block_h0) .AND.
ASSOCIATED(block_n))
87 ALLOCATE (block_v0(n, n))
91 ALLOCATE (block_h(n, n))
92 block_h = matmul(matmul(block_n, block_h0 + block_v0), block_n)
95 ALLOCATE (h_evecs(n, n), h_evals(n))
102 DEALLOCATE (block_h, h_evecs, h_evals, block_v0)
107 IF (pao%precondition) &
108 cpabort(
"PAO preconditioning not supported for selected parametrization.")
110 CALL timestop(handle)
132 INTEGER,
INTENT(IN) :: ikind
133 INTEGER,
INTENT(OUT) :: nparams
135 INTEGER :: cols, pao_basis_size, pri_basis_size, &
138 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
140 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
142 basis_set=basis_set, &
143 pao_basis_size=pao_basis_size)
144 pri_basis_size = basis_set%nsgf
147 rows = pao_basis_size
148 cols = pri_basis_size - pao_basis_size
175 LOGICAL,
INTENT(IN) :: gradient
177 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_calc_AB_exp'
183 CALL timeset(routinen, handle)
185 CALL dbcsr_create(matrix_u, matrix_type=
"N", dist=pao%diag_distribution, template=matrix_s(1)%matrix)
191 CALL pao_calc_u_exp(pao, matrix_u, matrix_m, pao%matrix_G)
194 CALL pao_calc_u_exp(pao, matrix_u)
199 CALL timestop(handle)
209 SUBROUTINE pao_calc_u_exp(pao, matrix_U, matrix_M, matrix_G)
212 TYPE(
dbcsr_type),
OPTIONAL :: matrix_m, matrix_g
214 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_calc_U_exp'
217 COMPLEX(dp),
DIMENSION(:),
POINTER :: evals
218 COMPLEX(dp),
DIMENSION(:, :),
POINTER :: block_d, evecs
219 INTEGER :: acol, arow, handle, i, iatom, j, k, m, &
221 INTEGER,
DIMENSION(:),
POINTER :: blk_sizes_pao, blk_sizes_pri
223 REAL(
dp),
DIMENSION(:, :),
POINTER :: block_g, block_g_full, block_m, &
224 block_tmp, block_u, block_u0, block_x, &
228 CALL timeset(routinen, handle)
230 CALL dbcsr_get_info(pao%matrix_Y, row_blk_size=blk_sizes_pri, col_blk_size=blk_sizes_pao)
239 iatom = arow; cpassert(arow == acol)
240 CALL dbcsr_get_block_p(matrix=matrix_u, row=iatom, col=iatom, block=block_u, found=found)
241 cpassert(
ASSOCIATED(block_u))
242 CALL dbcsr_get_block_p(matrix=pao%matrix_U0, row=iatom, col=iatom, block=block_u0, found=found)
243 cpassert(
ASSOCIATED(block_u0))
245 n = blk_sizes_pri(iatom)
246 m = blk_sizes_pao(iatom)
247 nparams =
SIZE(block_x, 1)
251 ALLOCATE (block_x_full(n, n))
252 block_x_full(:, :) = 0.0_dp
254 block_x_full(mod(i - 1, m) + 1, m + (i - 1)/m + 1) = +block_x(i, 1)
255 block_x_full(m + (i - 1)/m + 1, mod(i - 1, m) + 1) = -block_x(i, 1)
259 ALLOCATE (evals(n), evecs(n, n))
263 block_u(:, :) = 0.0_dp
267 block_u(i, j) = block_u(i, j) + real(exp(evals(k))*evecs(i, k)*conjg(evecs(j, k)),
dp)
272 block_u = matmul(block_u0, block_u)
275 IF (
PRESENT(matrix_g))
THEN
276 cpassert(
PRESENT(matrix_m))
278 CALL dbcsr_get_block_p(matrix=pao%matrix_G, row=iatom, col=iatom, block=block_g, found=found)
279 cpassert(
ASSOCIATED(block_g))
280 CALL dbcsr_get_block_p(matrix=matrix_m, row=iatom, col=iatom, block=block_m, found=found)
283 ALLOCATE (block_d(n, n), block_tmp(n, n), block_g_full(n, n))
286 denom = evals(i) - evals(j)
288 block_d(i, i) = exp(evals(i))
289 ELSE IF (abs(denom) > 1e-10_dp)
THEN
290 block_d(i, j) = (exp(evals(i)) - exp(evals(j)))/denom
292 block_d(i, j) = 1.0_dp
297 IF (
ASSOCIATED(block_m))
THEN
298 block_tmp = matmul(transpose(block_u0), block_m)
302 block_g_full = fold_derivatives(block_tmp, block_d, evecs)
306 block_g(i, 1) = 2.0_dp*block_g_full(mod(i - 1, m) + 1, m + (i - 1)/m + 1)
309 DEALLOCATE (block_d, block_tmp, block_g_full)
312 DEALLOCATE (block_x_full, evals, evecs)
318 CALL timestop(handle)
319 END SUBROUTINE pao_calc_u_exp
328 FUNCTION fold_derivatives(M, D, R)
RESULT(G)
329 REAL(
dp),
DIMENSION(:, :),
INTENT(IN) :: m
330 COMPLEX(dp),
DIMENSION(:, :),
INTENT(IN) :: d, r
331 REAL(
dp),
DIMENSION(SIZE(M, 1), SIZE(M, 1)) :: g
333 COMPLEX(dp),
DIMENSION(:, :),
POINTER :: f, rf, rm, rmr
335 REAL(
dp),
DIMENSION(:, :),
POINTER :: rfr
339 ALLOCATE (rm(n, n), rmr(n, n), f(n, n), rf(n, n), rfr(n, n))
341 rm = matmul(transpose(conjg(r)), transpose(m))
345 rfr = real(matmul(rf, transpose(conjg(r))),
dp)
348 g = 0.5_dp*(transpose(rfr) - rfr)
350 DEALLOCATE (rm, rmr, f, rf, rfr)
351 END FUNCTION fold_derivatives
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_reserve_diag_blocks(matrix)
Reserves all diagonal blocks.
Types needed for a linear scaling quickstep SCF run based on the density matrix.
Defines the basic variable types.
integer, parameter, public dp
Collection of simple mathematical functions and subroutines.
subroutine, public diag_antisym(matrix, evecs, evals)
Helper routine for diagonalizing anti symmetric matrices.
subroutine, public diamat_all(a, eigval, dac)
Diagonalize the symmetric n by n matrix a using the LAPACK library. Only the upper triangle of matrix...
Original matrix exponential parametrization.
subroutine, public pao_calc_ab_exp(pao, qs_env, ls_scf_env, gradient)
Takes current matrix_X and calculates the matrices A and B.
subroutine, public pao_param_finalize_exp(pao)
Finalize exponential parametrization.
subroutine, public pao_param_initguess_exp(pao)
Fills matrix_X with an initial guess.
subroutine, public pao_param_init_exp(pao, qs_env)
Initialize matrix exponential parametrization.
subroutine, public pao_param_count_exp(qs_env, ikind, nparams)
Returns the number of parameters for given atomic kind.
Common routines for PAO parametrizations.
subroutine, public pao_calc_grad_lnv_wrt_u(qs_env, ls_scf_env, matrix_m_diag)
Helper routine, calculates partial derivative dE/dU.
subroutine, public pao_calc_ab_from_u(pao, qs_env, ls_scf_env, matrix_u_diag)
Takes current matrix_X and calculates the matrices A and B.
Factory routines for potentials used e.g. by pao_param_exp and pao_ml.
subroutine, public pao_guess_initial_potential(qs_env, iatom, block_v)
Makes an educated guess for the initial potential based on positions of neighboring atoms.
Types used by the PAO machinery.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
Provides all information about a quickstep kind.