28 use,
intrinsic :: iso_fortran_env
48 type casida_spectrum_t
49 real(real64) :: br, energy_step, min_energy, max_energy
51 end type casida_spectrum_t
53 integer :: ierr, idir, jdir, iatom
54 type(space_t) :: space
55 type(casida_spectrum_t) :: cs
56 real(real64),
allocatable :: rotation(:,:), rot2(:,:), identity(:,:), coord(:)
58 type(ions_t),
pointer :: ions
74 allocate(rotation(space%dim, space%dim))
75 allocate(rot2(space%dim, space%dim))
76 allocate(identity(space%dim, space%dim))
77 allocate(coord(space%dim))
82 cs%ispin = min(2, cs%ispin)
129 do idir = 1, space%dim
130 identity(idir, idir) =
m_one
143 do idir = 1, space%dim
144 do jdir = 1, space%dim
150 message(1) =
"Info: Applying rotation matrix"
155 rot2(:,:) = abs(matmul(transpose(rotation), rotation))
156 if (any(abs(rot2(:,:) - identity(:,:)) > 1e-6_real64))
then
157 write(
message(1),
'(a,es13.6)')
"Rotation matrix is not orthogonal. max discrepancy in product = ", &
158 maxval(abs(rot2(:,:) - identity(:,:)))
164 do iatom = 1, ions%natoms
165 coord = ions%pos(:, iatom)
166 ions%pos(:, iatom) = matmul(rotation, coord)
168 call ions%write_xyz(trim(
casida_dir)//
'rotated')
169 safe_deallocate_p(ions)
171 rotation(:,:) = identity(:,:)
195 subroutine calc_broad(cs, dir, fname, extracols)
196 type(casida_spectrum_t),
intent(in) :: cs
197 character(len=*),
intent(in) :: dir
198 character(len=*),
intent(in) :: fname
199 logical,
intent(in) :: extracols
201 real(real64),
allocatable :: spectrum(:,:)
202 real(real64) :: omega, energy, re_tm(space%dim), im_tm(space%dim), ff(space%dim+1), tm_sq(space%dim)
203 integer :: istep, nsteps, iunit, trash(3), idir, ncols, ios
204 character(len=256) :: string
205 logical :: is_complex
209 nsteps = int((cs%max_energy - cs%min_energy) / cs%energy_step)
210 safe_allocate(spectrum(1:space%dim+1, 1:nsteps))
214 if (iunit == -1)
then
215 message(1) =
'Cannot open file "'//trim(dir)//trim(fname)//
'".'
216 message(2) =
'The '//trim(fname)//
' spectrum was not generated.'
226 ncols = ncols + cs%ispin
231 read(iunit,
'(a)') string
233 read(string, *, iostat = ios) trash(1:ncols), energy, (re_tm(idir), im_tm(idir), idir = 1, space%dim), ff(space%dim+1)
234 is_complex = (ios == 0)
240 read(iunit, *, iostat = ios) trash(1:ncols), energy, (re_tm(idir), im_tm(idir), idir = 1, space%dim), ff(space%dim+1)
243 read(iunit, *, iostat = ios) trash(1:ncols), energy, (re_tm(idir), idir = 1, space%dim), ff(space%dim+1)
250 else if (ios > 0)
then
251 message(1) =
"Error parsing file " // trim(fname)
258 tm_sq = (matmul(rotation, re_tm))**2
260 tm_sq = tm_sq + (matmul(rotation, im_tm))**2
262 ff(1:space%dim) =
m_two * energy * tm_sq
265 omega = cs%min_energy + real(istep-1, real64) *cs%energy_step
266 spectrum(:, istep) = spectrum(:, istep) + ff*cs%br/((omega-energy)**2 + cs%br**2)/
m_pi
275 do idir = 1, space%dim
278 write(iunit,
'(a14)')
'<f>'
287 safe_deallocate_a(spectrum)
subroutine calc_broad(cs, dir, fname, extracols)
Each program/utility that needs to use the getopt features should have an interface here – the defini...
Prints out to iunit a message in the form: ["InputVariable" = value] where "InputVariable" is given b...
subroutine, public casida_spectrum_main()
This module provides an interface to the getopt C library, so that the command line arguments can be ...
subroutine, public getopt_init(ierr)
Initializes the getopt machinery. Must be called before attempting to parse the options....
subroutine, public getopt_end
real(real64), parameter, public m_two
subroutine, public global_end()
Finalise parser varinfo file, and MPI.
real(real64), parameter, public m_zero
character(len= *), parameter, public casida_dir
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_end()
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
subroutine, public messages_end()
subroutine, public messages_init(output_dir)
subroutine, public messages_warning(no_lines, 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)
subroutine, public messages_input_error(namespace, var, details, row, column)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
type(mpi_grp_t), public mpi_world
type(namespace_t), public global_namespace
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_)
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
subroutine, public profiling_end(namespace)
subroutine, public profiling_init(namespace)
Create profiling subdirectory.
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
character(len=20) pure function, public units_abbrev(this)
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
subroutine, public unit_system_init(namespace)
type(unit_system_t), public units_inp
the units systems for reading and writing
type(unit_t), public unit_one
some special units required for particular quantities
This module is intended to contain simple general-purpose utility functions and procedures.
subroutine, public output_tensor(tensor, ndim, unit, write_average, iunit, namespace)
character pure function, public index2axis(idir)