Octopus
time_dependent.F90
Go to the documentation of this file.
1!! Copyright (C) 2019-2020 M. Oliveira, H. Appel, N. Tancogne-Dejean
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
22 use debug_oct_m
24 use global_oct_m
29 use parser_oct_m
32 use system_oct_m
33 use td_oct_m
35
36 implicit none
37
38 private
39 public :: time_dependent_run
40
41contains
42
43 ! ---------------------------------------------------------
44 subroutine time_dependent_run(system, from_scratch)
45 class(*), intent(inout) :: system
46 logical, intent(inout) :: from_scratch
47
48 push_sub(time_dependent_run)
49
50 select type (system)
51 class is (multisystem_basic_t)
52 call time_dependent_run_multisystem(system, from_scratch)
53 type is (electrons_t)
54 call time_dependent_run_legacy(system, from_scratch)
55 end select
56
57 pop_sub(time_dependent_run)
58 end subroutine time_dependent_run
59
60 ! ---------------------------------------------------------
61 subroutine time_dependent_run_multisystem(systems, from_scratch)
62 class(multisystem_basic_t), intent(inout) :: systems
63 logical, intent(in) :: from_scratch
64
65 logical :: trigger_restart, stop_code, stop_loop
66 logical :: restart_read
67
69
70 call multisystem_debug_init("debug/multisystem_propagation.log", global_namespace, systems%grp)
71
72 call messages_write('Info: Running Multi-system time evolution')
73 call messages_info(namespace=systems%namespace)
74
75 ! Read restart files or set initial conditions
76 call systems%init_iteration_counters()
77 if (.not. from_scratch) then
78 restart_read = systems%restart_read()
79 else
80 restart_read = .false.
81 end if
82 if (restart_read) then
83 message(1) = "Successfully read restart data for all system."
84 call messages_info(1, namespace=systems%namespace)
85 else
86 call systems%initial_conditions()
87 end if
88
89 call systems%propagation_start()
90
91 call multisystem_debug_write_marker(systems%namespace, event_marker_t("propagation_start"))
92
93 ! The full TD loop
94 stop_loop = .false.
95 do while (.not. systems%algorithm_finished())
96 ! Execute algorithm until next barrier
97 call systems%execute_algorithm()
98
99 ! determine cases in which to trigger writing restart files
100 stop_code = clean_stop(systems%grp%comm) .or. walltimer_alarm(systems%grp%comm)
101 trigger_restart = stop_code .or. restart_walltime_period_alarm(systems%grp%comm)
102
103 if (trigger_restart .and. .not. stop_loop) then
104 call systems%start_barrier(systems%next_time_on_largest_dt(), barrier_restart)
105 stop_loop = stop_code
106 trigger_restart = .false.
107 end if
108 if (systems%arrived_at_barrier(barrier_restart)) then
109 call systems%restart_write()
110 call systems%end_barrier(barrier_restart)
111 if (stop_loop) exit
112 end if
113 end do
115 if (systems%algorithm_finished()) then
116 call systems%restart_write()
117 end if
118
119 call multisystem_debug_write_marker(systems%namespace, event_marker_t("propagation_finish"))
120
121 call systems%propagation_finish()
122
124
126 end subroutine time_dependent_run_multisystem
127
128 ! ---------------------------------------------------------
129 subroutine time_dependent_run_legacy(electrons, from_scratch)
130 class(electrons_t), intent(inout) :: electrons
131 logical, intent(inout) :: from_scratch
132
134
135 call td_init(electrons%td, electrons%namespace, electrons%space, electrons%gr, electrons%ions, electrons%st, electrons%ks, &
136 electrons%hm, electrons%ext_partners, electrons%outp)
137 call td_init_run(electrons%td, electrons%namespace, electrons%mc, electrons%gr, electrons%ions, electrons%st, electrons%ks, &
138 electrons%hm, electrons%ext_partners, electrons%outp, electrons%space, from_scratch)
139 call td_run(electrons%td, electrons%namespace, electrons%mc, electrons%gr, electrons%ions, electrons%st, electrons%ks, &
140 electrons%hm, electrons%ext_partners, electrons%outp, electrons%space, from_scratch)
141 call td_end_run(electrons%td, electrons%st, electrons%hm)
142 call td_end(electrons%td)
143
145 end subroutine time_dependent_run_legacy
146
147end module time_dependent_oct_m
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
This module implements the basic mulsisystem class, a container system for other systems.
This module implements the multisystem debug functionality.
subroutine, public multisystem_debug_write_marker(system_namespace, event)
subroutine, public multisystem_debug_init(filename, namespace, group)
subroutine, public multisystem_debug_end()
type(namespace_t), public global_namespace
Definition: namespace.F90:132
logical function, public clean_stop(comm)
returns true if a file named stop exists
Definition: restart.F90:274
This module implements the abstract system type.
Definition: system.F90:118
integer, parameter, public barrier_restart
Definition: system.F90:165
Definition: td.F90:114
subroutine, public td_end(td)
Definition: td.F90:610
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_run(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, from_scratch)
Definition: td.F90:645
subroutine, public td_init_run(td, namespace, mc, gr, ions, st, ks, hm, ext_partners, outp, space, from_scratch)
Definition: td.F90:493
subroutine time_dependent_run_multisystem(systems, from_scratch)
subroutine time_dependent_run_legacy(electrons, from_scratch)
subroutine, public time_dependent_run(system, from_scratch)
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
logical function, public restart_walltime_period_alarm(comm)
Definition: walltimer.F90:343
Class describing the electron system.
Definition: electrons.F90:214
Container class for lists of system_oct_m::system_t.