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