125 SUBROUTINE sccs(qs_env, rho_tot_gspace, v_hartree_gspace, v_sccs, h_stress)
128 TYPE(
pw_c1d_gs_type),
INTENT(INOUT) :: rho_tot_gspace, v_hartree_gspace
130 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(OUT), &
133 CHARACTER(LEN=*),
PARAMETER :: routinen =
'sccs'
134 REAL(kind=
dp),
PARAMETER :: epstol = 1.0e-8_dp
136 CHARACTER(LEN=4*default_string_length) :: message, my_pos_cube
137 CHARACTER(LEN=default_path_length) :: cube_path, filename, mpi_filename, &
139 INTEGER :: cube_unit, handle, i, ispin, iter, j, k, &
140 nspin, output_unit, print_level
141 INTEGER(KIND=int_8) :: ngpts
142 INTEGER,
DIMENSION(3) :: lb, ub
143 LOGICAL :: append_cube, calculate_stress_tensor, &
144 do_kpoints, mpi_io, should_output
145 REAL(kind=
dp) :: alpha_zeta, cavity_surface, cavity_volume, cell_volume, delta_eta, &
146 delta_zeta, dphi2, dvol, e_tot, epsilon_solvent, f, f0, polarisation_charge, r, r_solv, &
147 rho_delta, rho_delta_avg, rho_delta_max, rho_iter_new, tot_rho_elec, tot_rho_solute
148 REAL(kind=
dp),
DIMENSION(3) :: abc, lxyz, uxyz
158 TYPE(
pw_r3d_rs_type) :: d_s_rhoel, deps_elec, dtf, eps_elec, ff, &
159 p_e_interface, s, t, tem_convolution, &
170 CALL timeset(routinen, handle)
172 NULLIFY (auxbas_pw_pool)
174 NULLIFY (dft_control)
180 NULLIFY (poisson_env)
184 NULLIFY (sccs_control)
189 cp_subsys=cp_subsys, &
190 do_kpoints=do_kpoints, &
191 dft_control=dft_control, &
200 sccs_control => dft_control%sccs_control
202 cpassert(
ASSOCIATED(qs_env))
205 cpwarn(
"SCCS with k-points has not yet been fully validated")
208 IF (
PRESENT(h_stress))
THEN
209 calculate_stress_tensor = .true.
210 h_stress(:, :) = 0.0_dp
211 cpwarn(
"The stress tensor for SCCS has not yet been fully validated")
213 calculate_stress_tensor = .false.
218 auxbas_pw_pool=auxbas_pw_pool, &
220 poisson_env=poisson_env)
225 IF (.NOT. sccs_control%sccs_activated)
THEN
226 IF (sccs_control%eps_scf > 0.0_dp)
THEN
227 IF ((scf_env%iter_delta > sccs_control%eps_scf) .OR. &
228 ((qs_env%scf_env%outer_scf%iter_count == 0) .AND. &
229 (qs_env%scf_env%iter_count <= 1)))
THEN
230 IF (calculate_stress_tensor)
THEN
233 density=rho_tot_gspace, &
234 ehartree=energy%hartree, &
235 vhartree=v_hartree_gspace, &
239 density=rho_tot_gspace, &
240 ehartree=energy%hartree, &
241 vhartree=v_hartree_gspace)
243 energy%sccs_pol = 0.0_dp
244 energy%sccs_cav = 0.0_dp
245 energy%sccs_dis = 0.0_dp
246 energy%sccs_rep = 0.0_dp
247 energy%sccs_sol = 0.0_dp
248 energy%sccs_hartree = energy%hartree
249 CALL timestop(handle)
253 sccs_control%sccs_activated = .true.
256 nspin = dft_control%nspins
260 print_level = logger%iter_info%print_level
261 print_path =
"DFT%PRINT%SCCS"
266 ignore_should_output=should_output, &
267 log_filename=.false.)
272 rho_r_sccs=rho_pw_r_sccs)
275 cpassert(
ASSOCIATED(rho_pw_r_sccs))
280 CALL auxbas_pw_pool%create_pw(rho_elec)
283 ngpts = rho_elec%pw_grid%ngpts
284 dvol = rho_elec%pw_grid%dvol
285 cell_volume = rho_elec%pw_grid%vol
286 abc(1:3) = real(rho_elec%pw_grid%npts(1:3), kind=
dp)*rho_elec%pw_grid%dr(1:3)
287 lb(1:3) = rho_elec%pw_grid%bounds_local(1, 1:3)
288 ub(1:3) = rho_elec%pw_grid%bounds_local(2, 1:3)
290 CALL pw_copy(rho_pw_r(1), rho_elec)
292 CALL pw_axpy(rho_pw_r(ispin), rho_elec)
297 CALL auxbas_pw_pool%create_pw(eps_elec)
298 CALL auxbas_pw_pool%create_pw(deps_elec)
300 CALL auxbas_pw_pool%create_pw(s)
301 CALL auxbas_pw_pool%create_pw(d_s_rhoel)
302 CALL auxbas_pw_pool%create_pw(u)
303 CALL auxbas_pw_pool%create_pw(ff)
304 CALL auxbas_pw_pool%create_pw(t)
305 CALL auxbas_pw_pool%create_pw(dtf)
307 delta_eta = sccs_control%delta_eta
308 alpha_zeta = sccs_control%alpha_zeta
309 r_solv = sccs_control%R_solv
310 delta_zeta = sccs_control%delta_zeta
314 epsilon_solvent = sccs_control%epsilon_solvent
315 SELECT CASE (sccs_control%method_id)
317 CALL andreussi(rho_elec, eps_elec, deps_elec, epsilon_solvent, sccs_control%rho_max, &
318 sccs_control%rho_min)
320 CALL fattebert_gygi(rho_elec, eps_elec, deps_elec, epsilon_solvent, sccs_control%beta, &
321 sccs_control%rho_zero)
323 CALL sa_andreussi(rho_elec, eps_elec, deps_elec, epsilon_solvent, sccs_control%rho_max, &
324 sccs_control%rho_min, s, d_s_rhoel)
326 cpabort(
"Invalid method specified for SCCS model")
331 filename =
"DIELECTRIC_FUNCTION"
332 cube_path = trim(print_path)//
"%"//trim(filename)
336 my_pos_cube =
"REWIND"
337 IF (append_cube) my_pos_cube =
"APPEND"
340 extension=
".cube", middle_name=trim(filename), &
341 file_position=my_pos_cube, log_filename=.false., &
342 mpi_io=mpi_io, fout=mpi_filename)
343 IF (output_unit > 0)
THEN
344 IF (.NOT. mpi_io)
THEN
345 INQUIRE (unit=cube_unit, name=filename)
347 filename = mpi_filename
349 WRITE (unit=output_unit, fmt=
"(T3,A)") &
350 "SCCS| The dielectric function is written in cube file format to the file:", &
351 "SCCS| "//trim(filename)
353 CALL cp_pw_to_cube(eps_elec, cube_unit, trim(filename), particles=particles, &
361 cavity_surface = 0.0_dp
362 cavity_volume = 0.0_dp
364 IF (abs(epsilon_solvent - 1.0_dp) > epstol)
THEN
369 CALL auxbas_pw_pool%create_pw(theta)
373 f = 1.0_dp/(epsilon_solvent - 1.0_dp)
380 theta%array(i, j, k) = f*(epsilon_solvent - eps_elec%array(i, j, k))
390 CALL auxbas_pw_pool%create_pw(drho_elec(i))
394 CALL auxbas_pw_pool%create_pw(norm_drho_elec)
403 norm_drho_elec%array(i, j, k) = sqrt(drho_elec(1)%array(i, j, k)* &
404 drho_elec(1)%array(i, j, k) + &
405 drho_elec(2)%array(i, j, k)* &
406 drho_elec(2)%array(i, j, k) + &
407 drho_elec(3)%array(i, j, k)* &
408 drho_elec(3)%array(i, j, k))
415 filename =
"DENSITY_GRADIENT"
416 cube_path = trim(print_path)//
"%"//trim(filename)
420 my_pos_cube =
"REWIND"
421 IF (append_cube) my_pos_cube =
"APPEND"
424 extension=
".cube", middle_name=trim(filename), &
425 file_position=my_pos_cube, log_filename=.false., &
426 mpi_io=mpi_io, fout=mpi_filename)
427 IF (output_unit > 0)
THEN
428 IF (.NOT. mpi_io)
THEN
429 INQUIRE (unit=cube_unit, name=filename)
431 filename = mpi_filename
433 WRITE (unit=output_unit, fmt=
"(T3,A)") &
434 "SCCS| The norm of the density gradient is written in cube file format to the file:", &
435 "SCCS| "//trim(filename)
437 CALL cp_pw_to_cube(norm_drho_elec, cube_unit, trim(filename), particles=particles, &
444 SELECT CASE (sccs_control%method_id)
446 CALL surface_andreussi(rho_elec, norm_drho_elec, theta, epsilon_solvent, &
447 sccs_control%rho_max, sccs_control%rho_min, &
448 sccs_control%delta_rho)
450 CALL surface_fattebert_gygi(rho_elec, norm_drho_elec, theta, epsilon_solvent, &
451 sccs_control%beta, sccs_control%rho_zero, &
452 sccs_control%delta_rho)
455 cpabort(
"Invalid method specified for SCCS model")
460 CALL auxbas_pw_pool%give_back_pw(theta)
461 CALL auxbas_pw_pool%give_back_pw(norm_drho_elec)
463 CALL auxbas_pw_pool%give_back_pw(drho_elec(i))
469 CALL auxbas_pw_pool%give_back_pw(rho_elec)
473 TYPE(pw_r3d_rs_type) :: rho_tot, phi_tot, rho_solute, rho_tot_zero
475 CALL auxbas_pw_pool%create_pw(rho_solute)
476 CALL pw_zero(rho_solute)
477 CALL pw_transfer(rho_tot_gspace, rho_solute)
478 tot_rho_solute = pw_integrate_function(rho_solute)
481 IF (abs(tot_rho_solute) >= 1.0e-6_dp)
THEN
482 IF ((poisson_env%parameters%solver /= pw_poisson_analytic) .AND. &
483 (poisson_env%parameters%solver /= pw_poisson_mt))
THEN
484 WRITE (unit=message, fmt=
"(A,SP,F0.6,A)") &
485 "The system (solute) has a non-negligible charge of ", -tot_rho_solute, &
486 ". It is recommended to use non-periodic boundary conditions (PERIODIC none) "// &
487 "combined with an appropriate Poisson solver (POISSON_SOLVER MT or analytic)"
493 CALL auxbas_pw_pool%create_pw(rho_tot_zero)
495 IF (sccs_control%method_id /= sccs_saa_andreussi)
THEN
506 IF (eps_elec%array(i, j, k) < 1.0_dp)
THEN
507 WRITE (unit=message, fmt=
"(A,ES12.3,A,3(I0,A))") &
508 "SCCS| Invalid dielectric function value ", eps_elec%array(i, j, k), &
509 " encountered at grid point (", i,
",", j,
",", k,
")"
512 rho_tot_zero%array(i, j, k) = rho_solute%array(i, j, k)/eps_elec%array(i, j, k)
513 eps_elec%array(i, j, k) = log(eps_elec%array(i, j, k))
521 lxyz(:) = real(u%pw_grid%bounds(1, :), dp)
522 uxyz(:) = real(u%pw_grid%bounds(2, :), dp)
530 IF (eps_elec%array(i, j, k) < 1.0_dp)
THEN
531 WRITE (unit=message, fmt=
"(A,ES12.3,A,3(I0,A))") &
532 "SCCS| Invalid dielectric function value ", eps_elec%array(i, j, k), &
533 " encountered at grid point (", i,
",", j,
",", k,
")"
536 IF (i > -1) r = ((real(uxyz(1), dp) - real(i, dp) + 0.5_dp)*u%pw_grid%dr(1))**2.0_dp
537 IF (i < 0) r = ((real(i, dp) - real(lxyz(1), dp) + 0.5_dp)*u%pw_grid%dr(1))**2.0_dp
538 IF (j > -1) r = ((real(uxyz(2), dp) - real(j, dp) + 0.5_dp)*u%pw_grid%dr(2))**2.0_dp + r
539 IF (j < 0) r = ((real(j, dp) - real(lxyz(2), dp) + 0.5_dp)*u%pw_grid%dr(2))**2.0_dp + r
540 IF (k > -1) r = ((real(uxyz(3), dp) - real(k, dp) + 0.5_dp)*u%pw_grid%dr(3))**2.0_dp + r
541 IF (k < 0) r = ((real(k, dp) - real(lxyz(3), dp) + 0.5_dp)*u%pw_grid%dr(3))**2.0_dp + r
543 u%array(i, j, k) = (1.0_dp/2.0_dp)*erfc((r - alpha_zeta*r_solv)/delta_zeta)
544 dtf%array(i, j, k) = 1.0_dp
550 CALL pw_func_u_convolution(poisson_env=poisson_env, func=dtf, convolution=ff, u=u)
551 CALL pw_scale(u, 1.0_dp/ff%array(0, 0, 0))
552 CALL pw_func_u_convolution(poisson_env=poisson_env, func=s, convolution=ff, u=u)
561 t%array(i, j, k) = 0.5_dp*(1.0_dp + erf((ff%array(i, j, k) - f0)/delta_eta))
562 dtf%array(i, j, k) = (1.0_dp/sqrt(pi))*exp(-(ff%array(i, j, k) - f0)**2.0/(delta_eta**2.0))
563 eps_elec%array(i, j, k) = exp(log(epsilon_solvent)*(1 - (s%array(i, j, k) &
564 + (1 - s%array(i, j, k))*t%array(i, j, k))))
565 rho_tot_zero%array(i, j, k) = rho_solute%array(i, j, k)/eps_elec%array(i, j, k)
573 filename =
"DIELECTRIC_FUNCTION"
574 cube_path = trim(print_path)//
"%"//trim(filename)
575 IF (btest(cp_print_key_should_output(logger%iter_info, input, trim(cube_path)), &
577 append_cube = section_get_lval(input, trim(cube_path)//
"%APPEND")
578 my_pos_cube =
"REWIND"
579 IF (append_cube) my_pos_cube =
"APPEND"
581 cube_unit = cp_print_key_unit_nr(logger, input, trim(cube_path), &
582 extension=
".cube", middle_name=trim(filename), &
583 file_position=my_pos_cube, log_filename=.false., &
584 mpi_io=mpi_io, fout=mpi_filename)
585 IF (output_unit > 0)
THEN
586 IF (.NOT. mpi_io)
THEN
587 INQUIRE (unit=cube_unit, name=filename)
589 filename = mpi_filename
591 WRITE (unit=output_unit, fmt=
"(T3,A)") &
592 "SCCS| The dielectric function is written in cube file format to the file:", &
593 "SCCS| "//trim(filename)
595 CALL cp_pw_to_cube(eps_elec, cube_unit, trim(filename), particles=particles, &
596 stride=section_get_ivals(input, trim(cube_path)//
"%STRIDE"), &
598 CALL cp_print_key_finished_output(cube_unit, logger, input, trim(cube_path), mpi_io=mpi_io)
608 eps_elec%array(i, j, k) = log(eps_elec%array(i, j, k))
618 CALL auxbas_pw_pool%create_pw(dln_eps_elec(i))
619 CALL pw_zero(dln_eps_elec(i))
621 CALL derive(eps_elec, dln_eps_elec, sccs_control%derivative_method, pw_env, input)
622 IF (sccs_control%method_id /= sccs_saa_andreussi)
THEN
623 CALL auxbas_pw_pool%give_back_pw(eps_elec)
627 IF (should_output .AND. (output_unit > 0))
THEN
628 IF (print_level > low_print_level)
THEN
629 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.12)") &
630 "SCCS| Total electronic charge density ", -tot_rho_elec, &
631 "SCCS| Total charge density (solute) ", -tot_rho_solute
632 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.3)") &
633 "SCCS| Volume of the cell [bohr^3]", cell_volume, &
634 "SCCS| [angstrom^3]", &
635 cp_unit_from_cp2k(cell_volume,
"angstrom^3")
636 IF (abs(epsilon_solvent - 1.0_dp) > epstol)
THEN
637 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.3)") &
638 "SCCS| Volume of the solute cavity [bohr^3]", cavity_volume, &
639 "SCCS| [angstrom^3]", &
640 cp_unit_from_cp2k(cavity_volume,
"angstrom^3"), &
641 "SCCS| Surface of the solute cavity [bohr^2]", cavity_surface, &
642 "SCCS| [angstrom^2]", &
643 cp_unit_from_cp2k(cavity_surface,
"angstrom^2")
645 WRITE (unit=output_unit, fmt=
"(T3,A)") &
647 "SCCS| Step Average residual Maximum residual E(Hartree) [a.u.]"
653 CALL auxbas_pw_pool%create_pw(dphi_tot(i))
657 CALL auxbas_pw_pool%create_pw(rho_tot)
658 CALL pw_copy(rho_tot_zero, rho_tot)
659 CALL pw_axpy(rho_pw_r_sccs, rho_tot)
661 CALL auxbas_pw_pool%create_pw(phi_tot)
662 CALL pw_zero(phi_tot)
664 IF (sccs_control%method_id == sccs_saa_andreussi)
THEN
665 CALL auxbas_pw_pool%create_pw(p_e_interface)
666 CALL pw_zero(p_e_interface)
678 IF (iter > sccs_control%max_iter)
THEN
679 IF (output_unit > 0)
THEN
680 WRITE (unit=output_unit, fmt=
"(T3,A,/,T3,A,I0,A)") &
681 "SCCS| Maximum number of SCCS iterations reached", &
682 "SCCS| Iteration cycle did not converge in ", sccs_control%max_iter,
" steps"
684 WRITE (unit=message, fmt=
"(A,I0,A)") &
685 "The SCCS iteration cycle did not converge in ", sccs_control%max_iter,
" steps"
692 CALL pw_poisson_solve(poisson_env=poisson_env, &
696 energy%sccs_hartree = 0.5_dp*pw_integral_ab(rho_solute, phi_tot)
701 rho_delta_avg = 0.0_dp
702 rho_delta_max = 0.0_dp
712 rho_iter_new = (dln_eps_elec(1)%array(i, j, k)*dphi_tot(1)%array(i, j, k) + &
713 dln_eps_elec(2)%array(i, j, k)*dphi_tot(2)%array(i, j, k) + &
714 dln_eps_elec(3)%array(i, j, k)*dphi_tot(3)%array(i, j, k))*f
715 rho_iter_new = rho_pw_r_sccs%array(i, j, k) + &
716 sccs_control%mixing*(rho_iter_new - rho_pw_r_sccs%array(i, j, k))
717 rho_delta = abs(rho_iter_new - rho_pw_r_sccs%array(i, j, k))
718 rho_delta_max = max(rho_delta, rho_delta_max)
719 rho_delta_avg = rho_delta_avg + rho_delta
720 rho_tot%array(i, j, k) = rho_tot_zero%array(i, j, k) + rho_iter_new
721 rho_pw_r_sccs%array(i, j, k) = rho_iter_new
727 CALL para_env%sum(rho_delta_avg)
728 rho_delta_avg = rho_delta_avg/real(ngpts, kind=dp)
729 CALL para_env%max(rho_delta_max)
731 IF (should_output .AND. (output_unit > 0))
THEN
732 IF (print_level > low_print_level)
THEN
733 IF ((abs(rho_delta_avg) < 1.0e-8_dp) .OR. &
734 (abs(rho_delta_avg) >= 1.0e5_dp))
THEN
735 WRITE (unit=output_unit, fmt=
"(T3,A,I6,4X,ES16.4,4X,ES16.4,1X,F25.12)") &
736 "SCCS| ", iter, rho_delta_avg, rho_delta_max, energy%sccs_hartree
738 WRITE (unit=output_unit, fmt=
"(T3,A,I6,4X,F16.8,4X,F16.8,1X,F25.12)") &
739 "SCCS| ", iter, rho_delta_avg, rho_delta_max, energy%sccs_hartree
745 IF (rho_delta_max <= sccs_control%eps_sccs)
THEN
746 IF (should_output .AND. (output_unit > 0))
THEN
747 WRITE (unit=output_unit, fmt=
"(T3,A,I0,A)") &
748 "SCCS| Iteration cycle converged in ", iter,
" steps"
755 IF (sccs_control%method_id == sccs_saa_andreussi)
THEN
756 CALL auxbas_pw_pool%create_pw(tem_convolution)
757 CALL auxbas_pw_pool%create_pw(tem_func)
766 p_e_interface%array(i, j, k) = 1.0_dp/(4.0_dp*twopi)*(exp(eps_elec%array(i, j, k))*log(epsilon_solvent))
767 dphi2 = dphi_tot(1)%array(i, j, k)*dphi_tot(1)%array(i, j, k) + &
768 dphi_tot(2)%array(i, j, k)*dphi_tot(2)%array(i, j, k) + &
769 dphi_tot(3)%array(i, j, k)*dphi_tot(3)%array(i, j, k)
770 p_e_interface%array(i, j, k) = p_e_interface%array(i, j, k)*dphi2
771 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)
777 CALL pw_func_u_convolution(poisson_env=poisson_env, func=tem_func, convolution=tem_convolution, u=u)
786 p_e_interface%array(i, j, k) = p_e_interface%array(i, j, k)*(1.0_dp - t%array(i, j, k)) &
787 + tem_convolution%array(i, j, k)
796 CALL auxbas_pw_pool%give_back_pw(rho_tot_zero)
798 CALL auxbas_pw_pool%give_back_pw(dln_eps_elec(i))
802 filename =
"TOTAL_CHARGE_DENSITY"
803 cube_path = trim(print_path)//
"%"//trim(filename)
804 IF (btest(cp_print_key_should_output(logger%iter_info, input, trim(cube_path)), cp_p_file))
THEN
805 append_cube = section_get_lval(input, trim(cube_path)//
"%APPEND")
806 my_pos_cube =
"REWIND"
807 IF (append_cube) my_pos_cube =
"APPEND"
809 cube_unit = cp_print_key_unit_nr(logger, input, trim(cube_path), &
810 extension=
".cube", middle_name=trim(filename), &
811 file_position=my_pos_cube, log_filename=.false., &
812 mpi_io=mpi_io, fout=mpi_filename)
813 IF (output_unit > 0)
THEN
814 IF (.NOT. mpi_io)
THEN
815 INQUIRE (unit=cube_unit, name=filename)
817 filename = mpi_filename
819 WRITE (unit=output_unit, fmt=
"(T3,A)") &
820 "SCCS| The total SCCS charge density is written in cube file format to the file:", &
821 "SCCS| "//trim(filename)
823 CALL cp_pw_to_cube(rho_tot, cube_unit, trim(filename), particles=particles, &
824 stride=section_get_ivals(input, trim(cube_path)//
"%STRIDE"), mpi_io=mpi_io)
825 CALL cp_print_key_finished_output(cube_unit, logger, input, trim(cube_path), mpi_io=mpi_io)
830 CALL pw_transfer(rho_tot, rho_tot_gspace)
831 IF (calculate_stress_tensor)
THEN
833 CALL pw_poisson_solve(poisson_env=poisson_env, &
834 density=rho_tot_gspace, &
836 vhartree=v_hartree_gspace, &
837 dvhartree=dphi_tot, &
840 CALL pw_poisson_solve(poisson_env=poisson_env, &
841 density=rho_tot_gspace, &
843 vhartree=v_hartree_gspace, &
846 CALL pw_transfer(v_hartree_gspace, phi_tot)
847 energy%sccs_hartree = 0.5_dp*pw_integral_ab(rho_solute, phi_tot)
851 TYPE(pw_r3d_rs_type) :: phi_solute
852 CALL auxbas_pw_pool%create_pw(phi_solute)
853 CALL pw_zero(phi_solute)
854 CALL pw_poisson_solve(poisson_env=poisson_env, &
855 density=rho_solute, &
856 ehartree=energy%hartree, &
861 CALL pw_axpy(phi_solute, phi_tot, alpha=-1.0_dp)
862 CALL auxbas_pw_pool%give_back_pw(phi_solute)
866 filename =
"POLARISATION_POTENTIAL"
867 cube_path = trim(print_path)//
"%"//trim(filename)
868 IF (btest(cp_print_key_should_output(logger%iter_info, input, trim(cube_path)), &
870 append_cube = section_get_lval(input, trim(cube_path)//
"%APPEND")
871 my_pos_cube =
"REWIND"
872 IF (append_cube) my_pos_cube =
"APPEND"
874 cube_unit = cp_print_key_unit_nr(logger, input, trim(cube_path), &
875 extension=
".cube", middle_name=trim(filename), &
876 file_position=my_pos_cube, log_filename=.false., &
877 mpi_io=mpi_io, fout=mpi_filename)
878 IF (output_unit > 0)
THEN
879 IF (.NOT. mpi_io)
THEN
880 INQUIRE (unit=cube_unit, name=filename)
882 filename = mpi_filename
884 WRITE (unit=output_unit, fmt=
"(T3,A)") &
885 "SCCS| The SCCS polarisation potential is written in cube file format to the file:", &
886 "SCCS| "//trim(filename)
888 CALL cp_pw_to_cube(phi_tot, cube_unit, trim(filename), particles=particles, &
889 stride=section_get_ivals(input, trim(cube_path)//
"%STRIDE"), mpi_io=mpi_io)
890 CALL cp_print_key_finished_output(cube_unit, logger, input, trim(cube_path), mpi_io=mpi_io)
895 CALL pw_axpy(rho_solute, rho_tot, alpha=-1.0_dp)
896 polarisation_charge = pw_integrate_function(rho_tot)
899 filename =
"POLARISATION_CHARGE_DENSITY"
900 cube_path = trim(print_path)//
"%"//trim(filename)
901 IF (btest(cp_print_key_should_output(logger%iter_info, input, trim(cube_path)), &
903 append_cube = section_get_lval(input, trim(cube_path)//
"%APPEND")
904 my_pos_cube =
"REWIND"
905 IF (append_cube) my_pos_cube =
"APPEND"
907 cube_unit = cp_print_key_unit_nr(logger, input, trim(cube_path), &
908 extension=
".cube", middle_name=trim(filename), &
909 file_position=my_pos_cube, log_filename=.false., &
910 mpi_io=mpi_io, fout=mpi_filename)
911 IF (output_unit > 0)
THEN
912 IF (.NOT. mpi_io)
THEN
913 INQUIRE (unit=cube_unit, name=filename)
915 filename = mpi_filename
917 WRITE (unit=output_unit, fmt=
"(T3,A)") &
918 "SCCS| The SCCS polarisation charge density is written in cube file format to the file:", &
919 "SCCS| "//trim(filename)
921 CALL cp_pw_to_cube(rho_tot, cube_unit, trim(filename), particles=particles, &
922 stride=section_get_ivals(input, trim(cube_path)//
"%STRIDE"), mpi_io=mpi_io)
923 CALL cp_print_key_finished_output(cube_unit, logger, input, trim(cube_path), mpi_io=mpi_io)
927 energy%sccs_pol = 0.5_dp*pw_integral_ab(rho_solute, phi_tot)
928 CALL auxbas_pw_pool%give_back_pw(rho_solute)
929 CALL auxbas_pw_pool%give_back_pw(phi_tot)
930 CALL auxbas_pw_pool%give_back_pw(rho_tot)
931 IF (sccs_control%method_id == sccs_saa_andreussi)
THEN
932 CALL auxbas_pw_pool%give_back_pw(s)
933 CALL auxbas_pw_pool%give_back_pw(u)
934 CALL auxbas_pw_pool%give_back_pw(ff)
935 CALL auxbas_pw_pool%give_back_pw(t)
936 CALL auxbas_pw_pool%give_back_pw(dtf)
937 CALL auxbas_pw_pool%give_back_pw(tem_convolution)
938 CALL auxbas_pw_pool%give_back_pw(tem_func)
939 CALL auxbas_pw_pool%give_back_pw(eps_elec)
944 energy%sccs_cav = sccs_control%gamma_solvent*cavity_surface
945 energy%sccs_dis = sccs_control%beta_solvent*cavity_volume
946 energy%sccs_rep = sccs_control%alpha_solvent*cavity_surface
948 energy%sccs_sol = energy%sccs_pol + energy%sccs_rep + energy%sccs_cav + energy%sccs_dis
950 IF (should_output .AND. (output_unit > 0))
THEN
951 WRITE (unit=output_unit, fmt=
"(T3,A)") &
953 WRITE (unit=output_unit, fmt=
"(T3,A,T56,F25.12)") &
954 "SCCS| Polarisation charge", polarisation_charge
956 WRITE (unit=output_unit, fmt=
"(T3,A)") &
962 IF (sccs_control%method_id /= sccs_saa_andreussi)
THEN
964 f = -0.5_dp*dvol/fourpi
972 dphi2 = dphi_tot(1)%array(i, j, k)*dphi_tot(1)%array(i, j, k) + &
973 dphi_tot(2)%array(i, j, k)*dphi_tot(2)%array(i, j, k) + &
974 dphi_tot(3)%array(i, j, k)*dphi_tot(3)%array(i, j, k)
975 v_sccs%array(i, j, k) = v_sccs%array(i, j, k) + f*deps_elec%array(i, j, k)*dphi2
990 v_sccs%array(i, j, k) = dvol*d_s_rhoel%array(i, j, k)*p_e_interface%array(i, j, k)
996 CALL auxbas_pw_pool%give_back_pw(d_s_rhoel)
997 CALL auxbas_pw_pool%give_back_pw(p_e_interface)
1001 CALL auxbas_pw_pool%give_back_pw(deps_elec)
1003 CALL auxbas_pw_pool%give_back_pw(dphi_tot(i))
1007 CALL cp_print_key_finished_output(output_unit, logger, input, trim(print_path), &
1008 ignore_should_output=should_output)
1010 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.