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