Octopus
propagator_data_classical_particles.F90
Go to the documentation of this file.
1!! Copyright (C) 2021 S. Ohlmann, I. Albar, A. Obzhirov, A. Geondzhian, M. Lawan
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
23 use debug_oct_m
24 use global_oct_m
25 use io_oct_m
34
35 implicit none
36
37 private
38 public :: &
40
41 type :: propagator_data_t
43 real(real64), allocatable :: acc(:,:)
44 real(real64), allocatable :: prev_acc(:,:,:)
45 real(real64), allocatable :: save_pos(:,:)
46 real(real64), allocatable :: save_vel(:,:)
47 real(real64), allocatable :: prev_tot_force(:,:)
48 real(real64), allocatable :: prev_pos(:,:,:)
49 real(real64), allocatable :: prev_vel(:,:,:)
50 real(real64), allocatable :: hamiltonian_elements(:,:)
51 logical :: initialized = .false.
52 contains
53 procedure :: restart_write => propagator_data_restart_write
54 procedure :: restart_read => propagator_data_restart_read
55 procedure :: initialize => propagator_data_initialize
56 procedure :: end => propagator_data_end
57 procedure :: propagator_data_copy
58 generic :: assignment(=) => propagator_data_copy
59 end type propagator_data_t
60
61contains
62 ! ---------------------------------------------------------
63 subroutine propagator_data_restart_write(this, namespace, prop)
64 class(propagator_data_t), intent(inout) :: this
65 type(namespace_t), intent(in) :: namespace
66 class(algorithm_t), intent(in) :: prop
67
68 type(restart_basic_t) :: restart
69 integer :: restart_file_unit
70 integer :: ierr
71
73
74
75 call restart%init(namespace, restart_td, restart_type_dump, ierr)
76
77 restart_file_unit = restart%open('restart_classical_particles_propagation')
78 if (restart%do_i_write()) then
79
80 select type(prop)
81 type is (propagator_verlet_t)
82 write(restart_file_unit,*) this%acc(:,:)
83 write(restart_file_unit,*) this%prev_acc(:,:,:)
84 type is (propagator_beeman_t)
85 write(restart_file_unit,*) this%acc(:,:)
86 write(restart_file_unit,*) this%prev_acc(:,:,:)
87 if (prop%predictor_corrector) then
88 write(restart_file_unit,*) this%prev_tot_force(:,:)
89 write(restart_file_unit,*) this%save_vel(:,:)
90 write(restart_file_unit,*) this%save_pos(:,:)
91 end if
93 write(restart_file_unit,*) this%prev_vel(:,:,:)
94 write(restart_file_unit,*) this%prev_pos(:,:,:)
95 write(restart_file_unit,*) this%save_vel(:,:)
96 write(restart_file_unit,*) this%save_pos(:,:)
97 end select
98
99 end if
100 call restart%close(restart_file_unit)
101
102 call restart%end()
103
105 end subroutine propagator_data_restart_write
106
107 ! ---------------------------------------------------------
108 logical function propagator_data_restart_read(this, namespace, prop)
109 class(propagator_data_t), intent(inout) :: this
110 type(namespace_t), intent(in) :: namespace
111 class(algorithm_t), intent(in) :: prop
112
113 type(restart_basic_t) :: restart
114 integer :: restart_file_unit
115 integer :: ierr
118
119 call restart%init(namespace, restart_td, restart_type_load, ierr)
120 restart_file_unit = restart%open('restart_classical_particles_propagation')
121 if (restart_file_unit /= -1) then
122 select type(prop)
123 type is (propagator_verlet_t)
124 read(restart_file_unit,*) this%acc(:,:)
125 read(restart_file_unit,*) this%prev_acc(:,:,:)
126
127 type is (propagator_beeman_t)
128 read(restart_file_unit,*) this%acc(:,:)
129 read(restart_file_unit,*) this%prev_acc(:,:,:)
130 if (prop%predictor_corrector) then
131 read(restart_file_unit,*) this%prev_tot_force(:,:)
132 read(restart_file_unit,*) this%save_vel(:,:)
133 read(restart_file_unit,*) this%save_pos(:,:)
134 end if
136 read(restart_file_unit,*) this%prev_vel(:,:,:)
137 read(restart_file_unit,*) this%prev_pos(:,:,:)
138 read(restart_file_unit,*) this%save_vel(:,:)
139 read(restart_file_unit,*) this%save_pos(:,:)
140 end select
142 call restart%close(restart_file_unit)
144 else
145 ! error opening file
147 end if
149 call restart%end()
154 ! ---------------------------------------------------------
155 subroutine propagator_data_initialize(this, prop, dim, np)
156 class(propagator_data_t), intent(inout) :: this
157 class(algorithm_t), intent(in) :: prop
158 integer, intent(in) :: dim
159 integer, intent(in) :: np
160
162
163 if (.not. this%initialized) then
164 select type(prop)
165 type is (propagator_verlet_t)
166 safe_allocate(this%acc(1:dim, 1:np))
167 safe_allocate(this%prev_acc(1:dim, 1:np, 1))
168 type is (propagator_beeman_t)
169 if (prop%predictor_corrector) then
170 safe_allocate(this%save_pos(1:dim, 1:np))
171 safe_allocate(this%save_vel(1:dim, 1:np))
172 safe_allocate(this%prev_tot_force(1:dim, 1:np))
173 end if
174 safe_allocate(this%acc(1:dim, 1:np))
175 safe_allocate(this%prev_acc(1:dim, 1:np, 1:2))
177 safe_allocate(this%save_pos(1:dim, 1:np))
178 safe_allocate(this%save_vel(1:dim, 1:np))
179 safe_allocate(this%hamiltonian_elements(1:dim, 1:np))
180 safe_allocate(this%prev_pos(1:dim, 1:np, 1))
181 safe_allocate(this%prev_vel(1:dim, 1:np, 1))
182 end select
183 this%initialized = .true.
184 end if
185
187 end subroutine propagator_data_initialize
188
189 ! ---------------------------------------------------------
190 subroutine propagator_data_end(this)
191 class(propagator_data_t), intent(inout) :: this
192
193 push_sub(propagator_data_end)
194
195 safe_deallocate_a(this%acc)
196 safe_deallocate_a(this%prev_acc)
197 safe_deallocate_a(this%prev_tot_force)
198 safe_deallocate_a(this%save_pos)
199 safe_deallocate_a(this%save_vel)
200 safe_deallocate_a(this%hamiltonian_elements)
201 safe_deallocate_a(this%prev_pos)
202 safe_deallocate_a(this%prev_vel)
204 pop_sub(propagator_data_end)
205 end subroutine propagator_data_end
206
207 ! ---------------------------------------------------------
208 subroutine propagator_data_copy(this, prop_data_in)
209 class(propagator_data_t), intent(inout) :: this
210 class(propagator_data_t), intent(in) :: prop_data_in
211
212 push_sub(propagator_data_copy)
213
214 safe_allocate_source_a(this%acc, prop_data_in%acc)
215 safe_allocate_source_a(this%prev_acc, prop_data_in%prev_acc)
216 safe_allocate_source_a(this%save_pos, prop_data_in%save_pos)
217 safe_allocate_source_a(this%save_vel, prop_data_in%save_vel)
218 safe_allocate_source_a(this%prev_tot_force, prop_data_in%prev_tot_force)
219 safe_allocate_source_a(this%prev_pos, prop_data_in%prev_pos)
220 safe_allocate_source_a(this%prev_vel, prop_data_in%prev_vel)
221 safe_allocate_source_a(this%hamiltonian_elements, prop_data_in%hamiltonian_elements)
222
223 pop_sub(propagator_data_copy)
224 end subroutine propagator_data_copy
226
227!! Local Variables:
228!! mode: f90
229!! coding: utf-8
230!! End:
This module implements the basic elements defining algorithms.
Definition: algorithm.F90:143
Definition: io.F90:116
logical function propagator_data_restart_read(this, namespace, prop)
This module implements the basic propagator framework.
Definition: propagator.F90:119
integer, parameter, public restart_type_dump
Definition: restart.F90:183
integer, parameter, public restart_td
Definition: restart.F90:156
integer, parameter, public restart_type_load
Definition: restart.F90:183
An algorithm is a list of algorithmic operations executed sequentially.
Definition: algorithm.F90:202
Implements the Beeman propagator (with or without SCF)
Implements the implicit exponential midpoint propagator with predictor-corrector.
Implements a propagator for the velocity Verlet algorithm.
int true(void)