41 integer :: in_file, out_file, ref_file, ii, jj, kk, ierr, ib, num_col, num_col_cart
42 integer :: time_steps, time_steps_ref, energy_steps, istart, iend, ntiter, iq
43 real(real64) :: dt, tt, ww, dt_ref
44 real(real64),
allocatable :: ftreal(:,:), ftimag(:,:)
45 real(real64),
allocatable :: m_cart(:,:), m_cart_ref(:,:), magnetization(:,:,:)
46 type(spectrum_t) :: spectrum
47 type(batch_t) :: vecpotb, ftrealb, ftimagb
49 character(len=256) :: header
50 character(len=MAX_PATH_LEN) :: fname, ref_filename
51 complex(real64),
allocatable :: chi(:,:)
83 time_steps = time_steps + 1
85 num_col_cart = 12*kick%nqvec
86 safe_allocate(m_cart(1:time_steps, 1:num_col_cart))
91 read(in_file, *) jj, tt, (m_cart(ii,ib),ib = 1, num_col_cart)
111 ref_file =
io_open(trim(ref_filename)//
'/total_magnetization',
global_namespace, action=
'read', status=
'old', die=.false.)
112 if (ref_file < 0)
then
113 message(1) =
"Cannot open reference file '"// &
119 time_steps_ref = time_steps_ref + 1
121 if (time_steps_ref < time_steps)
then
122 message(1) =
"The reference calculation does not contain enought time steps"
126 if (.not.
is_close(dt_ref, dt))
then
127 message(1) =
"The time step of the reference calculation is different from the current calculation"
132 safe_allocate(m_cart_ref(1:time_steps_ref, 1:num_col_cart))
134 do ii = 1, time_steps_ref
135 read(ref_file, *) jj, tt, (m_cart_ref(ii, kk), kk = 1, num_col_cart)
138 do ii = 1, time_steps
139 do kk = 1, num_col_cart
140 m_cart(ii, kk) = m_cart(ii, kk) - m_cart_ref(ii, kk)
143 safe_deallocate_a(m_cart_ref)
150 safe_allocate(magnetization(1:time_steps, 1:num_col, 1:kick%nqvec))
152 do iq = 1, kick%nqvec
154 magnetization(:,1,iq) = m_cart(:,(iq-1)*12+1)*kick%trans_vec(1,1) &
155 + m_cart(:,(iq-1)*12+3)*kick%trans_vec(2,1) &
156 + m_cart(:,(iq-1)*12+5)*kick%trans_vec(3,1)
158 magnetization(:,1,iq) = magnetization(:,1,iq) -(m_cart(:,(iq-1)*12+2)*kick%trans_vec(1,2) &
159 + m_cart(:,(iq-1)*12+4)*kick%trans_vec(2,2) &
160 + m_cart(:,(iq-1)*12+6)*kick%trans_vec(3,2))
163 magnetization(:,2,iq) = m_cart(:,(iq-1)*12+2)*kick%trans_vec(1,1) &
164 + m_cart(:,(iq-1)*12+4)*kick%trans_vec(2,1) &
165 + m_cart(:,(iq-1)*12+6)*kick%trans_vec(3,1)
167 magnetization(:,2,iq) = magnetization(:,2,iq) +(m_cart(:,(iq-1)*12+1)*kick%trans_vec(1,2) &
168 + m_cart(:,(iq-1)*12+3)*kick%trans_vec(2,2) &
169 + m_cart(:,(iq-1)*12+5)*kick%trans_vec(3,2))
172 magnetization(:,3,iq) = m_cart(:,(iq-1)*12+7)*kick%trans_vec(1,1) &
173 + m_cart(:,(iq-1)*12+9)*kick%trans_vec(2,1) &
174 + m_cart(:,(iq-1)*12+11)*kick%trans_vec(3,1)
176 magnetization(:,3,iq) = magnetization(:,3,iq) +(m_cart(:,(iq-1)*12+8)*kick%trans_vec(1,2) &
177 + m_cart(:,(iq-1)*12+10)*kick%trans_vec(2,2) &
178 + m_cart(:,(iq-1)*12+12)*kick%trans_vec(3,2))
181 magnetization(:,4,iq) = m_cart(:,(iq-1)*12+8)*kick%trans_vec(1,1) &
182 + m_cart(:,(iq-1)*12+10)*kick%trans_vec(2,1) &
183 + m_cart(:,(iq-1)*12+12)*kick%trans_vec(3,1)
185 magnetization(:,4,iq) = magnetization(:,4,iq) -(m_cart(:,(iq-1)*12+7)*kick%trans_vec(1,2) &
186 + m_cart(:,(iq-1)*12+9)*kick%trans_vec(2,2) &
187 + m_cart(:,(iq-1)*12+11)*kick%trans_vec(3,2))
190 magnetization(:,5,iq) = m_cart(:,(iq-1)*12+1)*kick%easy_axis(1) &
191 + m_cart(:,(iq-1)*12+3)*kick%easy_axis(2) &
192 + m_cart(:,(iq-1)*12+5)*kick%easy_axis(3)
193 magnetization(:,6,iq) = m_cart(:,(iq-1)*12+2)*kick%easy_axis(1) &
194 + m_cart(:,(iq-1)*12+4)*kick%easy_axis(2) &
195 + m_cart(:,(iq-1)*12+6)*kick%easy_axis(3)
196 magnetization(:,7,iq) = m_cart(:,(iq-1)*12+7)*kick%easy_axis(1) &
197 + m_cart(:,(iq-1)*12+9)*kick%easy_axis(2) &
198 + m_cart(:,(iq-1)*12+11)*kick%easy_axis(3)
199 magnetization(:,8,iq) = m_cart(:,(iq-1)*12+8)*kick%easy_axis(1) &
200 + m_cart(:,(iq-1)*12+10)*kick%easy_axis(2) &
201 + m_cart(:,(iq-1)*12+12)*kick%easy_axis(3)
204 safe_deallocate_a(m_cart)
206 write(
message(1),
'(a, i7, a)')
"Info: Read ", time_steps,
" steps from file '"// &
210 write(header,
'(9a15)')
'# time',
'Re[m_+(q,t)]',
'Im[m_+(q,t)]', &
211 'Re[m_-(-q, t)]',
'Im[m_-(-q,t)]', &
212 'Re[m_z(q,t)]',
'Im[m_z(q,t)]',
'Re[m_z(-q,t)]',
'Im[m_z(-q,t)]'
214 do iq = 1, kick%nqvec
216 write(fname,
'(a,i3.3)')
'td.general/transverse_magnetization_q', iq
218 write(out_file,
'(a)') trim(header)
219 do kk = 1, time_steps
220 write(out_file,
'(9e15.6)') (kk - 1)*dt, (magnetization(kk,ii,iq), ii = 1,8)
228 istart = max(1, istart)
232 safe_allocate(ftreal(1:energy_steps, 1:num_col))
233 safe_allocate(ftimag(1:energy_steps, 1:num_col))
235 call batch_init(vecpotb, 1, 1, num_col, magnetization(:, :, iq))
236 call batch_init(ftrealb, 1, 1, num_col, ftreal)
237 call batch_init(ftimagb, 1, 1, num_col, ftimag)
240 call spectrum_signal_damp(spectrum%damp, spectrum%damp_factor, istart, iend, spectrum%start_time, dt, vecpotb)
243 istart, iend, spectrum%start_time, dt, vecpotb, spectrum%min_energy, &
244 spectrum%max_energy, spectrum%energy_step, ftrealb)
247 istart, iend, spectrum%start_time, dt, vecpotb, spectrum%min_energy, &
248 spectrum%max_energy, spectrum%energy_step, ftimagb)
256 safe_allocate(chi(1:energy_steps, 1:num_col/2))
258 do kk = 1, energy_steps
259 chi(kk,ii) = (ftreal(kk,(ii-1)*2+1) +
m_zi*ftimag(kk, (ii-1)*2+1)&
260 -ftimag(kk, (ii-1)*2+2) +
m_zi*ftreal(kk, (ii-1)*2+2))/kick%delta_strength
264 safe_deallocate_a(ftreal)
265 safe_deallocate_a(ftimag)
268 write(header,
'(9a18)')
'# energy',
'Re[\chi_{+-}(q)]',
'Im[\chi_{+-}(q)]', &
269 'Re[\chi_{-+}(-q)]',
'Im[\chi_{-+}(-q)]', &
270 'Re[\chi_{zz}(q)]',
'Im[\chi_{zz}(q)]',
'Re[\chi_{zz}(-q)]',
'Im[\chi_{zz}(-q)]'
272 write(fname,
'(a,i3.3)')
'td.general/spin_susceptibility_q', iq
274 write(out_file,
'(a)') trim(header)
275 do kk = 1, energy_steps
276 ww = (kk-1)*spectrum%energy_step + spectrum%min_energy
277 write(out_file,
'(13e15.6)') ww, &
278 (real(chi(kk,ii), real64), aimag(chi(kk,ii)), ii = 1, num_col/2)
282 safe_deallocate_a(chi)
285 safe_deallocate_a(magnetization)
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.
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...
complex(real64), parameter, public m_zi
real(real64), parameter, public m_epsilon
real(real64), parameter, public m_half
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)
subroutine, public kick_read(kick, iunit, namespace)
subroutine, public kick_end(kick)
This module is intended to contain "only mathematical" functions and procedures.
subroutine, public messages_end()
subroutine, public messages_init(output_dir)
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.
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)
program spin_susceptibility