45 use,
intrinsic :: iso_fortran_env
108 integer,
parameter,
public :: &
114 type(propagator_base_t),
public :: tr
115 type(scf_t),
public :: scf
116 type(ion_dynamics_t),
public :: ions_dyn
117 real(real64),
public :: dt
118 integer,
public :: max_iter
119 integer,
public :: iter
120 logical,
public :: recalculate_gs
121 integer,
public :: recalculate_gs_interval
123 type(pes_t),
public :: pesv
125 integer,
public :: dynamics
126 integer,
public :: energy_update_iter
127 real(real64) :: scissor
129 logical :: freeze_occ
131 integer :: freeze_orbitals
133 logical :: from_scratch = .false.
135 type(td_write_t),
public :: write_handler
136 type(restart_t) :: restart_load
137 type(restart_t) :: restart_dump
144 subroutine td_init(td, namespace, space, gr, ions, st, ks, hm, ext_partners, outp, dmp)
145 type(td_t),
intent(inout) :: td
146 type(namespace_t),
intent(in) :: namespace
147 class(space_t),
intent(in) :: space
148 type(grid_t),
intent(in) :: gr
149 type(ions_t),
intent(inout) :: ions
150 type(states_elec_t),
intent(in) :: st
151 type(v_ks_t),
intent(in) :: ks
152 type(hamiltonian_elec_t),
intent(in) :: hm
153 type(partner_list_t),
intent(in) :: ext_partners
154 type(output_t),
intent(in) :: outp
155 type(dmp_t),
intent(inout) :: dmp
158 real(real64) :: propagation_time
159 type(lasers_t),
pointer :: lasers
160 logical :: symmetrize
166 symmetrize = hm%kpoints%use_symmetries .or. st%symmetrize_density
169 if (td%ions_dyn%ions_move())
then
170 if (hm%kpoints%use_symmetries)
then
171 message(1) =
"KPoints symmetries cannot be used with moving ions."
172 message(2) =
"Please set KPointsSymmetries = no."
175 if (st%symmetrize_density)
then
176 message(1) =
"Symmetrization of the density cannot be used with moving ions."
177 message(2) =
"Please set SymmetrizeDensity = no."
199 write(
message(1),
'(a)')
'A positive value for TDTimeStep must be defined in the input file.'
207 call messages_write(
'You cannot set TDMaxSteps and TDPropagationTime at the same time')
236 if (propagation_time >
m_zero) default = nint(propagation_time/td%dt)
237 call parse_variable(namespace,
'TDMaxSteps', default, td%max_iter)
239 if (propagation_time <=
m_zero) propagation_time = td%dt*td%max_iter
244 if (td%max_iter < 1)
then
245 write(
message(1),
'(a,i6,a)')
"Input: '", td%max_iter,
"' is not a valid value for TDMaxSteps."
246 message(2) =
'(TDMaxSteps <= 1)'
255 call pes_init(td%pesv, namespace, space, gr, gr%box, st, 1, hm%kpoints, &
256 hm%abs_boundaries, ext_partners, td%max_iter, td%dt)
271 call parse_variable(namespace,
'TDDynamics', ehrenfest, td%dynamics)
274 if (td%dynamics .ne. ehrenfest)
then
275 if (.not. td%ions_dyn%is_active())
then
276 message(1) =
"TDDynamics=bo can only be used if MoveIons=yes or CellDynamics=yes"
297 call parse_variable(namespace,
'RecalculateGSDuringEvolution', .false., td%recalculate_gs)
298 if (hm%lda_u_level /=
dft_u_none .and. td%recalculate_gs)
then
314 call parse_variable(namespace,
'RecalculateGSInterval', 50, td%recalculate_gs_interval)
333 if (st%requires_generalized_overlap .and. td%ions_dyn%ions_move())
then
337 if (
associated(lasers) .and. st%system_grp%is_root())
then
339 call laser_write_info(lasers%lasers, dt=td%dt, max_iter=td%max_iter, namespace=namespace)
355 call parse_variable(namespace,
'TDEnergyUpdateIter', default, td%energy_update_iter)
356 if (td%energy_update_iter < 1)
then
360 if (gr%der%boundaries%spiralBC .and. &
362 message(1) =
"Generalized Bloch theorem cannot be used with spin-orbit coupling."
366 if (gr%der%boundaries%spiralBC)
then
367 if (any(abs(hm%kick%easy_axis(1:2)) >
m_epsilon))
then
368 message(1) =
"Generalized Bloch theorem cannot be used for an easy axis not along the z direction."
394 call parse_variable(namespace,
'TDFreezeOrbitals', 0, td%freeze_orbitals)
396 if (td%freeze_orbitals /= 0)
then
430 if (dmp%calculation_mode /= option__tddmpropagation__no_propagation)
then
432 call dmp%init(namespace, st, space, hm)
441 subroutine td_init_run(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, dmp, from_scratch)
442 type(
td_t),
intent(inout) :: td
445 type(
grid_t),
intent(inout) :: gr
446 type(
ions_t),
intent(inout) :: ions
448 type(
v_ks_t),
intent(inout) :: ks
451 type(
output_t),
intent(inout) :: outp
453 type(
dmp_t),
intent(inout) :: dmp
454 logical,
intent(inout) :: from_scratch
464 call ions%initialize()
466 td%from_scratch = from_scratch
468 if (.not. td%from_scratch)
then
470 if (td%from_scratch)
then
471 message(1) =
"Unable to read time-dependent restart information: Starting from scratch"
476 if (td%iter >= td%max_iter)
then
477 message(1) =
"All requested iterations have already been done. Use FromScratch = yes if you want to redo them."
480 td%iter = td%iter + 1
481 if ((td%ions_dyn%is_active()) .and. td%recalculate_gs)
call td%restart_load%end()
486 if (td%from_scratch)
then
490 call td_init_with_wavefunctions(td, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, outp, dmp, td%from_scratch)
497 type(
td_t),
intent(inout) :: td
500 type(
grid_t),
intent(inout) :: gr
501 type(
ions_t),
intent(inout) :: ions
504 class(
space_t),
intent(in) :: space
509 if (td%dynamics == ehrenfest)
then
515 call lda_u_init(hm%lda_u, namespace, space, hm%lda_u_level, gr, ions, st, mc, hm%kpoints)
522 call scf_init(td%scf, namespace, gr, ions, st, mc, hm, space)
531 type(
td_t),
intent(inout) :: td
533 type(
grid_t),
intent(inout) :: gr
535 type(
v_ks_t),
intent(inout) :: ks
538 class(
space_t),
intent(in) :: space
545 if(
associated(gfield))
then
552 call hm%update(gr, namespace, space, ext_partners, time = td%dt*td%iter)
562 type(
td_t),
intent(inout) :: td
570 if (td%dynamics ==
bo)
call scf_end(td%scf)
577 type(
td_t),
intent(inout) :: td
580 type(
dmp_t),
intent(inout) :: dmp
584 if (st%pack_states .and. hm%apply_packed())
call st%unpack()
586 call td%restart_dump%end()
591 if ((td%ions_dyn%is_active()).and. td%recalculate_gs)
call td%restart_load%end()
593 if (dmp%calculation_mode /= option__tddmpropagation__no_propagation)
then
601 subroutine td_run(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, dmp, from_scratch)
602 type(
td_t),
intent(inout) :: td
605 type(
grid_t),
intent(inout) :: gr
606 type(
ions_t),
intent(inout) :: ions
608 type(
v_ks_t),
intent(inout) :: ks
611 type(
output_t),
intent(inout) :: outp
613 type(
dmp_t),
intent(inout) :: dmp
614 logical,
intent(inout) :: from_scratch
617 integer :: iter, scsteps
618 real(real64) :: etime
619 real(real64) :: wall_time, simulation_time, speed_fs_per_day
620 character(len=20) :: fmt
628 propagation:
do iter = td%iter, td%max_iter
635 if (((iter-1)*td%dt <= hm%kick%time) .and. (iter*td%dt > hm%kick%time))
then
636 if (st%requires_generalized_overlap)
then
638 else if (.not. hm%pcm%localf)
then
639 call kick_apply(space, gr, st, td%ions_dyn, ions, hm%kick, hm%psolver, hm%kpoints)
641 call kick_apply(space, gr, st, td%ions_dyn, ions, hm%kick, hm%psolver, hm%kpoints, pcm = hm%pcm)
643 call td_write_kick(outp, namespace, space, gr, hm%kick, ions, iter)
646 if (gr%der%boundaries%spiralBC) gr%der%boundaries%spiral = .
true.
651 select case (td%dynamics)
653 call propagator_elec_dt(ks, namespace, space, hm, gr, st, td%tr, iter*td%dt, td%dt, iter, td%ions_dyn, &
654 ions, ext_partners, mc, outp, td%write_handler, scsteps = scsteps, dmp = dmp, &
655 update_energy = (mod(iter, td%energy_update_iter) == 0) .or. (iter == td%max_iter))
657 call propagator_elec_dt_bo(td%scf, namespace, space, gr, ks, st, hm, ions, ext_partners, mc, iter, &
658 td%dt, td%ions_dyn, scsteps)
671 if (td%pesv%calc_spm .or. td%pesv%calc_mask .or. td%pesv%calc_flux)
then
672 call pes_calc(td%pesv, namespace, space, gr, st, td%dt, iter, gr%der, hm%kpoints, ext_partners, stopping)
675 call td_write_iter(td%write_handler, namespace, space, outp, gr, st, hm, ions, ext_partners, &
676 hm%kick, ks, td%dt, iter, mc, td%recalculate_gs, dmp)
679 call td_check_point(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, &
680 iter, scsteps, etime, dmp, stopping, from_scratch)
692 simulation_time = td%dt * (iter - td%iter + 1)
694 if (speed_fs_per_day > 1e4 .or. speed_fs_per_day < 1e-3)
then
699 write(
message(1),
'(a,'//trim(fmt)//
',a)')
'Propagation speed: ', speed_fs_per_day,
' fs/day'
711 write(
message(1),
'(a7,1x,a14,a14,a10,a17)')
'Iter ',
'Time ',
'Energy ',
'SC Steps',
'Elapsed Time '
720 subroutine td_check_point(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, &
721 iter, scsteps, etime, dmp, stopping, from_scratch)
722 type(
td_t),
intent(inout) :: td
725 type(
grid_t),
intent(inout) :: gr
726 type(
ions_t),
intent(inout) :: ions
728 type(
v_ks_t),
intent(inout) :: ks
733 integer,
intent(in) :: iter
734 integer,
intent(in) :: scsteps
735 real(real64),
intent(inout) :: etime
736 type(
dmp_t),
intent(inout) :: dmp
737 logical,
intent(in) :: stopping
738 logical,
intent(inout) :: from_scratch
746 if (outp%anything_now(iter))
then
747 call td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, td%dt)
753 call td_dump(td, namespace, space, gr, st, hm, ks, ext_partners, iter, ierr)
755 message(1) =
"Unable to write time-dependent restart information."
759 if (dmp%calculation_mode /= option__tddmpropagation__no_propagation .and. &
760 dmp%basis == option__tddmpropagationbasis__adiabatic)
then
761 call states_elec_dump(dmp%restart_dump, space, dmp%adiabatic_st, gr, hm%kpoints, ierr, iter=iter)
763 message(1) =
"Unable to write dm-adiabatic restart information."
768 call pes_output(td%pesv, namespace, space, gr, st, iter, outp, td%dt, ions)
771 if (mod(iter, td%recalculate_gs_interval) == 0 .or. iter == td%max_iter .or. stopping)
then
772 if ((td%ions_dyn%is_active()) .and. td%recalculate_gs)
then
774 call td_dump(td, namespace, space, gr, st, hm, ks, ext_partners, iter, ierr)
776 message(1) =
"Unable to write time-dependent restart information."
781 from_scratch = .false.
783 call electrons_ground_state_run(namespace, mc, gr, ions, ext_partners, st, ks, hm, outp, space, from_scratch)
786 call td_load(td%restart_load, namespace, space, gr, st, hm, ext_partners, td, ks, ierr)
788 message(1) =
"Unable to load TD states."
791 call density_calc(st, gr, st%rho, ep = hm%ep, vnl = hm%aug_overlap, phase = hm%phase)
792 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
793 calc_eigenval=.
true., time = iter*td%dt, calc_energy=.
true.)
794 call forces_calculate(gr, namespace, ions, hm, ext_partners, st, ks, t = iter*td%dt, dt = td%dt)
795 assert(.not. td%ions_dyn%cell_relax())
806 type(
td_t),
intent(inout) :: td
808 type(
ions_t),
intent(inout) :: ions
810 integer,
intent(in) :: iter
811 integer,
intent(in) :: scsteps
812 real(real64),
intent(inout) :: etime
827 real(real64),
intent(inout) :: etime
837 subroutine td_init_with_wavefunctions(td, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, outp, dmp, from_scratch)
838 type(
td_t),
intent(inout) :: td
842 type(
grid_t),
intent(inout) :: gr
843 type(
ions_t),
intent(inout) :: ions
846 type(
v_ks_t),
intent(inout) :: ks
848 type(
output_t),
intent(inout) :: outp
849 type(
dmp_t),
intent(inout) :: dmp
850 logical,
intent(in) :: from_scratch
854 real(real64) :: ndinitial(space%dim)
855 logical :: freeze_hxc, freeze_occ, freeze_u
856 type(
restart_t) :: restart, restart_frozen
863 if (gr%der%boundaries%spiralBC)
then
864 if ((td%iter-1)*td%dt > hm%kick%time)
then
865 gr%der%boundaries%spiral = .
true.
867 hm%vnl%spin => st%spin
868 hm%phase%spin => st%spin
873 if (from_scratch)
then
880 if (td%freeze_orbitals > 0)
then
881 if (from_scratch)
then
892 message(1) =
"Unable to read frozen restart information."
897 write(
message(1),
'(a,i4,a,i4,a)')
'Info: The lowest', td%freeze_orbitals, &
898 ' orbitals have been frozen.', st%nst,
' will be propagated.'
901 call density_calc(st, gr, st%rho, ep = hm%ep, vnl = hm%aug_overlap, phase = hm%phase)
902 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval=.
true., time = td%iter*td%dt)
903 else if (td%freeze_orbitals < 0)
then
906 write(
message(1),
'(a)')
'Info: The single-active-electron approximation will be used.'
908 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval=.
true., time = td%iter*td%dt)
909 if (from_scratch)
then
916 call density_calc(st, gr, st%rho, ep = hm%ep, vnl = hm%aug_overlap, phase = hm%phase)
919 call density_calc(st, gr, st%rho, ep = hm%ep, vnl = hm%aug_overlap, phase = hm%phase)
920 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval=.
true., time = td%iter*td%dt)
931 call parse_variable(namespace,
'TDFreezeHXC', .false., freeze_hxc)
932 if (freeze_hxc .and. td%tr%method ==
prop_aetrs) &
935 write(
message(1),
'(a)')
'Info: Freezing Hartree and exchange-correlation potentials.'
938 if (.not. from_scratch)
then
941 call states_elec_load(restart_frozen, namespace, space, st, gr, hm%kpoints, fixed_occ=.
true., ierr=ierr, label =
": gs")
943 call restart_frozen%end()
945 call density_calc(st, gr, st%rho, ep = hm%ep, vnl = hm%aug_overlap, phase = hm%phase)
946 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval=.
true., time = td%iter*td%dt)
949 call states_elec_load(restart_frozen, namespace, space, st, gr, hm%kpoints, st%restart_fixed_occ, &
950 ierr=ierr, iter=td%iter, label =
": td")
951 call restart_frozen%end()
952 call hm%ks_pot%run_zero_iter(td%tr%vks_old)
962 x = minval(st%eigenval(1, :))
963 call hm%update_span(gr%spacing(1:space%dim), x, namespace)
965 call states_elec_fermi(st, namespace, gr, compute_spin = .not. gr%der%boundaries%spiralBC)
976 call parse_variable(namespace,
'TDFreezeDFTUOccupations', .false., freeze_occ)
978 write(
message(1),
'(a)')
'Info: Freezing DFT+U occupation matrices that enters in the DFT+U potential.'
983 if (hm%lda_u_level /=
dft_u_none .and. .not. from_scratch)
then
985 call lda_u_load(restart_frozen, hm%lda_u, st, hm%energy%dft_u, ierr, occ_only = .
true.)
986 call restart_frozen%end()
999 write(
message(1),
'(a)')
'Info: Freezing the effective U of DFT+U.'
1004 if (hm%lda_u_level ==
dft_u_acbn0 .and. .not. from_scratch)
then
1006 call lda_u_load(restart_frozen, hm%lda_u, st, hm%energy%dft_u, ierr, u_only = .
true.)
1007 call restart_frozen%end()
1008 write(
message(1),
'(a)')
'Loaded GS effective U of DFT+U'
1017 call td_write_init(td%write_handler, namespace, space, outp, gr, st, hm, ions, ext_partners, &
1018 ks, td%ions_dyn%is_active(), &
1023 if(
associated(lasers))
then
1025 ndinitial(1:space%dim)=
m_zero
1034 call scissor_init(hm%scissor, namespace, space, st, gr, hm%kpoints, hm%phase, td%scissor, mc)
1038 if (dmp%calculation_mode /= option__tddmpropagation__no_propagation)
then
1042 if (td%iter == 0)
then
1043 call td_run_zero_iter(td, namespace, space, gr, ions, st, ks, hm, ext_partners, outp, mc, dmp)
1047 if(
associated(gfield))
then
1050 if (abs(ks%xc%lrc%alpha) >
m_epsilon)
then
1057 td%iter = td%iter + 1
1060 if (td%ions_dyn%is_active() .and. td%recalculate_gs)
then
1068 if ((td%pesv%calc_spm .or. td%pesv%calc_mask) .and. from_scratch)
then
1072 if (st%pack_states .and. hm%apply_packed())
call st%pack()
1079 type(
td_t),
intent(inout) :: td
1082 type(
grid_t),
intent(inout) :: gr
1083 type(
ions_t),
intent(inout) :: ions
1086 type(
v_ks_t),
intent(inout) :: ks
1088 type(
output_t),
intent(inout) :: outp
1093 if (td%ions_dyn%ions_move())
then
1094 if (td%iter > 0)
then
1101 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval=.
true., time = td%iter*td%dt)
1104 call forces_calculate(gr, namespace, ions, hm, ext_partners, st, ks, t = td%iter*td%dt, dt = td%dt)
1106 call ions%update_kinetic_energy()
1108 if (outp%what(option__output__forces) .or. td%write_handler%out(
out_separate_forces)%write)
then
1109 call forces_calculate(gr, namespace, ions, hm, ext_partners, st, ks, t = td%iter*td%dt, dt = td%dt)
1113 if (outp%what(option__output__stress) .or. td%ions_dyn%cell_relax())
then
1115 if (td%ions_dyn%cell_relax())
then
1116 call td%ions_dyn%update_stress(ions%space, st%stress_tensors%total, ions%latt%rlattice, ions%latt%rcell_volume)
1125 type(
td_t),
intent(inout) :: td
1127 class(
space_t),
intent(in) :: space
1129 type(
grid_t),
intent(inout) :: gr
1132 type(
v_ks_t),
intent(inout) :: ks
1134 logical,
intent(inout) :: from_scratch
1142 if (td%freeze_orbitals > 0)
then
1148 call td_load(restart, namespace, space, gr, st, hm, ext_partners, td, ks, ierr)
1152 from_scratch = .
true.
1161 type(
td_t),
intent(inout) :: td
1163 class(
space_t),
intent(in) :: space
1165 type(
grid_t),
intent(inout) :: gr
1168 type(
v_ks_t),
intent(inout) :: ks
1178 if (.not. st%only_userdef_istates)
then
1181 st%restart_fixed_occ, ierr, label =
": gs")
1184 message(1) =
'Unable to read ground-state wavefunctions.'
1185 if (td%ions_dyn%cell_relax() .and. restart%grid_changed)
then
1186 message(2) =
'With CellDynamics = yes, the boundary points are generated with the full-order'
1187 message(3) =
'cube stencil, so the mesh differs from the one of a fixed-cell ground state.'
1188 message(4) =
'Please set RestartWithChangedGrid = yes to restart from such a ground state.'
1209 subroutine td_run_zero_iter(td, namespace, space, gr, ions, st, ks, hm, ext_partners, outp, mc, dmp)
1210 type(
td_t),
intent(inout) :: td
1213 type(
grid_t),
intent(inout) :: gr
1214 type(
ions_t),
intent(inout) :: ions
1216 type(
v_ks_t),
intent(inout) :: ks
1221 type(
dmp_t),
intent(in) :: dmp
1225 call td_write_iter(td%write_handler, namespace, space, outp, gr, st, hm, ions, ext_partners, &
1226 hm%kick, ks, td%dt, 0, mc, td%recalculate_gs, dmp)
1230 if (abs(hm%kick%time) <=
m_epsilon)
then
1231 if (st%requires_generalized_overlap)
then
1233 else if (.not. hm%pcm%localf)
then
1234 call kick_apply(space, gr, st, td%ions_dyn, ions, hm%kick, hm%psolver, hm%kpoints)
1236 call kick_apply(space, gr, st, td%ions_dyn, ions, hm%kick, hm%psolver, hm%kpoints, pcm = hm%pcm)
1238 call td_write_kick(outp, namespace, space, gr, hm%kick, ions, 0)
1241 if (gr%der%boundaries%spiralBC)
then
1242 gr%der%boundaries%spiral = .
true.
1245 call hm%ks_pot%run_zero_iter(td%tr%vks_old)
1247 if (any(outp%output_interval > 0))
then
1249 call td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, 0)
1259 type(
td_t),
intent(in) :: td
1261 type(
ions_t),
intent(inout) :: ions
1263 integer :: iatom, iter, iunit
1267 iunit =
io_open(
'td.general/coordinates', namespace, action=
'read', status=
'old', die=.false.)
1268 if (iunit == -1)
then
1269 message(1) =
"Could not open file '"//trim(
io_workpath(
'td.general/coordinates', namespace))//
"'."
1270 message(2) =
"Starting simulation from initial geometry."
1277 do iter = 0, td%iter - 1
1280 read(iunit,
'(32x)', advance=
'no')
1282 do iatom = 1, ions%natoms
1283 read(iunit,
'(3es24.16)', advance=
'no') ions%pos(:, iatom)
1286 do iatom = 1, ions%natoms
1287 read(iunit,
'(3es24.16)', advance=
'no') ions%vel(:, iatom)
1290 do iatom = 1, ions%natoms
1291 read(iunit,
'(3es24.16)', advance=
'no') ions%tot_force(:, iatom)
1301 subroutine td_dump(td, namespace, space, gr, st, hm, ks, ext_partners, iter, ierr)
1302 type(
td_t),
intent(in) :: td
1304 class(
space_t),
intent(in) :: space
1305 type(
grid_t),
intent(in) :: gr
1308 type(
v_ks_t),
intent(in) :: ks
1310 integer,
intent(in) :: iter
1311 integer,
intent(out) :: ierr
1314 integer :: err, err2
1320 if (td%restart_dump%skip())
then
1325 message(1) =
"Debug: Writing td restart."
1329 call states_elec_dump(td%restart_dump, space, st, gr, hm%kpoints, err, iter=iter)
1330 if (err /= 0) ierr = ierr + 1
1333 if (err /= 0) ierr = ierr + 1
1336 call lda_u_dump(td%restart_dump, namespace, hm%lda_u, st, gr, err)
1337 if (err /= 0) ierr = ierr + 1
1341 if (err2 /= 0) ierr = ierr + 2
1343 call pes_dump(td%pesv, namespace, td%restart_dump, st, gr, err)
1344 if (err /= 0) ierr = ierr + 4
1348 if(
associated(gfield))
then
1350 if (err /= 0) ierr = ierr + 8
1353 if (gr%der%boundaries%spiralBC)
then
1355 if (err /= 0) ierr = ierr + 8
1358 call ks%v_ks_photons%restart_dump(td%restart_dump, gr, td%dt, ierr)
1360 if (
allocated(st%frozen_rho))
then
1363 if (err /= 0) ierr = ierr + 64
1365 if (td%ions_dyn%ions_move() .or. td%ions_dyn%cell_relax())
then
1368 if (err /= 0) ierr = ierr + 128
1370 message(1) =
"Debug: Writing td restart done."
1377 subroutine td_load(restart, namespace, space, gr, st, hm, ext_partners, td, ks, ierr)
1380 class(
space_t),
intent(in) :: space
1381 type(
grid_t),
intent(in) :: gr
1385 type(
td_t),
intent(inout) :: td
1386 type(
v_ks_t),
intent(inout) :: ks
1387 integer,
intent(out) :: ierr
1389 integer :: err, err2
1395 if (restart%skip())
then
1401 message(1) =
"Debug: Reading td restart."
1405 call states_elec_load(restart, namespace, space, st, gr, hm%kpoints, st%restart_fixed_occ, &
1406 err, iter=td%iter, label =
": td")
1413 if (err2 /= 0) ierr = ierr + 2
1416 call lda_u_load(restart, hm%lda_u, st, hm%energy%dft_u, err)
1417 if (err /= 0) ierr = ierr + 1
1422 if (td%pesv%calc_spm .or. td%pesv%calc_mask .or. td%pesv%calc_flux)
then
1423 call pes_load(td%pesv, namespace, restart, st, err)
1424 if (err /= 0) ierr = ierr + 4
1429 if (
associated(gfield))
then
1434 call hm%update(gr, namespace, space, ext_partners, time = td%dt*td%iter)
1439 call ks%v_ks_photons%restart_load(restart, gr, space, ierr)
1441 if (gr%der%boundaries%spiralBC)
then
1448 if (td%ions_dyn%is_active())
then
1450 if (err /= 0) ierr = ierr + 64
1453 message(1) =
"Debug: Reading td restart done."
1459 subroutine td_load_frozen(namespace, restart, space, mesh, st, hm, ierr)
1462 class(
space_t),
intent(in) :: space
1463 class(
mesh_t),
intent(in) :: mesh
1466 integer,
intent(out) :: ierr
1472 if (restart%skip())
then
1478 message(1) =
"Debug: Reading td frozen restart."
1481 safe_allocate(st%frozen_rho(1:mesh%np, 1:st%d%nspin))
1483 safe_allocate(st%frozen_tau(1:mesh%np, 1:st%d%nspin))
1484 safe_allocate(st%frozen_gdens(1:mesh%np, 1:space%dim, 1:st%d%nspin))
1485 safe_allocate(st%frozen_ldens(1:mesh%np, 1:st%d%nspin))
1490 message(1) =
"Debug: Reading td frozen restart done."
1498 type(
td_t),
intent(in) :: td
1509 type(
td_t),
intent(inout) :: td
1510 logical,
intent(in) :: from_scratch
1514 td%from_scratch = from_scratch
Prints out to iunit a message in the form: ["InputVariable" = value] where "InputVariable" is given b...
integer, parameter, public mask_absorbing
Module implementing boundary conditions in Octopus.
This module handles the calculation mode.
This module implements a calculator for the density and defines related functions.
subroutine, public states_elec_freeze_adjust_qtot(st)
subroutine, public states_elec_freeze_redistribute_states(st, namespace, mesh, mc, nn)
subroutine, public density_calc(st, gr, density, istin, ep, vnl, phase)
Computes the density from the orbitals in st.
subroutine, public states_elec_freeze_orbitals(st, namespace, space, gr, mc, kpoints, n, family_is_mgga)
Calculate partial density for frozen orbitals.
subroutine, public dm_propagation_init_run(dmp, namespace, space, gr, ions, st, hm, mc, from_scratch)
Initialise the adiabatic states prior to running TD propagation.
subroutine, public dm_end_run(system_grp, dmp)
A set of subroutines for performing the parts of a ground state calculation with an electrons system....
subroutine, public electrons_ground_state_run(namespace, mc, gr, ions, ext_partners, st, ks, hm, outp, space, fromScratch)
Run a ground state calculation for a system of electrons.
subroutine, public energy_calc_total(namespace, space, hm, gr, st, ext_partners, iunit, full)
This subroutine calculates the total energy of the system. Basically, it adds up the KS eigenvalues,...
integer, parameter, public spin_orbit
integer, parameter, public fully_relativistic_zora
logical function, public list_has_gauge_field(partners)
type(gauge_field_t) function, pointer, public list_get_gauge_field(partners)
type(lasers_t) function, pointer, public list_get_lasers(partners)
subroutine, public forces_calculate(gr, namespace, ions, hm, ext_partners, st, ks, vhxc_old, t, dt)
subroutine, public gauge_field_load(restart, gfield, ierr)
subroutine, public gauge_field_get_force(this, gr, spin_channels, current, lrc)
subroutine, public gauge_field_dump(restart, gfield, ierr)
logical pure function, public gauge_field_is_propagated(this)
logical pure function, public gauge_field_is_used(this)
subroutine, public gauge_field_init_vec_pot(this, qtot)
real(real64), parameter, public m_zero
real(real64), parameter, public m_epsilon
real(real64), parameter, public m_one
This module implements the underlying real-space grid.
subroutine, public zvmask(mesh, hm, st)
subroutine, public hamiltonian_elec_epot_generate(this, namespace, space, gr, ions, ext_partners, st, time)
subroutine, public dvmask(mesh, hm, st)
This module defines classes and functions for interaction partners.
subroutine, public io_close(iunit, grp)
subroutine, public io_skip_header(iunit)
character(len=max_path_len) function, public io_workpath(path, namespace)
construct path name from given name and namespace
subroutine, public io_debug_on_the_fly(namespace)
check if debug mode should be enabled or disabled on the fly
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
subroutine, public ion_dynamics_dump(this, restart, ierr)
subroutine, public ion_dynamics_propagate(this, ions, time, dt, namespace)
Interface for the ion/cell dynamics.
subroutine, public ion_dynamics_load(this, restart, ierr)
subroutine, public ion_dynamics_init(this, namespace, ions, symmetrize, symm)
subroutine, public ion_dynamics_end(this)
logical pure function, public ion_dynamics_drive_ions(this)
Is the ion dynamics activated or not.
subroutine, public kick_apply(space, mesh, st, ions_dyn, ions, kick, psolver, kpoints, pcm)
Applies the delta-function electric field where k = kick%delta_strength.
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.
subroutine, public laser_write_info(lasers, namespace, dt, max_iter, iunit)
subroutine, public lda_u_dump(restart, namespace, this, st, mesh, ierr)
subroutine, public lda_u_write_u(this, iunit, namespace)
subroutine, public lda_u_load(restart, this, st, dftu_energy, ierr, occ_only, u_only)
subroutine, public lda_u_write_v(this, iunit, namespace)
integer, parameter, public dft_u_none
subroutine, public lda_u_init(this, namespace, space, level, gr, ions, st, mc, kpoints)
subroutine, public lda_u_update_occ_matrices(this, namespace, mesh, st, phase, energy, aug_overlap)
subroutine, public lda_u_freeze_occ(this)
subroutine, public lda_u_freeze_u(this)
subroutine, public lda_u_end(this)
integer, parameter, public dft_u_acbn0
This module implements fully polymorphic linked lists, and some specializations thereof.
System information (time, memory, sysname)
This module defines the meshes, which are used in Octopus.
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
subroutine, public messages_not_implemented(feature, namespace)
character(len=512), private msg
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 messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
This module handles the communicators for the various parallelization strategies.
type(namespace_t), public global_namespace
this module contains the low-level part of the output system
this module contains the output system
logical function, public parse_is_defined(namespace, name)
subroutine, public pes_calc(pes, namespace, space, mesh, st, dt, iter, der, kpoints, ext_partners, stopping)
subroutine, public pes_init(pes, namespace, space, mesh, box, st, save_iter, kpoints, abs_boundaries, ext_partners, max_iter, dt)
subroutine, public pes_output(pes, namespace, space, gr, st, iter, outp, dt, ions)
subroutine, public pes_init_write(pes, mesh, st, namespace)
subroutine, public pes_end(pes)
subroutine, public pes_load(pes, namespace, restart, st, ierr)
subroutine, public pes_dump(pes, namespace, restart, st, mesh, ierr)
subroutine, public potential_interpolation_load(potential_interpolation, namespace, restart, mesh, nspin, err2)
subroutine, public potential_interpolation_dump(potential_interpolation, restart, mesh, nspin, err2)
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
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.
subroutine, public propagation_ops_elec_kick_generalized_overlap(namespace, space, gr, st, hm)
Delta kick with a generalized (ultrasoft) overlap.
integer, parameter, public prop_aetrs
subroutine, public propagator_elec_dt(ks, namespace, space, hm, gr, st, tr, time, dt, nt, ions_dyn, ions, ext_partners, mc, outp, write_handler, scsteps, update_energy, qcchi, dmp)
Propagates st from time - dt to t. If dt<0, it propagates backwards from t+|dt| to t.
subroutine, public propagator_elec_dt_bo(scf, namespace, space, gr, ks, st, hm, ions, ext_partners, mc, iter, dt, ions_dyn, scsteps)
subroutine, public propagator_elec_init(gr, namespace, st, tr, ks_pot, have_fields, family_is_mgga_with_exc, relax_cell)
subroutine, public propagator_elec_end(tr)
This module implements the basic propagator framework.
integer, parameter, public restart_gs
integer, parameter, public restart_type_dump
logical function, public clean_stop(mpi_grp)
returns true if a file named stop exists
integer, parameter, public restart_td
integer, parameter, public restart_type_load
subroutine, public scf_set_lower_bound_is_known(scf, known_lower_bound)
Set the flag lower_bound_is_known.
subroutine, public scf_init(scf, namespace, gr, ions, st, mc, hm, space)
subroutine, public scf_end(scf)
subroutine, public scissor_init(this, namespace, space, st, mesh, kpoints, phase, gap, mc)
pure logical function, public states_are_real(st)
subroutine, public states_elec_fermi(st, namespace, mesh, compute_spin)
calculate the Fermi level for the states in this 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.
This module handles reading and writing restart information for the states_elec_t.
subroutine, public states_elec_read_user_def_orbitals(mesh, namespace, space, st)
the routine reads formulas for user-defined wavefunctions from the input file and fills the respectiv...
subroutine, public states_elec_load_frozen(restart, space, st, mesh, ierr)
subroutine, public states_elec_transform(st, namespace, space, restart, mesh, kpoints, prefix)
subroutine, public states_elec_load(restart, namespace, space, st, mesh, kpoints, fixed_occ, ierr, iter, lr, lowest_missing, label, verbose, skip)
returns in ierr: <0 => Fatal error, or nothing read =0 => read all wavefunctions >0 => could only rea...
subroutine, public states_elec_dump(restart, space, st, mesh, kpoints, ierr, iter, lr, verbose)
subroutine, public states_elec_load_spin(restart, st, ierr)
returns in ierr: <0 => Fatal error, or nothing read =0 => read all wavefunctions >0 => could only rea...
subroutine, public states_elec_dump_frozen(restart, space, st, mesh, ierr)
subroutine, public states_elec_dump_rho(restart, st, mesh, ierr, iter)
subroutine, public states_elec_dump_spin(restart, st, ierr)
This module implements the calculation of the stress tensor.
subroutine, public stress_calculate(namespace, gr, hm, st, ions, ks, ext_partners)
This computes the total stress on the lattice.
subroutine, public td_init_with_wavefunctions(td, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, outp, dmp, from_scratch)
subroutine, public td_end(td)
subroutine, public td_load_restart_from_gs(td, namespace, space, mc, gr, ext_partners, st, ks, hm)
subroutine td_print_message(td, namespace, ions, hm, iter, scsteps, etime)
subroutine td_run_zero_iter(td, namespace, space, gr, ions, st, ks, hm, ext_partners, outp, mc, dmp)
subroutine, public td_allocate_wavefunctions(td, namespace, mc, gr, ions, st, hm, space)
subroutine, public td_init(td, namespace, space, gr, ions, st, ks, hm, ext_partners, outp, dmp)
logical function, public td_get_from_scratch(td)
subroutine, public td_init_run(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, dmp, from_scratch)
subroutine td_load_frozen(namespace, restart, space, mesh, st, hm, ierr)
subroutine td_print_header(namespace)
subroutine, public td_run(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, dmp, from_scratch)
integer, parameter, public bo
subroutine td_load(restart, namespace, space, gr, st, hm, ext_partners, td, ks, ierr)
subroutine, public td_set_from_scratch(td, from_scratch)
subroutine, public td_dump(td, namespace, space, gr, st, hm, ks, ext_partners, iter, ierr)
subroutine td_read_coordinates(td, namespace, ions)
reads the pos and vel from coordinates file
subroutine, public td_init_gaugefield(td, namespace, gr, st, ks, hm, ext_partners, space)
subroutine td_update_elapsed_time(etime)
subroutine, public td_check_point(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, iter, scsteps, etime, dmp, stopping, from_scratch)
subroutine, public td_load_restart_from_td(td, namespace, space, mc, gr, ext_partners, st, ks, hm, from_scratch)
subroutine td_init_ions_and_forces(td, namespace, space, gr, ions, ext_partners, st, ks, hm, outp)
subroutine, public td_end_run(td, st, hm, dmp)
subroutine, public td_write_iter(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, kick, ks, dt, iter, mc, recalculate_gs, dmp)
subroutine, public td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, dt)
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, dmp)
Initialize files to write when prograting in time.
subroutine, public td_write_data(writ)
subroutine, public td_write_kick(outp, namespace, space, mesh, kick, ions, iter)
subroutine, public td_write_end(writ)
integer, parameter, public out_separate_forces
type(type_t), parameter, public type_cmplx
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
This module defines the unit system, used for input and output.
type(unit_t), public unit_femtosecond
Time in femtoseconds.
type(unit_system_t), public units_out
type(unit_system_t), public units_inp
the units systems for reading and writing
subroutine, public v_ks_freeze_hxc(ks)
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)
This module provides a simple timer class which can be used to trigger the writing of a restart file ...
logical function, public walltimer_alarm(comm, print)
indicate whether time is up
real(real64) function, public walltimer_get_start_time()
Return the walltimer start time.
logical function, public restart_walltime_period_alarm(comm)
pure logical function, public family_is_mgga(family, only_collinear)
Is the xc function part of the mGGA family.
logical pure function, public family_is_mgga_with_exc(xcs)
Is the xc function part of the mGGA family with an energy functional.
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.
Stores all communicators and groups.
The states_elec_t class contains all electronic wave functions.