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 end if
75
77 end subroutine vtau_mixer_init_auxmixer
78
79 ! ---------------------------------------------------------
80 subroutine vtau_mixer_clear(mixer, smix)
81 type(vtau_mixer_t), intent(inout) :: mixer
82 type(mix_t), intent(inout) :: smix
83
84 if (.not. mixer%apply) return
85 push_sub(vtau_mixer_clear)
86
87 call mixfield_clear(mix_scheme(smix), mixer%field)
88
89 pop_sub(vtau_mixer_clear)
90 end subroutine vtau_mixer_clear
91
92 ! ---------------------------------------------------------
93 subroutine vtau_mixer_end(mixer, smix)
94 type(vtau_mixer_t), intent(inout) :: mixer
95 type(mix_t), intent(inout) :: smix
96
97 if (.not. mixer%apply) return
98 push_sub(vtau_mixer_end)
99
100 call mixfield_end(smix, mixer%field)
101
102 pop_sub(vtau_mixer_end)
103 end subroutine vtau_mixer_end
104
105 ! ---------------------------------------------------------
106 subroutine vtau_mixer_set_vout(mixer, hm)
107 type(vtau_mixer_t), intent(inout) :: mixer
108 type(hamiltonian_elec_t), intent(in) :: hm
109
110 if (.not. mixer%apply) return
111 push_sub(vtau_mixer_set_vout)
112
113 call vtau_set_vout(mixer%field, hm%ks_pot)
115 pop_sub(vtau_mixer_set_vout)
116 end subroutine vtau_mixer_set_vout
117
118 ! ---------------------------------------------------------
119 subroutine vtau_mixer_set_vin(mixer, hm)
120 type(vtau_mixer_t), intent(inout) :: mixer
121 type(hamiltonian_elec_t), intent(in) :: hm
122
123 if (.not. mixer%apply) return
124 push_sub(vtau_mixer_set_vin)
125
126 call vtau_set_vin(mixer%field, hm%ks_pot)
127
128 pop_sub(vtau_mixer_set_vin)
129 end subroutine vtau_mixer_set_vin
130
131 ! ---------------------------------------------------------
132 subroutine vtau_mixer_get_vnew(mixer, hm)
133 type(vtau_mixer_t), intent(in) :: mixer
134 type(hamiltonian_elec_t), intent(inout) :: hm
135
136 if (.not. mixer%apply) return
137 push_sub(vtau_mixer_get_vnew)
138
139 call vtau_get_vnew(mixer%field, hm%ks_pot)
140
142 end subroutine vtau_mixer_get_vnew
144
145end 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:870
integer pure function, public mix_scheme(this)
Definition: mix.F90:772
subroutine, public mixfield_init(smix, mixfield, d1, d2, d3, func_type)
Initialise all attributes of a mixfield instance.
Definition: mix.F90:826
subroutine, public mix_add_auxmixfield(namespace, smix, mixfield)
Definition: mix.F90:807
subroutine, public mixfield_clear(scheme, mixfield)
Zero all potential and field attributes of a mixfield instance.
Definition: mix.F90:907
integer pure function, public mix_d3(this)
Definition: mix.F90:778
type(type_t), public type_float
Definition: types.F90:133
subroutine, public vtau_mixer_end(mixer, smix)
Definition: vtau_mixer.F90:187
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:200
subroutine, public vtau_mixer_get_vnew(mixer, hm)
Definition: vtau_mixer.F90:226
subroutine, public vtau_mixer_clear(mixer, smix)
Definition: vtau_mixer.F90:174
subroutine, public vtau_mixer_set_vin(mixer, hm)
Definition: vtau_mixer.F90:213
int true(void)