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