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