Octopus
td.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
21module td_oct_m
27 use debug_oct_m
33 use epot_oct_m
35 use forces_oct_m
37 use global_oct_m
38 use grid_oct_m
41 use io_oct_m
43 use ions_oct_m
44 use kick_oct_m
45 use, intrinsic :: iso_fortran_env
46 use lasers_oct_m
47 use lda_u_oct_m
50 use loct_oct_m
52 use mesh_oct_m
54 use mpi_oct_m
57 use output_oct_m
59 use parser_oct_m
60 use pes_oct_m
70 use scf_oct_m
72 use space_oct_m
76 use stress_oct_m
78 use types_oct_m
79 use unit_oct_m
81 use v_ks_oct_m
84 use xc_oct_m
85
86 implicit none
87
88 private
89 public :: &
90 td_t, &
91 td_run, &
93 td_init, &
95 td_end, &
96 td_end_run, &
99 td_dump, &
107
109 integer, parameter, public :: &
110 EHRENFEST = 1, &
111 bo = 2
112
113 type td_t
114 private
115 type(propagator_base_t), public :: tr
116 type(scf_t), public :: scf
117 type(ion_dynamics_t), public :: ions_dyn
118 real(real64), public :: dt
119 integer, public :: max_iter
120 integer, public :: iter
121 logical, public :: recalculate_gs
122
123 type(pes_t), public :: pesv
124
125 integer, public :: dynamics
126 integer, public :: energy_update_iter
127 real(real64) :: scissor
128
129 logical :: freeze_occ
130 logical :: freeze_u
131 integer :: freeze_orbitals
132
133 logical :: from_scratch = .false.
134
135 type(td_write_t), public :: write_handler
136 type(restart_t) :: restart_load
137 type(restart_t) :: restart_dump
138
139 type(dmp_t) :: dmp
140 end type td_t
141
142
143contains
144
145 subroutine td_run_init()
146
147 push_sub(td_run_init)
148
149 call calc_mode_par%set_parallelization(p_strategy_states, default = .true.)
150
151 pop_sub(td_run_init)
152 end subroutine td_run_init
153
154 ! ---------------------------------------------------------
155
156 subroutine td_init(td, namespace, space, gr, ions, st, ks, hm, ext_partners, outp)
157 type(td_t), intent(inout) :: td
158 type(namespace_t), intent(in) :: namespace
159 class(space_t), intent(in) :: space
160 type(grid_t), intent(in) :: gr
161 type(ions_t), intent(inout) :: ions
162 type(states_elec_t), intent(in) :: st
163 type(v_ks_t), intent(in) :: ks
164 type(hamiltonian_elec_t), intent(in) :: hm
165 type(partner_list_t), intent(in) :: ext_partners
166 type(output_t), intent(in) :: outp
167
168 integer :: default
169 real(real64) :: propagation_time
170 type(lasers_t), pointer :: lasers
171 logical :: symmetrize
172
173 push_sub(td_init)
174
175 if (hm%pcm%run_pcm) call messages_experimental("PCM for CalculationMode = td", namespace=namespace)
176
177 symmetrize = hm%kpoints%use_symmetries .or. st%symmetrize_density
178 call ion_dynamics_init(td%ions_dyn, namespace, ions, symmetrize, gr%symmetrizer)
179
180 if (td%ions_dyn%ions_move()) then
181 if (hm%kpoints%use_symmetries) then
182 message(1) = "KPoints symmetries cannot be used with moving ions."
183 message(2) = "Please set KPointsSymmetries = no."
184 call messages_fatal(2, namespace=namespace)
185 end if
186 if (st%symmetrize_density) then
187 message(1) = "Symmetrization of the density cannot be used with moving ions."
188 message(2) = "Please set SymmetrizeDensity = no."
189 call messages_fatal(2, namespace=namespace)
190 end if
191 end if
192
193 td%iter = 0
194
195 !%Variable TDTimeStep
196 !%Type float
197 !%Section Time-Dependent::Propagation
198 !%Description
199 !% The time-step for the time propagation. For most propagators you
200 !% want to use the largest value that is possible without the
201 !% evolution becoming unstable.
202 !%
203 !% While prior versions of Octopus used to have a default time step, however,
204 !% this now needs to be systematically defined.
205 !%End
207 call parse_variable(namespace, 'TDTimeStep', -m_one, td%dt, unit = units_inp%time)
209 if (td%dt <= m_zero) then
210 write(message(1),'(a)') 'A positive value for TDTimeStep must be defined in the input file.'
211 call messages_fatal(1, namespace=namespace)
212 end if
214 call messages_print_var_value('TDTimeStep', td%dt, unit = units_out%time, namespace=namespace)
215
217 if (parse_is_defined(namespace, 'TDMaxSteps') .and. parse_is_defined(namespace, 'TDPropagationTime')) then
218 call messages_write('You cannot set TDMaxSteps and TDPropagationTime at the same time')
219 call messages_fatal(namespace=namespace)
220 end if
221
222 !%Variable TDPropagationTime
223 !%Type float
224 !%Section Time-Dependent::Propagation
225 !%Description
226 !% The length of the time propagation. You cannot set this variable
227 !% at the same time as <tt>TDMaxSteps</tt>. By default this variable will
228 !% not be used.
229 !%
230 !% The units for this variable are <math>\hbar</math>/Hartree (or <math>\hbar</math>/eV if you
231 !% selected <tt>ev_angstrom</tt> as input units). The approximate conversions to
232 !% femtoseconds are 1 fs = 41.34 <math>\hbar</math>/Hartree = 1.52 <math>\hbar</math>/eV.
233 !%End
234 call parse_variable(namespace, 'TDPropagationTime', -1.0_real64, propagation_time, unit = units_inp%time)
235
236 call messages_obsolete_variable(namespace, 'TDMaximumIter', 'TDMaxSteps')
237
238 !%Variable TDMaxSteps
239 !%Type integer
240 !%Default 1500
241 !%Section Time-Dependent::Propagation
242 !%Description
243 !% Number of time-propagation steps that will be performed. You
244 !% cannot use this variable together with <tt>TDPropagationTime</tt>.
245 !%End
246 default = 1500
247 if (propagation_time > m_zero) default = nint(propagation_time/td%dt)
248 call parse_variable(namespace, 'TDMaxSteps', default, td%max_iter)
250 if (propagation_time <= m_zero) propagation_time = td%dt*td%max_iter
251
252 call messages_print_var_value('TDPropagationTime', propagation_time, unit = units_out%time, namespace=namespace)
253 call messages_print_var_value('TDMaxSteps', td%max_iter, namespace=namespace)
254
255 if (td%max_iter < 1) then
256 write(message(1), '(a,i6,a)') "Input: '", td%max_iter, "' is not a valid value for TDMaxSteps."
257 message(2) = '(TDMaxSteps <= 1)'
258 call messages_fatal(2, namespace=namespace)
259 end if
260
261 td%iter = 0
262
263 td%dt = td%dt
264
265 lasers => list_get_lasers(ext_partners)
266
267 ! now the photoelectron stuff
268 call pes_init(td%pesv, namespace, space, gr, gr%box, st, outp%restart_write_interval, hm%kpoints, &
269 hm%abs_boundaries, ext_partners, td%max_iter, td%dt)
270
271 !%Variable TDDynamics
272 !%Type integer
273 !%Default ehrenfest
274 !%Section Time-Dependent::Propagation
275 !%Description
276 !% Type of dynamics to follow during a time propagation.
277 !% For BO, you must set <tt>MoveIons = yes</tt>.
278 !%Option ehrenfest 1
279 !% Ehrenfest dynamics.
280 !%Option bo 2
281 !% Born-Oppenheimer (Experimental).
282 !%End
283
284 call parse_variable(namespace, 'TDDynamics', ehrenfest, td%dynamics)
285 if (.not. varinfo_valid_option('TDDynamics', td%dynamics)) call messages_input_error(namespace, 'TDDynamics')
286 call messages_print_var_option('TDDynamics', td%dynamics, namespace=namespace)
287 if (td%dynamics .ne. ehrenfest) then
288 if (.not. td%ions_dyn%is_active()) then
289 message(1) = "TDDynamics=bo can only be used if MoveIons=yes or CellDynamics=yes"
290 call messages_fatal(1, namespace=namespace)
291 end if
292 end if
293
294 !%Variable RecalculateGSDuringEvolution
295 !%Type logical
296 !%Default no
297 !%Section Time-Dependent::Propagation
298 !%Description
299 !% In order to calculate some information about the system along the
300 !% evolution (e.g. projection onto the ground-state KS determinant,
301 !% projection of the TDKS spin-orbitals onto the ground-state KS
302 !% spin-orbitals), the ground-state KS orbitals are needed. If the
303 !% ionic potential changes -- that is, the ions move -- one may want
304 !% to recalculate the ground state. You may do this by setting this
305 !% variable.
306 !%
307 !% The recalculation is not done every time step, but only every
308 !% <tt>RestartWriteInterval</tt> time steps.
309 !%End
310 call parse_variable(namespace, 'RecalculateGSDuringEvolution', .false., td%recalculate_gs)
311 if (hm%lda_u_level /= dft_u_none .and. td%recalculate_gs) then
312 call messages_not_implemented("DFT+U with RecalculateGSDuringEvolution=yes", namespace=namespace)
313 end if
314
315 !%Variable TDScissor
316 !%Type float
317 !%Default 0.0
318 !%Section Time-Dependent
319 !%Description
320 !% (experimental) If set, a scissor operator will be applied in the
321 !% Hamiltonian, shifting the excitation energies by the amount
322 !% specified. By default, it is not applied.
323 !%End
324 call parse_variable(namespace, 'TDScissor', m_zero, td%scissor)
325 call messages_print_var_value('TDScissor', td%scissor, namespace=namespace)
326
327 call propagator_elec_init(gr, namespace, st, td%tr, hm%ks_pot, td%ions_dyn%is_active() .and.&
328 list_has_gauge_field(ext_partners), family_is_mgga_with_exc(ks%xc), td%ions_dyn%cell_relax())
329
330 if (associated(lasers) .and. mpi_grp_is_root(mpi_world)) then
331 call messages_print_with_emphasis(msg="Time-dependent external fields", namespace=namespace)
332 call laser_write_info(lasers%lasers, dt=td%dt, max_iter=td%max_iter, namespace=namespace)
333 call messages_print_with_emphasis(namespace=namespace)
334 end if
335
336 !%Variable TDEnergyUpdateIter
337 !%Type integer
338 !%Section Time-Dependent::Propagation
339 !%Description
340 !% This variable controls after how many iterations Octopus
341 !% updates the total energy during a time-propagation run. For
342 !% iterations where the energy is not updated, the last calculated
343 !% value is reported. If you set this variable to 1, the energy
344 !% will be calculated in each step.
345 !%End
346
347 default = 10
348 call parse_variable(namespace, 'TDEnergyUpdateIter', default, td%energy_update_iter)
349
350 if (gr%der%boundaries%spiralBC .and. hm%ep%reltype == spin_orbit) then
351 message(1) = "Generalized Bloch theorem cannot be used with spin-orbit coupling."
352 call messages_fatal(1, namespace=namespace)
353 end if
354
355 if (gr%der%boundaries%spiralBC) then
356 if (any(abs(hm%kick%easy_axis(1:2)) > m_epsilon)) then
357 message(1) = "Generalized Bloch theorem cannot be used for an easy axis not along the z direction."
358 call messages_fatal(1, namespace=namespace)
359 end if
360 end if
361
362 !%Variable TDFreezeOrbitals
363 !%Type integer
364 !%Default 0
365 !%Section Time-Dependent
366 !%Description
367 !% (Experimental) You have the possibility of "freezing" a number of orbitals during a time-propagation.
368 !% The Hartree and exchange-correlation potential due to these orbitals (which
369 !% will be the lowest-energy ones) will be added during the propagation, but the orbitals
370 !% will not be propagated.
371 !%Option sae -1
372 !% Single-active-electron approximation. This option is only valid for time-dependent
373 !% calculations (<tt>CalculationMode = td</tt>). Also, the nuclei should not move.
374 !% The idea is that all orbitals except the last one are frozen. The orbitals are to
375 !% be read from a previous ground-state calculation. The active orbital is then treated
376 !% as independent (whether it contains one electron or two) -- although it will
377 !% feel the Hartree and exchange-correlation potentials from the ground-state electronic
378 !% configuration.
379 !%
380 !% It is almost equivalent to setting <tt>TDFreezeOrbitals = N-1</tt>, where <tt>N</tt> is the number
381 !% of orbitals, but not completely.
382 !%End
383 call parse_variable(namespace, 'TDFreezeOrbitals', 0, td%freeze_orbitals)
384
385 if (td%freeze_orbitals /= 0) then
386 call messages_experimental('TDFreezeOrbitals', namespace=namespace)
387
388 if (hm%lda_u_level /= dft_u_none) then
389 call messages_not_implemented('TDFreezeOrbitals with DFT+U', namespace=namespace)
390 end if
391 end if
392
393 !%Variable TDDMPropagation
394 !%Type integer
395 !%Default no_propagation
396 !%Section Time-Dependent
397 !%Description
398 !% Decides whether to propagate the density matrix, in the spectral basis,
399 !% together with the KS orbitals.
400 !% The resulting time-depented orbilas are to be considered the natural orbitals
401 !% of the denstiy matrix and with the corresponding eigenvalues the occupation numbers.
402 !% In order to work properly this method requires an number of empty states
403 !% specified with the option "ExtraStates".
404 !% This is an experimental feature.
405 !%Option no_propagation 01
406 !% No density time propagation.
407 !%Option master_equation 02
408 !% Density time propagation with the Lindblad master equation.
409 !%End
410
411 call parse_variable(global_namespace, 'TDDMPropagation', option__tddmpropagation__no_propagation, td%dmp%calculation_mode)
412 if (.not. varinfo_valid_option('TDDMPropagation', td%dmp%calculation_mode)) then
413 call messages_input_error(global_namespace, 'TDDMPropagation')
414 endif
415 call messages_print_var_option('TDDMPropagation', td%dmp%calculation_mode, namespace=namespace)
416
417 if (td%dmp%calculation_mode /= option__tddmpropagation__no_propagation) then
418 call messages_experimental('TDDMPropagation', namespace=namespace)
419 call td%dmp%init(namespace, st)
420 end if
421
422 pop_sub(td_init)
423 nullify(lasers)
424
425 end subroutine td_init
426
427 ! ---------------------------------------------------------
428 subroutine td_init_run(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, from_scratch)
429 type(td_t), intent(inout) :: td
430 type(namespace_t), intent(in) :: namespace
431 type(multicomm_t), intent(inout) :: mc
432 type(grid_t), intent(inout) :: gr
433 type(ions_t), intent(inout) :: ions
434 type(states_elec_t), intent(inout) :: st
435 type(v_ks_t), intent(inout) :: ks
436 type(hamiltonian_elec_t), intent(inout) :: hm
437 type(partner_list_t), intent(in) :: ext_partners
438 type(output_t), intent(inout) :: outp
439 type(electron_space_t), intent(in) :: space
440 logical, intent(inout) :: from_scratch
441 push_sub(td_init_run)
442
443 ! NOTE: please do not change code in this function, but only in functions
444 ! called from here because the logic of this function is replicated in the
445 ! multisystem framework in different places
446
447 call td_allocate_wavefunctions(td, namespace, mc, gr, ions, st, hm, space)
448 call td_init_gaugefield(td, namespace, gr, st, ks, hm, ext_partners, space)
449
450 td%from_scratch = from_scratch
451
452 if (.not. td%from_scratch) then
453 call td_load_restart_from_td(td, namespace, space, mc, gr, ext_partners, st, ks, hm, td%from_scratch)
454 if (td%from_scratch) then
455 message(1) = "Unable to read time-dependent restart information: Starting from scratch"
456 call messages_warning(1, namespace=namespace)
457 end if
458 end if
459
460 if (td%iter >= td%max_iter) then
461 message(1) = "All requested iterations have already been done. Use FromScratch = yes if you want to redo them."
462 call messages_info(1, namespace=namespace)
464 td%iter = td%iter + 1
465 if ((td%ions_dyn%is_active()) .and. td%recalculate_gs) call restart_end(td%restart_load)
466 pop_sub(td_init_run)
467 return
468 end if
469
470 if (td%from_scratch) then
471 call td_load_restart_from_gs(td, namespace, space, mc, gr, ext_partners, st, ks, hm)
472 end if
473
474 call td_init_with_wavefunctions(td, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, outp, td%from_scratch)
475
476 if (td%dmp%calculation_mode /= option__tddmpropagation__no_propagation) then
477 call dm_propagation_init_run(td%dmp%adiabatic_st, namespace, space, gr, st, hm, mc)
478 end if
479
480 pop_sub(td_init_run)
481 end subroutine td_init_run
482
483 ! ---------------------------------------------------------
484 subroutine td_allocate_wavefunctions(td, namespace, mc, gr, ions, st, hm, space)
485 type(td_t), intent(inout) :: td
486 type(namespace_t), intent(in) :: namespace
487 type(multicomm_t), intent(inout) :: mc
488 type(grid_t), intent(inout) :: gr
489 type(ions_t), intent(inout) :: ions
490 type(states_elec_t), intent(inout) :: st
491 type(hamiltonian_elec_t), intent(inout) :: hm
492 class(space_t), intent(in) :: space
493
495
496 ! Allocate wavefunctions during time-propagation
497 if (td%dynamics == ehrenfest) then
498 !Note: this is not really clean to do this
499 if (hm%lda_u_level /= dft_u_none .and. states_are_real(st)) then
500 call lda_u_end(hm%lda_u)
501 !complex wfs are required for Ehrenfest
502 call states_elec_allocate_wfns(st, gr, type_cmplx, packed=.true.)
503 call lda_u_init(hm%lda_u, namespace, space, hm%lda_u_level, gr, ions, st, mc, &
504 hm%kpoints, hm%phase%is_allocated())
505 else
506 !complex wfs are required for Ehrenfest
507 call states_elec_allocate_wfns(st, gr, type_cmplx, packed=.true.)
508 end if
509 else
510 call states_elec_allocate_wfns(st, gr, packed=.true.)
511 call scf_init(td%scf, namespace, gr, ions, st, mc, hm, space)
512 end if
513
515 end subroutine td_allocate_wavefunctions
516
517 ! ---------------------------------------------------------
518 subroutine td_init_gaugefield(td, namespace, gr, st, ks, hm, ext_partners, space)
519 type(td_t), intent(inout) :: td
520 type(namespace_t), intent(in) :: namespace
521 type(grid_t), intent(inout) :: gr
522 type(states_elec_t), intent(inout) :: st
523 type(v_ks_t), intent(inout) :: ks
524 type(hamiltonian_elec_t), intent(inout) :: hm
525 type(partner_list_t), intent(in) :: ext_partners
526 class(space_t), intent(in) :: space
527
528 type(gauge_field_t), pointer :: gfield
529
530 push_sub(td_init_gaugefield)
531
532 gfield => list_get_gauge_field(ext_partners)
533 if(associated(gfield)) then
534 if (gauge_field_is_used(gfield)) then
535 !if the gauge field is applied, we need to tell v_ks to calculate the current
536 call v_ks_calculate_current(ks, .true.)
537
538 ! initialize the vector field and update the hamiltonian
539 call gauge_field_init_vec_pot(gfield, st%qtot)
540 call hm%update(gr, namespace, space, ext_partners, time = td%dt*td%iter)
541
542 end if
543 end if
544
545 pop_sub(td_init_gaugefield)
546 end subroutine td_init_gaugefield
547
548 ! ---------------------------------------------------------
549 subroutine td_end(td)
550 type(td_t), intent(inout) :: td
551
552 push_sub(td_end)
553
554 call pes_end(td%pesv)
555 call propagator_elec_end(td%tr) ! clean the evolution method
556 call ion_dynamics_end(td%ions_dyn)
557
558 if (td%dmp%calculation_mode /= option__tddmpropagation__no_propagation) then
559 call states_elec_end(td%dmp%adiabatic_st)
560 endif
561
562 if (td%dynamics == bo) call scf_end(td%scf)
563 pop_sub(td_end)
564
565 end subroutine td_end
566
567 ! ---------------------------------------------------------
568 subroutine td_end_run(td, st, hm)
569 type(td_t), intent(inout) :: td
570 type(states_elec_t), intent(inout) :: st
571 type(hamiltonian_elec_t), intent(inout) :: hm
572
573 push_sub(td_end_run)
574
575 if (st%pack_states .and. hm%apply_packed()) call st%unpack()
576
577 call restart_end(td%restart_dump)
578 call td_write_end(td%write_handler)
579
580 ! free memory
582 if ((td%ions_dyn%is_active()).and. td%recalculate_gs) call restart_end(td%restart_load)
583
584 pop_sub(td_end_run)
585 end subroutine td_end_run
586
587 ! ---------------------------------------------------------
588 subroutine td_run(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, from_scratch)
589 type(td_t), intent(inout) :: td
590 type(namespace_t), intent(in) :: namespace
591 type(multicomm_t), intent(inout) :: mc
592 type(grid_t), intent(inout) :: gr
593 type(ions_t), intent(inout) :: ions
594 type(states_elec_t), intent(inout) :: st
595 type(v_ks_t), intent(inout) :: ks
596 type(hamiltonian_elec_t), intent(inout) :: hm
597 type(partner_list_t), intent(in) :: ext_partners
598 type(output_t), intent(inout) :: outp
599 type(electron_space_t), intent(in) :: space
600 logical, intent(inout) :: from_scratch
601
602 logical :: stopping
603 integer :: iter, scsteps
604 real(real64) :: etime
605
606 push_sub(td_run)
607
608 etime = loct_clock()
609 ! This is the time-propagation loop. It starts at t=0 and finishes
610 ! at td%max_iter*dt. The index i runs from 1 to td%max_iter, and
611 ! step "iter" means propagation from (iter-1)*dt to iter*dt.
612 propagation: do iter = td%iter, td%max_iter
613
614 stopping = clean_stop(mc%master_comm) .or. walltimer_alarm(mc%master_comm)
615
616 call profiling_in("TIME_STEP")
617
618 if (iter > 1) then
619 if (((iter-1)*td%dt <= hm%kick%time) .and. (iter*td%dt > hm%kick%time)) then
620 if (.not. hm%pcm%localf) then
621 call kick_apply(space, gr, st, td%ions_dyn, ions, hm%kick, hm%psolver, hm%kpoints)
622 else
623 call kick_apply(space, gr, st, td%ions_dyn, ions, hm%kick, hm%psolver, hm%kpoints, pcm = hm%pcm)
624 end if
625 call td_write_kick(outp, namespace, space, gr, hm%kick, ions, iter)
626 !We activate the sprial BC only after the kick,
627 !to be sure that the first iteration corresponds to the ground state
628 if (gr%der%boundaries%spiralBC) gr%der%boundaries%spiral = .true.
629 end if
630 end if
631
632 ! time iterate the system, one time step.
633 select case (td%dynamics)
634 case (ehrenfest)
635 call propagator_elec_dt(ks, namespace, space, hm, gr, st, td%tr, iter*td%dt, td%dt, iter, td%ions_dyn, &
636 ions, ext_partners, mc, outp, td%write_handler, scsteps = scsteps, &
637 update_energy = (mod(iter, td%energy_update_iter) == 0) .or. (iter == td%max_iter))
638 case (bo)
639 call propagator_elec_dt_bo(td%scf, namespace, space, gr, ks, st, hm, ions, ext_partners, mc, outp, iter, &
640 td%dt, td%ions_dyn, scsteps)
641 end select
643 if (td%dmp%calculation_mode /= option__tddmpropagation__no_propagation) then
644 call dm_propagation_run(td%dmp, namespace, space, gr, ions, st, mc, hm, ks, iter, td%dt, ext_partners, &
645 update_energy = (mod(iter, td%energy_update_iter) == 0) .or. (iter == td%max_iter))
646 end if
647
648 !Apply mask absorbing boundaries
649 if (hm%abs_boundaries%abtype == mask_absorbing) then
650 if (states_are_real(st)) then
651 call dvmask(gr, hm, st)
652 else
653 call zvmask(gr, hm, st)
654 end if
655 end if
656
657 !Photoelectron stuff
658 if (td%pesv%calc_spm .or. td%pesv%calc_mask .or. td%pesv%calc_flux) then
659 call pes_calc(td%pesv, namespace, space, gr, st, td%dt, iter, gr%der, hm%kpoints, ext_partners, stopping)
660 end if
662 call td_write_iter(td%write_handler, namespace, space, outp, gr, st, hm, ions, ext_partners, &
663 hm%kick, ks, td%dt, iter, mc, td%recalculate_gs)
664
665 ! write down data
666 call td_check_point(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, &
667 iter, scsteps, etime, stopping, from_scratch)
668
669 ! check if debug mode should be enabled or disabled on the fly
670 call io_debug_on_the_fly(namespace)
671
672 call profiling_out("TIME_STEP")
673 if (stopping) exit
674
675 end do propagation
676
677 pop_sub(td_run)
678 end subroutine td_run
679
680 subroutine td_print_header(namespace)
681 type(namespace_t), intent(in) :: namespace
682
683 push_sub(td_print_header)
684
685 write(message(1), '(a7,1x,a14,a14,a10,a17)') 'Iter ', 'Time ', 'Energy ', 'SC Steps', 'Elapsed Time '
686
687 call messages_info(1, namespace=namespace)
688 call messages_print_with_emphasis(namespace=namespace)
689
690 pop_sub(td_print_header)
691 end subroutine td_print_header
692
693 ! ---------------------------------------------------------
694 subroutine td_check_point(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, &
695 iter, scsteps, etime, stopping, from_scratch)
696 type(td_t), intent(inout) :: td
697 type(namespace_t), intent(in) :: namespace
698 type(multicomm_t), intent(in) :: mc
699 type(grid_t), intent(inout) :: gr
700 type(ions_t), intent(inout) :: ions
701 type(states_elec_t), intent(inout) :: st
702 type(v_ks_t), intent(inout) :: ks
703 type(hamiltonian_elec_t), intent(inout) :: hm
704 type(partner_list_t), intent(in) :: ext_partners
705 type(output_t), intent(in) :: outp
706 type(electron_space_t), intent(in) :: space
707 integer, intent(in) :: iter
708 integer, intent(in) :: scsteps
709 real(real64), intent(inout) :: etime
710 logical, intent(in) :: stopping
711 logical, intent(inout) :: from_scratch
712
713 integer :: ierr
714
715 push_sub(td_check_point)
716
717 call td_print_message(td, namespace, ions, hm, iter, scsteps, etime)
718
719 if (outp%anything_now(iter)) then ! output
720 call td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, td%dt)
721 end if
722
723 if (mod(iter, outp%restart_write_interval) == 0 .or. iter == td%max_iter .or. stopping) then ! restart
724 !if (iter == td%max_iter) outp%iter = ii - 1
725 call td_write_data(td%write_handler)
726 call td_dump(td, namespace, space, gr, st, hm, ks, ext_partners, iter, ierr)
727 if (ierr /= 0) then
728 message(1) = "Unable to write time-dependent restart information."
729 call messages_warning(1, namespace=namespace)
730 end if
731
732 call pes_output(td%pesv, namespace, space, gr, st, iter, outp, td%dt, ions)
733
734 if ((td%ions_dyn%is_active()) .and. td%recalculate_gs) then
735 call messages_print_with_emphasis(msg='Recalculating the ground state.', namespace=namespace)
736 from_scratch = .false.
738 call electrons_ground_state_run(namespace, mc, gr, ions, ext_partners, st, ks, hm, outp, space, from_scratch)
739 call states_elec_allocate_wfns(st, gr, packed=.true.)
740 call td_load(td%restart_load, namespace, space, gr, st, hm, ext_partners, td, ks, ierr)
741 if (ierr /= 0) then
742 message(1) = "Unable to load TD states."
743 call messages_fatal(1, namespace=namespace)
744 end if
745 call density_calc(st, gr, st%rho)
746 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, &
747 calc_eigenval=.true., time = iter*td%dt, calc_energy=.true.)
748 call forces_calculate(gr, namespace, ions, hm, ext_partners, st, ks, t = iter*td%dt, dt = td%dt)
749 assert(.not. td%ions_dyn%cell_relax())
750 call messages_print_with_emphasis(msg="Time-dependent simulation proceeds", namespace=namespace)
751 call td_print_header(namespace)
752 end if
753 end if
754
755 pop_sub(td_check_point)
756 end subroutine td_check_point
757
758 ! ---------------------------------------------------------
759 subroutine td_print_message(td, namespace, ions, hm, iter, scsteps, etime)
760 type(td_t), intent(inout) :: td
761 type(namespace_t), intent(in) :: namespace
762 type(ions_t), intent(inout) :: ions
763 type(hamiltonian_elec_t), intent(inout) :: hm
764 integer, intent(in) :: iter
765 integer, intent(in) :: scsteps
766 real(real64), intent(inout) :: etime
767
768 push_sub(td_print_message)
769
770 write(message(1), '(i7,1x,2f14.6,i10,f14.3)') iter, units_from_atomic(units_out%time, iter*td%dt), &
771 units_from_atomic(units_out%energy, hm%energy%total + ions%kinetic_energy), scsteps, &
772 loct_clock() - etime
773 call messages_info(1, namespace=namespace)
774 call td_update_elapsed_time(etime)
775
776 pop_sub(td_print_message)
777 end subroutine td_print_message
778
779 ! ---------------------------------------------------------
780 subroutine td_update_elapsed_time(etime)
781 real(real64), intent(inout) :: etime
782
783 push_sub(td_update_elapsed_time)
784
785 etime = loct_clock()
786
788 end subroutine td_update_elapsed_time
789
790 ! ---------------------------------------------------------
791 subroutine td_init_with_wavefunctions(td, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, outp, from_scratch)
792 type(td_t), intent(inout) :: td
793 type(namespace_t), intent(in) :: namespace
794 type(electron_space_t), intent(in) :: space
795 type(multicomm_t), intent(in) :: mc
796 type(grid_t), intent(inout) :: gr
797 type(ions_t), intent(inout) :: ions
798 type(partner_list_t), intent(in) :: ext_partners
799 type(states_elec_t), target, intent(inout) :: st
800 type(v_ks_t), intent(inout) :: ks
801 type(hamiltonian_elec_t), intent(inout) :: hm
802 type(output_t), intent(inout) :: outp
803 logical, intent(in) :: from_scratch
804
805 integer :: ierr
806 real(real64) :: x
807 real(real64) :: ndinitial(space%dim)
808 logical :: freeze_hxc, freeze_occ, freeze_u
809 type(restart_t) :: restart, restart_frozen
810 type(gauge_field_t), pointer :: gfield
811 type(lasers_t), pointer :: lasers
813
814 !We activate the sprial BC only after the kick,
815 !to be sure that the first iteration corresponds to the ground state
816 if (gr%der%boundaries%spiralBC) then
817 if ((td%iter-1)*td%dt > hm%kick%time) then
818 gr%der%boundaries%spiral = .true.
819 end if
820 hm%vnl%spin => st%spin
821 hm%phase%spin => st%spin
822 !We fill st%spin. In case of restart, we read it in td_load
823 if (from_scratch) call states_elec_fermi(st, namespace, gr)
824 end if
825
826 if (from_scratch) then
827 ! Initialize the occupation matrices and U for DFT+U
828 ! This must be called before parsing TDFreezeOccupations and TDFreezeU
829 ! in order that the code does properly the initialization.
830 call lda_u_update_occ_matrices(hm%lda_u, namespace, gr, st, hm%hm_base, hm%phase, hm%energy)
831 end if
832
833 if (td%freeze_orbitals > 0) then
834 if (from_scratch) then
835 ! In this case, we first freeze the orbitals, then calculate the Hxc potential.
836 call states_elec_freeze_orbitals(st, namespace, space, gr, mc, hm%kpoints, &
837 td%freeze_orbitals, family_is_mgga(ks%xc_family))
838 else
839 call restart_init(restart, namespace, restart_td, restart_type_load, mc, ierr, mesh=gr)
840 if (ierr == 0) then
841 call td_load_frozen(namespace, restart, space, gr, st, hm, ierr)
842 end if
843 if (ierr /= 0) then
844 td%iter = 0
845 message(1) = "Unable to read frozen restart information."
846 call messages_fatal(1, namespace=namespace)
847 end if
848 call restart_end(restart)
849 end if
850 write(message(1),'(a,i4,a,i4,a)') 'Info: The lowest', td%freeze_orbitals, &
851 ' orbitals have been frozen.', st%nst, ' will be propagated.'
852 call messages_info(1, namespace=namespace)
854 call density_calc(st, gr, st%rho)
855 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval=.true., time = td%iter*td%dt)
856 else if (td%freeze_orbitals < 0) then
857 ! This means SAE approximation. We calculate the Hxc first, then freeze all
858 ! orbitals minus one.
859 write(message(1),'(a)') 'Info: The single-active-electron approximation will be used.'
860 call messages_info(1, namespace=namespace)
861 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval=.true., time = td%iter*td%dt)
862 if (from_scratch) then
863 call states_elec_freeze_orbitals(st, namespace, space, gr, mc, hm%kpoints, st%nst-1, family_is_mgga(ks%xc_family))
864 else
865 call messages_not_implemented("TDFreezeOrbials < 0 with FromScratch=no", namespace=namespace)
866 end if
868 call v_ks_freeze_hxc(ks)
869 call density_calc(st, gr, st%rho)
870 else
871 ! Normal run.
872 call density_calc(st, gr, st%rho)
873 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval=.true., time = td%iter*td%dt)
874 end if
875
876 !%Variable TDFreezeHXC
877 !%Type logical
878 !%Default no
879 !%Section Time-Dependent
880 !%Description
881 !% The electrons are evolved as independent particles feeling the Hartree and
882 !% exchange-correlation potentials from the ground-state electronic configuration.
883 !%End
884 call parse_variable(namespace, 'TDFreezeHXC', .false., freeze_hxc)
885 if (freeze_hxc) then
886 write(message(1),'(a)') 'Info: Freezing Hartree and exchange-correlation potentials.'
887 call messages_info(1, namespace=namespace)
888
889 if (.not. from_scratch) then
890
891 call restart_init(restart_frozen, namespace, restart_gs, restart_type_load, mc, ierr, mesh=gr, exact=.true.)
892 call states_elec_load(restart_frozen, namespace, space, st, gr, hm%kpoints, ierr, label = ": gs")
893 call states_elec_transform(st, namespace, space, restart_frozen, gr, hm%kpoints)
894 call restart_end(restart_frozen)
895
896 call density_calc(st, gr, st%rho)
897 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval=.true., time = td%iter*td%dt)
898
899 call restart_init(restart_frozen, namespace, restart_td, restart_type_load, mc, ierr, mesh=gr)
900 call states_elec_load(restart_frozen, namespace, space, st, gr, hm%kpoints, ierr, iter=td%iter, label = ": td")
901 call restart_end(restart_frozen)
902 call hm%ks_pot%run_zero_iter(td%tr%vks_old)
903
904 end if
905
906 call v_ks_freeze_hxc(ks)
907
908 end if
909
910 x = minval(st%eigenval(st%st_start, :))
911 if (st%parallel_in_states) then
912 call st%mpi_grp%bcast(x, 1, mpi_double_precision, 0)
913 end if
914 call hm%update_span(gr%spacing(1:space%dim), x, namespace)
915 ! initialize Fermi energy
916 call states_elec_fermi(st, namespace, gr, compute_spin = .not. gr%der%boundaries%spiralBC)
917 call energy_calc_total(namespace, space, hm, gr, st, ext_partners)
918
919 !%Variable TDFreezeDFTUOccupations
920 !%Type logical
921 !%Default no
922 !%Section Time-Dependent
923 !%Description
924 !% The occupation matrices than enters in the DFT+U potential
925 !% are not evolved during the time evolution.
926 !%End
927 call parse_variable(namespace, 'TDFreezeDFTUOccupations', .false., freeze_occ)
928 if (freeze_occ) then
929 write(message(1),'(a)') 'Info: Freezing DFT+U occupation matrices that enters in the DFT+U potential.'
930 call messages_info(1, namespace=namespace)
931 call lda_u_freeze_occ(hm%lda_u)
932
933 !In this case we should reload GS wavefunctions
934 if (hm%lda_u_level /= dft_u_none .and. .not. from_scratch) then
935 call restart_init(restart_frozen, namespace, restart_gs, restart_type_load, mc, ierr, mesh=gr)
936 call lda_u_load(restart_frozen, hm%lda_u, st, hm%energy%dft_u, ierr, occ_only = .true.)
937 call restart_end(restart_frozen)
938 end if
939 end if
940
941 !%Variable TDFreezeU
942 !%Type logical
943 !%Default no
944 !%Section Time-Dependent
945 !%Description
946 !% The effective U of DFT+U is not evolved during the time evolution.
947 !%End
948 call parse_variable(namespace, 'TDFreezeU', .false., freeze_u)
949 if (freeze_u) then
950 write(message(1),'(a)') 'Info: Freezing the effective U of DFT+U.'
951 call messages_info(1, namespace=namespace)
952 call lda_u_freeze_u(hm%lda_u)
953
954 !In this case we should reload GS wavefunctions
955 if (hm%lda_u_level == dft_u_acbn0 .and. .not. from_scratch) then
956 call restart_init(restart_frozen, namespace, restart_gs, restart_type_load, mc, ierr, mesh=gr)
957 call lda_u_load(restart_frozen, hm%lda_u, st, hm%energy%dft_u, ierr, u_only = .true.)
958 call restart_end(restart_frozen)
959 write(message(1),'(a)') 'Loaded GS effective U of DFT+U'
960 call messages_info(1, namespace=namespace)
961 call lda_u_write_u(hm%lda_u, namespace=namespace)
962 call lda_u_write_v(hm%lda_u, namespace=namespace)
963 end if
964 end if
965
966 ! This needs to be called before the calculation of the forces,
967 ! as we need to test of we output the forces or not
968 call td_write_init(td%write_handler, namespace, space, outp, gr, st, hm, ions, ext_partners, &
969 ks, td%ions_dyn%is_active(), &
970 list_has_gauge_field(ext_partners), hm%kick, td%iter, td%max_iter, td%dt, mc)
971
972 ! Resets the nondipole integration after laser-file has been written.
973 lasers => list_get_lasers(ext_partners)
974 if(associated(lasers)) then
975 if (lasers_with_nondipole_field(lasers)) then
976 ndinitial(1:space%dim)=m_zero
977 call lasers_set_nondipole_parameters(lasers,ndinitial,m_zero)
978 end if
979 end if
980 nullify(lasers)
981
982 call td_init_ions_and_forces(td, namespace, space, gr, ions, ext_partners, st, ks, hm, outp)
983
984 if (td%scissor > m_epsilon) then
985 call scissor_init(hm%scissor, namespace, space, st, gr, hm%d, hm%kpoints, hm%phase, td%scissor, mc)
986 end if
987
988 if (td%iter == 0) call td_run_zero_iter(td, namespace, space, gr, ions, st, ks, hm, ext_partners, outp, mc)
989
990 gfield => list_get_gauge_field(ext_partners)
991 if(associated(gfield)) then
992 if (gauge_field_is_propagated(gfield)) then
993 if(ks%xc%kernel_lrc_alpha > m_epsilon) then
994 call gauge_field_get_force(gfield, gr, st%d%spin_channels, st%current, ks%xc%kernel_lrc_alpha)
995 call messages_experimental('TD-LRC kernel')
996 else
997 call gauge_field_get_force(gfield, gr, st%d%spin_channels, st%current)
998 endif
999 endif
1000 end if
1001
1002 !call td_check_trotter(td, sys, h)
1003 td%iter = td%iter + 1
1004
1005 call restart_init(td%restart_dump, namespace, restart_td, restart_type_dump, mc, ierr, mesh=gr)
1006 if (td%ions_dyn%is_active() .and. td%recalculate_gs) then
1007 ! We will also use the TD restart directory as temporary storage during the time propagation
1008 call restart_init(td%restart_load, namespace, restart_td, restart_type_load, mc, ierr, mesh=gr)
1009 end if
1010
1011 call messages_print_with_emphasis(msg="Time-Dependent Simulation", namespace=namespace)
1012 call td_print_header(namespace)
1013
1014 if (td%pesv%calc_spm .or. td%pesv%calc_mask .and. from_scratch) then
1015 call pes_init_write(td%pesv,gr,st, namespace)
1016 end if
1017
1018 if (st%pack_states .and. hm%apply_packed()) call st%pack()
1019
1021 end subroutine td_init_with_wavefunctions
1022
1023 ! ---------------------------------------------------------
1024 subroutine td_init_ions_and_forces(td, namespace, space, gr, ions, ext_partners, st, ks, hm, outp)
1025 type(td_t), intent(inout) :: td
1026 type(namespace_t), intent(in) :: namespace
1027 type(electron_space_t), intent(in) :: space
1028 type(grid_t), intent(inout) :: gr
1029 type(ions_t), intent(inout) :: ions
1030 type(partner_list_t), intent(in) :: ext_partners
1031 type(states_elec_t), target, intent(inout) :: st
1032 type(v_ks_t), intent(inout) :: ks
1033 type(hamiltonian_elec_t), intent(inout) :: hm
1034 type(output_t), intent(inout) :: outp
1035
1036 push_sub(td_init_ions_and_forces)
1037
1038 ! Calculate initial forces and kinetic energy
1039 if (td%ions_dyn%ions_move()) then
1040 if (td%iter > 0) then
1041 call td_read_coordinates(td, namespace, ions)
1042 if (ion_dynamics_drive_ions(td%ions_dyn)) then
1043 call ion_dynamics_propagate(td%ions_dyn, ions, td%iter*td%dt, td%dt, namespace)
1044 end if
1045 call hamiltonian_elec_epot_generate(hm, namespace, space, gr, ions, ext_partners, st, time = td%iter*td%dt)
1046 ! recompute potential because the ions have moved
1047 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval=.true., time = td%iter*td%dt)
1048 end if
1049
1050 call forces_calculate(gr, namespace, ions, hm, ext_partners, st, ks, t = td%iter*td%dt, dt = td%dt)
1051
1052 call ions%update_kinetic_energy()
1053 else
1054 if (outp%what(option__output__forces) .or. td%write_handler%out(out_separate_forces)%write) then
1055 call forces_calculate(gr, namespace, ions, hm, ext_partners, st, ks, t = td%iter*td%dt, dt = td%dt)
1056 end if
1057 end if
1058
1059 if (outp%what(option__output__stress) .or. td%ions_dyn%cell_relax()) then
1060 call stress_calculate(namespace, gr, hm, st, ions, ks, ext_partners)
1061 if (td%ions_dyn%cell_relax()) then
1062 call td%ions_dyn%update_stress(ions%space, st%stress_tensors%total, ions%latt%rlattice, ions%latt%rcell_volume)
1063 end if
1064 end if
1065
1067 end subroutine td_init_ions_and_forces
1068
1069 ! ---------------------------------------------------------
1070 subroutine td_load_restart_from_td(td, namespace, space, mc, gr, ext_partners, st, ks, hm, from_scratch)
1071 type(td_t), intent(inout) :: td
1072 type(namespace_t), intent(in) :: namespace
1073 class(space_t), intent(in) :: space
1074 type(multicomm_t), intent(in) :: mc
1075 type(grid_t), intent(inout) :: gr
1076 type(partner_list_t), intent(in) :: ext_partners
1077 type(states_elec_t), target, intent(inout) :: st
1078 type(v_ks_t), intent(inout) :: ks
1079 type(hamiltonian_elec_t), intent(inout) :: hm
1080 logical, intent(inout) :: from_scratch
1081
1082 integer :: ierr
1083 type(restart_t) :: restart
1084
1085 push_sub(td_load_restart_from_td)
1086
1087 !We redistribute the states before the restarting
1088 if (td%freeze_orbitals > 0) then
1089 call states_elec_freeze_redistribute_states(st, namespace, gr, mc, td%freeze_orbitals)
1090 end if
1091
1092 call restart_init(restart, namespace, restart_td, restart_type_load, mc, ierr, mesh=gr)
1093 if (ierr == 0) then
1094 call td_load(restart, namespace, space, gr, st, hm, ext_partners, td, ks, ierr)
1095 end if
1096 call restart_end(restart)
1097 if (ierr /= 0) then
1098 from_scratch = .true.
1099 td%iter = 0
1100 end if
1101
1103 end subroutine td_load_restart_from_td
1104
1105 ! ---------------------------------------------------------
1106 subroutine td_load_restart_from_gs(td, namespace, space, mc, gr, ext_partners, st, ks, hm)
1107 type(td_t), intent(inout) :: td
1108 type(namespace_t), intent(in) :: namespace
1109 class(space_t), intent(in) :: space
1110 type(multicomm_t), intent(in) :: mc
1111 type(grid_t), intent(inout) :: gr
1112 type(partner_list_t), intent(in) :: ext_partners
1113 type(states_elec_t), target, intent(inout) :: st
1114 type(v_ks_t), intent(inout) :: ks
1115 type(hamiltonian_elec_t), intent(inout) :: hm
1116
1117 integer :: ierr
1118 type(restart_t) :: restart
1119
1120 push_sub(td_load_restart_from_gs)
1121
1122 call restart_init(restart, namespace, restart_gs, restart_type_load, mc, ierr, mesh=gr, exact=.true.)
1123
1124 if (.not. st%only_userdef_istates) then
1125 if (ierr == 0) then
1126 call states_elec_load(restart, namespace, space, st, gr, hm%kpoints, ierr, label = ": gs")
1127 end if
1128 if (ierr /= 0) then
1129 message(1) = 'Unable to read ground-state wavefunctions.'
1130 call messages_fatal(1, namespace=namespace)
1131 end if
1132 end if
1133
1134 ! check if we should deploy user-defined wavefunctions.
1135 ! according to the settings in the input file the routine
1136 ! overwrites orbitals that were read from restart/gs
1137 if (parse_is_defined(namespace, 'UserDefinedStates')) then
1138 call states_elec_read_user_def_orbitals(gr, namespace, space, st)
1139 end if
1140
1141 call states_elec_transform(st, namespace, space, restart, gr, hm%kpoints)
1142 call restart_end(restart)
1143
1145 end subroutine td_load_restart_from_gs
1146
1147 ! ---------------------------------------------------------
1148 subroutine td_run_zero_iter(td, namespace, space, gr, ions, st, ks, hm, ext_partners, outp, mc)
1149 type(td_t), intent(inout) :: td
1150 type(namespace_t), intent(in) :: namespace
1151 type(electron_space_t), intent(in) :: space
1152 type(grid_t), intent(inout) :: gr
1153 type(ions_t), intent(inout) :: ions
1154 type(states_elec_t), intent(inout) :: st
1155 type(v_ks_t), intent(inout) :: ks
1156 type(hamiltonian_elec_t), intent(inout) :: hm
1157 type(partner_list_t), intent(in) :: ext_partners
1158 type(output_t), intent(in) :: outp
1159 type(multicomm_t), intent(in) :: mc
1160
1161 push_sub(td_run_zero_iter)
1162
1163 call td_write_iter(td%write_handler, namespace, space, outp, gr, st, hm, ions, ext_partners, &
1164 hm%kick, ks, td%dt, 0, mc, td%recalculate_gs)
1165
1166 ! I apply the delta electric field *after* td_write_iter, otherwise the
1167 ! dipole matrix elements in write_proj are wrong
1168 if (abs(hm%kick%time) <= m_epsilon) then
1169 if (.not. hm%pcm%localf) then
1170 call kick_apply(space, gr, st, td%ions_dyn, ions, hm%kick, hm%psolver, hm%kpoints)
1171 else
1172 call kick_apply(space, gr, st, td%ions_dyn, ions, hm%kick, hm%psolver, hm%kpoints, pcm = hm%pcm)
1173 end if
1174 call td_write_kick(outp, namespace, space, gr, hm%kick, ions, 0)
1175
1176 !We activate the sprial BC only after the kick
1177 if (gr%der%boundaries%spiralBC) then
1178 gr%der%boundaries%spiral = .true.
1179 end if
1180 end if
1181 call hm%ks_pot%run_zero_iter(td%tr%vks_old)
1182
1183 if (any(outp%output_interval > 0)) then
1184 call td_write_data(td%write_handler)
1185 call td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, 0)
1186 end if
1187
1188 pop_sub(td_run_zero_iter)
1189 end subroutine td_run_zero_iter
1190
1191
1192 ! ---------------------------------------------------------
1194 subroutine td_read_coordinates(td, namespace, ions)
1195 type(td_t), intent(in) :: td
1196 type(namespace_t), intent(in) :: namespace
1197 type(ions_t), intent(inout) :: ions
1198
1199 integer :: iatom, iter, iunit
1200
1201 push_sub(td_read_coordinates)
1202
1203 iunit = io_open('td.general/coordinates', namespace, action='read', status='old', die=.false.)
1204 if (iunit == -1) then
1205 message(1) = "Could not open file '"//trim(io_workpath('td.general/coordinates', namespace))//"'."
1206 message(2) = "Starting simulation from initial geometry."
1207 call messages_warning(2, namespace=namespace)
1208 pop_sub(td_read_coordinates)
1209 return
1210 end if
1211
1212 call io_skip_header(iunit)
1213 do iter = 0, td%iter - 1
1214 read(iunit, *) ! skip previous iterations... sorry, but no portable seek in Fortran
1215 end do
1216 read(iunit, '(32x)', advance='no') ! skip the time index.
1217
1218 do iatom = 1, ions%natoms
1219 read(iunit, '(3es24.16)', advance='no') ions%pos(:, iatom)
1220 ions%pos(:, iatom) = units_to_atomic(units_out%length, ions%pos(:, iatom))
1221 end do
1222 do iatom = 1, ions%natoms
1223 read(iunit, '(3es24.16)', advance='no') ions%vel(:, iatom)
1224 ions%vel(:, iatom) = units_to_atomic(units_out%velocity, ions%vel(:, iatom))
1225 end do
1226 do iatom = 1, ions%natoms
1227 read(iunit, '(3es24.16)', advance='no') ions%tot_force(:, iatom)
1228 ions%tot_force(:, iatom) = units_to_atomic(units_out%force, ions%tot_force(:, iatom))
1229 end do
1230
1231 call io_close(iunit)
1232
1233 pop_sub(td_read_coordinates)
1234 end subroutine td_read_coordinates
1235
1236 ! ---------------------------------------------------------
1237 subroutine td_dump(td, namespace, space, gr, st, hm, ks, ext_partners, iter, ierr)
1238 type(td_t), intent(in) :: td
1239 type(namespace_t), intent(in) :: namespace
1240 class(space_t), intent(in) :: space
1241 type(grid_t), intent(in) :: gr
1242 type(states_elec_t), intent(in) :: st
1243 type(hamiltonian_elec_t), intent(in) :: hm
1244 type(v_ks_t), intent(in) :: ks
1245 type(partner_list_t), intent(in) :: ext_partners
1246 integer, intent(in) :: iter
1247 integer, intent(out) :: ierr
1248
1249 type(gauge_field_t), pointer :: gfield
1250 integer :: err, err2
1251
1252 push_sub(td_dump)
1253
1254 ierr = 0
1255
1256 if (restart_skip(td%restart_dump)) then
1257 pop_sub(td_dump)
1258 return
1259 end if
1260
1261 message(1) = "Debug: Writing td restart."
1262 call messages_info(1, namespace=namespace, debug_only=.true.)
1263
1264 ! first write resume file
1265 call states_elec_dump(td%restart_dump, space, st, gr, hm%kpoints, err, iter=iter)
1266 if (err /= 0) ierr = ierr + 1
1267
1268 call states_elec_dump_rho(td%restart_dump, space, st, gr, ierr, iter=iter)
1269 if (err /= 0) ierr = ierr + 1
1270
1271 if (hm%lda_u_level /= dft_u_none) then
1272 call lda_u_dump(td%restart_dump, namespace, hm%lda_u, st, gr, ierr)
1273 if (err /= 0) ierr = ierr + 1
1274 end if
1275
1276 call potential_interpolation_dump(td%tr%vks_old, space, td%restart_dump, gr, st%d%nspin, err2)
1277 if (err2 /= 0) ierr = ierr + 2
1278
1279 call pes_dump(td%pesv, namespace, td%restart_dump, st, gr, err)
1280 if (err /= 0) ierr = ierr + 4
1281
1282 ! Gauge field restart
1283 gfield => list_get_gauge_field(ext_partners)
1284 if(associated(gfield)) then
1285 call gauge_field_dump(td%restart_dump, gfield, ierr)
1286 end if
1288 if (gr%der%boundaries%spiralBC) then
1289 call states_elec_dump_spin(td%restart_dump, st, err)
1290 if (err /= 0) ierr = ierr + 8
1291 end if
1292
1293 if (ks%has_photons) then
1294 call mf_photons_dump(td%restart_dump, ks%pt_mx, gr, td%dt, ks%pt, err)
1295 if (err /= 0) ierr = ierr + 16
1296 end if
1297
1298 if (ks%xc_photon /= 0) then
1299 ! photon-free mean field
1300 call ks%xc_photons%mf_dump(td%restart_dump, err)
1301 if (err /= 0) ierr = ierr + 32
1302 end if
1303
1304 if (allocated(st%frozen_rho)) then
1305 call states_elec_dump_frozen(td%restart_dump, space, st, gr, ierr)
1306 end if
1307 if (err /= 0) ierr = ierr + 64
1308
1309 if (td%ions_dyn%ions_move() .or. td%ions_dyn%cell_relax()) then
1310 call ion_dynamics_dump(td%ions_dyn, td%restart_dump, err)
1311 end if
1312 if (err /= 0) ierr = ierr + 128
1313
1314 message(1) = "Debug: Writing td restart done."
1315 call messages_info(1, namespace=namespace, debug_only=.true.)
1316
1317 pop_sub(td_dump)
1318 end subroutine td_dump
1319
1320 ! ---------------------------------------------------------
1321 subroutine td_load(restart, namespace, space, gr, st, hm, ext_partners, td, ks, ierr)
1322 type(restart_t), intent(in) :: restart
1323 type(namespace_t), intent(in) :: namespace
1324 class(space_t), intent(in) :: space
1325 type(grid_t), intent(in) :: gr
1326 type(states_elec_t), intent(inout) :: st
1327 type(hamiltonian_elec_t), intent(inout) :: hm
1328 type(partner_list_t), intent(in) :: ext_partners
1329 type(td_t), intent(inout) :: td
1330 type(v_ks_t), intent(inout) :: ks
1331 integer, intent(out) :: ierr
1332
1333 integer :: err, err2
1334 type(gauge_field_t), pointer :: gfield
1335 push_sub(td_load)
1336
1337 ierr = 0
1338
1339 if (restart_skip(restart)) then
1340 ierr = -1
1341 pop_sub(td_load)
1342 return
1343 end if
1344
1345 message(1) = "Debug: Reading td restart."
1346 call messages_info(1, namespace=namespace, debug_only=.true.)
1347
1348 ! Read states
1349 call states_elec_load(restart, namespace, space, st, gr, hm%kpoints, err, iter=td%iter, label = ": td")
1350 if (err /= 0) then
1351 ierr = ierr + 1
1352 end if
1353
1354 ! read potential from previous interactions
1355 call potential_interpolation_load(td%tr%vks_old, namespace, space, restart, gr, st%d%nspin, err2)
1356 if (err2 /= 0) ierr = ierr + 2
1357
1358 if (hm%lda_u_level /= dft_u_none) then
1359 call lda_u_load(restart, hm%lda_u, st, hm%energy%dft_u, ierr)
1360 if (err /= 0) ierr = ierr + 1
1361 end if
1362
1363
1364 ! read PES restart
1365 if (td%pesv%calc_spm .or. td%pesv%calc_mask .or. td%pesv%calc_flux) then
1366 call pes_load(td%pesv, namespace, restart, st, err)
1367 if (err /= 0) ierr = ierr + 4
1368 end if
1369
1370 ! Gauge field restart
1371 gfield => list_get_gauge_field(ext_partners)
1372 if (associated(gfield)) then
1373 call gauge_field_load(restart, gfield, err)
1374 if (err /= 0) then
1375 ierr = ierr + 8
1376 else
1377 call hm%update(gr, namespace, space, ext_partners, time = td%dt*td%iter)
1378 end if
1379 end if
1380
1381 ! add photon restart
1382 if (ks%has_photons) then
1383 call mf_photons_load(restart, ks%pt_mx, gr, err)
1384 end if
1385 if (err /= 0) ierr = ierr + 16
1386
1387 if (ks%xc_photon /= 0) then
1388 call ks%xc_photons%mf_load(restart, space, err)
1389 end if
1390 if (err /= 0) ierr = ierr + 32
1391
1392 if (gr%der%boundaries%spiralBC) then
1393 call states_elec_load_spin(restart, st, err)
1394 !To ensure back compatibility, if the file is not present, we use the
1395 !current states to get the spins
1396 if (err /= 0) call states_elec_fermi(st, namespace, gr)
1397 end if
1398
1399 if (td%ions_dyn%is_active()) then
1400 call ion_dynamics_load(td%ions_dyn, restart, err)
1401 end if
1402 if (err /= 0) ierr = ierr + 64
1403
1404 message(1) = "Debug: Reading td restart done."
1405 call messages_info(1, namespace=namespace, debug_only=.true.)
1406
1407 pop_sub(td_load)
1408 end subroutine td_load
1409 ! ---------------------------------------------------------
1410 subroutine td_load_frozen(namespace, restart, space, mesh, st, hm, ierr)
1411 type(namespace_t), intent(in) :: namespace
1412 type(restart_t), intent(in) :: restart
1413 class(space_t), intent(in) :: space
1414 class(mesh_t), intent(in) :: mesh
1415 type(states_elec_t), intent(inout) :: st
1416 type(hamiltonian_elec_t), intent(inout) :: hm
1417 integer, intent(out) :: ierr
1418
1419 push_sub(td_load_frozen)
1420
1421 ierr = 0
1422
1423 if (restart_skip(restart)) then
1424 ierr = -1
1425 pop_sub(td_load_frozen)
1426 return
1427 end if
1428
1429 message(1) = "Debug: Reading td frozen restart."
1430 call messages_info(1, namespace=namespace, debug_only=.true.)
1431
1432 safe_allocate(st%frozen_rho(1:mesh%np, 1:st%d%nspin))
1433 if (family_is_mgga(hm%xc%family)) then
1434 safe_allocate(st%frozen_tau(1:mesh%np, 1:st%d%nspin))
1435 safe_allocate(st%frozen_gdens(1:mesh%np, 1:space%dim, 1:st%d%nspin))
1436 safe_allocate(st%frozen_ldens(1:mesh%np, 1:st%d%nspin))
1437 end if
1438
1439 call states_elec_load_frozen(restart, space, st, mesh, ierr)
1440
1441 message(1) = "Debug: Reading td frozen restart done."
1442 call messages_info(1, namespace=namespace, debug_only=.true.)
1443
1444 pop_sub(td_load_frozen)
1445 end subroutine td_load_frozen
1446
1447 ! ---------------------------------------------------------
1448 logical function td_get_from_scratch(td)
1449 type(td_t), intent(in) :: td
1450
1451 push_sub(td_get_from_scratch)
1452
1453 td_get_from_scratch = td%from_scratch
1454
1455 pop_sub(td_get_from_scratch)
1456 end function td_get_from_scratch
1457
1458 ! ---------------------------------------------------------
1459 subroutine td_set_from_scratch(td, from_scratch)
1460 type(td_t), intent(inout) :: td
1461 logical, intent(in) :: from_scratch
1462
1463 push_sub(td_set_from_scratch)
1464
1465 td%from_scratch = from_scratch
1466
1467 pop_sub(td_set_from_scratch)
1468 end subroutine td_set_from_scratch
1469end module td_oct_m
1470
1471!! Local Variables:
1472!! mode: f90
1473!! coding: utf-8
1474!! End:
Prints out to iunit a message in the form: ["InputVariable" = value] where "InputVariable" is given b...
Definition: messages.F90:180
integer, parameter, public mask_absorbing
Module implementing boundary conditions in Octopus.
Definition: boundaries.F90:122
This module handles the calculation mode.
type(calc_mode_par_t), public calc_mode_par
Singleton instance of parallel calculation mode.
integer, parameter, public p_strategy_states
parallelization in states
This module implements a calculator for the density and defines related functions.
Definition: density.F90:120
subroutine, public states_elec_freeze_adjust_qtot(st)
Definition: density.F90:812
subroutine, public states_elec_freeze_redistribute_states(st, namespace, mesh, mc, nn)
Definition: density.F90:784
subroutine, public states_elec_freeze_orbitals(st, namespace, space, gr, mc, kpoints, n, family_is_mgga)
Calculate partial density for frozen orbitals.
Definition: density.F90:653
subroutine, public density_calc(st, gr, density, istin)
Computes the density from the orbitals in st.
Definition: density.F90:610
subroutine, public dm_propagation_init_run(adiabatic_st, namespace, space, gr, st, hm, mc)
Initialise the adiabatic states prior to running TB propagation.
subroutine, public dm_propagation_run(dmp, namespace, space, gr, ions, st, mc, hm, ks, iter, dt, ext_partners, update_energy)
Apply dissipation to a TD run via the Linblad formalism.
subroutine, public electrons_ground_state_run(namespace, mc, gr, ions, ext_partners, st, ks, hm, outp, space, fromScratch)
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
Definition: epot.F90:166
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)
Definition: forces.F90:339
subroutine, public gauge_field_load(restart, gfield, ierr)
subroutine, public gauge_field_get_force(this, gr, spin_channels, current, lrc_alpha)
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
Definition: global.F90:188
real(real64), parameter, public m_epsilon
Definition: global.F90:204
real(real64), parameter, public m_one
Definition: global.F90:189
This module implements the underlying real-space grid.
Definition: grid.F90:117
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.
Definition: io.F90:114
subroutine, public io_close(iunit, grp)
Definition: io.F90:418
subroutine, public io_skip_header(iunit)
Definition: io.F90:597
character(len=max_path_len) function, public io_workpath(path, namespace)
Definition: io.F90:270
subroutine, public io_debug_on_the_fly(namespace)
check if debug mode should be enabled or disabled on the fly
Definition: io.F90:486
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
Definition: io.F90:352
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.
Definition: kick.F90:1135
subroutine, public lasers_set_nondipole_parameters(this, ndfield, nd_integration_time)
Set parameters for nondipole SFA calculation.
Definition: lasers.F90:752
logical function, public lasers_with_nondipole_field(lasers)
Check if a nondipole SFA correction should be computed for the given laser.
Definition: lasers.F90:739
subroutine, public laser_write_info(lasers, namespace, dt, max_iter, iunit)
Definition: lasers.F90:930
subroutine, public lda_u_dump(restart, namespace, this, st, mesh, ierr)
Definition: lda_u_io.F90:646
subroutine, public lda_u_write_u(this, iunit, namespace)
Definition: lda_u_io.F90:530
subroutine, public lda_u_load(restart, this, st, dftu_energy, ierr, occ_only, u_only)
Definition: lda_u_io.F90:727
subroutine, public lda_u_write_v(this, iunit, namespace)
Definition: lda_u_io.F90:579
integer, parameter, public dft_u_none
Definition: lda_u.F90:201
subroutine, public lda_u_freeze_occ(this)
Definition: lda_u.F90:888
subroutine, public lda_u_freeze_u(this)
Definition: lda_u.F90:895
subroutine, public lda_u_end(this)
Definition: lda_u.F90:655
subroutine, public lda_u_init(this, namespace, space, level, gr, ions, st, mc, kpoints, has_phase)
Definition: lda_u.F90:282
integer, parameter, public dft_u_acbn0
Definition: lda_u.F90:201
subroutine, public lda_u_update_occ_matrices(this, namespace, mesh, st, hm_base, phase, energy)
Definition: lda_u.F90:798
This module implements fully polymorphic linked lists, and some specializations thereof.
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:118
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
Definition: messages.F90:903
subroutine, public messages_not_implemented(feature, namespace)
Definition: messages.F90:1096
character(len=512), private msg
Definition: messages.F90:165
subroutine, public messages_warning(no_lines, all_nodes, namespace)
Definition: messages.F90:530
subroutine, public messages_obsolete_variable(namespace, name, rep)
Definition: messages.F90:1028
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:160
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:414
subroutine, public messages_input_error(namespace, var, details, row, column)
Definition: messages.F90:696
subroutine, public messages_experimental(name, namespace)
Definition: messages.F90:1068
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:599
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
Definition: mpi.F90:370
type(mpi_grp_t), public mpi_world
Definition: mpi.F90:270
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:145
type(namespace_t), public global_namespace
Definition: namespace.F90:132
this module contains the low-level part of the output system
Definition: output_low.F90:115
this module contains the output system
Definition: output.F90:115
logical function, public parse_is_defined(namespace, name)
Definition: parser.F90:502
subroutine, public pes_calc(pes, namespace, space, mesh, st, dt, iter, der, kpoints, ext_partners, stopping)
Definition: pes.F90:269
subroutine, public pes_init(pes, namespace, space, mesh, box, st, save_iter, kpoints, abs_boundaries, ext_partners, max_iter, dt)
Definition: pes.F90:175
subroutine, public pes_output(pes, namespace, space, gr, st, iter, outp, dt, ions)
Definition: pes.F90:295
subroutine, public pes_init_write(pes, mesh, st, namespace)
Definition: pes.F90:399
subroutine, public pes_end(pes)
Definition: pes.F90:255
subroutine, public pes_load(pes, namespace, restart, st, ierr)
Definition: pes.F90:359
subroutine, public pes_dump(pes, namespace, restart, st, mesh, ierr)
Definition: pes.F90:319
subroutine, public mf_photons_load(restart, this, gr, ierr)
subroutine, public mf_photons_dump(restart, this, gr, dt, pt_mode, ierr)
subroutine, public potential_interpolation_load(potential_interpolation, namespace, space, restart, mesh, nspin, err2)
subroutine, public potential_interpolation_dump(potential_interpolation, space, restart, mesh, nspin, err2)
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
Definition: profiling.F90:623
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
Definition: profiling.F90:552
subroutine, public propagator_elec_dt_bo(scf, namespace, space, gr, ks, st, hm, ions, ext_partners, mc, outp, 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_dt(ks, namespace, space, hm, gr, st, tr, time, dt, nt, ions_dyn, ions, ext_partners, mc, outp, write_handler, scsteps, update_energy, qcchi)
Propagates st from time - dt to t. If dt<0, it propagates backwards from t+|dt| to t.
subroutine, public propagator_elec_end(tr)
This module implements the basic propagator framework.
Definition: propagator.F90:117
logical function, public clean_stop(comm)
returns true if a file named stop exists
Definition: restart.F90:277
integer, parameter, public restart_gs
Definition: restart.F90:200
subroutine, public restart_init(restart, namespace, data_type, type, mc, ierr, mesh, dir, exact)
Initializes a restart object.
Definition: restart.F90:517
integer, parameter, public restart_type_dump
Definition: restart.F90:246
logical pure function, public restart_skip(restart)
Returns true if the restart information should neither be read nor written. This might happen because...
Definition: restart.F90:970
integer, parameter, public restart_td
Definition: restart.F90:200
integer, parameter, public restart_type_load
Definition: restart.F90:246
subroutine, public restart_end(restart)
Definition: restart.F90:723
subroutine, public scf_init(scf, namespace, gr, ions, st, mc, hm, space)
Definition: scf.F90:253
subroutine, public scf_end(scf)
Definition: scf.F90:546
subroutine, public scissor_init(this, namespace, space, st, mesh, d, kpoints, phase, gap, mc)
Definition: scissor.F90:162
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_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.
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_dump(restart, space, st, mesh, kpoints, ierr, iter, lr, st_start_writing, verbose)
subroutine, public states_elec_transform(st, namespace, space, restart, mesh, kpoints, prefix)
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 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, space, st, mesh, ierr, iter)
subroutine, public states_elec_dump_spin(restart, st, ierr)
This module implements the calculation of the stress tensor.
Definition: stress.F90:118
subroutine, public stress_calculate(namespace, gr, hm, st, ions, ks, ext_partners)
This computes the total stress on the lattice.
Definition: stress.F90:186
Definition: td.F90:114
subroutine, public td_check_point(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, iter, scsteps, etime, stopping, from_scratch)
Definition: td.F90:789
subroutine, public td_end(td)
Definition: td.F90:643
subroutine, public td_load_restart_from_gs(td, namespace, space, mc, gr, ext_partners, st, ks, hm)
Definition: td.F90:1200
subroutine td_print_message(td, namespace, ions, hm, iter, scsteps, etime)
Definition: td.F90:853
subroutine, public td_run_init()
Definition: td.F90:239
subroutine, public td_end_run(td, st, hm)
Definition: td.F90:662
subroutine, public td_init(td, namespace, space, gr, ions, st, ks, hm, ext_partners, outp)
Definition: td.F90:250
subroutine, public td_allocate_wavefunctions(td, namespace, mc, gr, ions, st, hm, space)
Definition: td.F90:578
logical function, public td_get_from_scratch(td)
Definition: td.F90:1542
subroutine td_load_frozen(namespace, restart, space, mesh, st, hm, ierr)
Definition: td.F90:1504
subroutine td_print_header(namespace)
Definition: td.F90:774
integer, parameter, public bo
Definition: td.F90:202
subroutine td_load(restart, namespace, space, gr, st, hm, ext_partners, td, ks, ierr)
Definition: td.F90:1415
subroutine, public td_set_from_scratch(td, from_scratch)
Definition: td.F90:1553
subroutine, public td_dump(td, namespace, space, gr, st, hm, ks, ext_partners, iter, ierr)
Definition: td.F90:1331
subroutine td_read_coordinates(td, namespace, ions)
reads the pos and vel from coordinates file
Definition: td.F90:1288
subroutine, public td_run(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, from_scratch)
Definition: td.F90:682
subroutine td_run_zero_iter(td, namespace, space, gr, ions, st, ks, hm, ext_partners, outp, mc)
Definition: td.F90:1242
subroutine, public td_init_gaugefield(td, namespace, gr, st, ks, hm, ext_partners, space)
Definition: td.F90:612
subroutine td_update_elapsed_time(etime)
Definition: td.F90:874
subroutine, public td_init_with_wavefunctions(td, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, outp, from_scratch)
Definition: td.F90:885
subroutine, public td_load_restart_from_td(td, namespace, space, mc, gr, ext_partners, st, ks, hm, from_scratch)
Definition: td.F90:1164
subroutine td_init_ions_and_forces(td, namespace, space, gr, ions, ext_partners, st, ks, hm, outp)
Definition: td.F90:1118
subroutine, public td_init_run(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, from_scratch)
Definition: td.F90:522
subroutine, public td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, dt)
Definition: td_write.F90:1237
subroutine, public td_write_data(writ)
Definition: td_write.F90:1203
subroutine, public td_write_kick(outp, namespace, space, mesh, kick, ions, iter)
Definition: td_write.F90:335
subroutine, public td_write_end(writ)
Definition: td_write.F90:987
subroutine, public td_write_iter(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, kick, ks, dt, iter, mc, recalculate_gs)
Definition: td_write.F90:1034
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.
Definition: td_write.F90:373
integer, parameter, public out_separate_forces
Definition: td_write.F90:201
type(type_t), public type_cmplx
Definition: types.F90:134
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
Definition: unit.F90:132
This module defines the unit system, used for input and output.
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)
Definition: v_ks.F90:1448
subroutine, public v_ks_calculate_current(this, calc_cur)
Definition: v_ks.F90:1459
subroutine, public v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval, time, calc_energy, calc_current, force_semilocal)
Definition: v_ks.F90:738
This module provices a simple timer class which can be used to trigger the writing of a restart file ...
Definition: walltimer.F90:121
logical function, public walltimer_alarm(comm, print)
indicate whether time is up
Definition: walltimer.F90:303
Definition: xc.F90:114
pure logical function, public family_is_mgga(family, only_collinear)
Is the xc function part of the mGGA family.
Definition: xc.F90:571
logical pure function, public family_is_mgga_with_exc(xcs)
Is the xc function part of the mGGA family with an energy functional.
Definition: xc.F90:584
Extension of space that contains the knowledge of the spin dimension.
Description of the grid, containing information on derivatives, stencil, and symmetries.
Definition: grid.F90:169
Describes mesh distribution to nodes.
Definition: mesh.F90:186
Stores all communicators and groups.
Definition: multicomm.F90:206
output handler class
Definition: output_low.F90:164
The states_elec_t class contains all electronic wave functions.
int true(void)