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 :: &
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 :: td_start_proj
234 integer :: n_excited_states
236 integer :: compute_interval
242 subroutine td_write_kick(outp, namespace, space, mesh, kick, ions, iter)
246 class(
mesh_t),
intent(in) :: mesh
247 type(
kick_t),
intent(in) :: kick
248 type(
ions_t),
intent(in) :: ions
249 integer,
intent(in) :: iter
251 complex(real64),
allocatable :: kick_function(:)
252 character(len=256) :: filename
257 write(filename,
'(a,i7.7)')
"td.", iter
258 if (outp%what(option__output__delta_perturbation))
then
259 safe_allocate(kick_function(1:mesh%np))
261 call zio_function_output(outp%how(option__output__delta_perturbation), filename,
"kick_function", namespace, &
262 space, mesh, kick_function(:),
units_out%energy, err, pos=ions%pos, atoms=ions%atom)
263 safe_deallocate_a(kick_function)
279 subroutine td_write_init(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, ks, ions_move, &
280 with_gauge_field, kick, iter, max_iter, dt, mc)
284 type(
output_t),
intent(inout) :: outp
285 type(
grid_t),
intent(in) :: gr
288 type(
ions_t),
intent(in) :: ions
290 type(
v_ks_t),
intent(inout) :: ks
291 logical,
intent(in) :: ions_move
292 logical,
intent(in) :: with_gauge_field
293 type(
kick_t),
intent(in) :: kick
294 integer,
intent(in) :: iter
295 integer,
intent(in) :: max_iter
296 real(real64),
intent(in) :: dt
300 integer :: ierr, first, ii, ist, jj, flags, iout, default, ifile
305 character(len=MAX_PATH_LEN) :: filename
307 logical :: resolve_states
308 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 .and. resolve_states)
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
601 writ%td_start_proj = 1
617 call parse_variable(namespace,
'TDProjStateStart', 1, writ%td_start_proj)
619 if (.not. writ%out(
out_n_ex)%write) writ%gs_st%st_start = writ%td_start_proj
621 if (st%parallel_in_states .and. writ%out(
out_proj)%write .and. writ%gs_st%st_start > 1)
then
627 writ%gs_st%lnst = writ%gs_st%st_end - writ%gs_st%st_start + 1
631 writ%gs_st%parallel_in_states = .false.
634 safe_allocate(writ%gs_st%occ(1:writ%gs_st%nst, 1:writ%gs_st%nik))
635 safe_allocate(writ%gs_st%eigenval(1:writ%gs_st%nst, 1:writ%gs_st%nik))
639 safe_allocate(writ%gs_st%node(1:writ%gs_st%nst))
640 writ%gs_st%node(:) = 0
642 writ%gs_st%eigenval = huge(writ%gs_st%eigenval)
644 if (writ%gs_st%d%ispin ==
spinors)
then
645 safe_deallocate_a(writ%gs_st%spin)
646 safe_allocate(writ%gs_st%spin(1:3, 1:writ%gs_st%nst, 1:writ%gs_st%nik))
649 safe_allocate(skip(1:writ%gs_st%nst))
651 skip(1:writ%gs_st%st_start-1) = .
true.
655 safe_deallocate_a(skip)
659 fixed_occ=.
true., ierr=ierr, label =
': gs for TDOutput')
661 if (ierr /= 0 .and. ierr /= (writ%gs_st%st_end-writ%gs_st%st_start+1)*writ%gs_st%nik &
662 *writ%gs_st%d%dim*writ%gs_st%mpi_grp%size)
then
663 message(1) =
"Unable to read wavefunctions for TDOutput."
708 if (
parse_block(namespace,
'TDExcitedStatesToProject', blk) == 0)
then
710 safe_allocate(writ%excited_st(1:writ%n_excited_states))
711 do ist = 1, writ%n_excited_states
716 writ%n_excited_states = 0
730 call parse_variable(namespace,
'TDOutputComputeInterval', 50, writ%compute_interval)
731 if (writ%compute_interval < 0)
then
732 message(1) =
"TDOutputComputeInterval must be >= 0."
748 call io_mkdir(
'td.general', namespace)
759 do ifile = 1, out_max
763 if (writ%out(ifile)%write)
then
767 trim(
io_workpath(
"td.general/"//trim(td_file_name(ifile)), namespace)))
775 if (writ%out(out_multipoles)%write .and. .not. resolve_states)
then
778 trim(
io_workpath(
"td.general/multipoles", namespace)))
782 select case (kick%qkick_mode)
784 write(filename,
'(a)')
'td.general/ftchd.sin'
786 write(filename,
'(a)')
'td.general/ftchd.cos'
788 write(filename,
'(a, SP, I0.3, a, I0.3)')
'td.general/ftchd.l', kick%qbessel_l,
'_m', kick%qbessel_m
790 write(filename,
'(a)')
'td.general/ftchd'
802 call io_rm(
"td.general/laser", namespace=namespace)
819 if (writ%out(out_multipoles)%write .and. resolve_states)
then
821 writ%out(out_multipoles)%hand_start = st%st_start
822 writ%out(out_multipoles)%hand_end = st%st_end
823 writ%out(out_multipoles)%resolve_states = .
true.
824 writ%out(out_multipoles)%mpi_grp = gr%mpi_grp
826 safe_allocate(writ%out(out_multipoles)%mult_handles(st%st_start:st%st_end))
829 do ist = st%st_start, st%st_end
830 write(filename,
'(a,i4.4)')
'td.general/multipoles-ist', ist
843 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
844 calc_eigenval=.false., time = iter*dt, calc_energy = .false.)
848 if (all(outp%how == 0) .and. writ%out(
out_n_ex)%write)
then
850 if (outp%how(option__output__current_kpt) + outp%how(option__output__density_kpt) /= 0)
then
851 call io_mkdir(outp%iter_dir, namespace)
873 if (hm%lda_u_level ==
dft_u_acbn0) default = default + 2**(out_dftu_effective_u - 1)
881 writ%out_dftu(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
885 if (writ%out_dftu(out_dftu_effective_u)%write)
then
888 trim(
io_workpath(
"td.general/effectiveU", namespace)))
906 if (writ%out(iout)%write)
then
908 if (writ%out(iout)%resolve_states)
then
909 do ist = writ%out(iout)%hand_start, writ%out(iout)%hand_end
912 safe_deallocate_a(writ%out(iout)%mult_handles)
922 if (writ%out_dftu(iout)%write)
call write_iter_end(writ%out_dftu(iout)%handle)
928 do ist = 1, writ%n_excited_states
931 writ%n_excited_states = 0
944 subroutine td_write_iter(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, kick, ks, dt, iter, mc, recalculate_gs)
947 class(
space_t),
intent(in) :: space
949 type(
grid_t),
intent(in) :: gr
952 type(
ions_t),
intent(inout) :: ions
954 type(
kick_t),
intent(in) :: kick
955 type(
v_ks_t),
intent(in) :: ks
956 real(real64),
intent(in) :: dt
957 integer,
intent(in) :: iter
959 logical,
intent(in) :: recalculate_gs
967 if (writ%out(out_multipoles)%write)
then
968 call td_write_multipole(writ%out(out_multipoles), space, gr, ions, st, writ%lmax, kick, iter)
991 if (writ%out(
out_proj)%write .and. mod(iter, writ%compute_interval) == 0)
then
993 call td_write_proj(writ%out(
out_proj)%handle, space, gr, ions, st, writ%gs_st, writ%td_start_proj, kick, iter)
1000 if (writ%out(
out_kp_proj)%write .and. mod(iter, writ%compute_interval) == 0)
then
1006 ions%pos, ions%vel, ions%tot_force, iter)
1011 ions%pos, ions%vel, ions%tot_force, iter, 1)
1016 ions%pos, ions%vel, ions%tot_force, iter, 2)
1021 ions%pos, ions%vel, ions%tot_force, iter, 3)
1032 if (writ%out(
out_acc)%write)
then
1033 call td_write_acc(writ%out(
out_acc)%handle, namespace, space, gr, ions, st, hm, ext_partners, dt, iter)
1036 if (writ%out(
out_vel)%write)
then
1049 if(
associated(gfield))
then
1075 if (writ%out(
out_n_ex)%write .and. mod(iter, writ%compute_interval) == 0)
then
1077 if (recalculate_gs)
then
1081 ierr=ierr, label =
': Houston states for TDOutput')
1085 call td_write_n_ex(writ%out(
out_n_ex)%handle, outp, namespace, gr, hm%kpoints, st, writ%gs_st, iter)
1097 if (writ%out_dftu(out_dftu_effective_u)%write)
then
1101 if (writ%out(
out_q)%write .and. ks%has_photons)
then
1105 if (writ%out(
out_mxll_field)%write .and. hm%mxll%calc_field_dip)
then
1122 do iout = 1, out_max
1124 if (writ%out(iout)%write)
then
1126 if (writ%out(iout)%resolve_states)
then
1127 do ii = writ%out(iout)%hand_start, writ%out(iout)%hand_end
1139 if (writ%out_dftu(iout)%write)
call write_iter_flush(writ%out_dftu(iout)%handle)
1148 subroutine td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, dt)
1151 type(
grid_t),
intent(in) :: gr
1154 type(
v_ks_t),
intent(inout) :: ks
1156 type(
ions_t),
intent(in) :: ions
1158 integer,
intent(in) :: iter
1159 real(real64),
optional,
intent(in) :: dt
1161 character(len=256) :: filename
1167 if (st%modelmbparticles%nparticle > 0)
then
1172 write(filename,
'(a,a,i7.7)') trim(outp%iter_dir),
"td.", iter
1174 call output_all(outp, namespace, space, filename, gr, ions, iter, st, hm, ks)
1176 call output_modelmb(outp, namespace, space, filename, gr, ions, iter, st)
1178 if (
present(dt))
then
1179 call output_scalar_pot(outp, namespace, space, filename, gr, ions, ext_partners, iter*dt)
1181 if (iter == 0)
call output_scalar_pot(outp, namespace, space, filename, gr, ions, ext_partners)
1190 type(c_ptr),
intent(inout) ::
out_spin
1191 class(
mesh_t),
intent(in) :: mesh
1193 integer,
intent(in) :: iter
1195 character(len=130) :: aux
1196 real(real64) :: spin(3)
1212 if (st%d%ispin ==
spinors)
then
1213 write(aux,
'(a2,18x)')
'Sx'
1215 write(aux,
'(a2,18x)')
'Sy'
1218 write(aux,
'(a2,18x)')
'Sz'
1226 select case (st%d%ispin)
1243 type(
grid_t),
intent(in) :: gr
1245 type(
ions_t),
intent(in) :: ions
1246 real(real64),
intent(in) :: lmm_r
1247 integer,
intent(in) :: iter
1250 character(len=50) :: aux
1251 real(real64),
allocatable :: lmm(:,:)
1256 safe_allocate(lmm(1:3, 1:ions%natoms))
1266 do ia = 1, ions%natoms
1267 if (st%d%ispin ==
spinors)
then
1268 write(aux,
'(a2,i2.2,16x)')
'mx', ia
1270 write(aux,
'(a2,i2.2,16x)')
'my', ia
1273 write(aux,
'(a2,i2.2,16x)')
'mz', ia
1282 do ia = 1, ions%natoms
1283 select case (st%d%ispin)
1293 safe_deallocate_a(lmm)
1300 type(c_ptr),
intent(inout) :: out_magnets
1301 class(
mesh_t),
intent(in) :: mesh
1303 type(
kick_t),
intent(in) :: kick
1304 integer,
intent(in) :: iter
1306 complex(real64),
allocatable :: tm(:,:)
1311 safe_allocate(tm(1:6,1:kick%nqvec))
1313 do iq = 1, kick%nqvec
1343 do iq = 1, kick%nqvec
1352 safe_deallocate_a(tm)
1366 subroutine td_write_angular(out_angular, namespace, space, gr, ions, hm, st, kick, iter)
1367 type(c_ptr),
intent(inout) :: out_angular
1369 class(
space_t),
intent(in) :: space
1370 type(
grid_t),
intent(in) :: gr
1371 type(
ions_t),
intent(inout) :: ions
1374 type(
kick_t),
intent(in) :: kick
1375 integer,
intent(in) :: iter
1378 character(len=130) :: aux
1379 real(real64) :: angular(3)
1386 call angular_momentum%setup_dir(idir)
1389 m_two*real(angular_momentum%zstates_elec_expectation_value(namespace, space, gr, hm, st), real64)
1391 safe_deallocate_p(angular_momentum)
1398 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
1406 write(aux,
'(a4,18x)')
'<Lx>'
1408 write(aux,
'(a4,18x)')
'<Ly>'
1410 write(aux,
'(a4,18x)')
'<Lz>'
1439 class(
space_t),
intent(in) :: space
1440 type(
grid_t),
intent(in) :: gr
1441 type(
ions_t),
intent(in) :: ions
1443 integer,
intent(in) :: lmax
1444 type(
kick_t),
intent(in) :: kick
1445 integer,
intent(in) :: iter
1448 real(real64),
allocatable :: rho(:,:)
1452 if (out_multip%resolve_states)
then
1453 safe_allocate(rho(1:gr%np_part, 1:st%d%nspin))
1456 do ist = st%st_start, st%st_end
1458 call td_write_multipole_r(out_multip%mult_handles(ist), space, gr, ions, st, lmax, kick, rho, iter, &
1459 mpi_grp = out_multip%mpi_grp)
1462 safe_deallocate_a(rho)
1465 if (
allocated(st%frozen_rho))
then
1466 safe_allocate(rho(1:gr%np, 1:st%d%nspin))
1467 call lalg_copy(gr%np, st%d%nspin, st%rho, rho)
1472 safe_deallocate_a(rho)
1484 subroutine td_write_multipole_r(out_multip, space, mesh, ions, st, lmax, kick, rho, iter, mpi_grp)
1485 type(c_ptr),
intent(inout) :: out_multip
1486 class(
space_t),
intent(in) :: space
1487 class(
mesh_t),
intent(in) :: mesh
1488 type(
ions_t),
intent(in) :: ions
1490 integer,
intent(in) :: lmax
1491 type(
kick_t),
intent(in) :: kick
1492 real(real64),
intent(in) :: rho(:,:)
1493 integer,
intent(in) :: iter
1494 type(
mpi_grp_t),
optional,
intent(in) :: mpi_grp
1497 integer :: is, idir, ll, mm, add_lm
1498 character(len=120) :: aux
1499 real(real64) :: ionic_dipole(ions%space%dim)
1500 real(real64),
allocatable :: multipole(:,:)
1506 assert(.not. (lmax > 1 .and. space%dim > 3))
1509 if (
present(mpi_grp)) mpi_grp_ = mpi_grp
1514 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
1518 write(aux,
'(a15,i2)')
'# lmax ', lmax
1526 do is = 1, st%d%nspin
1527 write(aux,
'(a18,i1,a1)')
'Electronic charge(', is,
')'
1530 do idir = 1, space%dim
1531 write(aux,
'(4a1,i1,a1)')
'<',
index2axis(idir),
'>',
'(', is,
')'
1537 write(aux,
'(a2,i2,a4,i2,a2,i1,a1)')
'l=', ll,
', m=', mm,
' (', is,
')'
1548 do is = 1, st%d%nspin
1551 do idir = 1, space%dim
1567 if (space%dim > 3 .and. lmax == 1)
then
1569 safe_allocate(multipole(1:space%dim+1, 1:st%d%nspin))
1571 safe_allocate(multipole(1:(lmax + 1)**2, 1:st%d%nspin))
1575 do is = 1, st%d%nspin
1580 ionic_dipole = ions%dipole()
1581 do is = 1, st%d%nspin
1582 multipole(2:space%dim+1, is) = -ionic_dipole(1:space%dim)/st%d%nspin - multipole(2:space%dim+1, is)
1588 do is = 1, st%d%nspin
1591 do idir = 1, space%dim
1595 add_lm = space%dim + 2
1606 safe_deallocate_a(multipole)
1611 subroutine td_write_ftchd(out_ftchd, space, mesh, st, kick, iter)
1612 type(c_ptr),
intent(inout) :: out_ftchd
1613 class(
space_t),
intent(in) :: space
1614 class(
mesh_t),
intent(in) :: mesh
1616 type(
kick_t),
intent(in) :: kick
1617 integer,
intent(in) :: iter
1619 integer :: is, ip, idir
1620 character(len=120) :: aux, aux2
1621 real(real64) :: ftchd_bessel
1622 complex(real64) :: ftchd
1624 real(real64),
allocatable :: integrand_bessel(:)
1625 complex(real64),
allocatable :: integrand(:)
1632 write(aux,
'(a15, i2)')
'# qkickmode ', kick%qkick_mode
1637 write(aux,
'(a15, i0.3, 1x, i0.3)')
'# ll, mm ', kick%qbessel_l, kick%qbessel_m
1643 write(aux,
'(a15, f9.6)')
'# qlength ', kick%qlength
1645 write(aux,
'(a15)')
'# qvector '
1646 do idir = 1, space%dim
1647 write(aux2,
'(f9.5)') kick%qvector(idir,1)
1648 aux = trim(aux) // trim(aux2)
1654 write(aux,
'(a15,f18.12)')
'# kick strength', kick%delta_strength
1660 write(aux,
'(a17)')
'int(j_l*Y_lm*rho)'
1662 write(aux,
'(a12)')
'Real, Imag'
1679 safe_allocate(integrand(1:mesh%np))
1681 do is = 1, st%d%nspin
1683 integrand(ip) = integrand(ip) + st%rho(ip, is) *
exp(-
m_zi*sum(mesh%x(ip, 1:space%dim)*kick%qvector(1:space%dim, 1)))
1687 safe_deallocate_a(integrand)
1690 safe_allocate(integrand_bessel(1:mesh%np))
1691 integrand_bessel =
m_zero
1692 do is = 1, st%d%nspin
1694 call ylmr_real(mesh%x(ip, 1:3), kick%qbessel_l, kick%qbessel_m, ylm)
1695 integrand_bessel(ip) = integrand_bessel(ip) + st%rho(ip, is) * &
1696 loct_sph_bessel(kick%qbessel_l, kick%qlength*norm2(mesh%x(ip, :)))*ylm
1700 safe_deallocate_a(integrand_bessel)
1719 type(c_ptr),
intent(inout) :: out_temperature
1720 type(
ions_t),
intent(in) :: ions
1721 integer,
intent(in) :: iter
1756 type(c_ptr),
intent(inout) :: out_populations
1758 class(
space_t),
intent(in) :: space
1759 class(
mesh_t),
intent(in) :: mesh
1762 real(real64),
intent(in) :: dt
1763 integer,
intent(in) :: iter
1766 character(len=6) :: excited_name
1767 complex(real64) :: gsp
1768 complex(real64),
allocatable :: excited_state_p(:)
1769 complex(real64),
allocatable :: dotprodmatrix(:, :, :)
1774 safe_allocate(dotprodmatrix(1:writ%gs_st%nst, 1:st%nst, 1:st%nik))
1779 assert(.not. space%is_periodic())
1784 if (writ%n_excited_states > 0)
then
1785 safe_allocate(excited_state_p(1:writ%n_excited_states))
1786 do ist = 1, writ%n_excited_states
1787 excited_state_p(ist) =
zstates_elec_mpdotp(namespace, mesh, writ%excited_st(ist), st, dotprodmatrix)
1799 do ist = 1, writ%n_excited_states
1800 write(excited_name,
'(a2,i3,a1)')
'P(', ist,
')'
1819 do ist = 1, writ%n_excited_states
1826 if (writ%n_excited_states > 0)
then
1827 safe_deallocate_a(excited_state_p)
1829 safe_deallocate_a(dotprodmatrix)
1835 subroutine td_write_acc(out_acc, namespace, space, gr, ions, st, hm, ext_partners, dt, iter)
1836 type(c_ptr),
intent(inout) :: out_acc
1838 class(
space_t),
intent(in) :: space
1839 type(
grid_t),
intent(in) :: gr
1840 type(
ions_t),
intent(inout) :: ions
1844 real(real64),
intent(in) :: dt
1845 integer,
intent(in) :: iter
1848 character(len=7) :: aux
1849 real(real64) :: acc(space%dim)
1858 do idim = 1, space%dim
1859 write(aux,
'(a4,i1,a1)')
'Acc(', idim,
')'
1867 do idim = 1, space%dim
1874 call td_calc_tacc(namespace, space, gr, ions, ext_partners, st, hm, acc, dt*iter)
1887 subroutine td_write_vel(out_vel, gr, st, space, kpoints, iter)
1888 type(c_ptr),
intent(inout) :: out_vel
1889 type(
grid_t),
intent(in) :: gr
1891 type(
space_t),
intent(in) :: space
1893 integer,
intent(in) :: iter
1896 character(len=7) :: aux
1897 real(real64) :: vel(space%dim)
1906 do idim = 1, space%dim
1907 write(aux,
'(a4,i1,a1)')
'Vel(', idim,
')'
1915 do idim = 1, space%dim
1937 type(c_ptr),
intent(inout) :: out_laser
1938 class(
space_t),
intent(in) :: space
1939 type(
lasers_t),
intent(inout) :: lasers
1940 real(real64),
intent(in) :: dt
1941 integer,
intent(in) :: iter
1944 real(real64) :: field(space%dim)
1945 real(real64) :: ndfield(space%dim)
1946 character(len=80) :: aux
1962 do il = 1, lasers%no_lasers
1965 do idir = 1, space%dim
1966 write(aux,
'(a,i1,a)')
'E(', idir,
')'
1970 do idir = 1, space%dim
1971 write(aux,
'(a,i1,a)')
'B(', idir,
')'
1975 do idir = 1, space%dim
1976 write(aux,
'(a,i1,a)')
'A(', idir,
')'
1980 write(aux,
'(a,i1,a)')
'e(t)'
1986 do idir = 1, space%dim
1987 write(aux,
'(a,i1,a)')
'A^M(', idir,
')'
1999 do il = 1, lasers%no_lasers
2003 do idir = 1, space%dim
2008 do idir = 1, space%dim
2019 do idir = 1, space%dim
2032 do il = 1, lasers%no_lasers
2034 call laser_field(lasers%lasers(il), field(1:space%dim), iter*dt)
2059 type(c_ptr),
intent(inout) :: out_energy
2061 integer,
intent(in) :: iter
2062 real(real64),
intent(in) :: ke
2066 integer :: n_columns
2089 if (hm%pcm%run_pcm)
then
2091 n_columns = n_columns + 1
2096 n_columns = n_columns + 1
2106 do ii = 1, n_columns
2129 hm%energy%int_nn_pcm + hm%energy%int_ne_pcm), 1)
2142 type(c_ptr),
intent(inout) :: out_eigs
2144 integer,
intent(in) :: iter
2147 character(len=68) :: buf
2160 write(buf,
'(a15,i2)')
'# nst ', st%nst
2164 write(buf,
'(a15,i2)')
'# nspin ', st%d%nspin
2170 do is = 1, st%d%kpt%nglobal
2172 write(buf,
'(a,i4)')
'Eigenvalue ',ii
2181 do is = 1, st%d%kpt%nglobal
2191 do is = 1, st%d%kpt%nglobal
2203 type(c_ptr),
intent(inout) :: out_ionch
2204 class(
mesh_t),
intent(in) :: mesh
2206 integer,
intent(in) :: iter
2208 integer :: ii, ist, Nch, ik, idim
2209 character(len=68) :: buf
2210 real(real64),
allocatable :: ch(:), occ(:)
2211 real(real64),
allocatable :: occbuf(:)
2216 nch = st%nst * st%d%kpt%nglobal * st%d%dim
2217 safe_allocate(ch(0: nch))
2218 safe_allocate(occ(0: nch))
2224 do idim = 1, st%d%dim
2225 if (st%st_start <= ist .and. ist <= st%st_end .and. &
2226 st%d%kpt%start <= ik .and. ik <= st%d%kpt%end)
then
2227 occ(ii) = st%occ(ist, ik)
2235 if (st%parallel_in_states)
then
2236 safe_allocate(occbuf(0: nch))
2238 call st%mpi_grp%allreduce(occ(0), occbuf(0), nch+1, mpi_double_precision, mpi_sum)
2240 safe_deallocate_a(occbuf)
2248 safe_deallocate_a(ch)
2249 safe_deallocate_a(occ)
2262 if (occ(ii)>
m_zero .or. ii == 0)
then
2263 write(buf,
'(a,f4.1,a)')
'Pion(',occ(ii)*ii,
'+, t)'
2273 if (occ(ii)>
m_zero .or. ii == 0)
then
2283 if (occ(ii)>
m_zero .or. ii == 0)
then
2289 safe_deallocate_a(ch)
2290 safe_deallocate_a(occ)
2296 subroutine td_write_proj(out_proj, space, mesh, ions, st, gs_st, td_start_proj, kick, iter)
2297 type(c_ptr),
intent(inout) :: out_proj
2298 class(
space_t),
intent(in) :: space
2299 class(
mesh_t),
intent(in) :: mesh
2300 type(
ions_t),
intent(in) :: ions
2303 integer,
intent(in) :: td_start_proj
2304 type(
kick_t),
intent(in) :: kick
2305 integer,
intent(in) :: iter
2307 complex(real64),
allocatable :: projections(:,:,:)
2308 character(len=80) :: aux
2309 integer :: ik, ist, uist, idir
2317 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
2326 write(aux,
'(a,i8)')
"# nik ", st%nik
2330 write(aux,
'(a,2i8)')
"# st ", td_start_proj, st%nst
2334 write(aux,
'(a,2i8)')
"# ust ", td_start_proj, gs_st%st_end
2340 do ist = td_start_proj, st%nst
2348 do ist = td_start_proj, st%nst
2349 do uist = td_start_proj, gs_st%st_end
2350 write(aux,
'(i4,a,i4)') ist,
' -> ', uist
2361 if (.not. space%is_periodic())
then
2363 safe_allocate(projections(td_start_proj:st%nst, td_start_proj:gs_st%st_end, 1:st%nik))
2364 do idir = 1, space%dim
2370 write(aux,
'(a,i1,a)')
"<i|x_", idir,
"|a>"
2374 do ist = td_start_proj, st%nst
2375 do uist = td_start_proj, gs_st%nst
2385 safe_deallocate_a(projections)
2395 safe_allocate(projections(td_start_proj:st%nst, td_start_proj:gs_st%nst, 1:st%nik))
2396 projections(:,:,:) =
m_z0
2402 do ist = td_start_proj, st%nst
2403 do uist = td_start_proj, gs_st%nst
2412 safe_deallocate_a(projections)
2418 integer,
intent(in) :: dir
2420 integer :: uist, ist, ik, idim
2421 real(real64) :: n_dip(space%dim)
2422 complex(real64),
allocatable :: xpsi(:,:)
2423 complex(real64),
allocatable :: psi(:, :), gspsi(:, :)
2427 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
2428 safe_allocate(gspsi(1:mesh%np, 1:st%d%dim))
2429 safe_allocate(xpsi(1:mesh%np, 1:st%d%dim))
2431 do ik = st%d%kpt%start, st%d%kpt%end
2432 do ist = max(td_start_proj, st%st_start), st%st_end
2434 do uist = max(td_start_proj, gs_st%st_start), gs_st%st_end
2437 do idim = 1, st%d%dim
2438 xpsi(1:mesh%np, idim) = mesh%x(1:mesh%np, dir)*gspsi(1:mesh%np, idim)
2440 projections(ist, uist, ik) = -
zmf_dotp(mesh, st%d%dim, psi, xpsi, reduce = .false.)
2446 safe_deallocate_a(xpsi)
2447 safe_deallocate_a(gspsi)
2448 safe_deallocate_a(psi)
2453 n_dip = ions%dipole()
2455 do ist = max(td_start_proj, st%st_start), st%nst
2456 do uist = max(td_start_proj, gs_st%st_start), gs_st%st_end
2457 projections(ist, uist, ik) = projections(ist, uist, ik) - n_dip(dir)
2473 subroutine td_write_n_ex(out_nex, outp, namespace, mesh, kpoints, st, gs_st, iter)
2474 type(c_ptr),
intent(inout) :: out_nex
2477 class(
mesh_t),
intent(in) :: mesh
2481 integer,
intent(in) :: iter
2483 complex(real64),
allocatable :: projections(:,:)
2484 character(len=80) :: aux, dir
2485 integer :: ik, ikpt, ist, uist, err
2486 real(real64) :: Nex, weight
2488 real(real64),
allocatable :: Nex_kpt(:)
2497 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
2504 write(aux,
'(a,i8)')
"# nik ", st%nik
2508 write(aux,
'(a,2i8)')
"# st ", gs_st%st_start, st%nst
2512 write(aux,
'(a,2i8)')
"# ust ", gs_st%st_start, gs_st%st_end
2531 do ist = 1, gs_st%nst
2532 if (gs_st%occ(ist, ik) >
m_min_occ .and. ist > gs_nst) gs_nst = ist
2536 safe_allocate(projections(1:gs_nst, 1:st%nst))
2538 safe_allocate(nex_kpt(1:st%nik))
2540 do ik = st%d%kpt%start, st%d%kpt%end
2541 ikpt = st%d%get_kpoint_index(ik)
2544 weight = st%kweights(ik) * gs_st%occ(ist, ik)/ st%smear%el_per_state
2545 do uist = st%st_start, st%st_end
2546 nex_kpt(ikpt) = nex_kpt(ikpt) - weight * st%occ(uist, ik) * abs(projections(ist, uist))**2
2549 nex_kpt(ikpt) = nex_kpt(ikpt) + sum(st%occ(st%st_start:st%st_end, ik))*st%kweights(ik)
2552 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
2564 write(dir,
'(a,a,i7.7)') trim(outp%iter_dir),
"td.", iter
2567 + outp%how(option__output__density_kpt), dir,
"n_excited_el_kpt", namespace, &
2571 safe_deallocate_a(projections)
2572 safe_deallocate_a(nex_kpt)
2584 class(
mesh_t),
intent(in) :: mesh
2587 integer,
intent(in) :: td_start_proj
2588 complex(real64),
intent(inout) :: projections(td_start_proj:st%nst, td_start_proj:gs_st%nst, 1:st%nik)
2590 integer :: uist, ist, ik
2591 complex(real64),
allocatable :: psi(:, :), gspsi(:, :)
2594 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
2595 safe_allocate(gspsi(1:mesh%np, 1:st%d%dim))
2597 projections(:,:,:) =
m_zero
2599 do ik = st%d%kpt%start, st%d%kpt%end
2600 do ist = max(td_start_proj, st%st_start), st%st_end
2602 do uist = max(td_start_proj, gs_st%st_start), gs_st%st_end
2604 projections(ist, uist, ik) =
zmf_dotp(mesh, st%d%dim, psi, gspsi, reduce = .false.)
2609 safe_deallocate_a(psi)
2610 safe_deallocate_a(gspsi)
2619 class(
mesh_t),
intent(in) :: mesh
2624 integer,
intent(in) :: iter
2626 complex(real64),
allocatable :: proj(:,:), psi(:,:,:), gs_psi(:,:,:), temp_state(:,:)
2627 character(len=80) :: filename1, filename2
2628 integer :: ik,ist, jst, file, idim, nk_proj
2632 write(filename1,
'(I10)') iter
2633 filename1 =
'td.general/projections_iter_'//trim(adjustl(filename1))
2636 safe_allocate(proj(1:gs_st%nst, 1:gs_st%nst))
2637 safe_allocate(psi(1:gs_st%nst,1:gs_st%d%dim,1:mesh%np))
2638 safe_allocate(gs_psi(1:gs_st%nst,1:gs_st%d%dim,1:mesh%np))
2639 safe_allocate(temp_state(1:mesh%np,1:gs_st%d%dim))
2645 nk_proj = kpoints%nik_skip
2647 do ik = kpoints%reduced%npoints-nk_proj+1, kpoints%reduced%npoints
2649 psi(1:gs_st%nst, 1:gs_st%d%dim, 1:mesh%np)=
m_zero
2650 gs_psi(1:gs_st%nst, 1:gs_st%d%dim, 1:mesh%np)=
m_zero
2653 write(filename2,
'(I10)') ik
2654 filename2 = trim(adjustl(filename1))//
'_ik_'//trim(adjustl(filename2))
2655 file =
io_open(filename2, namespace, action=
'write')
2658 do ist=gs_st%st_start,gs_st%st_end
2661 do idim = 1,gs_st%d%dim
2662 psi(ist,idim,1:mesh%np) = temp_state(1:mesh%np,idim)
2665 do idim = 1,gs_st%d%dim
2666 gs_psi(ist,idim,1:mesh%np) = temp_state(1:mesh%np,idim)
2675 assert(mesh%np_global*gs_st%d%dim < huge(0_int32))
2681 i8_to_i4(mesh%np_global*gs_st%d%dim), &
2682 cmplx(mesh%volume_element,
m_zero, real64) , &
2684 ubound(psi, dim = 1), &
2686 ubound(gs_psi, dim = 1), &
2689 ubound(proj, dim = 1))
2693 do ist = 1, gs_st%nst
2694 do jst = 1, gs_st%nst
2695 write(file,
'(I3,1x,I3,1x,e13.6,1x,e13.6,2x)') ist, jst, proj(ist,jst)
2703 safe_deallocate_a(proj)
2704 safe_deallocate_a(psi)
2705 safe_deallocate_a(gs_psi)
2706 safe_deallocate_a(temp_state)
2712 subroutine td_write_floquet(namespace, space, hm, ext_partners, mesh, st, iter)
2713 type(namespace_t),
intent(in) :: namespace
2714 class(space_t),
intent(in) :: space
2715 type(hamiltonian_elec_t),
intent(inout) :: hm
2716 type(partner_list_t),
intent(in) :: ext_partners
2717 class(mesh_t),
intent(in) :: mesh
2718 type(states_elec_t),
intent(inout) :: st
2719 integer,
intent(in) :: iter
2721 complex(real64),
allocatable :: hmss(:,:), psi(:,:,:), hpsi(:,:,:), temp_state1(:,:)
2722 complex(real64),
allocatable :: HFloquet(:,:,:), HFloq_eff(:,:), temp(:,:)
2723 real(real64),
allocatable :: eigenval(:), bands(:,:)
2724 character(len=80) :: filename
2725 integer :: it, nT, ik, ist, in, im, file, idim, nik, ik_count
2726 integer :: Forder, Fdim, m0, n0, n1, nst, ii, jj, lim_nst
2727 logical :: downfolding
2728 type(states_elec_t) :: hm_st
2730 real(real64) :: dt, Tcycle, omega
2734 downfolding = .false.
2737 if (.not. iter == 0)
then
2745 assert(mesh%np == mesh%np_global)
2748 call states_elec_copy(hm_st, st)
2759 call parse_variable(namespace,
'TDFloquetFrequency', m_zero, omega, units_inp%energy)
2760 call messages_print_var_value(
'Frequency used for Floquet analysis', omega, namespace=namespace)
2761 if (abs(omega) <= m_epsilon)
then
2762 message(1) =
"Please give a non-zero value for TDFloquetFrequency"
2763 call messages_fatal(1, namespace=namespace)
2767 tcycle = m_two * m_pi / omega
2777 call parse_variable(namespace,
'TDFloquetSample',20 ,nt)
2778 call messages_print_var_value(
'Number of Floquet time-sampling points', nt, namespace=namespace)
2779 dt = tcycle/real(nt, real64)
2788 call parse_variable(namespace,
'TDFloquetDimension',-1,forder)
2789 if (forder .ge. 0)
then
2790 call messages_print_var_value(
'Order of multiphoton Floquet-Hamiltonian', forder, namespace=namespace)
2792 fdim = 2 * forder + 1
2794 message(1) =
'Floquet-Hamiltonian is downfolded'
2795 call messages_info(1, namespace=namespace)
2796 downfolding = .
true.
2801 dt = tcycle/real(nt, real64)
2804 nik = hm%kpoints%nik_skip
2806 safe_allocate(hmss(1:nst,1:nst))
2807 safe_allocate( psi(1:nst,1:st%d%dim,1:mesh%np))
2808 safe_allocate(hpsi(1:nst,1:st%d%dim,1:mesh%np))
2809 safe_allocate(temp_state1(1:mesh%np,1:st%d%dim))
2817 safe_allocate(hfloquet(1:nik,1:nst*fdim, 1:nst*fdim))
2818 hfloquet(1:nik,1:nst*fdim, 1:nst*fdim) = m_zero
2823 call hm%update(mesh, namespace, space, ext_partners, time=tcycle+it*dt)
2825 call zhamiltonian_elec_apply_all(hm, namespace, mesh, st, hm_st)
2830 do ik = hm%kpoints%reduced%npoints-nik+1, hm%kpoints%reduced%npoints
2831 ik_count = ik_count + 1
2833 psi(1:nst, 1:st%d%dim, 1:mesh%np)= m_zero
2834 hpsi(1:nst, 1:st%d%dim, 1:mesh%np)= m_zero
2836 do ist = st%st_start, st%st_end
2837 if (state_kpt_is_local(st, ist, ik))
then
2838 call states_elec_get_state(st, mesh, ist, ik,temp_state1)
2839 do idim = 1, st%d%dim
2840 psi(ist, idim, 1:mesh%np) = temp_state1(1:mesh%np,idim)
2842 call states_elec_get_state(hm_st, mesh, ist, ik,temp_state1)
2843 do idim = 1, st%d%dim
2844 hpsi(ist, idim,1:mesh%np) = temp_state1(1:mesh%np,idim)
2848 call comm_allreduce(mpi_world, psi)
2849 call comm_allreduce(mpi_world, hpsi)
2850 assert(mesh%np_global*st%d%dim < huge(0_int32))
2851 hmss(1:nst,1:nst) = m_zero
2856 i8_to_i4(mesh%np_global*st%d%dim), &
2857 cmplx(mesh%volume_element, m_zero, real64) , &
2859 ubound(hpsi, dim = 1), &
2861 ubound(psi, dim = 1), &
2864 ubound(hmss, dim = 1))
2866 hmss(1:nst,1:nst) = conjg(hmss(1:nst,1:nst))
2869 do in = -forder, forder
2870 do im = -forder, forder
2871 ii = (in+forder) * nst
2872 jj = (im+forder) * nst
2873 hfloquet(ik_count, ii+1:ii+nst, jj+1:jj+nst) = &
2874 hfloquet(ik_count, ii+1:ii+nst, jj+1:jj+nst) + hmss(1:nst, 1:nst) *
exp(-(in-im)*m_zi*omega*it*dt)
2878 hfloquet(ik_count, ii+ist, ii+ist) = hfloquet(ik_count, ii+ist, ii+ist) + in*omega
2887 hfloquet(:,:,:) = m_one/nt*hfloquet(:,:,:)
2890 if (downfolding)
then
2892 safe_allocate(hfloq_eff(1:nst,1:nst))
2893 safe_allocate(eigenval(1:nst))
2894 safe_allocate(bands(1:nik,1:nst))
2896 hfloq_eff(1:nst,1:nst) = m_zero
2902 hfloq_eff(1:nst, 1:nst) = hfloquet(ik, n0+1:n0+nst, m0+1:m0+nst) + &
2903 m_one/omega*(matmul(hfloquet(ik, 1:nst, m0+1:m0+nst), hfloquet(ik, n1+1:n1+nst, m0+1:m0+nst))- &
2904 matmul(hfloquet(ik, n1+1:n1+nst, m0+1:m0+nst), hfloquet(ik, 1:nst, m0+1:m0+nst)))
2906 call lalg_eigensolve(nst, hfloq_eff, eigenval)
2907 bands(ik,1:nst) = eigenval(1:nst)
2909 safe_deallocate_a(hfloq_eff)
2912 safe_allocate(eigenval(1:nst*fdim))
2913 safe_allocate(bands(1:nik,1:nst*fdim))
2914 safe_allocate(temp(1:nst*fdim, 1:nst*fdim))
2917 temp(1:nst*fdim, 1:nst*fdim) = hfloquet(ik, 1:nst*fdim, 1:nst*fdim)
2918 call lalg_eigensolve(nst*fdim, temp, eigenval)
2919 bands(ik, 1:nst*fdim) = eigenval(1:nst*fdim)
2924 if (downfolding)
then
2926 filename =
"downfolded_floquet_bands"
2929 filename =
"floquet_bands"
2932 if (mpi_world%rank == 0)
then
2934 file = io_open(filename, namespace, action =
'write')
2937 write(file,
'(e13.6, 1x)',advance=
'no') bands(ik,ist)
2944 if (.not. downfolding)
then
2947 bands(1:nik, 1:nst*fdim) = m_zero
2949 temp(1:nst*fdim,1:nst*fdim) = m_zero
2952 temp(ii+1:ii+nst, ii+1:ii+nst) = hfloquet(ik, ii+1:ii+nst, ii+1:ii+nst)
2954 call lalg_eigensolve(nst*fdim, temp, eigenval)
2955 bands(ik, 1:nst*fdim) = eigenval(1:nst*fdim)
2958 if (mpi_world%rank == 0)
then
2959 filename =
'trivial_floquet_bands'
2960 file = io_open(filename, namespace, action =
'write')
2963 write(file,
'(e13.6, 1x)', advance=
'no') bands(ik,ist)
2972 call hm%update(mesh, namespace, space, ext_partners, time=m_zero)
2974 safe_deallocate_a(hmss)
2975 safe_deallocate_a(psi)
2976 safe_deallocate_a(hpsi)
2977 safe_deallocate_a(temp_state1)
2978 safe_deallocate_a(hfloquet)
2979 safe_deallocate_a(eigenval)
2980 safe_deallocate_a(bands)
2981 safe_deallocate_a(temp)
2989 type(c_ptr),
intent(inout) :: out_total_current
2990 class(space_t),
intent(in) :: space
2991 class(mesh_t),
intent(in) :: mesh
2992 type(states_elec_t),
intent(in) :: st
2993 integer,
intent(in) :: iter
2995 integer :: idir, ispin
2996 character(len=50) :: aux
2997 real(real64) :: total_current(space%dim), abs_current(space%dim)
3001 if (mpi_grp_is_root(mpi_world) .and. iter == 0)
then
3002 call td_write_print_header_init(out_total_current)
3005 call write_iter_header_start(out_total_current)
3007 do idir = 1, space%dim
3008 write(aux,
'(a2,a1,a1)')
'I(', index2axis(idir),
')'
3009 call write_iter_header(out_total_current, aux)
3012 do idir = 1, space%dim
3013 write(aux,
'(a10,a1,a1)')
'IntAbs(j)(', index2axis(idir),
')'
3014 call write_iter_header(out_total_current, aux)
3017 do ispin = 1, st%d%nspin
3018 do idir = 1, space%dim
3019 write(aux,
'(a4,i1,a1,a1,a1)')
'I-sp', ispin,
'(', index2axis(idir),
')'
3020 call write_iter_header(out_total_current, aux)
3024 call write_iter_nl(out_total_current)
3026 call td_write_print_header_end(out_total_current)
3029 assert(
allocated(st%current))
3031 if (mpi_grp_is_root(mpi_world))
then
3032 call write_iter_start(out_total_current)
3035 total_current = 0.0_real64
3036 do idir = 1, space%dim
3037 do ispin = 1, st%d%spin_channels
3038 total_current(idir) = total_current(idir) + dmf_integrate(mesh, st%current(:, idir, ispin), reduce = .false.)
3040 total_current(idir) = units_from_atomic(units_out%length/units_out%time, total_current(idir))
3042 call mesh%allreduce(total_current, dim = space%dim)
3044 abs_current = 0.0_real64
3045 do idir = 1, space%dim
3046 do ispin = 1, st%d%spin_channels
3047 abs_current(idir) = abs_current(idir) + dmf_integrate(mesh, abs(st%current(:, idir, ispin)), reduce = .false.)
3049 abs_current(idir) = units_from_atomic(units_out%length/units_out%time, abs_current(idir))
3051 call mesh%allreduce(abs_current, dim = space%dim)
3053 if (mpi_grp_is_root(mpi_world))
then
3054 call write_iter_double(out_total_current, total_current, space%dim)
3055 call write_iter_double(out_total_current, abs_current, space%dim)
3058 do ispin = 1, st%d%nspin
3059 total_current = units_from_atomic(units_out%length/units_out%time, dmf_integrate(mesh, space%dim, st%current(:, :, ispin)))
3061 if (mpi_grp_is_root(mpi_world))
then
3062 call write_iter_double(out_total_current, total_current, space%dim)
3066 if (mpi_grp_is_root(mpi_world))
then
3067 call write_iter_nl(out_total_current)
3076 type(c_ptr),
intent(inout) :: write_obj
3077 class(space_t),
intent(in) :: space
3078 type(hamiltonian_elec_t),
intent(inout) :: hm
3079 type(grid_t),
intent(in) :: gr
3080 type(states_elec_t),
intent(in) :: st
3081 integer,
intent(in) :: iter
3083 integer :: idir, ispin
3084 character(len=50) :: aux
3085 real(real64),
allocatable :: heat_current(:, :, :)
3086 real(real64) :: total_current(space%dim)
3090 if (mpi_grp_is_root(mpi_world) .and. iter == 0)
then
3091 call td_write_print_header_init(write_obj)
3094 call write_iter_header_start(write_obj)
3096 do idir = 1, space%dim
3097 write(aux,
'(a2,i1,a1)')
'Jh(', idir,
')'
3098 call write_iter_header(write_obj, aux)
3101 call write_iter_nl(write_obj)
3103 call td_write_print_header_end(write_obj)
3106 safe_allocate(heat_current(1:gr%np, 1:space%dim, 1:st%d%nspin))
3108 call current_heat_calculate(space, gr%der, hm, st, heat_current)
3110 if (mpi_grp_is_root(mpi_world))
call write_iter_start(write_obj)
3112 total_current = 0.0_real64
3113 do idir = 1, space%dim
3114 do ispin = 1, st%d%spin_channels
3115 total_current(idir) = total_current(idir) + dmf_integrate(gr, heat_current(:, idir, ispin))
3117 total_current(idir) = units_from_atomic(units_out%energy*units_out%length/units_out%time, total_current(idir))
3120 safe_deallocate_a(heat_current)
3122 if (mpi_grp_is_root(mpi_world))
call write_iter_double(write_obj, total_current, space%dim)
3124 if (mpi_grp_is_root(mpi_world))
call write_iter_nl(write_obj)
3132 type(c_ptr),
intent(inout) :: out_partial_charges
3133 class(mesh_t),
intent(in) :: mesh
3134 type(states_elec_t),
intent(in) :: st
3135 type(ions_t),
intent(in) :: ions
3136 integer,
intent(in) :: iter
3139 character(len=50) :: aux
3140 real(real64),
allocatable :: hirshfeld_charges(:)
3144 safe_allocate(hirshfeld_charges(1:ions%natoms))
3146 call partial_charges_calculate(mesh, st, ions, hirshfeld_charges)
3148 if (mpi_grp_is_root(mpi_world))
then
3152 call td_write_print_header_init(out_partial_charges)
3155 call write_iter_header_start(out_partial_charges)
3157 do idir = 1, ions%natoms
3158 write(aux,
'(a13,i3,a1)')
'hirshfeld(atom=', idir,
')'
3159 call write_iter_header(out_partial_charges, aux)
3162 call write_iter_nl(out_partial_charges)
3164 call td_write_print_header_end(out_partial_charges)
3167 call write_iter_start(out_partial_charges)
3169 call write_iter_double(out_partial_charges, hirshfeld_charges, ions%natoms)
3171 call write_iter_nl(out_partial_charges)
3174 safe_deallocate_a(hirshfeld_charges)
3180 subroutine td_write_q(out_q, space, ks, iter)
3181 type(c_ptr),
intent(inout) :: out_q
3182 class(space_t),
intent(in) :: space
3183 type(v_ks_t),
intent(in) :: ks
3184 integer,
intent(in) :: iter
3187 character(len=50) :: aux
3191 if (mpi_grp_is_root(mpi_world))
then
3193 call td_write_print_header_init(out_q)
3194 call write_iter_header_start(out_q)
3195 do ii = 1, ks%pt%nmodes
3196 write(aux,
'(a1,i3,a3)')
'q', ii,
'(t)'
3197 call write_iter_header(out_q, aux)
3199 do ii = 1, ks%pt%nmodes
3200 write(aux,
'(a1,i3,a3)')
'p', ii,
'(t)'
3201 call write_iter_header(out_q, aux)
3203 do ii = 1, space%dim
3204 write(aux,
'(a3,i3,a3)')
'f_pt', ii,
'(t)'
3205 call write_iter_header(out_q, aux)
3207 call write_iter_nl(out_q)
3208 call td_write_print_header_end(out_q)
3211 call write_iter_start(out_q)
3212 call write_iter_double(out_q, ks%pt_mx%pt_q, ks%pt%nmodes)
3213 call write_iter_double(out_q, ks%pt_mx%pt_p, ks%pt%nmodes)
3214 call write_iter_double(out_q, ks%pt_mx%fmf, space%dim)
3215 call write_iter_nl(out_q)
3224 type(c_ptr),
intent(inout) :: out_mxll
3225 class(space_t),
intent(in) :: space
3226 type(hamiltonian_elec_t),
intent(in) :: hm
3227 real(real64),
intent(in) :: dt
3228 integer,
intent(in) :: iter
3231 real(real64) :: field(space%dim)
3232 character(len=80) :: aux
3233 character(len=1) :: field_char
3237 if (.not. mpi_grp_is_root(mpi_world))
then
3247 call td_write_print_header_init(out_mxll)
3249 write(aux,
'(a7,e20.12,3a)')
'# dt = ', units_from_atomic(units_out%time, dt), &
3250 " [", trim(units_abbrev(units_out%time)),
"]"
3251 call write_iter_string(out_mxll, aux)
3252 call write_iter_nl(out_mxll)
3254 call write_iter_header_start(out_mxll)
3255 select case (hm%mxll%coupling_mode)
3256 case (length_gauge_dipole, multipolar_expansion)
3257 if (hm%mxll%add_electric_dip) field_char =
'E'
3258 if (hm%mxll%add_magnetic_dip) field_char =
'B'
3259 do idir = 1, space%dim
3260 write(aux,
'(a,i1,a)') field_char //
'(', idir,
')'
3261 call write_iter_header(out_mxll, aux)
3263 case (velocity_gauge_dipole)
3264 do idir = 1, space%dim
3265 write(aux,
'(a,i1,a)')
'A(', idir,
')'
3266 call write_iter_header(out_mxll, aux)
3269 call write_iter_nl(out_mxll)
3271 call write_iter_string(out_mxll,
'#[Iter n.]')
3272 call write_iter_header(out_mxll,
'[' // trim(units_abbrev(units_out%time)) //
']')
3276 select case (hm%mxll%coupling_mode)
3277 case (length_gauge_dipole, multipolar_expansion)
3278 if (hm%mxll%add_electric_dip) aux =
'[' // trim(units_abbrev(units_out%force)) //
']'
3279 if (hm%mxll%add_magnetic_dip) aux =
'[' // trim(units_abbrev(unit_one/units_out%length**2)) //
']'
3280 do idir = 1, space%dim
3281 call write_iter_header(out_mxll, aux)
3283 case (velocity_gauge_dipole)
3284 aux =
'[' // trim(units_abbrev(units_out%energy)) //
']'
3285 do idir = 1, space%dim
3286 call write_iter_header(out_mxll, aux)
3289 call write_iter_nl(out_mxll)
3290 call td_write_print_header_end(out_mxll)
3293 call write_iter_start(out_mxll)
3296 select case (hm%mxll%coupling_mode)
3297 case (length_gauge_dipole, multipolar_expansion)
3298 if (hm%mxll%add_electric_dip) field = units_from_atomic(units_out%force, hm%mxll%e_field_dip)
3299 if (hm%mxll%add_magnetic_dip) field = units_from_atomic(unit_one/units_out%length**2, hm%mxll%b_field_dip)
3300 call write_iter_double(out_mxll, field, space%dim)
3301 case (velocity_gauge_dipole)
3302 field = units_from_atomic(units_out%energy, hm%mxll%vec_pot_dip)
3303 call write_iter_double(out_mxll, field, space%dim)
3305 call write_iter_nl(out_mxll)
3313 type(c_ptr),
intent(inout) :: out_coords
3314 type(lda_u_t),
intent(in) :: lda_u
3315 integer,
intent(in) :: iter
3318 character(len=50) :: aux
3320 if (.not. mpi_grp_is_root(mpi_world))
return
3325 call td_write_print_header_init(out_coords)
3328 call write_iter_header_start(out_coords)
3330 do ios = 1, lda_u%norbsets
3331 write(aux,
'(a2,i3,a1)')
'Ueff(', ios,
')'
3332 call write_iter_header(out_coords, aux)
3335 do ios = 1, lda_u%norbsets
3336 write(aux,
'(a2,i3,a1)')
'U(', ios,
')'
3337 call write_iter_header(out_coords, aux)
3340 do ios = 1, lda_u%norbsets
3341 write(aux,
'(a2,i3,a1)')
'J(', ios,
')'
3342 call write_iter_header(out_coords, aux)
3345 if (lda_u%intersite)
then
3346 do ios = 1, lda_u%norbsets
3347 do inn = 1, lda_u%orbsets(ios)%nneighbors
3348 write(aux,
'(a2,i3,a1,i3,a1)')
'V(', ios,
'-', inn,
')'
3349 call write_iter_header(out_coords, aux)
3355 call write_iter_nl(out_coords)
3358 call write_iter_string(out_coords,
'#[Iter n.]')
3359 call write_iter_header(out_coords,
'[' // trim(units_abbrev(units_out%time)) //
']')
3360 call write_iter_string(out_coords, &
3361 'Effective U ' // trim(units_abbrev(units_out%energy)) // &
3362 ', U in '// trim(units_abbrev(units_out%energy)) // &
3363 ', J in ' // trim(units_abbrev(units_out%energy)))
3364 call write_iter_nl(out_coords)
3366 call td_write_print_header_end(out_coords)
3369 call write_iter_start(out_coords)
3371 do ios = 1, lda_u%norbsets
3372 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3373 lda_u%orbsets(ios)%Ueff), 1)
3376 do ios = 1, lda_u%norbsets
3377 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3378 lda_u%orbsets(ios)%Ubar), 1)
3381 do ios = 1, lda_u%norbsets
3382 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3383 lda_u%orbsets(ios)%Jbar), 1)
3386 if (lda_u%intersite)
then
3387 do ios = 1, lda_u%norbsets
3388 do inn = 1, lda_u%orbsets(ios)%nneighbors
3389 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3390 lda_u%orbsets(ios)%V_ij(inn,0)), 1)
3395 call write_iter_nl(out_coords)
3402 type(c_ptr),
intent(inout) :: file_handle
3403 type(grid_t),
intent(in) :: grid
3404 type(kpoints_t),
intent(in) :: kpoints
3405 type(states_elec_t),
intent(in) :: st
3406 integer,
intent(in) :: iter
3408 integer :: ik_ispin, ist
3409 character(len=7) :: nkpt_str, nst_str
3410 character(len=7) :: ik_str, ist_str
3411 real(real64),
allocatable :: norm_ks(:, :)
3412 real(real64) :: n_electrons
3416 safe_allocate(norm_ks(1:st%nst, 1:st%nik))
3417 call states_elec_calc_norms(grid, kpoints, st, norm_ks)
3419 if (mpi_grp_is_root(mpi_world))
then
3422 call td_write_print_header_init(file_handle)
3425 write(nkpt_str,
'(I7)') st%nik
3426 write(nst_str,
'(I7)') st%nst
3427 call write_iter_string(file_handle,
'# Dimensions. (nstates, nkpt * nspin):')
3428 call write_iter_string(file_handle, trim(adjustl(nst_str)) //
' ' // trim(adjustl(nkpt_str)))
3429 call write_iter_nl(file_handle)
3432 call write_iter_string(file_handle,
'# Norm ordering: (istate, ikpoint_spin)')
3433 call write_iter_nl(file_handle)
3436 call write_iter_header_start(file_handle)
3437 call write_iter_header(file_handle,
'N_electrons')
3438 do ik_ispin = 1, st%nik
3440 write(ik_str,
'(I7)') ik_ispin
3441 write(ist_str,
'(I7)') ist
3442 call write_iter_header(file_handle, &
3443 'Norm (' // trim(ist_str) //
',' // trim(ik_str) //
')')
3446 call write_iter_nl(file_handle)
3447 call td_write_print_header_end(file_handle)
3450 n_electrons = sum(st%occ * norm_ks**2)
3453 call write_iter_start(file_handle)
3454 call write_iter_double(file_handle, n_electrons, 1)
3455 do ik_ispin = 1, st%nik
3456 call write_iter_double(file_handle, norm_ks(:, ik_ispin),
size(norm_ks, 1))
3458 call write_iter_nl(file_handle)
3462 safe_deallocate_a(norm_ks)
3471 type(c_ptr),
intent(inout) :: file_handle
3472 type(ions_t),
intent(in) :: ions
3473 integer,
intent(in) :: iter
3476 real(real64) :: tmp(3)
3478 if (.not. mpi_grp_is_root(mpi_world))
return
3482 assert(ions%space%dim == 3)
3485 call td_write_print_header_init(file_handle)
3488 call write_iter_header_start(file_handle)
3490 call write_iter_string(file_handle,
'# Iter, a, b, c, volume, alpha, beta, gamma, ' &
3491 //
'a_x, a_y, a_z, b_x, b_y, b_z, c_x, c_y, c_z')
3494 call write_iter_string(file_handle,
'#[Iter n.]')
3495 call write_iter_header(file_handle,
'[' // trim(units_abbrev(units_out%time)) //
']')
3496 call write_iter_string(file_handle, &
3497 'Lengths in ' // trim(units_abbrev(units_out%length)) // &
3498 ', Volume in ' // trim(units_abbrev(units_out%length**3)) // &
3499 ', Angles in degree, Lattice vectors in '// trim(units_abbrev(units_out%length)))
3500 call write_iter_nl(file_handle)
3502 call td_write_print_header_end(file_handle)
3505 call write_iter_start(file_handle)
3509 tmp(idir) = units_from_atomic(units_out%length, norm2(ions%latt%rlattice(1:3, idir)))
3511 call write_iter_double(file_handle, tmp, 3)
3514 tmp(1) = units_from_atomic(units_out%length**3, ions%latt%rcell_volume)
3515 call write_iter_double(file_handle, tmp(1), 1)
3518 call write_iter_double(file_handle, ions%latt%alpha, 1)
3519 call write_iter_double(file_handle, ions%latt%beta, 1)
3520 call write_iter_double(file_handle, ions%latt%gamma, 1)
3524 tmp(1:3) = units_from_atomic(units_out%length, ions%latt%rlattice(:, idir))
3525 call write_iter_double(file_handle, tmp, 3)
3527 call write_iter_nl(file_handle)
3536 type(namespace_t),
intent(in) :: namespace
3537 integer,
intent(in) :: iter
3538 real(real64),
intent(in) :: dt
3540 integer :: default, flags, iout, first
3595 call parse_variable(namespace,
'MaxwellTDOutput', default, flags)
3597 if (.not. varinfo_valid_option(
'MaxwellTDOutput', flags, is_flag = .
true.))
then
3598 call messages_input_error(namespace,
'MaxwellTDOutput')
3602 writ%out(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
3603 if (writ%out(iout)%write)
then
3604 writ%out(iout + 1)%write = .
true.
3605 writ%out(iout + 2)%write = .
true.
3610 writ%out(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
3619 call io_mkdir(
'td.general', namespace)
3624 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_e_field_x", namespace)))
3626 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_e_field_y", namespace)))
3628 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_e_field_z", namespace)))
3634 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_b_field_x", namespace)))
3636 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_b_field_y", namespace)))
3638 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_b_field_z", namespace)))
3644 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_e_field_x", namespace)))
3646 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_e_field_y", namespace)))
3648 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_e_field_z", namespace)))
3654 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_b_field_x", namespace)))
3656 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_b_field_y", namespace)))
3658 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_b_field_z", namespace)))
3664 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_e_field_x", namespace)))
3666 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_e_field_y", namespace)))
3668 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_e_field_z", namespace)))
3674 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_b_field_x", namespace)))
3676 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_b_field_y", namespace)))
3678 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_b_field_z", namespace)))
3684 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/maxwell_energy", namespace)))
3689 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/electric_field_surface-x", namespace)))
3694 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/electric_field_surface-y", namespace)))
3699 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/electric_field_surface-z", namespace)))
3704 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/magnetic_field_surface-x", namespace)))
3709 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/magnetic_field_surface-y", namespace)))
3714 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/magnetic_field_surface-z", namespace)))
3730 if (writ%out(iout)%write)
call write_iter_end(writ%out(iout)%handle)
3738 subroutine td_write_mxll_iter(writ, space, gr, st, hm, helmholtz, dt, iter, namespace)
3740 class(space_t),
intent(in) :: space
3741 type(grid_t),
intent(inout) :: gr
3742 type(states_mxll_t),
intent(inout) :: st
3743 type(hamiltonian_mxll_t),
intent(inout) :: hm
3744 type(helmholtz_decomposition_t),
intent(inout) :: helmholtz
3745 real(real64),
intent(in) :: dt
3746 integer,
intent(in) :: iter
3747 type(namespace_t),
intent(in) :: namespace
3752 call profiling_in(
"TD_WRITE_ITER_MAXWELL")
3755 call helmholtz%get_trans_field(namespace, st%rs_state_trans, total_field=st%rs_state)
3756 call get_rs_state_at_point(st%selected_points_rs_state_trans(:,:), st%rs_state_trans, &
3757 st%selected_points_coordinate(:,:), st, gr)
3760 hm%energy%energy_trans = m_zero
3764 call helmholtz%get_long_field(namespace, st%rs_state_long, total_field=st%rs_state)
3765 call get_rs_state_at_point(st%selected_points_rs_state_long(:,:), st%rs_state_long, &
3766 st%selected_points_coordinate(:,:), st, gr)
3769 hm%energy%energy_long = m_zero
3861 call profiling_out(
"TD_WRITE_ITER_MAXWELL")
3870 type(hamiltonian_mxll_t),
intent(in) :: hm
3871 integer,
intent(in) :: iter
3875 integer :: n_columns
3877 if (.not. mpi_grp_is_root(mpi_world))
return
3902 call write_iter_header(
out_maxwell_energy,
'[' // trim(units_abbrev(units_out%time)) //
']')
3904 do ii = 1, n_columns
3905 call write_iter_header(
out_maxwell_energy,
'[' // trim(units_abbrev(units_out%energy)) //
']')
3913 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy), 1)
3914 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%e_energy), 1)
3915 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%b_energy), 1)
3917 hm%energy%energy+hm%energy%boundaries), 1)
3918 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%boundaries), 1)
3919 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_trans), 1)
3920 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_long), 1)
3921 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_plane_waves), 1)
3930 type(c_ptr),
intent(inout) :: out_field_surf
3931 type(states_mxll_t),
intent(in) :: st
3932 integer,
intent(in) :: dim
3933 integer,
intent(in) :: iter
3937 integer :: n_columns
3939 if (.not. mpi_grp_is_root(mpi_world))
return
3946 call td_write_print_header_init(out_field_surf)
3949 call write_iter_header_start(out_field_surf)
3950 call write_iter_header(out_field_surf,
'- x direction')
3951 call write_iter_header(out_field_surf,
'+ x direction')
3952 call write_iter_header(out_field_surf,
'- y direction')
3953 call write_iter_header(out_field_surf,
'+ y direction')
3954 call write_iter_header(out_field_surf,
'- z direction')
3955 call write_iter_header(out_field_surf,
'+ z direction')
3956 call write_iter_header(out_field_surf,
'- x dir. p. w.')
3957 call write_iter_header(out_field_surf,
'+ x dir. p. w.')
3958 call write_iter_header(out_field_surf,
'- y dir. p. w.')
3959 call write_iter_header(out_field_surf,
'+ y dir. p. w.')
3960 call write_iter_header(out_field_surf,
'- z dir. p. w.')
3961 call write_iter_header(out_field_surf,
'+ z dir. p. w.')
3963 call write_iter_nl(out_field_surf)
3966 call write_iter_string(out_field_surf,
'#[Iter n.]')
3967 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(units_out%time)) //
']')
3969 do ii = 1, n_columns
3970 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(units_out%energy/units_out%length)) //
']')
3972 call write_iter_nl(out_field_surf)
3974 call td_write_print_header_end(out_field_surf)
3977 call write_iter_start(out_field_surf)
3978 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3979 st%electric_field_box_surface(1,1,dim)), 1)
3980 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3981 st%electric_field_box_surface(2,1,dim)), 1)
3982 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3983 st%electric_field_box_surface(1,2,dim)), 1)
3984 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3985 st%electric_field_box_surface(2,2,dim)), 1)
3986 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3987 st%electric_field_box_surface(1,3,dim)), 1)
3988 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3989 st%electric_field_box_surface(2,3,dim)), 1)
3990 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3991 st%electric_field_box_surface_plane_waves(1,1,dim)), 1)
3992 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3993 st%electric_field_box_surface_plane_waves(2,1,dim)), 1)
3994 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3995 st%electric_field_box_surface_plane_waves(1,2,dim)), 1)
3996 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3997 st%electric_field_box_surface_plane_waves(2,2,dim)), 1)
3998 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3999 st%electric_field_box_surface_plane_waves(1,3,dim)), 1)
4000 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
4001 st%electric_field_box_surface_plane_waves(2,3,dim)), 1)
4002 call write_iter_nl(out_field_surf)
4010 type(c_ptr),
intent(inout) :: out_field_surf
4011 type(states_mxll_t),
intent(in) :: st
4012 integer,
intent(in) :: dim
4013 integer,
intent(in) :: iter
4017 integer :: n_columns
4019 if (.not. mpi_grp_is_root(mpi_world))
return
4026 call td_write_print_header_init(out_field_surf)
4029 call write_iter_header_start(out_field_surf)
4030 call write_iter_header(out_field_surf,
'- x direction')
4031 call write_iter_header(out_field_surf,
'+ x direction')
4032 call write_iter_header(out_field_surf,
'- y direction')
4033 call write_iter_header(out_field_surf,
'+ y direction')
4034 call write_iter_header(out_field_surf,
'- z direction')
4035 call write_iter_header(out_field_surf,
'+ z direction')
4036 call write_iter_header(out_field_surf,
'- x dir. p. w.')
4037 call write_iter_header(out_field_surf,
'+ x dir. p. w.')
4038 call write_iter_header(out_field_surf,
'- y dir. p. w.')
4039 call write_iter_header(out_field_surf,
'+ y dir. p. w.')
4040 call write_iter_header(out_field_surf,
'- z dir. p. w.')
4041 call write_iter_header(out_field_surf,
'+ z dir. p. w.')
4043 call write_iter_nl(out_field_surf)
4046 call write_iter_string(out_field_surf,
'#[Iter n.]')
4047 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(units_out%time)) //
']')
4049 do ii = 1, n_columns
4050 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(unit_one/units_out%length**2)) //
']')
4052 call write_iter_nl(out_field_surf)
4054 call td_write_print_header_end(out_field_surf)
4057 call write_iter_start(out_field_surf)
4058 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4059 st%magnetic_field_box_surface(1,1,dim)), 1)
4060 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4061 st%magnetic_field_box_surface(2,1,dim)), 1)
4062 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4063 st%magnetic_field_box_surface(1,2,dim)), 1)
4064 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4065 st%magnetic_field_box_surface(2,2,dim)), 1)
4066 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4067 st%magnetic_field_box_surface(1,3,dim)), 1)
4068 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4069 st%magnetic_field_box_surface(2,3,dim)), 1)
4070 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4071 st%magnetic_field_box_surface_plane_waves(1,1,dim)), 1)
4072 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4073 st%magnetic_field_box_surface_plane_waves(2,1,dim)), 1)
4074 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4075 st%magnetic_field_box_surface_plane_waves(1,2,dim)), 1)
4076 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4077 st%magnetic_field_box_surface_plane_waves(2,2,dim)), 1)
4078 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4079 st%magnetic_field_box_surface_plane_waves(1,3,dim)), 1)
4080 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4081 st%magnetic_field_box_surface_plane_waves(2,3,dim)), 1)
4082 call write_iter_nl(out_field_surf)
4088 subroutine td_write_fields(out_fields, space, st, iter, dt, e_or_b_field, field_type, idir)
4089 type(c_ptr),
intent(inout) :: out_fields
4090 class(space_t),
intent(in) :: space
4091 type(states_mxll_t),
intent(in) :: st
4092 integer,
intent(in) :: iter
4093 real(real64),
intent(in) :: dt
4094 integer,
intent(in) :: e_or_b_field
4095 integer,
intent(in) :: field_type
4096 integer,
intent(in) :: idir
4100 real(real64) :: field(space%dim), selected_field
4101 character(len=80) :: aux
4103 if (.not. mpi_grp_is_root(mpi_world))
return
4108 call td_write_print_header_init(out_fields)
4111 write(aux,
'(a7,e20.12,3a)')
'# dt = ', units_from_atomic(units_out%time, dt), &
4112 " [", trim(units_abbrev(units_out%time)),
"]"
4113 call write_iter_string(out_fields, aux)
4114 call write_iter_nl(out_fields)
4116 call write_iter_header_start(out_fields)
4118 do id = 1, st%selected_points_number
4119 select case (e_or_b_field)
4121 write(aux,
'(a,i1,a)')
'E(', id,
')'
4123 write(aux,
'(a,i1,a)')
'B(', id,
')'
4125 call write_iter_header(out_fields, aux)
4128 call write_iter_nl(out_fields)
4129 call write_iter_string(out_fields,
'#[Iter n.]')
4130 call write_iter_header(out_fields,
' [' // trim(units_abbrev(units_out%time)) //
']')
4135 aux =
' [' // trim(units_abbrev(units_out%force)) //
']'
4136 do id = 1, st%selected_points_number
4137 call write_iter_header(out_fields, aux)
4139 call write_iter_nl(out_fields)
4140 call td_write_print_header_end(out_fields)
4143 call write_iter_start(out_fields)
4145 do id = 1, st%selected_points_number
4146 select case (e_or_b_field)
4149 select case (field_type)
4151 call get_electric_field_vector(st%selected_points_rs_state(:,id), field(1:st%dim))
4153 call get_electric_field_vector(st%selected_points_rs_state_long(:,id), field(1:st%dim))
4155 call get_electric_field_vector(st%selected_points_rs_state_trans(:,id), field(1:st%dim))
4157 selected_field = units_from_atomic(units_out%energy/units_out%length, field(idir))
4160 select case (field_type)
4162 call get_magnetic_field_vector(st%selected_points_rs_state(:,id), st%rs_sign, field(1:st%dim))
4164 call get_magnetic_field_vector(st%selected_points_rs_state_long(:,id), st%rs_sign, field(1:st%dim))
4166 call get_magnetic_field_vector(st%selected_points_rs_state_trans(:,id), st%rs_sign, field(1:st%dim))
4168 selected_field = units_from_atomic(unit_one/units_out%length**2, field(idir))
4170 call write_iter_double(out_fields, selected_field, 1)
4173 call write_iter_nl(out_fields)
4182 type(namespace_t),
intent(in) :: namespace
4183 class(space_t),
intent(in) :: space
4184 type(grid_t),
intent(inout) :: gr
4185 type(states_mxll_t),
intent(inout) :: st
4186 type(hamiltonian_mxll_t),
intent(inout) :: hm
4187 type(helmholtz_decomposition_t),
intent(inout) :: helmholtz
4188 type(output_t),
intent(in) :: outp
4189 integer,
intent(in) :: iter
4190 real(real64),
intent(in) :: time
4192 character(len=256) :: filename
4194 push_sub(td_write_mxwll_free_data)
4195 call profiling_in(
"TD_WRITE_MAXWELL_DATA")
4198 write(filename,
'(a,a,i7.7)') trim(outp%iter_dir),
"td.", iter
4200 call output_mxll(outp, namespace, space, gr, st, hm, helmholtz, time, filename)
4202 call profiling_out(
"TD_WRITE_MAXWELL_DATA")
4203 pop_sub(td_write_mxwll_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)
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.
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
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)
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
subroutine, public restart_init(restart, namespace, data_type, type, mc, ierr, mesh, dir, exact)
Initializes a restart object.
integer, parameter, public restart_proj
integer, parameter, public restart_type_load
subroutine, public restart_end(restart)
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, fixed_occ, 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_ionch(mesh, st, ch, Nch)
Multiple ionization probabilities calculated form the KS orbital densities C. Ullrich,...
subroutine, public td_calc_tvel(gr, st, space, kpoints, vel)
Electronic velocity (to calculate harmonic spectrum...) It is calculated as:
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
integer, parameter, public out_q
integer, parameter, public out_mxll_field
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)
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_proj(out_proj, space, mesh, ions, st, gs_st, td_start_proj, kick, iter)
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
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, public td_write_mxll_free_data(writ, namespace, space, gr, st, hm, helmholtz, outp, iter, time)
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
subroutine td_write_vel(out_vel, gr, st, space, kpoints, iter)
subroutine td_write_floquet(namespace, space, hm, ext_partners, mesh, st, iter)
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 calc_projections(mesh, st, gs_st, td_start_proj, projections)
This subroutine calculates:
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, 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), parameter, 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.
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)