Octopus
wannier_opts.F90
Go to the documentation of this file.
1!! Copyright (C) A Buccheri, J Reimann. 2026
2!!
3!! This Source Code Form is subject to the terms of the Mozilla Public
4!! License, v. 2.0. If a copy of the MPL was not distributed with this
5!! file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
7#include "global.h"
8
13 use, intrinsic :: iso_fortran_env
14
15 use debug_oct_m
16 use global_oct_m
17 use io_oct_m
20 use parser_oct_m
22
23 implicit none
24 private
25
26 public :: &
30
31 integer, parameter, public :: &
32 TD_WANNIER_METHOD_NONE = 0, &
34
41 type :: wannier_opts_t
42 integer :: num_bands = 0
43 integer :: num_wann = 0
44 logical :: use_scdm
45 real(real64) :: scdm_mu
46 real(real64) :: scdm_sigma
47 real(real64) :: threshold
48 character(len=80) :: prefix
49 integer :: restart_from
50 logical :: plot
51 logical :: wannierize
52 logical :: calc_overlaps
53 logical :: dump_inputs
54 logical :: spinors = .false.
55 integer, allocatable :: spin_proj_component(:)
56
57 ! TD-related options
58 integer :: td_output_interval
59 integer :: td_method
60
61 contains
62 procedure :: parse_oct => wannier_opts_parse_oct
63 procedure :: parse_win => wannier_opts_parse_win
64 end type wannier_opts_t
65
66contains
67
69 subroutine wannier_opts_parse_oct(this, namespace)
70 class(wannier_opts_t), intent(inout) :: this
71 type(namespace_t), intent(in) :: namespace
72
73 logical :: read_from_td
74
76
77 !%Variable Wannier90Prefix
78 !%Type string
79 !%Default w90
80 !%Section Utilities::oct-wannier90
81 !%Description
82 !% Prefix for wannier90 files. Used by both oct-wannier90 and oct-wannier90lib
83 !% as well as the time-dependent Wannier workflow.
84 !%End
85 call parse_variable(namespace, 'Wannier90Prefix', 'w90', this%prefix)
86
87 !%Variable Wannier90UseTD
88 !%Type logical
89 !%Default no
90 !%Section Utilities::oct-wannier90
91 !%Description
92 !% This variable controls which states are used as input into the standalone utilities
93 !% oct-wannier90 and oct-wannier90lib.
94 !% By default oct-wannier90 uses the ground-state states.
95 !% By setting this variable to yes, oct-wannier90 will use the TD states instead.
96 !% This parameter does not apply to the time-dependent Wannier workflow.
97 !%End
98 call parse_variable(global_namespace, 'Wannier90UseTD', .false., read_from_td)
99 if (read_from_td) then
100 this%restart_from = restart_td
101 else
102 this%restart_from = restart_gs
103 end if
104
105 !%Variable Wannier90DumpFiles
106 !%Type logical
107 !%Default no
108 !%Section Utilities::oct-wannier90lib
109 !%Description
110 !% Whether or not to dump intermediate files to disk.
111 !% This applies only to the oct-wannierlib utility.
112 !% Files are: .amn, .mmn, .eig and .win with inputs.
113 !%End
114 call parse_variable(global_namespace, 'Wannier90DumpFiles', .false., this%dump_inputs)
115
116 !%Variable Wannier90Wannierize
117 !%Type logical
118 !%Default yes
119 !%Section Utilities::oct-wannier90lib
120 !%Description
121 !% Whether or not to perform the wannierization step (including disentanglement).
122 !% This applies only to the standalone utility oct-wannier90lib.
123 !%End
124 call parse_variable(global_namespace, 'Wannier90Wannierize', .true., this%wannierize)
125
126 !%Variable Wannier90Plot
127 !%Type logical
128 !%Default no
129 !%Section Utilities::oct-wannier90lib
130 !%Description
131 !% If set to yes, oct-wannier90lib will generate the wannier functions on a real space
132 !% grid and write them to file.
133 !%End
134 call parse_variable(global_namespace, 'Wannier90Plot', .false., this%plot)
135
136 !%Variable Wannier90CalcOverlaps
137 !%Type logical
138 !%Default no
139 !%Section Utilities::oct-wannier90lib
140 !%Description
141 !% Whether or not to calculate the amn and mmn matrices from octopus states.
142 !% By setting this variable to no, oct-wannier90 will attempt to read them from files.
143 !% This applies only to the standalone utility oct-wannier90lib.
144 !%End
145 call parse_variable(global_namespace, 'Wannier90CalcOverlaps', .false., this%calc_overlaps)
147 !%Variable Wannier90UseSCDM
148 !%Type logical
149 !%Default no
150 !%Section Utilities::oct-wannier90
151 !%Description
152 !% By default oct-wannier90 and oct-wannier90lib use the projection method to generate the .amn file.
153 !% By setting this variable to yes, they will use the SCDM method instead.
154 !%End
155 call parse_variable(namespace, 'Wannier90UseSCDM', .false., this%use_scdm)
156 if (this%use_scdm) then
157 !%Variable SCDMsigma
158 !%Type float
159 !%Default 0.2
160 !%Section Utilities::oct-wannier90
161 !%Description
162 !% Broadening of SCDM smearing function.
163 !%End
164 call parse_variable(namespace, 'SCDMsigma', 0.2_real64, this%scdm_sigma)
165
166 !%Variable SCDMmu
167 !%Type float
168 !%Section Utilities::oct-wannier90
169 !%Description
170 !% Energy range up to which states are considered for SCDM.
171 !%End
172 call parse_variable(namespace, 'SCDMmu', m_huge, this%scdm_mu)
173 end if
174
175 ! We use the variable AOThreshold to deterine the threshold on the radii of the atomic orbitals
176 ! TODO: Have the threshold for wannier functions different than for AO
177 call parse_variable(namespace, 'AOThreshold', 0.001_real64, this%threshold)
178
179 ! TODO: Parse the exclude_bands variable correctly from .win file here!
180
181 !%Variable TDWannierMethod
182 !%Type integer
183 !%Default 0
184 !%Section Time-Dependent
185 !%Description
186 !% Specifies which method to use for TD Wannier calculations.
187 !%Option none 0
188 !% TD Wannier functionality is disabled.
189 !%Option wannier90 1
190 !% Performs a full wannierization of the time-dependent Kohn-Sham states to update the U matrix.
191 !%End
192 call parse_variable(namespace, 'TDWannierMethod', 0, this%td_method)
193 if (this%td_method /= td_wannier_method_none) then
194 message(1) = 'Time-dependent Wannierization enabled, but not yet implemented.'
195 call messages_warning(1)
196 end if
197
198 !%Variable TDWannierOutputInterval
199 !%Type integer
200 !%Default 1
201 !%Section Time-Dependent::TD Output
202 !%Description
203 !% If TDWannierMethod is enabled, Wannier-related output is written
204 !% every TDWannierOutputInterval iterations.
205 !%End
206 call parse_variable(namespace, 'TDWannierOutputInterval', 1, this%td_output_interval)
207
209
210 end subroutine wannier_opts_parse_oct
211
221 subroutine wannier_opts_parse_win(this)
222 class(wannier_opts_t), intent(inout) :: this
223
224 character(len=80) :: filename, line, dummy, dummy1, dummy2
225 integer :: w90_win, io, tmp_int
226 logical :: exist
227
228 push_sub(wannier_opts_parse_win)
229
230 filename = trim(adjustl(this%prefix)) //'.win'
231 inquire(file=filename,exist=exist)
232 if (.not. exist) then
233 message(1) = 'Cannot find specified Wannier90 win file.'
234 call messages_fatal(1)
235 else
236 message(1) = 'Reading file '//filename
237 w90_win = io_open(trim(filename), action='read')
238 do
239 read(w90_win, '(A)', iostat=io) line
240 if (is_iostat_end(io)) exit
241
242 if (index(line, '=') > 0) then
243 read(line, *, iostat=io) dummy, dummy2, dummy1
244 else
245 read(line, *, iostat=io) dummy, dummy1
246 end if
247 if (dummy == 'num_bands') then
248 read(dummy1, *, iostat=io) tmp_int
249 this%num_bands = tmp_int
250 else if (dummy == 'num_wann') then
251 read(dummy1, *, iostat=io) tmp_int
252 this%num_wann = tmp_int
253 end if
254 end do
255 call io_close(w90_win)
256 end if
257
259
260 end subroutine wannier_opts_parse_win
261
262end module wannier_opts_oct_m
real(real64), parameter, public m_huge
Definition: global.F90:218
Definition: io.F90:116
subroutine, public io_close(iunit, grp)
Definition: io.F90:467
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
Definition: io.F90:402
subroutine, public messages_warning(no_lines, all_nodes, namespace)
Definition: messages.F90:525
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:162
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:410
type(namespace_t), public global_namespace
Definition: namespace.F90:135
integer, parameter, public restart_gs
Definition: restart.F90:156
integer, parameter, public restart_td
Definition: restart.F90:156
Wannier options module.
integer, parameter, public td_wannier_method_wannier90
subroutine, public wannier_opts_parse_win(this)
Parse required Wannier90 options from wannier90 .win input file.
subroutine, public wannier_opts_parse_oct(this, namespace)
Parse Wannier90 related options from octopus input file.
Wannier related options.
int true(void)