133 SUBROUTINE sccs(qs_env, rho_tot_gspace, v_hartree_gspace, v_sccs, h_stress)
136 TYPE(
pw_c1d_gs_type),
INTENT(INOUT) :: rho_tot_gspace, v_hartree_gspace
138 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(OUT), &
141 CHARACTER(LEN=*),
PARAMETER :: routinen =
'sccs'
142 REAL(kind=
dp),
PARAMETER :: epstol = 1.0e-8_dp
144 CHARACTER(LEN=4*default_string_length) :: message, my_pos_cube
145 CHARACTER(LEN=default_path_length) :: cube_path, filename, mpi_filename, &
147 INTEGER :: cube_unit, handle, i, ispin, iter, j, k, &
148 nspin, output_unit, print_level
149 INTEGER(KIND=int_8) :: ngpts
150 INTEGER,
DIMENSION(3) :: lb, ub
151 LOGICAL :: append_cube, calculate_stress_tensor, &
152 do_kpoints, mpi_io, should_output
153 REAL(kind=
dp) :: alpha_zeta, cavity_surface, cavity_volume, cell_volume, delta_eta, &
154 delta_zeta, dphi2, dvol, e_tot, epsilon_solvent, f, f0, polarisation_charge, r, r_solv, &
155 rho_delta, rho_delta_avg, rho_delta_max, rho_iter_new, tot_rho_elec, tot_rho_solute
156 REAL(kind=
dp),
DIMENSION(3) :: abc, lxyz, uxyz
166 TYPE(
pw_r3d_rs_type) :: d_s_rhoel, deps_elec, dtf, eps_elec, ff, &
167 p_e_interface, s, t, tem_convolution, &
178 CALL timeset(routinen, handle)
180 NULLIFY (auxbas_pw_pool)
182 NULLIFY (dft_control)
188 NULLIFY (poisson_env)
192 NULLIFY (sccs_control)
197 cp_subsys=cp_subsys, &
198 do_kpoints=do_kpoints, &
199 dft_control=dft_control, &
208 sccs_control => dft_control%sccs_control
210 cpassert(
ASSOCIATED(qs_env))
213 cpwarn(
"SCCS with k-points has not yet been fully validated")
216 IF (
PRESENT(h_stress))
THEN
217 calculate_stress_tensor = .true.
218 h_stress(:, :) = 0.0_dp
219 cpwarn(
"The stress tensor for SCCS has not yet been fully validated")
221 calculate_stress_tensor = .false.
226 auxbas_pw_pool=auxbas_pw_pool, &
228 poisson_env=poisson_env)
233 IF (.NOT. sccs_control%sccs_activated)
THEN
234 IF (sccs_control%eps_scf > 0.0_dp)
THEN
235 IF ((scf_env%iter_delta > sccs_control%eps_scf) .OR. &
236 ((qs_env%scf_env%outer_scf%iter_count == 0) .AND. &
237 (qs_env%scf_env%iter_count <= 1)))
THEN
238 IF (calculate_stress_tensor)
THEN
241 density=rho_tot_gspace, &
242 ehartree=energy%hartree, &
243 vhartree=v_hartree_gspace, &
247 density=rho_tot_gspace, &
248 ehartree=energy%hartree, &
249 vhartree=v_hartree_gspace)
251 energy%sccs_pol = 0.0_dp
252 energy%sccs_cav = 0.0_dp
253 energy%sccs_dis = 0.0_dp
254 energy%sccs_rep = 0.0_dp
255 energy%sccs_sol = 0.0_dp
256 energy%sccs_hartree = energy%hartree
257 CALL timestop(handle)
261 sccs_control%sccs_activated = .true.
264 nspin = dft_control%nspins
268 print_level = logger%iter_info%print_level
269 print_path =
"DFT%PRINT%SCCS"
274 ignore_should_output=should_output, &
275 log_filename=.false.)
280 rho_r_sccs=rho_pw_r_sccs)
283 cpassert(
ASSOCIATED(rho_pw_r_sccs))
288 CALL auxbas_pw_pool%create_pw(rho_elec)
291 ngpts = rho_elec%pw_grid%ngpts
292 dvol = rho_elec%pw_grid%dvol
293 cell_volume = rho_elec%pw_grid%vol
294 abc(1:3) = real(rho_elec%pw_grid%npts(1:3), kind=
dp)*rho_elec%pw_grid%dr(1:3)
295 lb(1:3) = rho_elec%pw_grid%bounds_local(1, 1:3)
296 ub(1:3) = rho_elec%pw_grid%bounds_local(2, 1:3)
298 CALL pw_copy(rho_pw_r(1), rho_elec)
300 CALL pw_axpy(rho_pw_r(ispin), rho_elec)
308 IF (sccs_control%core_fill)
THEN
310 REAL(kind=
dp) :: tot_rho_fill
311 REAL(kind=
dp),
DIMENSION(:),
ALLOCATABLE :: calpha, ccore
314 CALL auxbas_pw_pool%create_pw(rho_fill)
317 CALL pw_axpy(rho_fill, rho_elec, alpha=-1.0_dp)
318 CALL auxbas_pw_pool%give_back_pw(rho_fill)
319 DEALLOCATE (calpha, ccore)
324 CALL auxbas_pw_pool%create_pw(eps_elec)
325 CALL auxbas_pw_pool%create_pw(deps_elec)
327 CALL auxbas_pw_pool%create_pw(s)
328 CALL auxbas_pw_pool%create_pw(d_s_rhoel)
329 CALL auxbas_pw_pool%create_pw(u)
330 CALL auxbas_pw_pool%create_pw(ff)
331 CALL auxbas_pw_pool%create_pw(t)
332 CALL auxbas_pw_pool%create_pw(dtf)
334 delta_eta = sccs_control%delta_eta
335 alpha_zeta = sccs_control%alpha_zeta
336 r_solv = sccs_control%R_solv
337 delta_zeta = sccs_control%delta_zeta
341 epsilon_solvent = sccs_control%epsilon_solvent
342 SELECT CASE (sccs_control%method_id)
344 CALL andreussi(rho_elec, eps_elec, deps_elec, epsilon_solvent, sccs_control%rho_max, &
345 sccs_control%rho_min)
347 CALL fattebert_gygi(rho_elec, eps_elec, deps_elec, epsilon_solvent, sccs_control%beta, &
348 sccs_control%rho_zero)
350 CALL sa_andreussi(rho_elec, eps_elec, deps_elec, epsilon_solvent, sccs_control%rho_max, &
351 sccs_control%rho_min, s, d_s_rhoel)
353 cpabort(
"Invalid method specified for SCCS model")
358 filename =
"DIELECTRIC_FUNCTION"
359 cube_path = trim(print_path)//
"%"//trim(filename)
363 my_pos_cube =
"REWIND"
364 IF (append_cube) my_pos_cube =
"APPEND"
367 extension=
".cube", middle_name=trim(filename), &
368 file_position=my_pos_cube, log_filename=.false., &
369 mpi_io=mpi_io, fout=mpi_filename)
370 IF (output_unit > 0)
THEN
371 IF (.NOT. mpi_io)
THEN
372 INQUIRE (unit=cube_unit, name=filename)
374 filename = mpi_filename
376 WRITE (unit=output_unit, fmt=
"(T3,A)") &
377 "SCCS| The dielectric function is written in cube file format to the file:", &
378 "SCCS| "//trim(filename)
380 CALL cp_pw_to_cube(eps_elec, cube_unit, trim(filename), particles=particles, &
388 cavity_surface = 0.0_dp
389 cavity_volume = 0.0_dp
391 IF (abs(epsilon_solvent - 1.0_dp) > epstol)
THEN
396 CALL auxbas_pw_pool%create_pw(theta)
400 f = 1.0_dp/(epsilon_solvent - 1.0_dp)
407 theta%array(i, j, k) = f*(epsilon_solvent - eps_elec%array(i, j, k))
417 CALL auxbas_pw_pool%create_pw(drho_elec(i))
421 CALL auxbas_pw_pool%create_pw(norm_drho_elec)
430 norm_drho_elec%array(i, j, k) = sqrt(drho_elec(1)%array(i, j, k)* &
431 drho_elec(1)%array(i, j, k) + &
432 drho_elec(2)%array(i, j, k)* &
433 drho_elec(2)%array(i, j, k) + &
434 drho_elec(3)%array(i, j, k)* &
435 drho_elec(3)%array(i, j, k))
442 filename =
"DENSITY_GRADIENT"
443 cube_path = trim(print_path)//
"%"//trim(filename)
447 my_pos_cube =
"REWIND"
448 IF (append_cube) my_pos_cube =
"APPEND"
451 extension=
".cube", middle_name=trim(filename), &
452 file_position=my_pos_cube, log_filename=.false., &
453 mpi_io=mpi_io, fout=mpi_filename)
454 IF (output_unit > 0)
THEN
455 IF (.NOT. mpi_io)
THEN
456 INQUIRE (unit=cube_unit, name=filename)
458 filename = mpi_filename
460 WRITE (unit=output_unit, fmt=
"(T3,A)") &
461 "SCCS| The norm of the density gradient is written in cube file format to the file:", &
462 "SCCS| "//trim(filename)
464 CALL cp_pw_to_cube(norm_drho_elec, cube_unit, trim(filename), particles=particles, &
471 SELECT CASE (sccs_control%method_id)
473 CALL surface_andreussi(rho_elec, norm_drho_elec, theta, epsilon_solvent, &
474 sccs_control%rho_max, sccs_control%rho_min, &
475 sccs_control%delta_rho)
477 CALL surface_fattebert_gygi(rho_elec, norm_drho_elec, theta, epsilon_solvent, &
478 sccs_control%beta, sccs_control%rho_zero, &
479 sccs_control%delta_rho)
482 cpabort(
"Invalid method specified for SCCS model")
487 CALL auxbas_pw_pool%give_back_pw(theta)
488 CALL auxbas_pw_pool%give_back_pw(norm_drho_elec)
490 CALL auxbas_pw_pool%give_back_pw(drho_elec(i))
496 CALL auxbas_pw_pool%give_back_pw(rho_elec)
500 TYPE(pw_r3d_rs_type) :: rho_tot, phi_tot, rho_solute, rho_tot_zero
502 CALL auxbas_pw_pool%create_pw(rho_solute)
503 CALL pw_zero(rho_solute)
504 CALL pw_transfer(rho_tot_gspace, rho_solute)
505 tot_rho_solute = pw_integrate_function(rho_solute)
508 IF (abs(tot_rho_solute) >= 1.0e-6_dp)
THEN
509 IF ((poisson_env%parameters%solver /= pw_poisson_analytic) .AND. &
510 (poisson_env%parameters%solver /= pw_poisson_mt))
THEN
511 WRITE (unit=message, fmt=
"(A,SP,F0.6,A)") &
512 "The system (solute) has a non-negligible charge of ", -tot_rho_solute, &
513 ". It is recommended to use non-periodic boundary conditions (PERIODIC none) "// &
514 "combined with an appropriate Poisson solver (POISSON_SOLVER MT or analytic)"
520 CALL auxbas_pw_pool%create_pw(rho_tot_zero)
522 IF (sccs_control%method_id /= sccs_saa_andreussi)
THEN
533 IF (eps_elec%array(i, j, k) < 1.0_dp)
THEN
534 WRITE (unit=message, fmt=
"(A,ES12.3,A,3(I0,A))") &
535 "SCCS| Invalid dielectric function value ", eps_elec%array(i, j, k), &
536 " encountered at grid point (", i,
",", j,
",", k,
")"
539 rho_tot_zero%array(i, j, k) = rho_solute%array(i, j, k)/eps_elec%array(i, j, k)
540 eps_elec%array(i, j, k) = log(eps_elec%array(i, j, k))
548 lxyz(:) = real(u%pw_grid%bounds(1, :), dp)
549 uxyz(:) = real(u%pw_grid%bounds(2, :), dp)
557 IF (eps_elec%array(i, j, k) < 1.0_dp)
THEN
558 WRITE (unit=message, fmt=
"(A,ES12.3,A,3(I0,A))") &
559 "SCCS| Invalid dielectric function value ", eps_elec%array(i, j, k), &
560 " encountered at grid point (", i,
",", j,
",", k,
")"
563 IF (i > -1) r = ((real(uxyz(1), dp) - real(i, dp) + 0.5_dp)*u%pw_grid%dr(1))**2.0_dp
564 IF (i < 0) r = ((real(i, dp) - real(lxyz(1), dp) + 0.5_dp)*u%pw_grid%dr(1))**2.0_dp
565 IF (j > -1) r = ((real(uxyz(2), dp) - real(j, dp) + 0.5_dp)*u%pw_grid%dr(2))**2.0_dp + r
566 IF (j < 0) r = ((real(j, dp) - real(lxyz(2), dp) + 0.5_dp)*u%pw_grid%dr(2))**2.0_dp + r
567 IF (k > -1) r = ((real(uxyz(3), dp) - real(k, dp) + 0.5_dp)*u%pw_grid%dr(3))**2.0_dp + r
568 IF (k < 0) r = ((real(k, dp) - real(lxyz(3), dp) + 0.5_dp)*u%pw_grid%dr(3))**2.0_dp + r
570 u%array(i, j, k) = (1.0_dp/2.0_dp)*erfc((r - alpha_zeta*r_solv)/delta_zeta)
571 dtf%array(i, j, k) = 1.0_dp
577 CALL pw_func_u_convolution(poisson_env=poisson_env, func=dtf, convolution=ff, u=u)
578 CALL pw_scale(u, 1.0_dp/ff%array(0, 0, 0))
579 CALL pw_func_u_convolution(poisson_env=poisson_env, func=s, convolution=ff, u=u)
588 t%array(i, j, k) = 0.5_dp*(1.0_dp + erf((ff%array(i, j, k) - f0)/delta_eta))
589 dtf%array(i, j, k) = oorootpi*exp(-((ff%array(i, j, k) - f0)/delta_eta)**2)
590 eps_elec%array(i, j, k) = exp(log(epsilon_solvent)*(1 - (s%array(i, j, k) &
591 + (1 - s%array(i, j, k))*t%array(i, j, k))))
592 rho_tot_zero%array(i, j, k) = rho_solute%array(i, j, k)/eps_elec%array(i, j, k)
600 filename =
"DIELECTRIC_FUNCTION"
601 cube_path = trim(print_path)//
"%"//trim(filename)
602 IF (btest(cp_print_key_should_output(logger%iter_info, input, trim(cube_path)), &
604 append_cube = section_get_lval(input, trim(cube_path)//
"%APPEND")
605 my_pos_cube =
"REWIND"
606 IF (append_cube) my_pos_cube =
"APPEND"
608 cube_unit = cp_print_key_unit_nr(logger, input, trim(cube_path), &
609 extension=
".cube", middle_name=trim(filename), &
610 file_position=my_pos_cube, log_filename=.false., &
611 mpi_io=mpi_io, fout=mpi_filename)
612 IF (output_unit > 0)
THEN
613 IF (.NOT. mpi_io)
THEN
614 INQUIRE (unit=cube_unit, name=filename)
616 filename = mpi_filename
618 WRITE (unit=output_unit, fmt=
"(T3,A)") &
619 "SCCS| The dielectric function is written in cube file format to the file:", &
620 "SCCS| "//trim(filename)
622 CALL cp_pw_to_cube(eps_elec, cube_unit, trim(filename), particles=particles, &
623 stride=section_get_ivals(input, trim(cube_path)//
"%STRIDE"), &
625 CALL cp_print_key_finished_output(cube_unit, logger, input, trim(cube_path), mpi_io=mpi_io)
635 eps_elec%array(i, j, k) = log(eps_elec%array(i, j, k))
645 CALL auxbas_pw_pool%create_pw(dln_eps_elec(i))
646 CALL pw_zero(dln_eps_elec(i))
648 CALL derive(eps_elec, dln_eps_elec, sccs_control%derivative_method, pw_env, input)
649 IF (sccs_control%method_id /= sccs_saa_andreussi)
THEN
650 CALL auxbas_pw_pool%give_back_pw(eps_elec)
654 IF (should_output .AND. (output_unit > 0))
THEN
655 IF (print_level > low_print_level)
THEN
656 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.12)") &
657 "SCCS| Total electronic charge density ", -tot_rho_elec, &
658 "SCCS| Total charge density (solute) ", -tot_rho_solute
659 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.3)") &
660 "SCCS| Volume of the cell [bohr^3]", cell_volume, &
661 "SCCS| [angstrom^3]", &
662 cp_unit_from_cp2k(cell_volume,
"angstrom^3")
663 IF (abs(epsilon_solvent - 1.0_dp) > epstol)
THEN
664 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.3)") &
665 "SCCS| Volume of the solute cavity [bohr^3]", cavity_volume, &
666 "SCCS| [angstrom^3]", &
667 cp_unit_from_cp2k(cavity_volume,
"angstrom^3"), &
668 "SCCS| Surface of the solute cavity [bohr^2]", cavity_surface, &
669 "SCCS| [angstrom^2]", &
670 cp_unit_from_cp2k(cavity_surface,
"angstrom^2")
672 WRITE (unit=output_unit, fmt=
"(T3,A)") &
674 "SCCS| Step Average residual Maximum residual E(Hartree) [a.u.]"
680 CALL auxbas_pw_pool%create_pw(dphi_tot(i))
684 CALL auxbas_pw_pool%create_pw(rho_tot)
685 CALL pw_copy(rho_tot_zero, rho_tot)
686 CALL pw_axpy(rho_pw_r_sccs, rho_tot)
688 CALL auxbas_pw_pool%create_pw(phi_tot)
689 CALL pw_zero(phi_tot)
691 IF (sccs_control%method_id == sccs_saa_andreussi)
THEN
692 CALL auxbas_pw_pool%create_pw(p_e_interface)
693 CALL pw_zero(p_e_interface)
705 IF (iter > sccs_control%max_iter)
THEN
706 IF (output_unit > 0)
THEN
707 WRITE (unit=output_unit, fmt=
"(T3,A,/,T3,A,I0,A)") &
708 "SCCS| Maximum number of SCCS iterations reached", &
709 "SCCS| Iteration cycle did not converge in ", sccs_control%max_iter,
" steps"
711 WRITE (unit=message, fmt=
"(A,I0,A)") &
712 "The SCCS iteration cycle did not converge in ", sccs_control%max_iter,
" steps"
719 CALL pw_poisson_solve(poisson_env=poisson_env, &
723 energy%sccs_hartree = 0.5_dp*pw_integral_ab(rho_solute, phi_tot)
728 rho_delta_avg = 0.0_dp
729 rho_delta_max = 0.0_dp
739 rho_iter_new = (dln_eps_elec(1)%array(i, j, k)*dphi_tot(1)%array(i, j, k) + &
740 dln_eps_elec(2)%array(i, j, k)*dphi_tot(2)%array(i, j, k) + &
741 dln_eps_elec(3)%array(i, j, k)*dphi_tot(3)%array(i, j, k))*f
742 rho_iter_new = rho_pw_r_sccs%array(i, j, k) + &
743 sccs_control%mixing*(rho_iter_new - rho_pw_r_sccs%array(i, j, k))
744 rho_delta = abs(rho_iter_new - rho_pw_r_sccs%array(i, j, k))
745 rho_delta_max = max(rho_delta, rho_delta_max)
746 rho_delta_avg = rho_delta_avg + rho_delta
747 rho_tot%array(i, j, k) = rho_tot_zero%array(i, j, k) + rho_iter_new
748 rho_pw_r_sccs%array(i, j, k) = rho_iter_new
754 CALL para_env%sum(rho_delta_avg)
755 rho_delta_avg = rho_delta_avg/real(ngpts, kind=dp)
756 CALL para_env%max(rho_delta_max)
758 IF (should_output .AND. (output_unit > 0))
THEN
759 IF (print_level > low_print_level)
THEN
760 IF ((abs(rho_delta_avg) < 1.0e-8_dp) .OR. &
761 (abs(rho_delta_avg) >= 1.0e5_dp))
THEN
762 WRITE (unit=output_unit, fmt=
"(T3,A,I6,4X,ES16.4,4X,ES16.4,1X,F25.12)") &
763 "SCCS| ", iter, rho_delta_avg, rho_delta_max, energy%sccs_hartree
765 WRITE (unit=output_unit, fmt=
"(T3,A,I6,4X,F16.8,4X,F16.8,1X,F25.12)") &
766 "SCCS| ", iter, rho_delta_avg, rho_delta_max, energy%sccs_hartree
772 IF (rho_delta_max <= sccs_control%eps_sccs)
THEN
773 IF (should_output .AND. (output_unit > 0))
THEN
774 WRITE (unit=output_unit, fmt=
"(T3,A,I0,A)") &
775 "SCCS| Iteration cycle converged in ", iter,
" steps"
782 IF (sccs_control%method_id == sccs_saa_andreussi)
THEN
783 CALL auxbas_pw_pool%create_pw(tem_convolution)
784 CALL auxbas_pw_pool%create_pw(tem_func)
793 p_e_interface%array(i, j, k) = 1.0_dp/(4.0_dp*twopi)*(exp(eps_elec%array(i, j, k))*log(epsilon_solvent))
794 dphi2 = dphi_tot(1)%array(i, j, k)*dphi_tot(1)%array(i, j, k) + &
795 dphi_tot(2)%array(i, j, k)*dphi_tot(2)%array(i, j, k) + &
796 dphi_tot(3)%array(i, j, k)*dphi_tot(3)%array(i, j, k)
797 p_e_interface%array(i, j, k) = p_e_interface%array(i, j, k)*dphi2
798 tem_func%array(i, j, k) = (1.0_dp - s%array(i, j, k))*p_e_interface%array(i, j, k)*dtf%array(i, j, k)
804 CALL pw_func_u_convolution(poisson_env=poisson_env, func=tem_func, convolution=tem_convolution, u=u)
813 p_e_interface%array(i, j, k) = p_e_interface%array(i, j, k)*(1.0_dp - t%array(i, j, k)) &
814 + tem_convolution%array(i, j, k)
823 CALL auxbas_pw_pool%give_back_pw(rho_tot_zero)
825 CALL auxbas_pw_pool%give_back_pw(dln_eps_elec(i))
829 filename =
"TOTAL_CHARGE_DENSITY"
830 cube_path = trim(print_path)//
"%"//trim(filename)
831 IF (btest(cp_print_key_should_output(logger%iter_info, input, trim(cube_path)), cp_p_file))
THEN
832 append_cube = section_get_lval(input, trim(cube_path)//
"%APPEND")
833 my_pos_cube =
"REWIND"
834 IF (append_cube) my_pos_cube =
"APPEND"
836 cube_unit = cp_print_key_unit_nr(logger, input, trim(cube_path), &
837 extension=
".cube", middle_name=trim(filename), &
838 file_position=my_pos_cube, log_filename=.false., &
839 mpi_io=mpi_io, fout=mpi_filename)
840 IF (output_unit > 0)
THEN
841 IF (.NOT. mpi_io)
THEN
842 INQUIRE (unit=cube_unit, name=filename)
844 filename = mpi_filename
846 WRITE (unit=output_unit, fmt=
"(T3,A)") &
847 "SCCS| The total SCCS charge density is written in cube file format to the file:", &
848 "SCCS| "//trim(filename)
850 CALL cp_pw_to_cube(rho_tot, cube_unit, trim(filename), particles=particles, &
851 stride=section_get_ivals(input, trim(cube_path)//
"%STRIDE"), mpi_io=mpi_io)
852 CALL cp_print_key_finished_output(cube_unit, logger, input, trim(cube_path), mpi_io=mpi_io)
857 CALL pw_transfer(rho_tot, rho_tot_gspace)
858 IF (calculate_stress_tensor)
THEN
860 CALL pw_poisson_solve(poisson_env=poisson_env, &
861 density=rho_tot_gspace, &
863 vhartree=v_hartree_gspace, &
864 dvhartree=dphi_tot, &
867 CALL pw_poisson_solve(poisson_env=poisson_env, &
868 density=rho_tot_gspace, &
870 vhartree=v_hartree_gspace, &
873 CALL pw_transfer(v_hartree_gspace, phi_tot)
874 energy%sccs_hartree = 0.5_dp*pw_integral_ab(rho_solute, phi_tot)
878 TYPE(pw_r3d_rs_type) :: phi_solute
879 CALL auxbas_pw_pool%create_pw(phi_solute)
880 CALL pw_zero(phi_solute)
881 CALL pw_poisson_solve(poisson_env=poisson_env, &
882 density=rho_solute, &
883 ehartree=energy%hartree, &
888 CALL pw_axpy(phi_solute, phi_tot, alpha=-1.0_dp)
889 CALL auxbas_pw_pool%give_back_pw(phi_solute)
893 filename =
"POLARISATION_POTENTIAL"
894 cube_path = trim(print_path)//
"%"//trim(filename)
895 IF (btest(cp_print_key_should_output(logger%iter_info, input, trim(cube_path)), &
897 append_cube = section_get_lval(input, trim(cube_path)//
"%APPEND")
898 my_pos_cube =
"REWIND"
899 IF (append_cube) my_pos_cube =
"APPEND"
901 cube_unit = cp_print_key_unit_nr(logger, input, trim(cube_path), &
902 extension=
".cube", middle_name=trim(filename), &
903 file_position=my_pos_cube, log_filename=.false., &
904 mpi_io=mpi_io, fout=mpi_filename)
905 IF (output_unit > 0)
THEN
906 IF (.NOT. mpi_io)
THEN
907 INQUIRE (unit=cube_unit, name=filename)
909 filename = mpi_filename
911 WRITE (unit=output_unit, fmt=
"(T3,A)") &
912 "SCCS| The SCCS polarisation potential is written in cube file format to the file:", &
913 "SCCS| "//trim(filename)
915 CALL cp_pw_to_cube(phi_tot, cube_unit, trim(filename), particles=particles, &
916 stride=section_get_ivals(input, trim(cube_path)//
"%STRIDE"), mpi_io=mpi_io)
917 CALL cp_print_key_finished_output(cube_unit, logger, input, trim(cube_path), mpi_io=mpi_io)
922 CALL pw_axpy(rho_solute, rho_tot, alpha=-1.0_dp)
923 polarisation_charge = pw_integrate_function(rho_tot)
926 filename =
"POLARISATION_CHARGE_DENSITY"
927 cube_path = trim(print_path)//
"%"//trim(filename)
928 IF (btest(cp_print_key_should_output(logger%iter_info, input, trim(cube_path)), &
930 append_cube = section_get_lval(input, trim(cube_path)//
"%APPEND")
931 my_pos_cube =
"REWIND"
932 IF (append_cube) my_pos_cube =
"APPEND"
934 cube_unit = cp_print_key_unit_nr(logger, input, trim(cube_path), &
935 extension=
".cube", middle_name=trim(filename), &
936 file_position=my_pos_cube, log_filename=.false., &
937 mpi_io=mpi_io, fout=mpi_filename)
938 IF (output_unit > 0)
THEN
939 IF (.NOT. mpi_io)
THEN
940 INQUIRE (unit=cube_unit, name=filename)
942 filename = mpi_filename
944 WRITE (unit=output_unit, fmt=
"(T3,A)") &
945 "SCCS| The SCCS polarisation charge density is written in cube file format to the file:", &
946 "SCCS| "//trim(filename)
948 CALL cp_pw_to_cube(rho_tot, cube_unit, trim(filename), particles=particles, &
949 stride=section_get_ivals(input, trim(cube_path)//
"%STRIDE"), mpi_io=mpi_io)
950 CALL cp_print_key_finished_output(cube_unit, logger, input, trim(cube_path), mpi_io=mpi_io)
954 energy%sccs_pol = 0.5_dp*pw_integral_ab(rho_solute, phi_tot)
955 CALL auxbas_pw_pool%give_back_pw(rho_solute)
956 CALL auxbas_pw_pool%give_back_pw(phi_tot)
957 CALL auxbas_pw_pool%give_back_pw(rho_tot)
958 IF (sccs_control%method_id == sccs_saa_andreussi)
THEN
959 CALL auxbas_pw_pool%give_back_pw(s)
960 CALL auxbas_pw_pool%give_back_pw(u)
961 CALL auxbas_pw_pool%give_back_pw(ff)
962 CALL auxbas_pw_pool%give_back_pw(t)
963 CALL auxbas_pw_pool%give_back_pw(dtf)
964 CALL auxbas_pw_pool%give_back_pw(tem_convolution)
965 CALL auxbas_pw_pool%give_back_pw(tem_func)
966 CALL auxbas_pw_pool%give_back_pw(eps_elec)
971 energy%sccs_cav = sccs_control%gamma_solvent*cavity_surface
972 energy%sccs_dis = sccs_control%beta_solvent*cavity_volume
973 energy%sccs_rep = sccs_control%alpha_solvent*cavity_surface
975 energy%sccs_sol = energy%sccs_pol + energy%sccs_rep + energy%sccs_cav + energy%sccs_dis
977 IF (should_output .AND. (output_unit > 0))
THEN
978 WRITE (unit=output_unit, fmt=
"(T3,A)") &
980 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.12)") &
981 "SCCS| Polarisation charge", polarisation_charge
983 WRITE (unit=output_unit, fmt=
"(T3,A)") &
989 IF (sccs_control%method_id /= sccs_saa_andreussi)
THEN
991 f = -0.5_dp*dvol/fourpi
999 dphi2 = dphi_tot(1)%array(i, j, k)*dphi_tot(1)%array(i, j, k) + &
1000 dphi_tot(2)%array(i, j, k)*dphi_tot(2)%array(i, j, k) + &
1001 dphi_tot(3)%array(i, j, k)*dphi_tot(3)%array(i, j, k)
1002 v_sccs%array(i, j, k) = v_sccs%array(i, j, k) + f*deps_elec%array(i, j, k)*dphi2
1017 v_sccs%array(i, j, k) = dvol*d_s_rhoel%array(i, j, k)*p_e_interface%array(i, j, k)
1023 CALL auxbas_pw_pool%give_back_pw(d_s_rhoel)
1024 CALL auxbas_pw_pool%give_back_pw(p_e_interface)
1028 CALL auxbas_pw_pool%give_back_pw(deps_elec)
1030 CALL auxbas_pw_pool%give_back_pw(dphi_tot(i))
1034 CALL cp_print_key_finished_output(output_unit, logger, input, trim(print_path), &
1035 ignore_should_output=should_output)
1037 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.