Octopus
pcm_potential.F90
Go to the documentation of this file.
1!! Copyright (C) 2014 Alain Delgado Gran, Carlo Andrea Rozzi, Stefano Corni, Gabriel Gil
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
23 use debug_oct_m
25 use global_oct_m
26 use grid_oct_m
28 use index_oct_m
30 use ions_oct_m
31 use kick_oct_m
32 use lasers_oct_m
34 use mesh_oct_m
36 use mpi_oct_m
39 use pcm_oct_m
44 use space_oct_m
46
47 ! to output debug info
48 use unit_oct_m
52
53 implicit none
54
55 private
56
57 public :: &
59
60contains
61
62 ! -----------------------------------------------------------------------------
64 subroutine pcm_hartree_potential(pcm, space, mesh, psolver, ext_partners, vhartree, density, pcm_corr, &
65 kick, time)
66 type(pcm_t), intent(inout) :: pcm
67 class(space_t), intent(in) :: space
68 class(mesh_t), intent(in) :: mesh
69 type(poisson_t), intent(inout) :: psolver
70 type(partner_list_t),intent(in) :: ext_partners
71 real(real64), intent(in) :: vhartree(:)
72 real(real64), intent(in) :: density(:)
73 real(real64), intent(out) :: pcm_corr
74 type(kick_t), optional, intent(in) :: kick
75 real(real64), optional, intent(in) :: time
76
77 real(real64), allocatable :: potx(:)
78 complex(real64), allocatable :: kick_eval(:)
79 real(real64), allocatable :: kick_real(:)
80 integer :: ii
81
82 logical :: kick_time
83 type(lasers_t), pointer :: lasers
84
85 push_sub(pcm_hartree_potential)
86
87 if (.not. pcm%run_pcm .or. .not. pcm_update(pcm)) then
88 pcm_corr = m_zero
90 return
91 end if
92
94 if (pcm%solute) then
95 call pcm_calc_pot_rs(pcm, mesh, psolver, v_h = vhartree, time_present = present(time))
96 end if
97
102 if (pcm%localf .and. present(time)) then
103 lasers => list_get_lasers(ext_partners)
104 if (associated(lasers) .and. present(kick)) then
105 safe_allocate(potx(1:mesh%np_part))
106 safe_allocate(kick_eval(1:mesh%np_part))
107 safe_allocate(kick_real(1:mesh%np_part))
108 potx = m_zero
109 kick_eval = m_zero
110 do ii = 1, lasers%no_lasers
111 call laser_potential(lasers%lasers(ii), mesh, potx, time)
112 end do
113 kick_real = m_zero
114 kick_time = ((pcm%iter-1)*pcm%dt <= kick%time) .and. (pcm%iter*pcm%dt > kick%time)
115 if (kick_time) then
116 call kick_function_get(space, mesh, kick, kick_eval, 1, to_interpolate = .true.)
117 kick_eval = kick%delta_strength * kick_eval
118 kick_real = real(kick_eval, real64)
119 end if
120 call pcm_calc_pot_rs(pcm, mesh, psolver, v_ext = potx, kick = -kick_real, &
121 time_present = present(time), kick_time = kick_time)
122 safe_deallocate_a(potx)
123 safe_deallocate_a(kick_eval)
124 safe_deallocate_a(kick_real)
125 else if (associated(lasers) .and. .not.present(kick)) then
126 safe_allocate(potx(1:mesh%np_part))
127 potx = m_zero
128 do ii = 1, lasers%no_lasers
129 call laser_potential(lasers%lasers(ii), mesh, potx, time)
130 end do
131 call pcm_calc_pot_rs(pcm, mesh, psolver, v_ext = potx, time_present = present(time))
132 safe_deallocate_a(potx)
133 else if (.not.associated(lasers) .and. present(kick)) then
134 safe_allocate(kick_eval(1:mesh%np_part))
135 safe_allocate(kick_real(1:mesh%np_part))
136 kick_eval = m_zero
137 kick_real = m_zero
138 kick_time =((pcm%iter-1)*pcm%dt <= kick%time) .and. (pcm%iter*pcm%dt > kick%time)
139 if (kick_time) then
140 call kick_function_get(space, mesh, kick, kick_eval, 1, to_interpolate = .true.)
141 kick_eval = kick%delta_strength * kick_eval
142 kick_real = real(kick_eval, real64)
143 end if
144 call pcm_calc_pot_rs(pcm, mesh, psolver, kick = -kick_real, &
145 time_present = present(time), kick_time = kick_time)
146 safe_deallocate_a(kick_eval)
147 safe_deallocate_a(kick_real)
148 end if
149
150 ! Calculating the PCM term renormalizing the sum of the single-particle energies
151 ! to keep the idea of pcm_corr... but it will be added later on
152 pcm_corr = dmf_dotp( mesh, density, pcm%v_e_rs + pcm%v_n_rs + pcm%v_ext_rs)
153 else
154 ! Calculating the PCM term renormalizing the sum of the single-particle energies
155 pcm_corr = dmf_dotp( mesh, density, pcm%v_e_rs + pcm%v_n_rs)
156 end if
157
158 call messages_write(' PCM potential updated')
160 call messages_write(' PCM update iteration counter: ')
161 call messages_write(pcm%iter)
162 call messages_info(debug_only=.true.)
163
164 pop_sub(pcm_hartree_potential)
165
166 end subroutine pcm_hartree_potential
167
168end module pcm_potential_oct_m
169
170!! Local Variables:
171!! mode: f90
172!! coding: utf-8
173!! End:
type(lasers_t) function, pointer, public list_get_lasers(partners)
real(real64), parameter, public m_zero
Definition: global.F90:200
This module implements the underlying real-space grid.
Definition: grid.F90:119
This module implements the index, used for the mesh points.
Definition: index.F90:124
This module defines classes and functions for interaction partners.
subroutine, public kick_function_get(space, mesh, kick, kick_function, iq, to_interpolate)
Definition: kick.F90:994
subroutine, public laser_potential(laser, mesh, pot, time)
Definition: lasers.F90:1049
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:120
subroutine, public messages_new_line()
Definition: messages.F90:1089
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:594
Some general things and nomenclature:
Definition: par_vec.F90:173
subroutine, public pcm_calc_pot_rs(pcm, mesh, psolver, ions, v_h, v_ext, kick, time_present, kick_time)
Definition: pcm.F90:1216
logical function, public pcm_update(this)
Update pcm potential.
Definition: pcm.F90:3169
subroutine, public pcm_hartree_potential(pcm, space, mesh, psolver, ext_partners, vhartree, density, pcm_corr, kick, time)
PCM reaction field due to the electronic density.
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
Definition: unit.F90:134
This module defines the unit system, used for input and output.
int true(void)