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
53 procedure :: finished => minimizer_algorithm_finished
54
55 procedure :: init_iteration_counters => minimizer_algorithm_init_iteration_counters
56
57 procedure :: write_output_header => minimizer_algorithm_write_output_header
58
59 procedure :: continues_after_finished => minimizer_continues_after_finished
60
62
63contains
64
67 logical function minimizer_algorithm_do_operation(this, operation) result(done)
68 class(minimizer_algorithm_t), intent(inout) :: this
69 type(algorithmic_operation_t), intent(in) :: operation
70
71 ! Nothing done yet here
72 done = .false.
73
75
76 ! ---------------------------------------------------------
79 logical function minimizer_algorithm_finished(this) result(finished)
80 class(minimizer_algorithm_t), intent(in) :: this
81
82 type(iteration_counter_t) :: iter
83
84 iter = this%system%iteration
85 finished = iter%value() > this%max_iter
86
87 finished = finished .or. this%converged
89
90 ! ---------------------------------------------------------
96 class(minimizer_algorithm_t), intent(inout) :: this
97
98 this%iteration = iteration_counter_t()
99 this%system%iteration = iteration_counter_t()
100
102
103
105 class(minimizer_algorithm_t), intent(in) :: this
106
108
109 call messages_print_with_emphasis(msg="Multi-system minimizer", namespace=this%system%namespace)
110 call messages_print_with_emphasis(namespace=this%system%namespace)
111
114
115
116 ! The GS algorithms need to keep going even when they are finished,
117 ! otherwise other systems would get stuck at the update coupling step
118 logical function minimizer_continues_after_finished(this)
119 class(minimizer_algorithm_t), intent(in) :: this
120
122
124
127
129
130
131!! Local Variables:
132!! mode: f90
133!! coding: utf-8
134!! 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:920
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)