48 use,
intrinsic :: iso_fortran_env
108 integer,
parameter,
public :: &
109 OUT_MULTIPOLES = 1, &
145 character(len=100) :: td_file_name(OUT_MAX) = [character(100) :: &
155 "magnetic_moments", &
170 "total_heat_current", &
171 "total_magnetization", &
173 "maxwell_dipole_field", &
174 "norm_wavefunctions"]
176 integer,
parameter :: &
177 OUT_DFTU_EFFECTIVE_U = 1, &
181 integer,
parameter :: &
182 OUT_MAXWELL_TOTAL_E_FIELD = 1, &
196 integer,
parameter,
public :: &
199 integer,
parameter :: &
200 MAXWELL_TOTAL_FIELD = 1, &
204 integer,
parameter :: &
210 type(c_ptr) :: handle
211 type(c_ptr),
allocatable :: mult_handles(:)
213 integer :: hand_start
215 logical :: write = .false.
216 logical :: resolve_states = .false.
228 real(real64) :: lmm_r
231 integer :: n_excited_states
233 integer :: compute_interval
240 subroutine td_write_kick(outp, namespace, space, mesh, kick, ions, iter)
244 class(
mesh_t),
intent(in) :: mesh
245 type(
kick_t),
intent(in) :: kick
246 type(
ions_t),
intent(in) :: ions
247 integer,
intent(in) :: iter
249 complex(real64),
allocatable :: kick_function(:)
250 character(len=256) :: filename
255 write(filename,
'(a,i7.7)')
"td.", iter
256 if (outp%what(option__output__delta_perturbation))
then
257 safe_allocate(kick_function(1:mesh%np))
259 call zio_function_output(outp%how(option__output__delta_perturbation), filename,
"kick_function", namespace, &
260 space, mesh, kick_function(:),
units_out%energy, err, pos=ions%pos, atoms=ions%atom)
261 safe_deallocate_a(kick_function)
277 subroutine td_write_init(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, ks, ions_move, &
278 with_gauge_field, kick, iter, max_iter, dt, mc)
282 type(
output_t),
intent(inout) :: outp
283 type(
grid_t),
intent(in) :: gr
286 type(
ions_t),
intent(in) :: ions
288 type(
v_ks_t),
intent(inout) :: ks
289 logical,
intent(in) :: ions_move
290 logical,
intent(in) :: with_gauge_field
291 type(
kick_t),
intent(in) :: kick
292 integer,
intent(in) :: iter
293 integer,
intent(in) :: max_iter
294 real(real64),
intent(in) :: dt
298 integer :: ierr, first, ii, ist, jj, flags, iout, default, ifile
303 character(len=MAX_PATH_LEN) :: filename
305 logical :: resolve_states
306 logical,
allocatable :: skip(:)
446 output_options = .false.
447 output_options(out_multipoles) = .
true.
462 writ%out(iout)%write = output_options(iout)
477 if (space%is_periodic() .and. writ%out(
out_angular)%write)
then
488 if (gr%np /= gr%np_global)
then
489 message(1) =
"TDOutput option td_kpoint_occup and td_floquet do not work with domain parallelization"
496 'Forces for systems periodic in 1D are not currently implemented and options that output the forces are not allowed.')
500 if (writ%out(
out_kp_proj)%write .and. hm%kpoints%nik_skip == 0)
then
501 message(1) =
"TDOutput option td_kpoint_occup only work with zero-weight k-points at the moment."
515 call parse_variable(namespace,
'TDOutputResolveStates', .false., resolve_states)
516 if (.not. writ%out(out_multipoles)%write)
then
517 write(
message(1),
'(a)')
"TDOutputResolveStates works only for TDOutput = multipoles."
530 if (writ%lmax < 0)
then
531 write(
message(1),
'(a,i6,a)')
"Input: '", writ%lmax,
"' is not a valid TDMultipoleLmax."
532 message(2) =
'(Must be TDMultipoleLmax >= 0 )'
538 if ((writ%out(
out_acc)%write) .and. ions_move)
then
539 message(1) =
'If harmonic spectrum is to be calculated, atoms should not be allowed to move.'
543 if ((writ%out(
out_q)%write) .and. .not.(ks%has_photons))
then
544 message(1) =
'If q(t) is to be calculated, you need to allow for photon modes.'
549 .or. hm%mxll%add_electric_dip))
then
550 message(1) =
'If the dipolar field has to be written, MaxwellCouplingMode has to be'
551 message(2) =
'"lenght_gauge_dipole" or "velocity_gauge_dipole" and at least one Maxwell system'
552 message(3) =
'must be present.'
556 rmin = ions%min_distance()
566 message(1) =
"Option TDOutput = populations is not implemented for parallel in states."
578 safe_deallocate_a(writ%gs_st%node)
586 writ%gs_st%st_end = writ%gs_st%nst
588 message(1) =
"Unable to read states information."
592 writ%gs_st%st_start = 1
608 call parse_variable(namespace,
'TDProjStateStart', 1, writ%gs_st%st_start)
610 if (st%parallel_in_states .and. writ%out(
out_proj)%write .and. writ%gs_st%st_start > 1)
then
616 writ%gs_st%lnst = writ%gs_st%st_end - writ%gs_st%st_start + 1
620 writ%gs_st%parallel_in_states = .false.
623 safe_allocate(writ%gs_st%occ(1:writ%gs_st%nst, 1:writ%gs_st%nik))
624 safe_allocate(writ%gs_st%eigenval(1:writ%gs_st%nst, 1:writ%gs_st%nik))
628 safe_allocate(writ%gs_st%node(1:writ%gs_st%nst))
629 writ%gs_st%node(:) = 0
631 writ%gs_st%eigenval = huge(writ%gs_st%eigenval)
633 if (writ%gs_st%d%ispin ==
spinors)
then
634 safe_deallocate_a(writ%gs_st%spin)
635 safe_allocate(writ%gs_st%spin(1:3, 1:writ%gs_st%nst, 1:writ%gs_st%nik))
638 safe_allocate(skip(1:writ%gs_st%nst))
640 skip(1:writ%gs_st%st_start-1) = .
true.
644 safe_deallocate_a(skip)
649 if (ierr /= 0 .and. ierr /= (writ%gs_st%st_end-writ%gs_st%st_start+1)*writ%gs_st%nik &
650 *writ%gs_st%d%dim*writ%gs_st%mpi_grp%size)
then
651 message(1) =
"Unable to read wavefunctions for TDOutput."
696 if (
parse_block(namespace,
'TDExcitedStatesToProject', blk) == 0)
then
698 safe_allocate(writ%excited_st(1:writ%n_excited_states))
699 do ist = 1, writ%n_excited_states
704 writ%n_excited_states = 0
718 call parse_variable(namespace,
'TDOutputComputeInterval', 50, writ%compute_interval)
719 if (writ%compute_interval < 0)
then
720 message(1) =
"TDOutputComputeInterval must be >= 0."
736 call io_mkdir(
'td.general', namespace)
747 do ifile = 1, out_max
751 if (writ%out(ifile)%write)
then
755 trim(
io_workpath(
"td.general/"//trim(td_file_name(ifile)), namespace)))
763 if (writ%out(out_multipoles)%write .and. .not. resolve_states)
then
766 trim(
io_workpath(
"td.general/multipoles", namespace)))
770 select case (kick%qkick_mode)
772 write(filename,
'(a)')
'td.general/ftchd.sin'
774 write(filename,
'(a)')
'td.general/ftchd.cos'
776 write(filename,
'(a, SP, I0.3, a, I0.3)')
'td.general/ftchd.l', kick%qbessel_l,
'_m', kick%qbessel_m
778 write(filename,
'(a)')
'td.general/ftchd'
790 call io_rm(
"td.general/laser", namespace=namespace)
807 if (writ%out(out_multipoles)%write .and. resolve_states)
then
809 writ%out(out_multipoles)%hand_start = st%st_start
810 writ%out(out_multipoles)%hand_end = st%st_end
811 writ%out(out_multipoles)%resolve_states = .
true.
812 writ%out(out_multipoles)%mpi_grp = gr%mpi_grp
814 safe_allocate(writ%out(out_multipoles)%mult_handles(st%st_start:st%st_end))
817 do ist = st%st_start, st%st_end
818 write(filename,
'(a,i4.4)')
'td.general/multipoles-ist', ist
831 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
832 calc_eigenval=.false., time = iter*dt, calc_energy = .false.)
835 if (writ%out(
out_n_ex)%write .and. writ%compute_interval > 0)
then
836 call io_mkdir(outp%iter_dir, namespace)
839 if (all(outp%how == 0) .and. writ%out(
out_n_ex)%write)
then
861 if (hm%lda_u_level ==
dft_u_acbn0) default = default + 2**(out_dftu_effective_u - 1)
869 writ%out_dftu(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
873 if (writ%out_dftu(out_dftu_effective_u)%write)
then
876 trim(
io_workpath(
"td.general/effectiveU", namespace)))
881 call writ%elec_me%init(gr, space, st)
897 if (writ%out(iout)%write)
then
899 if (writ%out(iout)%resolve_states)
then
900 do ist = writ%out(iout)%hand_start, writ%out(iout)%hand_end
903 safe_deallocate_a(writ%out(iout)%mult_handles)
913 if (writ%out_dftu(iout)%write)
call write_iter_end(writ%out_dftu(iout)%handle)
919 do ist = 1, writ%n_excited_states
922 writ%n_excited_states = 0
935 subroutine td_write_iter(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, kick, ks, dt, iter, mc, recalculate_gs)
938 class(
space_t),
intent(in) :: space
940 type(
grid_t),
intent(in) :: gr
943 type(
ions_t),
intent(inout) :: ions
945 type(
kick_t),
intent(in) :: kick
946 type(
v_ks_t),
intent(in) :: ks
947 real(real64),
intent(in) :: dt
948 integer,
intent(in) :: iter
950 logical,
intent(in) :: recalculate_gs
958 if (writ%out(out_multipoles)%write)
then
959 call td_write_multipole(writ%out(out_multipoles), space, gr, ions, st, writ%lmax, kick, iter)
982 if (writ%out(
out_proj)%write .and. mod(iter, writ%compute_interval) == 0)
then
991 if (writ%out(
out_kp_proj)%write .and. mod(iter, writ%compute_interval) == 0)
then
997 ions%pos, ions%vel, ions%tot_force, iter)
1002 ions%pos, ions%vel, ions%tot_force, iter, 1)
1007 ions%pos, ions%vel, ions%tot_force, iter, 2)
1012 ions%pos, ions%vel, ions%tot_force, iter, 3)
1023 if (writ%out(
out_acc)%write)
then
1024 call td_write_acc(writ%out(
out_acc)%handle, namespace, space, gr, ions, st, hm, ext_partners, dt, iter)
1027 if (writ%out(
out_vel)%write)
then
1040 if(
associated(gfield))
then
1066 if (writ%out(
out_n_ex)%write .and. mod(iter, writ%compute_interval) == 0)
then
1068 if (recalculate_gs)
then
1071 ierr, label =
': Houston states for TDOutput')
1075 call td_write_n_ex(writ%out(
out_n_ex)%handle, outp, namespace, gr, hm%kpoints, st, writ%gs_st, iter)
1083 if (writ%out_dftu(out_dftu_effective_u)%write)
then
1087 if (writ%out(
out_q)%write .and. ks%has_photons)
then
1091 if (writ%out(
out_mxll_field)%write .and. hm%mxll%calc_field_dip)
then
1108 do iout = 1, out_max
1110 if (writ%out(iout)%write)
then
1112 if (writ%out(iout)%resolve_states)
then
1113 do ii = writ%out(iout)%hand_start, writ%out(iout)%hand_end
1125 if (writ%out_dftu(iout)%write)
call write_iter_flush(writ%out_dftu(iout)%handle)
1134 subroutine td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, dt)
1137 type(
grid_t),
intent(in) :: gr
1140 type(
v_ks_t),
intent(inout) :: ks
1142 type(
ions_t),
intent(in) :: ions
1144 integer,
intent(in) :: iter
1145 real(real64),
optional,
intent(in) :: dt
1147 character(len=256) :: filename
1153 if (st%modelmbparticles%nparticle > 0)
then
1158 write(filename,
'(a,a,i7.7)') trim(outp%iter_dir),
"td.", iter
1160 call output_all(outp, namespace, space, filename, gr, ions, iter, st, hm, ks)
1162 call output_modelmb(outp, namespace, space, filename, gr, ions, iter, st)
1164 if (
present(dt))
then
1165 call output_scalar_pot(outp, namespace, space, filename, gr, ions, ext_partners, iter*dt)
1167 if (iter == 0)
call output_scalar_pot(outp, namespace, space, filename, gr, ions, ext_partners)
1176 type(c_ptr),
intent(inout) ::
out_spin
1177 class(
mesh_t),
intent(in) :: mesh
1179 integer,
intent(in) :: iter
1181 character(len=130) :: aux
1182 real(real64) :: spin(3)
1198 if (st%d%ispin ==
spinors)
then
1199 write(aux,
'(a2,18x)')
'Sx'
1201 write(aux,
'(a2,18x)')
'Sy'
1204 write(aux,
'(a2,18x)')
'Sz'
1212 select case (st%d%ispin)
1229 type(
grid_t),
intent(in) :: gr
1231 type(
ions_t),
intent(in) :: ions
1232 real(real64),
intent(in) :: lmm_r
1233 integer,
intent(in) :: iter
1236 character(len=50) :: aux
1237 real(real64),
allocatable :: lmm(:,:)
1242 safe_allocate(lmm(1:3, 1:ions%natoms))
1252 do ia = 1, ions%natoms
1253 if (st%d%ispin ==
spinors)
then
1254 write(aux,
'(a2,i2.2,16x)')
'mx', ia
1256 write(aux,
'(a2,i2.2,16x)')
'my', ia
1259 write(aux,
'(a2,i2.2,16x)')
'mz', ia
1268 do ia = 1, ions%natoms
1269 select case (st%d%ispin)
1277 safe_deallocate_a(lmm)
1285 type(c_ptr),
intent(inout) :: out_magnets
1286 class(
mesh_t),
intent(in) :: mesh
1288 type(
kick_t),
intent(in) :: kick
1289 integer,
intent(in) :: iter
1291 complex(real64),
allocatable :: tm(:,:)
1296 safe_allocate(tm(1:6,1:kick%nqvec))
1298 do iq = 1, kick%nqvec
1328 do iq = 1, kick%nqvec
1337 safe_deallocate_a(tm)
1351 subroutine td_write_angular(out_angular, namespace, space, gr, ions, hm, st, kick, iter)
1352 type(c_ptr),
intent(inout) :: out_angular
1354 class(
space_t),
intent(in) :: space
1355 type(
grid_t),
intent(in) :: gr
1356 type(
ions_t),
intent(inout) :: ions
1359 type(
kick_t),
intent(in) :: kick
1360 integer,
intent(in) :: iter
1363 character(len=130) :: aux
1364 real(real64) :: angular(3)
1371 call angular_momentum%setup_dir(idir)
1374 m_two*real(angular_momentum%zstates_elec_expectation_value(namespace, space, gr, hm, st), real64)
1376 safe_deallocate_p(angular_momentum)
1383 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
1391 write(aux,
'(a4,18x)')
'<Lx>'
1393 write(aux,
'(a4,18x)')
'<Ly>'
1395 write(aux,
'(a4,18x)')
'<Lz>'
1424 class(
space_t),
intent(in) :: space
1425 type(
grid_t),
intent(in) :: gr
1426 type(
ions_t),
intent(in) :: ions
1428 integer,
intent(in) :: lmax
1429 type(
kick_t),
intent(in) :: kick
1430 integer,
intent(in) :: iter
1433 real(real64),
allocatable :: rho(:,:)
1437 if (out_multip%resolve_states)
then
1438 safe_allocate(rho(1:gr%np_part, 1:st%d%nspin))
1441 do ist = st%st_start, st%st_end
1443 call td_write_multipole_r(out_multip%mult_handles(ist), space, gr, ions, st, lmax, kick, rho, iter, &
1444 mpi_grp = out_multip%mpi_grp)
1447 safe_deallocate_a(rho)
1450 if (
allocated(st%frozen_rho))
then
1451 safe_allocate(rho(1:gr%np, 1:st%d%nspin))
1452 call lalg_copy(gr%np, st%d%nspin, st%rho, rho)
1457 safe_deallocate_a(rho)
1469 subroutine td_write_multipole_r(out_multip, space, mesh, ions, st, lmax, kick, rho, iter, mpi_grp)
1470 type(c_ptr),
intent(inout) :: out_multip
1471 class(
space_t),
intent(in) :: space
1472 class(
mesh_t),
intent(in) :: mesh
1473 type(
ions_t),
intent(in) :: ions
1475 integer,
intent(in) :: lmax
1476 type(
kick_t),
intent(in) :: kick
1477 real(real64),
intent(in) :: rho(:,:)
1478 integer,
intent(in) :: iter
1479 type(
mpi_grp_t),
optional,
intent(in) :: mpi_grp
1482 integer :: is, idir, ll, mm, add_lm
1483 character(len=120) :: aux
1484 real(real64) :: ionic_dipole(ions%space%dim)
1485 real(real64),
allocatable :: multipole(:,:)
1491 assert(.not. (lmax > 1 .and. space%dim > 3))
1494 if (
present(mpi_grp)) mpi_grp_ = mpi_grp
1499 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
1503 write(aux,
'(a15,i2)')
'# lmax ', lmax
1511 do is = 1, st%d%nspin
1512 write(aux,
'(a18,i1,a1)')
'Electronic charge(', is,
')'
1515 do idir = 1, space%dim
1516 write(aux,
'(4a1,i1,a1)')
'<',
index2axis(idir),
'>',
'(', is,
')'
1522 write(aux,
'(a2,i2,a4,i2,a2,i1,a1)')
'l=', ll,
', m=', mm,
' (', is,
')'
1533 do is = 1, st%d%nspin
1536 do idir = 1, space%dim
1552 if (space%dim > 3 .and. lmax == 1)
then
1554 safe_allocate(multipole(1:space%dim+1, 1:st%d%nspin))
1556 safe_allocate(multipole(1:(lmax + 1)**2, 1:st%d%nspin))
1560 do is = 1, st%d%nspin
1565 ionic_dipole = ions%dipole()
1566 do is = 1, st%d%nspin
1567 multipole(2:space%dim+1, is) = -ionic_dipole(1:space%dim)/st%d%nspin - multipole(2:space%dim+1, is)
1573 do is = 1, st%d%nspin
1576 do idir = 1, space%dim
1580 add_lm = space%dim + 2
1591 safe_deallocate_a(multipole)
1596 subroutine td_write_ftchd(out_ftchd, space, mesh, st, kick, iter)
1597 type(c_ptr),
intent(inout) :: out_ftchd
1598 class(
space_t),
intent(in) :: space
1599 class(
mesh_t),
intent(in) :: mesh
1601 type(
kick_t),
intent(in) :: kick
1602 integer,
intent(in) :: iter
1604 integer :: is, ip, idir
1605 character(len=120) :: aux, aux2
1606 real(real64) :: ftchd_bessel
1607 complex(real64) :: ftchd
1609 real(real64),
allocatable :: integrand_bessel(:)
1610 complex(real64),
allocatable :: integrand(:)
1617 write(aux,
'(a15, i2)')
'# qkickmode ', kick%qkick_mode
1622 write(aux,
'(a15, i0.3, 1x, i0.3)')
'# ll, mm ', kick%qbessel_l, kick%qbessel_m
1628 write(aux,
'(a15, f9.6)')
'# qlength ', kick%qlength
1630 write(aux,
'(a15)')
'# qvector '
1631 do idir = 1, space%dim
1632 write(aux2,
'(f9.5)') kick%qvector(idir,1)
1633 aux = trim(aux) // trim(aux2)
1639 write(aux,
'(a15,f18.12)')
'# kick strength', kick%delta_strength
1645 write(aux,
'(a17)')
'int(j_l*Y_lm*rho)'
1647 write(aux,
'(a12)')
'Real, Imag'
1664 safe_allocate(integrand(1:mesh%np))
1666 do is = 1, st%d%nspin
1668 integrand(ip) = integrand(ip) + st%rho(ip, is) *
exp(-
m_zi*sum(mesh%x(ip, 1:space%dim)*kick%qvector(1:space%dim, 1)))
1672 safe_deallocate_a(integrand)
1675 safe_allocate(integrand_bessel(1:mesh%np))
1676 integrand_bessel =
m_zero
1677 do is = 1, st%d%nspin
1679 call ylmr_real(mesh%x(ip, 1:3), kick%qbessel_l, kick%qbessel_m, ylm)
1680 integrand_bessel(ip) = integrand_bessel(ip) + st%rho(ip, is) * &
1681 loct_sph_bessel(kick%qbessel_l, kick%qlength*norm2(mesh%x(ip, :)))*ylm
1685 safe_deallocate_a(integrand_bessel)
1704 type(c_ptr),
intent(inout) :: out_temperature
1705 type(
ions_t),
intent(in) :: ions
1706 integer,
intent(in) :: iter
1741 type(c_ptr),
intent(inout) :: out_populations
1743 class(
space_t),
intent(in) :: space
1744 class(
mesh_t),
intent(in) :: mesh
1747 real(real64),
intent(in) :: dt
1748 integer,
intent(in) :: iter
1751 character(len=6) :: excited_name
1752 complex(real64) :: gsp
1753 complex(real64),
allocatable :: excited_state_p(:)
1754 complex(real64),
allocatable :: dotprodmatrix(:, :, :)
1759 safe_allocate(dotprodmatrix(1:writ%gs_st%nst, 1:st%nst, 1:st%nik))
1764 assert(.not. space%is_periodic())
1769 if (writ%n_excited_states > 0)
then
1770 safe_allocate(excited_state_p(1:writ%n_excited_states))
1771 do ist = 1, writ%n_excited_states
1772 excited_state_p(ist) =
zstates_elec_mpdotp(namespace, mesh, writ%excited_st(ist), st, dotprodmatrix)
1784 do ist = 1, writ%n_excited_states
1785 write(excited_name,
'(a2,i3,a1)')
'P(', ist,
')'
1804 do ist = 1, writ%n_excited_states
1811 if (writ%n_excited_states > 0)
then
1812 safe_deallocate_a(excited_state_p)
1814 safe_deallocate_a(dotprodmatrix)
1820 subroutine td_write_acc(out_acc, namespace, space, gr, ions, st, hm, ext_partners, dt, iter)
1821 type(c_ptr),
intent(inout) :: out_acc
1823 class(
space_t),
intent(in) :: space
1824 type(
grid_t),
intent(in) :: gr
1825 type(
ions_t),
intent(inout) :: ions
1829 real(real64),
intent(in) :: dt
1830 integer,
intent(in) :: iter
1833 character(len=7) :: aux
1834 real(real64) :: acc(space%dim)
1843 do idim = 1, space%dim
1844 write(aux,
'(a4,i1,a1)')
'Acc(', idim,
')'
1852 do idim = 1, space%dim
1859 call td_calc_tacc(namespace, space, gr, ions, ext_partners, st, hm, acc, dt*iter)
1872 subroutine td_write_vel(out_vel, elec_me, kpoints, iter)
1873 type(c_ptr),
intent(inout) :: out_vel
1876 integer,
intent(in) :: iter
1879 character(len=7) :: aux
1880 real(real64) :: vel(elec_me%space%dim)
1889 do idim = 1, elec_me%space%dim
1890 write(aux,
'(a4,i1,a1)')
'Vel(', idim,
')'
1898 do idim = 1, elec_me%space%dim
1920 type(c_ptr),
intent(inout) :: out_laser
1921 class(
space_t),
intent(in) :: space
1922 type(
lasers_t),
intent(inout) :: lasers
1923 real(real64),
intent(in) :: dt
1924 integer,
intent(in) :: iter
1927 real(real64) :: field(space%dim)
1928 real(real64) :: ndfield(space%dim)
1929 character(len=80) :: aux
1945 do il = 1, lasers%no_lasers
1948 do idir = 1, space%dim
1949 write(aux,
'(a,i1,a)')
'E(', idir,
')'
1953 do idir = 1, space%dim
1954 write(aux,
'(a,i1,a)')
'B(', idir,
')'
1958 do idir = 1, space%dim
1959 write(aux,
'(a,i1,a)')
'A(', idir,
')'
1963 write(aux,
'(a,i1,a)')
'e(t)'
1969 do idir = 1, space%dim
1970 write(aux,
'(a,i1,a)')
'A^M(', idir,
')'
1982 do il = 1, lasers%no_lasers
1986 do idir = 1, space%dim
1991 do idir = 1, space%dim
2002 do idir = 1, space%dim
2015 do il = 1, lasers%no_lasers
2017 call laser_field(lasers%lasers(il), field(1:space%dim), iter*dt)
2042 type(c_ptr),
intent(inout) :: out_energy
2044 integer,
intent(in) :: iter
2045 real(real64),
intent(in) :: ke
2049 integer :: n_columns
2072 if (hm%pcm%run_pcm)
then
2074 n_columns = n_columns + 1
2079 n_columns = n_columns + 1
2089 do ii = 1, n_columns
2112 hm%energy%int_nn_pcm + hm%energy%int_ne_pcm), 1)
2125 type(c_ptr),
intent(inout) :: out_eigs
2127 integer,
intent(in) :: iter
2130 character(len=68) :: buf
2143 write(buf,
'(a15,i2)')
'# nst ', st%nst
2147 write(buf,
'(a15,i2)')
'# nspin ', st%d%nspin
2153 do is = 1, st%d%kpt%nglobal
2155 write(buf,
'(a,i4)')
'Eigenvalue ',ii
2164 do is = 1, st%d%kpt%nglobal
2174 do is = 1, st%d%kpt%nglobal
2186 type(c_ptr),
intent(inout) :: out_ionch
2187 class(
mesh_t),
intent(in) :: mesh
2189 integer,
intent(in) :: iter
2191 integer :: ii, ist, Nch, ik, idim
2192 character(len=68) :: buf
2193 real(real64),
allocatable :: ch(:), occ(:)
2194 real(real64),
allocatable :: occbuf(:)
2199 nch = st%nst * st%d%kpt%nglobal * st%d%dim
2200 safe_allocate(ch(0: nch))
2201 safe_allocate(occ(0: nch))
2207 do idim = 1, st%d%dim
2208 if (st%st_start <= ist .and. ist <= st%st_end .and. &
2209 st%d%kpt%start <= ik .and. ik <= st%d%kpt%end)
then
2210 occ(ii) = st%occ(ist, ik)
2218 if (st%parallel_in_states)
then
2219 safe_allocate(occbuf(0: nch))
2221 call st%mpi_grp%allreduce(occ(0), occbuf(0), nch+1, mpi_double_precision, mpi_sum)
2223 safe_deallocate_a(occbuf)
2231 safe_deallocate_a(ch)
2244 if (occ(ii)>
m_zero .or. ii == 0)
then
2245 write(buf,
'(a,f4.1,a)')
'Pion(',occ(ii)*ii,
'+, t)'
2255 if (occ(ii)>
m_zero .or. ii == 0)
then
2265 if (occ(ii)>
m_zero .or. ii == 0)
then
2271 safe_deallocate_a(ch)
2272 safe_deallocate_a(occ)
2279 type(c_ptr),
intent(inout) :: out_proj
2280 class(
space_t),
intent(in) :: space
2281 class(
mesh_t),
intent(in) :: mesh
2282 type(
ions_t),
intent(in) :: ions
2285 type(
kick_t),
intent(in) :: kick
2286 integer,
intent(in) :: iter
2288 complex(real64),
allocatable :: projections(:,:,:)
2289 character(len=80) :: aux
2290 integer :: ik, ist, uist, idir
2298 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
2307 write(aux,
'(a,i8)')
"# nik ", st%nik
2311 write(aux,
'(a,2i8)')
"# st ", gs_st%st_start, st%nst
2315 write(aux,
'(a,2i8)')
"# ust ", gs_st%st_start, gs_st%st_end
2321 do ist = gs_st%st_start, st%nst
2329 do ist = gs_st%st_start, st%nst
2330 do uist = gs_st%st_start, gs_st%st_end
2331 write(aux,
'(i4,a,i4)') ist,
' -> ', uist
2342 if (.not. space%is_periodic())
then
2344 safe_allocate(projections(1:st%nst, gs_st%st_start:gs_st%st_end, 1:st%nik))
2345 do idir = 1, space%dim
2351 write(aux,
'(a,i1,a)')
"<i|x_", idir,
"|a>"
2355 do ist = gs_st%st_start, st%st_end
2356 do uist = gs_st%st_start, gs_st%st_end
2366 safe_deallocate_a(projections)
2376 safe_allocate(projections(1:st%nst, gs_st%st_start:gs_st%st_end, 1:st%nik))
2377 projections(:,:,:) =
m_z0
2383 do ist = gs_st%st_start, st%nst
2384 do uist = gs_st%st_start, gs_st%st_end
2393 safe_deallocate_a(projections)
2399 integer,
intent(in) :: dir
2401 integer :: uist, ist, ik, idim
2402 real(real64) :: n_dip(space%dim)
2403 complex(real64),
allocatable :: xpsi(:,:)
2404 complex(real64),
allocatable :: psi(:, :), gspsi(:, :)
2408 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
2409 safe_allocate(gspsi(1:mesh%np, 1:st%d%dim))
2410 safe_allocate(xpsi(1:mesh%np, 1:st%d%dim))
2412 do ik = st%d%kpt%start, st%d%kpt%end
2413 do ist = st%st_start, st%st_end
2415 do uist = gs_st%st_start, gs_st%st_end
2418 do idim = 1, st%d%dim
2419 xpsi(1:mesh%np, idim) = mesh%x(1:mesh%np, dir)*gspsi(1:mesh%np, idim)
2421 projections(ist, uist, ik) = -
zmf_dotp(mesh, st%d%dim, psi, xpsi, reduce = .false.)
2427 safe_deallocate_a(xpsi)
2428 safe_deallocate_a(gspsi)
2429 safe_deallocate_a(psi)
2434 n_dip = ions%dipole()
2436 do ist = gs_st%st_start, st%nst
2437 do uist = gs_st%st_start, gs_st%st_end
2438 projections(ist, uist, ik) = projections(ist, uist, ik) - n_dip(dir)
2454 subroutine td_write_n_ex(out_nex, outp, namespace, mesh, kpoints, st, gs_st, iter)
2455 type(c_ptr),
intent(inout) :: out_nex
2458 class(
mesh_t),
intent(in) :: mesh
2462 integer,
intent(in) :: iter
2464 complex(real64),
allocatable :: projections(:,:)
2465 character(len=80) :: aux, dir
2466 integer :: ik, ikpt, ist, uist, err
2467 real(real64) :: Nex, weight
2469 real(real64),
allocatable :: Nex_kpt(:)
2478 write(aux,
'(a15,i2)')
'# nspin ', st%d%nspin
2485 write(aux,
'(a,i8)')
"# nik ", st%nik
2489 write(aux,
'(a,2i8)')
"# st ", gs_st%st_start, st%nst
2493 write(aux,
'(a,2i8)')
"# ust ", gs_st%st_start, gs_st%st_end
2510 if (.not. st%parallel_in_states)
then
2511 do ik = st%d%kpt%start, st%d%kpt%end
2512 do ist = 1, gs_st%nst
2513 if (gs_st%occ(ist, ik) >
m_min_occ) gs_nst = ist
2520 safe_allocate(projections(1:gs_nst, 1:st%nst))
2522 safe_allocate(nex_kpt(1:st%nik))
2524 do ik = st%d%kpt%start, st%d%kpt%end
2525 ikpt = st%d%get_kpoint_index(ik)
2528 weight = st%kweights(ik) * gs_st%occ(ist, ik)/ st%smear%el_per_state
2529 do uist = st%st_start, st%st_end
2530 nex_kpt(ikpt) = nex_kpt(ikpt) - weight * st%occ(uist, ik) * abs(projections(ist, uist))**2
2534 nex_kpt(ikpt) = nex_kpt(ikpt) + sum(st%occ(st%st_start:st%st_end, ik))*
m_half*st%kweights(ik)
2536 nex_kpt(ikpt) = nex_kpt(ikpt) + sum(st%occ(st%st_start:st%st_end, ik))*st%kweights(ik)
2540 if (st%parallel_in_states .or. st%d%kpt%parallel)
then
2552 write(dir,
'(a,a,i7.7)') trim(outp%iter_dir),
"td.", iter
2555 + outp%how(option__output__density_kpt), dir,
"n_excited_el_kpt", namespace, &
2559 safe_deallocate_a(projections)
2560 safe_deallocate_a(nex_kpt)
2572 class(
mesh_t),
intent(in) :: mesh
2575 complex(real64),
intent(inout) :: projections(1:st%nst, gs_st%st_start:gs_st%nst, 1:st%nik)
2577 integer :: uist, ist, ik
2578 complex(real64),
allocatable :: psi(:, :), gspsi(:, :)
2581 safe_allocate(psi(1:mesh%np, 1:st%d%dim))
2582 safe_allocate(gspsi(1:mesh%np, 1:st%d%dim))
2584 projections(:,:,:) =
m_zero
2586 do ik = st%d%kpt%start, st%d%kpt%end
2587 do ist = st%st_start, st%st_end
2589 do uist = gs_st%st_start, gs_st%nst
2591 projections(ist, uist, ik) =
zmf_dotp(mesh, st%d%dim, psi, gspsi, reduce = .false.)
2596 safe_deallocate_a(psi)
2597 safe_deallocate_a(gspsi)
2606 class(
mesh_t),
intent(in) :: mesh
2611 integer,
intent(in) :: iter
2613 complex(real64),
allocatable :: proj(:,:), psi(:,:,:), gs_psi(:,:,:), temp_state(:,:)
2614 character(len=80) :: filename1, filename2
2615 integer :: ik,ist, jst, file, idim, nk_proj
2619 write(filename1,
'(I10)') iter
2620 filename1 =
'td.general/projections_iter_'//trim(adjustl(filename1))
2623 safe_allocate(proj(1:gs_st%nst, 1:gs_st%nst))
2624 safe_allocate(psi(1:gs_st%nst,1:gs_st%d%dim,1:mesh%np))
2625 safe_allocate(gs_psi(1:gs_st%nst,1:gs_st%d%dim,1:mesh%np))
2626 safe_allocate(temp_state(1:mesh%np,1:gs_st%d%dim))
2632 nk_proj = kpoints%nik_skip
2634 do ik = kpoints%reduced%npoints-nk_proj+1, kpoints%reduced%npoints
2636 psi(1:gs_st%nst, 1:gs_st%d%dim, 1:mesh%np)=
m_zero
2637 gs_psi(1:gs_st%nst, 1:gs_st%d%dim, 1:mesh%np)=
m_zero
2640 write(filename2,
'(I10)') ik
2641 filename2 = trim(adjustl(filename1))//
'_ik_'//trim(adjustl(filename2))
2642 file =
io_open(filename2, namespace, action=
'write')
2645 do ist=gs_st%st_start,gs_st%st_end
2648 do idim = 1,gs_st%d%dim
2649 psi(ist,idim,1:mesh%np) = temp_state(1:mesh%np,idim)
2652 do idim = 1,gs_st%d%dim
2653 gs_psi(ist,idim,1:mesh%np) = temp_state(1:mesh%np,idim)
2662 assert(mesh%np_global*gs_st%d%dim < huge(0_int32))
2663 proj(1:gs_st%nst, 1:gs_st%nst) =
m_zero
2668 i8_to_i4(mesh%np_global*gs_st%d%dim), &
2669 cmplx(mesh%volume_element,
m_zero, real64) , &
2671 ubound(psi, dim = 1), &
2673 ubound(gs_psi, dim = 1), &
2676 ubound(proj, dim = 1))
2680 do ist = 1, gs_st%nst
2681 do jst = 1, gs_st%nst
2682 write(file,
'(I3,1x,I3,1x,e13.6,1x,e13.6,2x)') ist, jst, proj(ist,jst)
2690 safe_deallocate_a(proj)
2691 safe_deallocate_a(psi)
2692 safe_deallocate_a(gs_psi)
2693 safe_deallocate_a(temp_state)
2699 subroutine td_write_floquet(namespace, space, hm, ext_partners, mesh, st, iter)
2700 type(namespace_t),
intent(in) :: namespace
2701 class(space_t),
intent(in) :: space
2702 type(hamiltonian_elec_t),
intent(inout) :: hm
2703 type(partner_list_t),
intent(in) :: ext_partners
2704 class(mesh_t),
intent(in) :: mesh
2705 type(states_elec_t),
intent(inout) :: st
2706 integer,
intent(in) :: iter
2708 complex(real64),
allocatable :: hmss(:,:), psi(:,:,:), hpsi(:,:,:), temp_state1(:,:)
2709 complex(real64),
allocatable :: HFloquet(:,:,:), HFloq_eff(:,:), temp(:,:)
2710 real(real64),
allocatable :: eigenval(:), bands(:,:)
2711 character(len=80) :: filename
2712 integer :: it, nT, ik, ist, in, im, file, idim, nik, ik_count
2713 integer :: Forder, Fdim, m0, n0, n1, nst, ii, jj, lim_nst
2714 logical :: downfolding
2715 type(states_elec_t) :: hm_st
2717 real(real64) :: dt, Tcycle, omega
2721 downfolding = .false.
2724 if (.not. iter == 0)
then
2732 assert(mesh%np == mesh%np_global)
2735 call states_elec_copy(hm_st, st)
2746 call parse_variable(namespace,
'TDFloquetFrequency', m_zero, omega, units_inp%energy)
2747 call messages_print_var_value(
'Frequency used for Floquet analysis', omega, namespace=namespace)
2748 if (abs(omega) <= m_epsilon)
then
2749 message(1) =
"Please give a non-zero value for TDFloquetFrequency"
2750 call messages_fatal(1, namespace=namespace)
2754 tcycle = m_two * m_pi / omega
2764 call parse_variable(namespace,
'TDFloquetSample',20 ,nt)
2765 call messages_print_var_value(
'Number of Floquet time-sampling points', nt, namespace=namespace)
2766 dt = tcycle/real(nt, real64)
2775 call parse_variable(namespace,
'TDFloquetDimension',-1,forder)
2776 if (forder .ge. 0)
then
2777 call messages_print_var_value(
'Order of multiphoton Floquet-Hamiltonian', forder, namespace=namespace)
2779 fdim = 2 * forder + 1
2781 message(1) =
'Floquet-Hamiltonian is downfolded'
2782 call messages_info(1, namespace=namespace)
2783 downfolding = .
true.
2788 dt = tcycle/real(nt, real64)
2791 nik = hm%kpoints%nik_skip
2793 safe_allocate(hmss(1:nst,1:nst))
2794 safe_allocate( psi(1:nst,1:st%d%dim,1:mesh%np))
2795 safe_allocate(hpsi(1:nst,1:st%d%dim,1:mesh%np))
2796 safe_allocate(temp_state1(1:mesh%np,1:st%d%dim))
2804 safe_allocate(hfloquet(1:nik,1:nst*fdim, 1:nst*fdim))
2805 hfloquet(1:nik,1:nst*fdim, 1:nst*fdim) = m_zero
2810 call hm%update(mesh, namespace, space, ext_partners, time=tcycle+it*dt)
2812 call zhamiltonian_elec_apply_all(hm, namespace, mesh, st, hm_st)
2817 do ik = hm%kpoints%reduced%npoints-nik+1, hm%kpoints%reduced%npoints
2818 ik_count = ik_count + 1
2820 psi(1:nst, 1:st%d%dim, 1:mesh%np)= m_zero
2821 hpsi(1:nst, 1:st%d%dim, 1:mesh%np)= m_zero
2823 do ist = st%st_start, st%st_end
2824 if (state_kpt_is_local(st, ist, ik))
then
2825 call states_elec_get_state(st, mesh, ist, ik,temp_state1)
2826 do idim = 1, st%d%dim
2827 psi(ist, idim, 1:mesh%np) = temp_state1(1:mesh%np,idim)
2829 call states_elec_get_state(hm_st, mesh, ist, ik,temp_state1)
2830 do idim = 1, st%d%dim
2831 hpsi(ist, idim,1:mesh%np) = temp_state1(1:mesh%np,idim)
2835 call comm_allreduce(mpi_world, psi)
2836 call comm_allreduce(mpi_world, hpsi)
2837 assert(mesh%np_global*st%d%dim < huge(0_int32))
2838 hmss(1:nst,1:nst) = m_zero
2843 i8_to_i4(mesh%np_global*st%d%dim), &
2844 cmplx(mesh%volume_element, m_zero, real64) , &
2846 ubound(hpsi, dim = 1), &
2848 ubound(psi, dim = 1), &
2851 ubound(hmss, dim = 1))
2853 hmss(1:nst,1:nst) = conjg(hmss(1:nst,1:nst))
2856 do in = -forder, forder
2857 do im = -forder, forder
2858 ii = (in+forder) * nst
2859 jj = (im+forder) * nst
2860 hfloquet(ik_count, ii+1:ii+nst, jj+1:jj+nst) = &
2861 hfloquet(ik_count, ii+1:ii+nst, jj+1:jj+nst) + hmss(1:nst, 1:nst) *
exp(-(in-im)*m_zi*omega*it*dt)
2865 hfloquet(ik_count, ii+ist, ii+ist) = hfloquet(ik_count, ii+ist, ii+ist) + in*omega
2874 hfloquet(:,:,:) = m_one/nt*hfloquet(:,:,:)
2877 if (downfolding)
then
2879 safe_allocate(hfloq_eff(1:nst,1:nst))
2880 safe_allocate(eigenval(1:nst))
2881 safe_allocate(bands(1:nik,1:nst))
2883 hfloq_eff(1:nst,1:nst) = m_zero
2889 hfloq_eff(1:nst, 1:nst) = hfloquet(ik, n0+1:n0+nst, m0+1:m0+nst) + &
2890 m_one/omega*(matmul(hfloquet(ik, 1:nst, m0+1:m0+nst), hfloquet(ik, n1+1:n1+nst, m0+1:m0+nst))- &
2891 matmul(hfloquet(ik, n1+1:n1+nst, m0+1:m0+nst), hfloquet(ik, 1:nst, m0+1:m0+nst)))
2893 call lalg_eigensolve(nst, hfloq_eff, eigenval)
2894 bands(ik,1:nst) = eigenval(1:nst)
2896 safe_deallocate_a(hfloq_eff)
2899 safe_allocate(eigenval(1:nst*fdim))
2900 safe_allocate(bands(1:nik,1:nst*fdim))
2901 safe_allocate(temp(1:nst*fdim, 1:nst*fdim))
2904 temp(1:nst*fdim, 1:nst*fdim) = hfloquet(ik, 1:nst*fdim, 1:nst*fdim)
2905 call lalg_eigensolve(nst*fdim, temp, eigenval)
2906 bands(ik, 1:nst*fdim) = eigenval(1:nst*fdim)
2911 if (downfolding)
then
2913 filename =
"downfolded_floquet_bands"
2916 filename =
"floquet_bands"
2919 if (mpi_world%rank == 0)
then
2921 file = io_open(filename, namespace, action =
'write')
2924 write(file,
'(e13.6, 1x)',advance=
'no') bands(ik,ist)
2931 if (.not. downfolding)
then
2934 bands(1:nik, 1:nst*fdim) = m_zero
2936 temp(1:nst*fdim,1:nst*fdim) = m_zero
2939 temp(ii+1:ii+nst, ii+1:ii+nst) = hfloquet(ik, ii+1:ii+nst, ii+1:ii+nst)
2941 call lalg_eigensolve(nst*fdim, temp, eigenval)
2942 bands(ik, 1:nst*fdim) = eigenval(1:nst*fdim)
2945 if (mpi_world%rank == 0)
then
2946 filename =
'trivial_floquet_bands'
2947 file = io_open(filename, namespace, action =
'write')
2950 write(file,
'(e13.6, 1x)', advance=
'no') bands(ik,ist)
2959 call hm%update(mesh, namespace, space, ext_partners, time=m_zero)
2961 safe_deallocate_a(hmss)
2962 safe_deallocate_a(psi)
2963 safe_deallocate_a(hpsi)
2964 safe_deallocate_a(temp_state1)
2965 safe_deallocate_a(hfloquet)
2966 safe_deallocate_a(eigenval)
2967 safe_deallocate_a(bands)
2968 safe_deallocate_a(temp)
2976 type(c_ptr),
intent(inout) :: out_total_current
2977 class(space_t),
intent(in) :: space
2978 class(mesh_t),
intent(in) :: mesh
2979 type(states_elec_t),
intent(in) :: st
2980 integer,
intent(in) :: iter
2982 integer :: idir, ispin
2983 character(len=50) :: aux
2984 real(real64) :: total_current(space%dim), abs_current(space%dim)
2988 if (mpi_grp_is_root(mpi_world) .and. iter == 0)
then
2989 call td_write_print_header_init(out_total_current)
2992 call write_iter_header_start(out_total_current)
2994 do idir = 1, space%dim
2995 write(aux,
'(a2,i1,a1)')
'I(', idir,
')'
2996 call write_iter_header(out_total_current, aux)
2999 do idir = 1, space%dim
3000 write(aux,
'(a10,i1,a1)')
'IntAbs(j)(', idir,
')'
3001 call write_iter_header(out_total_current, aux)
3004 do ispin = 1, st%d%nspin
3005 do idir = 1, space%dim
3006 write(aux,
'(a4,i1,a1,i1,a1)')
'I-sp', ispin,
'(', idir,
')'
3007 call write_iter_header(out_total_current, aux)
3011 call write_iter_nl(out_total_current)
3013 call td_write_print_header_end(out_total_current)
3016 assert(
allocated(st%current))
3018 if (mpi_grp_is_root(mpi_world))
then
3019 call write_iter_start(out_total_current)
3022 total_current = 0.0_real64
3023 do idir = 1, space%dim
3024 do ispin = 1, st%d%spin_channels
3025 total_current(idir) = total_current(idir) + dmf_integrate(mesh, st%current(:, idir, ispin), reduce = .false.)
3027 total_current(idir) = units_from_atomic(units_out%length/units_out%time, total_current(idir))
3029 if (mesh%parallel_in_domains)
then
3030 call mesh%allreduce(total_current, dim = space%dim)
3033 abs_current = 0.0_real64
3034 do idir = 1, space%dim
3035 do ispin = 1, st%d%spin_channels
3036 abs_current(idir) = abs_current(idir) + dmf_integrate(mesh, abs(st%current(:, idir, ispin)), reduce = .false.)
3038 abs_current(idir) = units_from_atomic(units_out%length/units_out%time, abs_current(idir))
3040 if (mesh%parallel_in_domains)
then
3041 call mesh%allreduce(abs_current, dim = space%dim)
3044 if (mpi_grp_is_root(mpi_world))
then
3045 call write_iter_double(out_total_current, total_current, space%dim)
3046 call write_iter_double(out_total_current, abs_current, space%dim)
3049 do ispin = 1, st%d%nspin
3050 total_current = 0.0_real64
3051 do idir = 1, space%dim
3052 total_current(idir) = units_from_atomic(units_out%length/units_out%time, &
3053 dmf_integrate(mesh, st%current(:, idir, ispin), reduce = .false.))
3055 if (mesh%parallel_in_domains)
then
3056 call mesh%allreduce(total_current, dim = space%dim)
3058 if (mpi_grp_is_root(mpi_world))
then
3059 call write_iter_double(out_total_current, total_current, space%dim)
3063 if (mpi_grp_is_root(mpi_world))
then
3064 call write_iter_nl(out_total_current)
3073 type(c_ptr),
intent(inout) :: write_obj
3074 class(space_t),
intent(in) :: space
3075 type(hamiltonian_elec_t),
intent(inout) :: hm
3076 type(grid_t),
intent(in) :: gr
3077 type(states_elec_t),
intent(in) :: st
3078 integer,
intent(in) :: iter
3080 integer :: idir, ispin
3081 character(len=50) :: aux
3082 real(real64),
allocatable :: heat_current(:, :, :)
3083 real(real64) :: total_current(space%dim)
3087 if (mpi_grp_is_root(mpi_world) .and. iter == 0)
then
3088 call td_write_print_header_init(write_obj)
3091 call write_iter_header_start(write_obj)
3093 do idir = 1, space%dim
3094 write(aux,
'(a2,i1,a1)')
'Jh(', idir,
')'
3095 call write_iter_header(write_obj, aux)
3098 call write_iter_nl(write_obj)
3100 call td_write_print_header_end(write_obj)
3103 safe_allocate(heat_current(1:gr%np, 1:space%dim, 1:st%d%nspin))
3105 call current_heat_calculate(space, gr%der, hm, st, heat_current)
3107 if (mpi_grp_is_root(mpi_world))
call write_iter_start(write_obj)
3109 total_current = 0.0_real64
3110 do idir = 1, space%dim
3111 do ispin = 1, st%d%spin_channels
3112 total_current(idir) = total_current(idir) + dmf_integrate(gr, heat_current(:, idir, ispin))
3114 total_current(idir) = units_from_atomic(units_out%energy*units_out%length/units_out%time, total_current(idir))
3117 safe_deallocate_a(heat_current)
3119 if (mpi_grp_is_root(mpi_world))
call write_iter_double(write_obj, total_current, space%dim)
3121 if (mpi_grp_is_root(mpi_world))
call write_iter_nl(write_obj)
3129 type(c_ptr),
intent(inout) :: out_partial_charges
3130 class(mesh_t),
intent(in) :: mesh
3131 type(states_elec_t),
intent(in) :: st
3132 type(ions_t),
intent(in) :: ions
3133 integer,
intent(in) :: iter
3136 character(len=50) :: aux
3137 real(real64),
allocatable :: hirshfeld_charges(:)
3141 safe_allocate(hirshfeld_charges(1:ions%natoms))
3143 call partial_charges_calculate(mesh, st, ions, hirshfeld_charges)
3145 if (mpi_grp_is_root(mpi_world))
then
3149 call td_write_print_header_init(out_partial_charges)
3152 call write_iter_header_start(out_partial_charges)
3154 do idir = 1, ions%natoms
3155 write(aux,
'(a13,i3,a1)')
'hirshfeld(atom=', idir,
')'
3156 call write_iter_header(out_partial_charges, aux)
3159 call write_iter_nl(out_partial_charges)
3161 call td_write_print_header_end(out_partial_charges)
3164 call write_iter_start(out_partial_charges)
3166 call write_iter_double(out_partial_charges, hirshfeld_charges, ions%natoms)
3168 call write_iter_nl(out_partial_charges)
3171 safe_deallocate_a(hirshfeld_charges)
3177 subroutine td_write_q(out_q, space, ks, iter)
3178 type(c_ptr),
intent(inout) :: out_q
3179 class(space_t),
intent(in) :: space
3180 type(v_ks_t),
intent(in) :: ks
3181 integer,
intent(in) :: iter
3184 character(len=50) :: aux
3188 if (mpi_grp_is_root(mpi_world))
then
3190 call td_write_print_header_init(out_q)
3191 call write_iter_header_start(out_q)
3192 do ii = 1, ks%pt%nmodes
3193 write(aux,
'(a1,i3,a3)')
'q', ii,
'(t)'
3194 call write_iter_header(out_q, aux)
3196 do ii = 1, ks%pt%nmodes
3197 write(aux,
'(a1,i3,a3)')
'p', ii,
'(t)'
3198 call write_iter_header(out_q, aux)
3200 do ii = 1, space%dim
3201 write(aux,
'(a3,i3,a3)')
'f_pt', ii,
'(t)'
3202 call write_iter_header(out_q, aux)
3204 call write_iter_nl(out_q)
3205 call td_write_print_header_end(out_q)
3208 call write_iter_start(out_q)
3209 call write_iter_double(out_q, ks%pt_mx%pt_q, ks%pt%nmodes)
3210 call write_iter_double(out_q, ks%pt_mx%pt_p, ks%pt%nmodes)
3211 call write_iter_double(out_q, ks%pt_mx%fmf, space%dim)
3212 call write_iter_nl(out_q)
3221 type(c_ptr),
intent(inout) :: out_mxll
3222 class(space_t),
intent(in) :: space
3223 type(hamiltonian_elec_t),
intent(in) :: hm
3224 real(real64),
intent(in) :: dt
3225 integer,
intent(in) :: iter
3228 real(real64) :: field(space%dim)
3229 character(len=80) :: aux
3230 character(len=1) :: field_char
3234 if (.not. mpi_grp_is_root(mpi_world))
then
3240 call td_write_print_header_init(out_mxll)
3242 write(aux,
'(a7,e20.12,3a)')
'# dt = ', units_from_atomic(units_out%time, dt), &
3243 " [", trim(units_abbrev(units_out%time)),
"]"
3244 call write_iter_string(out_mxll, aux)
3245 call write_iter_nl(out_mxll)
3247 call write_iter_header_start(out_mxll)
3248 select case (hm%mxll%coupling_mode)
3249 case (length_gauge_dipole, multipolar_expansion)
3250 if (hm%mxll%add_electric_dip) field_char =
'E'
3251 if (hm%mxll%add_magnetic_dip) field_char =
'B'
3252 do idir = 1, space%dim
3253 write(aux,
'(a,i1,a)') field_char //
'(', idir,
')'
3254 call write_iter_header(out_mxll, aux)
3256 case (velocity_gauge_dipole)
3257 do idir = 1, space%dim
3258 write(aux,
'(a,i1,a)')
'A(', idir,
')'
3259 call write_iter_header(out_mxll, aux)
3262 call write_iter_nl(out_mxll)
3264 call write_iter_string(out_mxll,
'#[Iter n.]')
3265 call write_iter_header(out_mxll,
'[' // trim(units_abbrev(units_out%time)) //
']')
3269 select case (hm%mxll%coupling_mode)
3270 case (length_gauge_dipole, multipolar_expansion)
3271 if (hm%mxll%add_electric_dip) aux =
'[' // trim(units_abbrev(units_out%force)) //
']'
3272 if (hm%mxll%add_magnetic_dip) aux =
'[' // trim(units_abbrev(unit_one/units_out%length**2)) //
']'
3273 do idir = 1, space%dim
3274 call write_iter_header(out_mxll, aux)
3276 case (velocity_gauge_dipole)
3277 aux =
'[' // trim(units_abbrev(units_out%energy)) //
']'
3278 do idir = 1, space%dim
3279 call write_iter_header(out_mxll, aux)
3282 call write_iter_nl(out_mxll)
3283 call td_write_print_header_end(out_mxll)
3286 call write_iter_start(out_mxll)
3289 select case (hm%mxll%coupling_mode)
3290 case (length_gauge_dipole, multipolar_expansion)
3291 if (hm%mxll%add_electric_dip) field = units_from_atomic(units_out%force, hm%mxll%e_field_dip)
3292 if (hm%mxll%add_magnetic_dip) field = units_from_atomic(unit_one/units_out%length**2, hm%mxll%b_field_dip)
3293 call write_iter_double(out_mxll, field, space%dim)
3294 case (velocity_gauge_dipole)
3295 field = units_from_atomic(units_out%energy, hm%mxll%vec_pot_dip)
3296 call write_iter_double(out_mxll, field, space%dim)
3298 call write_iter_nl(out_mxll)
3306 type(c_ptr),
intent(inout) :: out_coords
3307 type(lda_u_t),
intent(in) :: lda_u
3308 integer,
intent(in) :: iter
3311 character(len=50) :: aux
3313 if (.not. mpi_grp_is_root(mpi_world))
return
3318 call td_write_print_header_init(out_coords)
3321 call write_iter_header_start(out_coords)
3323 do ios = 1, lda_u%norbsets
3324 write(aux,
'(a2,i3,a1)')
'Ueff(', ios,
')'
3325 call write_iter_header(out_coords, aux)
3328 do ios = 1, lda_u%norbsets
3329 write(aux,
'(a2,i3,a1)')
'U(', ios,
')'
3330 call write_iter_header(out_coords, aux)
3333 do ios = 1, lda_u%norbsets
3334 write(aux,
'(a2,i3,a1)')
'J(', ios,
')'
3335 call write_iter_header(out_coords, aux)
3338 if (lda_u%intersite)
then
3339 do ios = 1, lda_u%norbsets
3340 do inn = 1, lda_u%orbsets(ios)%nneighbors
3341 write(aux,
'(a2,i3,a1,i3,a1)')
'V(', ios,
'-', inn,
')'
3342 call write_iter_header(out_coords, aux)
3348 call write_iter_nl(out_coords)
3351 call write_iter_string(out_coords,
'#[Iter n.]')
3352 call write_iter_header(out_coords,
'[' // trim(units_abbrev(units_out%time)) //
']')
3353 call write_iter_string(out_coords, &
3354 'Effective U ' // trim(units_abbrev(units_out%energy)) // &
3355 ', U in '// trim(units_abbrev(units_out%energy)) // &
3356 ', J in ' // trim(units_abbrev(units_out%energy)))
3357 call write_iter_nl(out_coords)
3359 call td_write_print_header_end(out_coords)
3362 call write_iter_start(out_coords)
3364 do ios = 1, lda_u%norbsets
3365 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3366 lda_u%orbsets(ios)%Ueff), 1)
3369 do ios = 1, lda_u%norbsets
3370 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3371 lda_u%orbsets(ios)%Ubar), 1)
3374 do ios = 1, lda_u%norbsets
3375 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3376 lda_u%orbsets(ios)%Jbar), 1)
3379 if (lda_u%intersite)
then
3380 do ios = 1, lda_u%norbsets
3381 do inn = 1, lda_u%orbsets(ios)%nneighbors
3382 call write_iter_double(out_coords, units_from_atomic(units_out%energy, &
3383 lda_u%orbsets(ios)%V_ij(inn,0)), 1)
3388 call write_iter_nl(out_coords)
3395 type(c_ptr),
intent(inout) :: file_handle
3396 type(grid_t),
intent(in) :: grid
3397 type(kpoints_t),
intent(in) :: kpoints
3398 type(states_elec_t),
intent(in) :: st
3399 integer,
intent(in) :: iter
3401 integer :: ik_ispin, ist
3402 character(len=7) :: nkpt_str, nst_str
3403 character(len=7) :: ik_str, ist_str
3404 real(real64),
allocatable :: norm_ks(:, :)
3405 real(real64) :: n_electrons
3409 safe_allocate(norm_ks(1:st%nst, 1:st%nik))
3410 call states_elec_calc_norms(grid, kpoints, st, norm_ks)
3412 if (mpi_grp_is_root(mpi_world))
then
3415 call td_write_print_header_init(file_handle)
3418 write(nkpt_str,
'(I7)') st%nik
3419 write(nst_str,
'(I7)') st%nst
3420 call write_iter_string(file_handle,
'# Dimensions. (nstates, nkpt * nspin):')
3421 call write_iter_string(file_handle, trim(adjustl(nst_str)) //
' ' // trim(adjustl(nkpt_str)))
3422 call write_iter_nl(file_handle)
3425 call write_iter_string(file_handle,
'# Norm ordering: (istate, ikpoint_spin)')
3426 call write_iter_nl(file_handle)
3429 call write_iter_header_start(file_handle)
3430 call write_iter_header(file_handle,
'N_electrons')
3431 do ik_ispin = 1, st%nik
3433 write(ik_str,
'(I7)') ik_ispin
3434 write(ist_str,
'(I7)') ist
3435 call write_iter_header(file_handle, &
3436 'Norm (' // trim(ist_str) //
',' // trim(ik_str) //
')')
3439 call write_iter_nl(file_handle)
3440 call td_write_print_header_end(file_handle)
3443 n_electrons = sum(st%occ * norm_ks**2)
3446 call write_iter_start(file_handle)
3447 call write_iter_double(file_handle, n_electrons, 1)
3448 do ik_ispin = 1, st%nik
3449 call write_iter_double(file_handle, norm_ks(:, ik_ispin),
size(norm_ks, 1))
3451 call write_iter_nl(file_handle)
3455 safe_deallocate_a(norm_ks)
3464 type(namespace_t),
intent(in) :: namespace
3465 integer,
intent(in) :: iter
3466 real(real64),
intent(in) :: dt
3468 integer :: default, flags, iout, first
3523 call parse_variable(namespace,
'MaxwellTDOutput', default, flags)
3525 if (.not. varinfo_valid_option(
'MaxwellTDOutput', flags, is_flag = .
true.))
then
3526 call messages_input_error(namespace,
'MaxwellTDOutput')
3530 writ%out(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
3531 if (writ%out(iout)%write)
then
3532 writ%out(iout + 1)%write = .
true.
3533 writ%out(iout + 2)%write = .
true.
3538 writ%out(iout)%write = (iand(flags, 2**(iout - 1)) /= 0)
3547 call io_mkdir(
'td.general', namespace)
3552 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_e_field_x", namespace)))
3554 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_e_field_y", namespace)))
3556 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_e_field_z", namespace)))
3562 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_b_field_x", namespace)))
3564 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_b_field_y", namespace)))
3566 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/total_b_field_z", namespace)))
3572 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_e_field_x", namespace)))
3574 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_e_field_y", namespace)))
3576 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_e_field_z", namespace)))
3582 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_b_field_x", namespace)))
3584 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_b_field_y", namespace)))
3586 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/longitudinal_b_field_z", namespace)))
3592 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_e_field_x", namespace)))
3594 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_e_field_y", namespace)))
3596 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_e_field_z", namespace)))
3602 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_b_field_x", namespace)))
3604 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_b_field_y", namespace)))
3606 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/transverse_b_field_z", namespace)))
3612 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/maxwell_energy", namespace)))
3617 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/electric_field_surface-x", namespace)))
3622 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/electric_field_surface-y", namespace)))
3627 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/electric_field_surface-z", namespace)))
3632 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/magnetic_field_surface-x", namespace)))
3637 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/magnetic_field_surface-y", namespace)))
3642 units_from_atomic(units_out%time, dt), trim(io_workpath(
"td.general/magnetic_field_surface-z", namespace)))
3658 if (writ%out(iout)%write)
call write_iter_end(writ%out(iout)%handle)
3666 subroutine td_write_mxll_iter(writ, space, gr, st, hm, helmholtz, dt, iter, namespace)
3668 class(space_t),
intent(in) :: space
3669 type(grid_t),
intent(inout) :: gr
3670 type(states_mxll_t),
intent(inout) :: st
3671 type(hamiltonian_mxll_t),
intent(inout) :: hm
3672 type(helmholtz_decomposition_t),
intent(inout) :: helmholtz
3673 real(real64),
intent(in) :: dt
3674 integer,
intent(in) :: iter
3675 type(namespace_t),
intent(in) :: namespace
3680 call profiling_in(
"TD_WRITE_ITER_MAXWELL")
3683 call helmholtz%get_trans_field(namespace, st%rs_state_trans, total_field=st%rs_state)
3684 call get_rs_state_at_point(st%selected_points_rs_state_trans(:,:), st%rs_state_trans, &
3685 st%selected_points_coordinate(:,:), st, gr)
3688 hm%energy%energy_trans = m_zero
3692 call helmholtz%get_long_field(namespace, st%rs_state_long, total_field=st%rs_state)
3693 call get_rs_state_at_point(st%selected_points_rs_state_long(:,:), st%rs_state_long, &
3694 st%selected_points_coordinate(:,:), st, gr)
3697 hm%energy%energy_long = m_zero
3789 call profiling_out(
"TD_WRITE_ITER_MAXWELL")
3798 type(hamiltonian_mxll_t),
intent(in) :: hm
3799 integer,
intent(in) :: iter
3803 integer :: n_columns
3805 if (.not. mpi_grp_is_root(mpi_world))
return
3830 call write_iter_header(
out_maxwell_energy,
'[' // trim(units_abbrev(units_out%time)) //
']')
3832 do ii = 1, n_columns
3833 call write_iter_header(
out_maxwell_energy,
'[' // trim(units_abbrev(units_out%energy)) //
']')
3841 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy), 1)
3842 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%e_energy), 1)
3843 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%b_energy), 1)
3845 hm%energy%energy+hm%energy%boundaries), 1)
3846 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%boundaries), 1)
3847 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_trans), 1)
3848 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_long), 1)
3849 call write_iter_double(
out_maxwell_energy, units_from_atomic(units_out%energy, hm%energy%energy_plane_waves), 1)
3858 type(c_ptr),
intent(inout) :: out_field_surf
3859 type(states_mxll_t),
intent(in) :: st
3860 integer,
intent(in) :: dim
3861 integer,
intent(in) :: iter
3865 integer :: n_columns
3867 if (.not. mpi_grp_is_root(mpi_world))
return
3874 call td_write_print_header_init(out_field_surf)
3877 call write_iter_header_start(out_field_surf)
3878 call write_iter_header(out_field_surf,
'- x direction')
3879 call write_iter_header(out_field_surf,
'+ x direction')
3880 call write_iter_header(out_field_surf,
'- y direction')
3881 call write_iter_header(out_field_surf,
'+ y direction')
3882 call write_iter_header(out_field_surf,
'- z direction')
3883 call write_iter_header(out_field_surf,
'+ z direction')
3884 call write_iter_header(out_field_surf,
'- x dir. p. w.')
3885 call write_iter_header(out_field_surf,
'+ x dir. p. w.')
3886 call write_iter_header(out_field_surf,
'- y dir. p. w.')
3887 call write_iter_header(out_field_surf,
'+ y dir. p. w.')
3888 call write_iter_header(out_field_surf,
'- z dir. p. w.')
3889 call write_iter_header(out_field_surf,
'+ z dir. p. w.')
3891 call write_iter_nl(out_field_surf)
3894 call write_iter_string(out_field_surf,
'#[Iter n.]')
3895 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(units_out%time)) //
']')
3897 do ii = 1, n_columns
3898 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(units_out%energy/units_out%length)) //
']')
3900 call write_iter_nl(out_field_surf)
3902 call td_write_print_header_end(out_field_surf)
3905 call write_iter_start(out_field_surf)
3906 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3907 st%electric_field_box_surface(1,1,dim)), 1)
3908 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3909 st%electric_field_box_surface(2,1,dim)), 1)
3910 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3911 st%electric_field_box_surface(1,2,dim)), 1)
3912 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3913 st%electric_field_box_surface(2,2,dim)), 1)
3914 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3915 st%electric_field_box_surface(1,3,dim)), 1)
3916 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3917 st%electric_field_box_surface(2,3,dim)), 1)
3918 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3919 st%electric_field_box_surface_plane_waves(1,1,dim)), 1)
3920 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3921 st%electric_field_box_surface_plane_waves(2,1,dim)), 1)
3922 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3923 st%electric_field_box_surface_plane_waves(1,2,dim)), 1)
3924 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3925 st%electric_field_box_surface_plane_waves(2,2,dim)), 1)
3926 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3927 st%electric_field_box_surface_plane_waves(1,3,dim)), 1)
3928 call write_iter_double(out_field_surf, units_from_atomic(units_out%energy/units_out%length, &
3929 st%electric_field_box_surface_plane_waves(2,3,dim)), 1)
3930 call write_iter_nl(out_field_surf)
3938 type(c_ptr),
intent(inout) :: out_field_surf
3939 type(states_mxll_t),
intent(in) :: st
3940 integer,
intent(in) :: dim
3941 integer,
intent(in) :: iter
3945 integer :: n_columns
3947 if (.not. mpi_grp_is_root(mpi_world))
return
3954 call td_write_print_header_init(out_field_surf)
3957 call write_iter_header_start(out_field_surf)
3958 call write_iter_header(out_field_surf,
'- x direction')
3959 call write_iter_header(out_field_surf,
'+ x direction')
3960 call write_iter_header(out_field_surf,
'- y direction')
3961 call write_iter_header(out_field_surf,
'+ y direction')
3962 call write_iter_header(out_field_surf,
'- z direction')
3963 call write_iter_header(out_field_surf,
'+ z direction')
3964 call write_iter_header(out_field_surf,
'- x dir. p. w.')
3965 call write_iter_header(out_field_surf,
'+ x dir. p. w.')
3966 call write_iter_header(out_field_surf,
'- y dir. p. w.')
3967 call write_iter_header(out_field_surf,
'+ y dir. p. w.')
3968 call write_iter_header(out_field_surf,
'- z dir. p. w.')
3969 call write_iter_header(out_field_surf,
'+ z dir. p. w.')
3971 call write_iter_nl(out_field_surf)
3974 call write_iter_string(out_field_surf,
'#[Iter n.]')
3975 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(units_out%time)) //
']')
3977 do ii = 1, n_columns
3978 call write_iter_header(out_field_surf,
'[' // trim(units_abbrev(unit_one/units_out%length**2)) //
']')
3980 call write_iter_nl(out_field_surf)
3982 call td_write_print_header_end(out_field_surf)
3985 call write_iter_start(out_field_surf)
3986 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
3987 st%magnetic_field_box_surface(1,1,dim)), 1)
3988 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
3989 st%magnetic_field_box_surface(2,1,dim)), 1)
3990 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
3991 st%magnetic_field_box_surface(1,2,dim)), 1)
3992 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
3993 st%magnetic_field_box_surface(2,2,dim)), 1)
3994 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
3995 st%magnetic_field_box_surface(1,3,dim)), 1)
3996 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
3997 st%magnetic_field_box_surface(2,3,dim)), 1)
3998 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
3999 st%magnetic_field_box_surface_plane_waves(1,1,dim)), 1)
4000 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4001 st%magnetic_field_box_surface_plane_waves(2,1,dim)), 1)
4002 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4003 st%magnetic_field_box_surface_plane_waves(1,2,dim)), 1)
4004 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4005 st%magnetic_field_box_surface_plane_waves(2,2,dim)), 1)
4006 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4007 st%magnetic_field_box_surface_plane_waves(1,3,dim)), 1)
4008 call write_iter_double(out_field_surf, units_from_atomic(unit_one/units_out%length**2, &
4009 st%magnetic_field_box_surface_plane_waves(2,3,dim)), 1)
4010 call write_iter_nl(out_field_surf)
4016 subroutine td_write_fields(out_fields, space, st, iter, dt, e_or_b_field, field_type, idir)
4017 type(c_ptr),
intent(inout) :: out_fields
4018 class(space_t),
intent(in) :: space
4019 type(states_mxll_t),
intent(in) :: st
4020 integer,
intent(in) :: iter
4021 real(real64),
intent(in) :: dt
4022 integer,
intent(in) :: e_or_b_field
4023 integer,
intent(in) :: field_type
4024 integer,
intent(in) :: idir
4028 real(real64) :: field(space%dim), selected_field
4029 character(len=80) :: aux
4031 if (.not. mpi_grp_is_root(mpi_world))
return
4036 call td_write_print_header_init(out_fields)
4039 write(aux,
'(a7,e20.12,3a)')
'# dt = ', units_from_atomic(units_out%time, dt), &
4040 " [", trim(units_abbrev(units_out%time)),
"]"
4041 call write_iter_string(out_fields, aux)
4042 call write_iter_nl(out_fields)
4044 call write_iter_header_start(out_fields)
4046 do id = 1, st%selected_points_number
4047 select case (e_or_b_field)
4049 write(aux,
'(a,i1,a)')
'E(', id,
')'
4051 write(aux,
'(a,i1,a)')
'B(', id,
')'
4053 call write_iter_header(out_fields, aux)
4056 call write_iter_nl(out_fields)
4057 call write_iter_string(out_fields,
'#[Iter n.]')
4058 call write_iter_header(out_fields,
' [' // trim(units_abbrev(units_out%time)) //
']')
4063 aux =
' [' // trim(units_abbrev(units_out%force)) //
']'
4064 do id = 1, st%selected_points_number
4065 call write_iter_header(out_fields, aux)
4067 call write_iter_nl(out_fields)
4068 call td_write_print_header_end(out_fields)
4071 call write_iter_start(out_fields)
4073 do id = 1, st%selected_points_number
4074 select case (e_or_b_field)
4077 select case (field_type)
4079 call get_electric_field_vector(st%selected_points_rs_state(:,id), field(1:st%dim))
4081 call get_electric_field_vector(st%selected_points_rs_state_long(:,id), field(1:st%dim))
4083 call get_electric_field_vector(st%selected_points_rs_state_trans(:,id), field(1:st%dim))
4085 selected_field = units_from_atomic(units_out%energy/units_out%length, field(idir))
4088 select case (field_type)
4090 call get_magnetic_field_vector(st%selected_points_rs_state(:,id), st%rs_sign, field(1:st%dim))
4092 call get_magnetic_field_vector(st%selected_points_rs_state_long(:,id), st%rs_sign, field(1:st%dim))
4094 call get_magnetic_field_vector(st%selected_points_rs_state_trans(:,id), st%rs_sign, field(1:st%dim))
4096 selected_field = units_from_atomic(unit_one/units_out%length**2, field(idir))
4098 call write_iter_double(out_fields, selected_field, 1)
4101 call write_iter_nl(out_fields)
4110 type(namespace_t),
intent(in) :: namespace
4111 class(space_t),
intent(in) :: space
4112 type(grid_t),
intent(inout) :: gr
4113 type(states_mxll_t),
intent(inout) :: st
4114 type(hamiltonian_mxll_t),
intent(inout) :: hm
4115 type(helmholtz_decomposition_t),
intent(inout) :: helmholtz
4116 type(output_t),
intent(in) :: outp
4117 integer,
intent(in) :: iter
4118 real(real64),
intent(in) :: time
4120 character(len=256) :: filename
4122 push_sub(td_write_maxwell_free_data)
4123 call profiling_in(
"TD_WRITE_MAXWELL_DATA")
4126 write(filename,
'(a,a,i7.7)') trim(outp%iter_dir),
"td.", iter
4128 call output_mxll(outp, namespace, space, gr, st, hm, helmholtz, time, filename)
4130 call profiling_out(
"TD_WRITE_MAXWELL_DATA")
4131 pop_sub(td_write_maxwell_free_data)
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.
complex(real64) function, public zmf_integrate(mesh, ff, mask, reduce)
Integrate a function on the mesh.
subroutine, public dmf_multipoles(mesh, ff, lmax, multipole, mask)
This routine calculates the multipoles of a function ff.
real(real64) function, public dmf_integrate(mesh, ff, mask, reduce)
Integrate a function on the mesh.
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 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, 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(elec_me, 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
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
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_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_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, 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)
subroutine td_write_vel(out_vel, elec_me, kpoints, 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_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), 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)