79 integer :: in_file, out_file, ref_file, ii, jj, kk
80 integer :: time_steps, time_steps_ref, energy_steps, istart, iend, ntiter
81 real(real64) :: dt, dt_ref, tt, ww, norm_Aext
82 real(real64),
allocatable :: vecpot(:, :), Aext(:), Eind_real(:, :), Eind_imag(:, :)
83 complex(real64),
allocatable :: dielectric(:), chi(:), invdielectric(:)
84 real(real64),
allocatable :: vecpot_ref(:, :)
85 type(spectrum_t) :: spectrum
87 type(space_t) :: space
88 type(lattice_vectors_t) :: latt
89 type(batch_t) :: vecpotb, Eind_realb, Eind_imagb
90 character(len=120) :: header
91 real(real64) :: start_time
92 character(len=MAX_PATH_LEN) :: ref_filename
93 complex(real64),
allocatable :: Eind(:)
100 safe_allocate(aext(1:space%dim))
101 safe_allocate(eind(1:space%dim))
113 message(1) =
"Cannot find the GaugeVectorField in the input file"
118 if(space%dim > 1)
then
119 message(1) =
"This program assumes that the gauge field is along a "
120 message(2) =
"direction for which the dielectric tensor has no off-diagonal terms."
121 message(3) =
"If this is not the case the dielectric function and the"
126 start_time = spectrum%start_time
130 if (in_file < 0)
then
142 spectrum%start_time = ceiling(spectrum%start_time/dt)*dt
159 ref_file =
io_open(trim(ref_filename)//
'/gauge_field',
global_namespace, action=
'read', status=
'old', die=.false.)
160 if (ref_file < 0)
then
161 message(1) =
"Cannot open reference file '"// &
167 if (time_steps_ref < time_steps)
then
168 message(1) =
"The reference calculation does not contain enought time steps"
172 if (.not.
is_close(dt_ref, dt))
then
173 message(1) =
"The time step of the reference calculation is different from the current calculation"
180 time_steps = time_steps + 1
182 safe_allocate(vecpot(1:time_steps, 1:space%dim*3))
186 do ii = 1, time_steps
187 read(in_file, *) jj, tt, (vecpot(ii, kk), kk = 1, space%dim*3)
194 time_steps_ref = time_steps_ref + 1
195 safe_allocate(vecpot_ref(1:time_steps_ref, 1:space%dim*3))
197 do ii = 1, time_steps_ref
198 read(ref_file, *) jj, tt, (vecpot_ref(ii, kk), kk = 1, space%dim*3)
201 do ii = 1, time_steps
202 do kk = 1, space%dim*3
203 vecpot(ii, kk) = vecpot(ii, kk) - vecpot_ref(ii, kk)
208 write(
message(1),
'(a, i7, a)')
"Info: Read ", time_steps,
" steps from file '"// &
222 norm_aext = norm2(aext(1:space%dim))
224 safe_allocate(eind_real(1:energy_steps, 1:space%dim))
225 safe_allocate(eind_imag(1:energy_steps, 1:space%dim))
228 call batch_init(vecpotb, 1, 1, space%dim, vecpot(:, space%dim+1:space%dim*2))
229 call batch_init(eind_realb, 1, 1, space%dim, eind_real)
230 call batch_init(eind_imagb, 1, 1, space%dim, eind_imag)
232 call spectrum_signal_damp(spectrum%damp, spectrum%damp_factor, istart, iend, spectrum%start_time, dt, vecpotb)
235 istart, iend, spectrum%start_time, dt, vecpotb, spectrum%min_energy, &
236 spectrum%max_energy, spectrum%energy_step, eind_realb)
239 istart, iend, spectrum%start_time, dt, vecpotb, spectrum%min_energy, &
240 spectrum%max_energy, spectrum%energy_step, eind_imagb)
244 call eind_realb%end()
245 call eind_imagb%end()
247 safe_allocate(invdielectric(1:energy_steps))
248 safe_allocate(dielectric(1:energy_steps))
249 safe_allocate(chi(1:energy_steps))
251 do kk = 1, energy_steps
252 ww = (kk-1)*spectrum%energy_step + spectrum%min_energy
259 eind = cmplx(eind_real(kk, 1:space%dim), eind_imag(kk, 1:space%dim), real64)
260 invdielectric(kk) = dot_product(aext, aext + eind) /norm_aext**2
262 dielectric(kk) =
m_one / invdielectric(kk)
268 write(header,
'(7a15)')
'# energy',
'Re',
'Im'
270 write(out_file,
'(a)') trim(header)
271 do kk = 1, energy_steps
272 ww = (kk-1)*spectrum%energy_step + spectrum%min_energy
273 write(out_file,
'(e15.6)', advance=
'no') ww
274 write(out_file,
'(2e15.6)', advance=
'no') real(invdielectric(kk), real64), aimag(invdielectric(kk))
275 write(out_file,
'()')
280 write(out_file,
'(a)') trim(header)
281 do kk = 1, energy_steps
282 ww = (kk-1)*spectrum%energy_step + spectrum%min_energy
283 write(out_file,
'(e15.6)', advance=
'no') ww
284 write(out_file,
'(2e15.6)', advance=
'no') real(dielectric(kk), real64), aimag(dielectric(kk))
285 write(out_file,
'()')
290 write(out_file,
'(a)') trim(header)
291 do kk = 1, energy_steps
292 ww = (kk-1)*spectrum%energy_step + spectrum%min_energy
293 write(out_file,
'(e15.6)', advance=
'no') ww
294 write(out_file,
'(2e15.6)', advance=
'no') real(chi(kk), real64), aimag(chi(kk))
295 write(out_file,
'()')
299 safe_deallocate_a(dielectric)
300 safe_deallocate_a(invdielectric)
301 safe_deallocate_a(chi)
302 safe_deallocate_a(vecpot)
303 safe_deallocate_a(vecpot_ref)
304 safe_deallocate_a(aext)
305 safe_deallocate_a(eind)
306 safe_deallocate_a(eind_real)
307 safe_deallocate_a(eind_imag)
subroutine dielectric_function_compute()
program dielectric_function
A utility used to obtain the dielectric function from a kick calculation using the gauge field approa...
initialize a batch with existing memory
This module implements batches of mesh functions.
subroutine, public getopt_init(ierr)
Initializes the getopt machinery. Must be called before attempting to parse the options....
subroutine, public getopt_end
subroutine, public global_end()
Finalise parser varinfo file, and MPI.
real(real64), parameter, public m_four
real(real64), parameter, public m_pi
some mathematical constants
type(mpi_comm), parameter, public serial_dummy_comm
Alias MPI_COMM_UNDEFINED for the specific use case of initialising Octopus utilities with no MPI supp...
subroutine, public init_octopus_globals(comm)
Initialise Octopus-specific global constants and files. This routine performs no initialisation calls...
real(real64), parameter, public m_one
subroutine, public io_init(defaults)
If the argument defaults is present and set to true, then the routine will not try to read anything f...
subroutine, public io_close(iunit, grp)
subroutine, public io_skip_header(iunit)
subroutine, public io_end()
character(len=max_path_len) function, public io_workpath(path, namespace)
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
This module is intended to contain "only mathematical" functions and procedures.
subroutine, public messages_end()
subroutine, public messages_init(output_dir)
subroutine, public messages_warning(no_lines, all_nodes, namespace)
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, all_nodes, namespace)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
type(namespace_t), public global_namespace
logical function, public parse_is_defined(namespace, name)
subroutine, public parser_init()
Initialise the Octopus parser.
subroutine, public parser_end()
End the Octopus parser.
integer function, public parse_block(namespace, name, blk, check_varinfo_)
subroutine, public profiling_end(namespace)
subroutine, public profiling_init(namespace)
Create profiling subdirectory.
subroutine, public spectrum_fix_time_limits(spectrum, time_steps, dt, istart, iend, ntiter)
subroutine, public spectrum_fourier_transform(method, transform, noise, time_start, time_end, t0, time_step, time_function, energy_start, energy_end, energy_step, energy_function)
Computes the sine, cosine, (or "exponential") Fourier transform of the real function given in the tim...
subroutine, public spectrum_init(spectrum, namespace, default_energy_step, default_max_energy)
subroutine, public spectrum_signal_damp(damp_type, damp_factor, time_start, time_end, t0, time_step, time_function)
integer, parameter, public spectrum_transform_cos
integer, parameter, public spectrum_transform_sin
subroutine, public spectrum_count_time_steps(namespace, iunit, time_steps, dt)
pure integer function, public spectrum_nenergy_steps(spectrum)
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
This module defines the unit system, used for input and output.
subroutine, public unit_system_init(namespace)