Octopus
minimizer_algorithm.F90
Go to the documentation of this file.
1!! Copyright (C) 2024 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
25 use debug_oct_m
26 use global_oct_m
28 use loct_oct_m
31 use system_oct_m
33
34 implicit none
35
36 private
37 public :: &
40
46 type, extends(algorithm_t), abstract :: minimizer_algorithm_t
47 private
48 class(system_t), pointer, public :: system
49 integer, public :: max_iter
50 logical, public :: converged = .false.
51 contains
52 ! Below are the list of operations that needs to be implemented
53 procedure :: do_operation => minimizer_algorithm_do_operation
54
55 procedure :: finished => minimizer_algorithm_finished
56
57 procedure :: init_iteration_counters => minimizer_algorithm_init_iteration_counters
58
59 procedure :: write_output_header => minimizer_algorithm_write_output_header
60
61 procedure :: continues_after_finished => minimizer_continues_after_finished
62
63 procedure :: print_speed => minimizer_algorithm_print_speed
65
66contains
67
70 logical function minimizer_algorithm_do_operation(this, operation) result(done)
71 class(minimizer_algorithm_t), intent(inout) :: this
72 type(algorithmic_operation_t), intent(in) :: operation
73
74 ! Nothing done yet here
75 done = .false.
76
78
79 ! ---------------------------------------------------------
82 logical function minimizer_algorithm_finished(this) result(finished)
83 class(minimizer_algorithm_t), intent(in) :: this
84
85 type(iteration_counter_t) :: iter
86
87 iter = this%system%iteration
88 finished = iter%value() > this%max_iter
89
90 finished = finished .or. this%converged
92
93 ! ---------------------------------------------------------
99 class(minimizer_algorithm_t), intent(inout) :: this
100
101 this%iteration = iteration_counter_t()
102 this%system%iteration = iteration_counter_t()
103
105
106
108 class(minimizer_algorithm_t), intent(in) :: this
109
111
112 call messages_print_with_emphasis(msg="Multi-system minimizer", namespace=this%system%namespace)
113 call messages_print_with_emphasis(namespace=this%system%namespace)
114
117
119 ! The GS algorithms need to keep going even when they are finished,
120 ! otherwise other systems would get stuck at the update coupling step
121 logical function minimizer_continues_after_finished(this)
122 class(minimizer_algorithm_t), intent(in) :: this
123
125
127
130
131 ! ---------------------------------------------------------
133 !
134 subroutine minimizer_algorithm_print_speed(this)
135 class(minimizer_algorithm_t), intent(in) :: this
136 real(real64) :: wall_time, simulation_time, speed_per_day
137
138 ! Output propagation speed in iterations/day
139 wall_time = loct_clock() - walltimer_get_start_time()
140 simulation_time = this%iteration%value(elapsed=.true.)
141 speed_per_day = simulation_time / (wall_time / 86400.0_real64)
142 write(message(1), '(a,f10.3,a)') 'Propagation speed: ', speed_per_day, ' iterations/day'
143 write(message(2), '(a)') ''
144 call messages_info(2, namespace=this%system%namespace)
149
150!! Local Variables:
151!! mode: f90
152!! coding: utf-8
153!! End:
This module implements the basic elements defining algorithms.
Definition: algorithm.F90:143
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
Definition: messages.F90:904
character(len=512), private msg
Definition: messages.F90:167
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:162
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:600
This module implements the basic minimizer framework.
subroutine minimizer_algorithm_init_iteration_counters(this)
Initialize the minimizer and system clocks.
subroutine minimizer_algorithm_write_output_header(this)
logical function, public minimizer_algorithm_finished(this)
indicate whether a minimizer has reached the final time
subroutine minimizer_algorithm_print_speed(this)
print iteration speed, i.e., fs/day of wall clock time
logical function minimizer_continues_after_finished(this)
logical function minimizer_algorithm_do_operation(this, operation)
Try to perform one operation of the algorithm. Return .true. if sucessful.
This module implements the abstract system type.
Definition: system.F90:120
This module provices a simple timer class which can be used to trigger the writing of a restart file ...
Definition: walltimer.F90:123
real(real64) function, public walltimer_get_start_time()
Return the walltimer start time.
Definition: walltimer.F90:407
An algorithm is a list of algorithmic operations executed sequentially.
Definition: algorithm.F90:202
This class implements the iteration counter used by the multisystem algorithms. As any iteration coun...
Abstract class implementing minimizers.
int true(void)