58#include "./base/base_uses.f90"
64 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'stm_images'
88 SUBROUTINE th_stm_image(qs_env, stm_section, particles, unoccupied_orbs, &
95 POINTER :: unoccupied_orbs
98 CHARACTER(len=*),
PARAMETER :: routinen =
'th_stm_image'
100 INTEGER :: handle, irep, ispin, n_rep, ndim, nmo, &
102 INTEGER,
DIMENSION(:),
POINTER :: nadd_unocc, stm_th_torb
103 LOGICAL :: append_cube, use_ref_energy
104 REAL(kind=
dp) :: efermi, ref_energy
105 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues, mo_occ, stm_biases
106 TYPE(
cp_1d_r_p_type),
ALLOCATABLE,
DIMENSION(:) :: evals, occupation
108 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: mo_arrays
122 CALL timeset(routinen, handle)
126 NULLIFY (ks_env, mos, rho, rho_ao, pw_env, stm_th_torb, fm_struct_tmp)
127 NULLIFY (auxbas_pw_pool, pw_pools, stm_density_ao, mo_coeff)
142 ALLOCATE (stm_th_torb(1))
145 ALLOCATE (stm_th_torb(n_rep))
148 i_rep_val=irep, i_val=stm_th_torb(irep))
152 ALLOCATE (stm_density_ao)
153 CALL dbcsr_copy(stm_density_ao, rho_ao(1)%matrix, &
154 name=
"stm_density_ao")
156 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
158 CALL auxbas_pw_pool%create_pw(wf_r)
159 CALL auxbas_pw_pool%create_pw(wf_g)
162 ALLOCATE (nadd_unocc(nspin))
164 IF (
ASSOCIATED(unoccupied_orbs))
THEN
166 nadd_unocc(ispin) =
SIZE(unoccupied_evals(ispin)%array)
170 ALLOCATE (mo_arrays(nspin))
171 ALLOCATE (evals(nspin))
172 ALLOCATE (occupation(nspin))
174 IF (nadd_unocc(ispin) == 0)
THEN
175 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
176 eigenvalues=mo_eigenvalues, nmo=nmo, mu=efermi, occupation_numbers=mo_occ)
177 mo_arrays(ispin) = mo_coeff
178 evals(ispin)%array => mo_eigenvalues
179 occupation(ispin)%array => mo_occ
181 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
182 eigenvalues=mo_eigenvalues, nmo=nmo, mu=efermi, occupation_numbers=mo_occ)
183 ndim = nmo + nadd_unocc(ispin)
184 ALLOCATE (evals(ispin)%array(ndim))
185 evals(ispin)%array(1:nmo) = mo_eigenvalues(1:nmo)
186 evals(ispin)%array(1 + nmo:ndim) = unoccupied_evals(ispin)%array(1:nadd_unocc(ispin))
187 ALLOCATE (occupation(ispin)%array(ndim))
188 occupation(ispin)%array(1:nmo) = mo_occ(1:nmo)
189 occupation(ispin)%array(1 + nmo:ndim) = 0.0_dp
191 template_fmstruct=mo_coeff%matrix_struct)
192 CALL cp_fm_create(mo_arrays(ispin), fm_struct_tmp, name=
"mo_arrays")
194 CALL cp_fm_to_fm(mo_coeff, mo_arrays(ispin), nmo, 1, 1)
195 CALL cp_fm_to_fm(unoccupied_orbs(ispin), mo_arrays(ispin), &
196 nadd_unocc(ispin), 1, nmo + 1)
199 IF (use_ref_energy) efermi = ref_energy
201 CALL stm_cubes(ks_env, stm_section, stm_density_ao, wf_r, wf_g, mo_arrays, evals, &
202 occupation, efermi, stm_biases, stm_th_torb, particles, &
203 output_unit, append_cube)
205 IF (nadd_unocc(ispin) > 0)
THEN
206 DEALLOCATE (evals(ispin)%array)
207 DEALLOCATE (occupation(ispin)%array)
211 DEALLOCATE (mo_arrays)
213 DEALLOCATE (occupation)
216 CALL auxbas_pw_pool%give_back_pw(wf_r)
217 CALL auxbas_pw_pool%give_back_pw(wf_g)
219 DEALLOCATE (stm_th_torb)
220 DEALLOCATE (nadd_unocc)
222 CALL timestop(handle)
250 SUBROUTINE stm_cubes(ks_env, stm_section, stm_density_ao, wf_r, wf_g, mo_arrays, evals, &
251 occupation, efermi, stm_biases, stm_th_torb, particles, &
252 output_unit, append_cube)
259 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(IN) :: mo_arrays
260 TYPE(
cp_1d_r_p_type),
DIMENSION(:),
INTENT(IN) :: evals, occupation
261 REAL(kind=
dp) :: efermi
262 REAL(kind=
dp),
DIMENSION(:),
POINTER :: stm_biases
263 INTEGER,
DIMENSION(:),
POINTER :: stm_th_torb
265 INTEGER,
INTENT(IN) :: output_unit
266 LOGICAL,
INTENT(IN) :: append_cube
268 CHARACTER(LEN=*),
DIMENSION(0:9),
PARAMETER :: &
269 torb_string = (/
" s",
" px",
" py",
" pz",
"dxy",
"dyz",
"dzx",
"dx2",
"dy2",
"dz2"/)
270 CHARACTER(len=*),
PARAMETER :: routinen =
'stm_cubes'
272 CHARACTER(LEN=default_path_length) :: filename
273 CHARACTER(LEN=default_string_length) :: my_pos, oname, title
274 INTEGER :: handle, i, ibias, imo, iorb, ispin, &
275 istates, nmo, nspin, nstates(2), &
276 state_start(2), unit_nr
278 REAL(kind=
dp) :: alpha
279 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: occ_tot
284 CALL timeset(routinen, handle)
287 NULLIFY (fm_struct_tmp)
289 nspin =
SIZE(mo_arrays)
291 IF (output_unit > 0)
WRITE (output_unit,
'(T2,A)')
""
292 IF (output_unit > 0)
WRITE (output_unit,
'(T2,A,F12.6, A)')
"STM : Reference energy ", efermi,
" a.u. "
293 DO ibias = 1,
SIZE(stm_biases)
295 IF (output_unit > 0)
WRITE (output_unit,
'(T2,A)')
""
296 IF (output_unit > 0)
WRITE (output_unit,
'(T2,A,F16.6)') &
297 "Preparing for STM image at bias [a.u.] ", stm_biases(ibias)
303 IF (stm_biases(ibias) < 0.0_dp)
THEN
304 nmo =
SIZE(evals(ispin)%array)
306 IF (evals(ispin)%array(imo) > (efermi + stm_biases(ibias)) .AND. &
307 evals(ispin)%array(imo) <= efermi)
THEN
308 IF (nstates(ispin) == 0) state_start(ispin) = imo
309 nstates(ispin) = nstates(ispin) + 1
312 IF ((output_unit > 0) .AND. evals(ispin)%array(1) > efermi + stm_biases(ibias)) &
313 WRITE (output_unit,
'(T4,A)')
"Warning: EFermi+bias below lowest computed occupied MO"
315 nmo =
SIZE(evals(ispin)%array)
317 IF (evals(ispin)%array(imo) <= (efermi + stm_biases(ibias)) .AND. &
318 evals(ispin)%array(imo) > efermi)
THEN
319 IF (nstates(ispin) == 0) state_start(ispin) = imo
320 nstates(ispin) = nstates(ispin) + 1
323 IF ((output_unit > 0) .AND. evals(ispin)%array(nmo) < efermi + stm_biases(ibias)) &
324 WRITE (output_unit,
'(T4,A)')
"Warning: E-Fermi+bias above highest computed unoccupied MO"
326 istates = istates + nstates(ispin)
328 IF ((output_unit > 0))
WRITE (output_unit,
'(T4,A,I0,A)')
"Using a total of ", istates,
" states"
329 IF (istates == 0) cycle
332 template_fmstruct=mo_arrays(1)%matrix_struct)
333 CALL cp_fm_create(matrix_v, fm_struct_tmp, name=
"matrix_v")
334 CALL cp_fm_create(matrix_vf, fm_struct_tmp, name=
"matrix_vf")
337 ALLOCATE (occ_tot(istates))
342 IF (nspin == 1) alpha = 2.0_dp
344 CALL cp_fm_to_fm(mo_arrays(ispin), matrix_v, nstates(ispin), state_start(ispin), istates + 1)
345 CALL cp_fm_to_fm(mo_arrays(ispin), matrix_vf, nstates(ispin), state_start(ispin), istates + 1)
346 IF (stm_biases(ibias) < 0.0_dp)
THEN
347 occ_tot(istates + 1:istates + nstates(ispin)) = &
348 occupation(ispin)%array(state_start(ispin):state_start(ispin) - 1 + nstates(ispin))
350 occ_tot(istates + 1:istates + nstates(ispin)) = &
351 alpha - occupation(ispin)%array(state_start(ispin):state_start(ispin) - 1 + nstates(ispin))
353 istates = istates + nstates(ispin)
363 DO i = 1,
SIZE(stm_th_torb)
364 iorb = stm_th_torb(i)
366 rho=wf_r, rho_gspace=wf_g, &
367 ks_env=ks_env, der_type=iorb)
369 oname = torb_string(iorb)
371 WRITE (filename,
'(a4,I2.2,a1,I5.5)')
"STM_d", iorb,
"_", ibias
373 IF (append_cube)
THEN
379 middle_name=trim(filename), file_position=my_pos, file_action=
"WRITE", &
380 log_filename=.false., mpi_io=mpi_io)
381 WRITE (title,
'(A,I0,A,I0,A,F16.8)')
"STM cube ", ibias,
" wfn deriv. ", iorb,
" at bias ", stm_biases(ibias)
382 CALL cp_pw_to_cube(wf_r, unit_nr, title, particles=particles, &
395 CALL timestop(handle)
397 END SUBROUTINE stm_cubes
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_set(matrix, alpha)
...
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_plus_fm_fm_t(sparse_matrix, matrix_v, matrix_g, ncol, alpha, keep_sparsity, symmetry_mode)
performs the multiplication sparse_matrix+dense_mat*dens_mat^T if matrix_g is not explicitly given,...
basic linear algebra operations for full matrices
subroutine, public cp_fm_column_scale(matrixa, scaling)
scales column i of matrix a with scaling(i)
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
A wrapper around pw_to_cube() which accepts particle_list_type.
subroutine, public cp_pw_to_cube(pw, unit_nr, title, particles, stride, zero_tails, silent, mpi_io)
...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
represent a simple array based list of the given type
container for various plainwaves related things
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Calculate the plane wave density by collocating the primitive Gaussian functions (pgf).
subroutine, public calculate_rho_elec(matrix_p, matrix_p_kp, rho, rho_gspace, total_rho, ks_env, soft_valid, compute_tau, compute_grad, basis_type, der_type, idir, task_list_external, pw_env_external)
computes the density corresponding to a given density matrix on the grid
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.
Definition and initialisation of the mo data type.
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count)
Get the components of a MO set data structure.
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
Calculation of STM image as post processing of an electronic structure calculation,...
subroutine, public th_stm_image(qs_env, stm_section, particles, unoccupied_orbs, unoccupied_evals)
Driver for the calculation of STM image, as post processing of a ground-state electronic structure ca...
represent a pointer to a 1d array
keeps the information about the structure of a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
represent a list of objects
contained for different pw related things
to create arrays of pools
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps the density in various representations, keeping track of which ones are valid.