48 use,
intrinsic :: iso_fortran_env
108 integer,
parameter,
public :: &
109 OUT_MULTIPOLES = 1, &
146 character(len=100) :: td_file_name(OUT_MAX) = [character(100) :: &
156 "magnetic_moments", &
171 "total_heat_current", &
172 "total_magnetization", &
174 "maxwell_dipole_field", &
175 "norm_wavefunctions", &
178 integer,
parameter :: &
179 OUT_DFTU_EFFECTIVE_U = 1, &
183 integer,
parameter :: &
184 OUT_MAXWELL_TOTAL_E_FIELD = 1, &
198 integer,
parameter,
public :: &
201 integer,
parameter :: &
202 MAXWELL_TOTAL_FIELD = 1, &
206 integer,
parameter :: &
212 type(c_ptr) :: handle
213 type(c_ptr),
allocatable :: mult_handles(:)
215 integer :: hand_start
217 logical ::
write = .false.
218 logical :: resolve_states = .false.
230 real(real64) :: lmm_r
233 integer :: n_excited_states
235 integer :: compute_interval
245 class(
mesh_t),
intent(in) :: mesh
246 type(
kick_t),
intent(in) :: kick
247 type(
ions_t),
intent(in) :: ions
248 integer,
intent(in) :: iter
250 complex(real64),
allocatable :: kick_function(:)
251 character(len=256) :: filename
256 write(filename,
'(a,i7.7)')
"td.", iter
257 if (outp%what(option__output__delta_perturbation))
then
258 safe_allocate(kick_function(1:mesh%np))
260 call zio_function_output(outp%how(option__output__delta_perturbation), filename,
"kick_function", namespace, &
261 space, mesh, kick_function(:),
units_out%energy, err, pos=ions%pos, atoms=ions%atom)
262 safe_deallocate_a(kick_function)
278 subroutine td_write_init(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, ks, ions_move, &
279 with_gauge_field, kick, iter, max_iter, dt, mc)
283 type(
output_t),
intent(inout) :: outp
284 type(
grid_t),
intent(in) :: gr
287 type(
ions_t),
intent(in) :: ions
289 type(
v_ks_t),
intent(inout) :: ks
290 logical,
intent(in) :: ions_move
291 logical,
intent(in) :: with_gauge_field
292 type(
kick_t),
intent(in) :: kick
293 integer,
intent(in) :: iter
294 integer,
intent(in) :: max_iter
295 real(real64),
intent(in) :: dt
299 integer :: ierr, first, ii, ist, jj, flags, iout, default, ifile
304 character(len=MAX_PATH_LEN) :: filename
306 logical :: resolve_states
307 logical,
allocatable :: skip(:)
450 output_options = .false.
451 output_options(out_multipoles) = .
true.
466 writ%out(iout)%write = output_options(iout)
481 if (space%is_periodic() .and. writ%out(
out_angular)%write)
then
496 if (gr%np /= gr%np_global)
then
497 message(1) =
"TDOutput option td_kpoint_occup and td_floquet do not work with domain parallelization"
504 'Forces for systems periodic in 1D are not currently implemented and options that output the forces are not allowed.')
508 if (writ%out(
out_kp_proj)%write .and. hm%kpoints%nik_skip == 0)
then
509 message(1) =
"TDOutput option td_kpoint_occup only work with zero-weight k-points at the moment."
523 call parse_variable(namespace,
'TDOutputResolveStates', .false., resolve_states)
524 if (.not. writ%out(out_multipoles)%write)
then
525 write(
message(1),
'(a)')
"TDOutputResolveStates works only for TDOutput = multipoles."
538 if (writ%lmax < 0)
then
539 write(
message(1),
'(a,i6,a)')
"Input: '", writ%lmax,
"' is not a valid TDMultipoleLmax."
540 message(2) =
'(Must be TDMultipoleLmax >= 0 )'
546 if ((writ%out(
out_acc)%write) .and. ions_move)
then
547 message(1) =
'If harmonic spectrum is to be calculated, atoms should not be allowed to move.'
551 if ((writ%out(
out_q)%write) .and. .not.(ks%has_photons))
then
552 message(1) =
'If q(t) is to be calculated, you need to allow for photon modes.'
557 .or. hm%mxll%add_electric_dip))
then
558 message(1) =
'If the dipolar field has to be written, MaxwellCouplingMode has to be'
559 message(2) =
'"lenght_gauge_dipole" or "velocity_gauge_dipole" and at least one Maxwell system'
560 message(3) =
'must be present.'
564 rmin = ions%min_distance()
574 message(1) =
"Option TDOutput = populations is not implemented for parallel in states."
586 safe_deallocate_a(writ%gs_st%node)
594 writ%gs_st%st_end = writ%gs_st%nst
596 message(1) =
"Unable to read states information."
600 writ%gs_st%st_start = 1
616 call parse_variable(namespace,
'TDProjStateStart', 1, writ%gs_st%st_start)
618 if (st%parallel_in_states .and. writ%out(
out_proj)%write .and. writ%gs_st%st_start > 1)
then
624 writ%gs_st%lnst = writ%gs_st%st_end - writ%gs_st%st_start + 1
628 writ%gs_st%parallel_in_states = .false.
631 safe_allocate(writ%gs_st%occ(1:writ%gs_st%nst, 1:writ%gs_st%nik))
632 safe_allocate(writ%gs_st%eigenval(1:writ%gs_st%nst, 1:writ%gs_st%nik))
636 safe_allocate(writ%gs_st%node(1:writ%gs_st%nst))
637 writ%gs_st%node(:) = 0
639 writ%gs_st%eigenval = huge(writ%gs_st%eigenval)
641 if (writ%gs_st%d%ispin ==
spinors)
then
642 safe_deallocate_a(writ%gs_st%spin)
643 safe_allocate(writ%gs_st%spin(1:3, 1:writ%gs_st%nst, 1:writ%gs_st%nik))
646 safe_allocate(skip(1:writ%gs_st%nst))
648 skip(1:writ%gs_st%st_start-1) = .
true.
652 safe_deallocate_a(skip)
657 if (ierr /= 0 .and. ierr /= (writ%gs_st%st_end-writ%gs_st%st_start+1)*writ%gs_st%nik &
658 *writ%gs_st%d%dim*writ%gs_st%mpi_grp%size)
then
659 message(1) =
"Unable to read wavefunctions for TDOutput."
704 if (
parse_block(namespace,
'TDExcitedStatesToProject', blk) == 0)
then
706 safe_allocate(writ%excited_st(1:writ%n_excited_states))
707 do ist = 1, writ%n_excited_states
712 writ%n_excited_states = 0
726 call parse_variable(namespace,
'TDOutputComputeInterval', 50, writ%compute_interval)
727 if (writ%compute_interval < 0)
then
728 message(1) =
"TDOutputComputeInterval must be >= 0."
744 call io_mkdir(
'td.general', namespace)
755 do ifile = 1, out_max
759 if (writ%out(ifile)%write)
then
763 trim(
io_workpath(
"td.general/"//trim(td_file_name(ifile)), namespace)))
771 if (writ%out(out_multipoles)%write .and. .not. resolve_states)
then
774 trim(
io_workpath(
"td.general/multipoles", namespace)))
778 select case (kick%qkick_mode)
780 write(filename,
'(a)')
'td.general/ftchd.sin'
782 write(filename,
'(a)')
'td.general/ftchd.cos'
784 write(filename,
'(a, SP, I0.3, a, I0.3)')
'td.general/ftchd.l', kick%qbessel_l,
'_m', kick%qbessel_m
786 write(filename,
'(a)')
'td.general/ftchd'
798 call io_rm(
"td.general/laser", namespace=namespace)
815 if (writ%out(out_multipoles)%write .and. resolve_states)
then
817 writ%out(out_multipoles)%hand_start = st%st_start
818 writ%out(out_multipoles)%hand_end = st%st_end
819 writ%out(out_multipoles)%resolve_states = .
true.
820 writ%out(out_multipoles)%mpi_grp = gr%mpi_grp
822 safe_allocate(writ%out(out_multipoles)%mult_handles(st%st_start:st%st_end))
824 if (writ%out(out_multipoles)%mpi_grp%is_root())
then
825 do ist = st%st_start, st%st_end
826 write(filename,
'(a,i4.4)')
'td.general/multipoles-ist', ist
839 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
840 calc_eigenval=.false., time = iter*dt, calc_energy = .false.)
843 if (writ%out(
out_n_ex)%write .and. writ%compute_interval > 0)
then
844 call io_mkdir(outp%iter_dir, namespace)
847 if (all(outp%how == 0) .and. writ%out(
out_n_ex)%write)
then
869 if (hm%lda_u_level ==
dft_u_acbn0) default = default + 2**(out_dftu_effective_u - 1)
877 writ%out_dftu(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
881 if (writ%out_dftu(out_dftu_effective_u)%write)
then
884 trim(
io_workpath(
"td.general/effectiveU", namespace)))
902 if (writ%out(iout)%write)
then
903 if (writ%out(iout)%mpi_grp%is_root())
then
904 if (writ%out(iout)%resolve_states)
then
905 do ist = writ%out(iout)%hand_start, writ%out(iout)%hand_end
908 safe_deallocate_a(writ%out(iout)%mult_handles)
918 if (writ%out_dftu(iout)%write)
call write_iter_end(writ%out_dftu(iout)%handle)
924 do ist = 1, writ%n_excited_states
927 writ%n_excited_states = 0
940 subroutine td_write_iter(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, kick, ks, dt, iter, mc, recalculate_gs)
943 class(
space_t),
intent(in) :: space
945 type(
grid_t),
intent(in) :: gr
948 type(
ions_t),
intent(inout) :: ions
950 type(
kick_t),
intent(in) :: kick
951 type(
v_ks_t),
intent(in) :: ks
952 real(real64),
intent(in) :: dt
953 integer,
intent(in) :: iter
955 logical,
intent(in) :: recalculate_gs
963 if (writ%out(out_multipoles)%write)
then
964 call td_write_multipole(writ%out(out_multipoles), space, gr, ions, st, writ%lmax, kick, iter)
987 if (writ%out(
out_proj)%write .and. mod(iter, writ%compute_interval) == 0)
then
996 if (writ%out(
out_kp_proj)%write .and. mod(iter, writ%compute_interval) == 0)
then
1002 ions%pos, ions%vel, ions%tot_force, iter)
1007 ions%pos, ions%vel, ions%tot_force, iter, 1)
1012 ions%pos, ions%vel, ions%tot_force, iter, 2)
1017 ions%pos, ions%vel, ions%tot_force, iter, 3)
1028 if (writ%out(
out_acc)%write)
then
1029 call td_write_acc(writ%out(
out_acc)%handle, namespace, space, gr, ions, st, hm, ext_partners, dt, iter)
1032 if (writ%out(
out_vel)%write)
then
1045 if(
associated(gfield))
then
1071 if (writ%out(
out_n_ex)%write .and. mod(iter, writ%compute_interval) == 0)
then
1073 if (recalculate_gs)
then
1076 ierr, label =
': Houston states for TDOutput')
1080 call td_write_n_ex(writ%out(
out_n_ex)%handle, outp, namespace, gr, hm%kpoints, st, writ%gs_st, iter)
1092 if (writ%out_dftu(out_dftu_effective_u)%write)
then
1096 if (writ%out(
out_q)%write .and. ks%has_photons)
then
1100 if (writ%out(
out_mxll_field)%write .and. hm%mxll%calc_field_dip)
then
1117 do iout = 1, out_max
1119 if (writ%out(iout)%write)
then
1120 if (writ%out(iout)%mpi_grp%is_root())
then
1121 if (writ%out(iout)%resolve_states)
then
1122 do ii = writ%out(iout)%hand_start, writ%out(iout)%hand_end
1134 if (writ%out_dftu(iout)%write)
call write_iter_flush(writ%out_dftu(iout)%handle)
1143 subroutine td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, dt)
1146 type(
grid_t),
intent(in) :: gr
1149 type(
v_ks_t),
intent(inout) :: ks
1151 type(
ions_t),
intent(in) :: ions
1153 integer,
intent(in) :: iter
1154 real(real64),
optional,
intent(in) :: dt
1156 character(len=256) :: filename
1162 if (st%modelmbparticles%nparticle > 0)
then
1167 write(filename,
'(a,a,i7.7)') trim(outp%iter_dir),
"td.", iter
1169 call output_all(outp, namespace, space, filename, gr, ions, iter, st, hm, ks)
1171 call output_modelmb(outp, namespace, space, filename, gr, ions, iter, st)
1173 if (
present(dt))
then
1174 call output_scalar_pot(outp, namespace, space, filename, gr, ions, ext_partners, iter*dt)
1176 if (iter == 0)
call output_scalar_pot(outp, namespace, space, filename, gr, ions, ext_partners)
1185 type(c_ptr),
intent(inout) ::
out_spin
1186 class(
mesh_t),
intent(in) :: mesh
1188 integer,
intent(in) :: iter
1190 character(len=130) :: aux
1191 real(real64) :: spin(3)
1207 if (st%d%ispin ==
spinors)
then
1208 write(aux,
'(a2,18x)')
'Sx'
1210 write(aux,
'(a2,18x)')
'Sy'
1213 write(aux,
'(a2,18x)')
'Sz'
1221 select case (st%d%ispin)
1240 type(
ions_t),
intent(in) :: ions
1241 real(real64),
intent(in) :: lmm_r
1242 integer,
intent(in) :: iter
1245 character(len=50) :: aux
1246 real(real64),
allocatable :: lmm(:,:)
1251 safe_allocate(lmm(1:3, 1:ions%natoms))
1261 do ia = 1, ions%natoms
1262 if (st%d%ispin ==
spinors)
then
1263 write(aux,
'(a2,i2.2,16x)')
'mx', ia
1265 write(aux,
'(a2,i2.2,16x)')
'my', ia
1268 write(aux,
'(a2,i2.2,16x)')
'mz', ia
1277 do ia = 1, ions%natoms
1278 select case (st%d%ispin)
1286 safe_deallocate_a(lmm)
1294 type(c_ptr),
intent(inout) :: out_magnets
1295 class(
mesh_t),
intent(in) :: mesh
1297 type(
kick_t),
intent(in) :: kick
1298 integer,
intent(in) :: iter
1300 complex(real64),
allocatable :: tm(:,:)
1305 safe_allocate(tm(1:6,1:kick%nqvec))
1307 do iq = 1, kick%nqvec
1337 do iq = 1, kick%nqvec
1346 safe_deallocate_a(tm)
1360 subroutine td_write_angular(out_angular, namespace, space, gr, ions, hm, st, kick, iter)
1361 type(c_ptr),
intent(inout) :: out_angular
1363 class(
space_t),
intent(in) :: space
1364 type(
grid_t),
intent(in) :: gr
1365 type(
ions_t),
intent(inout) :: ions
1368 type(
kick_t),
intent(in) :: kick
1369 integer,
intent(in) :: iter
1372 character(len=130) :: aux
1373 real(real64) :: angular(3)
1380 call angular_momentum%setup_dir(idir)
1383 m_two*real(angular_momentum%zstates_elec_expectation_value(namespace, space, gr, hm, st), real64)
1385 safe_deallocate_p(angular_momentum)
1392 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
1400 write(aux,
'(a4,18x)')
'<Lx>'
1402 write(aux,
'(a4,18x)')
'<Ly>'
1404 write(aux,
'(a4,18x)')
'<Lz>'
1433 class(
space_t),
intent(in) :: space
1434 type(
grid_t),
intent(in) :: gr
1435 type(
ions_t),
intent(in) :: ions
1437 integer,
intent(in) :: lmax
1438 type(
kick_t),
intent(in) :: kick
1439 integer,
intent(in) :: iter
1442 real(real64),
allocatable :: rho(:,:)
1446 if (out_multip%resolve_states)
then
1447 safe_allocate(rho(1:gr%np_part, 1:st%d%nspin))
1450 do ist = st%st_start, st%st_end
1452 call td_write_multipole_r(out_multip%mult_handles(ist), space, gr, ions, st, lmax, kick, rho, iter, &
1453 mpi_grp = out_multip%mpi_grp)
1456 safe_deallocate_a(rho)
1459 if (
allocated(st%frozen_rho))
then
1460 safe_allocate(rho(1:gr%np, 1:st%d%nspin))
1461 call lalg_copy(gr%np, st%d%nspin, st%rho, rho)
1466 safe_deallocate_a(rho)
1478 subroutine td_write_multipole_r(out_multip, space, mesh, ions, st, lmax, kick, rho, iter, mpi_grp)
1479 type(c_ptr),
intent(inout) :: out_multip
1480 class(
space_t),
intent(in) :: space
1481 class(
mesh_t),
intent(in) :: mesh
1482 type(
ions_t),
intent(in) :: ions
1484 integer,
intent(in) :: lmax
1485 type(
kick_t),
intent(in) :: kick
1486 real(real64),
intent(in) :: rho(:,:)
1487 integer,
intent(in) :: iter
1488 type(
mpi_grp_t),
optional,
intent(in) :: mpi_grp
1491 integer :: is, idir, ll, mm, add_lm
1492 character(len=120) :: aux
1493 real(real64) :: ionic_dipole(ions%space%dim)
1494 real(real64),
allocatable :: multipole(:,:)
1500 assert(.not. (lmax > 1 .and. space%dim > 3))
1503 if (
present(mpi_grp)) mpi_grp_ = mpi_grp
1505 if (mpi_grp_%is_root().and.iter == 0)
then
1508 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
1512 write(aux,
'(a15,i2)')
'# lmax ', lmax
1520 do is = 1, st%d%nspin
1521 write(aux,
'(a18,i1,a1)')
'Electronic charge(', is,
')'
1524 do idir = 1, space%dim
1525 write(aux,
'(4a1,i1,a1)')
'<',
index2axis(idir),
'>',
'(', is,
')'
1531 write(aux,
'(a2,i2,a4,i2,a2,i1,a1)')
'l=', ll,
', m=', mm,
' (', is,
')'
1542 do is = 1, st%d%nspin
1545 do idir = 1, space%dim
1561 if (space%dim > 3 .and. lmax == 1)
then
1563 safe_allocate(multipole(1:space%dim+1, 1:st%d%nspin))
1565 safe_allocate(multipole(1:(lmax + 1)**2, 1:st%d%nspin))
1569 do is = 1, st%d%nspin
1574 ionic_dipole = ions%dipole()
1575 do is = 1, st%d%nspin
1576 multipole(2:space%dim+1, is) = -ionic_dipole(1:space%dim)/st%d%nspin - multipole(2:space%dim+1, is)
1580 if (mpi_grp_%is_root())
then
1582 do is = 1, st%d%nspin
1585 do idir = 1, space%dim
1589 add_lm = space%dim + 2
1600 safe_deallocate_a(multipole)
1605 subroutine td_write_ftchd(out_ftchd, space, mesh, st, kick, iter)
1606 type(c_ptr),
intent(inout) :: out_ftchd
1607 class(
space_t),
intent(in) :: space
1608 class(
mesh_t),
intent(in) :: mesh
1610 type(
kick_t),
intent(in) :: kick
1611 integer,
intent(in) :: iter
1613 integer :: is, ip, idir
1614 character(len=120) :: aux, aux2
1615 real(real64) :: ftchd_bessel
1616 complex(real64) :: ftchd
1618 real(real64),
allocatable :: integrand_bessel(:)
1619 complex(real64),
allocatable :: integrand(:)
1623 if (
mpi_world%is_root().and.iter == 0)
then
1626 write(aux,
'(a15, i2)')
'# qkickmode ', kick%qkick_mode
1631 write(aux,
'(a15, i0.3, 1x, i0.3)')
'# ll, mm ', kick%qbessel_l, kick%qbessel_m
1637 write(aux,
'(a15, f9.6)')
'# qlength ', kick%qlength
1639 write(aux,
'(a15)')
'# qvector '
1640 do idir = 1, space%dim
1641 write(aux2,
'(f9.5)') kick%qvector(idir,1)
1642 aux = trim(aux) // trim(aux2)
1648 write(aux,
'(a15,f18.12)')
'# kick strength', kick%delta_strength
1654 write(aux,
'(a17)')
'int(j_l*Y_lm*rho)'
1656 write(aux,
'(a12)')
'Real, Imag'
1673 safe_allocate(integrand(1:mesh%np))
1675 do is = 1, st%d%nspin
1677 integrand(ip) = integrand(ip) + st%rho(ip, is) *
exp(-
m_zi*sum(mesh%x(ip, 1:space%dim)*kick%qvector(1:space%dim, 1)))
1681 safe_deallocate_a(integrand)
1684 safe_allocate(integrand_bessel(1:mesh%np))
1685 integrand_bessel =
m_zero
1686 do is = 1, st%d%nspin
1688 call ylmr_real(mesh%x(ip, 1:3), kick%qbessel_l, kick%qbessel_m, ylm)
1689 integrand_bessel(ip) = integrand_bessel(ip) + st%rho(ip, is) * &
1690 loct_sph_bessel(kick%qbessel_l, kick%qlength*norm2(mesh%x(ip, :)))*ylm
1694 safe_deallocate_a(integrand_bessel)
1713 type(c_ptr),
intent(inout) :: out_temperature
1714 type(
ions_t),
intent(in) :: ions
1715 integer,
intent(in) :: iter
1750 type(c_ptr),
intent(inout) :: out_populations
1752 class(
space_t),
intent(in) :: space
1753 class(
mesh_t),
intent(in) :: mesh
1756 real(real64),
intent(in) :: dt
1757 integer,
intent(in) :: iter
1760 character(len=6) :: excited_name
1761 complex(real64) :: gsp
1762 complex(real64),
allocatable :: excited_state_p(:)
1763 complex(real64),
allocatable :: dotprodmatrix(:, :, :)
1768 safe_allocate(dotprodmatrix(1:writ%gs_st%nst, 1:st%nst, 1:st%nik))
1773 assert(.not. space%is_periodic())
1778 if (writ%n_excited_states > 0)
then
1779 safe_allocate(excited_state_p(1:writ%n_excited_states))
1780 do ist = 1, writ%n_excited_states
1781 excited_state_p(ist) =
zstates_elec_mpdotp(namespace, mesh, writ%excited_st(ist), st, dotprodmatrix)
1793 do ist = 1, writ%n_excited_states
1794 write(excited_name,
'(a2,i3,a1)')
'P(', ist,
')'
1813 do ist = 1, writ%n_excited_states
1820 if (writ%n_excited_states > 0)
then
1821 safe_deallocate_a(excited_state_p)
1823 safe_deallocate_a(dotprodmatrix)
1829 subroutine td_write_acc(out_acc, namespace, space, gr, ions, st, hm, ext_partners, dt, iter)
1830 type(c_ptr),
intent(inout) :: out_acc
1832 class(
space_t),
intent(in) :: space
1833 type(
grid_t),
intent(in) :: gr
1834 type(
ions_t),
intent(inout) :: ions
1838 real(real64),
intent(in) :: dt
1839 integer,
intent(in) :: iter
1842 character(len=7) :: aux
1843 real(real64) :: acc(space%dim)
1847 if (iter == 0 .and.
mpi_world%is_root())
then
1852 do idim = 1, space%dim
1853 write(aux,
'(a4,i1,a1)')
'Acc(', idim,
')'
1861 do idim = 1, space%dim
1868 call td_calc_tacc(namespace, space, gr, ions, ext_partners, st, hm, acc, dt*iter)
1881 subroutine td_write_vel(out_vel, namespace, gr, st, space, hm, ions, iter)
1882 type(c_ptr),
intent(inout) :: out_vel
1884 type(
grid_t),
intent(in) :: gr
1886 type(
space_t),
intent(in) :: space
1888 type(
ions_t),
intent(in) :: ions
1889 integer,
intent(in) :: iter
1892 character(len=7) :: aux
1893 real(real64) :: vel(space%dim)
1897 if (iter == 0 .and.
mpi_world%is_root())
then
1902 do idim = 1, space%dim
1903 write(aux,
'(a4,i1,a1)')
'Vel(', idim,
')'
1911 do idim = 1, space%dim
1918 call td_calc_tvel(namespace, gr, st, space, hm, ions, vel)
1933 type(c_ptr),
intent(inout) :: out_laser
1934 class(
space_t),
intent(in) :: space
1935 type(
lasers_t),
intent(inout) :: lasers
1936 real(real64),
intent(in) :: dt
1937 integer,
intent(in) :: iter
1940 real(real64) :: field(space%dim)
1941 real(real64) :: ndfield(space%dim)
1942 character(len=80) :: aux
1958 do il = 1, lasers%no_lasers
1961 do idir = 1, space%dim
1962 write(aux,
'(a,i1,a)')
'E(', idir,
')'
1966 do idir = 1, space%dim
1967 write(aux,
'(a,i1,a)')
'B(', idir,
')'
1971 do idir = 1, space%dim
1972 write(aux,
'(a,i1,a)')
'A(', idir,
')'
1976 write(aux,
'(a,i1,a)')
'e(t)'
1982 do idir = 1, space%dim
1983 write(aux,
'(a,i1,a)')
'A^M(', idir,
')'
1995 do il = 1, lasers%no_lasers
1999 do idir = 1, space%dim
2004 do idir = 1, space%dim
2015 do idir = 1, space%dim
2028 do il = 1, lasers%no_lasers
2030 call laser_field(lasers%lasers(il), field(1:space%dim), iter*dt)
2055 type(c_ptr),
intent(inout) :: out_energy
2057 integer,
intent(in) :: iter
2058 real(real64),
intent(in) :: ke
2062 integer :: n_columns
2085 if (hm%pcm%run_pcm)
then
2087 n_columns = n_columns + 1
2092 n_columns = n_columns + 1
2102 do ii = 1, n_columns
2125 hm%energy%int_nn_pcm + hm%energy%int_ne_pcm), 1)
2138 type(c_ptr),
intent(inout) :: out_eigs
2140 integer,
intent(in) :: iter
2143 character(len=68) :: buf
2156 write(buf,
'(a15,i2)')
'# nst ', st%nst
2160 write(buf,
'(a15,i2)')
'# nspin ', st%d%nspin
2166 do is = 1, st%d%kpt%nglobal
2168 write(buf,
'(a,i4)')
'Eigenvalue ',ii
2177 do is = 1, st%d%kpt%nglobal
2187 do is = 1, st%d%kpt%nglobal
2199 type(c_ptr),
intent(inout) :: out_ionch
2200 class(
mesh_t),
intent(in) :: mesh
2202 integer,
intent(in) :: iter
2204 integer :: ii, ist, Nch, ik, idim
2205 character(len=68) :: buf
2206 real(real64),
allocatable :: ch(:), occ(:)
2207 real(real64),
allocatable :: occbuf(:)
2212 nch = st%nst * st%d%kpt%nglobal * st%d%dim
2213 safe_allocate(ch(0: nch))
2214 safe_allocate(occ(0: nch))
2220 do idim = 1, st%d%dim
2221 if (st%st_start <= ist .and. ist <= st%st_end .and. &
2222 st%d%kpt%start <= ik .and. ik <= st%d%kpt%end)
then
2223 occ(ii) = st%occ(ist, ik)
2231 if (st%parallel_in_states)
then
2232 safe_allocate(occbuf(0: nch))
2234 call st%mpi_grp%allreduce(occ(0), occbuf(0), nch+1, mpi_double_precision, mpi_sum)
2236 safe_deallocate_a(occbuf)
2244 safe_deallocate_a(ch)
2257 if (occ(ii)>
m_zero .or. ii == 0)
then
2258 write(buf,
'(a,f4.1,a)')
'Pion(',occ(ii)*ii,
'+, t)'
2268 if (occ(ii)>
m_zero .or. ii == 0)
then
2278 if (occ(ii)>
m_zero .or. ii == 0)
then
2284 safe_deallocate_a(ch)
2285 safe_deallocate_a(occ)
2291 subroutine td_write_proj(out_proj, space, mesh, ions, st, gs_st, kick, iter)
2292 type(c_ptr),
intent(inout) :: out_proj
2294 class(
mesh_t),
intent(in) :: mesh
2295 type(
ions_t),
intent(in) :: ions
2298 type(
kick_t),
intent(in) :: kick
2299 integer,
intent(in) :: iter
2301 complex(real64),
allocatable :: projections(:,:,:)
2302 character(len=80) :: aux
2303 integer :: ik, ist, uist, idir
2311 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
2320 write(aux,
'(a,i8)')
"# nik ", st%nik
2324 write(aux,
'(a,2i8)')
"# st ", gs_st%st_start, st%nst
2328 write(aux,
'(a,2i8)')
"# ust ", gs_st%st_start, gs_st%st_end
2334 do ist = gs_st%st_start, st%nst
2342 do ist = gs_st%st_start, st%nst
2343 do uist = gs_st%st_start, gs_st%st_end
2344 write(aux,
'(i4,a,i4)') ist,
' -> ', uist
2355 if (.not. space%is_periodic())
then
2357 safe_allocate(projections(1:st%nst, gs_st%st_start:gs_st%st_end, 1:st%nik))
2358 do idir = 1, space%dim
2364 write(aux,
'(a,i1,a)')
"<i|x_", idir,
"|a>"
2368 do ist = gs_st%st_start, st%st_end
2369 do uist = gs_st%st_start, gs_st%st_end
2379 safe_deallocate_a(projections)
2389 safe_allocate(projections(1:st%nst, gs_st%st_start:gs_st%st_end, 1:st%nik))
2390 projections(:,:,:) =
m_z0
2396 do ist = gs_st%st_start, st%nst
2397 do uist = gs_st%st_start, gs_st%st_end
2406 safe_deallocate_a(projections)
2412 integer,
intent(in) :: dir
2414 integer :: uist, ist, ik, idim
2415 real(real64) :: n_dip(space%dim)
2416 complex(real64),
allocatable :: xpsi(:,:)
2417 complex(real64),
allocatable :: psi(:, :), gspsi(:, :)
2421 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
2422 safe_allocate(gspsi(1:mesh%np, 1:st%d%dim))
2423 safe_allocate(xpsi(1:mesh%np, 1:st%d%dim))
2425 do ik = st%d%kpt%start, st%d%kpt%end
2426 do ist = st%st_start, st%st_end
2428 do uist = gs_st%st_start, gs_st%st_end
2431 do idim = 1, st%d%dim
2432 xpsi(1:mesh%np, idim) = mesh%x(1:mesh%np, dir)*gspsi(1:mesh%np, idim)
2434 projections(ist, uist, ik) = -
zmf_dotp(mesh, st%d%dim, psi, xpsi, reduce = .false.)
2440 safe_deallocate_a(xpsi)
2441 safe_deallocate_a(gspsi)
2442 safe_deallocate_a(psi)
2447 n_dip = ions%dipole()
2449 do ist = gs_st%st_start, st%nst
2450 do uist = gs_st%st_start, gs_st%st_end
2451 projections(ist, uist, ik) = projections(ist, uist, ik) - n_dip(dir)
2467 subroutine td_write_n_ex(out_nex, outp, namespace, mesh, kpoints, st, gs_st, iter)
2468 type(c_ptr),
intent(inout) :: out_nex
2471 class(
mesh_t),
intent(in) :: mesh
2475 integer,
intent(in) :: iter
2477 complex(real64),
allocatable :: projections(:,:)
2478 character(len=80) :: aux, dir
2479 integer :: ik, ikpt, ist, uist, err
2480 real(real64) :: Nex, weight
2482 real(real64),
allocatable :: Nex_kpt(:)
2491 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
2498 write(aux,
'(a,i8)')
"# nik ", st%nik
2502 write(aux,
'(a,2i8)')
"# st ", gs_st%st_start, st%nst
2506 write(aux,
'(a,2i8)')
"# ust ", gs_st%st_start, gs_st%st_end
2525 do ist = 1, gs_st%nst
2526 if (gs_st%occ(ist, ik) >
m_min_occ .and. ist > gs_nst) gs_nst = ist
2530 safe_allocate(projections(1:gs_nst, 1:st%nst))
2532 safe_allocate(nex_kpt(1:st%nik))
2534 do ik = st%d%kpt%start, st%d%kpt%end
2535 ikpt = st%d%get_kpoint_index(ik)
2538 weight = st%kweights(ik) * gs_st%occ(ist, ik)/ st%smear%el_per_state
2539 do uist = st%st_start, st%st_end
2540 nex_kpt(ikpt) = nex_kpt(ikpt) - weight * st%occ(uist, ik) * abs(projections(ist, uist))**2
2543 nex_kpt(ikpt) = nex_kpt(ikpt) + sum(st%occ(st%st_start:st%st_end, ik))*st%kweights(ik)
2546 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
2558 write(dir,
'(a,a,i7.7)') trim(outp%iter_dir),
"td.", iter
2561 + outp%how(option__output__density_kpt), dir,
"n_excited_el_kpt", namespace, &
2565 safe_deallocate_a(projections)
2566 safe_deallocate_a(nex_kpt)
2578 class(
mesh_t),
intent(in) :: mesh
2581 complex(real64),
intent(inout) :: projections(1:st%nst, gs_st%st_start:gs_st%nst, 1:st%nik)
2583 integer :: uist, ist, ik
2584 complex(real64),
allocatable :: psi(:, :), gspsi(:, :)
2587 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
2588 safe_allocate(gspsi(1:mesh%np, 1:st%d%dim))
2590 projections(:,:,:) =
m_zero
2592 do ik = st%d%kpt%start, st%d%kpt%end
2593 do ist = st%st_start, st%st_end
2595 do uist = gs_st%st_start, gs_st%nst
2597 projections(ist, uist, ik) =
zmf_dotp(mesh, st%d%dim, psi, gspsi, reduce = .false.)
2602 safe_deallocate_a(psi)
2603 safe_deallocate_a(gspsi)
2612 class(
mesh_t),
intent(in) :: mesh
2617 integer,
intent(in) :: iter
2619 complex(real64),
allocatable :: proj(:,:), psi(:,:,:), gs_psi(:,:,:), temp_state(:,:)
2620 character(len=80) :: filename1, filename2
2621 integer :: ik,ist, jst, file, idim, nk_proj
2625 write(filename1,
'(I10)') iter
2626 filename1 =
'td.general/projections_iter_'//trim(adjustl(filename1))
2629 safe_allocate(proj(1:gs_st%nst, 1:gs_st%nst))
2630 safe_allocate(psi(1:gs_st%nst,1:gs_st%d%dim,1:mesh%np))
2631 safe_allocate(gs_psi(1:gs_st%nst,1:gs_st%d%dim,1:mesh%np))
2632 safe_allocate(temp_state(1:mesh%np,1:gs_st%d%dim))
2638 nk_proj = kpoints%nik_skip
2640 do ik = kpoints%reduced%npoints-nk_proj+1, kpoints%reduced%npoints
2642 psi(1:gs_st%nst, 1:gs_st%d%dim, 1:mesh%np)=
m_zero
2643 gs_psi(1:gs_st%nst, 1:gs_st%d%dim, 1:mesh%np)=
m_zero
2646 write(filename2,
'(I10)') ik
2647 filename2 = trim(adjustl(filename1))//
'_ik_'//trim(adjustl(filename2))
2648 file =
io_open(filename2, namespace, action=
'write')
2651 do ist=gs_st%st_start,gs_st%st_end
2654 do idim = 1,gs_st%d%dim
2655 psi(ist,idim,1:mesh%np) = temp_state(1:mesh%np,idim)
2658 do idim = 1,gs_st%d%dim
2659 gs_psi(ist,idim,1:mesh%np) = temp_state(1:mesh%np,idim)
2668 assert(mesh%np_global*gs_st%d%dim < huge(0_int32))
2669 proj(1:gs_st%nst, 1:gs_st%nst) =
m_zero
2674 i8_to_i4(mesh%np_global*gs_st%d%dim), &
2675 cmplx(mesh%volume_element,
m_zero, real64) , &
2677 ubound(psi, dim = 1), &
2679 ubound(gs_psi, dim = 1), &
2682 ubound(proj, dim = 1))
2686 do ist = 1, gs_st%nst
2687 do jst = 1, gs_st%nst
2688 write(file,
'(I3,1x,I3,1x,e13.6,1x,e13.6,2x)') ist, jst, proj(ist,jst)
2696 safe_deallocate_a(proj)
2697 safe_deallocate_a(psi)
2698 safe_deallocate_a(gs_psi)
2699 safe_deallocate_a(temp_state)
2705 subroutine td_write_floquet(namespace, space, hm, ext_partners, gr, st, iter)
2706 type(namespace_t),
intent(in) :: namespace
2707 class(space_t),
intent(in) :: space
2708 type(hamiltonian_elec_t),
intent(inout) :: hm
2709 type(partner_list_t),
intent(in) :: ext_partners
2710 type(grid_t),
intent(in) :: gr
2711 type(states_elec_t),
intent(inout) :: st
2712 integer,
intent(in) :: iter
2714 complex(real64),
allocatable :: hmss(:,:), psi(:,:,:), hpsi(:,:,:), temp_state1(:,:)
2715 complex(real64),
allocatable :: HFloquet(:,:,:), HFloq_eff(:,:), temp(:,:)
2716 real(real64),
allocatable :: eigenval(:), bands(:,:)
2717 character(len=80) :: filename
2718 integer :: it, nT, ik, ist, in, im, file, idim, nik, ik_count
2719 integer :: Forder, Fdim, m0, n0, n1, nst, ii, jj, lim_nst
2720 logical :: downfolding
2721 type(states_elec_t) :: hm_st
2723 real(real64) :: dt, Tcycle, omega
2727 downfolding = .false.
2730 if (.not. iter == 0)
then
2738 assert(gr%np == gr%np_global)
2741 call states_elec_copy(hm_st, st)
2752 call parse_variable(namespace,
'TDFloquetFrequency', m_zero, omega, units_inp%energy)
2753 call messages_print_var_value(
'Frequency used for Floquet analysis', omega, namespace=namespace)
2754 if (abs(omega) <= m_epsilon)
then
2755 message(1) =
"Please give a non-zero value for TDFloquetFrequency"
2756 call messages_fatal(1, namespace=namespace)
2760 tcycle = m_two * m_pi / omega
2770 call parse_variable(namespace,
'TDFloquetSample',20 ,nt)
2771 call messages_print_var_value(
'Number of Floquet time-sampling points', nt, namespace=namespace)
2772 dt = tcycle/real(nt, real64)
2781 call parse_variable(namespace,
'TDFloquetDimension',-1,forder)
2782 if (forder .ge. 0)
then
2783 call messages_print_var_value(
'Order of multiphoton Floquet-Hamiltonian', forder, namespace=namespace)
2785 fdim = 2 * forder + 1
2787 message(1) =
'Floquet-Hamiltonian is downfolded'
2788 call messages_info(1, namespace=namespace)
2789 downfolding = .
true.
2794 dt = tcycle/real(nt, real64)
2797 nik = hm%kpoints%nik_skip
2799 safe_allocate(hmss(1:nst,1:nst))
2800 safe_allocate( psi(1:nst,1:st%d%dim,1:gr%np))
2801 safe_allocate(hpsi(1:nst,1:st%d%dim,1:gr%np))
2802 safe_allocate(temp_state1(1:gr%np,1:st%d%dim))
2810 safe_allocate(hfloquet(1:nik,1:nst*fdim, 1:nst*fdim))
2811 hfloquet(1:nik,1:nst*fdim, 1:nst*fdim) = m_zero
2816 call hm%update(gr, namespace, space, ext_partners, time=tcycle+it*dt)
2818 call zhamiltonian_elec_apply_all(hm, namespace, gr, st, hm_st)
2823 do ik = hm%kpoints%reduced%npoints-nik+1, hm%kpoints%reduced%npoints
2824 ik_count = ik_count + 1
2826 psi(1:nst, 1:st%d%dim, 1:gr%np)= m_zero
2827 hpsi(1:nst, 1:st%d%dim, 1:gr%np)= m_zero
2829 do ist = st%st_start, st%st_end
2830 if (state_kpt_is_local(st, ist, ik))
then
2831 call states_elec_get_state(st, gr, ist, ik,temp_state1)
2832 do idim = 1, st%d%dim
2833 psi(ist, idim, 1:gr%np) = temp_state1(1:gr%np, idim)
2835 call states_elec_get_state(hm_st, gr, ist, ik,temp_state1)
2836 do idim = 1, st%d%dim
2837 hpsi(ist, idim, 1:gr%np) = temp_state1(1:gr%np, idim)
2841 call comm_allreduce(mpi_world, psi)
2842 call comm_allreduce(mpi_world, hpsi)
2843 assert(gr%np_global*st%d%dim < huge(0_int32))
2844 hmss(1:nst,1:nst) = m_zero
2849 i8_to_i4(gr%np_global*st%d%dim), &
2850 cmplx(gr%volume_element, m_zero, real64) , &
2852 ubound(hpsi, dim = 1), &
2854 ubound(psi, dim = 1), &
2857 ubound(hmss, dim = 1))
2859 hmss(1:nst,1:nst) = conjg(hmss(1:nst,1:nst))
2862 do in = -forder, forder
2863 do im = -forder, forder
2864 ii = (in+forder) * nst
2865 jj = (im+forder) * nst
2866 hfloquet(ik_count, ii+1:ii+nst, jj+1:jj+nst) = &
2867 hfloquet(ik_count, ii+1:ii+nst, jj+1:jj+nst) + hmss(1:nst, 1:nst) *
exp(-(in-im)*m_zi*omega*it*dt)
2871 hfloquet(ik_count, ii+ist, ii+ist) = hfloquet(ik_count, ii+ist, ii+ist) + in*omega
2880 hfloquet(:,:,:) = m_one/nt*hfloquet(:,:,:)
2883 if (downfolding)
then
2885 safe_allocate(hfloq_eff(1:nst,1:nst))
2886 safe_allocate(eigenval(1:nst))
2887 safe_allocate(bands(1:nik,1:nst))
2889 hfloq_eff(1:nst,1:nst) = m_zero
2895 hfloq_eff(1:nst, 1:nst) = hfloquet(ik, n0+1:n0+nst, m0+1:m0+nst) + &
2896 m_one/omega*(matmul(hfloquet(ik, 1:nst, m0+1:m0+nst), hfloquet(ik, n1+1:n1+nst, m0+1:m0+nst))- &
2897 matmul(hfloquet(ik, n1+1:n1+nst, m0+1:m0+nst), hfloquet(ik, 1:nst, m0+1:m0+nst)))
2899 call lalg_eigensolve(nst, hfloq_eff, eigenval)
2900 bands(ik,1:nst) = eigenval(1:nst)
2902 safe_deallocate_a(hfloq_eff)
2905 safe_allocate(eigenval(1:nst*fdim))
2906 safe_allocate(bands(1:nik,1:nst*fdim))
2907 safe_allocate(temp(1:nst*fdim, 1:nst*fdim))
2910 temp(1:nst*fdim, 1:nst*fdim) = hfloquet(ik, 1:nst*fdim, 1:nst*fdim)
2911 call lalg_eigensolve(nst*fdim, temp, eigenval)
2912 bands(ik, 1:nst*fdim) = eigenval(1:nst*fdim)
2917 if (downfolding)
then
2919 filename =
"downfolded_floquet_bands"
2922 filename =
"floquet_bands"
2925 if (mpi_world%is_root())
then
2927 file = io_open(filename, namespace, action =
'write')
2930 write(file,
'(e13.6, 1x)',advance=
'no') bands(ik,ist)
2937 if (.not. downfolding)
then
2940 bands(1:nik, 1:nst*fdim) = m_zero
2942 temp(1:nst*fdim,1:nst*fdim) = m_zero
2945 temp(ii+1:ii+nst, ii+1:ii+nst) = hfloquet(ik, ii+1:ii+nst, ii+1:ii+nst)
2947 call lalg_eigensolve(nst*fdim, temp, eigenval)
2948 bands(ik, 1:nst*fdim) = eigenval(1:nst*fdim)
2951 if (mpi_world%is_root())
then
2952 filename =
'trivial_floquet_bands'
2953 file = io_open(filename, namespace, action =
'write')
2956 write(file,
'(e13.6, 1x)', advance=
'no') bands(ik,ist)
2965 call hm%update(gr, namespace, space, ext_partners, time=m_zero)
2967 safe_deallocate_a(hmss)
2968 safe_deallocate_a(psi)
2969 safe_deallocate_a(hpsi)
2970 safe_deallocate_a(temp_state1)
2971 safe_deallocate_a(hfloquet)
2972 safe_deallocate_a(eigenval)
2973 safe_deallocate_a(bands)
2974 safe_deallocate_a(temp)
2982 type(c_ptr),
intent(inout) :: out_total_current
2983 class(space_t),
intent(in) :: space
2984 class(mesh_t),
intent(in) :: mesh
2985 type(states_elec_t),
intent(in) :: st
2986 integer,
intent(in) :: iter
2988 integer :: idir, ispin
2989 character(len=50) :: aux
2990 real(real64) :: total_current(space%dim), abs_current(space%dim)
2994 if (mpi_world%is_root() .and. iter == 0)
then
2995 call td_write_print_header_init(out_total_current)
2998 call write_iter_header_start(out_total_current)
3000 do idir = 1, space%dim
3001 write(aux,
'(a2,a1,a1)')
'I(', index2axis(idir),
')'
3002 call write_iter_header(out_total_current, aux)
3005 do idir = 1, space%dim
3006 write(aux,
'(a10,a1,a1)')
'IntAbs(j)(', index2axis(idir),
')'
3007 call write_iter_header(out_total_current, aux)
3010 do ispin = 1, st%d%nspin
3011 do idir = 1, space%dim
3012 write(aux,
'(a4,i1,a1,a1,a1)')
'I-sp', ispin,
'(', index2axis(idir),
')'
3013 call write_iter_header(out_total_current, aux)
3017 call write_iter_nl(out_total_current)
3019 call td_write_print_header_end(out_total_current)
3022 assert(
allocated(st%current))
3024 if (mpi_world%is_root())
then
3025 call write_iter_start(out_total_current)
3028 total_current = 0.0_real64
3029 do idir = 1, space%dim
3030 do ispin = 1, st%d%spin_channels
3031 total_current(idir) = total_current(idir) + dmf_integrate(mesh, st%current(:, idir, ispin), reduce = .false.)
3033 total_current(idir) = units_from_atomic(units_out%length/units_out%time, total_current(idir))
3035 call mesh%allreduce(total_current, dim = space%dim)
3037 abs_current = 0.0_real64
3038 do idir = 1, space%dim
3039 do ispin = 1, st%d%spin_channels
3040 abs_current(idir) = abs_current(idir) + dmf_integrate(mesh, abs(st%current(:, idir, ispin)), reduce = .false.)
3042 abs_current(idir) = units_from_atomic(units_out%length/units_out%time, abs_current(idir))
3044 call mesh%allreduce(abs_current, dim = space%dim)
3046 if (mpi_world%is_root())
then
3047 call write_iter_double(out_total_current, total_current, space%dim)
3048 call write_iter_double(out_total_current, abs_current, space%dim)
3051 do ispin = 1, st%d%nspin
3052 total_current = units_from_atomic(units_out%length/units_out%time, dmf_integrate(mesh, space%dim, st%current(:, :, ispin)))
3054 if (mpi_world%is_root())
then
3055 call write_iter_double(out_total_current, total_current, space%dim)
3059 if (mpi_world%is_root())
then
3060 call write_iter_nl(out_total_current)
3069 type(c_ptr),
intent(inout) :: write_obj
3070 class(space_t),
intent(in) :: space
3071 type(hamiltonian_elec_t),
intent(inout) :: hm
3072 type(grid_t),
intent(in) :: gr
3073 type(states_elec_t),
intent(in) :: st
3074 integer,
intent(in) :: iter
3076 integer :: idir, ispin
3077 character(len=50) :: aux
3078 real(real64),
allocatable :: heat_current(:, :, :)
3079 real(real64) :: total_current(space%dim)
3083 if (mpi_world%is_root() .and. iter == 0)
then
3084 call td_write_print_header_init(write_obj)
3087 call write_iter_header_start(write_obj)
3089 do idir = 1, space%dim
3090 write(aux,
'(a2,i1,a1)')
'Jh(', idir,
')'
3091 call write_iter_header(write_obj, aux)
3094 call write_iter_nl(write_obj)
3096 call td_write_print_header_end(write_obj)
3099 safe_allocate(heat_current(1:gr%np, 1:space%dim, 1:st%d%nspin))
3101 call current_heat_calculate(space, gr%der, hm, st, heat_current)
3103 if (mpi_world%is_root())
call write_iter_start(write_obj)
3105 total_current = 0.0_real64
3106 do idir = 1, space%dim
3107 do ispin = 1, st%d%spin_channels
3108 total_current(idir) = total_current(idir) + dmf_integrate(gr, heat_current(:, idir, ispin))
3110 total_current(idir) = units_from_atomic(units_out%energy*units_out%length/units_out%time, total_current(idir))
3113 safe_deallocate_a(heat_current)
3115 if (mpi_world%is_root())
call write_iter_double(write_obj, total_current, space%dim)
3117 if (mpi_world%is_root())
call write_iter_nl(write_obj)
3125 type(c_ptr),
intent(inout) :: out_partial_charges
3126 class(mesh_t),
intent(in) :: mesh
3127 type(states_elec_t),
intent(in) :: st
3128 type(ions_t),
intent(in) :: ions
3129 integer,
intent(in) :: iter
3132 character(len=50) :: aux
3133 real(real64),
allocatable :: hirshfeld_charges(:)
3137 safe_allocate(hirshfeld_charges(1:ions%natoms))
3139 call partial_charges_calculate(mesh, st, ions, hirshfeld_charges)
3141 if (mpi_world%is_root())
then
3145 call td_write_print_header_init(out_partial_charges)
3148 call write_iter_header_start(out_partial_charges)
3150 do idir = 1, ions%natoms
3151 write(aux,
'(a13,i3,a1)')
'hirshfeld(atom=', idir,
')'
3152 call write_iter_header(out_partial_charges, aux)
3155 call write_iter_nl(out_partial_charges)
3157 call td_write_print_header_end(out_partial_charges)
3160 call write_iter_start(out_partial_charges)
3162 call write_iter_double(out_partial_charges, hirshfeld_charges, ions%natoms)
3164 call write_iter_nl(out_partial_charges)
3167 safe_deallocate_a(hirshfeld_charges)
3173 subroutine td_write_q(out_q, space, ks, iter)
3174 type(c_ptr),
intent(inout) :: out_q
3175 class(space_t),
intent(in) :: space
3176 type(v_ks_t),
intent(in) :: ks
3177 integer,
intent(in) :: iter
3180 character(len=50) :: aux
3184 if (mpi_world%is_root())
then
3186 call td_write_print_header_init(out_q)
3187 call write_iter_header_start(out_q)
3188 do ii = 1, ks%pt%nmodes
3189 write(aux,
'(a1,i3,a3)')
'q', ii,
'(t)'
3190 call write_iter_header(out_q, aux)
3192 do ii = 1, ks%pt%nmodes
3193 write(aux,
'(a1,i3,a3)')
'p', ii,
'(t)'
3194 call write_iter_header(out_q, aux)
3196 do ii = 1, space%dim
3197 write(aux,
'(a3,i3,a3)')
'f_pt', ii,
'(t)'
3198 call write_iter_header(out_q, aux)
3200 call write_iter_nl(out_q)
3201 call td_write_print_header_end(out_q)
3204 call write_iter_start(out_q)
3205 call write_iter_double(out_q, ks%pt_mx%pt_q, ks%pt%nmodes)
3206 call write_iter_double(out_q, ks%pt_mx%pt_p, ks%pt%nmodes)
3207 call write_iter_double(out_q, ks%pt_mx%fmf, space%dim)
3208 call write_iter_nl(out_q)
3217 type(c_ptr),
intent(inout) :: out_mxll
3218 class(space_t),
intent(in) :: space
3219 type(hamiltonian_elec_t),
intent(in) :: hm
3220 real(real64),
intent(in) :: dt
3221 integer,
intent(in) :: iter
3224 real(real64) :: field(space%dim)
3225 character(len=80) :: aux
3226 character(len=1) :: field_char
3230 if (.not. mpi_world%is_root())
then
3236 call td_write_print_header_init(out_mxll)
3238 write(aux,
'(a7,e20.12,3a)')
'# dt = ', units_from_atomic(units_out%time, dt), &
3239 " [", trim(units_abbrev(units_out%time)),
"]"
3240 call write_iter_string(out_mxll, aux)
3241 call write_iter_nl(out_mxll)
3243 call write_iter_header_start(out_mxll)
3244 select case (hm%mxll%coupling_mode)
3245 case (length_gauge_dipole, multipolar_expansion)
3246 if (hm%mxll%add_electric_dip) field_char =
'E'
3247 if (hm%mxll%add_magnetic_dip) field_char =
'B'
3248 do idir = 1, space%dim
3249 write(aux,
'(a,i1,a)') field_char //
'(', idir,
')'
3250 call write_iter_header(out_mxll, aux)
3252 case (velocity_gauge_dipole)
3253 do idir = 1, space%dim
3254 write(aux,
'(a,i1,a)')
'A(', idir,
')'
3255 call write_iter_header(out_mxll, aux)
3258 call write_iter_nl(out_mxll)
3260 call write_iter_string(out_mxll,
'#[Iter n.]')
3261 call write_iter_header(out_mxll,
'[' // trim(units_abbrev(units_out%time)) //
']')
3265 select case (hm%mxll%coupling_mode)
3266 case (length_gauge_dipole, multipolar_expansion)
3267 if (hm%mxll%add_electric_dip) aux =
'[' // trim(units_abbrev(units_out%force)) //
']'
3268 if (hm%mxll%add_magnetic_dip) aux =
'[' // trim(units_abbrev(unit_one/units_out%length**2)) //
']'
3269 do idir = 1, space%dim
3270 call write_iter_header(out_mxll, aux)
3272 case (velocity_gauge_dipole)
3273 aux =
'[' // trim(units_abbrev(units_out%energy)) //
']'
3274 do idir = 1, space%dim
3275 call write_iter_header(out_mxll, aux)
3278 call write_iter_nl(out_mxll)
3279 call td_write_print_header_end(out_mxll)
3282 call write_iter_start(out_mxll)
3285 select case (hm%mxll%coupling_mode)
3286 case (length_gauge_dipole, multipolar_expansion)
3287 if (hm%mxll%add_electric_dip) field = units_from_atomic(units_out%force, hm%mxll%e_field_dip)
3288 if (hm%mxll%add_magnetic_dip) field = units_from_atomic(unit_one/units_out%length**2, hm%mxll%b_field_dip)
3289 call write_iter_double(out_mxll, field, space%dim)
3290 case (velocity_gauge_dipole)
3291 field = units_from_atomic(units_out%energy, hm%mxll%vec_pot_dip)
3292 call write_iter_double(out_mxll, field, space%dim)
3294 call write_iter_nl(out_mxll)
3302 type(c_ptr),
intent(inout) :: out_coords
3303 type(lda_u_t),
intent(in) :: lda_u
3304 integer,
intent(in) :: iter
3307 character(len=50) :: aux
3309 if (.not. mpi_world%is_root())
return
3314 call td_write_print_header_init(out_coords)
3317 call write_iter_header_start(out_coords)
3319 do ios = 1, lda_u%norbsets
3320 write(aux,
'(a2,i3,a1)')
'Ueff(', ios,
')'
3321 call write_iter_header(out_coords, aux)
3324 do ios = 1, lda_u%norbsets
3325 write(aux,
'(a2,i3,a1)')
'U(', ios,
')'
3326 call write_iter_header(out_coords, aux)
3329 do ios = 1, lda_u%norbsets
3330 write(aux,
'(a2,i3,a1)')
'J(', ios,
')'
3331 call write_iter_header(out_coords, aux)
3334 if (lda_u%intersite)
then
3335 do ios = 1, lda_u%norbsets
3336 do inn = 1, lda_u%orbsets(ios)%nneighbors
3337 write(aux,
'(a2,i3,a1,i3,a1)')
'V(', ios,
'-', inn,
')'
3338 call write_iter_header(out_coords, aux)
3344 call write_iter_nl(out_coords)
3347 call write_iter_string(out_coords,
'#[Iter n.]')
3348 call write_iter_header(out_coords,
'[' // trim(units_abbrev(units_out%time)) //
']')
3349 call write_iter_string(out_coords, &
3350 'Effective U ' // trim(units_abbrev(units_out%energy)) // &
3351 ', U in '// trim(units_abbrev(units_out%energy)) // &
3352 ', J in ' // trim(units_abbrev(units_out%energy)))
3353 call write_iter_nl(out_coords)
3355 call td_write_print_header_end(out_coords)
3358 call write_iter_start(out_coords)
3360 do ios = 1, lda_u%norbsets
3361 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3362 lda_u%orbsets(ios)%Ueff), 1)
3365 do ios = 1, lda_u%norbsets
3366 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3367 lda_u%orbsets(ios)%Ubar), 1)
3370 do ios = 1, lda_u%norbsets
3371 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3372 lda_u%orbsets(ios)%Jbar), 1)
3375 if (lda_u%intersite)
then
3376 do ios = 1, lda_u%norbsets
3377 do inn = 1, lda_u%orbsets(ios)%nneighbors
3378 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3379 lda_u%orbsets(ios)%V_ij(inn,0)), 1)
3384 call write_iter_nl(out_coords)
3391 type(c_ptr),
intent(inout) :: file_handle
3392 type(grid_t),
intent(in) :: grid
3393 type(kpoints_t),
intent(in) :: kpoints
3394 type(states_elec_t),
intent(in) :: st
3395 integer,
intent(in) :: iter
3397 integer :: ik_ispin, ist
3398 character(len=7) :: nkpt_str, nst_str
3399 character(len=7) :: ik_str, ist_str
3400 real(real64),
allocatable :: norm_ks(:, :)
3401 real(real64) :: n_electrons
3405 safe_allocate(norm_ks(1:st%nst, 1:st%nik))
3406 call states_elec_calc_norms(grid, kpoints, st, norm_ks)
3408 if (mpi_world%is_root())
then
3411 call td_write_print_header_init(file_handle)
3414 write(nkpt_str,
'(I7)') st%nik
3415 write(nst_str,
'(I7)') st%nst
3416 call write_iter_string(file_handle,
'# Dimensions. (nstates, nkpt * nspin):')
3417 call write_iter_string(file_handle, trim(adjustl(nst_str)) //
' ' // trim(adjustl(nkpt_str)))
3418 call write_iter_nl(file_handle)
3421 call write_iter_string(file_handle,
'# Norm ordering: (istate, ikpoint_spin)')
3422 call write_iter_nl(file_handle)
3425 call write_iter_header_start(file_handle)
3426 call write_iter_header(file_handle,
'N_electrons')
3427 do ik_ispin = 1, st%nik
3429 write(ik_str,
'(I7)') ik_ispin
3430 write(ist_str,
'(I7)') ist
3431 call write_iter_header(file_handle, &
3432 'Norm (' // trim(ist_str) //
',' // trim(ik_str) //
')')
3435 call write_iter_nl(file_handle)
3436 call td_write_print_header_end(file_handle)
3439 n_electrons = sum(st%occ * norm_ks**2)
3442 call write_iter_start(file_handle)
3443 call write_iter_double(file_handle, n_electrons, 1)
3444 do ik_ispin = 1, st%nik
3445 call write_iter_double(file_handle, norm_ks(:, ik_ispin),
size(norm_ks, 1))
3447 call write_iter_nl(file_handle)
3451 safe_deallocate_a(norm_ks)
3460 type(c_ptr),
intent(inout) :: file_handle
3461 type(ions_t),
intent(in) :: ions
3462 integer,
intent(in) :: iter
3465 real(real64) :: tmp(3)
3467 if (.not. mpi_world%is_root())
return
3471 assert(ions%space%dim == 3)
3474 call td_write_print_header_init(file_handle)
3477 call write_iter_header_start(file_handle)
3479 call write_iter_string(file_handle,
'# Iter, a, b, c, volume, alpha, beta, gamma, ' &
3480 //
'a_x, a_y, a_z, b_x, b_y, b_z, c_x, c_y, c_z')
3483 call write_iter_string(file_handle,
'#[Iter n.]')
3484 call write_iter_header(file_handle,
'[' // trim(units_abbrev(units_out%time)) //
']')
3485 call write_iter_string(file_handle, &
3486 'Lengths in ' // trim(units_abbrev(units_out%length)) // &
3487 ', Volume in ' // trim(units_abbrev(units_out%length**3)) // &
3488 ', Angles in degree, Lattice vectors in '// trim(units_abbrev(units_out%length)))
3489 call write_iter_nl(file_handle)
3491 call td_write_print_header_end(file_handle)
3494 call write_iter_start(file_handle)
3498 tmp(idir) = units_from_atomic(units_out%length, norm2(ions%latt%rlattice(1:3, idir)))
3500 call write_iter_double(file_handle, tmp, 3)
3503 tmp(1) = units_from_atomic(units_out%length**3, ions%latt%rcell_volume)
3504 call write_iter_double(file_handle, tmp(1), 1)
3507 call write_iter_double(file_handle, ions%latt%alpha, 1)
3508 call write_iter_double(file_handle, ions%latt%beta, 1)
3509 call write_iter_double(file_handle, ions%latt%gamma, 1)
3513 tmp(1:3) = units_from_atomic(units_out%length, ions%latt%rlattice(:, idir))
3514 call write_iter_double(file_handle, tmp, 3)
3516 call write_iter_nl(file_handle)
3525 type(namespace_t),
intent(in) :: namespace
3526 integer,
intent(in) :: iter
3527 real(real64),
intent(in) :: dt
3529 integer :: default, flags, iout, first
3584 call parse_variable(namespace,
'MaxwellTDOutput', default, flags)
3586 if (.not. varinfo_valid_option(
'MaxwellTDOutput', flags, is_flag = .
true.))
then
3587 call messages_input_error(namespace,
'MaxwellTDOutput')
3591 writ%out(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
3592 if (writ%out(iout)%write)
then
3593 writ%out(iout + 1)%write = .
true.
3594 writ%out(iout + 2)%write = .
true.
3599 writ%out(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
3608 call io_mkdir(
'td.general', namespace)
3613 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_e_field_x", namespace)))
3615 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_e_field_y", namespace)))
3617 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_e_field_z", namespace)))
3623 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_b_field_x", namespace)))
3625 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_b_field_y", namespace)))
3627 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_b_field_z", namespace)))
3633 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_e_field_x", namespace)))
3635 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_e_field_y", namespace)))
3637 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_e_field_z", namespace)))
3643 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_b_field_x", namespace)))
3645 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_b_field_y", namespace)))
3647 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_b_field_z", namespace)))
3653 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_e_field_x", namespace)))
3655 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_e_field_y", namespace)))
3657 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_e_field_z", namespace)))
3663 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_b_field_x", namespace)))
3665 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_b_field_y", namespace)))
3667 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_b_field_z", namespace)))
3673 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/maxwell_energy", namespace)))
3678 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/electric_field_surface-x", namespace)))
3683 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/electric_field_surface-y", namespace)))
3688 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/electric_field_surface-z", namespace)))
3693 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/magnetic_field_surface-x", namespace)))
3698 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/magnetic_field_surface-y", namespace)))
3703 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/magnetic_field_surface-z", namespace)))
3719 if (writ%out(iout)%write)
call write_iter_end(writ%out(iout)%handle)
3727 subroutine td_write_mxll_iter(writ, space, gr, st, hm, helmholtz, dt, iter, namespace)
3729 class(space_t),
intent(in) :: space
3730 type(grid_t),
intent(inout) :: gr
3731 type(states_mxll_t),
intent(inout) :: st
3732 type(hamiltonian_mxll_t),
intent(inout) :: hm
3733 type(helmholtz_decomposition_t),
intent(inout) :: helmholtz
3734 real(real64),
intent(in) :: dt
3735 integer,
intent(in) :: iter
3736 type(namespace_t),
intent(in) :: namespace
3741 call profiling_in(
"TD_WRITE_ITER_MAXWELL")
3744 call helmholtz%get_trans_field(namespace, st%rs_state_trans, total_field=st%rs_state)
3745 call get_rs_state_at_point(st%selected_points_rs_state_trans(:,:), st%rs_state_trans, &
3746 st%selected_points_coordinate(:,:), st, gr)
3749 hm%energy%energy_trans = m_zero
3753 call helmholtz%get_long_field(namespace, st%rs_state_long, total_field=st%rs_state)
3754 call get_rs_state_at_point(st%selected_points_rs_state_long(:,:), st%rs_state_long, &
3755 st%selected_points_coordinate(:,:), st, gr)
3758 hm%energy%energy_long = m_zero
3850 call profiling_out(
"TD_WRITE_ITER_MAXWELL")
3859 type(hamiltonian_mxll_t),
intent(in) :: hm
3860 integer,
intent(in) :: iter
3864 integer :: n_columns
3866 if (.not. mpi_world%is_root())
return
3891 call write_iter_header(
out_maxwell_energy,
'[' // trim(units_abbrev(units_out%time)) //
']')
3893 do ii = 1, n_columns
3894 call write_iter_header(
out_maxwell_energy,
'[' // trim(units_abbrev(units_out%energy)) //
']')
3902 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy), 1)
3903 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%e_energy), 1)
3904 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%b_energy), 1)
3906 hm%energy%energy+hm%energy%boundaries), 1)
3907 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%boundaries), 1)
3908 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_trans), 1)
3909 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_long), 1)
3910 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_plane_waves), 1)
3919 type(c_ptr),
intent(inout) :: out_field_surf
3920 type(states_mxll_t),
intent(in) :: st
3921 integer,
intent(in) :: dim
3922 integer,
intent(in) :: iter
3926 integer :: n_columns
3928 if (.not. mpi_world%is_root())
return
3935 call td_write_print_header_init(out_field_surf)
3938 call write_iter_header_start(out_field_surf)
3939 call write_iter_header(out_field_surf,
'- x direction')
3940 call write_iter_header(out_field_surf,
'+ x direction')
3941 call write_iter_header(out_field_surf,
'- y direction')
3942 call write_iter_header(out_field_surf,
'+ y direction')
3943 call write_iter_header(out_field_surf,
'- z direction')
3944 call write_iter_header(out_field_surf,
'+ z direction')
3945 call write_iter_header(out_field_surf,
'- x dir. p. w.')
3946 call write_iter_header(out_field_surf,
'+ x dir. p. w.')
3947 call write_iter_header(out_field_surf,
'- y dir. p. w.')
3948 call write_iter_header(out_field_surf,
'+ y dir. p. w.')
3949 call write_iter_header(out_field_surf,
'- z dir. p. w.')
3950 call write_iter_header(out_field_surf,
'+ z dir. p. w.')
3952 call write_iter_nl(out_field_surf)
3955 call write_iter_string(out_field_surf,
'#[Iter n.]')
3956 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(units_out%time)) //
']')
3958 do ii = 1, n_columns
3959 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(units_out%energy/units_out%length)) //
']')
3961 call write_iter_nl(out_field_surf)
3963 call td_write_print_header_end(out_field_surf)
3966 call write_iter_start(out_field_surf)
3967 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3968 st%electric_field_box_surface(1,1,dim)), 1)
3969 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3970 st%electric_field_box_surface(2,1,dim)), 1)
3971 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3972 st%electric_field_box_surface(1,2,dim)), 1)
3973 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3974 st%electric_field_box_surface(2,2,dim)), 1)
3975 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3976 st%electric_field_box_surface(1,3,dim)), 1)
3977 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3978 st%electric_field_box_surface(2,3,dim)), 1)
3979 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3980 st%electric_field_box_surface_plane_waves(1,1,dim)), 1)
3981 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3982 st%electric_field_box_surface_plane_waves(2,1,dim)), 1)
3983 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3984 st%electric_field_box_surface_plane_waves(1,2,dim)), 1)
3985 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3986 st%electric_field_box_surface_plane_waves(2,2,dim)), 1)
3987 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3988 st%electric_field_box_surface_plane_waves(1,3,dim)), 1)
3989 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3990 st%electric_field_box_surface_plane_waves(2,3,dim)), 1)
3991 call write_iter_nl(out_field_surf)
3999 type(c_ptr),
intent(inout) :: out_field_surf
4000 type(states_mxll_t),
intent(in) :: st
4001 integer,
intent(in) :: dim
4002 integer,
intent(in) :: iter
4006 integer :: n_columns
4008 if (.not. mpi_world%is_root())
return
4015 call td_write_print_header_init(out_field_surf)
4018 call write_iter_header_start(out_field_surf)
4019 call write_iter_header(out_field_surf,
'- x direction')
4020 call write_iter_header(out_field_surf,
'+ x direction')
4021 call write_iter_header(out_field_surf,
'- y direction')
4022 call write_iter_header(out_field_surf,
'+ y direction')
4023 call write_iter_header(out_field_surf,
'- z direction')
4024 call write_iter_header(out_field_surf,
'+ z direction')
4025 call write_iter_header(out_field_surf,
'- x dir. p. w.')
4026 call write_iter_header(out_field_surf,
'+ x dir. p. w.')
4027 call write_iter_header(out_field_surf,
'- y dir. p. w.')
4028 call write_iter_header(out_field_surf,
'+ y dir. p. w.')
4029 call write_iter_header(out_field_surf,
'- z dir. p. w.')
4030 call write_iter_header(out_field_surf,
'+ z dir. p. w.')
4032 call write_iter_nl(out_field_surf)
4035 call write_iter_string(out_field_surf,
'#[Iter n.]')
4036 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(units_out%time)) //
']')
4038 do ii = 1, n_columns
4039 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(unit_one/units_out%length**2)) //
']')
4041 call write_iter_nl(out_field_surf)
4043 call td_write_print_header_end(out_field_surf)
4046 call write_iter_start(out_field_surf)
4047 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4048 st%magnetic_field_box_surface(1,1,dim)), 1)
4049 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4050 st%magnetic_field_box_surface(2,1,dim)), 1)
4051 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4052 st%magnetic_field_box_surface(1,2,dim)), 1)
4053 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4054 st%magnetic_field_box_surface(2,2,dim)), 1)
4055 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4056 st%magnetic_field_box_surface(1,3,dim)), 1)
4057 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4058 st%magnetic_field_box_surface(2,3,dim)), 1)
4059 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4060 st%magnetic_field_box_surface_plane_waves(1,1,dim)), 1)
4061 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4062 st%magnetic_field_box_surface_plane_waves(2,1,dim)), 1)
4063 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4064 st%magnetic_field_box_surface_plane_waves(1,2,dim)), 1)
4065 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4066 st%magnetic_field_box_surface_plane_waves(2,2,dim)), 1)
4067 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4068 st%magnetic_field_box_surface_plane_waves(1,3,dim)), 1)
4069 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4070 st%magnetic_field_box_surface_plane_waves(2,3,dim)), 1)
4071 call write_iter_nl(out_field_surf)
4077 subroutine td_write_fields(out_fields, space, st, iter, dt, e_or_b_field, field_type, idir)
4078 type(c_ptr),
intent(inout) :: out_fields
4079 class(space_t),
intent(in) :: space
4080 type(states_mxll_t),
intent(in) :: st
4081 integer,
intent(in) :: iter
4082 real(real64),
intent(in) :: dt
4083 integer,
intent(in) :: e_or_b_field
4084 integer,
intent(in) :: field_type
4085 integer,
intent(in) :: idir
4089 real(real64) :: field(space%dim), selected_field
4090 character(len=80) :: aux
4092 if (.not. mpi_world%is_root())
return
4097 call td_write_print_header_init(out_fields)
4100 write(aux,
'(a7,e20.12,3a)')
'# dt = ', units_from_atomic(units_out%time, dt), &
4101 " [", trim(units_abbrev(units_out%time)),
"]"
4102 call write_iter_string(out_fields, aux)
4103 call write_iter_nl(out_fields)
4105 call write_iter_header_start(out_fields)
4107 do id = 1, st%selected_points_number
4108 select case (e_or_b_field)
4110 write(aux,
'(a,i1,a)')
'E(', id,
')'
4112 write(aux,
'(a,i1,a)')
'B(', id,
')'
4114 call write_iter_header(out_fields, aux)
4117 call write_iter_nl(out_fields)
4118 call write_iter_string(out_fields,
'#[Iter n.]')
4119 call write_iter_header(out_fields,
' [' // trim(units_abbrev(units_out%time)) //
']')
4124 aux =
' [' // trim(units_abbrev(units_out%force)) //
']'
4125 do id = 1, st%selected_points_number
4126 call write_iter_header(out_fields, aux)
4128 call write_iter_nl(out_fields)
4129 call td_write_print_header_end(out_fields)
4132 call write_iter_start(out_fields)
4134 do id = 1, st%selected_points_number
4135 select case (e_or_b_field)
4138 select case (field_type)
4140 call get_electric_field_vector(st%selected_points_rs_state(:,id), field(1:st%dim))
4142 call get_electric_field_vector(st%selected_points_rs_state_long(:,id), field(1:st%dim))
4144 call get_electric_field_vector(st%selected_points_rs_state_trans(:,id), field(1:st%dim))
4146 selected_field = units_from_atomic(units_out%energy/units_out%length, field(idir))
4149 select case (field_type)
4151 call get_magnetic_field_vector(st%selected_points_rs_state(:,id), st%rs_sign, field(1:st%dim))
4153 call get_magnetic_field_vector(st%selected_points_rs_state_long(:,id), st%rs_sign, field(1:st%dim))
4155 call get_magnetic_field_vector(st%selected_points_rs_state_trans(:,id), st%rs_sign, field(1:st%dim))
4157 selected_field = units_from_atomic(unit_one/units_out%length**2, field(idir))
4159 call write_iter_double(out_fields, selected_field, 1)
4162 call write_iter_nl(out_fields)
4170 type(namespace_t),
intent(in) :: namespace
4171 class(space_t),
intent(in) :: space
4172 type(grid_t),
intent(inout) :: gr
4173 type(states_mxll_t),
intent(inout) :: st
4174 type(hamiltonian_mxll_t),
intent(inout) :: hm
4175 type(helmholtz_decomposition_t),
intent(inout) :: helmholtz
4176 type(output_t),
intent(in) :: outp
4177 integer,
intent(in) :: iter
4178 real(real64),
intent(in) :: time
4180 character(len=256) :: filename
4182 push_sub(td_write_maxwell_free_data)
4183 call profiling_in(
"TD_WRITE_MAXWELL_DATA")
4186 write(filename,
'(a,a,i7.7)') trim(outp%iter_dir),
"td.", iter
4188 call output_mxll(outp, namespace, space, gr, st, hm, helmholtz, time, filename)
4190 call profiling_out(
"TD_WRITE_MAXWELL_DATA")
4191 pop_sub(td_write_maxwell_free_data)
ssize_t ssize_t write(int __fd, const void *__buf, size_t __n) __attribute__((__access__(__read_only__
constant times a vector plus a vector
Copies a vector x, to a vector y.
Sets the iteration number to the C object.
Writes to the corresponding file and adds one to the iteration. Must be called after write_iter_init(...
double exp(double __x) __attribute__((__nothrow__
This module contains interfaces for BLAS routines You should not use these routines directly....
This module implements a calculator for the density and defines related functions.
subroutine, public density_calc(st, gr, density, istin)
Computes the density from the orbitals in st.
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
integer, parameter, public spinors
integer, parameter, public spin_polarized
subroutine, public excited_states_kill(excited_state)
Kills an excited_state structure.
subroutine, public excited_states_init(excited_state, ground_state, filename, namespace)
Fills in an excited_state structure, by reading a file called "filename". This file describes the "pr...
type(gauge_field_t) function, pointer, public list_get_gauge_field(partners)
logical function, public list_has_lasers(partners)
type(lasers_t) function, pointer, public list_get_lasers(partners)
subroutine, public gauge_field_output_write(this, out_gauge, iter)
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
complex(real64), parameter, public m_z0
real(real64), parameter, public lmm_r_single_atom
Default local magnetic moments sphere radius for an isolated system.
complex(real64), parameter, public m_zi
integer, parameter, public max_output_types
real(real64), parameter, public m_half
real(real64), parameter, public m_one
real(real64), parameter, public m_min_occ
Minimal occupation that is considered to be non-zero.
This module implements the underlying real-space grid.
The Helmholtz decomposition is intended to contain "only mathematical" functions and procedures to co...
This module defines classes and functions for interaction partners.
subroutine, public zio_function_output(how, dir, fname, namespace, space, mesh, ff, unit, ierr, pos, atoms, grp, root)
Top-level IO routine for functions defined on the mesh.
subroutine, public io_function_read_what_how_when(namespace, space, what, how, output_interval, what_tag_in, how_tag_in, output_interval_tag_in, ignore_error)
subroutine, public io_close(iunit, grp)
character(len=max_path_len) function, public io_workpath(path, namespace)
construct path name from given name and namespace
subroutine, public io_rm(fname, namespace)
subroutine, public io_mkdir(fname, namespace, parents)
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
real(real64) function, public ion_dynamics_temperature(ions)
This function returns the ionic temperature in energy units.
integer, parameter, public qkickmode_cos
integer, parameter, public qkickmode_none
integer, parameter, public qkickmode_sin
subroutine, public kick_function_get(space, mesh, kick, kick_function, iq, to_interpolate)
subroutine, public kick_write(kick, iunit, out)
integer, parameter, public qkickmode_bessel
subroutine, public lasers_nondipole_laser_field_step(this, field, time)
Retrieves the NDSFA vector_potential correction. The nondipole field is obtained for consecutive time...
subroutine, public lasers_set_nondipole_parameters(this, ndfield, nd_integration_time)
Set parameters for nondipole SFA calculation.
logical function, public lasers_with_nondipole_field(lasers)
Check if a nondipole SFA correction should be computed for the given laser.
integer, parameter, public e_field_electric
integer, parameter, public e_field_vector_potential
integer, parameter, public e_field_scalar_potential
integer pure elemental function, public laser_kind(laser)
subroutine, public laser_field(laser, field, time)
Retrieves the value of either the electric or the magnetic field. If the laser is given by a scalar p...
integer, parameter, public e_field_magnetic
integer, parameter, public dft_u_none
integer, parameter, public dft_u_acbn0
subroutine, public magnetic_local_moments(mesh, st, ions, boundaries, rho, rr, lmm)
subroutine, public magnetic_moment(mesh, st, rho, mm)
subroutine, public magnetic_total_magnetization(mesh, st, qq, trans_mag)
This module is intended to contain "only mathematical" functions and procedures.
subroutine, public ylmr_real(xx, li, mi, ylm)
This is a Numerical Recipes-based subroutine computes real spherical harmonics ylm at position (x,...
This module defines functions over batches of mesh functions.
This module defines various routines, operating on mesh functions.
subroutine, public dmf_multipoles(mesh, ff, lmax, multipole, mask)
This routine calculates the multipoles of a function ff.
This module defines the meshes, which are used in Octopus.
subroutine, public messages_not_implemented(feature, namespace)
subroutine, public messages_warning(no_lines, all_nodes, namespace)
subroutine, public messages_obsolete_variable(namespace, name, rep)
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_experimental(name, namespace)
subroutine, public modelmb_sym_all_states(space, mesh, st)
This module contains some common usage patterns of MPI routines.
type(mpi_grp_t), public mpi_world
This module handles the communicators for the various parallelization strategies.
integer, parameter, public velocity_gauge_dipole
this module contains the low-level part of the output system
subroutine, public output_modelmb(outp, namespace, space, dir, gr, ions, iter, st)
this module contains the output system
subroutine, public output_all(outp, namespace, space, dir, gr, ions, iter, st, hm, ks)
subroutine, public output_scalar_pot(outp, namespace, space, dir, mesh, ions, ext_partners, time)
subroutine, public parse_block_string(blk, l, c, res, convert_to_c)
integer function, public parse_block(namespace, name, blk, check_varinfo_)
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
integer, parameter, public restart_gs
integer, parameter, public restart_proj
integer, parameter, public restart_type_load
subroutine, public zstates_elec_matrix(st1, st2, mesh, aa)
subroutine, public zstates_elec_calc_projections(st, gs_st, namespace, mesh, ik, proj, gs_nst)
This routine computes the projection between two set of states.
This module handles spin dimensions of the states and the k-point distribution.
logical function, public state_kpt_is_local(st, ist, ik)
check whether a given state (ist, ik) is on the local node
subroutine, public states_elec_end(st)
finalize the states_elec_t object
subroutine, public states_elec_deallocate_wfns(st)
Deallocates the KS wavefunctions defined within a states_elec_t structure.
subroutine, public states_elec_allocate_wfns(st, mesh, wfs_type, skip, packed)
Allocates the KS wavefunctions defined within a states_elec_t structure.
subroutine, public states_elec_copy(stout, stin, exclude_wfns, exclude_eigenval, special)
make a (selective) copy of a states_elec_t object
subroutine, public states_elec_look(restart, nik, dim, nst, ierr)
Reads the 'states' file in the restart directory, and finds out the nik, dim, and nst contained in it...
This module handles reading and writing restart information for the states_elec_t.
subroutine, public states_elec_load(restart, namespace, space, st, mesh, kpoints, ierr, iter, lr, lowest_missing, label, verbose, skip)
returns in ierr: <0 => Fatal error, or nothing read =0 => read all wavefunctions >0 => could only rea...
subroutine, public td_calc_tacc(namespace, space, gr, ions, ext_partners, st, hm, acc, time)
Electronic acceleration (to calculate harmonic spectrum...) It is calculated as:
subroutine, public td_calc_tvel(namespace, gr, st, space, hm, ions, vel)
Electronic velocity (to calculate harmonic spectrum...) It is calculated as:
subroutine, public td_calc_ionch(mesh, st, ch, Nch)
Multiple ionization probabilities calculated form the KS orbital densities C. Ullrich,...
subroutine, public td_write_coordinates(out_coords, natoms, space, pos, vel, tot_forces, iter)
subroutine, public td_write_sep_coordinates(out_coords, natoms, space, pos, vel, tot_forces, iter, which)
subroutine, public td_write_print_header_init(out)
subroutine, public td_write_print_header_end(out)
subroutine td_write_magnetic_field_box_surface(out_field_surf, st, dim, iter)
integer, parameter, public out_total_current
integer, parameter maxwell_b_field
integer, parameter, public out_maxwell_max
subroutine td_write_proj(out_proj, space, mesh, ions, st, gs_st, kick, iter)
integer, parameter, public out_q
integer, parameter, public out_mxll_field
subroutine calc_projections(mesh, st, gs_st, projections)
This subroutine calculates:
integer, parameter out_b_field_surface_y
subroutine td_write_ionch(out_ionch, mesh, st, iter)
integer, parameter, public out_tot_m
integer, parameter, public out_norm_ks
integer, parameter out_maxwell_trans_b_field
integer, parameter, public out_cell_parameters
subroutine td_write_multipole_r(out_multip, space, mesh, ions, st, lmax, kick, rho, iter, mpi_grp)
Write multipoles to the corresponding file.
integer, parameter, public out_proj
integer, parameter, public out_partial_charges
integer, parameter, public out_separate_coords
subroutine td_write_total_current(out_total_current, space, mesh, st, iter)
subroutine, public td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, dt)
subroutine td_write_effective_u(out_coords, lda_u, iter)
integer, parameter maxwell_trans_field
subroutine td_write_acc(out_acc, namespace, space, gr, ions, st, hm, ext_partners, dt, iter)
subroutine, public td_write_mxll_init(writ, namespace, iter, dt)
subroutine, public td_write_mxll_end(writ)
subroutine td_write_mxll_field(out_mxll, space, hm, dt, iter)
integer, parameter out_b_field_surface_x
integer, parameter out_maxwell_long_e_field
integer, parameter, public out_kp_proj
integer, parameter, public out_magnets
subroutine td_write_multipole(out_multip, space, gr, ions, st, lmax, kick, iter)
Top-level routine that write multipoles to file, or files depending on whether a state-resolved outpu...
subroutine td_write_electric_field_box_surface(out_field_surf, st, dim, iter)
subroutine td_write_floquet(namespace, space, hm, ext_partners, gr, st, iter)
integer, parameter out_e_field_surface_y
integer, parameter, public out_angular
subroutine td_write_populations(out_populations, namespace, space, mesh, st, writ, dt, iter)
integer, parameter, public out_max
integer, parameter out_maxwell_long_b_field
integer, parameter, public out_energy
integer, parameter, public out_spin
subroutine td_write_ftchd(out_ftchd, space, mesh, st, kick, iter)
subroutine td_write_partial_charges(out_partial_charges, mesh, st, ions, iter)
integer, parameter out_dftu_max
For the Maxwell fields we increment in steps of 3 to leave room for x, y, and z output.
subroutine td_write_laser(out_laser, space, lasers, dt, iter)
integer, parameter out_maxwell_total_b_field
integer, parameter, public out_ftchd
integer, parameter, public out_separate_velocity
subroutine td_write_tot_mag(out_magnets, mesh, st, kick, iter)
subroutine td_write_q(out_q, space, ks, iter)
integer, parameter, public out_floquet
subroutine, public td_write_mxll_free_data(namespace, space, gr, st, hm, helmholtz, outp, iter, time)
integer, parameter, public out_acc
integer, parameter, public out_ion_ch
integer, parameter maxwell_long_field
integer, parameter, public out_n_ex
integer, parameter out_b_field_surface_z
subroutine td_write_proj_kp(mesh, kpoints, st, gs_st, namespace, iter)
integer, parameter, public out_temperature
subroutine td_write_norm_ks_orbitals(file_handle, grid, kpoints, st, iter)
Write the norm of the KS orbitals to file as a function of time step.
subroutine, public td_write_data(writ)
subroutine td_write_total_heat_current(write_obj, space, hm, gr, st, iter)
integer, parameter out_e_field_surface_z
integer, parameter maxwell_total_field
integer, parameter, public out_coords
integer, parameter out_maxwell_total_e_field
integer, parameter, public out_laser
integer, parameter, public out_eigs
integer, parameter, public out_total_heat_current
integer, parameter out_e_field_surface_x
subroutine, public td_write_kick(outp, namespace, space, mesh, kick, ions, iter)
subroutine, public td_write_end(writ)
subroutine td_write_angular(out_angular, namespace, space, gr, ions, hm, st, kick, iter)
Computes and outputs the orbital angular momentum defined by.
subroutine td_write_eigs(out_eigs, st, iter)
subroutine, public td_write_iter(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, kick, ks, dt, iter, mc, recalculate_gs)
subroutine td_write_n_ex(out_nex, outp, namespace, mesh, kpoints, st, gs_st, iter)
This routine computes the total number of excited electrons based on projections on the GS orbitals T...
subroutine td_write_fields(out_fields, space, st, iter, dt, e_or_b_field, field_type, idir)
subroutine td_write_spin(out_spin, mesh, st, iter)
integer, parameter, public out_vel
integer, parameter, public out_gauge_field
subroutine td_write_temperature(out_temperature, ions, iter)
integer, parameter maxwell_e_field
integer, parameter, public out_populations
subroutine, public td_write_mxll_iter(writ, space, gr, st, hm, helmholtz, dt, iter, namespace)
subroutine td_write_cell_parameters(file_handle, ions, iter)
Write the cell parameters as a function of time.
subroutine td_write_local_magnetic_moments(out_magnets, gr, st, ions, lmm_r, iter)
subroutine td_write_vel(out_vel, namespace, gr, st, space, hm, ions, iter)
subroutine, public td_write_init(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, ks, ions_move, with_gauge_field, kick, iter, max_iter, dt, mc)
Initialize files to write when prograting in time.
integer, parameter out_maxwell_energy
subroutine td_write_energy(out_energy, hm, iter, ke)
subroutine td_write_maxwell_energy(out_maxwell_energy, hm, iter)
integer, parameter, public out_separate_forces
integer, parameter out_maxwell_trans_e_field
type(type_t), public type_cmplx
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
type(unit_t), public unit_kelvin
For converting energies into temperatures.
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.
character pure function, public index2axis(idir)
subroutine, public v_ks_calculate_current(this, calc_cur)
subroutine, public v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval, time, calc_energy, calc_current, force_semilocal)
Explicit interfaces to C functions, defined in write_iter_low.cc.
subroutine, public write_iter_header(out, string)
subroutine, public write_iter_string(out, string)
subroutine, public write_iter_init(out, iter, factor, file)
Extension of space that contains the knowledge of the spin dimension.
Description of the grid, containing information on derivatives, stencil, and symmetries.
Describes mesh distribution to nodes.
This is defined even when running serial.
Stores all communicators and groups.
The states_elec_t class contains all electronic wave functions.
Time-dependent Write Properties.
subroutine dipole_matrix_elements(dir)