Octopus
vtau_mixer.F90
Go to the documentation of this file.
1!! Copyright (C) 2022 N. Tancogne-Dejean
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
22 use debug_oct_m
23 use global_oct_m
27 use mix_oct_m
30 use types_oct_m
31 use xc_oct_m
32
33 implicit none
34
35 private
36
37 public :: &
45
46 type vtau_mixer_t
47 private
48 logical :: apply = .false.
49
50 type(mixfield_t) :: field
51 end type vtau_mixer_t
52
53contains
54
55 ! ---------------------------------------------------------
56 subroutine vtau_mixer_init_auxmixer(namespace, mixer, smix, hm, np, nspin)
57 type(namespace_t), intent(in) :: namespace
58 type(vtau_mixer_t), intent(inout) :: mixer
59 type(mix_t), intent(inout) :: smix
60 type(hamiltonian_elec_t), intent(in) :: hm
61 integer, intent(in) :: np
62 integer, intent(in) :: nspin
63
65
66 if (family_is_mgga_with_exc(hm%xc) .and. hm%theory_level == generalized_kohn_sham_dft) then
67
68 mixer%apply = .true.
69
70 call mixfield_init(smix, mixer%field, np, nspin, mix_d3(smix), type_float)
71 call mixfield_clear(mix_scheme(smix), mixer%field)
72 call mix_add_auxmixfield(namespace, smix, mixer%field)
73
74 else
75 mixer%apply = .false.
76 end if
77
79 end subroutine vtau_mixer_init_auxmixer
80
81 ! ---------------------------------------------------------
82 subroutine vtau_mixer_clear(mixer, smix)
83 type(vtau_mixer_t), intent(inout) :: mixer
84 type(mix_t), intent(inout) :: smix
85
86 if (.not. mixer%apply) return
87 push_sub(vtau_mixer_clear)
88
89 call mixfield_clear(mix_scheme(smix), mixer%field)
90
91 pop_sub(vtau_mixer_clear)
92 end subroutine vtau_mixer_clear
93
94 ! ---------------------------------------------------------
95 subroutine vtau_mixer_end(mixer, smix)
96 type(vtau_mixer_t), intent(inout) :: mixer
97 type(mix_t), intent(inout) :: smix
98
99 if (.not. mixer%apply) return
100 push_sub(vtau_mixer_end)
101
102 call mixfield_end(smix, mixer%field)
103 mixer%apply = .false.
104
105 pop_sub(vtau_mixer_end)
106 end subroutine vtau_mixer_end
107
108 ! ---------------------------------------------------------
109 subroutine vtau_mixer_set_vout(mixer, hm)
110 type(vtau_mixer_t), intent(inout) :: mixer
111 type(hamiltonian_elec_t), intent(in) :: hm
112
113 if (.not. mixer%apply) return
115
116 call vtau_set_vout(mixer%field, hm%ks_pot)
117
118 pop_sub(vtau_mixer_set_vout)
119 end subroutine vtau_mixer_set_vout
120
121 ! ---------------------------------------------------------
122 subroutine vtau_mixer_set_vin(mixer, hm)
123 type(vtau_mixer_t), intent(inout) :: mixer
124 type(hamiltonian_elec_t), intent(in) :: hm
125
126 if (.not. mixer%apply) return
127 push_sub(vtau_mixer_set_vin)
128
129 call vtau_set_vin(mixer%field, hm%ks_pot)
130
131 pop_sub(vtau_mixer_set_vin)
132 end subroutine vtau_mixer_set_vin
133
134 ! ---------------------------------------------------------
135 subroutine vtau_mixer_get_vnew(mixer, hm)
136 type(vtau_mixer_t), intent(in) :: mixer
137 type(hamiltonian_elec_t), intent(inout) :: hm
138
139 if (.not. mixer%apply) return
140 push_sub(vtau_mixer_get_vnew)
142 call vtau_get_vnew(mixer%field, hm%ks_pot)
144 pop_sub(vtau_mixer_get_vnew)
145 end subroutine vtau_mixer_get_vnew
146
147
148end module vtau_mixer_oct_m
A module to handle KS potential, without the external potential.
subroutine, public vtau_set_vin(field, this)
subroutine, public vtau_set_vout(field, this)
subroutine, public vtau_get_vnew(field, this)
integer, parameter, public generalized_kohn_sham_dft
subroutine, public mixfield_end(smix, mixfield)
Deallocate all arrays of a mixfield instance.
Definition: mix.F90:906
integer pure function, public mix_scheme(this)
Definition: mix.F90:806
subroutine, public mixfield_init(smix, mixfield, d1, d2, d3, func_type)
Initialise all attributes of a mixfield instance.
Definition: mix.F90:860
subroutine, public mix_add_auxmixfield(namespace, smix, mixfield)
Definition: mix.F90:841
subroutine, public mixfield_clear(scheme, mixfield)
Zero all potential and field attributes of a mixfield instance.
Definition: mix.F90:943
integer pure function, public mix_d3(this)
Definition: mix.F90:812
type(type_t), parameter, public type_float
Definition: types.F90:133
subroutine, public vtau_mixer_end(mixer, smix)
Definition: vtau_mixer.F90:189
subroutine, public vtau_mixer_init_auxmixer(namespace, mixer, smix, hm, np, nspin)
Definition: vtau_mixer.F90:150
subroutine, public vtau_mixer_set_vout(mixer, hm)
Definition: vtau_mixer.F90:203
subroutine, public vtau_mixer_get_vnew(mixer, hm)
Definition: vtau_mixer.F90:229
subroutine, public vtau_mixer_clear(mixer, smix)
Definition: vtau_mixer.F90:176
subroutine, public vtau_mixer_set_vin(mixer, hm)
Definition: vtau_mixer.F90:216
Definition: xc.F90:114
logical pure function, public family_is_mgga_with_exc(xcs)
Is the xc function part of the mGGA family with an energy functional.
Definition: xc.F90:595
int true(void)