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
56 use output_oct_m
58 use parser_oct_m
59 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, &
92 td_init, &
94 td_end, &
95 td_end_run, &
98 td_dump, &
106
108 integer, parameter, public :: &
109 EHRENFEST = 1, &
110 bo = 2
111
112 type td_t
113 private
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
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 end type td_t
140
141
142contains
143
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
156
157 integer :: default
158 real(real64) :: propagation_time
159 type(lasers_t), pointer :: lasers
160 logical :: symmetrize
161
162 push_sub(td_init)
163
164 if (hm%pcm%run_pcm) call messages_experimental("PCM for CalculationMode = td", namespace=namespace)
165
166 symmetrize = hm%kpoints%use_symmetries .or. st%symmetrize_density
167 call ion_dynamics_init(td%ions_dyn, namespace, ions, symmetrize, gr%symmetrizer)
168
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."
173 call messages_fatal(2, namespace=namespace)
174 end if
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."
178 call messages_fatal(2, namespace=namespace)
179 end if
180 end if
181
182 td%iter = 0
183
184 !%Variable TDTimeStep
185 !%Type float
186 !%Section Time-Dependent::Propagation
187 !%Description
188 !% The time-step for the time propagation. For most propagators you
189 !% want to use the largest value that is possible without the
190 !% evolution becoming unstable.
191 !%
192 !% While prior versions of Octopus used to have a default time step, however,
193 !% this now needs to be systematically defined.
194 !%End
196 call parse_variable(namespace, 'TDTimeStep', -m_one, td%dt, unit = units_inp%time)
198 if (td%dt <= m_zero) then
199 write(message(1),'(a)') 'A positive value for TDTimeStep must be defined in the input file.'
200 call messages_fatal(1, namespace=namespace)
201 end if
203 call messages_print_var_value('TDTimeStep', td%dt, unit = units_out%time, namespace=namespace)
204
206 if (parse_is_defined(namespace, 'TDMaxSteps') .and. parse_is_defined(namespace, 'TDPropagationTime')) then
207 call messages_write('You cannot set TDMaxSteps and TDPropagationTime at the same time')
208 call messages_fatal(namespace=namespace)
209 end if
210
211 !%Variable TDPropagationTime
212 !%Type float
213 !%Section Time-Dependent::Propagation
214 !%Description
215 !% The length of the time propagation. You cannot set this variable
216 !% at the same time as <tt>TDMaxSteps</tt>. By default this variable will
217 !% not be used.
218 !%
219 !% The units for this variable are <math>\hbar</math>/Hartree (or <math>\hbar</math>/eV if you
220 !% selected <tt>ev_angstrom</tt> as input units). The approximate conversions to
221 !% femtoseconds are 1 fs = 41.34 <math>\hbar</math>/Hartree = 1.52 <math>\hbar</math>/eV.
222 !%End
223 call parse_variable(namespace, 'TDPropagationTime', -1.0_real64, propagation_time, unit = units_inp%time)
224
225 call messages_obsolete_variable(namespace, 'TDMaximumIter', 'TDMaxSteps')
226
227 !%Variable TDMaxSteps
228 !%Type integer
229 !%Default 1500
230 !%Section Time-Dependent::Propagation
231 !%Description
232 !% Number of time-propagation steps that will be performed. You
233 !% cannot use this variable together with <tt>TDPropagationTime</tt>.
234 !%End
235 default = 1500
236 if (propagation_time > m_zero) default = nint(propagation_time/td%dt)
237 call parse_variable(namespace, 'TDMaxSteps', default, td%max_iter)
238
239 if (propagation_time <= m_zero) propagation_time = td%dt*td%max_iter
240
241 call messages_print_var_value('TDPropagationTime', propagation_time, unit = units_out%time, namespace=namespace)
242 call messages_print_var_value('TDMaxSteps', td%max_iter, namespace=namespace)
243
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)'
247 call messages_fatal(2, namespace=namespace)
248 end if
249
250 td%iter = 0
251
252 lasers => list_get_lasers(ext_partners)
253
254 ! now the photoelectron stuff
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)
257
258 !%Variable TDDynamics
259 !%Type integer
260 !%Default ehrenfest
261 !%Section Time-Dependent::Propagation
262 !%Description
263 !% Type of dynamics to follow during a time propagation.
264 !% For BO, you must set <tt>MoveIons = yes</tt>.
265 !%Option ehrenfest 1
266 !% Ehrenfest dynamics.
267 !%Option bo 2
268 !% Born-Oppenheimer (Experimental).
269 !%End
270
271 call parse_variable(namespace, 'TDDynamics', ehrenfest, td%dynamics)
272 if (.not. varinfo_valid_option('TDDynamics', td%dynamics)) call messages_input_error(namespace, 'TDDynamics')
273 call messages_print_var_option('TDDynamics', td%dynamics, namespace=namespace)
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"
277 call messages_fatal(1, namespace=namespace)
278 end if
279 end if
280
281 !%Variable RecalculateGSDuringEvolution
282 !%Type logical
283 !%Default no
284 !%Section Time-Dependent::Propagation
285 !%Description
286 !% In order to calculate some information about the system along the
287 !% evolution (e.g. projection onto the ground-state KS determinant,
288 !% projection of the TDKS spin-orbitals onto the ground-state KS
289 !% spin-orbitals), the ground-state KS orbitals are needed. If the
290 !% ionic potential changes -- that is, the ions move -- one may want
291 !% to recalculate the ground state. You may do this by setting this
292 !% variable.
293 !%
294 !% The recalculation is not done every time step, but only every
295 !% <tt>RecalculateGSInterval</tt> time steps.
296 !%End
297 call parse_variable(namespace, 'RecalculateGSDuringEvolution', .false., td%recalculate_gs)
298 if (hm%lda_u_level /= dft_u_none .and. td%recalculate_gs) then
299 call messages_not_implemented("DFT+U with RecalculateGSDuringEvolution=yes", namespace=namespace)
300 end if
301
302 !%Variable RecalculateGSInterval
303 !%Type integer
304 !%Default 50
305 !%Section Time-Dependent::Propagation
306 !%Description
307 !% This variable controls how often the GS is recalculated for
308 !% <tt>RecalculateGSDuringEvolution = yes</tt>. It is the number of
309 !% time-propagation steps between two ground-state recalculations.
310 !% A smaller value follows the instantaneous Hamiltonian more closely,
311 !% while a larger value reduces the cost of outputs that need the
312 !% instantaneous ground-state basis, such as <tt>TDOutput = n_excited_el</tt>.
313 !%End
314 call parse_variable(namespace, 'RecalculateGSInterval', 50, td%recalculate_gs_interval)
315
316 !%Variable TDScissor
317 !%Type float
318 !%Default 0.0
319 !%Section Time-Dependent
320 !%Description
321 !% (experimental) If set, a scissor operator will be applied in the
322 !% Hamiltonian, shifting the excitation energies by the amount
323 !% specified. By default, it is not applied.
324 !%End
325 call parse_variable(namespace, 'TDScissor', m_zero, td%scissor)
326 call messages_print_var_value('TDScissor', td%scissor, namespace=namespace)
327
328 call propagator_elec_init(gr, namespace, st, td%tr, hm%ks_pot, td%ions_dyn%is_active() .and.&
329 list_has_gauge_field(ext_partners), family_is_mgga_with_exc(ks%xc), td%ions_dyn%cell_relax())
330
331 ! Moving ions with ultrasoft/PAW would require the time-dependent overlap S(t) (and its
332 ! derivative) in the equation of motion.
333 if (st%requires_generalized_overlap .and. td%ions_dyn%ions_move()) then
334 call messages_not_implemented("TDDFT with ultrasoft/PAW and moving ions", namespace=namespace)
335 end if
336
337 if (associated(lasers) .and. st%system_grp%is_root()) then
338 call messages_print_with_emphasis(msg="Time-dependent external fields", namespace=namespace)
339 call laser_write_info(lasers%lasers, dt=td%dt, max_iter=td%max_iter, namespace=namespace)
340 call messages_print_with_emphasis(namespace=namespace)
341 end if
342
343 !%Variable TDEnergyUpdateIter
344 !%Type integer
345 !%Section Time-Dependent::Propagation
346 !%Description
347 !% This variable controls after how many iterations Octopus
348 !% updates the total energy during a time-propagation run. For
349 !% iterations where the energy is not updated, the last calculated
350 !% value is reported. If you set this variable to 1, the energy
351 !% will be calculated in each step.
352 !%End
353
354 default = 10
355 call parse_variable(namespace, 'TDEnergyUpdateIter', default, td%energy_update_iter)
356 if (td%energy_update_iter < 1) then
357 call messages_input_error(namespace, 'TDEnergyUpdateIter')
358 end if
359
360 if (gr%der%boundaries%spiralBC .and. &
361 (hm%ep%reltype == spin_orbit .or. hm%ep%reltype == fully_relativistic_zora)) then
362 message(1) = "Generalized Bloch theorem cannot be used with spin-orbit coupling."
363 call messages_fatal(1, namespace=namespace)
364 end if
365
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."
369 call messages_fatal(1, namespace=namespace)
370 end if
371 end if
372
373 !%Variable TDFreezeOrbitals
374 !%Type integer
375 !%Default 0
376 !%Section Time-Dependent
377 !%Description
378 !% (Experimental) You have the possibility of "freezing" a number of orbitals during a time-propagation.
379 !% The Hartree and exchange-correlation potential due to these orbitals (which
380 !% will be the lowest-energy ones) will be added during the propagation, but the orbitals
381 !% will not be propagated.
382 !%Option sae -1
383 !% Single-active-electron approximation. This option is only valid for time-dependent
384 !% calculations (<tt>CalculationMode = td</tt>). Also, the nuclei should not move.
385 !% The idea is that all orbitals except the last one are frozen. The orbitals are to
386 !% be read from a previous ground-state calculation. The active orbital is then treated
387 !% as independent (whether it contains one electron or two) -- although it will
388 !% feel the Hartree and exchange-correlation potentials from the ground-state electronic
389 !% configuration.
390 !%
391 !% It is almost equivalent to setting <tt>TDFreezeOrbitals = N-1</tt>, where <tt>N</tt> is the number
392 !% of orbitals, but not completely.
393 !%End
394 call parse_variable(namespace, 'TDFreezeOrbitals', 0, td%freeze_orbitals)
395
396 if (td%freeze_orbitals /= 0) then
397 call messages_experimental('TDFreezeOrbitals', namespace=namespace)
398
399 if (hm%lda_u_level /= dft_u_none) then
400 call messages_not_implemented('TDFreezeOrbitals with DFT+U', namespace=namespace)
401 end if
402 end if
403
404 !%Variable TDDMPropagation
405 !%Type integer
406 !%Default 1
407 !%Section Time-Dependent
408 !%Description
409 !% Decides whether to propagate the density matrix, in the spectral basis,
410 !% together with the KS orbitals.
411 !% The resulting time-depented orbilas are to be considered the natural orbitals
412 !% of the denstiy matrix and with the corresponding eigenvalues the occupation numbers.
413 !% In order to work properly this method requires an number of empty states
414 !% specified with the option "ExtraStates".
415 !% This is an experimental feature.
416 !%Option no_propagation 1
417 !% No density time propagation.
418 !%Option master_equation 2
419 !% Density time propagation with the Lindblad master equation.
420 !%Option collision_integral 3
421 !% Density time propagation with the collosion integral.
422 !%End
423
424 call parse_variable(global_namespace, 'TDDMPropagation', option__tddmpropagation__no_propagation, dmp%calculation_mode)
425 if (.not. varinfo_valid_option('TDDMPropagation', dmp%calculation_mode)) then
426 call messages_input_error(global_namespace, 'TDDMPropagation')
427 endif
428 call messages_print_var_option('TDDMPropagation', dmp%calculation_mode, namespace=namespace)
429
430 if (dmp%calculation_mode /= option__tddmpropagation__no_propagation) then
431 call messages_experimental('TDDMPropagation', namespace=namespace)
432 call dmp%init(namespace, st, space, hm)
433 end if
434
435 pop_sub(td_init)
436 nullify(lasers)
437
438 end subroutine td_init
439
440 ! ---------------------------------------------------------
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
443 type(namespace_t), intent(in) :: namespace
444 type(multicomm_t), intent(inout) :: mc
445 type(grid_t), intent(inout) :: gr
446 type(ions_t), intent(inout) :: ions
447 type(states_elec_t), intent(inout) :: st
448 type(v_ks_t), intent(inout) :: ks
449 type(hamiltonian_elec_t), intent(inout) :: hm
450 type(partner_list_t), intent(in) :: ext_partners
451 type(output_t), intent(inout) :: outp
452 type(electron_space_t), intent(in) :: space
453 type(dmp_t), intent(inout) :: dmp
454 logical, intent(inout) :: from_scratch
455 push_sub(td_init_run)
456
457 ! NOTE: please do not change code in this function, but only in functions
458 ! called from here because the logic of this function is replicated in the
459 ! multisystem framework in different places
460
461 call td_allocate_wavefunctions(td, namespace, mc, gr, ions, st, hm, space)
462 call td_init_gaugefield(td, namespace, gr, st, ks, hm, ext_partners, space)
463
464 call ions%initialize()
465
466 td%from_scratch = from_scratch
467
468 if (.not. td%from_scratch) then
469 call td_load_restart_from_td(td, namespace, space, mc, gr, ext_partners, st, ks, hm, td%from_scratch)
470 if (td%from_scratch) then
471 message(1) = "Unable to read time-dependent restart information: Starting from scratch"
472 call messages_warning(1, namespace=namespace)
473 end if
474 end if
475
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."
478 call messages_info(1, namespace=namespace)
480 td%iter = td%iter + 1
481 if ((td%ions_dyn%is_active()) .and. td%recalculate_gs) call td%restart_load%end()
482 pop_sub(td_init_run)
483 return
484 end if
485
486 if (td%from_scratch) then
487 call td_load_restart_from_gs(td, namespace, space, mc, gr, ext_partners, st, ks, hm)
488 end if
489
490 call td_init_with_wavefunctions(td, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, outp, dmp, td%from_scratch)
491
492 pop_sub(td_init_run)
493 end subroutine td_init_run
494
495 ! ---------------------------------------------------------
496 subroutine td_allocate_wavefunctions(td, namespace, mc, gr, ions, st, hm, space)
497 type(td_t), intent(inout) :: td
498 type(namespace_t), intent(in) :: namespace
499 type(multicomm_t), intent(inout) :: mc
500 type(grid_t), intent(inout) :: gr
501 type(ions_t), intent(inout) :: ions
502 type(states_elec_t), intent(inout) :: st
503 type(hamiltonian_elec_t), intent(inout) :: hm
504 class(space_t), intent(in) :: space
505
507
508 ! Allocate wavefunctions during time-propagation
509 if (td%dynamics == ehrenfest) then
510 !Note: this is not really clean to do this
511 if (hm%lda_u_level /= dft_u_none .and. states_are_real(st)) then
512 call lda_u_end(hm%lda_u)
513 !complex wfs are required for Ehrenfest
514 call states_elec_allocate_wfns(st, gr, type_cmplx, packed=.true.)
515 call lda_u_init(hm%lda_u, namespace, space, hm%lda_u_level, gr, ions, st, mc, hm%kpoints)
516 else
517 !complex wfs are required for Ehrenfest
518 call states_elec_allocate_wfns(st, gr, type_cmplx, packed=.true.)
519 end if
520 else
521 call states_elec_allocate_wfns(st, gr, packed=.true.)
522 call scf_init(td%scf, namespace, gr, ions, st, mc, hm, space)
523 call scf_set_lower_bound_is_known(td%scf, .true.)
524 end if
525
527 end subroutine td_allocate_wavefunctions
528
529 ! ---------------------------------------------------------
530 subroutine td_init_gaugefield(td, namespace, gr, st, ks, hm, ext_partners, space)
531 type(td_t), intent(inout) :: td
532 type(namespace_t), intent(in) :: namespace
533 type(grid_t), intent(inout) :: gr
534 type(states_elec_t), intent(inout) :: st
535 type(v_ks_t), intent(inout) :: ks
536 type(hamiltonian_elec_t), intent(inout) :: hm
537 type(partner_list_t), intent(in) :: ext_partners
538 class(space_t), intent(in) :: space
539
540 type(gauge_field_t), pointer :: gfield
541
542 push_sub(td_init_gaugefield)
543
544 gfield => list_get_gauge_field(ext_partners)
545 if(associated(gfield)) then
546 if (gauge_field_is_used(gfield)) then
547 !if the gauge field is applied, we need to tell v_ks to calculate the current
548 call v_ks_calculate_current(ks, .true.)
549
550 ! initialize the vector field and update the hamiltonian
551 call gauge_field_init_vec_pot(gfield, st%qtot)
552 call hm%update(gr, namespace, space, ext_partners, time = td%dt*td%iter)
553
554 end if
555 end if
556
557 pop_sub(td_init_gaugefield)
558 end subroutine td_init_gaugefield
559
560 ! ---------------------------------------------------------
561 subroutine td_end(td)
562 type(td_t), intent(inout) :: td
563
564 push_sub(td_end)
565
566 call pes_end(td%pesv)
567 call propagator_elec_end(td%tr) ! clean the evolution method
568 call ion_dynamics_end(td%ions_dyn)
569
570 if (td%dynamics == bo) call scf_end(td%scf)
571 pop_sub(td_end)
572
573 end subroutine td_end
574
575 ! ---------------------------------------------------------
576 subroutine td_end_run(td, st, hm, dmp)
577 type(td_t), intent(inout) :: td
578 type(states_elec_t), intent(inout) :: st
579 type(hamiltonian_elec_t), intent(inout) :: hm
580 type(dmp_t), intent(inout) :: dmp
581
582 push_sub(td_end_run)
583
584 if (st%pack_states .and. hm%apply_packed()) call st%unpack()
585
586 call td%restart_dump%end()
587 call td_write_end(td%write_handler)
588
589 ! free memory
591 if ((td%ions_dyn%is_active()).and. td%recalculate_gs) call td%restart_load%end()
592
593 if (dmp%calculation_mode /= option__tddmpropagation__no_propagation) then
594 call dm_end_run(st%system_grp, dmp)
595 endif
596
597 pop_sub(td_end_run)
598 end subroutine td_end_run
599
600 ! ---------------------------------------------------------
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
603 type(namespace_t), intent(in) :: namespace
604 type(multicomm_t), intent(inout) :: mc
605 type(grid_t), intent(inout) :: gr
606 type(ions_t), intent(inout) :: ions
607 type(states_elec_t), intent(inout) :: st
608 type(v_ks_t), intent(inout) :: ks
609 type(hamiltonian_elec_t), intent(inout) :: hm
610 type(partner_list_t), intent(in) :: ext_partners
611 type(output_t), intent(inout) :: outp
612 type(electron_space_t), intent(in) :: space
613 type(dmp_t), intent(inout) :: dmp
614 logical, intent(inout) :: from_scratch
615
616 logical :: stopping
617 integer :: iter, scsteps
618 real(real64) :: etime
619 real(real64) :: wall_time, simulation_time, speed_fs_per_day
620 character(len=20) :: fmt
621
622 push_sub(td_run)
623
624 etime = loct_clock()
625 ! This is the time-propagation loop. It starts at t=0 and finishes
626 ! at td%max_iter*dt. The index i runs from 1 to td%max_iter, and
627 ! step "iter" means propagation from (iter-1)*dt to iter*dt.
628 propagation: do iter = td%iter, td%max_iter
629
630 stopping = clean_stop(mc%master_grp) .or. walltimer_alarm(mc%master_comm)
631
632 call profiling_in("TIME_STEP")
634 if (iter > 1) then
635 if (((iter-1)*td%dt <= hm%kick%time) .and. (iter*td%dt > hm%kick%time)) then
636 if (st%requires_generalized_overlap) then
637 call propagation_ops_elec_kick_generalized_overlap(namespace, space, gr, st, hm)
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)
640 else
641 call kick_apply(space, gr, st, td%ions_dyn, ions, hm%kick, hm%psolver, hm%kpoints, pcm = hm%pcm)
642 end if
643 call td_write_kick(outp, namespace, space, gr, hm%kick, ions, iter)
644 !We activate the sprial BC only after the kick,
645 !to be sure that the first iteration corresponds to the ground state
646 if (gr%der%boundaries%spiralBC) gr%der%boundaries%spiral = .true.
647 end if
648 end if
649
650 ! time iterate the system, one time step.
651 select case (td%dynamics)
652 case (ehrenfest)
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))
656 case (bo)
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)
659 end select
660
661 !Apply mask absorbing boundaries
662 if (hm%abs_boundaries%abtype == mask_absorbing) then
663 if (states_are_real(st)) then
664 call dvmask(gr, hm, st)
665 else
666 call zvmask(gr, hm, st)
667 end if
668 end if
669
670 !Photoelectron stuff
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)
673 end if
674
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)
677
678 ! write down data
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)
681
682 ! check if debug mode should be enabled or disabled on the fly
683 call io_debug_on_the_fly(namespace)
684
685 call profiling_out("TIME_STEP")
686 if (stopping) exit
687
688 end do propagation
689
690 ! Output propagation speed in fs/day
691 wall_time = loct_clock() - walltimer_get_start_time()
692 simulation_time = td%dt * (iter - td%iter + 1)
693 speed_fs_per_day = units_from_atomic(unit_femtosecond, simulation_time) / (wall_time / 86400.0_real64)
694 if (speed_fs_per_day > 1e4 .or. speed_fs_per_day < 1e-3) then
695 fmt = "ES10.3"
696 else
697 fmt = "F10.3"
698 end if
699 write(message(1), '(a,'//trim(fmt)//',a)') 'Propagation speed: ', speed_fs_per_day, ' fs/day'
700 write(message(2), '(a)') ''
701 call messages_info(2, namespace=namespace)
702
703 pop_sub(td_run)
704 end subroutine td_run
705
706 subroutine td_print_header(namespace)
707 type(namespace_t), intent(in) :: namespace
708
709 push_sub(td_print_header)
710
711 write(message(1), '(a7,1x,a14,a14,a10,a17)') 'Iter ', 'Time ', 'Energy ', 'SC Steps', 'Elapsed Time '
712
713 call messages_info(1, namespace=namespace)
714 call messages_print_with_emphasis(namespace=namespace)
715
716 pop_sub(td_print_header)
717 end subroutine td_print_header
718
719 ! ---------------------------------------------------------
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
723 type(namespace_t), intent(in) :: namespace
724 type(multicomm_t), intent(in) :: mc
725 type(grid_t), intent(inout) :: gr
726 type(ions_t), intent(inout) :: ions
727 type(states_elec_t), intent(inout) :: st
728 type(v_ks_t), intent(inout) :: ks
729 type(hamiltonian_elec_t), intent(inout) :: hm
730 type(partner_list_t), intent(in) :: ext_partners
731 type(output_t), intent(in) :: outp
732 type(electron_space_t), intent(in) :: space
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
739
740 integer :: ierr
741
742 push_sub(td_check_point)
743
744 call td_print_message(td, namespace, ions, hm, iter, scsteps, etime)
745
746 if (outp%anything_now(iter)) then ! output
747 call td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, td%dt)
748 end if
749
750 if (restart_walltime_period_alarm(mc%master_comm) .or. iter == td%max_iter .or. stopping) then ! restart
751 !if (iter == td%max_iter) outp%iter = ii - 1
752 call td_write_data(td%write_handler)
753 call td_dump(td, namespace, space, gr, st, hm, ks, ext_partners, iter, ierr)
754 if (ierr /= 0) then
755 message(1) = "Unable to write time-dependent restart information."
756 call messages_warning(1, namespace=namespace)
757 end if
758 ! dm_propagation adiabatic states
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)
762 if (ierr /= 0) then
763 message(1) = "Unable to write dm-adiabatic restart information."
764 call messages_warning(1, namespace=namespace)
765 end if
766 end if
767
768 call pes_output(td%pesv, namespace, space, gr, st, iter, outp, td%dt, ions)
769 end if
770
771 if (mod(iter, td%recalculate_gs_interval) == 0 .or. iter == td%max_iter .or. stopping) then ! potentially recalculate GS
772 if ((td%ions_dyn%is_active()) .and. td%recalculate_gs) then
773 ! write TD restart data
774 call td_dump(td, namespace, space, gr, st, hm, ks, ext_partners, iter, ierr)
775 if (ierr /= 0) then
776 message(1) = "Unable to write time-dependent restart information."
777 call messages_warning(1, namespace=namespace)
778 end if
779 ! run GS
780 call messages_print_with_emphasis(msg='Recalculating the ground state.', namespace=namespace)
781 from_scratch = .false.
783 call electrons_ground_state_run(namespace, mc, gr, ions, ext_partners, st, ks, hm, outp, space, from_scratch)
784 call states_elec_allocate_wfns(st, gr, packed=.true.)
785 ! load TD restart data again
786 call td_load(td%restart_load, namespace, space, gr, st, hm, ext_partners, td, ks, ierr)
787 if (ierr /= 0) then
788 message(1) = "Unable to load TD states."
789 call messages_fatal(1, namespace=namespace)
790 end if
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())
796 call messages_print_with_emphasis(msg="Time-dependent simulation proceeds", namespace=namespace)
797 call td_print_header(namespace)
798 end if
799 end if
800
801 pop_sub(td_check_point)
802 end subroutine td_check_point
803
804 ! ---------------------------------------------------------
805 subroutine td_print_message(td, namespace, ions, hm, iter, scsteps, etime)
806 type(td_t), intent(inout) :: td
807 type(namespace_t), intent(in) :: namespace
808 type(ions_t), intent(inout) :: ions
809 type(hamiltonian_elec_t), intent(inout) :: hm
810 integer, intent(in) :: iter
811 integer, intent(in) :: scsteps
812 real(real64), intent(inout) :: etime
813
814 push_sub(td_print_message)
815
816 write(message(1), '(i7,1x,2f14.6,i10,f14.3)') iter, units_from_atomic(units_out%time, iter*td%dt), &
817 units_from_atomic(units_out%energy, hm%energy%total + ions%kinetic_energy), scsteps, &
818 loct_clock() - etime
819 call messages_info(1, namespace=namespace)
820 call td_update_elapsed_time(etime)
821
822 pop_sub(td_print_message)
823 end subroutine td_print_message
824
825 ! ---------------------------------------------------------
826 subroutine td_update_elapsed_time(etime)
827 real(real64), intent(inout) :: etime
828
829 push_sub(td_update_elapsed_time)
830
831 etime = loct_clock()
832
834 end subroutine td_update_elapsed_time
835
836 ! ---------------------------------------------------------
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
839 type(namespace_t), intent(in) :: namespace
840 type(electron_space_t), intent(in) :: space
841 type(multicomm_t), intent(in) :: mc
842 type(grid_t), intent(inout) :: gr
843 type(ions_t), intent(inout) :: ions
844 type(partner_list_t), intent(in) :: ext_partners
845 type(states_elec_t), target, intent(inout) :: st
846 type(v_ks_t), intent(inout) :: ks
847 type(hamiltonian_elec_t), intent(inout) :: hm
848 type(output_t), intent(inout) :: outp
849 type(dmp_t), intent(inout) :: dmp
850 logical, intent(in) :: from_scratch
851
852 integer :: ierr
853 real(real64) :: x
854 real(real64) :: ndinitial(space%dim)
855 logical :: freeze_hxc, freeze_occ, freeze_u
856 type(restart_t) :: restart, restart_frozen
857 type(gauge_field_t), pointer :: gfield
858 type(lasers_t), pointer :: lasers
860
861 !We activate the sprial BC only after the kick,
862 !to be sure that the first iteration corresponds to the ground state
863 if (gr%der%boundaries%spiralBC) then
864 if ((td%iter-1)*td%dt > hm%kick%time) then
865 gr%der%boundaries%spiral = .true.
866 end if
867 hm%vnl%spin => st%spin
868 hm%phase%spin => st%spin
869 !We fill st%spin. In case of restart, we read it in td_load
870 if (from_scratch) call states_elec_fermi(st, namespace, gr)
871 end if
872
873 if (from_scratch) then
874 ! Initialize the occupation matrices and U for DFT+U
875 ! This must be called before parsing TDFreezeOccupations and TDFreezeU
876 ! in order that the code does properly the initialization.
877 call lda_u_update_occ_matrices(hm%lda_u, namespace, gr, st, hm%phase, hm%energy, hm%aug_overlap)
878 end if
879
880 if (td%freeze_orbitals > 0) then
881 if (from_scratch) then
882 ! In this case, we first freeze the orbitals, then calculate the Hxc potential.
883 call states_elec_freeze_orbitals(st, namespace, space, gr, mc, hm%kpoints, &
884 td%freeze_orbitals, family_is_mgga(ks%xc_family))
885 else
886 call restart%init(namespace, restart_td, restart_type_load, mc, ierr, mesh=gr)
887 if (ierr == 0) then
888 call td_load_frozen(namespace, restart, space, gr, st, hm, ierr)
889 end if
890 if (ierr /= 0) then
891 td%iter = 0
892 message(1) = "Unable to read frozen restart information."
893 call messages_fatal(1, namespace=namespace)
894 end if
895 call restart%end()
896 end if
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.'
899 call messages_info(1, namespace=namespace)
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
904 ! This means SAE approximation. We calculate the Hxc first, then freeze all
905 ! orbitals minus one.
906 write(message(1),'(a)') 'Info: The single-active-electron approximation will be used.'
907 call messages_info(1, namespace=namespace)
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
910 call states_elec_freeze_orbitals(st, namespace, space, gr, mc, hm%kpoints, st%nst-1, family_is_mgga(ks%xc_family))
911 else
912 call messages_not_implemented("TDFreezeOrbials < 0 with FromScratch=no", namespace=namespace)
913 end if
915 call v_ks_freeze_hxc(ks)
916 call density_calc(st, gr, st%rho, ep = hm%ep, vnl = hm%aug_overlap, phase = hm%phase)
917 else
918 ! Normal run.
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)
921 end if
922
923 !%Variable TDFreezeHXC
924 !%Type logical
925 !%Default no
926 !%Section Time-Dependent
927 !%Description
928 !% The electrons are evolved as independent particles feeling the Hartree and
929 !% exchange-correlation potentials from the ground-state electronic configuration.
930 !%End
931 call parse_variable(namespace, 'TDFreezeHXC', .false., freeze_hxc)
932 if (freeze_hxc .and. td%tr%method == prop_aetrs) &
933 call messages_input_error(namespace, 'TDPropagator', 'AETRS is incompatible with TDFreezeHXC')
934 if (freeze_hxc) then
935 write(message(1),'(a)') 'Info: Freezing Hartree and exchange-correlation potentials.'
936 call messages_info(1, namespace=namespace)
937
938 if (.not. from_scratch) then
939
940 call restart_frozen%init(namespace, restart_gs, restart_type_load, mc, ierr, mesh=gr, exact=.true.)
941 call states_elec_load(restart_frozen, namespace, space, st, gr, hm%kpoints, fixed_occ=.true., ierr=ierr, label = ": gs")
942 call states_elec_transform(st, namespace, space, restart_frozen, gr, hm%kpoints)
943 call restart_frozen%end()
944
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)
947
948 call restart_frozen%init(namespace, restart_td, restart_type_load, mc, ierr, mesh=gr)
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)
953
954 end if
955
956 call v_ks_freeze_hxc(ks)
957
958 end if
959
960 ! The lowest eigenvalue is at band index 1, and the eigenvalues are known
961 ! to all processors, so no broadcast over the states group is needed here.
962 x = minval(st%eigenval(1, :))
963 call hm%update_span(gr%spacing(1:space%dim), x, namespace)
964 ! initialize Fermi energy
965 call states_elec_fermi(st, namespace, gr, compute_spin = .not. gr%der%boundaries%spiralBC)
966 call energy_calc_total(namespace, space, hm, gr, st, ext_partners)
967
968 !%Variable TDFreezeDFTUOccupations
969 !%Type logical
970 !%Default no
971 !%Section Time-Dependent
972 !%Description
973 !% The occupation matrices than enters in the DFT+U potential
974 !% are not evolved during the time evolution.
975 !%End
976 call parse_variable(namespace, 'TDFreezeDFTUOccupations', .false., freeze_occ)
977 if (freeze_occ) then
978 write(message(1),'(a)') 'Info: Freezing DFT+U occupation matrices that enters in the DFT+U potential.'
979 call messages_info(1, namespace=namespace)
980 call lda_u_freeze_occ(hm%lda_u)
981
982 !In this case we should reload GS wavefunctions
983 if (hm%lda_u_level /= dft_u_none .and. .not. from_scratch) then
984 call restart_frozen%init(namespace, restart_gs, restart_type_load, mc, ierr, mesh=gr)
985 call lda_u_load(restart_frozen, hm%lda_u, st, hm%energy%dft_u, ierr, occ_only = .true.)
986 call restart_frozen%end()
987 end if
988 end if
989
990 !%Variable TDFreezeU
991 !%Type logical
992 !%Default no
993 !%Section Time-Dependent
994 !%Description
995 !% The effective U of DFT+U is not evolved during the time evolution.
996 !%End
997 call parse_variable(namespace, 'TDFreezeU', .false., freeze_u)
998 if (freeze_u) then
999 write(message(1),'(a)') 'Info: Freezing the effective U of DFT+U.'
1000 call messages_info(1, namespace=namespace)
1001 call lda_u_freeze_u(hm%lda_u)
1002
1003 !In this case we should reload GS wavefunctions
1004 if (hm%lda_u_level == dft_u_acbn0 .and. .not. from_scratch) then
1005 call restart_frozen%init(namespace, restart_gs, restart_type_load, mc, ierr, mesh=gr)
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'
1009 call messages_info(1, namespace=namespace)
1010 call lda_u_write_u(hm%lda_u, namespace=namespace)
1011 call lda_u_write_v(hm%lda_u, namespace=namespace)
1012 end if
1013 end if
1014
1015 ! This needs to be called before the calculation of the forces,
1016 ! as we need to test of we output the forces or not
1017 call td_write_init(td%write_handler, namespace, space, outp, gr, st, hm, ions, ext_partners, &
1018 ks, td%ions_dyn%is_active(), &
1019 list_has_gauge_field(ext_partners), hm%kick, td%iter, td%max_iter, td%dt, mc, dmp)
1020
1021 ! Resets the nondipole integration after laser-file has been written.
1022 lasers => list_get_lasers(ext_partners)
1023 if(associated(lasers)) then
1024 if (lasers_with_nondipole_field(lasers)) then
1025 ndinitial(1:space%dim)=m_zero
1026 call lasers_set_nondipole_parameters(lasers,ndinitial,m_zero)
1027 end if
1028 end if
1029 nullify(lasers)
1030
1031 call td_init_ions_and_forces(td, namespace, space, gr, ions, ext_partners, st, ks, hm, outp)
1032
1033 if (td%scissor > m_epsilon) then
1034 call scissor_init(hm%scissor, namespace, space, st, gr, hm%kpoints, hm%phase, td%scissor, mc)
1035 end if
1036
1037 ! Density matrix-based dissipation. initialize ad_st before td_run_zero_iter
1038 if (dmp%calculation_mode /= option__tddmpropagation__no_propagation) then
1039 call dm_propagation_init_run(dmp, namespace, space, gr, ions, st, hm, mc, td%from_scratch)
1040 end if
1041
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)
1044 end if
1045
1046 gfield => list_get_gauge_field(ext_partners)
1047 if(associated(gfield)) then
1048 if (gauge_field_is_propagated(gfield)) then
1049 call gauge_field_get_force(gfield, gr, st%d%spin_channels, st%current, ks%xc%lrc)
1050 if (abs(ks%xc%lrc%alpha) > m_epsilon) then
1051 call messages_experimental('TD-LRC kernel')
1052 end if
1053 endif
1054 end if
1055
1056 !call td_check_trotter(td, sys, h)
1057 td%iter = td%iter + 1
1058
1059 call td%restart_dump%init(namespace, restart_td, restart_type_dump, mc, ierr, mesh=gr)
1060 if (td%ions_dyn%is_active() .and. td%recalculate_gs) then
1061 ! We will also use the TD restart directory as temporary storage during the time propagation
1062 call td%restart_load%init(namespace, restart_td, restart_type_load, mc, ierr, mesh=gr)
1063 end if
1064
1065 call messages_print_with_emphasis(msg="Time-Dependent Simulation", namespace=namespace)
1066 call td_print_header(namespace)
1067
1068 if ((td%pesv%calc_spm .or. td%pesv%calc_mask) .and. from_scratch) then
1069 call pes_init_write(td%pesv,gr,st, namespace)
1070 end if
1071
1072 if (st%pack_states .and. hm%apply_packed()) call st%pack()
1073
1075 end subroutine td_init_with_wavefunctions
1076
1077 ! ---------------------------------------------------------
1078 subroutine td_init_ions_and_forces(td, namespace, space, gr, ions, ext_partners, st, ks, hm, outp)
1079 type(td_t), intent(inout) :: td
1080 type(namespace_t), intent(in) :: namespace
1081 type(electron_space_t), intent(in) :: space
1082 type(grid_t), intent(inout) :: gr
1083 type(ions_t), intent(inout) :: ions
1084 type(partner_list_t), intent(in) :: ext_partners
1085 type(states_elec_t), target, intent(inout) :: st
1086 type(v_ks_t), intent(inout) :: ks
1087 type(hamiltonian_elec_t), intent(inout) :: hm
1088 type(output_t), intent(inout) :: outp
1089
1090 push_sub(td_init_ions_and_forces)
1091
1092 ! Calculate initial forces and kinetic energy
1093 if (td%ions_dyn%ions_move()) then
1094 if (td%iter > 0) then
1095 call td_read_coordinates(td, namespace, ions)
1096 if (ion_dynamics_drive_ions(td%ions_dyn)) then
1097 call ion_dynamics_propagate(td%ions_dyn, ions, td%iter*td%dt, td%dt, namespace)
1098 end if
1099 call hamiltonian_elec_epot_generate(hm, namespace, space, gr, ions, ext_partners, st, time = td%iter*td%dt)
1100 ! recompute potential because the ions have moved
1101 call v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval=.true., time = td%iter*td%dt)
1102 end if
1103
1104 call forces_calculate(gr, namespace, ions, hm, ext_partners, st, ks, t = td%iter*td%dt, dt = td%dt)
1105
1106 call ions%update_kinetic_energy()
1107 else
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)
1110 end if
1111 end if
1112
1113 if (outp%what(option__output__stress) .or. td%ions_dyn%cell_relax()) then
1114 call stress_calculate(namespace, gr, hm, st, ions, ks, ext_partners)
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)
1117 end if
1118 end if
1119
1121 end subroutine td_init_ions_and_forces
1122
1123 ! ---------------------------------------------------------
1124 subroutine td_load_restart_from_td(td, namespace, space, mc, gr, ext_partners, st, ks, hm, from_scratch)
1125 type(td_t), intent(inout) :: td
1126 type(namespace_t), intent(in) :: namespace
1127 class(space_t), intent(in) :: space
1128 type(multicomm_t), intent(in) :: mc
1129 type(grid_t), intent(inout) :: gr
1130 type(partner_list_t), intent(in) :: ext_partners
1131 type(states_elec_t), target, intent(inout) :: st
1132 type(v_ks_t), intent(inout) :: ks
1133 type(hamiltonian_elec_t), intent(inout) :: hm
1134 logical, intent(inout) :: from_scratch
1135
1136 integer :: ierr
1137 type(restart_t) :: restart
1138
1139 push_sub(td_load_restart_from_td)
1140
1141 !We redistribute the states before the restarting
1142 if (td%freeze_orbitals > 0) then
1143 call states_elec_freeze_redistribute_states(st, namespace, gr, mc, td%freeze_orbitals)
1144 end if
1145
1146 call restart%init(namespace, restart_td, restart_type_load, mc, ierr, mesh=gr)
1147 if (ierr == 0) then
1148 call td_load(restart, namespace, space, gr, st, hm, ext_partners, td, ks, ierr)
1149 end if
1150 call restart%end()
1151 if (ierr /= 0) then
1152 from_scratch = .true.
1153 td%iter = 0
1154 end if
1155
1157 end subroutine td_load_restart_from_td
1158
1159 ! ---------------------------------------------------------
1160 subroutine td_load_restart_from_gs(td, namespace, space, mc, gr, ext_partners, st, ks, hm)
1161 type(td_t), intent(inout) :: td
1162 type(namespace_t), intent(in) :: namespace
1163 class(space_t), intent(in) :: space
1164 type(multicomm_t), intent(in) :: mc
1165 type(grid_t), intent(inout) :: gr
1166 type(partner_list_t), intent(in) :: ext_partners
1167 type(states_elec_t), target, intent(inout) :: st
1168 type(v_ks_t), intent(inout) :: ks
1169 type(hamiltonian_elec_t), intent(inout) :: hm
1170
1171 integer :: ierr
1172 type(restart_t) :: restart
1173
1174 push_sub(td_load_restart_from_gs)
1175
1176 call restart%init(namespace, restart_gs, restart_type_load, mc, ierr, mesh=gr, exact=.true.)
1177
1178 if (.not. st%only_userdef_istates) then
1179 if (ierr == 0) then
1180 call states_elec_load(restart, namespace, space, st, gr, hm%kpoints, &
1181 st%restart_fixed_occ, ierr, label = ": gs")
1182 end if
1183 if (ierr /= 0) then
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.'
1189 call messages_fatal(4, namespace=namespace)
1190 end if
1191 call messages_fatal(1, namespace=namespace)
1192 end if
1193 end if
1194
1195 ! check if we should deploy user-defined wavefunctions.
1196 ! according to the settings in the input file the routine
1197 ! overwrites orbitals that were read from restart/gs
1198 if (parse_is_defined(namespace, 'UserDefinedStates')) then
1199 call states_elec_read_user_def_orbitals(gr, namespace, space, st)
1200 end if
1201
1202 call states_elec_transform(st, namespace, space, restart, gr, hm%kpoints)
1203 call restart%end()
1204
1206 end subroutine td_load_restart_from_gs
1207
1208 ! ---------------------------------------------------------
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
1211 type(namespace_t), intent(in) :: namespace
1212 type(electron_space_t), intent(in) :: space
1213 type(grid_t), intent(inout) :: gr
1214 type(ions_t), intent(inout) :: ions
1215 type(states_elec_t), intent(inout) :: st
1216 type(v_ks_t), intent(inout) :: ks
1217 type(hamiltonian_elec_t), intent(inout) :: hm
1218 type(partner_list_t), intent(in) :: ext_partners
1219 type(output_t), intent(in) :: outp
1220 type(multicomm_t), intent(in) :: mc
1221 type(dmp_t), intent(in) :: dmp
1222
1223 push_sub(td_run_zero_iter)
1224
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)
1227
1228 ! I apply the delta electric field *after* td_write_iter, otherwise the
1229 ! dipole matrix elements in write_proj are wrong
1230 if (abs(hm%kick%time) <= m_epsilon) then
1231 if (st%requires_generalized_overlap) then
1232 call propagation_ops_elec_kick_generalized_overlap(namespace, space, gr, st, hm)
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)
1235 else
1236 call kick_apply(space, gr, st, td%ions_dyn, ions, hm%kick, hm%psolver, hm%kpoints, pcm = hm%pcm)
1237 end if
1238 call td_write_kick(outp, namespace, space, gr, hm%kick, ions, 0)
1239
1240 !We activate the sprial BC only after the kick
1241 if (gr%der%boundaries%spiralBC) then
1242 gr%der%boundaries%spiral = .true.
1243 end if
1244 end if
1245 call hm%ks_pot%run_zero_iter(td%tr%vks_old)
1246
1247 if (any(outp%output_interval > 0)) then
1248 call td_write_data(td%write_handler)
1249 call td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, 0)
1250 end if
1251
1252 pop_sub(td_run_zero_iter)
1253 end subroutine td_run_zero_iter
1254
1255
1256 ! ---------------------------------------------------------
1258 subroutine td_read_coordinates(td, namespace, ions)
1259 type(td_t), intent(in) :: td
1260 type(namespace_t), intent(in) :: namespace
1261 type(ions_t), intent(inout) :: ions
1262
1263 integer :: iatom, iter, iunit
1264
1265 push_sub(td_read_coordinates)
1266
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."
1271 call messages_warning(2, namespace=namespace)
1272 pop_sub(td_read_coordinates)
1273 return
1274 end if
1275
1276 call io_skip_header(iunit)
1277 do iter = 0, td%iter - 1
1278 read(iunit, *) ! skip previous iterations... sorry, but no portable seek in Fortran
1279 end do
1280 read(iunit, '(32x)', advance='no') ! skip the time index.
1282 do iatom = 1, ions%natoms
1283 read(iunit, '(3es24.16)', advance='no') ions%pos(:, iatom)
1284 ions%pos(:, iatom) = units_to_atomic(units_out%length, ions%pos(:, iatom))
1285 end do
1286 do iatom = 1, ions%natoms
1287 read(iunit, '(3es24.16)', advance='no') ions%vel(:, iatom)
1288 ions%vel(:, iatom) = units_to_atomic(units_out%velocity, ions%vel(:, iatom))
1289 end do
1290 do iatom = 1, ions%natoms
1291 read(iunit, '(3es24.16)', advance='no') ions%tot_force(:, iatom)
1292 ions%tot_force(:, iatom) = units_to_atomic(units_out%force, ions%tot_force(:, iatom))
1293 end do
1294
1295 call io_close(iunit)
1296
1297 pop_sub(td_read_coordinates)
1298 end subroutine td_read_coordinates
1299
1300 ! ---------------------------------------------------------
1301 subroutine td_dump(td, namespace, space, gr, st, hm, ks, ext_partners, iter, ierr)
1302 type(td_t), intent(in) :: td
1303 type(namespace_t), intent(in) :: namespace
1304 class(space_t), intent(in) :: space
1305 type(grid_t), intent(in) :: gr
1306 type(states_elec_t), intent(in) :: st
1307 type(hamiltonian_elec_t), intent(in) :: hm
1308 type(v_ks_t), intent(in) :: ks
1309 type(partner_list_t), intent(in) :: ext_partners
1310 integer, intent(in) :: iter
1311 integer, intent(out) :: ierr
1312
1313 type(gauge_field_t), pointer :: gfield
1314 integer :: err, err2
1315
1316 push_sub(td_dump)
1317
1318 ierr = 0
1319
1320 if (td%restart_dump%skip()) then
1321 pop_sub(td_dump)
1322 return
1323 end if
1324
1325 message(1) = "Debug: Writing td restart."
1326 call messages_info(1, namespace=namespace, debug_only=.true.)
1327
1328 ! first write resume file
1329 call states_elec_dump(td%restart_dump, space, st, gr, hm%kpoints, err, iter=iter)
1330 if (err /= 0) ierr = ierr + 1
1331
1332 call states_elec_dump_rho(td%restart_dump, st, gr, ierr, iter=iter)
1333 if (err /= 0) ierr = ierr + 1
1334
1335 if (hm%lda_u_level /= dft_u_none) then
1336 call lda_u_dump(td%restart_dump, namespace, hm%lda_u, st, gr, err)
1337 if (err /= 0) ierr = ierr + 1
1338 end if
1339
1340 call potential_interpolation_dump(td%tr%vks_old, td%restart_dump, gr, st%d%nspin, err2)
1341 if (err2 /= 0) ierr = ierr + 2
1342
1343 call pes_dump(td%pesv, namespace, td%restart_dump, st, gr, err)
1344 if (err /= 0) ierr = ierr + 4
1345
1346 ! Gauge field restart
1347 gfield => list_get_gauge_field(ext_partners)
1348 if(associated(gfield)) then
1349 call gauge_field_dump(td%restart_dump, gfield, err)
1350 if (err /= 0) ierr = ierr + 8
1351 end if
1352
1353 if (gr%der%boundaries%spiralBC) then
1354 call states_elec_dump_spin(td%restart_dump, st, err)
1355 if (err /= 0) ierr = ierr + 8
1356 end if
1357
1358 call ks%v_ks_photons%restart_dump(td%restart_dump, gr, td%dt, ierr)
1359
1360 if (allocated(st%frozen_rho)) then
1361 call states_elec_dump_frozen(td%restart_dump, space, st, gr, err)
1362 end if
1363 if (err /= 0) ierr = ierr + 64
1364
1365 if (td%ions_dyn%ions_move() .or. td%ions_dyn%cell_relax()) then
1366 call ion_dynamics_dump(td%ions_dyn, td%restart_dump, err)
1367 end if
1368 if (err /= 0) ierr = ierr + 128
1369
1370 message(1) = "Debug: Writing td restart done."
1371 call messages_info(1, namespace=namespace, debug_only=.true.)
1372
1373 pop_sub(td_dump)
1374 end subroutine td_dump
1375
1376 ! ---------------------------------------------------------
1377 subroutine td_load(restart, namespace, space, gr, st, hm, ext_partners, td, ks, ierr)
1378 type(restart_t), intent(in) :: restart
1379 type(namespace_t), intent(in) :: namespace
1380 class(space_t), intent(in) :: space
1381 type(grid_t), intent(in) :: gr
1382 type(states_elec_t), intent(inout) :: st
1383 type(hamiltonian_elec_t), intent(inout) :: hm
1384 type(partner_list_t), intent(in) :: ext_partners
1385 type(td_t), intent(inout) :: td
1386 type(v_ks_t), intent(inout) :: ks
1387 integer, intent(out) :: ierr
1388
1389 integer :: err, err2
1390 type(gauge_field_t), pointer :: gfield
1391 push_sub(td_load)
1392
1393 ierr = 0
1394
1395 if (restart%skip()) then
1396 ierr = -1
1397 pop_sub(td_load)
1398 return
1399 end if
1400
1401 message(1) = "Debug: Reading td restart."
1402 call messages_info(1, namespace=namespace, debug_only=.true.)
1403
1404 ! Read states
1405 call states_elec_load(restart, namespace, space, st, gr, hm%kpoints, st%restart_fixed_occ, &
1406 err, iter=td%iter, label = ": td")
1407 if (err /= 0) then
1408 ierr = ierr + 1
1409 end if
1410
1411 ! read potential from previous interactions
1412 call potential_interpolation_load(td%tr%vks_old, namespace, restart, gr, st%d%nspin, err2)
1413 if (err2 /= 0) ierr = ierr + 2
1414
1415 if (hm%lda_u_level /= dft_u_none) then
1416 call lda_u_load(restart, hm%lda_u, st, hm%energy%dft_u, err)
1417 if (err /= 0) ierr = ierr + 1
1418 end if
1419
1420
1421 ! read PES restart
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
1425 end if
1426
1427 ! Gauge field restart
1428 gfield => list_get_gauge_field(ext_partners)
1429 if (associated(gfield)) then
1430 call gauge_field_load(restart, gfield, err)
1431 if (err /= 0) then
1432 ierr = ierr + 8
1433 else
1434 call hm%update(gr, namespace, space, ext_partners, time = td%dt*td%iter)
1435 end if
1436 end if
1437
1438 ! add photon restart
1439 call ks%v_ks_photons%restart_load(restart, gr, space, ierr)
1440
1441 if (gr%der%boundaries%spiralBC) then
1442 call states_elec_load_spin(restart, st, err)
1443 !To ensure back compatibility, if the file is not present, we use the
1444 !current states to get the spins
1445 if (err /= 0) call states_elec_fermi(st, namespace, gr)
1446 end if
1447
1448 if (td%ions_dyn%is_active()) then
1449 call ion_dynamics_load(td%ions_dyn, restart, err)
1450 if (err /= 0) ierr = ierr + 64
1451 end if
1452
1453 message(1) = "Debug: Reading td restart done."
1454 call messages_info(1, namespace=namespace, debug_only=.true.)
1455
1456 pop_sub(td_load)
1457 end subroutine td_load
1458 ! ---------------------------------------------------------
1459 subroutine td_load_frozen(namespace, restart, space, mesh, st, hm, ierr)
1460 type(namespace_t), intent(in) :: namespace
1461 type(restart_t), intent(in) :: restart
1462 class(space_t), intent(in) :: space
1463 class(mesh_t), intent(in) :: mesh
1464 type(states_elec_t), intent(inout) :: st
1465 type(hamiltonian_elec_t), intent(inout) :: hm
1466 integer, intent(out) :: ierr
1467
1468 push_sub(td_load_frozen)
1469
1470 ierr = 0
1471
1472 if (restart%skip()) then
1473 ierr = -1
1474 pop_sub(td_load_frozen)
1475 return
1476 end if
1477
1478 message(1) = "Debug: Reading td frozen restart."
1479 call messages_info(1, namespace=namespace, debug_only=.true.)
1480
1481 safe_allocate(st%frozen_rho(1:mesh%np, 1:st%d%nspin))
1482 if (family_is_mgga(hm%xc%family)) then
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))
1486 end if
1487
1488 call states_elec_load_frozen(restart, space, st, mesh, ierr)
1489
1490 message(1) = "Debug: Reading td frozen restart done."
1491 call messages_info(1, namespace=namespace, debug_only=.true.)
1492
1493 pop_sub(td_load_frozen)
1494 end subroutine td_load_frozen
1495
1496 ! ---------------------------------------------------------
1497 logical function td_get_from_scratch(td)
1498 type(td_t), intent(in) :: td
1499
1500 push_sub(td_get_from_scratch)
1501
1502 td_get_from_scratch = td%from_scratch
1503
1504 pop_sub(td_get_from_scratch)
1505 end function td_get_from_scratch
1506
1507 ! ---------------------------------------------------------
1508 subroutine td_set_from_scratch(td, from_scratch)
1509 type(td_t), intent(inout) :: td
1510 logical, intent(in) :: from_scratch
1511
1512 push_sub(td_set_from_scratch)
1513
1514 td%from_scratch = from_scratch
1515
1516 pop_sub(td_set_from_scratch)
1517 end subroutine td_set_from_scratch
1518end module td_oct_m
1519
1520!! Local Variables:
1521!! mode: f90
1522!! coding: utf-8
1523!! End:
Prints out to iunit a message in the form: ["InputVariable" = value] where "InputVariable" is given b...
Definition: messages.F90:158
integer, parameter, public mask_absorbing
Module implementing boundary conditions in Octopus.
Definition: boundaries.F90:101
This module handles the calculation mode.
This module implements a calculator for the density and defines related functions.
Definition: density.F90:99
subroutine, public states_elec_freeze_adjust_qtot(st)
Definition: density.F90:1050
subroutine, public states_elec_freeze_redistribute_states(st, namespace, mesh, mc, nn)
Definition: density.F90:1022
subroutine, public density_calc(st, gr, density, istin, ep, vnl, phase)
Computes the density from the orbitals in st.
Definition: density.F90:839
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:887
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
Definition: epot.F90:152
integer, parameter, public fully_relativistic_zora
Definition: epot.F90:152
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:319
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
Definition: global.F90:173
real(real64), parameter, public m_epsilon
Definition: global.F90:189
real(real64), parameter, public m_one
Definition: global.F90:174
This module implements the underlying real-space grid.
Definition: grid.F90:96
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:93
subroutine, public io_close(iunit, grp)
Definition: io.F90:444
subroutine, public io_skip_header(iunit)
Definition: io.F90:623
character(len=max_path_len) function, public io_workpath(path, namespace)
construct path name from given name and namespace
Definition: io.F90:295
subroutine, public io_debug_on_the_fly(namespace)
check if debug mode should be enabled or disabled on the fly
Definition: io.F90:512
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
Definition: io.F90:379
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:1117
subroutine, public lasers_set_nondipole_parameters(this, ndfield, nd_integration_time)
Set parameters for nondipole SFA calculation.
Definition: lasers.F90:737
logical function, public lasers_with_nondipole_field(lasers)
Check if a nondipole SFA correction should be computed for the given laser.
Definition: lasers.F90:724
subroutine, public laser_write_info(lasers, namespace, dt, max_iter, iunit)
Definition: lasers.F90:917
subroutine, public lda_u_dump(restart, namespace, this, st, mesh, ierr)
Definition: lda_u_io.F90:618
subroutine, public lda_u_write_u(this, iunit, namespace)
Definition: lda_u_io.F90:504
subroutine, public lda_u_load(restart, this, st, dftu_energy, ierr, occ_only, u_only)
Definition: lda_u_io.F90:699
subroutine, public lda_u_write_v(this, iunit, namespace)
Definition: lda_u_io.F90:552
integer, parameter, public dft_u_none
Definition: lda_u.F90:188
subroutine, public lda_u_init(this, namespace, space, level, gr, ions, st, mc, kpoints)
Definition: lda_u.F90:270
subroutine, public lda_u_update_occ_matrices(this, namespace, mesh, st, phase, energy, aug_overlap)
Definition: lda_u.F90:915
subroutine, public lda_u_freeze_occ(this)
Definition: lda_u.F90:1005
subroutine, public lda_u_freeze_u(this)
Definition: lda_u.F90:1012
subroutine, public lda_u_end(this)
Definition: lda_u.F90:667
integer, parameter, public dft_u_acbn0
Definition: lda_u.F90:188
This module implements fully polymorphic linked lists, and some specializations thereof.
Definition: linked_list.F90:84
System information (time, memory, sysname)
Definition: loct.F90:94
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:97
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
Definition: messages.F90:878
subroutine, public messages_not_implemented(feature, namespace)
Definition: messages.F90:1048
character(len=512), private msg
Definition: messages.F90:143
subroutine, public messages_warning(no_lines, all_nodes, namespace)
Definition: messages.F90:501
subroutine, public messages_obsolete_variable(namespace, name, rep)
Definition: messages.F90:980
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:138
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:386
subroutine, public messages_input_error(namespace, var, details, row, column)
Definition: messages.F90:671
subroutine, public messages_experimental(name, namespace)
Definition: messages.F90:1020
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:570
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:124
type(namespace_t), public global_namespace
Definition: namespace.F90:112
this module contains the low-level part of the output system
Definition: output_low.F90:94
this module contains the output system
Definition: output.F90:94
logical function, public parse_is_defined(namespace, name)
Definition: parser.F90:440
subroutine, public pes_calc(pes, namespace, space, mesh, st, dt, iter, der, kpoints, ext_partners, stopping)
Definition: pes.F90:248
subroutine, public pes_init(pes, namespace, space, mesh, box, st, save_iter, kpoints, abs_boundaries, ext_partners, max_iter, dt)
Definition: pes.F90:154
subroutine, public pes_output(pes, namespace, space, gr, st, iter, outp, dt, ions)
Definition: pes.F90:274
subroutine, public pes_init_write(pes, mesh, st, namespace)
Definition: pes.F90:378
subroutine, public pes_end(pes)
Definition: pes.F90:234
subroutine, public pes_load(pes, namespace, restart, st, ierr)
Definition: pes.F90:338
subroutine, public pes_dump(pes, namespace, restart, st, mesh, ierr)
Definition: pes.F90:298
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...
Definition: profiling.F90:122
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
Definition: profiling.F90:672
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
Definition: profiling.F90:604
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.
Definition: propagator.F90:96
integer, parameter, public restart_gs
Definition: restart.F90:133
integer, parameter, public restart_type_dump
Definition: restart.F90:161
logical function, public clean_stop(mpi_grp)
returns true if a file named stop exists
Definition: restart.F90:315
integer, parameter, public restart_td
Definition: restart.F90:133
integer, parameter, public restart_type_load
Definition: restart.F90:161
subroutine, public scf_set_lower_bound_is_known(scf, known_lower_bound)
Set the flag lower_bound_is_known.
Definition: scf.F90:1724
subroutine, public scf_init(scf, namespace, gr, ions, st, mc, hm, space)
Definition: scf.F90:239
subroutine, public scf_end(scf)
Definition: scf.F90:565
subroutine, public scissor_init(this, namespace, space, st, mesh, kpoints, phase, gap, mc)
Definition: scissor.F90:142
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.
Definition: stress.F90:97
subroutine, public stress_calculate(namespace, gr, hm, st, ions, ks, ext_partners)
This computes the total stress on the lattice.
Definition: stress.F90:167
Definition: td.F90:93
subroutine, public td_init_with_wavefunctions(td, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, outp, dmp, from_scratch)
Definition: td.F90:910
subroutine, public td_end(td)
Definition: td.F90:634
subroutine, public td_load_restart_from_gs(td, namespace, space, mc, gr, ext_partners, st, ks, hm)
Definition: td.F90:1233
subroutine td_print_message(td, namespace, ions, hm, iter, scsteps, etime)
Definition: td.F90:878
subroutine td_run_zero_iter(td, namespace, space, gr, ions, st, ks, hm, ext_partners, outp, mc, dmp)
Definition: td.F90:1282
subroutine, public td_allocate_wavefunctions(td, namespace, mc, gr, ions, st, hm, space)
Definition: td.F90:569
subroutine, public td_init(td, namespace, space, gr, ions, st, ks, hm, ext_partners, outp, dmp)
Definition: td.F90:217
logical function, public td_get_from_scratch(td)
Definition: td.F90:1570
subroutine, public td_init_run(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, dmp, from_scratch)
Definition: td.F90:514
subroutine td_load_frozen(namespace, restart, space, mesh, st, hm, ierr)
Definition: td.F90:1532
subroutine td_print_header(namespace)
Definition: td.F90:779
subroutine, public td_run(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, dmp, from_scratch)
Definition: td.F90:674
integer, parameter, public bo
Definition: td.F90:180
subroutine td_load(restart, namespace, space, gr, st, hm, ext_partners, td, ks, ierr)
Definition: td.F90:1450
subroutine, public td_set_from_scratch(td, from_scratch)
Definition: td.F90:1581
subroutine, public td_dump(td, namespace, space, gr, st, hm, ks, ext_partners, iter, ierr)
Definition: td.F90:1374
subroutine td_read_coordinates(td, namespace, ions)
reads the pos and vel from coordinates file
Definition: td.F90:1331
subroutine, public td_init_gaugefield(td, namespace, gr, st, ks, hm, ext_partners, space)
Definition: td.F90:603
subroutine td_update_elapsed_time(etime)
Definition: td.F90:899
subroutine, public td_check_point(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, iter, scsteps, etime, dmp, stopping, from_scratch)
Definition: td.F90:794
subroutine, public td_load_restart_from_td(td, namespace, space, mc, gr, ext_partners, st, ks, hm, from_scratch)
Definition: td.F90:1197
subroutine td_init_ions_and_forces(td, namespace, space, gr, ions, ext_partners, st, ks, hm, outp)
Definition: td.F90:1151
subroutine, public td_end_run(td, st, hm, dmp)
Definition: td.F90:649
subroutine, public td_write_iter(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, kick, ks, dt, iter, mc, recalculate_gs, dmp)
Definition: td_write.F90:1076
subroutine, public td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, dt)
Definition: td_write.F90:1295
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.
Definition: td_write.F90:363
subroutine, public td_write_data(writ)
Definition: td_write.F90:1261
subroutine, public td_write_kick(outp, namespace, space, mesh, kick, ions, iter)
Definition: td_write.F90:325
subroutine, public td_write_end(writ)
Definition: td_write.F90:1029
integer, parameter, public out_separate_forces
Definition: td_write.F90:187
type(type_t), parameter, public type_cmplx
Definition: types.F90:114
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
Definition: unit.F90:111
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)
Definition: v_ks.F90:1554
subroutine, public v_ks_calculate_current(this, calc_cur)
Definition: v_ks.F90:1565
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:789
This module provides a simple timer class which can be used to trigger the writing of a restart file ...
Definition: walltimer.F90:100
logical function, public walltimer_alarm(comm, print)
indicate whether time is up
Definition: walltimer.F90:310
real(real64) function, public walltimer_get_start_time()
Return the walltimer start time.
Definition: walltimer.F90:384
logical function, public restart_walltime_period_alarm(comm)
Definition: walltimer.F90:352
Definition: xc.F90:97
pure logical function, public family_is_mgga(family, only_collinear)
Is the xc function part of the mGGA family.
Definition: xc.F90:697
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:716
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:148
Describes mesh distribution to nodes.
Definition: mesh.F90:165
Stores all communicators and groups.
Definition: multicomm.F90:185
output handler class
Definition: output_low.F90:143
The states_elec_t class contains all electronic wave functions.
int true(void)