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
30 use system_oct_m
31
32 implicit none
33
34 private
35 public :: &
38
44 type, extends(algorithm_t), abstract :: minimizer_algorithm_t
45 private
46 class(system_t), pointer, public :: system
47 integer, public :: max_iter
48 logical, public :: converged = .false.
49 contains
50 ! Below are the list of operations that needs to be implemented
51 procedure :: do_operation => minimizer_algorithm_do_operation
52 procedure :: finished => minimizer_algorithm_finished
53 procedure :: init_iteration_counters => minimizer_algorithm_init_iteration_counters
54 procedure :: write_output_header => minimizer_algorithm_write_output_header
55 procedure :: continues_after_finished => minimizer_continues_after_finished
57
58contains
59
62 logical function minimizer_algorithm_do_operation(this, operation) result(done)
63 class(minimizer_algorithm_t), intent(inout) :: this
64 type(algorithmic_operation_t), intent(in) :: operation
65
66 ! Nothing done yet here
67 done = .false.
68
70
71 ! ---------------------------------------------------------
74 logical function minimizer_algorithm_finished(this) result(finished)
75 class(minimizer_algorithm_t), intent(in) :: this
76
77 type(iteration_counter_t) :: iter
78
79 iter = this%system%iteration
80 finished = iter%value() > this%max_iter
81
82 finished = finished .or. this%converged
84
85 ! ---------------------------------------------------------
91 class(minimizer_algorithm_t), intent(inout) :: this
92
93 this%iteration = iteration_counter_t()
94 this%system%iteration = iteration_counter_t()
95
97
98
100 class(minimizer_algorithm_t), intent(in) :: this
101
103
104 call messages_print_with_emphasis(msg="Multi-system minimizer", namespace=this%system%namespace)
105 call messages_print_with_emphasis(namespace=this%system%namespace)
106
109
110
111 ! The GS algorithms need to keep going even when they are finished,
112 ! otherwise other systems would get stuck at the update coupling step
113 logical function minimizer_continues_after_finished(this)
114 class(minimizer_algorithm_t), intent(in) :: this
115
117
119
122
124
125
126!! Local Variables:
127!! mode: f90
128!! coding: utf-8
129!! End:
This module implements the basic elements defining algorithms.
Definition: algorithm.F90:141
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
Definition: messages.F90:930
character(len=512), private msg
Definition: messages.F90:165
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
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:118
An algorithm is a list of algorithmic operations executed sequentially.
Definition: algorithm.F90:200
This class implements the iteration counter used by the multisystem algorithms. As any iteration coun...
Abstract class implementing minimizers.
int true(void)