56 CHARACTER(len=*),
PARAMETER :: routinen =
'fde_run'
58 CHARACTER(len=default_path_length) :: grid_path, input, res_path, rho_path, &
60 INTEGER :: handle, i_a, iounit, iter, max_iter, n_a
62 REAL(kind=
dp) :: drho, e_emb, e_env, e_es_e, e_es_int, &
63 e_es_n, e_kin_na, e_n, e_sub, &
64 e_sub_bare, e_tot, e_xc_na, n_el, &
66 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: z
67 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: r
79 CALL timeset(routinen, handle)
86 NULLIFY (dft_control, fde_control, para_env, pw_env, auxbas_pw_pool,
qs_energy)
87 CALL get_qs_env(qs_env, dft_control=dft_control, para_env=para_env, pw_env=pw_env, &
89 fde_control => dft_control%fde_control
90 cpassert(
ASSOCIATED(fde_control))
92 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
95 v_path =
join_paths(fde_control%workdir, fde_control%pot_file)
96 grid_path =
join_paths(fde_control%workdir, fde_control%grid_file)
97 rho_path =
join_paths(fde_control%workdir, fde_control%rho_file)
98 res_path =
join_paths(fde_control%workdir, fde_control%result_file)
99 input = fde_control%molcas_input_template
105 CALL auxbas_pw_pool%create_pw(rho)
107 CALL auxbas_pw_pool%create_pw(rho_new)
110 IF (fde_control%freeze_and_thaw) max_iter = fde_control%max_ft_iter
113 WRITE (iounit,
'(/,T2,A)') repeat(
"=", 78)
114 WRITE (iounit,
'(T2,A)')
"FDE: Frozen-density embedding"
115 WRITE (iounit,
'(T2,A)') repeat(
"=", 78)
119 DO iter = 1, max_iter
121 CALL fde_write_pw(v_emb, trim(v_path), write_value=.true.)
122 CALL fde_write_pw(v_emb, trim(grid_path), write_value=.false.)
124 CALL fde_spawn(fde_control, trim(input), para_env)
127 CALL fde_read_results(trim(res_path), para_env, e_sub, e_emb, e_n, n_el, n_a, z, r)
130 IF (n_el_pw > 1.0e-10_dp .AND. n_el > 0.0_dp)
THEN
131 CALL pw_scale(rho_new, n_el/n_el_pw)
134 drho = fde_drho(rho, rho_new, para_env)
143 e_es_n = e_es_n - z(i_a)*phi_at_atom
145 e_es_int = e_es_e + e_es_n
146 CALL auxbas_pw_pool%give_back_pw(phi_es)
149 e_sub_bare = e_sub - e_emb
150 e_tot = e_sub_bare + e_env + e_es_int + e_xc_na + e_kin_na
153 WRITE (iounit,
'(/,T2,A,I0)')
"FDE freeze-and-thaw iteration ", iter
154 WRITE (iounit,
'(T4,A,F20.10)')
"E(sub, embedded) = ", e_sub
155 WRITE (iounit,
'(T4,A,F20.10)')
"E(emb) = ", e_emb
156 WRITE (iounit,
'(T4,A,F20.10)')
"E(sub) = ", e_sub_bare
157 WRITE (iounit,
'(T4,A,F20.10)')
"E(env) = ", e_env
158 WRITE (iounit,
'(T4,A,F20.10)')
"E(es) = ", e_es_int
159 WRITE (iounit,
'(T6,A,F20.10)')
"E(elec) = ", e_es_e
160 WRITE (iounit,
'(T6,A,F20.10)')
"E(nuc) = ", e_es_n
161 WRITE (iounit,
'(T4,A,F20.10)')
"E(XC, nonadditive) = ", e_xc_na
162 WRITE (iounit,
'(T4,A,F20.10)')
"E(kin, nonadditive) = ", e_kin_na
163 WRITE (iounit,
'(T4,A,F20.10)')
"E(FDE) = ", e_tot
164 WRITE (iounit,
'(T4,A,F14.6,A,F14.6)')
"N(sub, e): grid = ", n_el_pw, &
166 WRITE (iounit,
'(T4,A,ES14.6)')
"int|rho(sub, new) - rho(sub, old)|dr = ", drho
169 CALL auxbas_pw_pool%give_back_pw(v_emb)
171 IF (fde_control%freeze_and_thaw)
THEN
172 IF (drho < fde_control%eps_ft_density)
THEN
175 CALL pw_scale(rho, 1.0_dp - fde_control%density_mixing)
176 CALL pw_axpy(rho_new, rho, fde_control%density_mixing)
187 WRITE (iounit,
'(/,T2,A)') repeat(
"=", 78)
188 IF (fde_control%freeze_and_thaw .AND. .NOT. converged)
THEN
189 WRITE (iounit,
'(T2,A)')
"FDE WARNING: freeze-and-thaw did not converge"
191 WRITE (iounit,
'(T2,A,F20.10)')
"FDE final total energy = ", e_tot
192 WRITE (iounit,
'(T2,A)') repeat(
"=", 78)
197 CALL auxbas_pw_pool%give_back_pw(rho)
198 CALL auxbas_pw_pool%give_back_pw(rho_new)
200 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, mimic, 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, sab_cneo, 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, matrix_vhxc, 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, xcint_weights, 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, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_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, do_rixs, tb_tblite)
Get the QUICKSTEP environment.