48 use,
intrinsic :: iso_fortran_env
108 integer,
parameter,
public :: &
109 OUT_MULTIPOLES = 1, &
147 character(len=100) :: td_file_name(OUT_MAX) = [character(100) :: &
157 "magnetic_moments", &
172 "total_heat_current", &
173 "total_magnetization", &
175 "maxwell_dipole_field", &
176 "norm_wavefunctions", &
180 integer,
parameter :: &
181 OUT_DFTU_EFFECTIVE_U = 1, &
185 integer,
parameter :: &
186 OUT_MAXWELL_TOTAL_E_FIELD = 1, &
200 integer,
parameter,
public :: &
203 integer,
parameter :: &
208 integer,
parameter :: &
214 type(c_ptr) :: handle
215 type(c_ptr),
allocatable :: mult_handles(:)
217 integer :: hand_start
219 logical ::
write = .false.
220 logical :: resolve_states = .false.
232 real(real64) :: lmm_r
235 integer :: n_excited_states
237 integer :: compute_interval
243 subroutine td_write_kick(outp, namespace, space, mesh, kick, ions, iter)
247 class(
mesh_t),
intent(in) :: mesh
248 type(
kick_t),
intent(in) :: kick
249 type(
ions_t),
intent(in) :: ions
250 integer,
intent(in) :: iter
252 complex(real64),
allocatable :: kick_function(:)
253 character(len=256) :: filename
258 write(filename,
'(a,i7.7)')
"td.", iter
259 if (outp%what(option__output__delta_perturbation))
then
260 safe_allocate(kick_function(1:mesh%np))
262 call zio_function_output(outp%how(option__output__delta_perturbation), filename,
"kick_function", namespace, &
263 space, mesh, kick_function(:),
units_out%energy, err, pos=ions%pos, atoms=ions%atom)
264 safe_deallocate_a(kick_function)
280 subroutine td_write_init(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, ks, ions_move, &
281 with_gauge_field, kick, iter, max_iter, dt, mc)
285 type(
output_t),
intent(inout) :: outp
286 type(
grid_t),
intent(in) :: gr
289 type(
ions_t),
intent(in) :: ions
291 type(
v_ks_t),
intent(inout) :: ks
292 logical,
intent(in) :: ions_move
293 logical,
intent(in) :: with_gauge_field
294 type(
kick_t),
intent(in) :: kick
295 integer,
intent(in) :: iter
296 integer,
intent(in) :: max_iter
297 real(real64),
intent(in) :: dt
301 integer :: ierr, first, ii, ist, jj, flags, iout, default, ifile
306 character(len=MAX_PATH_LEN) :: filename
308 logical :: resolve_states
309 logical,
allocatable :: skip(:)
454 output_options = .false.
455 output_options(out_multipoles) = .
true.
473 writ%out(iout)%write = output_options(iout)
488 if (space%is_periodic() .and. writ%out(
out_angular)%write)
then
503 if (gr%np /= gr%np_global)
then
504 message(1) =
"TDOutput option td_kpoint_occup and td_floquet do not work with domain parallelization"
511 'Forces for systems periodic in 1D are not currently implemented and options that output the forces are not allowed.')
515 if (writ%out(
out_kp_proj)%write .and. hm%kpoints%nik_skip == 0)
then
516 message(1) =
"TDOutput option td_kpoint_occup only work with zero-weight k-points at the moment."
530 call parse_variable(namespace,
'TDOutputResolveStates', .false., resolve_states)
531 if (.not. writ%out(out_multipoles)%write)
then
532 write(
message(1),
'(a)')
"TDOutputResolveStates works only for TDOutput = multipoles."
545 if (writ%lmax < 0)
then
546 write(
message(1),
'(a,i6,a)')
"Input: '", writ%lmax,
"' is not a valid TDMultipoleLmax."
547 message(2) =
'(Must be TDMultipoleLmax >= 0 )'
553 if ((writ%out(
out_acc)%write) .and. ions_move)
then
554 message(1) =
'If harmonic spectrum is to be calculated, atoms should not be allowed to move.'
558 if ((writ%out(
out_q)%write) .and. .not.(ks%has_photons))
then
559 message(1) =
'If q(t) is to be calculated, you need to allow for photon modes.'
564 .or. hm%mxll%add_electric_dip))
then
565 message(1) =
'If the dipolar field has to be written, MaxwellCouplingMode has to be'
566 message(2) =
'"lenght_gauge_dipole" or "velocity_gauge_dipole" and at least one Maxwell system'
567 message(3) =
'must be present.'
571 rmin = ions%min_distance()
581 message(1) =
"Option TDOutput = populations is not implemented for parallel in states."
593 safe_deallocate_a(writ%gs_st%node)
601 writ%gs_st%st_end = writ%gs_st%nst
603 message(1) =
"Unable to read states information."
607 writ%gs_st%st_start = 1
623 call parse_variable(namespace,
'TDProjStateStart', 1, writ%gs_st%st_start)
625 if (st%parallel_in_states .and. writ%out(
out_proj)%write .and. writ%gs_st%st_start > 1)
then
631 writ%gs_st%lnst = writ%gs_st%st_end - writ%gs_st%st_start + 1
635 writ%gs_st%parallel_in_states = .false.
638 safe_allocate(writ%gs_st%occ(1:writ%gs_st%nst, 1:writ%gs_st%nik))
639 safe_allocate(writ%gs_st%eigenval(1:writ%gs_st%nst, 1:writ%gs_st%nik))
643 safe_allocate(writ%gs_st%node(1:writ%gs_st%nst))
644 writ%gs_st%node(:) = 0
646 writ%gs_st%eigenval = huge(writ%gs_st%eigenval)
648 if (writ%gs_st%d%ispin ==
spinors)
then
649 safe_deallocate_a(writ%gs_st%spin)
650 safe_allocate(writ%gs_st%spin(1:3, 1:writ%gs_st%nst, 1:writ%gs_st%nik))
653 safe_allocate(skip(1:writ%gs_st%nst))
655 skip(1:writ%gs_st%st_start-1) = .
true.
659 safe_deallocate_a(skip)
664 if (ierr /= 0 .and. ierr /= (writ%gs_st%st_end-writ%gs_st%st_start+1)*writ%gs_st%nik &
665 *writ%gs_st%d%dim*writ%gs_st%mpi_grp%size)
then
666 message(1) =
"Unable to read wavefunctions for TDOutput."
711 if (
parse_block(namespace,
'TDExcitedStatesToProject', blk) == 0)
then
713 safe_allocate(writ%excited_st(1:writ%n_excited_states))
714 do ist = 1, writ%n_excited_states
719 writ%n_excited_states = 0
733 call parse_variable(namespace,
'TDOutputComputeInterval', 50, writ%compute_interval)
734 if (writ%compute_interval < 0)
then
735 message(1) =
"TDOutputComputeInterval must be >= 0."
751 call io_mkdir(
'td.general', namespace)
762 do ifile = 1, out_max
766 if (writ%out(ifile)%write)
then
770 trim(
io_workpath(
"td.general/"//trim(td_file_name(ifile)), namespace)))
778 if (writ%out(out_multipoles)%write .and. .not. resolve_states)
then
781 trim(
io_workpath(
"td.general/multipoles", namespace)))
785 select case (kick%qkick_mode)
787 write(filename,
'(a)')
'td.general/ftchd.sin'
789 write(filename,
'(a)')
'td.general/ftchd.cos'
791 write(filename,
'(a, SP, I0.3, a, I0.3)')
'td.general/ftchd.l', kick%qbessel_l,
'_m', kick%qbessel_m
793 write(filename,
'(a)')
'td.general/ftchd'
805 call io_rm(
"td.general/laser", namespace=namespace)
822 if (writ%out(out_multipoles)%write .and. resolve_states)
then
824 writ%out(out_multipoles)%hand_start = st%st_start
825 writ%out(out_multipoles)%hand_end = st%st_end
826 writ%out(out_multipoles)%resolve_states = .
true.
827 writ%out(out_multipoles)%mpi_grp = gr%mpi_grp
829 safe_allocate(writ%out(out_multipoles)%mult_handles(st%st_start:st%st_end))
831 if (writ%out(out_multipoles)%mpi_grp%is_root())
then
832 do ist = st%st_start, st%st_end
833 write(filename,
'(a,i4.4)')
'td.general/multipoles-ist', ist
846 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
847 calc_eigenval=.false., time = iter*dt, calc_energy = .false.)
850 if (writ%out(
out_n_ex)%write .and. writ%compute_interval > 0)
then
851 call io_mkdir(outp%iter_dir, namespace)
854 if (all(outp%how == 0) .and. writ%out(
out_n_ex)%write)
then
876 if (hm%lda_u_level ==
dft_u_acbn0) default = default + 2**(out_dftu_effective_u - 1)
884 writ%out_dftu(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
888 if (writ%out_dftu(out_dftu_effective_u)%write)
then
891 trim(
io_workpath(
"td.general/effectiveU", namespace)))
909 if (writ%out(iout)%write)
then
910 if (writ%out(iout)%mpi_grp%is_root())
then
911 if (writ%out(iout)%resolve_states)
then
912 do ist = writ%out(iout)%hand_start, writ%out(iout)%hand_end
915 safe_deallocate_a(writ%out(iout)%mult_handles)
925 if (writ%out_dftu(iout)%write)
call write_iter_end(writ%out_dftu(iout)%handle)
931 do ist = 1, writ%n_excited_states
934 writ%n_excited_states = 0
947 subroutine td_write_iter(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, kick, ks, dt, iter, mc, recalculate_gs)
950 class(
space_t),
intent(in) :: space
952 type(
grid_t),
intent(in) :: gr
955 type(
ions_t),
intent(inout) :: ions
957 type(
kick_t),
intent(in) :: kick
958 type(
v_ks_t),
intent(in) :: ks
959 real(real64),
intent(in) :: dt
960 integer,
intent(in) :: iter
962 logical,
intent(in) :: recalculate_gs
970 if (writ%out(out_multipoles)%write)
then
971 call td_write_multipole(writ%out(out_multipoles), space, gr, ions, st, writ%lmax, kick, iter)
994 if (writ%out(
out_proj)%write .and. mod(iter, writ%compute_interval) == 0)
then
1003 if (writ%out(
out_kp_proj)%write .and. mod(iter, writ%compute_interval) == 0)
then
1009 ions%pos, ions%vel, ions%tot_force, iter)
1014 ions%pos, ions%vel, ions%tot_force, iter, 1)
1019 ions%pos, ions%vel, ions%tot_force, iter, 2)
1024 ions%pos, ions%vel, ions%tot_force, iter, 3)
1035 if (writ%out(
out_acc)%write)
then
1036 call td_write_acc(writ%out(
out_acc)%handle, namespace, space, gr, ions, st, hm, ext_partners, dt, iter)
1039 if (writ%out(
out_vel)%write)
then
1052 if(
associated(gfield))
then
1082 if (writ%out(
out_n_ex)%write .and. mod(iter, writ%compute_interval) == 0)
then
1084 if (recalculate_gs)
then
1087 ierr, label =
': Houston states for TDOutput')
1091 call td_write_n_ex(writ%out(
out_n_ex)%handle, outp, namespace, gr, hm%kpoints, st, writ%gs_st, iter)
1103 if (writ%out_dftu(out_dftu_effective_u)%write)
then
1107 if (writ%out(
out_q)%write .and. ks%has_photons)
then
1111 if (writ%out(
out_mxll_field)%write .and. hm%mxll%calc_field_dip)
then
1128 do iout = 1, out_max
1130 if (writ%out(iout)%write)
then
1131 if (writ%out(iout)%mpi_grp%is_root())
then
1132 if (writ%out(iout)%resolve_states)
then
1133 do ii = writ%out(iout)%hand_start, writ%out(iout)%hand_end
1145 if (writ%out_dftu(iout)%write)
call write_iter_flush(writ%out_dftu(iout)%handle)
1154 subroutine td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, dt)
1157 type(
grid_t),
intent(in) :: gr
1160 type(
v_ks_t),
intent(inout) :: ks
1162 type(
ions_t),
intent(in) :: ions
1164 integer,
intent(in) :: iter
1165 real(real64),
optional,
intent(in) :: dt
1167 character(len=256) :: filename
1173 if (st%modelmbparticles%nparticle > 0)
then
1178 write(filename,
'(a,a,i7.7)') trim(outp%iter_dir),
"td.", iter
1180 call output_all(outp, namespace, space, filename, gr, ions, iter, st, hm, ks)
1182 call output_modelmb(outp, namespace, space, filename, gr, ions, iter, st)
1184 if (
present(dt))
then
1185 call output_scalar_pot(outp, namespace, space, filename, gr, ions, ext_partners, iter*dt)
1187 if (iter == 0)
call output_scalar_pot(outp, namespace, space, filename, gr, ions, ext_partners)
1196 type(c_ptr),
intent(inout) ::
out_spin
1197 class(
mesh_t),
intent(in) :: mesh
1199 integer,
intent(in) :: iter
1201 character(len=130) :: aux
1202 real(real64) :: spin(3)
1218 if (st%d%ispin ==
spinors)
then
1219 write(aux,
'(a2,18x)')
'Sx'
1221 write(aux,
'(a2,18x)')
'Sy'
1224 write(aux,
'(a2,18x)')
'Sz'
1232 select case (st%d%ispin)
1251 type(
ions_t),
intent(in) :: ions
1252 real(real64),
intent(in) :: lmm_r
1253 integer,
intent(in) :: iter
1256 character(len=50) :: aux
1257 real(real64),
allocatable :: lmm(:,:)
1262 safe_allocate(lmm(1:3, 1:ions%natoms))
1272 do ia = 1, ions%natoms
1273 if (st%d%ispin ==
spinors)
then
1274 write(aux,
'(a2,i2.2,16x)')
'mx', ia
1276 write(aux,
'(a2,i2.2,16x)')
'my', ia
1279 write(aux,
'(a2,i2.2,16x)')
'mz', ia
1288 do ia = 1, ions%natoms
1289 select case (st%d%ispin)
1297 safe_deallocate_a(lmm)
1305 type(c_ptr),
intent(inout) :: out_magnets
1306 class(
mesh_t),
intent(in) :: mesh
1308 type(
kick_t),
intent(in) :: kick
1309 integer,
intent(in) :: iter
1311 complex(real64),
allocatable :: tm(:,:)
1316 safe_allocate(tm(1:6,1:kick%nqvec))
1318 do iq = 1, kick%nqvec
1348 do iq = 1, kick%nqvec
1357 safe_deallocate_a(tm)
1371 subroutine td_write_angular(out_angular, namespace, space, gr, ions, hm, st, kick, iter)
1372 type(c_ptr),
intent(inout) :: out_angular
1374 class(
space_t),
intent(in) :: space
1375 type(
grid_t),
intent(in) :: gr
1376 type(
ions_t),
intent(inout) :: ions
1379 type(
kick_t),
intent(in) :: kick
1380 integer,
intent(in) :: iter
1383 character(len=130) :: aux
1384 real(real64) :: angular(3)
1391 call angular_momentum%setup_dir(idir)
1394 m_two*real(angular_momentum%zstates_elec_expectation_value(namespace, space, gr, hm, st), real64)
1396 safe_deallocate_p(angular_momentum)
1403 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
1411 write(aux,
'(a4,18x)')
'<Lx>'
1413 write(aux,
'(a4,18x)')
'<Ly>'
1415 write(aux,
'(a4,18x)')
'<Lz>'
1444 class(
space_t),
intent(in) :: space
1445 type(
grid_t),
intent(in) :: gr
1446 type(
ions_t),
intent(in) :: ions
1448 integer,
intent(in) :: lmax
1449 type(
kick_t),
intent(in) :: kick
1450 integer,
intent(in) :: iter
1453 real(real64),
allocatable :: rho(:,:)
1457 if (out_multip%resolve_states)
then
1458 safe_allocate(rho(1:gr%np_part, 1:st%d%nspin))
1461 do ist = st%st_start, st%st_end
1463 call td_write_multipole_r(out_multip%mult_handles(ist), space, gr, ions, st, lmax, kick, rho, iter, &
1464 mpi_grp = out_multip%mpi_grp)
1467 safe_deallocate_a(rho)
1470 if (
allocated(st%frozen_rho))
then
1471 safe_allocate(rho(1:gr%np, 1:st%d%nspin))
1472 call lalg_copy(gr%np, st%d%nspin, st%rho, rho)
1477 safe_deallocate_a(rho)
1489 subroutine td_write_multipole_r(out_multip, space, mesh, ions, st, lmax, kick, rho, iter, mpi_grp)
1490 type(c_ptr),
intent(inout) :: out_multip
1491 class(
space_t),
intent(in) :: space
1492 class(
mesh_t),
intent(in) :: mesh
1493 type(
ions_t),
intent(in) :: ions
1495 integer,
intent(in) :: lmax
1496 type(
kick_t),
intent(in) :: kick
1497 real(real64),
intent(in) :: rho(:,:)
1498 integer,
intent(in) :: iter
1499 type(
mpi_grp_t),
optional,
intent(in) :: mpi_grp
1502 integer :: is, idir, ll, mm, add_lm
1503 character(len=120) :: aux
1504 real(real64) :: ionic_dipole(ions%space%dim)
1505 real(real64),
allocatable :: multipole(:,:)
1511 assert(.not. (lmax > 1 .and. space%dim > 3))
1514 if (
present(mpi_grp)) mpi_grp_ = mpi_grp
1516 if (mpi_grp_%is_root().and.iter == 0)
then
1519 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
1523 write(aux,
'(a15,i2)')
'# lmax ', lmax
1531 do is = 1, st%d%nspin
1532 write(aux,
'(a18,i1,a1)')
'Electronic charge(', is,
')'
1535 do idir = 1, space%dim
1536 write(aux,
'(4a1,i1,a1)')
'<',
index2axis(idir),
'>',
'(', is,
')'
1542 write(aux,
'(a2,i2,a4,i2,a2,i1,a1)')
'l=', ll,
', m=', mm,
' (', is,
')'
1553 do is = 1, st%d%nspin
1556 do idir = 1, space%dim
1572 if (space%dim > 3 .and. lmax == 1)
then
1574 safe_allocate(multipole(1:space%dim+1, 1:st%d%nspin))
1576 safe_allocate(multipole(1:(lmax + 1)**2, 1:st%d%nspin))
1580 do is = 1, st%d%nspin
1585 ionic_dipole = ions%dipole()
1586 do is = 1, st%d%nspin
1587 multipole(2:space%dim+1, is) = -ionic_dipole(1:space%dim)/st%d%nspin - multipole(2:space%dim+1, is)
1591 if (mpi_grp_%is_root())
then
1593 do is = 1, st%d%nspin
1596 do idir = 1, space%dim
1600 add_lm = space%dim + 2
1611 safe_deallocate_a(multipole)
1616 subroutine td_write_ftchd(out_ftchd, space, mesh, st, kick, iter)
1617 type(c_ptr),
intent(inout) :: out_ftchd
1618 class(
space_t),
intent(in) :: space
1619 class(
mesh_t),
intent(in) :: mesh
1621 type(
kick_t),
intent(in) :: kick
1622 integer,
intent(in) :: iter
1624 integer :: is, ip, idir
1625 character(len=120) :: aux, aux2
1626 real(real64) :: ftchd_bessel
1627 complex(real64) :: ftchd
1629 real(real64),
allocatable :: integrand_bessel(:)
1630 complex(real64),
allocatable :: integrand(:)
1634 if (
mpi_world%is_root().and.iter == 0)
then
1637 write(aux,
'(a15, i2)')
'# qkickmode ', kick%qkick_mode
1642 write(aux,
'(a15, i0.3, 1x, i0.3)')
'# ll, mm ', kick%qbessel_l, kick%qbessel_m
1648 write(aux,
'(a15, f9.6)')
'# qlength ', kick%qlength
1650 write(aux,
'(a15)')
'# qvector '
1651 do idir = 1, space%dim
1652 write(aux2,
'(f9.5)') kick%qvector(idir,1)
1653 aux = trim(aux) // trim(aux2)
1659 write(aux,
'(a15,f18.12)')
'# kick strength', kick%delta_strength
1665 write(aux,
'(a17)')
'int(j_l*Y_lm*rho)'
1667 write(aux,
'(a12)')
'Real, Imag'
1684 safe_allocate(integrand(1:mesh%np))
1686 do is = 1, st%d%nspin
1688 integrand(ip) = integrand(ip) + st%rho(ip, is) *
exp(-
m_zi*sum(mesh%x(ip, 1:space%dim)*kick%qvector(1:space%dim, 1)))
1692 safe_deallocate_a(integrand)
1695 safe_allocate(integrand_bessel(1:mesh%np))
1696 integrand_bessel =
m_zero
1697 do is = 1, st%d%nspin
1699 call ylmr_real(mesh%x(ip, 1:3), kick%qbessel_l, kick%qbessel_m, ylm)
1700 integrand_bessel(ip) = integrand_bessel(ip) + st%rho(ip, is) * &
1701 loct_sph_bessel(kick%qbessel_l, kick%qlength*norm2(mesh%x(ip, :)))*ylm
1705 safe_deallocate_a(integrand_bessel)
1724 type(c_ptr),
intent(inout) :: out_temperature
1725 type(
ions_t),
intent(in) :: ions
1726 integer,
intent(in) :: iter
1761 type(c_ptr),
intent(inout) :: out_populations
1763 class(
space_t),
intent(in) :: space
1764 class(
mesh_t),
intent(in) :: mesh
1767 real(real64),
intent(in) :: dt
1768 integer,
intent(in) :: iter
1771 character(len=6) :: excited_name
1772 complex(real64) :: gsp
1773 complex(real64),
allocatable :: excited_state_p(:)
1774 complex(real64),
allocatable :: dotprodmatrix(:, :, :)
1779 safe_allocate(dotprodmatrix(1:writ%gs_st%nst, 1:st%nst, 1:st%nik))
1784 assert(.not. space%is_periodic())
1789 if (writ%n_excited_states > 0)
then
1790 safe_allocate(excited_state_p(1:writ%n_excited_states))
1791 do ist = 1, writ%n_excited_states
1792 excited_state_p(ist) =
zstates_elec_mpdotp(namespace, mesh, writ%excited_st(ist), st, dotprodmatrix)
1804 do ist = 1, writ%n_excited_states
1805 write(excited_name,
'(a2,i3,a1)')
'P(', ist,
')'
1824 do ist = 1, writ%n_excited_states
1831 if (writ%n_excited_states > 0)
then
1832 safe_deallocate_a(excited_state_p)
1834 safe_deallocate_a(dotprodmatrix)
1840 subroutine td_write_acc(out_acc, namespace, space, gr, ions, st, hm, ext_partners, dt, iter)
1841 type(c_ptr),
intent(inout) :: out_acc
1843 class(
space_t),
intent(in) :: space
1844 type(
grid_t),
intent(in) :: gr
1845 type(
ions_t),
intent(inout) :: ions
1849 real(real64),
intent(in) :: dt
1850 integer,
intent(in) :: iter
1853 character(len=7) :: aux
1854 real(real64) :: acc(space%dim)
1858 if (iter == 0 .and.
mpi_world%is_root())
then
1863 do idim = 1, space%dim
1864 write(aux,
'(a4,i1,a1)')
'Acc(', idim,
')'
1872 do idim = 1, space%dim
1879 call td_calc_tacc(namespace, space, gr, ions, ext_partners, st, hm, acc, dt*iter)
1892 subroutine td_write_vel(out_vel, namespace, gr, st, space, hm, ions, iter)
1893 type(c_ptr),
intent(inout) :: out_vel
1895 type(
grid_t),
intent(in) :: gr
1897 type(
space_t),
intent(in) :: space
1899 type(
ions_t),
intent(in) :: ions
1900 integer,
intent(in) :: iter
1903 character(len=7) :: aux
1904 real(real64) :: vel(space%dim)
1908 if (iter == 0 .and.
mpi_world%is_root())
then
1913 do idim = 1, space%dim
1914 write(aux,
'(a4,i1,a1)')
'Vel(', idim,
')'
1922 do idim = 1, space%dim
1929 call td_calc_tvel(namespace, gr, st, space, hm, ions, vel)
1944 type(c_ptr),
intent(inout) :: out_laser
1945 class(
space_t),
intent(in) :: space
1946 type(
lasers_t),
intent(inout) :: lasers
1947 real(real64),
intent(in) :: dt
1948 integer,
intent(in) :: iter
1951 real(real64) :: field(space%dim)
1952 real(real64) :: ndfield(space%dim)
1953 character(len=80) :: aux
1969 do il = 1, lasers%no_lasers
1972 do idir = 1, space%dim
1973 write(aux,
'(a,i1,a)')
'E(', idir,
')'
1977 do idir = 1, space%dim
1978 write(aux,
'(a,i1,a)')
'B(', idir,
')'
1982 do idir = 1, space%dim
1983 write(aux,
'(a,i1,a)')
'A(', idir,
')'
1987 write(aux,
'(a,i1,a)')
'e(t)'
1993 do idir = 1, space%dim
1994 write(aux,
'(a,i1,a)')
'A^M(', idir,
')'
2006 do il = 1, lasers%no_lasers
2010 do idir = 1, space%dim
2015 do idir = 1, space%dim
2026 do idir = 1, space%dim
2039 do il = 1, lasers%no_lasers
2041 call laser_field(lasers%lasers(il), field(1:space%dim), iter*dt)
2066 type(c_ptr),
intent(inout) :: out_energy
2068 integer,
intent(in) :: iter
2069 real(real64),
intent(in) :: ke
2073 integer :: n_columns
2096 if (hm%pcm%run_pcm)
then
2098 n_columns = n_columns + 1
2103 n_columns = n_columns + 1
2113 do ii = 1, n_columns
2136 hm%energy%int_nn_pcm + hm%energy%int_ne_pcm), 1)
2149 type(c_ptr),
intent(inout) :: out_eigs
2151 integer,
intent(in) :: iter
2154 character(len=68) :: buf
2167 write(buf,
'(a15,i2)')
'# nst ', st%nst
2171 write(buf,
'(a15,i2)')
'# nspin ', st%d%nspin
2177 do is = 1, st%d%kpt%nglobal
2179 write(buf,
'(a,i4)')
'Eigenvalue ',ii
2188 do is = 1, st%d%kpt%nglobal
2198 do is = 1, st%d%kpt%nglobal
2210 type(c_ptr),
intent(inout) :: out_ionch
2211 class(
mesh_t),
intent(in) :: mesh
2213 integer,
intent(in) :: iter
2215 integer :: ii, ist, Nch, ik, idim
2216 character(len=68) :: buf
2217 real(real64),
allocatable :: ch(:), occ(:)
2218 real(real64),
allocatable :: occbuf(:)
2223 nch = st%nst * st%d%kpt%nglobal * st%d%dim
2224 safe_allocate(ch(0: nch))
2225 safe_allocate(occ(0: nch))
2231 do idim = 1, st%d%dim
2232 if (st%st_start <= ist .and. ist <= st%st_end .and. &
2233 st%d%kpt%start <= ik .and. ik <= st%d%kpt%end)
then
2234 occ(ii) = st%occ(ist, ik)
2242 if (st%parallel_in_states)
then
2243 safe_allocate(occbuf(0: nch))
2245 call st%mpi_grp%allreduce(occ(0), occbuf(0), nch+1, mpi_double_precision, mpi_sum)
2247 safe_deallocate_a(occbuf)
2255 safe_deallocate_a(ch)
2268 if (occ(ii)>
m_zero .or. ii == 0)
then
2269 write(buf,
'(a,f4.1,a)')
'Pion(',occ(ii)*ii,
'+, t)'
2279 if (occ(ii)>
m_zero .or. ii == 0)
then
2289 if (occ(ii)>
m_zero .or. ii == 0)
then
2295 safe_deallocate_a(ch)
2296 safe_deallocate_a(occ)
2302 subroutine td_write_proj(out_proj, space, mesh, ions, st, gs_st, kick, iter)
2303 type(c_ptr),
intent(inout) :: out_proj
2305 class(
mesh_t),
intent(in) :: mesh
2306 type(
ions_t),
intent(in) :: ions
2309 type(
kick_t),
intent(in) :: kick
2310 integer,
intent(in) :: iter
2312 complex(real64),
allocatable :: projections(:,:,:)
2313 character(len=80) :: aux
2314 integer :: ik, ist, uist, idir
2322 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
2331 write(aux,
'(a,i8)')
"# nik ", st%nik
2335 write(aux,
'(a,2i8)')
"# st ", gs_st%st_start, st%nst
2339 write(aux,
'(a,2i8)')
"# ust ", gs_st%st_start, gs_st%st_end
2345 do ist = gs_st%st_start, st%nst
2353 do ist = gs_st%st_start, st%nst
2354 do uist = gs_st%st_start, gs_st%st_end
2355 write(aux,
'(i4,a,i4)') ist,
' -> ', uist
2366 if (.not. space%is_periodic())
then
2368 safe_allocate(projections(1:st%nst, gs_st%st_start:gs_st%st_end, 1:st%nik))
2369 do idir = 1, space%dim
2375 write(aux,
'(a,i1,a)')
"<i|x_", idir,
"|a>"
2379 do ist = gs_st%st_start, st%st_end
2380 do uist = gs_st%st_start, gs_st%st_end
2390 safe_deallocate_a(projections)
2400 safe_allocate(projections(1:st%nst, gs_st%st_start:gs_st%st_end, 1:st%nik))
2401 projections(:,:,:) =
m_z0
2407 do ist = gs_st%st_start, st%nst
2408 do uist = gs_st%st_start, gs_st%st_end
2417 safe_deallocate_a(projections)
2423 integer,
intent(in) :: dir
2425 integer :: uist, ist, ik, idim
2426 real(real64) :: n_dip(space%dim)
2427 complex(real64),
allocatable :: xpsi(:,:)
2428 complex(real64),
allocatable :: psi(:, :), gspsi(:, :)
2432 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
2433 safe_allocate(gspsi(1:mesh%np, 1:st%d%dim))
2434 safe_allocate(xpsi(1:mesh%np, 1:st%d%dim))
2436 do ik = st%d%kpt%start, st%d%kpt%end
2437 do ist = st%st_start, st%st_end
2439 do uist = gs_st%st_start, gs_st%st_end
2442 do idim = 1, st%d%dim
2443 xpsi(1:mesh%np, idim) = mesh%x(1:mesh%np, dir)*gspsi(1:mesh%np, idim)
2445 projections(ist, uist, ik) = -
zmf_dotp(mesh, st%d%dim, psi, xpsi, reduce = .false.)
2451 safe_deallocate_a(xpsi)
2452 safe_deallocate_a(gspsi)
2453 safe_deallocate_a(psi)
2458 n_dip = ions%dipole()
2460 do ist = gs_st%st_start, st%nst
2461 do uist = gs_st%st_start, gs_st%st_end
2462 projections(ist, uist, ik) = projections(ist, uist, ik) - n_dip(dir)
2478 subroutine td_write_n_ex(out_nex, outp, namespace, mesh, kpoints, st, gs_st, iter)
2479 type(c_ptr),
intent(inout) :: out_nex
2482 class(
mesh_t),
intent(in) :: mesh
2486 integer,
intent(in) :: iter
2488 complex(real64),
allocatable :: projections(:,:)
2489 character(len=80) :: aux, dir
2490 integer :: ik, ikpt, ist, uist, err
2491 real(real64) :: Nex, weight
2493 real(real64),
allocatable :: Nex_kpt(:)
2502 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
2509 write(aux,
'(a,i8)')
"# nik ", st%nik
2513 write(aux,
'(a,2i8)')
"# st ", gs_st%st_start, st%nst
2517 write(aux,
'(a,2i8)')
"# ust ", gs_st%st_start, gs_st%st_end
2536 do ist = 1, gs_st%nst
2537 if (gs_st%occ(ist, ik) >
m_min_occ .and. ist > gs_nst) gs_nst = ist
2541 safe_allocate(projections(1:gs_nst, 1:st%nst))
2543 safe_allocate(nex_kpt(1:st%nik))
2545 do ik = st%d%kpt%start, st%d%kpt%end
2546 ikpt = st%d%get_kpoint_index(ik)
2549 weight = st%kweights(ik) * gs_st%occ(ist, ik)/ st%smear%el_per_state
2550 do uist = st%st_start, st%st_end
2551 nex_kpt(ikpt) = nex_kpt(ikpt) - weight * st%occ(uist, ik) * abs(projections(ist, uist))**2
2554 nex_kpt(ikpt) = nex_kpt(ikpt) + sum(st%occ(st%st_start:st%st_end, ik))*st%kweights(ik)
2557 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
2569 write(dir,
'(a,a,i7.7)') trim(outp%iter_dir),
"td.", iter
2572 + outp%how(option__output__density_kpt), dir,
"n_excited_el_kpt", namespace, &
2576 safe_deallocate_a(projections)
2577 safe_deallocate_a(nex_kpt)
2589 class(
mesh_t),
intent(in) :: mesh
2592 complex(real64),
intent(inout) :: projections(1:st%nst, gs_st%st_start:gs_st%nst, 1:st%nik)
2594 integer :: uist, ist, ik
2595 complex(real64),
allocatable :: psi(:, :), gspsi(:, :)
2598 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
2599 safe_allocate(gspsi(1:mesh%np, 1:st%d%dim))
2601 projections(:,:,:) =
m_zero
2603 do ik = st%d%kpt%start, st%d%kpt%end
2604 do ist = st%st_start, st%st_end
2606 do uist = gs_st%st_start, gs_st%nst
2608 projections(ist, uist, ik) =
zmf_dotp(mesh, st%d%dim, psi, gspsi, reduce = .false.)
2613 safe_deallocate_a(psi)
2614 safe_deallocate_a(gspsi)
2623 class(
mesh_t),
intent(in) :: mesh
2628 integer,
intent(in) :: iter
2630 complex(real64),
allocatable :: proj(:,:), psi(:,:,:), gs_psi(:,:,:), temp_state(:,:)
2631 character(len=80) :: filename1, filename2
2632 integer :: ik,ist, jst, file, idim, nk_proj
2636 write(filename1,
'(I10)') iter
2637 filename1 =
'td.general/projections_iter_'//trim(adjustl(filename1))
2640 safe_allocate(proj(1:gs_st%nst, 1:gs_st%nst))
2641 safe_allocate(psi(1:gs_st%nst,1:gs_st%d%dim,1:mesh%np))
2642 safe_allocate(gs_psi(1:gs_st%nst,1:gs_st%d%dim,1:mesh%np))
2643 safe_allocate(temp_state(1:mesh%np,1:gs_st%d%dim))
2649 nk_proj = kpoints%nik_skip
2651 do ik = kpoints%reduced%npoints-nk_proj+1, kpoints%reduced%npoints
2653 psi(1:gs_st%nst, 1:gs_st%d%dim, 1:mesh%np)=
m_zero
2654 gs_psi(1:gs_st%nst, 1:gs_st%d%dim, 1:mesh%np)=
m_zero
2657 write(filename2,
'(I10)') ik
2658 filename2 = trim(adjustl(filename1))//
'_ik_'//trim(adjustl(filename2))
2659 file =
io_open(filename2, namespace, action=
'write')
2662 do ist=gs_st%st_start,gs_st%st_end
2665 do idim = 1,gs_st%d%dim
2666 psi(ist,idim,1:mesh%np) = temp_state(1:mesh%np,idim)
2669 do idim = 1,gs_st%d%dim
2670 gs_psi(ist,idim,1:mesh%np) = temp_state(1:mesh%np,idim)
2679 assert(mesh%np_global*gs_st%d%dim < huge(0_int32))
2680 proj(1:gs_st%nst, 1:gs_st%nst) =
m_zero
2685 i8_to_i4(mesh%np_global*gs_st%d%dim), &
2686 cmplx(mesh%volume_element,
m_zero, real64) , &
2688 ubound(psi, dim = 1), &
2690 ubound(gs_psi, dim = 1), &
2693 ubound(proj, dim = 1))
2697 do ist = 1, gs_st%nst
2698 do jst = 1, gs_st%nst
2699 write(file,
'(I3,1x,I3,1x,e13.6,1x,e13.6,2x)') ist, jst, proj(ist,jst)
2707 safe_deallocate_a(proj)
2708 safe_deallocate_a(psi)
2709 safe_deallocate_a(gs_psi)
2710 safe_deallocate_a(temp_state)
2716 subroutine td_write_floquet(namespace, space, hm, ext_partners, gr, st, iter)
2717 type(namespace_t),
intent(in) :: namespace
2718 class(space_t),
intent(in) :: space
2719 type(hamiltonian_elec_t),
intent(inout) :: hm
2720 type(partner_list_t),
intent(in) :: ext_partners
2721 type(grid_t),
intent(in) :: gr
2722 type(states_elec_t),
intent(inout) :: st
2723 integer,
intent(in) :: iter
2725 complex(real64),
allocatable :: hmss(:,:), psi(:,:,:), hpsi(:,:,:), temp_state1(:,:)
2726 complex(real64),
allocatable :: HFloquet(:,:,:), HFloq_eff(:,:), temp(:,:)
2727 real(real64),
allocatable :: eigenval(:), bands(:,:)
2728 character(len=80) :: filename
2729 integer :: it, nT, ik, ist, in, im, file, idim, nik, ik_count
2730 integer :: Forder, Fdim, m0, n0, n1, nst, ii, jj, lim_nst
2731 logical :: downfolding
2732 type(states_elec_t) :: hm_st
2734 real(real64) :: dt, Tcycle, omega
2738 downfolding = .false.
2741 if (.not. iter == 0)
then
2749 assert(gr%np == gr%np_global)
2752 call states_elec_copy(hm_st, st)
2763 call parse_variable(namespace,
'TDFloquetFrequency', m_zero, omega, units_inp%energy)
2764 call messages_print_var_value(
'Frequency used for Floquet analysis', omega, namespace=namespace)
2765 if (abs(omega) <= m_epsilon)
then
2766 message(1) =
"Please give a non-zero value for TDFloquetFrequency"
2767 call messages_fatal(1, namespace=namespace)
2771 tcycle = m_two * m_pi / omega
2781 call parse_variable(namespace,
'TDFloquetSample',20 ,nt)
2782 call messages_print_var_value(
'Number of Floquet time-sampling points', nt, namespace=namespace)
2783 dt = tcycle/real(nt, real64)
2792 call parse_variable(namespace,
'TDFloquetDimension',-1,forder)
2793 if (forder .ge. 0)
then
2794 call messages_print_var_value(
'Order of multiphoton Floquet-Hamiltonian', forder, namespace=namespace)
2796 fdim = 2 * forder + 1
2798 message(1) =
'Floquet-Hamiltonian is downfolded'
2799 call messages_info(1, namespace=namespace)
2800 downfolding = .
true.
2805 dt = tcycle/real(nt, real64)
2808 nik = hm%kpoints%nik_skip
2810 safe_allocate(hmss(1:nst,1:nst))
2811 safe_allocate( psi(1:nst,1:st%d%dim,1:gr%np))
2812 safe_allocate(hpsi(1:nst,1:st%d%dim,1:gr%np))
2813 safe_allocate(temp_state1(1:gr%np,1:st%d%dim))
2821 safe_allocate(hfloquet(1:nik,1:nst*fdim, 1:nst*fdim))
2822 hfloquet(1:nik,1:nst*fdim, 1:nst*fdim) = m_zero
2827 call hm%update(gr, namespace, space, ext_partners, time=tcycle+it*dt)
2829 call zhamiltonian_elec_apply_all(hm, namespace, gr, st, hm_st)
2834 do ik = hm%kpoints%reduced%npoints-nik+1, hm%kpoints%reduced%npoints
2835 ik_count = ik_count + 1
2837 psi(1:nst, 1:st%d%dim, 1:gr%np)= m_zero
2838 hpsi(1:nst, 1:st%d%dim, 1:gr%np)= m_zero
2840 do ist = st%st_start, st%st_end
2841 if (state_kpt_is_local(st, ist, ik))
then
2842 call states_elec_get_state(st, gr, ist, ik,temp_state1)
2843 do idim = 1, st%d%dim
2844 psi(ist, idim, 1:gr%np) = temp_state1(1:gr%np, idim)
2846 call states_elec_get_state(hm_st, gr, ist, ik,temp_state1)
2847 do idim = 1, st%d%dim
2848 hpsi(ist, idim, 1:gr%np) = temp_state1(1:gr%np, idim)
2852 call comm_allreduce(mpi_world, psi)
2853 call comm_allreduce(mpi_world, hpsi)
2854 assert(gr%np_global*st%d%dim < huge(0_int32))
2855 hmss(1:nst,1:nst) = m_zero
2860 i8_to_i4(gr%np_global*st%d%dim), &
2861 cmplx(gr%volume_element, m_zero, real64) , &
2863 ubound(hpsi, dim = 1), &
2865 ubound(psi, dim = 1), &
2868 ubound(hmss, dim = 1))
2870 hmss(1:nst,1:nst) = conjg(hmss(1:nst,1:nst))
2873 do in = -forder, forder
2874 do im = -forder, forder
2875 ii = (in+forder) * nst
2876 jj = (im+forder) * nst
2877 hfloquet(ik_count, ii+1:ii+nst, jj+1:jj+nst) = &
2878 hfloquet(ik_count, ii+1:ii+nst, jj+1:jj+nst) + hmss(1:nst, 1:nst) *
exp(-(in-im)*m_zi*omega*it*dt)
2882 hfloquet(ik_count, ii+ist, ii+ist) = hfloquet(ik_count, ii+ist, ii+ist) + in*omega
2891 hfloquet(:,:,:) = m_one/nt*hfloquet(:,:,:)
2894 if (downfolding)
then
2896 safe_allocate(hfloq_eff(1:nst,1:nst))
2897 safe_allocate(eigenval(1:nst))
2898 safe_allocate(bands(1:nik,1:nst))
2900 hfloq_eff(1:nst,1:nst) = m_zero
2906 hfloq_eff(1:nst, 1:nst) = hfloquet(ik, n0+1:n0+nst, m0+1:m0+nst) + &
2907 m_one/omega*(matmul(hfloquet(ik, 1:nst, m0+1:m0+nst), hfloquet(ik, n1+1:n1+nst, m0+1:m0+nst))- &
2908 matmul(hfloquet(ik, n1+1:n1+nst, m0+1:m0+nst), hfloquet(ik, 1:nst, m0+1:m0+nst)))
2910 call lalg_eigensolve(nst, hfloq_eff, eigenval)
2911 bands(ik,1:nst) = eigenval(1:nst)
2913 safe_deallocate_a(hfloq_eff)
2916 safe_allocate(eigenval(1:nst*fdim))
2917 safe_allocate(bands(1:nik,1:nst*fdim))
2918 safe_allocate(temp(1:nst*fdim, 1:nst*fdim))
2921 temp(1:nst*fdim, 1:nst*fdim) = hfloquet(ik, 1:nst*fdim, 1:nst*fdim)
2922 call lalg_eigensolve(nst*fdim, temp, eigenval)
2923 bands(ik, 1:nst*fdim) = eigenval(1:nst*fdim)
2928 if (downfolding)
then
2930 filename =
"downfolded_floquet_bands"
2933 filename =
"floquet_bands"
2936 if (mpi_world%is_root())
then
2938 file = io_open(filename, namespace, action =
'write')
2941 write(file,
'(e13.6, 1x)',advance=
'no') bands(ik,ist)
2948 if (.not. downfolding)
then
2951 bands(1:nik, 1:nst*fdim) = m_zero
2953 temp(1:nst*fdim,1:nst*fdim) = m_zero
2956 temp(ii+1:ii+nst, ii+1:ii+nst) = hfloquet(ik, ii+1:ii+nst, ii+1:ii+nst)
2958 call lalg_eigensolve(nst*fdim, temp, eigenval)
2959 bands(ik, 1:nst*fdim) = eigenval(1:nst*fdim)
2962 if (mpi_world%is_root())
then
2963 filename =
'trivial_floquet_bands'
2964 file = io_open(filename, namespace, action =
'write')
2967 write(file,
'(e13.6, 1x)', advance=
'no') bands(ik,ist)
2976 call hm%update(gr, namespace, space, ext_partners, time=m_zero)
2978 safe_deallocate_a(hmss)
2979 safe_deallocate_a(psi)
2980 safe_deallocate_a(hpsi)
2981 safe_deallocate_a(temp_state1)
2982 safe_deallocate_a(hfloquet)
2983 safe_deallocate_a(eigenval)
2984 safe_deallocate_a(bands)
2985 safe_deallocate_a(temp)
2993 type(c_ptr),
intent(inout) :: out_total_current
2994 class(space_t),
intent(in) :: space
2995 class(mesh_t),
intent(in) :: mesh
2996 type(states_elec_t),
intent(in) :: st
2997 integer,
intent(in) :: iter
2999 integer :: idir, ispin
3000 character(len=50) :: aux
3001 real(real64) :: total_current(space%dim), abs_current(space%dim)
3005 if (mpi_world%is_root() .and. iter == 0)
then
3006 call td_write_print_header_init(out_total_current)
3009 call write_iter_header_start(out_total_current)
3011 do idir = 1, space%dim
3012 write(aux,
'(a2,a1,a1)')
'I(', index2axis(idir),
')'
3013 call write_iter_header(out_total_current, aux)
3016 do idir = 1, space%dim
3017 write(aux,
'(a10,a1,a1)')
'IntAbs(j)(', index2axis(idir),
')'
3018 call write_iter_header(out_total_current, aux)
3021 do ispin = 1, st%d%nspin
3022 do idir = 1, space%dim
3023 write(aux,
'(a4,i1,a1,a1,a1)')
'I-sp', ispin,
'(', index2axis(idir),
')'
3024 call write_iter_header(out_total_current, aux)
3028 call write_iter_nl(out_total_current)
3030 call td_write_print_header_end(out_total_current)
3033 assert(
allocated(st%current))
3035 if (mpi_world%is_root())
then
3036 call write_iter_start(out_total_current)
3039 total_current = 0.0_real64
3040 do idir = 1, space%dim
3041 do ispin = 1, st%d%spin_channels
3042 total_current(idir) = total_current(idir) + dmf_integrate(mesh, st%current(:, idir, ispin), reduce = .false.)
3044 total_current(idir) = units_from_atomic(units_out%length/units_out%time, total_current(idir))
3046 call mesh%allreduce(total_current, dim = space%dim)
3048 abs_current = 0.0_real64
3049 do idir = 1, space%dim
3050 do ispin = 1, st%d%spin_channels
3051 abs_current(idir) = abs_current(idir) + dmf_integrate(mesh, abs(st%current(:, idir, ispin)), reduce = .false.)
3053 abs_current(idir) = units_from_atomic(units_out%length/units_out%time, abs_current(idir))
3055 call mesh%allreduce(abs_current, dim = space%dim)
3057 if (mpi_world%is_root())
then
3058 call write_iter_double(out_total_current, total_current, space%dim)
3059 call write_iter_double(out_total_current, abs_current, space%dim)
3062 do ispin = 1, st%d%nspin
3063 total_current = units_from_atomic(units_out%length/units_out%time, dmf_integrate(mesh, space%dim, st%current(:, :, ispin)))
3065 if (mpi_world%is_root())
then
3066 call write_iter_double(out_total_current, total_current, space%dim)
3070 if (mpi_world%is_root())
then
3071 call write_iter_nl(out_total_current)
3079 type(c_ptr),
intent(inout) :: out_ionic_current
3080 class(space_t),
intent(in) :: space
3081 class(ions_t),
intent(in) :: ions
3082 integer,
intent(in) :: iter
3085 character(len=50) :: aux
3086 real(real64) :: ionic_current(space%dim), abs_current(space%dim)
3090 if (mpi_world%is_root() .and. iter == 0)
then
3091 call td_write_print_header_init(out_ionic_current)
3094 call write_iter_header_start(out_ionic_current)
3096 do idir = 1, space%dim
3097 write(aux,
'(a2,a1,a1)')
'I(', index2axis(idir),
')'
3098 call write_iter_header(out_ionic_current, aux)
3101 do idir = 1, space%dim
3102 write(aux,
'(a10,a1,a1)')
'IntAbs(j)(', index2axis(idir),
')'
3103 call write_iter_header(out_ionic_current, aux)
3106 call write_iter_nl(out_ionic_current)
3108 call td_write_print_header_end(out_ionic_current)
3111 if (mpi_world%is_root())
then
3112 call write_iter_start(out_ionic_current)
3115 ionic_current = ions%current()
3116 abs_current = ions%abs_current()
3118 if (mpi_world%is_root())
then
3119 call write_iter_double(out_ionic_current, ionic_current, space%dim)
3120 call write_iter_double(out_ionic_current, abs_current, space%dim)
3123 if (mpi_world%is_root())
then
3124 call write_iter_nl(out_ionic_current)
3134 type(c_ptr),
intent(inout) :: write_obj
3135 class(space_t),
intent(in) :: space
3136 type(hamiltonian_elec_t),
intent(inout) :: hm
3137 type(grid_t),
intent(in) :: gr
3138 type(states_elec_t),
intent(in) :: st
3139 integer,
intent(in) :: iter
3141 integer :: idir, ispin
3142 character(len=50) :: aux
3143 real(real64),
allocatable :: heat_current(:, :, :)
3144 real(real64) :: total_current(space%dim)
3148 if (mpi_world%is_root() .and. iter == 0)
then
3149 call td_write_print_header_init(write_obj)
3152 call write_iter_header_start(write_obj)
3154 do idir = 1, space%dim
3155 write(aux,
'(a2,i1,a1)')
'Jh(', idir,
')'
3156 call write_iter_header(write_obj, aux)
3159 call write_iter_nl(write_obj)
3161 call td_write_print_header_end(write_obj)
3164 safe_allocate(heat_current(1:gr%np, 1:space%dim, 1:st%d%nspin))
3166 call current_heat_calculate(space, gr%der, hm, st, heat_current)
3168 if (mpi_world%is_root())
call write_iter_start(write_obj)
3170 total_current = 0.0_real64
3171 do idir = 1, space%dim
3172 do ispin = 1, st%d%spin_channels
3173 total_current(idir) = total_current(idir) + dmf_integrate(gr, heat_current(:, idir, ispin))
3175 total_current(idir) = units_from_atomic(units_out%energy*units_out%length/units_out%time, total_current(idir))
3178 safe_deallocate_a(heat_current)
3180 if (mpi_world%is_root())
call write_iter_double(write_obj, total_current, space%dim)
3182 if (mpi_world%is_root())
call write_iter_nl(write_obj)
3190 type(c_ptr),
intent(inout) :: out_partial_charges
3191 class(mesh_t),
intent(in) :: mesh
3192 type(states_elec_t),
intent(in) :: st
3193 type(ions_t),
intent(in) :: ions
3194 integer,
intent(in) :: iter
3197 character(len=50) :: aux
3198 real(real64),
allocatable :: hirshfeld_charges(:)
3202 safe_allocate(hirshfeld_charges(1:ions%natoms))
3204 call partial_charges_calculate(mesh, st, ions, hirshfeld_charges)
3206 if (mpi_world%is_root())
then
3210 call td_write_print_header_init(out_partial_charges)
3213 call write_iter_header_start(out_partial_charges)
3215 do idir = 1, ions%natoms
3216 write(aux,
'(a13,i3,a1)')
'hirshfeld(atom=', idir,
')'
3217 call write_iter_header(out_partial_charges, aux)
3220 call write_iter_nl(out_partial_charges)
3222 call td_write_print_header_end(out_partial_charges)
3225 call write_iter_start(out_partial_charges)
3227 call write_iter_double(out_partial_charges, hirshfeld_charges, ions%natoms)
3229 call write_iter_nl(out_partial_charges)
3232 safe_deallocate_a(hirshfeld_charges)
3238 subroutine td_write_q(out_q, space, ks, iter)
3239 type(c_ptr),
intent(inout) :: out_q
3240 class(space_t),
intent(in) :: space
3241 type(v_ks_t),
intent(in) :: ks
3242 integer,
intent(in) :: iter
3245 character(len=50) :: aux
3249 if (mpi_world%is_root())
then
3251 call td_write_print_header_init(out_q)
3252 call write_iter_header_start(out_q)
3253 do ii = 1, ks%pt%nmodes
3254 write(aux,
'(a1,i3,a3)')
'q', ii,
'(t)'
3255 call write_iter_header(out_q, aux)
3257 do ii = 1, ks%pt%nmodes
3258 write(aux,
'(a1,i3,a3)')
'p', ii,
'(t)'
3259 call write_iter_header(out_q, aux)
3261 do ii = 1, space%dim
3262 write(aux,
'(a3,i3,a3)')
'f_pt', ii,
'(t)'
3263 call write_iter_header(out_q, aux)
3265 call write_iter_nl(out_q)
3266 call td_write_print_header_end(out_q)
3269 call write_iter_start(out_q)
3270 call write_iter_double(out_q, ks%pt_mx%pt_q, ks%pt%nmodes)
3271 call write_iter_double(out_q, ks%pt_mx%pt_p, ks%pt%nmodes)
3272 call write_iter_double(out_q, ks%pt_mx%fmf, space%dim)
3273 call write_iter_nl(out_q)
3282 type(c_ptr),
intent(inout) :: out_mxll
3283 class(space_t),
intent(in) :: space
3284 type(hamiltonian_elec_t),
intent(in) :: hm
3285 real(real64),
intent(in) :: dt
3286 integer,
intent(in) :: iter
3289 real(real64) :: field(space%dim)
3290 character(len=80) :: aux
3291 character(len=1) :: field_char
3295 if (.not. mpi_world%is_root())
then
3301 call td_write_print_header_init(out_mxll)
3303 write(aux,
'(a7,e20.12,3a)')
'# dt = ', units_from_atomic(units_out%time, dt), &
3304 " [", trim(units_abbrev(units_out%time)),
"]"
3305 call write_iter_string(out_mxll, aux)
3306 call write_iter_nl(out_mxll)
3308 call write_iter_header_start(out_mxll)
3309 select case (hm%mxll%coupling_mode)
3310 case (length_gauge_dipole, multipolar_expansion)
3311 if (hm%mxll%add_electric_dip) field_char =
'E'
3312 if (hm%mxll%add_magnetic_dip) field_char =
'B'
3313 do idir = 1, space%dim
3314 write(aux,
'(a,i1,a)') field_char //
'(', idir,
')'
3315 call write_iter_header(out_mxll, aux)
3317 case (velocity_gauge_dipole)
3318 do idir = 1, space%dim
3319 write(aux,
'(a,i1,a)')
'A(', idir,
')'
3320 call write_iter_header(out_mxll, aux)
3323 call write_iter_nl(out_mxll)
3325 call write_iter_string(out_mxll,
'#[Iter n.]')
3326 call write_iter_header(out_mxll,
'[' // trim(units_abbrev(units_out%time)) //
']')
3330 select case (hm%mxll%coupling_mode)
3331 case (length_gauge_dipole, multipolar_expansion)
3332 if (hm%mxll%add_electric_dip) aux =
'[' // trim(units_abbrev(units_out%force)) //
']'
3333 if (hm%mxll%add_magnetic_dip) aux =
'[' // trim(units_abbrev(unit_one/units_out%length**2)) //
']'
3334 do idir = 1, space%dim
3335 call write_iter_header(out_mxll, aux)
3337 case (velocity_gauge_dipole)
3338 aux =
'[' // trim(units_abbrev(units_out%energy)) //
']'
3339 do idir = 1, space%dim
3340 call write_iter_header(out_mxll, aux)
3343 call write_iter_nl(out_mxll)
3344 call td_write_print_header_end(out_mxll)
3347 call write_iter_start(out_mxll)
3350 select case (hm%mxll%coupling_mode)
3351 case (length_gauge_dipole, multipolar_expansion)
3352 if (hm%mxll%add_electric_dip) field = units_from_atomic(units_out%force, hm%mxll%e_field_dip)
3353 if (hm%mxll%add_magnetic_dip) field = units_from_atomic(unit_one/units_out%length**2, hm%mxll%b_field_dip)
3354 call write_iter_double(out_mxll, field, space%dim)
3355 case (velocity_gauge_dipole)
3356 field = units_from_atomic(units_out%energy, hm%mxll%vec_pot_dip)
3357 call write_iter_double(out_mxll, field, space%dim)
3359 call write_iter_nl(out_mxll)
3367 type(c_ptr),
intent(inout) :: out_coords
3368 type(lda_u_t),
intent(in) :: lda_u
3369 integer,
intent(in) :: iter
3372 character(len=50) :: aux
3374 if (.not. mpi_world%is_root())
return
3379 call td_write_print_header_init(out_coords)
3382 call write_iter_header_start(out_coords)
3384 do ios = 1, lda_u%norbsets
3385 write(aux,
'(a2,i3,a1)')
'Ueff(', ios,
')'
3386 call write_iter_header(out_coords, aux)
3389 do ios = 1, lda_u%norbsets
3390 write(aux,
'(a2,i3,a1)')
'U(', ios,
')'
3391 call write_iter_header(out_coords, aux)
3394 do ios = 1, lda_u%norbsets
3395 write(aux,
'(a2,i3,a1)')
'J(', ios,
')'
3396 call write_iter_header(out_coords, aux)
3399 if (lda_u%intersite)
then
3400 do ios = 1, lda_u%norbsets
3401 do inn = 1, lda_u%orbsets(ios)%nneighbors
3402 write(aux,
'(a2,i3,a1,i3,a1)')
'V(', ios,
'-', inn,
')'
3403 call write_iter_header(out_coords, aux)
3409 call write_iter_nl(out_coords)
3412 call write_iter_string(out_coords,
'#[Iter n.]')
3413 call write_iter_header(out_coords,
'[' // trim(units_abbrev(units_out%time)) //
']')
3414 call write_iter_string(out_coords, &
3415 'Effective U ' // trim(units_abbrev(units_out%energy)) // &
3416 ', U in '// trim(units_abbrev(units_out%energy)) // &
3417 ', J in ' // trim(units_abbrev(units_out%energy)))
3418 call write_iter_nl(out_coords)
3420 call td_write_print_header_end(out_coords)
3423 call write_iter_start(out_coords)
3425 do ios = 1, lda_u%norbsets
3426 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3427 lda_u%orbsets(ios)%Ueff), 1)
3430 do ios = 1, lda_u%norbsets
3431 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3432 lda_u%orbsets(ios)%Ubar), 1)
3435 do ios = 1, lda_u%norbsets
3436 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3437 lda_u%orbsets(ios)%Jbar), 1)
3440 if (lda_u%intersite)
then
3441 do ios = 1, lda_u%norbsets
3442 do inn = 1, lda_u%orbsets(ios)%nneighbors
3443 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3444 lda_u%orbsets(ios)%V_ij(inn,0)), 1)
3449 call write_iter_nl(out_coords)
3456 type(c_ptr),
intent(inout) :: file_handle
3457 type(grid_t),
intent(in) :: grid
3458 type(kpoints_t),
intent(in) :: kpoints
3459 type(states_elec_t),
intent(in) :: st
3460 integer,
intent(in) :: iter
3462 integer :: ik_ispin, ist
3463 character(len=7) :: nkpt_str, nst_str
3464 character(len=7) :: ik_str, ist_str
3465 real(real64),
allocatable :: norm_ks(:, :)
3466 real(real64) :: n_electrons
3470 safe_allocate(norm_ks(1:st%nst, 1:st%nik))
3471 call states_elec_calc_norms(grid, kpoints, st, norm_ks)
3473 if (mpi_world%is_root())
then
3476 call td_write_print_header_init(file_handle)
3479 write(nkpt_str,
'(I7)') st%nik
3480 write(nst_str,
'(I7)') st%nst
3481 call write_iter_string(file_handle,
'# Dimensions. (nstates, nkpt * nspin):')
3482 call write_iter_string(file_handle, trim(adjustl(nst_str)) //
' ' // trim(adjustl(nkpt_str)))
3483 call write_iter_nl(file_handle)
3486 call write_iter_string(file_handle,
'# Norm ordering: (istate, ikpoint_spin)')
3487 call write_iter_nl(file_handle)
3490 call write_iter_header_start(file_handle)
3491 call write_iter_header(file_handle,
'N_electrons')
3492 do ik_ispin = 1, st%nik
3494 write(ik_str,
'(I7)') ik_ispin
3495 write(ist_str,
'(I7)') ist
3496 call write_iter_header(file_handle, &
3497 'Norm (' // trim(ist_str) //
',' // trim(ik_str) //
')')
3500 call write_iter_nl(file_handle)
3501 call td_write_print_header_end(file_handle)
3504 n_electrons = sum(st%occ * norm_ks**2)
3507 call write_iter_start(file_handle)
3508 call write_iter_double(file_handle, n_electrons, 1)
3509 do ik_ispin = 1, st%nik
3510 call write_iter_double(file_handle, norm_ks(:, ik_ispin),
size(norm_ks, 1))
3512 call write_iter_nl(file_handle)
3516 safe_deallocate_a(norm_ks)
3525 type(c_ptr),
intent(inout) :: file_handle
3526 type(ions_t),
intent(in) :: ions
3527 integer,
intent(in) :: iter
3530 real(real64) :: tmp(3)
3532 if (.not. mpi_world%is_root())
return
3536 assert(ions%space%dim == 3)
3539 call td_write_print_header_init(file_handle)
3542 call write_iter_header_start(file_handle)
3544 call write_iter_string(file_handle,
'# Iter, a, b, c, volume, alpha, beta, gamma, ' &
3545 //
'a_x, a_y, a_z, b_x, b_y, b_z, c_x, c_y, c_z')
3548 call write_iter_string(file_handle,
'#[Iter n.]')
3549 call write_iter_header(file_handle,
'[' // trim(units_abbrev(units_out%time)) //
']')
3550 call write_iter_string(file_handle, &
3551 'Lengths in ' // trim(units_abbrev(units_out%length)) // &
3552 ', Volume in ' // trim(units_abbrev(units_out%length**3)) // &
3553 ', Angles in degree, Lattice vectors in '// trim(units_abbrev(units_out%length)))
3554 call write_iter_nl(file_handle)
3556 call td_write_print_header_end(file_handle)
3559 call write_iter_start(file_handle)
3563 tmp(idir) = units_from_atomic(units_out%length, norm2(ions%latt%rlattice(1:3, idir)))
3565 call write_iter_double(file_handle, tmp, 3)
3568 tmp(1) = units_from_atomic(units_out%length**3, ions%latt%rcell_volume)
3569 call write_iter_double(file_handle, tmp(1), 1)
3572 call write_iter_double(file_handle, ions%latt%alpha, 1)
3573 call write_iter_double(file_handle, ions%latt%beta, 1)
3574 call write_iter_double(file_handle, ions%latt%gamma, 1)
3578 tmp(1:3) = units_from_atomic(units_out%length, ions%latt%rlattice(:, idir))
3579 call write_iter_double(file_handle, tmp, 3)
3581 call write_iter_nl(file_handle)
3590 type(namespace_t),
intent(in) :: namespace
3591 integer,
intent(in) :: iter
3592 real(real64),
intent(in) :: dt
3594 integer :: default, flags, iout, first
3649 call parse_variable(namespace,
'MaxwellTDOutput', default, flags)
3651 if (.not. varinfo_valid_option(
'MaxwellTDOutput', flags, is_flag = .
true.))
then
3652 call messages_input_error(namespace,
'MaxwellTDOutput')
3656 writ%out(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
3657 if (writ%out(iout)%write)
then
3658 writ%out(iout + 1)%write = .
true.
3659 writ%out(iout + 2)%write = .
true.
3664 writ%out(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
3673 call io_mkdir(
'td.general', namespace)
3678 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_e_field_x", namespace)))
3680 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_e_field_y", namespace)))
3682 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_e_field_z", namespace)))
3688 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_b_field_x", namespace)))
3690 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_b_field_y", namespace)))
3692 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_b_field_z", namespace)))
3698 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_e_field_x", namespace)))
3700 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_e_field_y", namespace)))
3702 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_e_field_z", namespace)))
3708 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_b_field_x", namespace)))
3710 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_b_field_y", namespace)))
3712 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_b_field_z", namespace)))
3718 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_e_field_x", namespace)))
3720 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_e_field_y", namespace)))
3722 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_e_field_z", namespace)))
3728 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_b_field_x", namespace)))
3730 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_b_field_y", namespace)))
3732 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_b_field_z", namespace)))
3738 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/maxwell_energy", namespace)))
3743 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/electric_field_surface-x", namespace)))
3748 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/electric_field_surface-y", namespace)))
3753 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/electric_field_surface-z", namespace)))
3758 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/magnetic_field_surface-x", namespace)))
3763 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/magnetic_field_surface-y", namespace)))
3768 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/magnetic_field_surface-z", namespace)))
3784 if (writ%out(iout)%write)
call write_iter_end(writ%out(iout)%handle)
3792 subroutine td_write_mxll_iter(writ, space, gr, st, hm, helmholtz, dt, iter, namespace)
3794 class(space_t),
intent(in) :: space
3795 type(grid_t),
intent(inout) :: gr
3796 type(states_mxll_t),
intent(inout) :: st
3797 type(hamiltonian_mxll_t),
intent(inout) :: hm
3798 type(helmholtz_decomposition_t),
intent(inout) :: helmholtz
3799 real(real64),
intent(in) :: dt
3800 integer,
intent(in) :: iter
3801 type(namespace_t),
intent(in) :: namespace
3806 call profiling_in(
"TD_WRITE_ITER_MAXWELL")
3809 call helmholtz%get_trans_field(namespace, st%rs_state_trans, total_field=st%rs_state)
3810 call get_rs_state_at_point(st%selected_points_rs_state_trans(:,:), st%rs_state_trans, &
3811 st%selected_points_coordinate(:,:), st, gr)
3814 hm%energy%energy_trans = m_zero
3818 call helmholtz%get_long_field(namespace, st%rs_state_long, total_field=st%rs_state)
3819 call get_rs_state_at_point(st%selected_points_rs_state_long(:,:), st%rs_state_long, &
3820 st%selected_points_coordinate(:,:), st, gr)
3823 hm%energy%energy_long = m_zero
3915 call profiling_out(
"TD_WRITE_ITER_MAXWELL")
3924 type(hamiltonian_mxll_t),
intent(in) :: hm
3925 integer,
intent(in) :: iter
3929 integer :: n_columns
3931 if (.not. mpi_world%is_root())
return
3956 call write_iter_header(
out_maxwell_energy,
'[' // trim(units_abbrev(units_out%time)) //
']')
3958 do ii = 1, n_columns
3959 call write_iter_header(
out_maxwell_energy,
'[' // trim(units_abbrev(units_out%energy)) //
']')
3967 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy), 1)
3968 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%e_energy), 1)
3969 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%b_energy), 1)
3971 hm%energy%energy+hm%energy%boundaries), 1)
3972 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%boundaries), 1)
3973 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_trans), 1)
3974 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_long), 1)
3975 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_plane_waves), 1)
3984 type(c_ptr),
intent(inout) :: out_field_surf
3985 type(states_mxll_t),
intent(in) :: st
3986 integer,
intent(in) :: dim
3987 integer,
intent(in) :: iter
3991 integer :: n_columns
3993 if (.not. mpi_world%is_root())
return
4000 call td_write_print_header_init(out_field_surf)
4003 call write_iter_header_start(out_field_surf)
4004 call write_iter_header(out_field_surf,
'- x direction')
4005 call write_iter_header(out_field_surf,
'+ x direction')
4006 call write_iter_header(out_field_surf,
'- y direction')
4007 call write_iter_header(out_field_surf,
'+ y direction')
4008 call write_iter_header(out_field_surf,
'- z direction')
4009 call write_iter_header(out_field_surf,
'+ z direction')
4010 call write_iter_header(out_field_surf,
'- x dir. p. w.')
4011 call write_iter_header(out_field_surf,
'+ x dir. p. w.')
4012 call write_iter_header(out_field_surf,
'- y dir. p. w.')
4013 call write_iter_header(out_field_surf,
'+ y dir. p. w.')
4014 call write_iter_header(out_field_surf,
'- z dir. p. w.')
4015 call write_iter_header(out_field_surf,
'+ z dir. p. w.')
4017 call write_iter_nl(out_field_surf)
4020 call write_iter_string(out_field_surf,
'#[Iter n.]')
4021 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(units_out%time)) //
']')
4023 do ii = 1, n_columns
4024 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(units_out%energy/units_out%length)) //
']')
4026 call write_iter_nl(out_field_surf)
4028 call td_write_print_header_end(out_field_surf)
4031 call write_iter_start(out_field_surf)
4032 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
4033 st%electric_field_box_surface(1,1,dim)), 1)
4034 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
4035 st%electric_field_box_surface(2,1,dim)), 1)
4036 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
4037 st%electric_field_box_surface(1,2,dim)), 1)
4038 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
4039 st%electric_field_box_surface(2,2,dim)), 1)
4040 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
4041 st%electric_field_box_surface(1,3,dim)), 1)
4042 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
4043 st%electric_field_box_surface(2,3,dim)), 1)
4044 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
4045 st%electric_field_box_surface_plane_waves(1,1,dim)), 1)
4046 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
4047 st%electric_field_box_surface_plane_waves(2,1,dim)), 1)
4048 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
4049 st%electric_field_box_surface_plane_waves(1,2,dim)), 1)
4050 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
4051 st%electric_field_box_surface_plane_waves(2,2,dim)), 1)
4052 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
4053 st%electric_field_box_surface_plane_waves(1,3,dim)), 1)
4054 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
4055 st%electric_field_box_surface_plane_waves(2,3,dim)), 1)
4056 call write_iter_nl(out_field_surf)
4064 type(c_ptr),
intent(inout) :: out_field_surf
4065 type(states_mxll_t),
intent(in) :: st
4066 integer,
intent(in) :: dim
4067 integer,
intent(in) :: iter
4071 integer :: n_columns
4073 if (.not. mpi_world%is_root())
return
4080 call td_write_print_header_init(out_field_surf)
4083 call write_iter_header_start(out_field_surf)
4084 call write_iter_header(out_field_surf,
'- x direction')
4085 call write_iter_header(out_field_surf,
'+ x direction')
4086 call write_iter_header(out_field_surf,
'- y direction')
4087 call write_iter_header(out_field_surf,
'+ y direction')
4088 call write_iter_header(out_field_surf,
'- z direction')
4089 call write_iter_header(out_field_surf,
'+ z direction')
4090 call write_iter_header(out_field_surf,
'- x dir. p. w.')
4091 call write_iter_header(out_field_surf,
'+ x dir. p. w.')
4092 call write_iter_header(out_field_surf,
'- y dir. p. w.')
4093 call write_iter_header(out_field_surf,
'+ y dir. p. w.')
4094 call write_iter_header(out_field_surf,
'- z dir. p. w.')
4095 call write_iter_header(out_field_surf,
'+ z dir. p. w.')
4097 call write_iter_nl(out_field_surf)
4100 call write_iter_string(out_field_surf,
'#[Iter n.]')
4101 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(units_out%time)) //
']')
4103 do ii = 1, n_columns
4104 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(unit_one/units_out%length**2)) //
']')
4106 call write_iter_nl(out_field_surf)
4108 call td_write_print_header_end(out_field_surf)
4111 call write_iter_start(out_field_surf)
4112 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4113 st%magnetic_field_box_surface(1,1,dim)), 1)
4114 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4115 st%magnetic_field_box_surface(2,1,dim)), 1)
4116 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4117 st%magnetic_field_box_surface(1,2,dim)), 1)
4118 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4119 st%magnetic_field_box_surface(2,2,dim)), 1)
4120 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4121 st%magnetic_field_box_surface(1,3,dim)), 1)
4122 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4123 st%magnetic_field_box_surface(2,3,dim)), 1)
4124 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4125 st%magnetic_field_box_surface_plane_waves(1,1,dim)), 1)
4126 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4127 st%magnetic_field_box_surface_plane_waves(2,1,dim)), 1)
4128 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4129 st%magnetic_field_box_surface_plane_waves(1,2,dim)), 1)
4130 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4131 st%magnetic_field_box_surface_plane_waves(2,2,dim)), 1)
4132 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4133 st%magnetic_field_box_surface_plane_waves(1,3,dim)), 1)
4134 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4135 st%magnetic_field_box_surface_plane_waves(2,3,dim)), 1)
4136 call write_iter_nl(out_field_surf)
4142 subroutine td_write_fields(out_fields, space, st, iter, dt, e_or_b_field, field_type, idir)
4143 type(c_ptr),
intent(inout) :: out_fields
4144 class(space_t),
intent(in) :: space
4145 type(states_mxll_t),
intent(in) :: st
4146 integer,
intent(in) :: iter
4147 real(real64),
intent(in) :: dt
4148 integer,
intent(in) :: e_or_b_field
4149 integer,
intent(in) :: field_type
4150 integer,
intent(in) :: idir
4154 real(real64) :: field(space%dim), selected_field
4155 character(len=80) :: aux
4157 if (.not. mpi_world%is_root())
return
4162 call td_write_print_header_init(out_fields)
4165 write(aux,
'(a7,e20.12,3a)')
'# dt = ', units_from_atomic(units_out%time, dt), &
4166 " [", trim(units_abbrev(units_out%time)),
"]"
4167 call write_iter_string(out_fields, aux)
4168 call write_iter_nl(out_fields)
4170 call write_iter_header_start(out_fields)
4172 do id = 1, st%selected_points_number
4173 select case (e_or_b_field)
4175 write(aux,
'(a,i1,a)')
'E(', id,
')'
4177 write(aux,
'(a,i1,a)')
'B(', id,
')'
4179 call write_iter_header(out_fields, aux)
4182 call write_iter_nl(out_fields)
4183 call write_iter_string(out_fields,
'#[Iter n.]')
4184 call write_iter_header(out_fields,
' [' // trim(units_abbrev(units_out%time)) //
']')
4189 aux =
' [' // trim(units_abbrev(units_out%force)) //
']'
4190 do id = 1, st%selected_points_number
4191 call write_iter_header(out_fields, aux)
4193 call write_iter_nl(out_fields)
4194 call td_write_print_header_end(out_fields)
4197 call write_iter_start(out_fields)
4199 do id = 1, st%selected_points_number
4200 select case (e_or_b_field)
4203 select case (field_type)
4205 call get_electric_field_vector(st%selected_points_rs_state(:,id), field(1:st%dim))
4207 call get_electric_field_vector(st%selected_points_rs_state_long(:,id), field(1:st%dim))
4209 call get_electric_field_vector(st%selected_points_rs_state_trans(:,id), field(1:st%dim))
4211 selected_field = units_from_atomic(units_out%energy/units_out%length, field(idir))
4214 select case (field_type)
4216 call get_magnetic_field_vector(st%selected_points_rs_state(:,id), st%rs_sign, field(1:st%dim))
4218 call get_magnetic_field_vector(st%selected_points_rs_state_long(:,id), st%rs_sign, field(1:st%dim))
4220 call get_magnetic_field_vector(st%selected_points_rs_state_trans(:,id), st%rs_sign, field(1:st%dim))
4222 selected_field = units_from_atomic(unit_one/units_out%length**2, field(idir))
4224 call write_iter_double(out_fields, selected_field, 1)
4227 call write_iter_nl(out_fields)
4235 type(namespace_t),
intent(in) :: namespace
4236 class(space_t),
intent(in) :: space
4237 type(grid_t),
intent(inout) :: gr
4238 type(states_mxll_t),
intent(inout) :: st
4239 type(hamiltonian_mxll_t),
intent(inout) :: hm
4240 type(helmholtz_decomposition_t),
intent(inout) :: helmholtz
4241 type(output_t),
intent(in) :: outp
4242 integer,
intent(in) :: iter
4243 real(real64),
intent(in) :: time
4245 character(len=256) :: filename
4247 push_sub(td_write_maxwell_free_data)
4248 call profiling_in(
"TD_WRITE_MAXWELL_DATA")
4251 write(filename,
'(a,a,i7.7)') trim(outp%iter_dir),
"td.", iter
4253 call output_mxll(outp, namespace, space, gr, st, hm, helmholtz, time, filename)
4255 call profiling_out(
"TD_WRITE_MAXWELL_DATA")
4256 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)
integer, parameter, public out_ionic_current
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_ionic_current(out_ionic_current, space, ions, iter)
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)