60 CHARACTER(len=*),
PARAMETER :: routinen =
'external_read_density'
62 CHARACTER(LEN=default_string_length) :: filename
63 INTEGER :: extunit, handle, i, igrid_level, j, k, &
65 INTEGER,
DIMENSION(3) :: lbounds, lbounds_local, npoints, &
66 npoints_local, ubounds, ubounds_local
67 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: buffer
68 REAL(kind=
dp),
DIMENSION(3) :: dr, rdum
69 REAL(kind=
dp),
DIMENSION(:),
POINTER :: tot_rho_r_ext
80 DIMENSION(:) :: rs_rho_ext
83 CALL timeset(routinen, handle)
84 NULLIFY (cell, input, ext_den_section, rs_descs, dft_control)
85 NULLIFY (rho_ext_r, rho_ext_g, tot_rho_r_ext)
89 rho_external=rho_external, &
92 dft_control=dft_control)
94 IF (dft_control%apply_external_density)
THEN
98 tot_rho_r=tot_rho_r_ext)
100 gridlevel_info => pw_env%gridlevel_info
104 ALLOCATE (rs_rho_ext(gridlevel_info%ngrid_levels))
106 DO igrid_level = 1, gridlevel_info%ngrid_levels
108 rs_descs(igrid_level)%rs_desc)
112 igrid_level = igrid_level - 1
118 associate(gid => rho_ext_r(1)%pw_grid%para%group, my_rank => rho_ext_r(1)%pw_grid%para%group%mepos, &
119 num_pe => rho_ext_r(1)%pw_grid%para%group%num_pe)
121 IF (dft_control%read_external_density)
THEN
124 dr(i) = rs_descs(igrid_level)%rs_desc%dh(i, i)
126 npoints = rs_descs(igrid_level)%rs_desc%npts
127 lbounds = rs_descs(igrid_level)%rs_desc%lb
128 ubounds = rs_descs(igrid_level)%rs_desc%ub
130 npoints_local = rho_ext_r(1)%pw_grid%npts_local
131 lbounds_local = rho_ext_r(1)%pw_grid%bounds_local(1, :)
132 ubounds_local = rho_ext_r(1)%pw_grid%bounds_local(2, :)
134 ALLOCATE (buffer(lbounds_local(3):ubounds_local(3)))
136 IF (my_rank == 0)
THEN
137 WRITE (*, fmt=
"(/,/,T2,A)")
"INITIALIZING ZMP CONSTRAINED DENSITY METHOD"
138 WRITE (*, fmt=
"(/,(T3,A,T51,A30))")
"ZMP| Reading the target density: ", filename
142 file_form=
"FORMATTED", &
143 file_action=
"READ", &
149 READ (extunit, *) nat, rdum
151 READ (extunit, *) ndum, rdum
152 IF (ndum /= npoints(i) .OR. (abs(rdum(i) - dr(i)) > 1e-4))
THEN
153 WRITE (*, *)
"ZMP | ERROR! | CUBE FILE NOT COINCIDENT WITH INTERNAL GRID ", i
154 WRITE (*, *)
"ZMP | ", ndum,
" DIFFERS FROM ", npoints(i)
155 WRITE (*, *)
"ZMP | ", rdum,
" DIFFERS FROM ", dr(i)
163 DO i = lbounds(1), ubounds(1)
164 DO j = lbounds(2), ubounds(2)
165 IF (my_rank .EQ. 0)
THEN
166 READ (extunit, *) (buffer(k), k=lbounds(3), ubounds(3))
168 CALL gid%bcast(buffer(lbounds(3):ubounds(3)), 0)
170 IF ((lbounds_local(1) .LE. i) .AND. (i .LE. ubounds_local(1)) .AND. (lbounds_local(2) .LE. j) &
171 .AND. (j .LE. ubounds_local(2)))
THEN
172 rs_rho_ext(igrid_level)%r(i, j, lbounds(3):ubounds(3)) = buffer(lbounds(3):ubounds(3))
177 IF (my_rank == 0)
CALL close_file(unit_number=extunit)
180 CALL density_rs2pw(pw_env, rs_rho_ext, rho=rho_ext_r(1), rho_gspace=rho_ext_g(1))
181 DO igrid_level = 1,
SIZE(rs_rho_ext)
185 IF (my_rank == 0)
THEN
186 WRITE (*, fmt=
"(T3,A,T61,F20.10)")
"ZMP| Total external charge: ", &
189 DEALLOCATE (buffer, rs_rho_ext)
194 CALL timestop(handle)
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.